mutation.go 1.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/apikey"
  14. "wechat-api/ent/batchmsg"
  15. "wechat-api/ent/category"
  16. "wechat-api/ent/chatrecords"
  17. "wechat-api/ent/chatsession"
  18. "wechat-api/ent/contact"
  19. "wechat-api/ent/creditbalance"
  20. "wechat-api/ent/creditusage"
  21. "wechat-api/ent/custom_types"
  22. "wechat-api/ent/employee"
  23. "wechat-api/ent/employeeconfig"
  24. "wechat-api/ent/label"
  25. "wechat-api/ent/labelrelationship"
  26. "wechat-api/ent/labeltagging"
  27. "wechat-api/ent/message"
  28. "wechat-api/ent/messagerecords"
  29. "wechat-api/ent/msg"
  30. "wechat-api/ent/payrecharge"
  31. "wechat-api/ent/predicate"
  32. "wechat-api/ent/server"
  33. "wechat-api/ent/sopnode"
  34. "wechat-api/ent/sopstage"
  35. "wechat-api/ent/soptask"
  36. "wechat-api/ent/token"
  37. "wechat-api/ent/tutorial"
  38. "wechat-api/ent/usagedetail"
  39. "wechat-api/ent/usagestatisticday"
  40. "wechat-api/ent/usagestatistichour"
  41. "wechat-api/ent/usagestatisticmonth"
  42. "wechat-api/ent/usagetotal"
  43. "wechat-api/ent/whatsapp"
  44. "wechat-api/ent/whatsappchannel"
  45. "wechat-api/ent/workexperience"
  46. "wechat-api/ent/wpchatroom"
  47. "wechat-api/ent/wpchatroommember"
  48. "wechat-api/ent/wx"
  49. "wechat-api/ent/wxcard"
  50. "wechat-api/ent/wxcarduser"
  51. "wechat-api/ent/wxcardvisit"
  52. "wechat-api/ent/xunji"
  53. "wechat-api/ent/xunjiservice"
  54. "entgo.io/ent"
  55. "entgo.io/ent/dialect/sql"
  56. )
  57. const (
  58. // Operation types.
  59. OpCreate = ent.OpCreate
  60. OpDelete = ent.OpDelete
  61. OpDeleteOne = ent.OpDeleteOne
  62. OpUpdate = ent.OpUpdate
  63. OpUpdateOne = ent.OpUpdateOne
  64. // Node types.
  65. TypeAgent = "Agent"
  66. TypeAgentBase = "AgentBase"
  67. TypeAliyunAvatar = "AliyunAvatar"
  68. TypeAllocAgent = "AllocAgent"
  69. TypeApiKey = "ApiKey"
  70. TypeBatchMsg = "BatchMsg"
  71. TypeCategory = "Category"
  72. TypeChatRecords = "ChatRecords"
  73. TypeChatSession = "ChatSession"
  74. TypeContact = "Contact"
  75. TypeCreditBalance = "CreditBalance"
  76. TypeCreditUsage = "CreditUsage"
  77. TypeEmployee = "Employee"
  78. TypeEmployeeConfig = "EmployeeConfig"
  79. TypeLabel = "Label"
  80. TypeLabelRelationship = "LabelRelationship"
  81. TypeLabelTagging = "LabelTagging"
  82. TypeMessage = "Message"
  83. TypeMessageRecords = "MessageRecords"
  84. TypeMsg = "Msg"
  85. TypePayRecharge = "PayRecharge"
  86. TypeServer = "Server"
  87. TypeSopNode = "SopNode"
  88. TypeSopStage = "SopStage"
  89. TypeSopTask = "SopTask"
  90. TypeToken = "Token"
  91. TypeTutorial = "Tutorial"
  92. TypeUsageDetail = "UsageDetail"
  93. TypeUsageStatisticDay = "UsageStatisticDay"
  94. TypeUsageStatisticHour = "UsageStatisticHour"
  95. TypeUsageStatisticMonth = "UsageStatisticMonth"
  96. TypeUsageTotal = "UsageTotal"
  97. TypeWhatsapp = "Whatsapp"
  98. TypeWhatsappChannel = "WhatsappChannel"
  99. TypeWorkExperience = "WorkExperience"
  100. TypeWpChatroom = "WpChatroom"
  101. TypeWpChatroomMember = "WpChatroomMember"
  102. TypeWx = "Wx"
  103. TypeWxCard = "WxCard"
  104. TypeWxCardUser = "WxCardUser"
  105. TypeWxCardVisit = "WxCardVisit"
  106. TypeXunji = "Xunji"
  107. TypeXunjiService = "XunjiService"
  108. )
  109. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  110. type AgentMutation struct {
  111. config
  112. op Op
  113. typ string
  114. id *uint64
  115. created_at *time.Time
  116. updated_at *time.Time
  117. deleted_at *time.Time
  118. name *string
  119. role *string
  120. status *int
  121. addstatus *int
  122. background *string
  123. examples *string
  124. organization_id *uint64
  125. addorganization_id *int64
  126. dataset_id *string
  127. collection_id *string
  128. clearedFields map[string]struct{}
  129. wx_agent map[uint64]struct{}
  130. removedwx_agent map[uint64]struct{}
  131. clearedwx_agent bool
  132. token_agent map[uint64]struct{}
  133. removedtoken_agent map[uint64]struct{}
  134. clearedtoken_agent bool
  135. wa_agent map[uint64]struct{}
  136. removedwa_agent map[uint64]struct{}
  137. clearedwa_agent bool
  138. xjs_agent map[uint64]struct{}
  139. removedxjs_agent map[uint64]struct{}
  140. clearedxjs_agent bool
  141. key_agent map[uint64]struct{}
  142. removedkey_agent map[uint64]struct{}
  143. clearedkey_agent bool
  144. xjs_agent map[uint64]struct{}
  145. removedxjs_agent map[uint64]struct{}
  146. clearedxjs_agent bool
  147. done bool
  148. oldValue func(context.Context) (*Agent, error)
  149. predicates []predicate.Agent
  150. }
  151. var _ ent.Mutation = (*AgentMutation)(nil)
  152. // agentOption allows management of the mutation configuration using functional options.
  153. type agentOption func(*AgentMutation)
  154. // newAgentMutation creates new mutation for the Agent entity.
  155. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  156. m := &AgentMutation{
  157. config: c,
  158. op: op,
  159. typ: TypeAgent,
  160. clearedFields: make(map[string]struct{}),
  161. }
  162. for _, opt := range opts {
  163. opt(m)
  164. }
  165. return m
  166. }
  167. // withAgentID sets the ID field of the mutation.
  168. func withAgentID(id uint64) agentOption {
  169. return func(m *AgentMutation) {
  170. var (
  171. err error
  172. once sync.Once
  173. value *Agent
  174. )
  175. m.oldValue = func(ctx context.Context) (*Agent, error) {
  176. once.Do(func() {
  177. if m.done {
  178. err = errors.New("querying old values post mutation is not allowed")
  179. } else {
  180. value, err = m.Client().Agent.Get(ctx, id)
  181. }
  182. })
  183. return value, err
  184. }
  185. m.id = &id
  186. }
  187. }
  188. // withAgent sets the old Agent of the mutation.
  189. func withAgent(node *Agent) agentOption {
  190. return func(m *AgentMutation) {
  191. m.oldValue = func(context.Context) (*Agent, error) {
  192. return node, nil
  193. }
  194. m.id = &node.ID
  195. }
  196. }
  197. // Client returns a new `ent.Client` from the mutation. If the mutation was
  198. // executed in a transaction (ent.Tx), a transactional client is returned.
  199. func (m AgentMutation) Client() *Client {
  200. client := &Client{config: m.config}
  201. client.init()
  202. return client
  203. }
  204. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  205. // it returns an error otherwise.
  206. func (m AgentMutation) Tx() (*Tx, error) {
  207. if _, ok := m.driver.(*txDriver); !ok {
  208. return nil, errors.New("ent: mutation is not running in a transaction")
  209. }
  210. tx := &Tx{config: m.config}
  211. tx.init()
  212. return tx, nil
  213. }
  214. // SetID sets the value of the id field. Note that this
  215. // operation is only accepted on creation of Agent entities.
  216. func (m *AgentMutation) SetID(id uint64) {
  217. m.id = &id
  218. }
  219. // ID returns the ID value in the mutation. Note that the ID is only available
  220. // if it was provided to the builder or after it was returned from the database.
  221. func (m *AgentMutation) ID() (id uint64, exists bool) {
  222. if m.id == nil {
  223. return
  224. }
  225. return *m.id, true
  226. }
  227. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  228. // That means, if the mutation is applied within a transaction with an isolation level such
  229. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  230. // or updated by the mutation.
  231. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  232. switch {
  233. case m.op.Is(OpUpdateOne | OpDeleteOne):
  234. id, exists := m.ID()
  235. if exists {
  236. return []uint64{id}, nil
  237. }
  238. fallthrough
  239. case m.op.Is(OpUpdate | OpDelete):
  240. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  241. default:
  242. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  243. }
  244. }
  245. // SetCreatedAt sets the "created_at" field.
  246. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  247. m.created_at = &t
  248. }
  249. // CreatedAt returns the value of the "created_at" field in the mutation.
  250. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  251. v := m.created_at
  252. if v == nil {
  253. return
  254. }
  255. return *v, true
  256. }
  257. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  258. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  260. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  261. if !m.op.Is(OpUpdateOne) {
  262. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  263. }
  264. if m.id == nil || m.oldValue == nil {
  265. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  266. }
  267. oldValue, err := m.oldValue(ctx)
  268. if err != nil {
  269. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  270. }
  271. return oldValue.CreatedAt, nil
  272. }
  273. // ResetCreatedAt resets all changes to the "created_at" field.
  274. func (m *AgentMutation) ResetCreatedAt() {
  275. m.created_at = nil
  276. }
  277. // SetUpdatedAt sets the "updated_at" field.
  278. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  279. m.updated_at = &t
  280. }
  281. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  282. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  283. v := m.updated_at
  284. if v == nil {
  285. return
  286. }
  287. return *v, true
  288. }
  289. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  290. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  292. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  293. if !m.op.Is(OpUpdateOne) {
  294. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  295. }
  296. if m.id == nil || m.oldValue == nil {
  297. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  298. }
  299. oldValue, err := m.oldValue(ctx)
  300. if err != nil {
  301. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  302. }
  303. return oldValue.UpdatedAt, nil
  304. }
  305. // ResetUpdatedAt resets all changes to the "updated_at" field.
  306. func (m *AgentMutation) ResetUpdatedAt() {
  307. m.updated_at = nil
  308. }
  309. // SetDeletedAt sets the "deleted_at" field.
  310. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  311. m.deleted_at = &t
  312. }
  313. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  314. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  315. v := m.deleted_at
  316. if v == nil {
  317. return
  318. }
  319. return *v, true
  320. }
  321. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  322. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  324. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  325. if !m.op.Is(OpUpdateOne) {
  326. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  327. }
  328. if m.id == nil || m.oldValue == nil {
  329. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  330. }
  331. oldValue, err := m.oldValue(ctx)
  332. if err != nil {
  333. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  334. }
  335. return oldValue.DeletedAt, nil
  336. }
  337. // ClearDeletedAt clears the value of the "deleted_at" field.
  338. func (m *AgentMutation) ClearDeletedAt() {
  339. m.deleted_at = nil
  340. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  341. }
  342. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  343. func (m *AgentMutation) DeletedAtCleared() bool {
  344. _, ok := m.clearedFields[agent.FieldDeletedAt]
  345. return ok
  346. }
  347. // ResetDeletedAt resets all changes to the "deleted_at" field.
  348. func (m *AgentMutation) ResetDeletedAt() {
  349. m.deleted_at = nil
  350. delete(m.clearedFields, agent.FieldDeletedAt)
  351. }
  352. // SetName sets the "name" field.
  353. func (m *AgentMutation) SetName(s string) {
  354. m.name = &s
  355. }
  356. // Name returns the value of the "name" field in the mutation.
  357. func (m *AgentMutation) Name() (r string, exists bool) {
  358. v := m.name
  359. if v == nil {
  360. return
  361. }
  362. return *v, true
  363. }
  364. // OldName returns the old "name" field's value of the Agent entity.
  365. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  367. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  368. if !m.op.Is(OpUpdateOne) {
  369. return v, errors.New("OldName is only allowed on UpdateOne operations")
  370. }
  371. if m.id == nil || m.oldValue == nil {
  372. return v, errors.New("OldName requires an ID field in the mutation")
  373. }
  374. oldValue, err := m.oldValue(ctx)
  375. if err != nil {
  376. return v, fmt.Errorf("querying old value for OldName: %w", err)
  377. }
  378. return oldValue.Name, nil
  379. }
  380. // ResetName resets all changes to the "name" field.
  381. func (m *AgentMutation) ResetName() {
  382. m.name = nil
  383. }
  384. // SetRole sets the "role" field.
  385. func (m *AgentMutation) SetRole(s string) {
  386. m.role = &s
  387. }
  388. // Role returns the value of the "role" field in the mutation.
  389. func (m *AgentMutation) Role() (r string, exists bool) {
  390. v := m.role
  391. if v == nil {
  392. return
  393. }
  394. return *v, true
  395. }
  396. // OldRole returns the old "role" field's value of the Agent entity.
  397. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  399. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  400. if !m.op.Is(OpUpdateOne) {
  401. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  402. }
  403. if m.id == nil || m.oldValue == nil {
  404. return v, errors.New("OldRole requires an ID field in the mutation")
  405. }
  406. oldValue, err := m.oldValue(ctx)
  407. if err != nil {
  408. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  409. }
  410. return oldValue.Role, nil
  411. }
  412. // ResetRole resets all changes to the "role" field.
  413. func (m *AgentMutation) ResetRole() {
  414. m.role = nil
  415. }
  416. // SetStatus sets the "status" field.
  417. func (m *AgentMutation) SetStatus(i int) {
  418. m.status = &i
  419. m.addstatus = nil
  420. }
  421. // Status returns the value of the "status" field in the mutation.
  422. func (m *AgentMutation) Status() (r int, exists bool) {
  423. v := m.status
  424. if v == nil {
  425. return
  426. }
  427. return *v, true
  428. }
  429. // OldStatus returns the old "status" field's value of the Agent entity.
  430. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  432. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  433. if !m.op.Is(OpUpdateOne) {
  434. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  435. }
  436. if m.id == nil || m.oldValue == nil {
  437. return v, errors.New("OldStatus requires an ID field in the mutation")
  438. }
  439. oldValue, err := m.oldValue(ctx)
  440. if err != nil {
  441. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  442. }
  443. return oldValue.Status, nil
  444. }
  445. // AddStatus adds i to the "status" field.
  446. func (m *AgentMutation) AddStatus(i int) {
  447. if m.addstatus != nil {
  448. *m.addstatus += i
  449. } else {
  450. m.addstatus = &i
  451. }
  452. }
  453. // AddedStatus returns the value that was added to the "status" field in this mutation.
  454. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  455. v := m.addstatus
  456. if v == nil {
  457. return
  458. }
  459. return *v, true
  460. }
  461. // ClearStatus clears the value of the "status" field.
  462. func (m *AgentMutation) ClearStatus() {
  463. m.status = nil
  464. m.addstatus = nil
  465. m.clearedFields[agent.FieldStatus] = struct{}{}
  466. }
  467. // StatusCleared returns if the "status" field was cleared in this mutation.
  468. func (m *AgentMutation) StatusCleared() bool {
  469. _, ok := m.clearedFields[agent.FieldStatus]
  470. return ok
  471. }
  472. // ResetStatus resets all changes to the "status" field.
  473. func (m *AgentMutation) ResetStatus() {
  474. m.status = nil
  475. m.addstatus = nil
  476. delete(m.clearedFields, agent.FieldStatus)
  477. }
  478. // SetBackground sets the "background" field.
  479. func (m *AgentMutation) SetBackground(s string) {
  480. m.background = &s
  481. }
  482. // Background returns the value of the "background" field in the mutation.
  483. func (m *AgentMutation) Background() (r string, exists bool) {
  484. v := m.background
  485. if v == nil {
  486. return
  487. }
  488. return *v, true
  489. }
  490. // OldBackground returns the old "background" field's value of the Agent entity.
  491. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  493. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  494. if !m.op.Is(OpUpdateOne) {
  495. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  496. }
  497. if m.id == nil || m.oldValue == nil {
  498. return v, errors.New("OldBackground requires an ID field in the mutation")
  499. }
  500. oldValue, err := m.oldValue(ctx)
  501. if err != nil {
  502. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  503. }
  504. return oldValue.Background, nil
  505. }
  506. // ClearBackground clears the value of the "background" field.
  507. func (m *AgentMutation) ClearBackground() {
  508. m.background = nil
  509. m.clearedFields[agent.FieldBackground] = struct{}{}
  510. }
  511. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  512. func (m *AgentMutation) BackgroundCleared() bool {
  513. _, ok := m.clearedFields[agent.FieldBackground]
  514. return ok
  515. }
  516. // ResetBackground resets all changes to the "background" field.
  517. func (m *AgentMutation) ResetBackground() {
  518. m.background = nil
  519. delete(m.clearedFields, agent.FieldBackground)
  520. }
  521. // SetExamples sets the "examples" field.
  522. func (m *AgentMutation) SetExamples(s string) {
  523. m.examples = &s
  524. }
  525. // Examples returns the value of the "examples" field in the mutation.
  526. func (m *AgentMutation) Examples() (r string, exists bool) {
  527. v := m.examples
  528. if v == nil {
  529. return
  530. }
  531. return *v, true
  532. }
  533. // OldExamples returns the old "examples" field's value of the Agent entity.
  534. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  536. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  537. if !m.op.Is(OpUpdateOne) {
  538. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  539. }
  540. if m.id == nil || m.oldValue == nil {
  541. return v, errors.New("OldExamples requires an ID field in the mutation")
  542. }
  543. oldValue, err := m.oldValue(ctx)
  544. if err != nil {
  545. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  546. }
  547. return oldValue.Examples, nil
  548. }
  549. // ClearExamples clears the value of the "examples" field.
  550. func (m *AgentMutation) ClearExamples() {
  551. m.examples = nil
  552. m.clearedFields[agent.FieldExamples] = struct{}{}
  553. }
  554. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  555. func (m *AgentMutation) ExamplesCleared() bool {
  556. _, ok := m.clearedFields[agent.FieldExamples]
  557. return ok
  558. }
  559. // ResetExamples resets all changes to the "examples" field.
  560. func (m *AgentMutation) ResetExamples() {
  561. m.examples = nil
  562. delete(m.clearedFields, agent.FieldExamples)
  563. }
  564. // SetOrganizationID sets the "organization_id" field.
  565. func (m *AgentMutation) SetOrganizationID(u uint64) {
  566. m.organization_id = &u
  567. m.addorganization_id = nil
  568. }
  569. // OrganizationID returns the value of the "organization_id" field in the mutation.
  570. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  571. v := m.organization_id
  572. if v == nil {
  573. return
  574. }
  575. return *v, true
  576. }
  577. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  578. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  580. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  581. if !m.op.Is(OpUpdateOne) {
  582. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  583. }
  584. if m.id == nil || m.oldValue == nil {
  585. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  586. }
  587. oldValue, err := m.oldValue(ctx)
  588. if err != nil {
  589. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  590. }
  591. return oldValue.OrganizationID, nil
  592. }
  593. // AddOrganizationID adds u to the "organization_id" field.
  594. func (m *AgentMutation) AddOrganizationID(u int64) {
  595. if m.addorganization_id != nil {
  596. *m.addorganization_id += u
  597. } else {
  598. m.addorganization_id = &u
  599. }
  600. }
  601. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  602. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  603. v := m.addorganization_id
  604. if v == nil {
  605. return
  606. }
  607. return *v, true
  608. }
  609. // ResetOrganizationID resets all changes to the "organization_id" field.
  610. func (m *AgentMutation) ResetOrganizationID() {
  611. m.organization_id = nil
  612. m.addorganization_id = nil
  613. }
  614. // SetDatasetID sets the "dataset_id" field.
  615. func (m *AgentMutation) SetDatasetID(s string) {
  616. m.dataset_id = &s
  617. }
  618. // DatasetID returns the value of the "dataset_id" field in the mutation.
  619. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  620. v := m.dataset_id
  621. if v == nil {
  622. return
  623. }
  624. return *v, true
  625. }
  626. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  627. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  629. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  630. if !m.op.Is(OpUpdateOne) {
  631. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  632. }
  633. if m.id == nil || m.oldValue == nil {
  634. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  635. }
  636. oldValue, err := m.oldValue(ctx)
  637. if err != nil {
  638. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  639. }
  640. return oldValue.DatasetID, nil
  641. }
  642. // ResetDatasetID resets all changes to the "dataset_id" field.
  643. func (m *AgentMutation) ResetDatasetID() {
  644. m.dataset_id = nil
  645. }
  646. // SetCollectionID sets the "collection_id" field.
  647. func (m *AgentMutation) SetCollectionID(s string) {
  648. m.collection_id = &s
  649. }
  650. // CollectionID returns the value of the "collection_id" field in the mutation.
  651. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  652. v := m.collection_id
  653. if v == nil {
  654. return
  655. }
  656. return *v, true
  657. }
  658. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  659. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  661. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  662. if !m.op.Is(OpUpdateOne) {
  663. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  664. }
  665. if m.id == nil || m.oldValue == nil {
  666. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  667. }
  668. oldValue, err := m.oldValue(ctx)
  669. if err != nil {
  670. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  671. }
  672. return oldValue.CollectionID, nil
  673. }
  674. // ResetCollectionID resets all changes to the "collection_id" field.
  675. func (m *AgentMutation) ResetCollectionID() {
  676. m.collection_id = nil
  677. }
  678. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  679. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  680. if m.wx_agent == nil {
  681. m.wx_agent = make(map[uint64]struct{})
  682. }
  683. for i := range ids {
  684. m.wx_agent[ids[i]] = struct{}{}
  685. }
  686. }
  687. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  688. func (m *AgentMutation) ClearWxAgent() {
  689. m.clearedwx_agent = true
  690. }
  691. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  692. func (m *AgentMutation) WxAgentCleared() bool {
  693. return m.clearedwx_agent
  694. }
  695. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  696. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  697. if m.removedwx_agent == nil {
  698. m.removedwx_agent = make(map[uint64]struct{})
  699. }
  700. for i := range ids {
  701. delete(m.wx_agent, ids[i])
  702. m.removedwx_agent[ids[i]] = struct{}{}
  703. }
  704. }
  705. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  706. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  707. for id := range m.removedwx_agent {
  708. ids = append(ids, id)
  709. }
  710. return
  711. }
  712. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  713. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  714. for id := range m.wx_agent {
  715. ids = append(ids, id)
  716. }
  717. return
  718. }
  719. // ResetWxAgent resets all changes to the "wx_agent" edge.
  720. func (m *AgentMutation) ResetWxAgent() {
  721. m.wx_agent = nil
  722. m.clearedwx_agent = false
  723. m.removedwx_agent = nil
  724. }
  725. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  726. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  727. if m.token_agent == nil {
  728. m.token_agent = make(map[uint64]struct{})
  729. }
  730. for i := range ids {
  731. m.token_agent[ids[i]] = struct{}{}
  732. }
  733. }
  734. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  735. func (m *AgentMutation) ClearTokenAgent() {
  736. m.clearedtoken_agent = true
  737. }
  738. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  739. func (m *AgentMutation) TokenAgentCleared() bool {
  740. return m.clearedtoken_agent
  741. }
  742. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  743. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  744. if m.removedtoken_agent == nil {
  745. m.removedtoken_agent = make(map[uint64]struct{})
  746. }
  747. for i := range ids {
  748. delete(m.token_agent, ids[i])
  749. m.removedtoken_agent[ids[i]] = struct{}{}
  750. }
  751. }
  752. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  753. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  754. for id := range m.removedtoken_agent {
  755. ids = append(ids, id)
  756. }
  757. return
  758. }
  759. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  760. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  761. for id := range m.token_agent {
  762. ids = append(ids, id)
  763. }
  764. return
  765. }
  766. // ResetTokenAgent resets all changes to the "token_agent" edge.
  767. func (m *AgentMutation) ResetTokenAgent() {
  768. m.token_agent = nil
  769. m.clearedtoken_agent = false
  770. m.removedtoken_agent = nil
  771. }
  772. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  773. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  774. if m.wa_agent == nil {
  775. m.wa_agent = make(map[uint64]struct{})
  776. }
  777. for i := range ids {
  778. m.wa_agent[ids[i]] = struct{}{}
  779. }
  780. }
  781. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  782. func (m *AgentMutation) ClearWaAgent() {
  783. m.clearedwa_agent = true
  784. }
  785. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  786. func (m *AgentMutation) WaAgentCleared() bool {
  787. return m.clearedwa_agent
  788. }
  789. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  790. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  791. if m.removedwa_agent == nil {
  792. m.removedwa_agent = make(map[uint64]struct{})
  793. }
  794. for i := range ids {
  795. delete(m.wa_agent, ids[i])
  796. m.removedwa_agent[ids[i]] = struct{}{}
  797. }
  798. }
  799. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  800. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  801. for id := range m.removedwa_agent {
  802. ids = append(ids, id)
  803. }
  804. return
  805. }
  806. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  807. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  808. for id := range m.wa_agent {
  809. ids = append(ids, id)
  810. }
  811. return
  812. }
  813. // ResetWaAgent resets all changes to the "wa_agent" edge.
  814. func (m *AgentMutation) ResetWaAgent() {
  815. m.wa_agent = nil
  816. m.clearedwa_agent = false
  817. m.removedwa_agent = nil
  818. }
  819. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  820. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  821. if m.xjs_agent == nil {
  822. m.xjs_agent = make(map[uint64]struct{})
  823. }
  824. for i := range ids {
  825. m.xjs_agent[ids[i]] = struct{}{}
  826. }
  827. }
  828. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  829. func (m *AgentMutation) ClearXjsAgent() {
  830. m.clearedxjs_agent = true
  831. }
  832. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  833. func (m *AgentMutation) XjsAgentCleared() bool {
  834. return m.clearedxjs_agent
  835. }
  836. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  837. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  838. if m.removedxjs_agent == nil {
  839. m.removedxjs_agent = make(map[uint64]struct{})
  840. }
  841. for i := range ids {
  842. delete(m.xjs_agent, ids[i])
  843. m.removedxjs_agent[ids[i]] = struct{}{}
  844. }
  845. }
  846. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  847. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  848. for id := range m.removedxjs_agent {
  849. ids = append(ids, id)
  850. }
  851. return
  852. }
  853. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  854. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  855. for id := range m.xjs_agent {
  856. ids = append(ids, id)
  857. }
  858. return
  859. }
  860. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  861. func (m *AgentMutation) ResetXjsAgent() {
  862. m.xjs_agent = nil
  863. m.clearedxjs_agent = false
  864. m.removedxjs_agent = nil
  865. }
  866. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  867. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  868. if m.key_agent == nil {
  869. m.key_agent = make(map[uint64]struct{})
  870. }
  871. for i := range ids {
  872. m.key_agent[ids[i]] = struct{}{}
  873. }
  874. }
  875. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  876. func (m *AgentMutation) ClearKeyAgent() {
  877. m.clearedkey_agent = true
  878. }
  879. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  880. func (m *AgentMutation) KeyAgentCleared() bool {
  881. return m.clearedkey_agent
  882. }
  883. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  884. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  885. if m.removedkey_agent == nil {
  886. m.removedkey_agent = make(map[uint64]struct{})
  887. }
  888. for i := range ids {
  889. delete(m.key_agent, ids[i])
  890. m.removedkey_agent[ids[i]] = struct{}{}
  891. }
  892. }
  893. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  894. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  895. for id := range m.removedkey_agent {
  896. ids = append(ids, id)
  897. }
  898. return
  899. }
  900. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  901. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  902. for id := range m.key_agent {
  903. ids = append(ids, id)
  904. }
  905. return
  906. }
  907. // ResetKeyAgent resets all changes to the "key_agent" edge.
  908. func (m *AgentMutation) ResetKeyAgent() {
  909. m.key_agent = nil
  910. m.clearedkey_agent = false
  911. m.removedkey_agent = nil
  912. }
  913. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  914. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  915. if m.xjs_agent == nil {
  916. m.xjs_agent = make(map[uint64]struct{})
  917. }
  918. for i := range ids {
  919. m.xjs_agent[ids[i]] = struct{}{}
  920. }
  921. }
  922. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  923. func (m *AgentMutation) ClearXjsAgent() {
  924. m.clearedxjs_agent = true
  925. }
  926. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  927. func (m *AgentMutation) XjsAgentCleared() bool {
  928. return m.clearedxjs_agent
  929. }
  930. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  931. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  932. if m.removedxjs_agent == nil {
  933. m.removedxjs_agent = make(map[uint64]struct{})
  934. }
  935. for i := range ids {
  936. delete(m.xjs_agent, ids[i])
  937. m.removedxjs_agent[ids[i]] = struct{}{}
  938. }
  939. }
  940. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  941. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  942. for id := range m.removedxjs_agent {
  943. ids = append(ids, id)
  944. }
  945. return
  946. }
  947. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  948. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  949. for id := range m.xjs_agent {
  950. ids = append(ids, id)
  951. }
  952. return
  953. }
  954. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  955. func (m *AgentMutation) ResetXjsAgent() {
  956. m.xjs_agent = nil
  957. m.clearedxjs_agent = false
  958. m.removedxjs_agent = nil
  959. }
  960. // Where appends a list predicates to the AgentMutation builder.
  961. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  962. m.predicates = append(m.predicates, ps...)
  963. }
  964. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  965. // users can use type-assertion to append predicates that do not depend on any generated package.
  966. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  967. p := make([]predicate.Agent, len(ps))
  968. for i := range ps {
  969. p[i] = ps[i]
  970. }
  971. m.Where(p...)
  972. }
  973. // Op returns the operation name.
  974. func (m *AgentMutation) Op() Op {
  975. return m.op
  976. }
  977. // SetOp allows setting the mutation operation.
  978. func (m *AgentMutation) SetOp(op Op) {
  979. m.op = op
  980. }
  981. // Type returns the node type of this mutation (Agent).
  982. func (m *AgentMutation) Type() string {
  983. return m.typ
  984. }
  985. // Fields returns all fields that were changed during this mutation. Note that in
  986. // order to get all numeric fields that were incremented/decremented, call
  987. // AddedFields().
  988. func (m *AgentMutation) Fields() []string {
  989. fields := make([]string, 0, 11)
  990. if m.created_at != nil {
  991. fields = append(fields, agent.FieldCreatedAt)
  992. }
  993. if m.updated_at != nil {
  994. fields = append(fields, agent.FieldUpdatedAt)
  995. }
  996. if m.deleted_at != nil {
  997. fields = append(fields, agent.FieldDeletedAt)
  998. }
  999. if m.name != nil {
  1000. fields = append(fields, agent.FieldName)
  1001. }
  1002. if m.role != nil {
  1003. fields = append(fields, agent.FieldRole)
  1004. }
  1005. if m.status != nil {
  1006. fields = append(fields, agent.FieldStatus)
  1007. }
  1008. if m.background != nil {
  1009. fields = append(fields, agent.FieldBackground)
  1010. }
  1011. if m.examples != nil {
  1012. fields = append(fields, agent.FieldExamples)
  1013. }
  1014. if m.organization_id != nil {
  1015. fields = append(fields, agent.FieldOrganizationID)
  1016. }
  1017. if m.dataset_id != nil {
  1018. fields = append(fields, agent.FieldDatasetID)
  1019. }
  1020. if m.collection_id != nil {
  1021. fields = append(fields, agent.FieldCollectionID)
  1022. }
  1023. return fields
  1024. }
  1025. // Field returns the value of a field with the given name. The second boolean
  1026. // return value indicates that this field was not set, or was not defined in the
  1027. // schema.
  1028. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  1029. switch name {
  1030. case agent.FieldCreatedAt:
  1031. return m.CreatedAt()
  1032. case agent.FieldUpdatedAt:
  1033. return m.UpdatedAt()
  1034. case agent.FieldDeletedAt:
  1035. return m.DeletedAt()
  1036. case agent.FieldName:
  1037. return m.Name()
  1038. case agent.FieldRole:
  1039. return m.Role()
  1040. case agent.FieldStatus:
  1041. return m.Status()
  1042. case agent.FieldBackground:
  1043. return m.Background()
  1044. case agent.FieldExamples:
  1045. return m.Examples()
  1046. case agent.FieldOrganizationID:
  1047. return m.OrganizationID()
  1048. case agent.FieldDatasetID:
  1049. return m.DatasetID()
  1050. case agent.FieldCollectionID:
  1051. return m.CollectionID()
  1052. }
  1053. return nil, false
  1054. }
  1055. // OldField returns the old value of the field from the database. An error is
  1056. // returned if the mutation operation is not UpdateOne, or the query to the
  1057. // database failed.
  1058. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1059. switch name {
  1060. case agent.FieldCreatedAt:
  1061. return m.OldCreatedAt(ctx)
  1062. case agent.FieldUpdatedAt:
  1063. return m.OldUpdatedAt(ctx)
  1064. case agent.FieldDeletedAt:
  1065. return m.OldDeletedAt(ctx)
  1066. case agent.FieldName:
  1067. return m.OldName(ctx)
  1068. case agent.FieldRole:
  1069. return m.OldRole(ctx)
  1070. case agent.FieldStatus:
  1071. return m.OldStatus(ctx)
  1072. case agent.FieldBackground:
  1073. return m.OldBackground(ctx)
  1074. case agent.FieldExamples:
  1075. return m.OldExamples(ctx)
  1076. case agent.FieldOrganizationID:
  1077. return m.OldOrganizationID(ctx)
  1078. case agent.FieldDatasetID:
  1079. return m.OldDatasetID(ctx)
  1080. case agent.FieldCollectionID:
  1081. return m.OldCollectionID(ctx)
  1082. }
  1083. return nil, fmt.Errorf("unknown Agent field %s", name)
  1084. }
  1085. // SetField sets the value of a field with the given name. It returns an error if
  1086. // the field is not defined in the schema, or if the type mismatched the field
  1087. // type.
  1088. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1089. switch name {
  1090. case agent.FieldCreatedAt:
  1091. v, ok := value.(time.Time)
  1092. if !ok {
  1093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1094. }
  1095. m.SetCreatedAt(v)
  1096. return nil
  1097. case agent.FieldUpdatedAt:
  1098. v, ok := value.(time.Time)
  1099. if !ok {
  1100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1101. }
  1102. m.SetUpdatedAt(v)
  1103. return nil
  1104. case agent.FieldDeletedAt:
  1105. v, ok := value.(time.Time)
  1106. if !ok {
  1107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1108. }
  1109. m.SetDeletedAt(v)
  1110. return nil
  1111. case agent.FieldName:
  1112. v, ok := value.(string)
  1113. if !ok {
  1114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1115. }
  1116. m.SetName(v)
  1117. return nil
  1118. case agent.FieldRole:
  1119. v, ok := value.(string)
  1120. if !ok {
  1121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1122. }
  1123. m.SetRole(v)
  1124. return nil
  1125. case agent.FieldStatus:
  1126. v, ok := value.(int)
  1127. if !ok {
  1128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1129. }
  1130. m.SetStatus(v)
  1131. return nil
  1132. case agent.FieldBackground:
  1133. v, ok := value.(string)
  1134. if !ok {
  1135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1136. }
  1137. m.SetBackground(v)
  1138. return nil
  1139. case agent.FieldExamples:
  1140. v, ok := value.(string)
  1141. if !ok {
  1142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1143. }
  1144. m.SetExamples(v)
  1145. return nil
  1146. case agent.FieldOrganizationID:
  1147. v, ok := value.(uint64)
  1148. if !ok {
  1149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1150. }
  1151. m.SetOrganizationID(v)
  1152. return nil
  1153. case agent.FieldDatasetID:
  1154. v, ok := value.(string)
  1155. if !ok {
  1156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1157. }
  1158. m.SetDatasetID(v)
  1159. return nil
  1160. case agent.FieldCollectionID:
  1161. v, ok := value.(string)
  1162. if !ok {
  1163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1164. }
  1165. m.SetCollectionID(v)
  1166. return nil
  1167. }
  1168. return fmt.Errorf("unknown Agent field %s", name)
  1169. }
  1170. // AddedFields returns all numeric fields that were incremented/decremented during
  1171. // this mutation.
  1172. func (m *AgentMutation) AddedFields() []string {
  1173. var fields []string
  1174. if m.addstatus != nil {
  1175. fields = append(fields, agent.FieldStatus)
  1176. }
  1177. if m.addorganization_id != nil {
  1178. fields = append(fields, agent.FieldOrganizationID)
  1179. }
  1180. return fields
  1181. }
  1182. // AddedField returns the numeric value that was incremented/decremented on a field
  1183. // with the given name. The second boolean return value indicates that this field
  1184. // was not set, or was not defined in the schema.
  1185. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1186. switch name {
  1187. case agent.FieldStatus:
  1188. return m.AddedStatus()
  1189. case agent.FieldOrganizationID:
  1190. return m.AddedOrganizationID()
  1191. }
  1192. return nil, false
  1193. }
  1194. // AddField adds the value to the field with the given name. It returns an error if
  1195. // the field is not defined in the schema, or if the type mismatched the field
  1196. // type.
  1197. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1198. switch name {
  1199. case agent.FieldStatus:
  1200. v, ok := value.(int)
  1201. if !ok {
  1202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1203. }
  1204. m.AddStatus(v)
  1205. return nil
  1206. case agent.FieldOrganizationID:
  1207. v, ok := value.(int64)
  1208. if !ok {
  1209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1210. }
  1211. m.AddOrganizationID(v)
  1212. return nil
  1213. }
  1214. return fmt.Errorf("unknown Agent numeric field %s", name)
  1215. }
  1216. // ClearedFields returns all nullable fields that were cleared during this
  1217. // mutation.
  1218. func (m *AgentMutation) ClearedFields() []string {
  1219. var fields []string
  1220. if m.FieldCleared(agent.FieldDeletedAt) {
  1221. fields = append(fields, agent.FieldDeletedAt)
  1222. }
  1223. if m.FieldCleared(agent.FieldStatus) {
  1224. fields = append(fields, agent.FieldStatus)
  1225. }
  1226. if m.FieldCleared(agent.FieldBackground) {
  1227. fields = append(fields, agent.FieldBackground)
  1228. }
  1229. if m.FieldCleared(agent.FieldExamples) {
  1230. fields = append(fields, agent.FieldExamples)
  1231. }
  1232. return fields
  1233. }
  1234. // FieldCleared returns a boolean indicating if a field with the given name was
  1235. // cleared in this mutation.
  1236. func (m *AgentMutation) FieldCleared(name string) bool {
  1237. _, ok := m.clearedFields[name]
  1238. return ok
  1239. }
  1240. // ClearField clears the value of the field with the given name. It returns an
  1241. // error if the field is not defined in the schema.
  1242. func (m *AgentMutation) ClearField(name string) error {
  1243. switch name {
  1244. case agent.FieldDeletedAt:
  1245. m.ClearDeletedAt()
  1246. return nil
  1247. case agent.FieldStatus:
  1248. m.ClearStatus()
  1249. return nil
  1250. case agent.FieldBackground:
  1251. m.ClearBackground()
  1252. return nil
  1253. case agent.FieldExamples:
  1254. m.ClearExamples()
  1255. return nil
  1256. }
  1257. return fmt.Errorf("unknown Agent nullable field %s", name)
  1258. }
  1259. // ResetField resets all changes in the mutation for the field with the given name.
  1260. // It returns an error if the field is not defined in the schema.
  1261. func (m *AgentMutation) ResetField(name string) error {
  1262. switch name {
  1263. case agent.FieldCreatedAt:
  1264. m.ResetCreatedAt()
  1265. return nil
  1266. case agent.FieldUpdatedAt:
  1267. m.ResetUpdatedAt()
  1268. return nil
  1269. case agent.FieldDeletedAt:
  1270. m.ResetDeletedAt()
  1271. return nil
  1272. case agent.FieldName:
  1273. m.ResetName()
  1274. return nil
  1275. case agent.FieldRole:
  1276. m.ResetRole()
  1277. return nil
  1278. case agent.FieldStatus:
  1279. m.ResetStatus()
  1280. return nil
  1281. case agent.FieldBackground:
  1282. m.ResetBackground()
  1283. return nil
  1284. case agent.FieldExamples:
  1285. m.ResetExamples()
  1286. return nil
  1287. case agent.FieldOrganizationID:
  1288. m.ResetOrganizationID()
  1289. return nil
  1290. case agent.FieldDatasetID:
  1291. m.ResetDatasetID()
  1292. return nil
  1293. case agent.FieldCollectionID:
  1294. m.ResetCollectionID()
  1295. return nil
  1296. }
  1297. return fmt.Errorf("unknown Agent field %s", name)
  1298. }
  1299. // AddedEdges returns all edge names that were set/added in this mutation.
  1300. func (m *AgentMutation) AddedEdges() []string {
  1301. edges := make([]string, 0, 5)
  1302. if m.wx_agent != nil {
  1303. edges = append(edges, agent.EdgeWxAgent)
  1304. }
  1305. if m.token_agent != nil {
  1306. edges = append(edges, agent.EdgeTokenAgent)
  1307. }
  1308. if m.wa_agent != nil {
  1309. edges = append(edges, agent.EdgeWaAgent)
  1310. }
  1311. if m.xjs_agent != nil {
  1312. edges = append(edges, agent.EdgeXjsAgent)
  1313. }
  1314. if m.key_agent != nil {
  1315. edges = append(edges, agent.EdgeKeyAgent)
  1316. }
  1317. if m.xjs_agent != nil {
  1318. edges = append(edges, agent.EdgeXjsAgent)
  1319. }
  1320. return edges
  1321. }
  1322. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1323. // name in this mutation.
  1324. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1325. switch name {
  1326. case agent.EdgeWxAgent:
  1327. ids := make([]ent.Value, 0, len(m.wx_agent))
  1328. for id := range m.wx_agent {
  1329. ids = append(ids, id)
  1330. }
  1331. return ids
  1332. case agent.EdgeTokenAgent:
  1333. ids := make([]ent.Value, 0, len(m.token_agent))
  1334. for id := range m.token_agent {
  1335. ids = append(ids, id)
  1336. }
  1337. return ids
  1338. case agent.EdgeWaAgent:
  1339. ids := make([]ent.Value, 0, len(m.wa_agent))
  1340. for id := range m.wa_agent {
  1341. ids = append(ids, id)
  1342. }
  1343. return ids
  1344. case agent.EdgeXjsAgent:
  1345. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1346. for id := range m.xjs_agent {
  1347. ids = append(ids, id)
  1348. }
  1349. return ids
  1350. case agent.EdgeKeyAgent:
  1351. ids := make([]ent.Value, 0, len(m.key_agent))
  1352. for id := range m.key_agent {
  1353. ids = append(ids, id)
  1354. }
  1355. return ids
  1356. case agent.EdgeXjsAgent:
  1357. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1358. for id := range m.xjs_agent {
  1359. ids = append(ids, id)
  1360. }
  1361. return ids
  1362. }
  1363. return nil
  1364. }
  1365. // RemovedEdges returns all edge names that were removed in this mutation.
  1366. func (m *AgentMutation) RemovedEdges() []string {
  1367. edges := make([]string, 0, 5)
  1368. if m.removedwx_agent != nil {
  1369. edges = append(edges, agent.EdgeWxAgent)
  1370. }
  1371. if m.removedtoken_agent != nil {
  1372. edges = append(edges, agent.EdgeTokenAgent)
  1373. }
  1374. if m.removedwa_agent != nil {
  1375. edges = append(edges, agent.EdgeWaAgent)
  1376. }
  1377. if m.removedxjs_agent != nil {
  1378. edges = append(edges, agent.EdgeXjsAgent)
  1379. }
  1380. if m.removedkey_agent != nil {
  1381. edges = append(edges, agent.EdgeKeyAgent)
  1382. }
  1383. if m.removedxjs_agent != nil {
  1384. edges = append(edges, agent.EdgeXjsAgent)
  1385. }
  1386. return edges
  1387. }
  1388. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1389. // the given name in this mutation.
  1390. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1391. switch name {
  1392. case agent.EdgeWxAgent:
  1393. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1394. for id := range m.removedwx_agent {
  1395. ids = append(ids, id)
  1396. }
  1397. return ids
  1398. case agent.EdgeTokenAgent:
  1399. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1400. for id := range m.removedtoken_agent {
  1401. ids = append(ids, id)
  1402. }
  1403. return ids
  1404. case agent.EdgeWaAgent:
  1405. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1406. for id := range m.removedwa_agent {
  1407. ids = append(ids, id)
  1408. }
  1409. return ids
  1410. case agent.EdgeXjsAgent:
  1411. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1412. for id := range m.removedxjs_agent {
  1413. ids = append(ids, id)
  1414. }
  1415. return ids
  1416. case agent.EdgeKeyAgent:
  1417. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1418. for id := range m.removedkey_agent {
  1419. ids = append(ids, id)
  1420. }
  1421. return ids
  1422. case agent.EdgeXjsAgent:
  1423. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1424. for id := range m.removedxjs_agent {
  1425. ids = append(ids, id)
  1426. }
  1427. return ids
  1428. }
  1429. return nil
  1430. }
  1431. // ClearedEdges returns all edge names that were cleared in this mutation.
  1432. func (m *AgentMutation) ClearedEdges() []string {
  1433. edges := make([]string, 0, 5)
  1434. if m.clearedwx_agent {
  1435. edges = append(edges, agent.EdgeWxAgent)
  1436. }
  1437. if m.clearedtoken_agent {
  1438. edges = append(edges, agent.EdgeTokenAgent)
  1439. }
  1440. if m.clearedwa_agent {
  1441. edges = append(edges, agent.EdgeWaAgent)
  1442. }
  1443. if m.clearedxjs_agent {
  1444. edges = append(edges, agent.EdgeXjsAgent)
  1445. }
  1446. if m.clearedkey_agent {
  1447. edges = append(edges, agent.EdgeKeyAgent)
  1448. }
  1449. if m.clearedxjs_agent {
  1450. edges = append(edges, agent.EdgeXjsAgent)
  1451. }
  1452. return edges
  1453. }
  1454. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1455. // was cleared in this mutation.
  1456. func (m *AgentMutation) EdgeCleared(name string) bool {
  1457. switch name {
  1458. case agent.EdgeWxAgent:
  1459. return m.clearedwx_agent
  1460. case agent.EdgeTokenAgent:
  1461. return m.clearedtoken_agent
  1462. case agent.EdgeWaAgent:
  1463. return m.clearedwa_agent
  1464. case agent.EdgeXjsAgent:
  1465. return m.clearedxjs_agent
  1466. case agent.EdgeKeyAgent:
  1467. return m.clearedkey_agent
  1468. case agent.EdgeXjsAgent:
  1469. return m.clearedxjs_agent
  1470. }
  1471. return false
  1472. }
  1473. // ClearEdge clears the value of the edge with the given name. It returns an error
  1474. // if that edge is not defined in the schema.
  1475. func (m *AgentMutation) ClearEdge(name string) error {
  1476. switch name {
  1477. }
  1478. return fmt.Errorf("unknown Agent unique edge %s", name)
  1479. }
  1480. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1481. // It returns an error if the edge is not defined in the schema.
  1482. func (m *AgentMutation) ResetEdge(name string) error {
  1483. switch name {
  1484. case agent.EdgeWxAgent:
  1485. m.ResetWxAgent()
  1486. return nil
  1487. case agent.EdgeTokenAgent:
  1488. m.ResetTokenAgent()
  1489. return nil
  1490. case agent.EdgeWaAgent:
  1491. m.ResetWaAgent()
  1492. return nil
  1493. case agent.EdgeXjsAgent:
  1494. m.ResetXjsAgent()
  1495. return nil
  1496. case agent.EdgeKeyAgent:
  1497. m.ResetKeyAgent()
  1498. return nil
  1499. case agent.EdgeXjsAgent:
  1500. m.ResetXjsAgent()
  1501. return nil
  1502. }
  1503. return fmt.Errorf("unknown Agent edge %s", name)
  1504. }
  1505. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1506. type AgentBaseMutation struct {
  1507. config
  1508. op Op
  1509. typ string
  1510. id *string
  1511. q *string
  1512. a *string
  1513. chunk_index *uint64
  1514. addchunk_index *int64
  1515. indexes *[]string
  1516. appendindexes []string
  1517. dataset_id *string
  1518. collection_id *string
  1519. source_name *string
  1520. can_write *[]bool
  1521. appendcan_write []bool
  1522. is_owner *[]bool
  1523. appendis_owner []bool
  1524. clearedFields map[string]struct{}
  1525. wx_agent map[uint64]struct{}
  1526. removedwx_agent map[uint64]struct{}
  1527. clearedwx_agent bool
  1528. done bool
  1529. oldValue func(context.Context) (*AgentBase, error)
  1530. predicates []predicate.AgentBase
  1531. }
  1532. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1533. // agentbaseOption allows management of the mutation configuration using functional options.
  1534. type agentbaseOption func(*AgentBaseMutation)
  1535. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1536. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1537. m := &AgentBaseMutation{
  1538. config: c,
  1539. op: op,
  1540. typ: TypeAgentBase,
  1541. clearedFields: make(map[string]struct{}),
  1542. }
  1543. for _, opt := range opts {
  1544. opt(m)
  1545. }
  1546. return m
  1547. }
  1548. // withAgentBaseID sets the ID field of the mutation.
  1549. func withAgentBaseID(id string) agentbaseOption {
  1550. return func(m *AgentBaseMutation) {
  1551. var (
  1552. err error
  1553. once sync.Once
  1554. value *AgentBase
  1555. )
  1556. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1557. once.Do(func() {
  1558. if m.done {
  1559. err = errors.New("querying old values post mutation is not allowed")
  1560. } else {
  1561. value, err = m.Client().AgentBase.Get(ctx, id)
  1562. }
  1563. })
  1564. return value, err
  1565. }
  1566. m.id = &id
  1567. }
  1568. }
  1569. // withAgentBase sets the old AgentBase of the mutation.
  1570. func withAgentBase(node *AgentBase) agentbaseOption {
  1571. return func(m *AgentBaseMutation) {
  1572. m.oldValue = func(context.Context) (*AgentBase, error) {
  1573. return node, nil
  1574. }
  1575. m.id = &node.ID
  1576. }
  1577. }
  1578. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1579. // executed in a transaction (ent.Tx), a transactional client is returned.
  1580. func (m AgentBaseMutation) Client() *Client {
  1581. client := &Client{config: m.config}
  1582. client.init()
  1583. return client
  1584. }
  1585. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1586. // it returns an error otherwise.
  1587. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1588. if _, ok := m.driver.(*txDriver); !ok {
  1589. return nil, errors.New("ent: mutation is not running in a transaction")
  1590. }
  1591. tx := &Tx{config: m.config}
  1592. tx.init()
  1593. return tx, nil
  1594. }
  1595. // SetID sets the value of the id field. Note that this
  1596. // operation is only accepted on creation of AgentBase entities.
  1597. func (m *AgentBaseMutation) SetID(id string) {
  1598. m.id = &id
  1599. }
  1600. // ID returns the ID value in the mutation. Note that the ID is only available
  1601. // if it was provided to the builder or after it was returned from the database.
  1602. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1603. if m.id == nil {
  1604. return
  1605. }
  1606. return *m.id, true
  1607. }
  1608. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1609. // That means, if the mutation is applied within a transaction with an isolation level such
  1610. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1611. // or updated by the mutation.
  1612. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1613. switch {
  1614. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1615. id, exists := m.ID()
  1616. if exists {
  1617. return []string{id}, nil
  1618. }
  1619. fallthrough
  1620. case m.op.Is(OpUpdate | OpDelete):
  1621. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1622. default:
  1623. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1624. }
  1625. }
  1626. // SetQ sets the "q" field.
  1627. func (m *AgentBaseMutation) SetQ(s string) {
  1628. m.q = &s
  1629. }
  1630. // Q returns the value of the "q" field in the mutation.
  1631. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1632. v := m.q
  1633. if v == nil {
  1634. return
  1635. }
  1636. return *v, true
  1637. }
  1638. // OldQ returns the old "q" field's value of the AgentBase entity.
  1639. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1641. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1642. if !m.op.Is(OpUpdateOne) {
  1643. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1644. }
  1645. if m.id == nil || m.oldValue == nil {
  1646. return v, errors.New("OldQ requires an ID field in the mutation")
  1647. }
  1648. oldValue, err := m.oldValue(ctx)
  1649. if err != nil {
  1650. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1651. }
  1652. return oldValue.Q, nil
  1653. }
  1654. // ClearQ clears the value of the "q" field.
  1655. func (m *AgentBaseMutation) ClearQ() {
  1656. m.q = nil
  1657. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1658. }
  1659. // QCleared returns if the "q" field was cleared in this mutation.
  1660. func (m *AgentBaseMutation) QCleared() bool {
  1661. _, ok := m.clearedFields[agentbase.FieldQ]
  1662. return ok
  1663. }
  1664. // ResetQ resets all changes to the "q" field.
  1665. func (m *AgentBaseMutation) ResetQ() {
  1666. m.q = nil
  1667. delete(m.clearedFields, agentbase.FieldQ)
  1668. }
  1669. // SetA sets the "a" field.
  1670. func (m *AgentBaseMutation) SetA(s string) {
  1671. m.a = &s
  1672. }
  1673. // A returns the value of the "a" field in the mutation.
  1674. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1675. v := m.a
  1676. if v == nil {
  1677. return
  1678. }
  1679. return *v, true
  1680. }
  1681. // OldA returns the old "a" field's value of the AgentBase entity.
  1682. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1684. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1685. if !m.op.Is(OpUpdateOne) {
  1686. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1687. }
  1688. if m.id == nil || m.oldValue == nil {
  1689. return v, errors.New("OldA requires an ID field in the mutation")
  1690. }
  1691. oldValue, err := m.oldValue(ctx)
  1692. if err != nil {
  1693. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1694. }
  1695. return oldValue.A, nil
  1696. }
  1697. // ClearA clears the value of the "a" field.
  1698. func (m *AgentBaseMutation) ClearA() {
  1699. m.a = nil
  1700. m.clearedFields[agentbase.FieldA] = struct{}{}
  1701. }
  1702. // ACleared returns if the "a" field was cleared in this mutation.
  1703. func (m *AgentBaseMutation) ACleared() bool {
  1704. _, ok := m.clearedFields[agentbase.FieldA]
  1705. return ok
  1706. }
  1707. // ResetA resets all changes to the "a" field.
  1708. func (m *AgentBaseMutation) ResetA() {
  1709. m.a = nil
  1710. delete(m.clearedFields, agentbase.FieldA)
  1711. }
  1712. // SetChunkIndex sets the "chunk_index" field.
  1713. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1714. m.chunk_index = &u
  1715. m.addchunk_index = nil
  1716. }
  1717. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1718. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1719. v := m.chunk_index
  1720. if v == nil {
  1721. return
  1722. }
  1723. return *v, true
  1724. }
  1725. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1726. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1728. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1729. if !m.op.Is(OpUpdateOne) {
  1730. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1731. }
  1732. if m.id == nil || m.oldValue == nil {
  1733. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1734. }
  1735. oldValue, err := m.oldValue(ctx)
  1736. if err != nil {
  1737. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1738. }
  1739. return oldValue.ChunkIndex, nil
  1740. }
  1741. // AddChunkIndex adds u to the "chunk_index" field.
  1742. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1743. if m.addchunk_index != nil {
  1744. *m.addchunk_index += u
  1745. } else {
  1746. m.addchunk_index = &u
  1747. }
  1748. }
  1749. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1750. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1751. v := m.addchunk_index
  1752. if v == nil {
  1753. return
  1754. }
  1755. return *v, true
  1756. }
  1757. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1758. func (m *AgentBaseMutation) ResetChunkIndex() {
  1759. m.chunk_index = nil
  1760. m.addchunk_index = nil
  1761. }
  1762. // SetIndexes sets the "indexes" field.
  1763. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1764. m.indexes = &s
  1765. m.appendindexes = nil
  1766. }
  1767. // Indexes returns the value of the "indexes" field in the mutation.
  1768. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1769. v := m.indexes
  1770. if v == nil {
  1771. return
  1772. }
  1773. return *v, true
  1774. }
  1775. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1776. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1778. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1779. if !m.op.Is(OpUpdateOne) {
  1780. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1781. }
  1782. if m.id == nil || m.oldValue == nil {
  1783. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1784. }
  1785. oldValue, err := m.oldValue(ctx)
  1786. if err != nil {
  1787. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1788. }
  1789. return oldValue.Indexes, nil
  1790. }
  1791. // AppendIndexes adds s to the "indexes" field.
  1792. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1793. m.appendindexes = append(m.appendindexes, s...)
  1794. }
  1795. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1796. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1797. if len(m.appendindexes) == 0 {
  1798. return nil, false
  1799. }
  1800. return m.appendindexes, true
  1801. }
  1802. // ClearIndexes clears the value of the "indexes" field.
  1803. func (m *AgentBaseMutation) ClearIndexes() {
  1804. m.indexes = nil
  1805. m.appendindexes = nil
  1806. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1807. }
  1808. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1809. func (m *AgentBaseMutation) IndexesCleared() bool {
  1810. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1811. return ok
  1812. }
  1813. // ResetIndexes resets all changes to the "indexes" field.
  1814. func (m *AgentBaseMutation) ResetIndexes() {
  1815. m.indexes = nil
  1816. m.appendindexes = nil
  1817. delete(m.clearedFields, agentbase.FieldIndexes)
  1818. }
  1819. // SetDatasetID sets the "dataset_id" field.
  1820. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1821. m.dataset_id = &s
  1822. }
  1823. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1824. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1825. v := m.dataset_id
  1826. if v == nil {
  1827. return
  1828. }
  1829. return *v, true
  1830. }
  1831. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1832. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1834. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1835. if !m.op.Is(OpUpdateOne) {
  1836. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1837. }
  1838. if m.id == nil || m.oldValue == nil {
  1839. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1840. }
  1841. oldValue, err := m.oldValue(ctx)
  1842. if err != nil {
  1843. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1844. }
  1845. return oldValue.DatasetID, nil
  1846. }
  1847. // ClearDatasetID clears the value of the "dataset_id" field.
  1848. func (m *AgentBaseMutation) ClearDatasetID() {
  1849. m.dataset_id = nil
  1850. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1851. }
  1852. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1853. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1854. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1855. return ok
  1856. }
  1857. // ResetDatasetID resets all changes to the "dataset_id" field.
  1858. func (m *AgentBaseMutation) ResetDatasetID() {
  1859. m.dataset_id = nil
  1860. delete(m.clearedFields, agentbase.FieldDatasetID)
  1861. }
  1862. // SetCollectionID sets the "collection_id" field.
  1863. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1864. m.collection_id = &s
  1865. }
  1866. // CollectionID returns the value of the "collection_id" field in the mutation.
  1867. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1868. v := m.collection_id
  1869. if v == nil {
  1870. return
  1871. }
  1872. return *v, true
  1873. }
  1874. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1875. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1877. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1878. if !m.op.Is(OpUpdateOne) {
  1879. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1880. }
  1881. if m.id == nil || m.oldValue == nil {
  1882. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1883. }
  1884. oldValue, err := m.oldValue(ctx)
  1885. if err != nil {
  1886. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1887. }
  1888. return oldValue.CollectionID, nil
  1889. }
  1890. // ClearCollectionID clears the value of the "collection_id" field.
  1891. func (m *AgentBaseMutation) ClearCollectionID() {
  1892. m.collection_id = nil
  1893. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1894. }
  1895. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1896. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1897. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1898. return ok
  1899. }
  1900. // ResetCollectionID resets all changes to the "collection_id" field.
  1901. func (m *AgentBaseMutation) ResetCollectionID() {
  1902. m.collection_id = nil
  1903. delete(m.clearedFields, agentbase.FieldCollectionID)
  1904. }
  1905. // SetSourceName sets the "source_name" field.
  1906. func (m *AgentBaseMutation) SetSourceName(s string) {
  1907. m.source_name = &s
  1908. }
  1909. // SourceName returns the value of the "source_name" field in the mutation.
  1910. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1911. v := m.source_name
  1912. if v == nil {
  1913. return
  1914. }
  1915. return *v, true
  1916. }
  1917. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1918. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1920. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1921. if !m.op.Is(OpUpdateOne) {
  1922. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1923. }
  1924. if m.id == nil || m.oldValue == nil {
  1925. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1926. }
  1927. oldValue, err := m.oldValue(ctx)
  1928. if err != nil {
  1929. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1930. }
  1931. return oldValue.SourceName, nil
  1932. }
  1933. // ClearSourceName clears the value of the "source_name" field.
  1934. func (m *AgentBaseMutation) ClearSourceName() {
  1935. m.source_name = nil
  1936. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1937. }
  1938. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1939. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1940. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1941. return ok
  1942. }
  1943. // ResetSourceName resets all changes to the "source_name" field.
  1944. func (m *AgentBaseMutation) ResetSourceName() {
  1945. m.source_name = nil
  1946. delete(m.clearedFields, agentbase.FieldSourceName)
  1947. }
  1948. // SetCanWrite sets the "can_write" field.
  1949. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1950. m.can_write = &b
  1951. m.appendcan_write = nil
  1952. }
  1953. // CanWrite returns the value of the "can_write" field in the mutation.
  1954. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1955. v := m.can_write
  1956. if v == nil {
  1957. return
  1958. }
  1959. return *v, true
  1960. }
  1961. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1962. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1964. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1965. if !m.op.Is(OpUpdateOne) {
  1966. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1967. }
  1968. if m.id == nil || m.oldValue == nil {
  1969. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1970. }
  1971. oldValue, err := m.oldValue(ctx)
  1972. if err != nil {
  1973. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1974. }
  1975. return oldValue.CanWrite, nil
  1976. }
  1977. // AppendCanWrite adds b to the "can_write" field.
  1978. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1979. m.appendcan_write = append(m.appendcan_write, b...)
  1980. }
  1981. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1982. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1983. if len(m.appendcan_write) == 0 {
  1984. return nil, false
  1985. }
  1986. return m.appendcan_write, true
  1987. }
  1988. // ClearCanWrite clears the value of the "can_write" field.
  1989. func (m *AgentBaseMutation) ClearCanWrite() {
  1990. m.can_write = nil
  1991. m.appendcan_write = nil
  1992. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1993. }
  1994. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1995. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1996. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1997. return ok
  1998. }
  1999. // ResetCanWrite resets all changes to the "can_write" field.
  2000. func (m *AgentBaseMutation) ResetCanWrite() {
  2001. m.can_write = nil
  2002. m.appendcan_write = nil
  2003. delete(m.clearedFields, agentbase.FieldCanWrite)
  2004. }
  2005. // SetIsOwner sets the "is_owner" field.
  2006. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  2007. m.is_owner = &b
  2008. m.appendis_owner = nil
  2009. }
  2010. // IsOwner returns the value of the "is_owner" field in the mutation.
  2011. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  2012. v := m.is_owner
  2013. if v == nil {
  2014. return
  2015. }
  2016. return *v, true
  2017. }
  2018. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  2019. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2021. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  2022. if !m.op.Is(OpUpdateOne) {
  2023. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  2024. }
  2025. if m.id == nil || m.oldValue == nil {
  2026. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  2027. }
  2028. oldValue, err := m.oldValue(ctx)
  2029. if err != nil {
  2030. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  2031. }
  2032. return oldValue.IsOwner, nil
  2033. }
  2034. // AppendIsOwner adds b to the "is_owner" field.
  2035. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  2036. m.appendis_owner = append(m.appendis_owner, b...)
  2037. }
  2038. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  2039. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  2040. if len(m.appendis_owner) == 0 {
  2041. return nil, false
  2042. }
  2043. return m.appendis_owner, true
  2044. }
  2045. // ClearIsOwner clears the value of the "is_owner" field.
  2046. func (m *AgentBaseMutation) ClearIsOwner() {
  2047. m.is_owner = nil
  2048. m.appendis_owner = nil
  2049. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  2050. }
  2051. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  2052. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  2053. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  2054. return ok
  2055. }
  2056. // ResetIsOwner resets all changes to the "is_owner" field.
  2057. func (m *AgentBaseMutation) ResetIsOwner() {
  2058. m.is_owner = nil
  2059. m.appendis_owner = nil
  2060. delete(m.clearedFields, agentbase.FieldIsOwner)
  2061. }
  2062. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  2063. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  2064. if m.wx_agent == nil {
  2065. m.wx_agent = make(map[uint64]struct{})
  2066. }
  2067. for i := range ids {
  2068. m.wx_agent[ids[i]] = struct{}{}
  2069. }
  2070. }
  2071. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2072. func (m *AgentBaseMutation) ClearWxAgent() {
  2073. m.clearedwx_agent = true
  2074. }
  2075. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2076. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2077. return m.clearedwx_agent
  2078. }
  2079. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2080. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2081. if m.removedwx_agent == nil {
  2082. m.removedwx_agent = make(map[uint64]struct{})
  2083. }
  2084. for i := range ids {
  2085. delete(m.wx_agent, ids[i])
  2086. m.removedwx_agent[ids[i]] = struct{}{}
  2087. }
  2088. }
  2089. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2090. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2091. for id := range m.removedwx_agent {
  2092. ids = append(ids, id)
  2093. }
  2094. return
  2095. }
  2096. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2097. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2098. for id := range m.wx_agent {
  2099. ids = append(ids, id)
  2100. }
  2101. return
  2102. }
  2103. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2104. func (m *AgentBaseMutation) ResetWxAgent() {
  2105. m.wx_agent = nil
  2106. m.clearedwx_agent = false
  2107. m.removedwx_agent = nil
  2108. }
  2109. // Where appends a list predicates to the AgentBaseMutation builder.
  2110. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2111. m.predicates = append(m.predicates, ps...)
  2112. }
  2113. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2114. // users can use type-assertion to append predicates that do not depend on any generated package.
  2115. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2116. p := make([]predicate.AgentBase, len(ps))
  2117. for i := range ps {
  2118. p[i] = ps[i]
  2119. }
  2120. m.Where(p...)
  2121. }
  2122. // Op returns the operation name.
  2123. func (m *AgentBaseMutation) Op() Op {
  2124. return m.op
  2125. }
  2126. // SetOp allows setting the mutation operation.
  2127. func (m *AgentBaseMutation) SetOp(op Op) {
  2128. m.op = op
  2129. }
  2130. // Type returns the node type of this mutation (AgentBase).
  2131. func (m *AgentBaseMutation) Type() string {
  2132. return m.typ
  2133. }
  2134. // Fields returns all fields that were changed during this mutation. Note that in
  2135. // order to get all numeric fields that were incremented/decremented, call
  2136. // AddedFields().
  2137. func (m *AgentBaseMutation) Fields() []string {
  2138. fields := make([]string, 0, 9)
  2139. if m.q != nil {
  2140. fields = append(fields, agentbase.FieldQ)
  2141. }
  2142. if m.a != nil {
  2143. fields = append(fields, agentbase.FieldA)
  2144. }
  2145. if m.chunk_index != nil {
  2146. fields = append(fields, agentbase.FieldChunkIndex)
  2147. }
  2148. if m.indexes != nil {
  2149. fields = append(fields, agentbase.FieldIndexes)
  2150. }
  2151. if m.dataset_id != nil {
  2152. fields = append(fields, agentbase.FieldDatasetID)
  2153. }
  2154. if m.collection_id != nil {
  2155. fields = append(fields, agentbase.FieldCollectionID)
  2156. }
  2157. if m.source_name != nil {
  2158. fields = append(fields, agentbase.FieldSourceName)
  2159. }
  2160. if m.can_write != nil {
  2161. fields = append(fields, agentbase.FieldCanWrite)
  2162. }
  2163. if m.is_owner != nil {
  2164. fields = append(fields, agentbase.FieldIsOwner)
  2165. }
  2166. return fields
  2167. }
  2168. // Field returns the value of a field with the given name. The second boolean
  2169. // return value indicates that this field was not set, or was not defined in the
  2170. // schema.
  2171. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2172. switch name {
  2173. case agentbase.FieldQ:
  2174. return m.Q()
  2175. case agentbase.FieldA:
  2176. return m.A()
  2177. case agentbase.FieldChunkIndex:
  2178. return m.ChunkIndex()
  2179. case agentbase.FieldIndexes:
  2180. return m.Indexes()
  2181. case agentbase.FieldDatasetID:
  2182. return m.DatasetID()
  2183. case agentbase.FieldCollectionID:
  2184. return m.CollectionID()
  2185. case agentbase.FieldSourceName:
  2186. return m.SourceName()
  2187. case agentbase.FieldCanWrite:
  2188. return m.CanWrite()
  2189. case agentbase.FieldIsOwner:
  2190. return m.IsOwner()
  2191. }
  2192. return nil, false
  2193. }
  2194. // OldField returns the old value of the field from the database. An error is
  2195. // returned if the mutation operation is not UpdateOne, or the query to the
  2196. // database failed.
  2197. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2198. switch name {
  2199. case agentbase.FieldQ:
  2200. return m.OldQ(ctx)
  2201. case agentbase.FieldA:
  2202. return m.OldA(ctx)
  2203. case agentbase.FieldChunkIndex:
  2204. return m.OldChunkIndex(ctx)
  2205. case agentbase.FieldIndexes:
  2206. return m.OldIndexes(ctx)
  2207. case agentbase.FieldDatasetID:
  2208. return m.OldDatasetID(ctx)
  2209. case agentbase.FieldCollectionID:
  2210. return m.OldCollectionID(ctx)
  2211. case agentbase.FieldSourceName:
  2212. return m.OldSourceName(ctx)
  2213. case agentbase.FieldCanWrite:
  2214. return m.OldCanWrite(ctx)
  2215. case agentbase.FieldIsOwner:
  2216. return m.OldIsOwner(ctx)
  2217. }
  2218. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2219. }
  2220. // SetField sets the value of a field with the given name. It returns an error if
  2221. // the field is not defined in the schema, or if the type mismatched the field
  2222. // type.
  2223. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2224. switch name {
  2225. case agentbase.FieldQ:
  2226. v, ok := value.(string)
  2227. if !ok {
  2228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2229. }
  2230. m.SetQ(v)
  2231. return nil
  2232. case agentbase.FieldA:
  2233. v, ok := value.(string)
  2234. if !ok {
  2235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2236. }
  2237. m.SetA(v)
  2238. return nil
  2239. case agentbase.FieldChunkIndex:
  2240. v, ok := value.(uint64)
  2241. if !ok {
  2242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2243. }
  2244. m.SetChunkIndex(v)
  2245. return nil
  2246. case agentbase.FieldIndexes:
  2247. v, ok := value.([]string)
  2248. if !ok {
  2249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2250. }
  2251. m.SetIndexes(v)
  2252. return nil
  2253. case agentbase.FieldDatasetID:
  2254. v, ok := value.(string)
  2255. if !ok {
  2256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2257. }
  2258. m.SetDatasetID(v)
  2259. return nil
  2260. case agentbase.FieldCollectionID:
  2261. v, ok := value.(string)
  2262. if !ok {
  2263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2264. }
  2265. m.SetCollectionID(v)
  2266. return nil
  2267. case agentbase.FieldSourceName:
  2268. v, ok := value.(string)
  2269. if !ok {
  2270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2271. }
  2272. m.SetSourceName(v)
  2273. return nil
  2274. case agentbase.FieldCanWrite:
  2275. v, ok := value.([]bool)
  2276. if !ok {
  2277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2278. }
  2279. m.SetCanWrite(v)
  2280. return nil
  2281. case agentbase.FieldIsOwner:
  2282. v, ok := value.([]bool)
  2283. if !ok {
  2284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2285. }
  2286. m.SetIsOwner(v)
  2287. return nil
  2288. }
  2289. return fmt.Errorf("unknown AgentBase field %s", name)
  2290. }
  2291. // AddedFields returns all numeric fields that were incremented/decremented during
  2292. // this mutation.
  2293. func (m *AgentBaseMutation) AddedFields() []string {
  2294. var fields []string
  2295. if m.addchunk_index != nil {
  2296. fields = append(fields, agentbase.FieldChunkIndex)
  2297. }
  2298. return fields
  2299. }
  2300. // AddedField returns the numeric value that was incremented/decremented on a field
  2301. // with the given name. The second boolean return value indicates that this field
  2302. // was not set, or was not defined in the schema.
  2303. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2304. switch name {
  2305. case agentbase.FieldChunkIndex:
  2306. return m.AddedChunkIndex()
  2307. }
  2308. return nil, false
  2309. }
  2310. // AddField adds the value to the field with the given name. It returns an error if
  2311. // the field is not defined in the schema, or if the type mismatched the field
  2312. // type.
  2313. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2314. switch name {
  2315. case agentbase.FieldChunkIndex:
  2316. v, ok := value.(int64)
  2317. if !ok {
  2318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2319. }
  2320. m.AddChunkIndex(v)
  2321. return nil
  2322. }
  2323. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2324. }
  2325. // ClearedFields returns all nullable fields that were cleared during this
  2326. // mutation.
  2327. func (m *AgentBaseMutation) ClearedFields() []string {
  2328. var fields []string
  2329. if m.FieldCleared(agentbase.FieldQ) {
  2330. fields = append(fields, agentbase.FieldQ)
  2331. }
  2332. if m.FieldCleared(agentbase.FieldA) {
  2333. fields = append(fields, agentbase.FieldA)
  2334. }
  2335. if m.FieldCleared(agentbase.FieldIndexes) {
  2336. fields = append(fields, agentbase.FieldIndexes)
  2337. }
  2338. if m.FieldCleared(agentbase.FieldDatasetID) {
  2339. fields = append(fields, agentbase.FieldDatasetID)
  2340. }
  2341. if m.FieldCleared(agentbase.FieldCollectionID) {
  2342. fields = append(fields, agentbase.FieldCollectionID)
  2343. }
  2344. if m.FieldCleared(agentbase.FieldSourceName) {
  2345. fields = append(fields, agentbase.FieldSourceName)
  2346. }
  2347. if m.FieldCleared(agentbase.FieldCanWrite) {
  2348. fields = append(fields, agentbase.FieldCanWrite)
  2349. }
  2350. if m.FieldCleared(agentbase.FieldIsOwner) {
  2351. fields = append(fields, agentbase.FieldIsOwner)
  2352. }
  2353. return fields
  2354. }
  2355. // FieldCleared returns a boolean indicating if a field with the given name was
  2356. // cleared in this mutation.
  2357. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2358. _, ok := m.clearedFields[name]
  2359. return ok
  2360. }
  2361. // ClearField clears the value of the field with the given name. It returns an
  2362. // error if the field is not defined in the schema.
  2363. func (m *AgentBaseMutation) ClearField(name string) error {
  2364. switch name {
  2365. case agentbase.FieldQ:
  2366. m.ClearQ()
  2367. return nil
  2368. case agentbase.FieldA:
  2369. m.ClearA()
  2370. return nil
  2371. case agentbase.FieldIndexes:
  2372. m.ClearIndexes()
  2373. return nil
  2374. case agentbase.FieldDatasetID:
  2375. m.ClearDatasetID()
  2376. return nil
  2377. case agentbase.FieldCollectionID:
  2378. m.ClearCollectionID()
  2379. return nil
  2380. case agentbase.FieldSourceName:
  2381. m.ClearSourceName()
  2382. return nil
  2383. case agentbase.FieldCanWrite:
  2384. m.ClearCanWrite()
  2385. return nil
  2386. case agentbase.FieldIsOwner:
  2387. m.ClearIsOwner()
  2388. return nil
  2389. }
  2390. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2391. }
  2392. // ResetField resets all changes in the mutation for the field with the given name.
  2393. // It returns an error if the field is not defined in the schema.
  2394. func (m *AgentBaseMutation) ResetField(name string) error {
  2395. switch name {
  2396. case agentbase.FieldQ:
  2397. m.ResetQ()
  2398. return nil
  2399. case agentbase.FieldA:
  2400. m.ResetA()
  2401. return nil
  2402. case agentbase.FieldChunkIndex:
  2403. m.ResetChunkIndex()
  2404. return nil
  2405. case agentbase.FieldIndexes:
  2406. m.ResetIndexes()
  2407. return nil
  2408. case agentbase.FieldDatasetID:
  2409. m.ResetDatasetID()
  2410. return nil
  2411. case agentbase.FieldCollectionID:
  2412. m.ResetCollectionID()
  2413. return nil
  2414. case agentbase.FieldSourceName:
  2415. m.ResetSourceName()
  2416. return nil
  2417. case agentbase.FieldCanWrite:
  2418. m.ResetCanWrite()
  2419. return nil
  2420. case agentbase.FieldIsOwner:
  2421. m.ResetIsOwner()
  2422. return nil
  2423. }
  2424. return fmt.Errorf("unknown AgentBase field %s", name)
  2425. }
  2426. // AddedEdges returns all edge names that were set/added in this mutation.
  2427. func (m *AgentBaseMutation) AddedEdges() []string {
  2428. edges := make([]string, 0, 1)
  2429. if m.wx_agent != nil {
  2430. edges = append(edges, agentbase.EdgeWxAgent)
  2431. }
  2432. return edges
  2433. }
  2434. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2435. // name in this mutation.
  2436. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2437. switch name {
  2438. case agentbase.EdgeWxAgent:
  2439. ids := make([]ent.Value, 0, len(m.wx_agent))
  2440. for id := range m.wx_agent {
  2441. ids = append(ids, id)
  2442. }
  2443. return ids
  2444. }
  2445. return nil
  2446. }
  2447. // RemovedEdges returns all edge names that were removed in this mutation.
  2448. func (m *AgentBaseMutation) RemovedEdges() []string {
  2449. edges := make([]string, 0, 1)
  2450. if m.removedwx_agent != nil {
  2451. edges = append(edges, agentbase.EdgeWxAgent)
  2452. }
  2453. return edges
  2454. }
  2455. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2456. // the given name in this mutation.
  2457. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2458. switch name {
  2459. case agentbase.EdgeWxAgent:
  2460. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2461. for id := range m.removedwx_agent {
  2462. ids = append(ids, id)
  2463. }
  2464. return ids
  2465. }
  2466. return nil
  2467. }
  2468. // ClearedEdges returns all edge names that were cleared in this mutation.
  2469. func (m *AgentBaseMutation) ClearedEdges() []string {
  2470. edges := make([]string, 0, 1)
  2471. if m.clearedwx_agent {
  2472. edges = append(edges, agentbase.EdgeWxAgent)
  2473. }
  2474. return edges
  2475. }
  2476. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2477. // was cleared in this mutation.
  2478. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2479. switch name {
  2480. case agentbase.EdgeWxAgent:
  2481. return m.clearedwx_agent
  2482. }
  2483. return false
  2484. }
  2485. // ClearEdge clears the value of the edge with the given name. It returns an error
  2486. // if that edge is not defined in the schema.
  2487. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2488. switch name {
  2489. }
  2490. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2491. }
  2492. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2493. // It returns an error if the edge is not defined in the schema.
  2494. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2495. switch name {
  2496. case agentbase.EdgeWxAgent:
  2497. m.ResetWxAgent()
  2498. return nil
  2499. }
  2500. return fmt.Errorf("unknown AgentBase edge %s", name)
  2501. }
  2502. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2503. type AliyunAvatarMutation struct {
  2504. config
  2505. op Op
  2506. typ string
  2507. id *uint64
  2508. created_at *time.Time
  2509. updated_at *time.Time
  2510. deleted_at *time.Time
  2511. user_id *uint64
  2512. adduser_id *int64
  2513. biz_id *string
  2514. access_key_id *string
  2515. access_key_secret *string
  2516. app_id *string
  2517. tenant_id *uint64
  2518. addtenant_id *int64
  2519. response *string
  2520. token *string
  2521. session_id *string
  2522. clearedFields map[string]struct{}
  2523. done bool
  2524. oldValue func(context.Context) (*AliyunAvatar, error)
  2525. predicates []predicate.AliyunAvatar
  2526. }
  2527. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2528. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2529. type aliyunavatarOption func(*AliyunAvatarMutation)
  2530. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2531. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2532. m := &AliyunAvatarMutation{
  2533. config: c,
  2534. op: op,
  2535. typ: TypeAliyunAvatar,
  2536. clearedFields: make(map[string]struct{}),
  2537. }
  2538. for _, opt := range opts {
  2539. opt(m)
  2540. }
  2541. return m
  2542. }
  2543. // withAliyunAvatarID sets the ID field of the mutation.
  2544. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2545. return func(m *AliyunAvatarMutation) {
  2546. var (
  2547. err error
  2548. once sync.Once
  2549. value *AliyunAvatar
  2550. )
  2551. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2552. once.Do(func() {
  2553. if m.done {
  2554. err = errors.New("querying old values post mutation is not allowed")
  2555. } else {
  2556. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2557. }
  2558. })
  2559. return value, err
  2560. }
  2561. m.id = &id
  2562. }
  2563. }
  2564. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2565. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2566. return func(m *AliyunAvatarMutation) {
  2567. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2568. return node, nil
  2569. }
  2570. m.id = &node.ID
  2571. }
  2572. }
  2573. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2574. // executed in a transaction (ent.Tx), a transactional client is returned.
  2575. func (m AliyunAvatarMutation) Client() *Client {
  2576. client := &Client{config: m.config}
  2577. client.init()
  2578. return client
  2579. }
  2580. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2581. // it returns an error otherwise.
  2582. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2583. if _, ok := m.driver.(*txDriver); !ok {
  2584. return nil, errors.New("ent: mutation is not running in a transaction")
  2585. }
  2586. tx := &Tx{config: m.config}
  2587. tx.init()
  2588. return tx, nil
  2589. }
  2590. // SetID sets the value of the id field. Note that this
  2591. // operation is only accepted on creation of AliyunAvatar entities.
  2592. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2593. m.id = &id
  2594. }
  2595. // ID returns the ID value in the mutation. Note that the ID is only available
  2596. // if it was provided to the builder or after it was returned from the database.
  2597. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2598. if m.id == nil {
  2599. return
  2600. }
  2601. return *m.id, true
  2602. }
  2603. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2604. // That means, if the mutation is applied within a transaction with an isolation level such
  2605. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2606. // or updated by the mutation.
  2607. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2608. switch {
  2609. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2610. id, exists := m.ID()
  2611. if exists {
  2612. return []uint64{id}, nil
  2613. }
  2614. fallthrough
  2615. case m.op.Is(OpUpdate | OpDelete):
  2616. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2617. default:
  2618. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2619. }
  2620. }
  2621. // SetCreatedAt sets the "created_at" field.
  2622. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2623. m.created_at = &t
  2624. }
  2625. // CreatedAt returns the value of the "created_at" field in the mutation.
  2626. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2627. v := m.created_at
  2628. if v == nil {
  2629. return
  2630. }
  2631. return *v, true
  2632. }
  2633. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2634. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2636. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2637. if !m.op.Is(OpUpdateOne) {
  2638. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2639. }
  2640. if m.id == nil || m.oldValue == nil {
  2641. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2642. }
  2643. oldValue, err := m.oldValue(ctx)
  2644. if err != nil {
  2645. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2646. }
  2647. return oldValue.CreatedAt, nil
  2648. }
  2649. // ResetCreatedAt resets all changes to the "created_at" field.
  2650. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2651. m.created_at = nil
  2652. }
  2653. // SetUpdatedAt sets the "updated_at" field.
  2654. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2655. m.updated_at = &t
  2656. }
  2657. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2658. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2659. v := m.updated_at
  2660. if v == nil {
  2661. return
  2662. }
  2663. return *v, true
  2664. }
  2665. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2666. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2668. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2669. if !m.op.Is(OpUpdateOne) {
  2670. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2671. }
  2672. if m.id == nil || m.oldValue == nil {
  2673. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2674. }
  2675. oldValue, err := m.oldValue(ctx)
  2676. if err != nil {
  2677. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2678. }
  2679. return oldValue.UpdatedAt, nil
  2680. }
  2681. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2682. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2683. m.updated_at = nil
  2684. }
  2685. // SetDeletedAt sets the "deleted_at" field.
  2686. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2687. m.deleted_at = &t
  2688. }
  2689. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2690. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2691. v := m.deleted_at
  2692. if v == nil {
  2693. return
  2694. }
  2695. return *v, true
  2696. }
  2697. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2698. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2700. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2701. if !m.op.Is(OpUpdateOne) {
  2702. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2703. }
  2704. if m.id == nil || m.oldValue == nil {
  2705. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2706. }
  2707. oldValue, err := m.oldValue(ctx)
  2708. if err != nil {
  2709. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2710. }
  2711. return oldValue.DeletedAt, nil
  2712. }
  2713. // ClearDeletedAt clears the value of the "deleted_at" field.
  2714. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2715. m.deleted_at = nil
  2716. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2717. }
  2718. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2719. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2720. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2721. return ok
  2722. }
  2723. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2724. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2725. m.deleted_at = nil
  2726. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2727. }
  2728. // SetUserID sets the "user_id" field.
  2729. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2730. m.user_id = &u
  2731. m.adduser_id = nil
  2732. }
  2733. // UserID returns the value of the "user_id" field in the mutation.
  2734. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2735. v := m.user_id
  2736. if v == nil {
  2737. return
  2738. }
  2739. return *v, true
  2740. }
  2741. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2742. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2744. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2745. if !m.op.Is(OpUpdateOne) {
  2746. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2747. }
  2748. if m.id == nil || m.oldValue == nil {
  2749. return v, errors.New("OldUserID requires an ID field in the mutation")
  2750. }
  2751. oldValue, err := m.oldValue(ctx)
  2752. if err != nil {
  2753. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2754. }
  2755. return oldValue.UserID, nil
  2756. }
  2757. // AddUserID adds u to the "user_id" field.
  2758. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2759. if m.adduser_id != nil {
  2760. *m.adduser_id += u
  2761. } else {
  2762. m.adduser_id = &u
  2763. }
  2764. }
  2765. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2766. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2767. v := m.adduser_id
  2768. if v == nil {
  2769. return
  2770. }
  2771. return *v, true
  2772. }
  2773. // ResetUserID resets all changes to the "user_id" field.
  2774. func (m *AliyunAvatarMutation) ResetUserID() {
  2775. m.user_id = nil
  2776. m.adduser_id = nil
  2777. }
  2778. // SetBizID sets the "biz_id" field.
  2779. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2780. m.biz_id = &s
  2781. }
  2782. // BizID returns the value of the "biz_id" field in the mutation.
  2783. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2784. v := m.biz_id
  2785. if v == nil {
  2786. return
  2787. }
  2788. return *v, true
  2789. }
  2790. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2791. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2793. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2794. if !m.op.Is(OpUpdateOne) {
  2795. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2796. }
  2797. if m.id == nil || m.oldValue == nil {
  2798. return v, errors.New("OldBizID requires an ID field in the mutation")
  2799. }
  2800. oldValue, err := m.oldValue(ctx)
  2801. if err != nil {
  2802. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2803. }
  2804. return oldValue.BizID, nil
  2805. }
  2806. // ResetBizID resets all changes to the "biz_id" field.
  2807. func (m *AliyunAvatarMutation) ResetBizID() {
  2808. m.biz_id = nil
  2809. }
  2810. // SetAccessKeyID sets the "access_key_id" field.
  2811. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2812. m.access_key_id = &s
  2813. }
  2814. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2815. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2816. v := m.access_key_id
  2817. if v == nil {
  2818. return
  2819. }
  2820. return *v, true
  2821. }
  2822. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2823. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2825. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2826. if !m.op.Is(OpUpdateOne) {
  2827. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2828. }
  2829. if m.id == nil || m.oldValue == nil {
  2830. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2831. }
  2832. oldValue, err := m.oldValue(ctx)
  2833. if err != nil {
  2834. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2835. }
  2836. return oldValue.AccessKeyID, nil
  2837. }
  2838. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2839. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2840. m.access_key_id = nil
  2841. }
  2842. // SetAccessKeySecret sets the "access_key_secret" field.
  2843. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2844. m.access_key_secret = &s
  2845. }
  2846. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2847. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2848. v := m.access_key_secret
  2849. if v == nil {
  2850. return
  2851. }
  2852. return *v, true
  2853. }
  2854. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2855. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2857. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2858. if !m.op.Is(OpUpdateOne) {
  2859. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2860. }
  2861. if m.id == nil || m.oldValue == nil {
  2862. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2863. }
  2864. oldValue, err := m.oldValue(ctx)
  2865. if err != nil {
  2866. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2867. }
  2868. return oldValue.AccessKeySecret, nil
  2869. }
  2870. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2871. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2872. m.access_key_secret = nil
  2873. }
  2874. // SetAppID sets the "app_id" field.
  2875. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2876. m.app_id = &s
  2877. }
  2878. // AppID returns the value of the "app_id" field in the mutation.
  2879. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2880. v := m.app_id
  2881. if v == nil {
  2882. return
  2883. }
  2884. return *v, true
  2885. }
  2886. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2887. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2889. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2890. if !m.op.Is(OpUpdateOne) {
  2891. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2892. }
  2893. if m.id == nil || m.oldValue == nil {
  2894. return v, errors.New("OldAppID requires an ID field in the mutation")
  2895. }
  2896. oldValue, err := m.oldValue(ctx)
  2897. if err != nil {
  2898. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2899. }
  2900. return oldValue.AppID, nil
  2901. }
  2902. // ClearAppID clears the value of the "app_id" field.
  2903. func (m *AliyunAvatarMutation) ClearAppID() {
  2904. m.app_id = nil
  2905. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2906. }
  2907. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2908. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2909. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2910. return ok
  2911. }
  2912. // ResetAppID resets all changes to the "app_id" field.
  2913. func (m *AliyunAvatarMutation) ResetAppID() {
  2914. m.app_id = nil
  2915. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2916. }
  2917. // SetTenantID sets the "tenant_id" field.
  2918. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2919. m.tenant_id = &u
  2920. m.addtenant_id = nil
  2921. }
  2922. // TenantID returns the value of the "tenant_id" field in the mutation.
  2923. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2924. v := m.tenant_id
  2925. if v == nil {
  2926. return
  2927. }
  2928. return *v, true
  2929. }
  2930. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2931. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2933. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2934. if !m.op.Is(OpUpdateOne) {
  2935. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2936. }
  2937. if m.id == nil || m.oldValue == nil {
  2938. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2939. }
  2940. oldValue, err := m.oldValue(ctx)
  2941. if err != nil {
  2942. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2943. }
  2944. return oldValue.TenantID, nil
  2945. }
  2946. // AddTenantID adds u to the "tenant_id" field.
  2947. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2948. if m.addtenant_id != nil {
  2949. *m.addtenant_id += u
  2950. } else {
  2951. m.addtenant_id = &u
  2952. }
  2953. }
  2954. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2955. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2956. v := m.addtenant_id
  2957. if v == nil {
  2958. return
  2959. }
  2960. return *v, true
  2961. }
  2962. // ResetTenantID resets all changes to the "tenant_id" field.
  2963. func (m *AliyunAvatarMutation) ResetTenantID() {
  2964. m.tenant_id = nil
  2965. m.addtenant_id = nil
  2966. }
  2967. // SetResponse sets the "response" field.
  2968. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2969. m.response = &s
  2970. }
  2971. // Response returns the value of the "response" field in the mutation.
  2972. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2973. v := m.response
  2974. if v == nil {
  2975. return
  2976. }
  2977. return *v, true
  2978. }
  2979. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2980. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2982. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2983. if !m.op.Is(OpUpdateOne) {
  2984. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2985. }
  2986. if m.id == nil || m.oldValue == nil {
  2987. return v, errors.New("OldResponse requires an ID field in the mutation")
  2988. }
  2989. oldValue, err := m.oldValue(ctx)
  2990. if err != nil {
  2991. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2992. }
  2993. return oldValue.Response, nil
  2994. }
  2995. // ResetResponse resets all changes to the "response" field.
  2996. func (m *AliyunAvatarMutation) ResetResponse() {
  2997. m.response = nil
  2998. }
  2999. // SetToken sets the "token" field.
  3000. func (m *AliyunAvatarMutation) SetToken(s string) {
  3001. m.token = &s
  3002. }
  3003. // Token returns the value of the "token" field in the mutation.
  3004. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  3005. v := m.token
  3006. if v == nil {
  3007. return
  3008. }
  3009. return *v, true
  3010. }
  3011. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  3012. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3014. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  3015. if !m.op.Is(OpUpdateOne) {
  3016. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  3017. }
  3018. if m.id == nil || m.oldValue == nil {
  3019. return v, errors.New("OldToken requires an ID field in the mutation")
  3020. }
  3021. oldValue, err := m.oldValue(ctx)
  3022. if err != nil {
  3023. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  3024. }
  3025. return oldValue.Token, nil
  3026. }
  3027. // ResetToken resets all changes to the "token" field.
  3028. func (m *AliyunAvatarMutation) ResetToken() {
  3029. m.token = nil
  3030. }
  3031. // SetSessionID sets the "session_id" field.
  3032. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  3033. m.session_id = &s
  3034. }
  3035. // SessionID returns the value of the "session_id" field in the mutation.
  3036. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  3037. v := m.session_id
  3038. if v == nil {
  3039. return
  3040. }
  3041. return *v, true
  3042. }
  3043. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  3044. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3046. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  3047. if !m.op.Is(OpUpdateOne) {
  3048. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  3049. }
  3050. if m.id == nil || m.oldValue == nil {
  3051. return v, errors.New("OldSessionID requires an ID field in the mutation")
  3052. }
  3053. oldValue, err := m.oldValue(ctx)
  3054. if err != nil {
  3055. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  3056. }
  3057. return oldValue.SessionID, nil
  3058. }
  3059. // ResetSessionID resets all changes to the "session_id" field.
  3060. func (m *AliyunAvatarMutation) ResetSessionID() {
  3061. m.session_id = nil
  3062. }
  3063. // Where appends a list predicates to the AliyunAvatarMutation builder.
  3064. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  3065. m.predicates = append(m.predicates, ps...)
  3066. }
  3067. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  3068. // users can use type-assertion to append predicates that do not depend on any generated package.
  3069. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  3070. p := make([]predicate.AliyunAvatar, len(ps))
  3071. for i := range ps {
  3072. p[i] = ps[i]
  3073. }
  3074. m.Where(p...)
  3075. }
  3076. // Op returns the operation name.
  3077. func (m *AliyunAvatarMutation) Op() Op {
  3078. return m.op
  3079. }
  3080. // SetOp allows setting the mutation operation.
  3081. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3082. m.op = op
  3083. }
  3084. // Type returns the node type of this mutation (AliyunAvatar).
  3085. func (m *AliyunAvatarMutation) Type() string {
  3086. return m.typ
  3087. }
  3088. // Fields returns all fields that were changed during this mutation. Note that in
  3089. // order to get all numeric fields that were incremented/decremented, call
  3090. // AddedFields().
  3091. func (m *AliyunAvatarMutation) Fields() []string {
  3092. fields := make([]string, 0, 12)
  3093. if m.created_at != nil {
  3094. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3095. }
  3096. if m.updated_at != nil {
  3097. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3098. }
  3099. if m.deleted_at != nil {
  3100. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3101. }
  3102. if m.user_id != nil {
  3103. fields = append(fields, aliyunavatar.FieldUserID)
  3104. }
  3105. if m.biz_id != nil {
  3106. fields = append(fields, aliyunavatar.FieldBizID)
  3107. }
  3108. if m.access_key_id != nil {
  3109. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3110. }
  3111. if m.access_key_secret != nil {
  3112. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3113. }
  3114. if m.app_id != nil {
  3115. fields = append(fields, aliyunavatar.FieldAppID)
  3116. }
  3117. if m.tenant_id != nil {
  3118. fields = append(fields, aliyunavatar.FieldTenantID)
  3119. }
  3120. if m.response != nil {
  3121. fields = append(fields, aliyunavatar.FieldResponse)
  3122. }
  3123. if m.token != nil {
  3124. fields = append(fields, aliyunavatar.FieldToken)
  3125. }
  3126. if m.session_id != nil {
  3127. fields = append(fields, aliyunavatar.FieldSessionID)
  3128. }
  3129. return fields
  3130. }
  3131. // Field returns the value of a field with the given name. The second boolean
  3132. // return value indicates that this field was not set, or was not defined in the
  3133. // schema.
  3134. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3135. switch name {
  3136. case aliyunavatar.FieldCreatedAt:
  3137. return m.CreatedAt()
  3138. case aliyunavatar.FieldUpdatedAt:
  3139. return m.UpdatedAt()
  3140. case aliyunavatar.FieldDeletedAt:
  3141. return m.DeletedAt()
  3142. case aliyunavatar.FieldUserID:
  3143. return m.UserID()
  3144. case aliyunavatar.FieldBizID:
  3145. return m.BizID()
  3146. case aliyunavatar.FieldAccessKeyID:
  3147. return m.AccessKeyID()
  3148. case aliyunavatar.FieldAccessKeySecret:
  3149. return m.AccessKeySecret()
  3150. case aliyunavatar.FieldAppID:
  3151. return m.AppID()
  3152. case aliyunavatar.FieldTenantID:
  3153. return m.TenantID()
  3154. case aliyunavatar.FieldResponse:
  3155. return m.Response()
  3156. case aliyunavatar.FieldToken:
  3157. return m.Token()
  3158. case aliyunavatar.FieldSessionID:
  3159. return m.SessionID()
  3160. }
  3161. return nil, false
  3162. }
  3163. // OldField returns the old value of the field from the database. An error is
  3164. // returned if the mutation operation is not UpdateOne, or the query to the
  3165. // database failed.
  3166. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3167. switch name {
  3168. case aliyunavatar.FieldCreatedAt:
  3169. return m.OldCreatedAt(ctx)
  3170. case aliyunavatar.FieldUpdatedAt:
  3171. return m.OldUpdatedAt(ctx)
  3172. case aliyunavatar.FieldDeletedAt:
  3173. return m.OldDeletedAt(ctx)
  3174. case aliyunavatar.FieldUserID:
  3175. return m.OldUserID(ctx)
  3176. case aliyunavatar.FieldBizID:
  3177. return m.OldBizID(ctx)
  3178. case aliyunavatar.FieldAccessKeyID:
  3179. return m.OldAccessKeyID(ctx)
  3180. case aliyunavatar.FieldAccessKeySecret:
  3181. return m.OldAccessKeySecret(ctx)
  3182. case aliyunavatar.FieldAppID:
  3183. return m.OldAppID(ctx)
  3184. case aliyunavatar.FieldTenantID:
  3185. return m.OldTenantID(ctx)
  3186. case aliyunavatar.FieldResponse:
  3187. return m.OldResponse(ctx)
  3188. case aliyunavatar.FieldToken:
  3189. return m.OldToken(ctx)
  3190. case aliyunavatar.FieldSessionID:
  3191. return m.OldSessionID(ctx)
  3192. }
  3193. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3194. }
  3195. // SetField sets the value of a field with the given name. It returns an error if
  3196. // the field is not defined in the schema, or if the type mismatched the field
  3197. // type.
  3198. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3199. switch name {
  3200. case aliyunavatar.FieldCreatedAt:
  3201. v, ok := value.(time.Time)
  3202. if !ok {
  3203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3204. }
  3205. m.SetCreatedAt(v)
  3206. return nil
  3207. case aliyunavatar.FieldUpdatedAt:
  3208. v, ok := value.(time.Time)
  3209. if !ok {
  3210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3211. }
  3212. m.SetUpdatedAt(v)
  3213. return nil
  3214. case aliyunavatar.FieldDeletedAt:
  3215. v, ok := value.(time.Time)
  3216. if !ok {
  3217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3218. }
  3219. m.SetDeletedAt(v)
  3220. return nil
  3221. case aliyunavatar.FieldUserID:
  3222. v, ok := value.(uint64)
  3223. if !ok {
  3224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3225. }
  3226. m.SetUserID(v)
  3227. return nil
  3228. case aliyunavatar.FieldBizID:
  3229. v, ok := value.(string)
  3230. if !ok {
  3231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3232. }
  3233. m.SetBizID(v)
  3234. return nil
  3235. case aliyunavatar.FieldAccessKeyID:
  3236. v, ok := value.(string)
  3237. if !ok {
  3238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3239. }
  3240. m.SetAccessKeyID(v)
  3241. return nil
  3242. case aliyunavatar.FieldAccessKeySecret:
  3243. v, ok := value.(string)
  3244. if !ok {
  3245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3246. }
  3247. m.SetAccessKeySecret(v)
  3248. return nil
  3249. case aliyunavatar.FieldAppID:
  3250. v, ok := value.(string)
  3251. if !ok {
  3252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3253. }
  3254. m.SetAppID(v)
  3255. return nil
  3256. case aliyunavatar.FieldTenantID:
  3257. v, ok := value.(uint64)
  3258. if !ok {
  3259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3260. }
  3261. m.SetTenantID(v)
  3262. return nil
  3263. case aliyunavatar.FieldResponse:
  3264. v, ok := value.(string)
  3265. if !ok {
  3266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3267. }
  3268. m.SetResponse(v)
  3269. return nil
  3270. case aliyunavatar.FieldToken:
  3271. v, ok := value.(string)
  3272. if !ok {
  3273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3274. }
  3275. m.SetToken(v)
  3276. return nil
  3277. case aliyunavatar.FieldSessionID:
  3278. v, ok := value.(string)
  3279. if !ok {
  3280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3281. }
  3282. m.SetSessionID(v)
  3283. return nil
  3284. }
  3285. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3286. }
  3287. // AddedFields returns all numeric fields that were incremented/decremented during
  3288. // this mutation.
  3289. func (m *AliyunAvatarMutation) AddedFields() []string {
  3290. var fields []string
  3291. if m.adduser_id != nil {
  3292. fields = append(fields, aliyunavatar.FieldUserID)
  3293. }
  3294. if m.addtenant_id != nil {
  3295. fields = append(fields, aliyunavatar.FieldTenantID)
  3296. }
  3297. return fields
  3298. }
  3299. // AddedField returns the numeric value that was incremented/decremented on a field
  3300. // with the given name. The second boolean return value indicates that this field
  3301. // was not set, or was not defined in the schema.
  3302. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3303. switch name {
  3304. case aliyunavatar.FieldUserID:
  3305. return m.AddedUserID()
  3306. case aliyunavatar.FieldTenantID:
  3307. return m.AddedTenantID()
  3308. }
  3309. return nil, false
  3310. }
  3311. // AddField adds the value to the field with the given name. It returns an error if
  3312. // the field is not defined in the schema, or if the type mismatched the field
  3313. // type.
  3314. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3315. switch name {
  3316. case aliyunavatar.FieldUserID:
  3317. v, ok := value.(int64)
  3318. if !ok {
  3319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3320. }
  3321. m.AddUserID(v)
  3322. return nil
  3323. case aliyunavatar.FieldTenantID:
  3324. v, ok := value.(int64)
  3325. if !ok {
  3326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3327. }
  3328. m.AddTenantID(v)
  3329. return nil
  3330. }
  3331. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3332. }
  3333. // ClearedFields returns all nullable fields that were cleared during this
  3334. // mutation.
  3335. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3336. var fields []string
  3337. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3338. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3339. }
  3340. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3341. fields = append(fields, aliyunavatar.FieldAppID)
  3342. }
  3343. return fields
  3344. }
  3345. // FieldCleared returns a boolean indicating if a field with the given name was
  3346. // cleared in this mutation.
  3347. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3348. _, ok := m.clearedFields[name]
  3349. return ok
  3350. }
  3351. // ClearField clears the value of the field with the given name. It returns an
  3352. // error if the field is not defined in the schema.
  3353. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3354. switch name {
  3355. case aliyunavatar.FieldDeletedAt:
  3356. m.ClearDeletedAt()
  3357. return nil
  3358. case aliyunavatar.FieldAppID:
  3359. m.ClearAppID()
  3360. return nil
  3361. }
  3362. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3363. }
  3364. // ResetField resets all changes in the mutation for the field with the given name.
  3365. // It returns an error if the field is not defined in the schema.
  3366. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3367. switch name {
  3368. case aliyunavatar.FieldCreatedAt:
  3369. m.ResetCreatedAt()
  3370. return nil
  3371. case aliyunavatar.FieldUpdatedAt:
  3372. m.ResetUpdatedAt()
  3373. return nil
  3374. case aliyunavatar.FieldDeletedAt:
  3375. m.ResetDeletedAt()
  3376. return nil
  3377. case aliyunavatar.FieldUserID:
  3378. m.ResetUserID()
  3379. return nil
  3380. case aliyunavatar.FieldBizID:
  3381. m.ResetBizID()
  3382. return nil
  3383. case aliyunavatar.FieldAccessKeyID:
  3384. m.ResetAccessKeyID()
  3385. return nil
  3386. case aliyunavatar.FieldAccessKeySecret:
  3387. m.ResetAccessKeySecret()
  3388. return nil
  3389. case aliyunavatar.FieldAppID:
  3390. m.ResetAppID()
  3391. return nil
  3392. case aliyunavatar.FieldTenantID:
  3393. m.ResetTenantID()
  3394. return nil
  3395. case aliyunavatar.FieldResponse:
  3396. m.ResetResponse()
  3397. return nil
  3398. case aliyunavatar.FieldToken:
  3399. m.ResetToken()
  3400. return nil
  3401. case aliyunavatar.FieldSessionID:
  3402. m.ResetSessionID()
  3403. return nil
  3404. }
  3405. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3406. }
  3407. // AddedEdges returns all edge names that were set/added in this mutation.
  3408. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3409. edges := make([]string, 0, 0)
  3410. return edges
  3411. }
  3412. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3413. // name in this mutation.
  3414. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3415. return nil
  3416. }
  3417. // RemovedEdges returns all edge names that were removed in this mutation.
  3418. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3419. edges := make([]string, 0, 0)
  3420. return edges
  3421. }
  3422. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3423. // the given name in this mutation.
  3424. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3425. return nil
  3426. }
  3427. // ClearedEdges returns all edge names that were cleared in this mutation.
  3428. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3429. edges := make([]string, 0, 0)
  3430. return edges
  3431. }
  3432. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3433. // was cleared in this mutation.
  3434. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3435. return false
  3436. }
  3437. // ClearEdge clears the value of the edge with the given name. It returns an error
  3438. // if that edge is not defined in the schema.
  3439. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3440. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3441. }
  3442. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3443. // It returns an error if the edge is not defined in the schema.
  3444. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3445. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3446. }
  3447. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3448. type AllocAgentMutation struct {
  3449. config
  3450. op Op
  3451. typ string
  3452. id *uint64
  3453. created_at *time.Time
  3454. updated_at *time.Time
  3455. deleted_at *time.Time
  3456. user_id *string
  3457. organization_id *uint64
  3458. addorganization_id *int64
  3459. agents *[]uint64
  3460. appendagents []uint64
  3461. status *int
  3462. addstatus *int
  3463. clearedFields map[string]struct{}
  3464. done bool
  3465. oldValue func(context.Context) (*AllocAgent, error)
  3466. predicates []predicate.AllocAgent
  3467. }
  3468. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3469. // allocagentOption allows management of the mutation configuration using functional options.
  3470. type allocagentOption func(*AllocAgentMutation)
  3471. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3472. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3473. m := &AllocAgentMutation{
  3474. config: c,
  3475. op: op,
  3476. typ: TypeAllocAgent,
  3477. clearedFields: make(map[string]struct{}),
  3478. }
  3479. for _, opt := range opts {
  3480. opt(m)
  3481. }
  3482. return m
  3483. }
  3484. // withAllocAgentID sets the ID field of the mutation.
  3485. func withAllocAgentID(id uint64) allocagentOption {
  3486. return func(m *AllocAgentMutation) {
  3487. var (
  3488. err error
  3489. once sync.Once
  3490. value *AllocAgent
  3491. )
  3492. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3493. once.Do(func() {
  3494. if m.done {
  3495. err = errors.New("querying old values post mutation is not allowed")
  3496. } else {
  3497. value, err = m.Client().AllocAgent.Get(ctx, id)
  3498. }
  3499. })
  3500. return value, err
  3501. }
  3502. m.id = &id
  3503. }
  3504. }
  3505. // withAllocAgent sets the old AllocAgent of the mutation.
  3506. func withAllocAgent(node *AllocAgent) allocagentOption {
  3507. return func(m *AllocAgentMutation) {
  3508. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3509. return node, nil
  3510. }
  3511. m.id = &node.ID
  3512. }
  3513. }
  3514. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3515. // executed in a transaction (ent.Tx), a transactional client is returned.
  3516. func (m AllocAgentMutation) Client() *Client {
  3517. client := &Client{config: m.config}
  3518. client.init()
  3519. return client
  3520. }
  3521. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3522. // it returns an error otherwise.
  3523. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3524. if _, ok := m.driver.(*txDriver); !ok {
  3525. return nil, errors.New("ent: mutation is not running in a transaction")
  3526. }
  3527. tx := &Tx{config: m.config}
  3528. tx.init()
  3529. return tx, nil
  3530. }
  3531. // SetID sets the value of the id field. Note that this
  3532. // operation is only accepted on creation of AllocAgent entities.
  3533. func (m *AllocAgentMutation) SetID(id uint64) {
  3534. m.id = &id
  3535. }
  3536. // ID returns the ID value in the mutation. Note that the ID is only available
  3537. // if it was provided to the builder or after it was returned from the database.
  3538. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3539. if m.id == nil {
  3540. return
  3541. }
  3542. return *m.id, true
  3543. }
  3544. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3545. // That means, if the mutation is applied within a transaction with an isolation level such
  3546. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3547. // or updated by the mutation.
  3548. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3549. switch {
  3550. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3551. id, exists := m.ID()
  3552. if exists {
  3553. return []uint64{id}, nil
  3554. }
  3555. fallthrough
  3556. case m.op.Is(OpUpdate | OpDelete):
  3557. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3558. default:
  3559. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3560. }
  3561. }
  3562. // SetCreatedAt sets the "created_at" field.
  3563. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3564. m.created_at = &t
  3565. }
  3566. // CreatedAt returns the value of the "created_at" field in the mutation.
  3567. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3568. v := m.created_at
  3569. if v == nil {
  3570. return
  3571. }
  3572. return *v, true
  3573. }
  3574. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3575. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3577. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3578. if !m.op.Is(OpUpdateOne) {
  3579. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3580. }
  3581. if m.id == nil || m.oldValue == nil {
  3582. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3583. }
  3584. oldValue, err := m.oldValue(ctx)
  3585. if err != nil {
  3586. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3587. }
  3588. return oldValue.CreatedAt, nil
  3589. }
  3590. // ResetCreatedAt resets all changes to the "created_at" field.
  3591. func (m *AllocAgentMutation) ResetCreatedAt() {
  3592. m.created_at = nil
  3593. }
  3594. // SetUpdatedAt sets the "updated_at" field.
  3595. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3596. m.updated_at = &t
  3597. }
  3598. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3599. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3600. v := m.updated_at
  3601. if v == nil {
  3602. return
  3603. }
  3604. return *v, true
  3605. }
  3606. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3607. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3609. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3610. if !m.op.Is(OpUpdateOne) {
  3611. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3612. }
  3613. if m.id == nil || m.oldValue == nil {
  3614. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3615. }
  3616. oldValue, err := m.oldValue(ctx)
  3617. if err != nil {
  3618. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3619. }
  3620. return oldValue.UpdatedAt, nil
  3621. }
  3622. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3623. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3624. m.updated_at = nil
  3625. }
  3626. // SetDeletedAt sets the "deleted_at" field.
  3627. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3628. m.deleted_at = &t
  3629. }
  3630. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3631. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3632. v := m.deleted_at
  3633. if v == nil {
  3634. return
  3635. }
  3636. return *v, true
  3637. }
  3638. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3639. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3641. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3642. if !m.op.Is(OpUpdateOne) {
  3643. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3644. }
  3645. if m.id == nil || m.oldValue == nil {
  3646. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3647. }
  3648. oldValue, err := m.oldValue(ctx)
  3649. if err != nil {
  3650. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3651. }
  3652. return oldValue.DeletedAt, nil
  3653. }
  3654. // ClearDeletedAt clears the value of the "deleted_at" field.
  3655. func (m *AllocAgentMutation) ClearDeletedAt() {
  3656. m.deleted_at = nil
  3657. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3658. }
  3659. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3660. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3661. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3662. return ok
  3663. }
  3664. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3665. func (m *AllocAgentMutation) ResetDeletedAt() {
  3666. m.deleted_at = nil
  3667. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3668. }
  3669. // SetUserID sets the "user_id" field.
  3670. func (m *AllocAgentMutation) SetUserID(s string) {
  3671. m.user_id = &s
  3672. }
  3673. // UserID returns the value of the "user_id" field in the mutation.
  3674. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3675. v := m.user_id
  3676. if v == nil {
  3677. return
  3678. }
  3679. return *v, true
  3680. }
  3681. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3682. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3684. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3685. if !m.op.Is(OpUpdateOne) {
  3686. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3687. }
  3688. if m.id == nil || m.oldValue == nil {
  3689. return v, errors.New("OldUserID requires an ID field in the mutation")
  3690. }
  3691. oldValue, err := m.oldValue(ctx)
  3692. if err != nil {
  3693. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3694. }
  3695. return oldValue.UserID, nil
  3696. }
  3697. // ClearUserID clears the value of the "user_id" field.
  3698. func (m *AllocAgentMutation) ClearUserID() {
  3699. m.user_id = nil
  3700. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3701. }
  3702. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3703. func (m *AllocAgentMutation) UserIDCleared() bool {
  3704. _, ok := m.clearedFields[allocagent.FieldUserID]
  3705. return ok
  3706. }
  3707. // ResetUserID resets all changes to the "user_id" field.
  3708. func (m *AllocAgentMutation) ResetUserID() {
  3709. m.user_id = nil
  3710. delete(m.clearedFields, allocagent.FieldUserID)
  3711. }
  3712. // SetOrganizationID sets the "organization_id" field.
  3713. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3714. m.organization_id = &u
  3715. m.addorganization_id = nil
  3716. }
  3717. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3718. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3719. v := m.organization_id
  3720. if v == nil {
  3721. return
  3722. }
  3723. return *v, true
  3724. }
  3725. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3726. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3728. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3729. if !m.op.Is(OpUpdateOne) {
  3730. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3731. }
  3732. if m.id == nil || m.oldValue == nil {
  3733. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3734. }
  3735. oldValue, err := m.oldValue(ctx)
  3736. if err != nil {
  3737. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3738. }
  3739. return oldValue.OrganizationID, nil
  3740. }
  3741. // AddOrganizationID adds u to the "organization_id" field.
  3742. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3743. if m.addorganization_id != nil {
  3744. *m.addorganization_id += u
  3745. } else {
  3746. m.addorganization_id = &u
  3747. }
  3748. }
  3749. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3750. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3751. v := m.addorganization_id
  3752. if v == nil {
  3753. return
  3754. }
  3755. return *v, true
  3756. }
  3757. // ClearOrganizationID clears the value of the "organization_id" field.
  3758. func (m *AllocAgentMutation) ClearOrganizationID() {
  3759. m.organization_id = nil
  3760. m.addorganization_id = nil
  3761. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3762. }
  3763. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3764. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3765. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3766. return ok
  3767. }
  3768. // ResetOrganizationID resets all changes to the "organization_id" field.
  3769. func (m *AllocAgentMutation) ResetOrganizationID() {
  3770. m.organization_id = nil
  3771. m.addorganization_id = nil
  3772. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3773. }
  3774. // SetAgents sets the "agents" field.
  3775. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3776. m.agents = &u
  3777. m.appendagents = nil
  3778. }
  3779. // Agents returns the value of the "agents" field in the mutation.
  3780. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3781. v := m.agents
  3782. if v == nil {
  3783. return
  3784. }
  3785. return *v, true
  3786. }
  3787. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3788. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3790. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3791. if !m.op.Is(OpUpdateOne) {
  3792. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3793. }
  3794. if m.id == nil || m.oldValue == nil {
  3795. return v, errors.New("OldAgents requires an ID field in the mutation")
  3796. }
  3797. oldValue, err := m.oldValue(ctx)
  3798. if err != nil {
  3799. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3800. }
  3801. return oldValue.Agents, nil
  3802. }
  3803. // AppendAgents adds u to the "agents" field.
  3804. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3805. m.appendagents = append(m.appendagents, u...)
  3806. }
  3807. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3808. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3809. if len(m.appendagents) == 0 {
  3810. return nil, false
  3811. }
  3812. return m.appendagents, true
  3813. }
  3814. // ResetAgents resets all changes to the "agents" field.
  3815. func (m *AllocAgentMutation) ResetAgents() {
  3816. m.agents = nil
  3817. m.appendagents = nil
  3818. }
  3819. // SetStatus sets the "status" field.
  3820. func (m *AllocAgentMutation) SetStatus(i int) {
  3821. m.status = &i
  3822. m.addstatus = nil
  3823. }
  3824. // Status returns the value of the "status" field in the mutation.
  3825. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3826. v := m.status
  3827. if v == nil {
  3828. return
  3829. }
  3830. return *v, true
  3831. }
  3832. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3833. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3835. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3836. if !m.op.Is(OpUpdateOne) {
  3837. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3838. }
  3839. if m.id == nil || m.oldValue == nil {
  3840. return v, errors.New("OldStatus requires an ID field in the mutation")
  3841. }
  3842. oldValue, err := m.oldValue(ctx)
  3843. if err != nil {
  3844. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3845. }
  3846. return oldValue.Status, nil
  3847. }
  3848. // AddStatus adds i to the "status" field.
  3849. func (m *AllocAgentMutation) AddStatus(i int) {
  3850. if m.addstatus != nil {
  3851. *m.addstatus += i
  3852. } else {
  3853. m.addstatus = &i
  3854. }
  3855. }
  3856. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3857. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3858. v := m.addstatus
  3859. if v == nil {
  3860. return
  3861. }
  3862. return *v, true
  3863. }
  3864. // ClearStatus clears the value of the "status" field.
  3865. func (m *AllocAgentMutation) ClearStatus() {
  3866. m.status = nil
  3867. m.addstatus = nil
  3868. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3869. }
  3870. // StatusCleared returns if the "status" field was cleared in this mutation.
  3871. func (m *AllocAgentMutation) StatusCleared() bool {
  3872. _, ok := m.clearedFields[allocagent.FieldStatus]
  3873. return ok
  3874. }
  3875. // ResetStatus resets all changes to the "status" field.
  3876. func (m *AllocAgentMutation) ResetStatus() {
  3877. m.status = nil
  3878. m.addstatus = nil
  3879. delete(m.clearedFields, allocagent.FieldStatus)
  3880. }
  3881. // Where appends a list predicates to the AllocAgentMutation builder.
  3882. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3883. m.predicates = append(m.predicates, ps...)
  3884. }
  3885. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3886. // users can use type-assertion to append predicates that do not depend on any generated package.
  3887. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3888. p := make([]predicate.AllocAgent, len(ps))
  3889. for i := range ps {
  3890. p[i] = ps[i]
  3891. }
  3892. m.Where(p...)
  3893. }
  3894. // Op returns the operation name.
  3895. func (m *AllocAgentMutation) Op() Op {
  3896. return m.op
  3897. }
  3898. // SetOp allows setting the mutation operation.
  3899. func (m *AllocAgentMutation) SetOp(op Op) {
  3900. m.op = op
  3901. }
  3902. // Type returns the node type of this mutation (AllocAgent).
  3903. func (m *AllocAgentMutation) Type() string {
  3904. return m.typ
  3905. }
  3906. // Fields returns all fields that were changed during this mutation. Note that in
  3907. // order to get all numeric fields that were incremented/decremented, call
  3908. // AddedFields().
  3909. func (m *AllocAgentMutation) Fields() []string {
  3910. fields := make([]string, 0, 7)
  3911. if m.created_at != nil {
  3912. fields = append(fields, allocagent.FieldCreatedAt)
  3913. }
  3914. if m.updated_at != nil {
  3915. fields = append(fields, allocagent.FieldUpdatedAt)
  3916. }
  3917. if m.deleted_at != nil {
  3918. fields = append(fields, allocagent.FieldDeletedAt)
  3919. }
  3920. if m.user_id != nil {
  3921. fields = append(fields, allocagent.FieldUserID)
  3922. }
  3923. if m.organization_id != nil {
  3924. fields = append(fields, allocagent.FieldOrganizationID)
  3925. }
  3926. if m.agents != nil {
  3927. fields = append(fields, allocagent.FieldAgents)
  3928. }
  3929. if m.status != nil {
  3930. fields = append(fields, allocagent.FieldStatus)
  3931. }
  3932. return fields
  3933. }
  3934. // Field returns the value of a field with the given name. The second boolean
  3935. // return value indicates that this field was not set, or was not defined in the
  3936. // schema.
  3937. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3938. switch name {
  3939. case allocagent.FieldCreatedAt:
  3940. return m.CreatedAt()
  3941. case allocagent.FieldUpdatedAt:
  3942. return m.UpdatedAt()
  3943. case allocagent.FieldDeletedAt:
  3944. return m.DeletedAt()
  3945. case allocagent.FieldUserID:
  3946. return m.UserID()
  3947. case allocagent.FieldOrganizationID:
  3948. return m.OrganizationID()
  3949. case allocagent.FieldAgents:
  3950. return m.Agents()
  3951. case allocagent.FieldStatus:
  3952. return m.Status()
  3953. }
  3954. return nil, false
  3955. }
  3956. // OldField returns the old value of the field from the database. An error is
  3957. // returned if the mutation operation is not UpdateOne, or the query to the
  3958. // database failed.
  3959. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3960. switch name {
  3961. case allocagent.FieldCreatedAt:
  3962. return m.OldCreatedAt(ctx)
  3963. case allocagent.FieldUpdatedAt:
  3964. return m.OldUpdatedAt(ctx)
  3965. case allocagent.FieldDeletedAt:
  3966. return m.OldDeletedAt(ctx)
  3967. case allocagent.FieldUserID:
  3968. return m.OldUserID(ctx)
  3969. case allocagent.FieldOrganizationID:
  3970. return m.OldOrganizationID(ctx)
  3971. case allocagent.FieldAgents:
  3972. return m.OldAgents(ctx)
  3973. case allocagent.FieldStatus:
  3974. return m.OldStatus(ctx)
  3975. }
  3976. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3977. }
  3978. // SetField sets the value of a field with the given name. It returns an error if
  3979. // the field is not defined in the schema, or if the type mismatched the field
  3980. // type.
  3981. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3982. switch name {
  3983. case allocagent.FieldCreatedAt:
  3984. v, ok := value.(time.Time)
  3985. if !ok {
  3986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3987. }
  3988. m.SetCreatedAt(v)
  3989. return nil
  3990. case allocagent.FieldUpdatedAt:
  3991. v, ok := value.(time.Time)
  3992. if !ok {
  3993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3994. }
  3995. m.SetUpdatedAt(v)
  3996. return nil
  3997. case allocagent.FieldDeletedAt:
  3998. v, ok := value.(time.Time)
  3999. if !ok {
  4000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4001. }
  4002. m.SetDeletedAt(v)
  4003. return nil
  4004. case allocagent.FieldUserID:
  4005. v, ok := value.(string)
  4006. if !ok {
  4007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4008. }
  4009. m.SetUserID(v)
  4010. return nil
  4011. case allocagent.FieldOrganizationID:
  4012. v, ok := value.(uint64)
  4013. if !ok {
  4014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4015. }
  4016. m.SetOrganizationID(v)
  4017. return nil
  4018. case allocagent.FieldAgents:
  4019. v, ok := value.([]uint64)
  4020. if !ok {
  4021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4022. }
  4023. m.SetAgents(v)
  4024. return nil
  4025. case allocagent.FieldStatus:
  4026. v, ok := value.(int)
  4027. if !ok {
  4028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4029. }
  4030. m.SetStatus(v)
  4031. return nil
  4032. }
  4033. return fmt.Errorf("unknown AllocAgent field %s", name)
  4034. }
  4035. // AddedFields returns all numeric fields that were incremented/decremented during
  4036. // this mutation.
  4037. func (m *AllocAgentMutation) AddedFields() []string {
  4038. var fields []string
  4039. if m.addorganization_id != nil {
  4040. fields = append(fields, allocagent.FieldOrganizationID)
  4041. }
  4042. if m.addstatus != nil {
  4043. fields = append(fields, allocagent.FieldStatus)
  4044. }
  4045. return fields
  4046. }
  4047. // AddedField returns the numeric value that was incremented/decremented on a field
  4048. // with the given name. The second boolean return value indicates that this field
  4049. // was not set, or was not defined in the schema.
  4050. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  4051. switch name {
  4052. case allocagent.FieldOrganizationID:
  4053. return m.AddedOrganizationID()
  4054. case allocagent.FieldStatus:
  4055. return m.AddedStatus()
  4056. }
  4057. return nil, false
  4058. }
  4059. // AddField adds the value to the field with the given name. It returns an error if
  4060. // the field is not defined in the schema, or if the type mismatched the field
  4061. // type.
  4062. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  4063. switch name {
  4064. case allocagent.FieldOrganizationID:
  4065. v, ok := value.(int64)
  4066. if !ok {
  4067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4068. }
  4069. m.AddOrganizationID(v)
  4070. return nil
  4071. case allocagent.FieldStatus:
  4072. v, ok := value.(int)
  4073. if !ok {
  4074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4075. }
  4076. m.AddStatus(v)
  4077. return nil
  4078. }
  4079. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4080. }
  4081. // ClearedFields returns all nullable fields that were cleared during this
  4082. // mutation.
  4083. func (m *AllocAgentMutation) ClearedFields() []string {
  4084. var fields []string
  4085. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4086. fields = append(fields, allocagent.FieldDeletedAt)
  4087. }
  4088. if m.FieldCleared(allocagent.FieldUserID) {
  4089. fields = append(fields, allocagent.FieldUserID)
  4090. }
  4091. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4092. fields = append(fields, allocagent.FieldOrganizationID)
  4093. }
  4094. if m.FieldCleared(allocagent.FieldStatus) {
  4095. fields = append(fields, allocagent.FieldStatus)
  4096. }
  4097. return fields
  4098. }
  4099. // FieldCleared returns a boolean indicating if a field with the given name was
  4100. // cleared in this mutation.
  4101. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4102. _, ok := m.clearedFields[name]
  4103. return ok
  4104. }
  4105. // ClearField clears the value of the field with the given name. It returns an
  4106. // error if the field is not defined in the schema.
  4107. func (m *AllocAgentMutation) ClearField(name string) error {
  4108. switch name {
  4109. case allocagent.FieldDeletedAt:
  4110. m.ClearDeletedAt()
  4111. return nil
  4112. case allocagent.FieldUserID:
  4113. m.ClearUserID()
  4114. return nil
  4115. case allocagent.FieldOrganizationID:
  4116. m.ClearOrganizationID()
  4117. return nil
  4118. case allocagent.FieldStatus:
  4119. m.ClearStatus()
  4120. return nil
  4121. }
  4122. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4123. }
  4124. // ResetField resets all changes in the mutation for the field with the given name.
  4125. // It returns an error if the field is not defined in the schema.
  4126. func (m *AllocAgentMutation) ResetField(name string) error {
  4127. switch name {
  4128. case allocagent.FieldCreatedAt:
  4129. m.ResetCreatedAt()
  4130. return nil
  4131. case allocagent.FieldUpdatedAt:
  4132. m.ResetUpdatedAt()
  4133. return nil
  4134. case allocagent.FieldDeletedAt:
  4135. m.ResetDeletedAt()
  4136. return nil
  4137. case allocagent.FieldUserID:
  4138. m.ResetUserID()
  4139. return nil
  4140. case allocagent.FieldOrganizationID:
  4141. m.ResetOrganizationID()
  4142. return nil
  4143. case allocagent.FieldAgents:
  4144. m.ResetAgents()
  4145. return nil
  4146. case allocagent.FieldStatus:
  4147. m.ResetStatus()
  4148. return nil
  4149. }
  4150. return fmt.Errorf("unknown AllocAgent field %s", name)
  4151. }
  4152. // AddedEdges returns all edge names that were set/added in this mutation.
  4153. func (m *AllocAgentMutation) AddedEdges() []string {
  4154. edges := make([]string, 0, 0)
  4155. return edges
  4156. }
  4157. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4158. // name in this mutation.
  4159. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4160. return nil
  4161. }
  4162. // RemovedEdges returns all edge names that were removed in this mutation.
  4163. func (m *AllocAgentMutation) RemovedEdges() []string {
  4164. edges := make([]string, 0, 0)
  4165. return edges
  4166. }
  4167. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4168. // the given name in this mutation.
  4169. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4170. return nil
  4171. }
  4172. // ClearedEdges returns all edge names that were cleared in this mutation.
  4173. func (m *AllocAgentMutation) ClearedEdges() []string {
  4174. edges := make([]string, 0, 0)
  4175. return edges
  4176. }
  4177. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4178. // was cleared in this mutation.
  4179. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4180. return false
  4181. }
  4182. // ClearEdge clears the value of the edge with the given name. It returns an error
  4183. // if that edge is not defined in the schema.
  4184. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4185. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4186. }
  4187. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4188. // It returns an error if the edge is not defined in the schema.
  4189. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4190. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4191. }
  4192. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4193. type ApiKeyMutation struct {
  4194. config
  4195. op Op
  4196. typ string
  4197. id *uint64
  4198. created_at *time.Time
  4199. updated_at *time.Time
  4200. deleted_at *time.Time
  4201. title *string
  4202. key *string
  4203. organization_id *uint64
  4204. addorganization_id *int64
  4205. custom_agent_base *string
  4206. custom_agent_key *string
  4207. openai_base *string
  4208. openai_key *string
  4209. clearedFields map[string]struct{}
  4210. agent *uint64
  4211. clearedagent bool
  4212. done bool
  4213. oldValue func(context.Context) (*ApiKey, error)
  4214. predicates []predicate.ApiKey
  4215. }
  4216. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4217. // apikeyOption allows management of the mutation configuration using functional options.
  4218. type apikeyOption func(*ApiKeyMutation)
  4219. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4220. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4221. m := &ApiKeyMutation{
  4222. config: c,
  4223. op: op,
  4224. typ: TypeApiKey,
  4225. clearedFields: make(map[string]struct{}),
  4226. }
  4227. for _, opt := range opts {
  4228. opt(m)
  4229. }
  4230. return m
  4231. }
  4232. // withApiKeyID sets the ID field of the mutation.
  4233. func withApiKeyID(id uint64) apikeyOption {
  4234. return func(m *ApiKeyMutation) {
  4235. var (
  4236. err error
  4237. once sync.Once
  4238. value *ApiKey
  4239. )
  4240. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4241. once.Do(func() {
  4242. if m.done {
  4243. err = errors.New("querying old values post mutation is not allowed")
  4244. } else {
  4245. value, err = m.Client().ApiKey.Get(ctx, id)
  4246. }
  4247. })
  4248. return value, err
  4249. }
  4250. m.id = &id
  4251. }
  4252. }
  4253. // withApiKey sets the old ApiKey of the mutation.
  4254. func withApiKey(node *ApiKey) apikeyOption {
  4255. return func(m *ApiKeyMutation) {
  4256. m.oldValue = func(context.Context) (*ApiKey, error) {
  4257. return node, nil
  4258. }
  4259. m.id = &node.ID
  4260. }
  4261. }
  4262. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4263. // executed in a transaction (ent.Tx), a transactional client is returned.
  4264. func (m ApiKeyMutation) Client() *Client {
  4265. client := &Client{config: m.config}
  4266. client.init()
  4267. return client
  4268. }
  4269. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4270. // it returns an error otherwise.
  4271. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4272. if _, ok := m.driver.(*txDriver); !ok {
  4273. return nil, errors.New("ent: mutation is not running in a transaction")
  4274. }
  4275. tx := &Tx{config: m.config}
  4276. tx.init()
  4277. return tx, nil
  4278. }
  4279. // SetID sets the value of the id field. Note that this
  4280. // operation is only accepted on creation of ApiKey entities.
  4281. func (m *ApiKeyMutation) SetID(id uint64) {
  4282. m.id = &id
  4283. }
  4284. // ID returns the ID value in the mutation. Note that the ID is only available
  4285. // if it was provided to the builder or after it was returned from the database.
  4286. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4287. if m.id == nil {
  4288. return
  4289. }
  4290. return *m.id, true
  4291. }
  4292. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4293. // That means, if the mutation is applied within a transaction with an isolation level such
  4294. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4295. // or updated by the mutation.
  4296. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4297. switch {
  4298. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4299. id, exists := m.ID()
  4300. if exists {
  4301. return []uint64{id}, nil
  4302. }
  4303. fallthrough
  4304. case m.op.Is(OpUpdate | OpDelete):
  4305. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4306. default:
  4307. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4308. }
  4309. }
  4310. // SetCreatedAt sets the "created_at" field.
  4311. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4312. m.created_at = &t
  4313. }
  4314. // CreatedAt returns the value of the "created_at" field in the mutation.
  4315. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4316. v := m.created_at
  4317. if v == nil {
  4318. return
  4319. }
  4320. return *v, true
  4321. }
  4322. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4323. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4325. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4326. if !m.op.Is(OpUpdateOne) {
  4327. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4328. }
  4329. if m.id == nil || m.oldValue == nil {
  4330. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4331. }
  4332. oldValue, err := m.oldValue(ctx)
  4333. if err != nil {
  4334. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4335. }
  4336. return oldValue.CreatedAt, nil
  4337. }
  4338. // ResetCreatedAt resets all changes to the "created_at" field.
  4339. func (m *ApiKeyMutation) ResetCreatedAt() {
  4340. m.created_at = nil
  4341. }
  4342. // SetUpdatedAt sets the "updated_at" field.
  4343. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4344. m.updated_at = &t
  4345. }
  4346. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4347. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4348. v := m.updated_at
  4349. if v == nil {
  4350. return
  4351. }
  4352. return *v, true
  4353. }
  4354. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4355. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4357. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4358. if !m.op.Is(OpUpdateOne) {
  4359. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4360. }
  4361. if m.id == nil || m.oldValue == nil {
  4362. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4363. }
  4364. oldValue, err := m.oldValue(ctx)
  4365. if err != nil {
  4366. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4367. }
  4368. return oldValue.UpdatedAt, nil
  4369. }
  4370. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4371. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4372. m.updated_at = nil
  4373. }
  4374. // SetDeletedAt sets the "deleted_at" field.
  4375. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4376. m.deleted_at = &t
  4377. }
  4378. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4379. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4380. v := m.deleted_at
  4381. if v == nil {
  4382. return
  4383. }
  4384. return *v, true
  4385. }
  4386. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4387. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4389. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4390. if !m.op.Is(OpUpdateOne) {
  4391. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4392. }
  4393. if m.id == nil || m.oldValue == nil {
  4394. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4395. }
  4396. oldValue, err := m.oldValue(ctx)
  4397. if err != nil {
  4398. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4399. }
  4400. return oldValue.DeletedAt, nil
  4401. }
  4402. // ClearDeletedAt clears the value of the "deleted_at" field.
  4403. func (m *ApiKeyMutation) ClearDeletedAt() {
  4404. m.deleted_at = nil
  4405. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4406. }
  4407. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4408. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4409. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4410. return ok
  4411. }
  4412. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4413. func (m *ApiKeyMutation) ResetDeletedAt() {
  4414. m.deleted_at = nil
  4415. delete(m.clearedFields, apikey.FieldDeletedAt)
  4416. }
  4417. // SetTitle sets the "title" field.
  4418. func (m *ApiKeyMutation) SetTitle(s string) {
  4419. m.title = &s
  4420. }
  4421. // Title returns the value of the "title" field in the mutation.
  4422. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4423. v := m.title
  4424. if v == nil {
  4425. return
  4426. }
  4427. return *v, true
  4428. }
  4429. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4430. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4432. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4433. if !m.op.Is(OpUpdateOne) {
  4434. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4435. }
  4436. if m.id == nil || m.oldValue == nil {
  4437. return v, errors.New("OldTitle requires an ID field in the mutation")
  4438. }
  4439. oldValue, err := m.oldValue(ctx)
  4440. if err != nil {
  4441. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4442. }
  4443. return oldValue.Title, nil
  4444. }
  4445. // ClearTitle clears the value of the "title" field.
  4446. func (m *ApiKeyMutation) ClearTitle() {
  4447. m.title = nil
  4448. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4449. }
  4450. // TitleCleared returns if the "title" field was cleared in this mutation.
  4451. func (m *ApiKeyMutation) TitleCleared() bool {
  4452. _, ok := m.clearedFields[apikey.FieldTitle]
  4453. return ok
  4454. }
  4455. // ResetTitle resets all changes to the "title" field.
  4456. func (m *ApiKeyMutation) ResetTitle() {
  4457. m.title = nil
  4458. delete(m.clearedFields, apikey.FieldTitle)
  4459. }
  4460. // SetKey sets the "key" field.
  4461. func (m *ApiKeyMutation) SetKey(s string) {
  4462. m.key = &s
  4463. }
  4464. // Key returns the value of the "key" field in the mutation.
  4465. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4466. v := m.key
  4467. if v == nil {
  4468. return
  4469. }
  4470. return *v, true
  4471. }
  4472. // OldKey returns the old "key" field's value of the ApiKey entity.
  4473. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4475. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4476. if !m.op.Is(OpUpdateOne) {
  4477. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4478. }
  4479. if m.id == nil || m.oldValue == nil {
  4480. return v, errors.New("OldKey requires an ID field in the mutation")
  4481. }
  4482. oldValue, err := m.oldValue(ctx)
  4483. if err != nil {
  4484. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4485. }
  4486. return oldValue.Key, nil
  4487. }
  4488. // ClearKey clears the value of the "key" field.
  4489. func (m *ApiKeyMutation) ClearKey() {
  4490. m.key = nil
  4491. m.clearedFields[apikey.FieldKey] = struct{}{}
  4492. }
  4493. // KeyCleared returns if the "key" field was cleared in this mutation.
  4494. func (m *ApiKeyMutation) KeyCleared() bool {
  4495. _, ok := m.clearedFields[apikey.FieldKey]
  4496. return ok
  4497. }
  4498. // ResetKey resets all changes to the "key" field.
  4499. func (m *ApiKeyMutation) ResetKey() {
  4500. m.key = nil
  4501. delete(m.clearedFields, apikey.FieldKey)
  4502. }
  4503. // SetOrganizationID sets the "organization_id" field.
  4504. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4505. m.organization_id = &u
  4506. m.addorganization_id = nil
  4507. }
  4508. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4509. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4510. v := m.organization_id
  4511. if v == nil {
  4512. return
  4513. }
  4514. return *v, true
  4515. }
  4516. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4517. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4519. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4520. if !m.op.Is(OpUpdateOne) {
  4521. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4522. }
  4523. if m.id == nil || m.oldValue == nil {
  4524. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4525. }
  4526. oldValue, err := m.oldValue(ctx)
  4527. if err != nil {
  4528. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4529. }
  4530. return oldValue.OrganizationID, nil
  4531. }
  4532. // AddOrganizationID adds u to the "organization_id" field.
  4533. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4534. if m.addorganization_id != nil {
  4535. *m.addorganization_id += u
  4536. } else {
  4537. m.addorganization_id = &u
  4538. }
  4539. }
  4540. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4541. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4542. v := m.addorganization_id
  4543. if v == nil {
  4544. return
  4545. }
  4546. return *v, true
  4547. }
  4548. // ResetOrganizationID resets all changes to the "organization_id" field.
  4549. func (m *ApiKeyMutation) ResetOrganizationID() {
  4550. m.organization_id = nil
  4551. m.addorganization_id = nil
  4552. }
  4553. // SetAgentID sets the "agent_id" field.
  4554. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4555. m.agent = &u
  4556. }
  4557. // AgentID returns the value of the "agent_id" field in the mutation.
  4558. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4559. v := m.agent
  4560. if v == nil {
  4561. return
  4562. }
  4563. return *v, true
  4564. }
  4565. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4566. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4568. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4569. if !m.op.Is(OpUpdateOne) {
  4570. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4571. }
  4572. if m.id == nil || m.oldValue == nil {
  4573. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4574. }
  4575. oldValue, err := m.oldValue(ctx)
  4576. if err != nil {
  4577. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4578. }
  4579. return oldValue.AgentID, nil
  4580. }
  4581. // ResetAgentID resets all changes to the "agent_id" field.
  4582. func (m *ApiKeyMutation) ResetAgentID() {
  4583. m.agent = nil
  4584. }
  4585. // SetCustomAgentBase sets the "custom_agent_base" field.
  4586. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4587. m.custom_agent_base = &s
  4588. }
  4589. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4590. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4591. v := m.custom_agent_base
  4592. if v == nil {
  4593. return
  4594. }
  4595. return *v, true
  4596. }
  4597. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4598. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4600. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4601. if !m.op.Is(OpUpdateOne) {
  4602. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4603. }
  4604. if m.id == nil || m.oldValue == nil {
  4605. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4606. }
  4607. oldValue, err := m.oldValue(ctx)
  4608. if err != nil {
  4609. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4610. }
  4611. return oldValue.CustomAgentBase, nil
  4612. }
  4613. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4614. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4615. m.custom_agent_base = nil
  4616. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4617. }
  4618. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4619. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4620. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4621. return ok
  4622. }
  4623. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4624. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4625. m.custom_agent_base = nil
  4626. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4627. }
  4628. // SetCustomAgentKey sets the "custom_agent_key" field.
  4629. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4630. m.custom_agent_key = &s
  4631. }
  4632. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4633. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4634. v := m.custom_agent_key
  4635. if v == nil {
  4636. return
  4637. }
  4638. return *v, true
  4639. }
  4640. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4641. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4643. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4644. if !m.op.Is(OpUpdateOne) {
  4645. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4646. }
  4647. if m.id == nil || m.oldValue == nil {
  4648. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4649. }
  4650. oldValue, err := m.oldValue(ctx)
  4651. if err != nil {
  4652. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4653. }
  4654. return oldValue.CustomAgentKey, nil
  4655. }
  4656. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4657. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4658. m.custom_agent_key = nil
  4659. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4660. }
  4661. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4662. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4663. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4664. return ok
  4665. }
  4666. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4667. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4668. m.custom_agent_key = nil
  4669. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4670. }
  4671. // SetOpenaiBase sets the "openai_base" field.
  4672. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4673. m.openai_base = &s
  4674. }
  4675. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4676. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4677. v := m.openai_base
  4678. if v == nil {
  4679. return
  4680. }
  4681. return *v, true
  4682. }
  4683. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4684. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4686. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4687. if !m.op.Is(OpUpdateOne) {
  4688. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4689. }
  4690. if m.id == nil || m.oldValue == nil {
  4691. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4692. }
  4693. oldValue, err := m.oldValue(ctx)
  4694. if err != nil {
  4695. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4696. }
  4697. return oldValue.OpenaiBase, nil
  4698. }
  4699. // ClearOpenaiBase clears the value of the "openai_base" field.
  4700. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4701. m.openai_base = nil
  4702. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4703. }
  4704. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4705. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4706. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4707. return ok
  4708. }
  4709. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4710. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4711. m.openai_base = nil
  4712. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4713. }
  4714. // SetOpenaiKey sets the "openai_key" field.
  4715. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4716. m.openai_key = &s
  4717. }
  4718. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4719. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4720. v := m.openai_key
  4721. if v == nil {
  4722. return
  4723. }
  4724. return *v, true
  4725. }
  4726. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4727. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4729. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4730. if !m.op.Is(OpUpdateOne) {
  4731. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4732. }
  4733. if m.id == nil || m.oldValue == nil {
  4734. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4735. }
  4736. oldValue, err := m.oldValue(ctx)
  4737. if err != nil {
  4738. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4739. }
  4740. return oldValue.OpenaiKey, nil
  4741. }
  4742. // ClearOpenaiKey clears the value of the "openai_key" field.
  4743. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4744. m.openai_key = nil
  4745. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4746. }
  4747. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4748. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4749. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4750. return ok
  4751. }
  4752. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4753. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4754. m.openai_key = nil
  4755. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4756. }
  4757. // ClearAgent clears the "agent" edge to the Agent entity.
  4758. func (m *ApiKeyMutation) ClearAgent() {
  4759. m.clearedagent = true
  4760. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4761. }
  4762. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4763. func (m *ApiKeyMutation) AgentCleared() bool {
  4764. return m.clearedagent
  4765. }
  4766. // AgentIDs returns the "agent" edge IDs in the mutation.
  4767. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4768. // AgentID instead. It exists only for internal usage by the builders.
  4769. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4770. if id := m.agent; id != nil {
  4771. ids = append(ids, *id)
  4772. }
  4773. return
  4774. }
  4775. // ResetAgent resets all changes to the "agent" edge.
  4776. func (m *ApiKeyMutation) ResetAgent() {
  4777. m.agent = nil
  4778. m.clearedagent = false
  4779. }
  4780. // Where appends a list predicates to the ApiKeyMutation builder.
  4781. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4782. m.predicates = append(m.predicates, ps...)
  4783. }
  4784. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4785. // users can use type-assertion to append predicates that do not depend on any generated package.
  4786. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4787. p := make([]predicate.ApiKey, len(ps))
  4788. for i := range ps {
  4789. p[i] = ps[i]
  4790. }
  4791. m.Where(p...)
  4792. }
  4793. // Op returns the operation name.
  4794. func (m *ApiKeyMutation) Op() Op {
  4795. return m.op
  4796. }
  4797. // SetOp allows setting the mutation operation.
  4798. func (m *ApiKeyMutation) SetOp(op Op) {
  4799. m.op = op
  4800. }
  4801. // Type returns the node type of this mutation (ApiKey).
  4802. func (m *ApiKeyMutation) Type() string {
  4803. return m.typ
  4804. }
  4805. // Fields returns all fields that were changed during this mutation. Note that in
  4806. // order to get all numeric fields that were incremented/decremented, call
  4807. // AddedFields().
  4808. func (m *ApiKeyMutation) Fields() []string {
  4809. fields := make([]string, 0, 11)
  4810. if m.created_at != nil {
  4811. fields = append(fields, apikey.FieldCreatedAt)
  4812. }
  4813. if m.updated_at != nil {
  4814. fields = append(fields, apikey.FieldUpdatedAt)
  4815. }
  4816. if m.deleted_at != nil {
  4817. fields = append(fields, apikey.FieldDeletedAt)
  4818. }
  4819. if m.title != nil {
  4820. fields = append(fields, apikey.FieldTitle)
  4821. }
  4822. if m.key != nil {
  4823. fields = append(fields, apikey.FieldKey)
  4824. }
  4825. if m.organization_id != nil {
  4826. fields = append(fields, apikey.FieldOrganizationID)
  4827. }
  4828. if m.agent != nil {
  4829. fields = append(fields, apikey.FieldAgentID)
  4830. }
  4831. if m.custom_agent_base != nil {
  4832. fields = append(fields, apikey.FieldCustomAgentBase)
  4833. }
  4834. if m.custom_agent_key != nil {
  4835. fields = append(fields, apikey.FieldCustomAgentKey)
  4836. }
  4837. if m.openai_base != nil {
  4838. fields = append(fields, apikey.FieldOpenaiBase)
  4839. }
  4840. if m.openai_key != nil {
  4841. fields = append(fields, apikey.FieldOpenaiKey)
  4842. }
  4843. return fields
  4844. }
  4845. // Field returns the value of a field with the given name. The second boolean
  4846. // return value indicates that this field was not set, or was not defined in the
  4847. // schema.
  4848. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  4849. switch name {
  4850. case apikey.FieldCreatedAt:
  4851. return m.CreatedAt()
  4852. case apikey.FieldUpdatedAt:
  4853. return m.UpdatedAt()
  4854. case apikey.FieldDeletedAt:
  4855. return m.DeletedAt()
  4856. case apikey.FieldTitle:
  4857. return m.Title()
  4858. case apikey.FieldKey:
  4859. return m.Key()
  4860. case apikey.FieldOrganizationID:
  4861. return m.OrganizationID()
  4862. case apikey.FieldAgentID:
  4863. return m.AgentID()
  4864. case apikey.FieldCustomAgentBase:
  4865. return m.CustomAgentBase()
  4866. case apikey.FieldCustomAgentKey:
  4867. return m.CustomAgentKey()
  4868. case apikey.FieldOpenaiBase:
  4869. return m.OpenaiBase()
  4870. case apikey.FieldOpenaiKey:
  4871. return m.OpenaiKey()
  4872. }
  4873. return nil, false
  4874. }
  4875. // OldField returns the old value of the field from the database. An error is
  4876. // returned if the mutation operation is not UpdateOne, or the query to the
  4877. // database failed.
  4878. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4879. switch name {
  4880. case apikey.FieldCreatedAt:
  4881. return m.OldCreatedAt(ctx)
  4882. case apikey.FieldUpdatedAt:
  4883. return m.OldUpdatedAt(ctx)
  4884. case apikey.FieldDeletedAt:
  4885. return m.OldDeletedAt(ctx)
  4886. case apikey.FieldTitle:
  4887. return m.OldTitle(ctx)
  4888. case apikey.FieldKey:
  4889. return m.OldKey(ctx)
  4890. case apikey.FieldOrganizationID:
  4891. return m.OldOrganizationID(ctx)
  4892. case apikey.FieldAgentID:
  4893. return m.OldAgentID(ctx)
  4894. case apikey.FieldCustomAgentBase:
  4895. return m.OldCustomAgentBase(ctx)
  4896. case apikey.FieldCustomAgentKey:
  4897. return m.OldCustomAgentKey(ctx)
  4898. case apikey.FieldOpenaiBase:
  4899. return m.OldOpenaiBase(ctx)
  4900. case apikey.FieldOpenaiKey:
  4901. return m.OldOpenaiKey(ctx)
  4902. }
  4903. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  4904. }
  4905. // SetField sets the value of a field with the given name. It returns an error if
  4906. // the field is not defined in the schema, or if the type mismatched the field
  4907. // type.
  4908. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  4909. switch name {
  4910. case apikey.FieldCreatedAt:
  4911. v, ok := value.(time.Time)
  4912. if !ok {
  4913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4914. }
  4915. m.SetCreatedAt(v)
  4916. return nil
  4917. case apikey.FieldUpdatedAt:
  4918. v, ok := value.(time.Time)
  4919. if !ok {
  4920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4921. }
  4922. m.SetUpdatedAt(v)
  4923. return nil
  4924. case apikey.FieldDeletedAt:
  4925. v, ok := value.(time.Time)
  4926. if !ok {
  4927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4928. }
  4929. m.SetDeletedAt(v)
  4930. return nil
  4931. case apikey.FieldTitle:
  4932. v, ok := value.(string)
  4933. if !ok {
  4934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4935. }
  4936. m.SetTitle(v)
  4937. return nil
  4938. case apikey.FieldKey:
  4939. v, ok := value.(string)
  4940. if !ok {
  4941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4942. }
  4943. m.SetKey(v)
  4944. return nil
  4945. case apikey.FieldOrganizationID:
  4946. v, ok := value.(uint64)
  4947. if !ok {
  4948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4949. }
  4950. m.SetOrganizationID(v)
  4951. return nil
  4952. case apikey.FieldAgentID:
  4953. v, ok := value.(uint64)
  4954. if !ok {
  4955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4956. }
  4957. m.SetAgentID(v)
  4958. return nil
  4959. case apikey.FieldCustomAgentBase:
  4960. v, ok := value.(string)
  4961. if !ok {
  4962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4963. }
  4964. m.SetCustomAgentBase(v)
  4965. return nil
  4966. case apikey.FieldCustomAgentKey:
  4967. v, ok := value.(string)
  4968. if !ok {
  4969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4970. }
  4971. m.SetCustomAgentKey(v)
  4972. return nil
  4973. case apikey.FieldOpenaiBase:
  4974. v, ok := value.(string)
  4975. if !ok {
  4976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4977. }
  4978. m.SetOpenaiBase(v)
  4979. return nil
  4980. case apikey.FieldOpenaiKey:
  4981. v, ok := value.(string)
  4982. if !ok {
  4983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4984. }
  4985. m.SetOpenaiKey(v)
  4986. return nil
  4987. }
  4988. return fmt.Errorf("unknown ApiKey field %s", name)
  4989. }
  4990. // AddedFields returns all numeric fields that were incremented/decremented during
  4991. // this mutation.
  4992. func (m *ApiKeyMutation) AddedFields() []string {
  4993. var fields []string
  4994. if m.addorganization_id != nil {
  4995. fields = append(fields, apikey.FieldOrganizationID)
  4996. }
  4997. return fields
  4998. }
  4999. // AddedField returns the numeric value that was incremented/decremented on a field
  5000. // with the given name. The second boolean return value indicates that this field
  5001. // was not set, or was not defined in the schema.
  5002. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  5003. switch name {
  5004. case apikey.FieldOrganizationID:
  5005. return m.AddedOrganizationID()
  5006. }
  5007. return nil, false
  5008. }
  5009. // AddField adds the value to the field with the given name. It returns an error if
  5010. // the field is not defined in the schema, or if the type mismatched the field
  5011. // type.
  5012. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  5013. switch name {
  5014. case apikey.FieldOrganizationID:
  5015. v, ok := value.(int64)
  5016. if !ok {
  5017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5018. }
  5019. m.AddOrganizationID(v)
  5020. return nil
  5021. }
  5022. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  5023. }
  5024. // ClearedFields returns all nullable fields that were cleared during this
  5025. // mutation.
  5026. func (m *ApiKeyMutation) ClearedFields() []string {
  5027. var fields []string
  5028. if m.FieldCleared(apikey.FieldDeletedAt) {
  5029. fields = append(fields, apikey.FieldDeletedAt)
  5030. }
  5031. if m.FieldCleared(apikey.FieldTitle) {
  5032. fields = append(fields, apikey.FieldTitle)
  5033. }
  5034. if m.FieldCleared(apikey.FieldKey) {
  5035. fields = append(fields, apikey.FieldKey)
  5036. }
  5037. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  5038. fields = append(fields, apikey.FieldCustomAgentBase)
  5039. }
  5040. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  5041. fields = append(fields, apikey.FieldCustomAgentKey)
  5042. }
  5043. if m.FieldCleared(apikey.FieldOpenaiBase) {
  5044. fields = append(fields, apikey.FieldOpenaiBase)
  5045. }
  5046. if m.FieldCleared(apikey.FieldOpenaiKey) {
  5047. fields = append(fields, apikey.FieldOpenaiKey)
  5048. }
  5049. return fields
  5050. }
  5051. // FieldCleared returns a boolean indicating if a field with the given name was
  5052. // cleared in this mutation.
  5053. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  5054. _, ok := m.clearedFields[name]
  5055. return ok
  5056. }
  5057. // ClearField clears the value of the field with the given name. It returns an
  5058. // error if the field is not defined in the schema.
  5059. func (m *ApiKeyMutation) ClearField(name string) error {
  5060. switch name {
  5061. case apikey.FieldDeletedAt:
  5062. m.ClearDeletedAt()
  5063. return nil
  5064. case apikey.FieldTitle:
  5065. m.ClearTitle()
  5066. return nil
  5067. case apikey.FieldKey:
  5068. m.ClearKey()
  5069. return nil
  5070. case apikey.FieldCustomAgentBase:
  5071. m.ClearCustomAgentBase()
  5072. return nil
  5073. case apikey.FieldCustomAgentKey:
  5074. m.ClearCustomAgentKey()
  5075. return nil
  5076. case apikey.FieldOpenaiBase:
  5077. m.ClearOpenaiBase()
  5078. return nil
  5079. case apikey.FieldOpenaiKey:
  5080. m.ClearOpenaiKey()
  5081. return nil
  5082. }
  5083. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5084. }
  5085. // ResetField resets all changes in the mutation for the field with the given name.
  5086. // It returns an error if the field is not defined in the schema.
  5087. func (m *ApiKeyMutation) ResetField(name string) error {
  5088. switch name {
  5089. case apikey.FieldCreatedAt:
  5090. m.ResetCreatedAt()
  5091. return nil
  5092. case apikey.FieldUpdatedAt:
  5093. m.ResetUpdatedAt()
  5094. return nil
  5095. case apikey.FieldDeletedAt:
  5096. m.ResetDeletedAt()
  5097. return nil
  5098. case apikey.FieldTitle:
  5099. m.ResetTitle()
  5100. return nil
  5101. case apikey.FieldKey:
  5102. m.ResetKey()
  5103. return nil
  5104. case apikey.FieldOrganizationID:
  5105. m.ResetOrganizationID()
  5106. return nil
  5107. case apikey.FieldAgentID:
  5108. m.ResetAgentID()
  5109. return nil
  5110. case apikey.FieldCustomAgentBase:
  5111. m.ResetCustomAgentBase()
  5112. return nil
  5113. case apikey.FieldCustomAgentKey:
  5114. m.ResetCustomAgentKey()
  5115. return nil
  5116. case apikey.FieldOpenaiBase:
  5117. m.ResetOpenaiBase()
  5118. return nil
  5119. case apikey.FieldOpenaiKey:
  5120. m.ResetOpenaiKey()
  5121. return nil
  5122. }
  5123. return fmt.Errorf("unknown ApiKey field %s", name)
  5124. }
  5125. // AddedEdges returns all edge names that were set/added in this mutation.
  5126. func (m *ApiKeyMutation) AddedEdges() []string {
  5127. edges := make([]string, 0, 1)
  5128. if m.agent != nil {
  5129. edges = append(edges, apikey.EdgeAgent)
  5130. }
  5131. return edges
  5132. }
  5133. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5134. // name in this mutation.
  5135. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5136. switch name {
  5137. case apikey.EdgeAgent:
  5138. if id := m.agent; id != nil {
  5139. return []ent.Value{*id}
  5140. }
  5141. }
  5142. return nil
  5143. }
  5144. // RemovedEdges returns all edge names that were removed in this mutation.
  5145. func (m *ApiKeyMutation) RemovedEdges() []string {
  5146. edges := make([]string, 0, 1)
  5147. return edges
  5148. }
  5149. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5150. // the given name in this mutation.
  5151. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5152. return nil
  5153. }
  5154. // ClearedEdges returns all edge names that were cleared in this mutation.
  5155. func (m *ApiKeyMutation) ClearedEdges() []string {
  5156. edges := make([]string, 0, 1)
  5157. if m.clearedagent {
  5158. edges = append(edges, apikey.EdgeAgent)
  5159. }
  5160. return edges
  5161. }
  5162. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5163. // was cleared in this mutation.
  5164. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5165. switch name {
  5166. case apikey.EdgeAgent:
  5167. return m.clearedagent
  5168. }
  5169. return false
  5170. }
  5171. // ClearEdge clears the value of the edge with the given name. It returns an error
  5172. // if that edge is not defined in the schema.
  5173. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5174. switch name {
  5175. case apikey.EdgeAgent:
  5176. m.ClearAgent()
  5177. return nil
  5178. }
  5179. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5180. }
  5181. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5182. // It returns an error if the edge is not defined in the schema.
  5183. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5184. switch name {
  5185. case apikey.EdgeAgent:
  5186. m.ResetAgent()
  5187. return nil
  5188. }
  5189. return fmt.Errorf("unknown ApiKey edge %s", name)
  5190. }
  5191. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5192. type BatchMsgMutation struct {
  5193. config
  5194. op Op
  5195. typ string
  5196. id *uint64
  5197. created_at *time.Time
  5198. updated_at *time.Time
  5199. deleted_at *time.Time
  5200. status *uint8
  5201. addstatus *int8
  5202. batch_no *string
  5203. task_name *string
  5204. fromwxid *string
  5205. msg *string
  5206. tag *string
  5207. tagids *string
  5208. total *int32
  5209. addtotal *int32
  5210. success *int32
  5211. addsuccess *int32
  5212. fail *int32
  5213. addfail *int32
  5214. start_time *time.Time
  5215. stop_time *time.Time
  5216. send_time *time.Time
  5217. _type *int32
  5218. add_type *int32
  5219. organization_id *uint64
  5220. addorganization_id *int64
  5221. ctype *uint64
  5222. addctype *int64
  5223. cc *string
  5224. phone *string
  5225. template_name *string
  5226. template_code *string
  5227. lang *string
  5228. clearedFields map[string]struct{}
  5229. done bool
  5230. oldValue func(context.Context) (*BatchMsg, error)
  5231. predicates []predicate.BatchMsg
  5232. }
  5233. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5234. // batchmsgOption allows management of the mutation configuration using functional options.
  5235. type batchmsgOption func(*BatchMsgMutation)
  5236. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5237. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5238. m := &BatchMsgMutation{
  5239. config: c,
  5240. op: op,
  5241. typ: TypeBatchMsg,
  5242. clearedFields: make(map[string]struct{}),
  5243. }
  5244. for _, opt := range opts {
  5245. opt(m)
  5246. }
  5247. return m
  5248. }
  5249. // withBatchMsgID sets the ID field of the mutation.
  5250. func withBatchMsgID(id uint64) batchmsgOption {
  5251. return func(m *BatchMsgMutation) {
  5252. var (
  5253. err error
  5254. once sync.Once
  5255. value *BatchMsg
  5256. )
  5257. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5258. once.Do(func() {
  5259. if m.done {
  5260. err = errors.New("querying old values post mutation is not allowed")
  5261. } else {
  5262. value, err = m.Client().BatchMsg.Get(ctx, id)
  5263. }
  5264. })
  5265. return value, err
  5266. }
  5267. m.id = &id
  5268. }
  5269. }
  5270. // withBatchMsg sets the old BatchMsg of the mutation.
  5271. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5272. return func(m *BatchMsgMutation) {
  5273. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5274. return node, nil
  5275. }
  5276. m.id = &node.ID
  5277. }
  5278. }
  5279. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5280. // executed in a transaction (ent.Tx), a transactional client is returned.
  5281. func (m BatchMsgMutation) Client() *Client {
  5282. client := &Client{config: m.config}
  5283. client.init()
  5284. return client
  5285. }
  5286. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5287. // it returns an error otherwise.
  5288. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5289. if _, ok := m.driver.(*txDriver); !ok {
  5290. return nil, errors.New("ent: mutation is not running in a transaction")
  5291. }
  5292. tx := &Tx{config: m.config}
  5293. tx.init()
  5294. return tx, nil
  5295. }
  5296. // SetID sets the value of the id field. Note that this
  5297. // operation is only accepted on creation of BatchMsg entities.
  5298. func (m *BatchMsgMutation) SetID(id uint64) {
  5299. m.id = &id
  5300. }
  5301. // ID returns the ID value in the mutation. Note that the ID is only available
  5302. // if it was provided to the builder or after it was returned from the database.
  5303. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5304. if m.id == nil {
  5305. return
  5306. }
  5307. return *m.id, true
  5308. }
  5309. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5310. // That means, if the mutation is applied within a transaction with an isolation level such
  5311. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5312. // or updated by the mutation.
  5313. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5314. switch {
  5315. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5316. id, exists := m.ID()
  5317. if exists {
  5318. return []uint64{id}, nil
  5319. }
  5320. fallthrough
  5321. case m.op.Is(OpUpdate | OpDelete):
  5322. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5323. default:
  5324. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5325. }
  5326. }
  5327. // SetCreatedAt sets the "created_at" field.
  5328. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5329. m.created_at = &t
  5330. }
  5331. // CreatedAt returns the value of the "created_at" field in the mutation.
  5332. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5333. v := m.created_at
  5334. if v == nil {
  5335. return
  5336. }
  5337. return *v, true
  5338. }
  5339. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5340. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5342. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5343. if !m.op.Is(OpUpdateOne) {
  5344. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5345. }
  5346. if m.id == nil || m.oldValue == nil {
  5347. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5348. }
  5349. oldValue, err := m.oldValue(ctx)
  5350. if err != nil {
  5351. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5352. }
  5353. return oldValue.CreatedAt, nil
  5354. }
  5355. // ResetCreatedAt resets all changes to the "created_at" field.
  5356. func (m *BatchMsgMutation) ResetCreatedAt() {
  5357. m.created_at = nil
  5358. }
  5359. // SetUpdatedAt sets the "updated_at" field.
  5360. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5361. m.updated_at = &t
  5362. }
  5363. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5364. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5365. v := m.updated_at
  5366. if v == nil {
  5367. return
  5368. }
  5369. return *v, true
  5370. }
  5371. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5372. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5374. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5375. if !m.op.Is(OpUpdateOne) {
  5376. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5377. }
  5378. if m.id == nil || m.oldValue == nil {
  5379. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5380. }
  5381. oldValue, err := m.oldValue(ctx)
  5382. if err != nil {
  5383. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5384. }
  5385. return oldValue.UpdatedAt, nil
  5386. }
  5387. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5388. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5389. m.updated_at = nil
  5390. }
  5391. // SetDeletedAt sets the "deleted_at" field.
  5392. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5393. m.deleted_at = &t
  5394. }
  5395. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5396. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5397. v := m.deleted_at
  5398. if v == nil {
  5399. return
  5400. }
  5401. return *v, true
  5402. }
  5403. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5404. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5406. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5407. if !m.op.Is(OpUpdateOne) {
  5408. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5409. }
  5410. if m.id == nil || m.oldValue == nil {
  5411. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5412. }
  5413. oldValue, err := m.oldValue(ctx)
  5414. if err != nil {
  5415. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5416. }
  5417. return oldValue.DeletedAt, nil
  5418. }
  5419. // ClearDeletedAt clears the value of the "deleted_at" field.
  5420. func (m *BatchMsgMutation) ClearDeletedAt() {
  5421. m.deleted_at = nil
  5422. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5423. }
  5424. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5425. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5426. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5427. return ok
  5428. }
  5429. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5430. func (m *BatchMsgMutation) ResetDeletedAt() {
  5431. m.deleted_at = nil
  5432. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5433. }
  5434. // SetStatus sets the "status" field.
  5435. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5436. m.status = &u
  5437. m.addstatus = nil
  5438. }
  5439. // Status returns the value of the "status" field in the mutation.
  5440. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5441. v := m.status
  5442. if v == nil {
  5443. return
  5444. }
  5445. return *v, true
  5446. }
  5447. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5448. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5450. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5451. if !m.op.Is(OpUpdateOne) {
  5452. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5453. }
  5454. if m.id == nil || m.oldValue == nil {
  5455. return v, errors.New("OldStatus requires an ID field in the mutation")
  5456. }
  5457. oldValue, err := m.oldValue(ctx)
  5458. if err != nil {
  5459. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5460. }
  5461. return oldValue.Status, nil
  5462. }
  5463. // AddStatus adds u to the "status" field.
  5464. func (m *BatchMsgMutation) AddStatus(u int8) {
  5465. if m.addstatus != nil {
  5466. *m.addstatus += u
  5467. } else {
  5468. m.addstatus = &u
  5469. }
  5470. }
  5471. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5472. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5473. v := m.addstatus
  5474. if v == nil {
  5475. return
  5476. }
  5477. return *v, true
  5478. }
  5479. // ClearStatus clears the value of the "status" field.
  5480. func (m *BatchMsgMutation) ClearStatus() {
  5481. m.status = nil
  5482. m.addstatus = nil
  5483. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5484. }
  5485. // StatusCleared returns if the "status" field was cleared in this mutation.
  5486. func (m *BatchMsgMutation) StatusCleared() bool {
  5487. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5488. return ok
  5489. }
  5490. // ResetStatus resets all changes to the "status" field.
  5491. func (m *BatchMsgMutation) ResetStatus() {
  5492. m.status = nil
  5493. m.addstatus = nil
  5494. delete(m.clearedFields, batchmsg.FieldStatus)
  5495. }
  5496. // SetBatchNo sets the "batch_no" field.
  5497. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5498. m.batch_no = &s
  5499. }
  5500. // BatchNo returns the value of the "batch_no" field in the mutation.
  5501. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5502. v := m.batch_no
  5503. if v == nil {
  5504. return
  5505. }
  5506. return *v, true
  5507. }
  5508. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5509. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5511. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5512. if !m.op.Is(OpUpdateOne) {
  5513. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5514. }
  5515. if m.id == nil || m.oldValue == nil {
  5516. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5517. }
  5518. oldValue, err := m.oldValue(ctx)
  5519. if err != nil {
  5520. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5521. }
  5522. return oldValue.BatchNo, nil
  5523. }
  5524. // ClearBatchNo clears the value of the "batch_no" field.
  5525. func (m *BatchMsgMutation) ClearBatchNo() {
  5526. m.batch_no = nil
  5527. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5528. }
  5529. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5530. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5531. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5532. return ok
  5533. }
  5534. // ResetBatchNo resets all changes to the "batch_no" field.
  5535. func (m *BatchMsgMutation) ResetBatchNo() {
  5536. m.batch_no = nil
  5537. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5538. }
  5539. // SetTaskName sets the "task_name" field.
  5540. func (m *BatchMsgMutation) SetTaskName(s string) {
  5541. m.task_name = &s
  5542. }
  5543. // TaskName returns the value of the "task_name" field in the mutation.
  5544. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5545. v := m.task_name
  5546. if v == nil {
  5547. return
  5548. }
  5549. return *v, true
  5550. }
  5551. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5552. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5554. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5555. if !m.op.Is(OpUpdateOne) {
  5556. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5557. }
  5558. if m.id == nil || m.oldValue == nil {
  5559. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5560. }
  5561. oldValue, err := m.oldValue(ctx)
  5562. if err != nil {
  5563. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5564. }
  5565. return oldValue.TaskName, nil
  5566. }
  5567. // ClearTaskName clears the value of the "task_name" field.
  5568. func (m *BatchMsgMutation) ClearTaskName() {
  5569. m.task_name = nil
  5570. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5571. }
  5572. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5573. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5574. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5575. return ok
  5576. }
  5577. // ResetTaskName resets all changes to the "task_name" field.
  5578. func (m *BatchMsgMutation) ResetTaskName() {
  5579. m.task_name = nil
  5580. delete(m.clearedFields, batchmsg.FieldTaskName)
  5581. }
  5582. // SetFromwxid sets the "fromwxid" field.
  5583. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5584. m.fromwxid = &s
  5585. }
  5586. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5587. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5588. v := m.fromwxid
  5589. if v == nil {
  5590. return
  5591. }
  5592. return *v, true
  5593. }
  5594. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5595. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5597. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5598. if !m.op.Is(OpUpdateOne) {
  5599. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5600. }
  5601. if m.id == nil || m.oldValue == nil {
  5602. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5603. }
  5604. oldValue, err := m.oldValue(ctx)
  5605. if err != nil {
  5606. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5607. }
  5608. return oldValue.Fromwxid, nil
  5609. }
  5610. // ClearFromwxid clears the value of the "fromwxid" field.
  5611. func (m *BatchMsgMutation) ClearFromwxid() {
  5612. m.fromwxid = nil
  5613. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5614. }
  5615. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5616. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5617. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5618. return ok
  5619. }
  5620. // ResetFromwxid resets all changes to the "fromwxid" field.
  5621. func (m *BatchMsgMutation) ResetFromwxid() {
  5622. m.fromwxid = nil
  5623. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5624. }
  5625. // SetMsg sets the "msg" field.
  5626. func (m *BatchMsgMutation) SetMsg(s string) {
  5627. m.msg = &s
  5628. }
  5629. // Msg returns the value of the "msg" field in the mutation.
  5630. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5631. v := m.msg
  5632. if v == nil {
  5633. return
  5634. }
  5635. return *v, true
  5636. }
  5637. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5638. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5640. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5641. if !m.op.Is(OpUpdateOne) {
  5642. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5643. }
  5644. if m.id == nil || m.oldValue == nil {
  5645. return v, errors.New("OldMsg requires an ID field in the mutation")
  5646. }
  5647. oldValue, err := m.oldValue(ctx)
  5648. if err != nil {
  5649. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5650. }
  5651. return oldValue.Msg, nil
  5652. }
  5653. // ClearMsg clears the value of the "msg" field.
  5654. func (m *BatchMsgMutation) ClearMsg() {
  5655. m.msg = nil
  5656. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5657. }
  5658. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5659. func (m *BatchMsgMutation) MsgCleared() bool {
  5660. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5661. return ok
  5662. }
  5663. // ResetMsg resets all changes to the "msg" field.
  5664. func (m *BatchMsgMutation) ResetMsg() {
  5665. m.msg = nil
  5666. delete(m.clearedFields, batchmsg.FieldMsg)
  5667. }
  5668. // SetTag sets the "tag" field.
  5669. func (m *BatchMsgMutation) SetTag(s string) {
  5670. m.tag = &s
  5671. }
  5672. // Tag returns the value of the "tag" field in the mutation.
  5673. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5674. v := m.tag
  5675. if v == nil {
  5676. return
  5677. }
  5678. return *v, true
  5679. }
  5680. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5681. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5683. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5684. if !m.op.Is(OpUpdateOne) {
  5685. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5686. }
  5687. if m.id == nil || m.oldValue == nil {
  5688. return v, errors.New("OldTag requires an ID field in the mutation")
  5689. }
  5690. oldValue, err := m.oldValue(ctx)
  5691. if err != nil {
  5692. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5693. }
  5694. return oldValue.Tag, nil
  5695. }
  5696. // ClearTag clears the value of the "tag" field.
  5697. func (m *BatchMsgMutation) ClearTag() {
  5698. m.tag = nil
  5699. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5700. }
  5701. // TagCleared returns if the "tag" field was cleared in this mutation.
  5702. func (m *BatchMsgMutation) TagCleared() bool {
  5703. _, ok := m.clearedFields[batchmsg.FieldTag]
  5704. return ok
  5705. }
  5706. // ResetTag resets all changes to the "tag" field.
  5707. func (m *BatchMsgMutation) ResetTag() {
  5708. m.tag = nil
  5709. delete(m.clearedFields, batchmsg.FieldTag)
  5710. }
  5711. // SetTagids sets the "tagids" field.
  5712. func (m *BatchMsgMutation) SetTagids(s string) {
  5713. m.tagids = &s
  5714. }
  5715. // Tagids returns the value of the "tagids" field in the mutation.
  5716. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5717. v := m.tagids
  5718. if v == nil {
  5719. return
  5720. }
  5721. return *v, true
  5722. }
  5723. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5724. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5726. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5727. if !m.op.Is(OpUpdateOne) {
  5728. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5729. }
  5730. if m.id == nil || m.oldValue == nil {
  5731. return v, errors.New("OldTagids requires an ID field in the mutation")
  5732. }
  5733. oldValue, err := m.oldValue(ctx)
  5734. if err != nil {
  5735. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5736. }
  5737. return oldValue.Tagids, nil
  5738. }
  5739. // ClearTagids clears the value of the "tagids" field.
  5740. func (m *BatchMsgMutation) ClearTagids() {
  5741. m.tagids = nil
  5742. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5743. }
  5744. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5745. func (m *BatchMsgMutation) TagidsCleared() bool {
  5746. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5747. return ok
  5748. }
  5749. // ResetTagids resets all changes to the "tagids" field.
  5750. func (m *BatchMsgMutation) ResetTagids() {
  5751. m.tagids = nil
  5752. delete(m.clearedFields, batchmsg.FieldTagids)
  5753. }
  5754. // SetTotal sets the "total" field.
  5755. func (m *BatchMsgMutation) SetTotal(i int32) {
  5756. m.total = &i
  5757. m.addtotal = nil
  5758. }
  5759. // Total returns the value of the "total" field in the mutation.
  5760. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5761. v := m.total
  5762. if v == nil {
  5763. return
  5764. }
  5765. return *v, true
  5766. }
  5767. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5768. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5770. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5771. if !m.op.Is(OpUpdateOne) {
  5772. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5773. }
  5774. if m.id == nil || m.oldValue == nil {
  5775. return v, errors.New("OldTotal requires an ID field in the mutation")
  5776. }
  5777. oldValue, err := m.oldValue(ctx)
  5778. if err != nil {
  5779. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5780. }
  5781. return oldValue.Total, nil
  5782. }
  5783. // AddTotal adds i to the "total" field.
  5784. func (m *BatchMsgMutation) AddTotal(i int32) {
  5785. if m.addtotal != nil {
  5786. *m.addtotal += i
  5787. } else {
  5788. m.addtotal = &i
  5789. }
  5790. }
  5791. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5792. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5793. v := m.addtotal
  5794. if v == nil {
  5795. return
  5796. }
  5797. return *v, true
  5798. }
  5799. // ClearTotal clears the value of the "total" field.
  5800. func (m *BatchMsgMutation) ClearTotal() {
  5801. m.total = nil
  5802. m.addtotal = nil
  5803. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5804. }
  5805. // TotalCleared returns if the "total" field was cleared in this mutation.
  5806. func (m *BatchMsgMutation) TotalCleared() bool {
  5807. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5808. return ok
  5809. }
  5810. // ResetTotal resets all changes to the "total" field.
  5811. func (m *BatchMsgMutation) ResetTotal() {
  5812. m.total = nil
  5813. m.addtotal = nil
  5814. delete(m.clearedFields, batchmsg.FieldTotal)
  5815. }
  5816. // SetSuccess sets the "success" field.
  5817. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5818. m.success = &i
  5819. m.addsuccess = nil
  5820. }
  5821. // Success returns the value of the "success" field in the mutation.
  5822. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5823. v := m.success
  5824. if v == nil {
  5825. return
  5826. }
  5827. return *v, true
  5828. }
  5829. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5830. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5832. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  5833. if !m.op.Is(OpUpdateOne) {
  5834. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  5835. }
  5836. if m.id == nil || m.oldValue == nil {
  5837. return v, errors.New("OldSuccess requires an ID field in the mutation")
  5838. }
  5839. oldValue, err := m.oldValue(ctx)
  5840. if err != nil {
  5841. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  5842. }
  5843. return oldValue.Success, nil
  5844. }
  5845. // AddSuccess adds i to the "success" field.
  5846. func (m *BatchMsgMutation) AddSuccess(i int32) {
  5847. if m.addsuccess != nil {
  5848. *m.addsuccess += i
  5849. } else {
  5850. m.addsuccess = &i
  5851. }
  5852. }
  5853. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  5854. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  5855. v := m.addsuccess
  5856. if v == nil {
  5857. return
  5858. }
  5859. return *v, true
  5860. }
  5861. // ClearSuccess clears the value of the "success" field.
  5862. func (m *BatchMsgMutation) ClearSuccess() {
  5863. m.success = nil
  5864. m.addsuccess = nil
  5865. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  5866. }
  5867. // SuccessCleared returns if the "success" field was cleared in this mutation.
  5868. func (m *BatchMsgMutation) SuccessCleared() bool {
  5869. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  5870. return ok
  5871. }
  5872. // ResetSuccess resets all changes to the "success" field.
  5873. func (m *BatchMsgMutation) ResetSuccess() {
  5874. m.success = nil
  5875. m.addsuccess = nil
  5876. delete(m.clearedFields, batchmsg.FieldSuccess)
  5877. }
  5878. // SetFail sets the "fail" field.
  5879. func (m *BatchMsgMutation) SetFail(i int32) {
  5880. m.fail = &i
  5881. m.addfail = nil
  5882. }
  5883. // Fail returns the value of the "fail" field in the mutation.
  5884. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  5885. v := m.fail
  5886. if v == nil {
  5887. return
  5888. }
  5889. return *v, true
  5890. }
  5891. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  5892. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5894. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  5895. if !m.op.Is(OpUpdateOne) {
  5896. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  5897. }
  5898. if m.id == nil || m.oldValue == nil {
  5899. return v, errors.New("OldFail requires an ID field in the mutation")
  5900. }
  5901. oldValue, err := m.oldValue(ctx)
  5902. if err != nil {
  5903. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  5904. }
  5905. return oldValue.Fail, nil
  5906. }
  5907. // AddFail adds i to the "fail" field.
  5908. func (m *BatchMsgMutation) AddFail(i int32) {
  5909. if m.addfail != nil {
  5910. *m.addfail += i
  5911. } else {
  5912. m.addfail = &i
  5913. }
  5914. }
  5915. // AddedFail returns the value that was added to the "fail" field in this mutation.
  5916. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  5917. v := m.addfail
  5918. if v == nil {
  5919. return
  5920. }
  5921. return *v, true
  5922. }
  5923. // ClearFail clears the value of the "fail" field.
  5924. func (m *BatchMsgMutation) ClearFail() {
  5925. m.fail = nil
  5926. m.addfail = nil
  5927. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  5928. }
  5929. // FailCleared returns if the "fail" field was cleared in this mutation.
  5930. func (m *BatchMsgMutation) FailCleared() bool {
  5931. _, ok := m.clearedFields[batchmsg.FieldFail]
  5932. return ok
  5933. }
  5934. // ResetFail resets all changes to the "fail" field.
  5935. func (m *BatchMsgMutation) ResetFail() {
  5936. m.fail = nil
  5937. m.addfail = nil
  5938. delete(m.clearedFields, batchmsg.FieldFail)
  5939. }
  5940. // SetStartTime sets the "start_time" field.
  5941. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  5942. m.start_time = &t
  5943. }
  5944. // StartTime returns the value of the "start_time" field in the mutation.
  5945. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  5946. v := m.start_time
  5947. if v == nil {
  5948. return
  5949. }
  5950. return *v, true
  5951. }
  5952. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  5953. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5955. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  5956. if !m.op.Is(OpUpdateOne) {
  5957. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  5958. }
  5959. if m.id == nil || m.oldValue == nil {
  5960. return v, errors.New("OldStartTime requires an ID field in the mutation")
  5961. }
  5962. oldValue, err := m.oldValue(ctx)
  5963. if err != nil {
  5964. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  5965. }
  5966. return oldValue.StartTime, nil
  5967. }
  5968. // ClearStartTime clears the value of the "start_time" field.
  5969. func (m *BatchMsgMutation) ClearStartTime() {
  5970. m.start_time = nil
  5971. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  5972. }
  5973. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  5974. func (m *BatchMsgMutation) StartTimeCleared() bool {
  5975. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  5976. return ok
  5977. }
  5978. // ResetStartTime resets all changes to the "start_time" field.
  5979. func (m *BatchMsgMutation) ResetStartTime() {
  5980. m.start_time = nil
  5981. delete(m.clearedFields, batchmsg.FieldStartTime)
  5982. }
  5983. // SetStopTime sets the "stop_time" field.
  5984. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  5985. m.stop_time = &t
  5986. }
  5987. // StopTime returns the value of the "stop_time" field in the mutation.
  5988. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  5989. v := m.stop_time
  5990. if v == nil {
  5991. return
  5992. }
  5993. return *v, true
  5994. }
  5995. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  5996. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5998. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  5999. if !m.op.Is(OpUpdateOne) {
  6000. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  6001. }
  6002. if m.id == nil || m.oldValue == nil {
  6003. return v, errors.New("OldStopTime requires an ID field in the mutation")
  6004. }
  6005. oldValue, err := m.oldValue(ctx)
  6006. if err != nil {
  6007. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  6008. }
  6009. return oldValue.StopTime, nil
  6010. }
  6011. // ClearStopTime clears the value of the "stop_time" field.
  6012. func (m *BatchMsgMutation) ClearStopTime() {
  6013. m.stop_time = nil
  6014. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  6015. }
  6016. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  6017. func (m *BatchMsgMutation) StopTimeCleared() bool {
  6018. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  6019. return ok
  6020. }
  6021. // ResetStopTime resets all changes to the "stop_time" field.
  6022. func (m *BatchMsgMutation) ResetStopTime() {
  6023. m.stop_time = nil
  6024. delete(m.clearedFields, batchmsg.FieldStopTime)
  6025. }
  6026. // SetSendTime sets the "send_time" field.
  6027. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  6028. m.send_time = &t
  6029. }
  6030. // SendTime returns the value of the "send_time" field in the mutation.
  6031. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  6032. v := m.send_time
  6033. if v == nil {
  6034. return
  6035. }
  6036. return *v, true
  6037. }
  6038. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  6039. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6041. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6042. if !m.op.Is(OpUpdateOne) {
  6043. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6044. }
  6045. if m.id == nil || m.oldValue == nil {
  6046. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6047. }
  6048. oldValue, err := m.oldValue(ctx)
  6049. if err != nil {
  6050. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6051. }
  6052. return oldValue.SendTime, nil
  6053. }
  6054. // ClearSendTime clears the value of the "send_time" field.
  6055. func (m *BatchMsgMutation) ClearSendTime() {
  6056. m.send_time = nil
  6057. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  6058. }
  6059. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6060. func (m *BatchMsgMutation) SendTimeCleared() bool {
  6061. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  6062. return ok
  6063. }
  6064. // ResetSendTime resets all changes to the "send_time" field.
  6065. func (m *BatchMsgMutation) ResetSendTime() {
  6066. m.send_time = nil
  6067. delete(m.clearedFields, batchmsg.FieldSendTime)
  6068. }
  6069. // SetType sets the "type" field.
  6070. func (m *BatchMsgMutation) SetType(i int32) {
  6071. m._type = &i
  6072. m.add_type = nil
  6073. }
  6074. // GetType returns the value of the "type" field in the mutation.
  6075. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6076. v := m._type
  6077. if v == nil {
  6078. return
  6079. }
  6080. return *v, true
  6081. }
  6082. // OldType returns the old "type" field's value of the BatchMsg entity.
  6083. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6085. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6086. if !m.op.Is(OpUpdateOne) {
  6087. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6088. }
  6089. if m.id == nil || m.oldValue == nil {
  6090. return v, errors.New("OldType requires an ID field in the mutation")
  6091. }
  6092. oldValue, err := m.oldValue(ctx)
  6093. if err != nil {
  6094. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6095. }
  6096. return oldValue.Type, nil
  6097. }
  6098. // AddType adds i to the "type" field.
  6099. func (m *BatchMsgMutation) AddType(i int32) {
  6100. if m.add_type != nil {
  6101. *m.add_type += i
  6102. } else {
  6103. m.add_type = &i
  6104. }
  6105. }
  6106. // AddedType returns the value that was added to the "type" field in this mutation.
  6107. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6108. v := m.add_type
  6109. if v == nil {
  6110. return
  6111. }
  6112. return *v, true
  6113. }
  6114. // ClearType clears the value of the "type" field.
  6115. func (m *BatchMsgMutation) ClearType() {
  6116. m._type = nil
  6117. m.add_type = nil
  6118. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6119. }
  6120. // TypeCleared returns if the "type" field was cleared in this mutation.
  6121. func (m *BatchMsgMutation) TypeCleared() bool {
  6122. _, ok := m.clearedFields[batchmsg.FieldType]
  6123. return ok
  6124. }
  6125. // ResetType resets all changes to the "type" field.
  6126. func (m *BatchMsgMutation) ResetType() {
  6127. m._type = nil
  6128. m.add_type = nil
  6129. delete(m.clearedFields, batchmsg.FieldType)
  6130. }
  6131. // SetOrganizationID sets the "organization_id" field.
  6132. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6133. m.organization_id = &u
  6134. m.addorganization_id = nil
  6135. }
  6136. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6137. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6138. v := m.organization_id
  6139. if v == nil {
  6140. return
  6141. }
  6142. return *v, true
  6143. }
  6144. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6145. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6147. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6148. if !m.op.Is(OpUpdateOne) {
  6149. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6150. }
  6151. if m.id == nil || m.oldValue == nil {
  6152. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6153. }
  6154. oldValue, err := m.oldValue(ctx)
  6155. if err != nil {
  6156. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6157. }
  6158. return oldValue.OrganizationID, nil
  6159. }
  6160. // AddOrganizationID adds u to the "organization_id" field.
  6161. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6162. if m.addorganization_id != nil {
  6163. *m.addorganization_id += u
  6164. } else {
  6165. m.addorganization_id = &u
  6166. }
  6167. }
  6168. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6169. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6170. v := m.addorganization_id
  6171. if v == nil {
  6172. return
  6173. }
  6174. return *v, true
  6175. }
  6176. // ResetOrganizationID resets all changes to the "organization_id" field.
  6177. func (m *BatchMsgMutation) ResetOrganizationID() {
  6178. m.organization_id = nil
  6179. m.addorganization_id = nil
  6180. }
  6181. // SetCtype sets the "ctype" field.
  6182. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6183. m.ctype = &u
  6184. m.addctype = nil
  6185. }
  6186. // Ctype returns the value of the "ctype" field in the mutation.
  6187. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6188. v := m.ctype
  6189. if v == nil {
  6190. return
  6191. }
  6192. return *v, true
  6193. }
  6194. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6195. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6197. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6198. if !m.op.Is(OpUpdateOne) {
  6199. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6200. }
  6201. if m.id == nil || m.oldValue == nil {
  6202. return v, errors.New("OldCtype requires an ID field in the mutation")
  6203. }
  6204. oldValue, err := m.oldValue(ctx)
  6205. if err != nil {
  6206. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6207. }
  6208. return oldValue.Ctype, nil
  6209. }
  6210. // AddCtype adds u to the "ctype" field.
  6211. func (m *BatchMsgMutation) AddCtype(u int64) {
  6212. if m.addctype != nil {
  6213. *m.addctype += u
  6214. } else {
  6215. m.addctype = &u
  6216. }
  6217. }
  6218. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6219. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6220. v := m.addctype
  6221. if v == nil {
  6222. return
  6223. }
  6224. return *v, true
  6225. }
  6226. // ResetCtype resets all changes to the "ctype" field.
  6227. func (m *BatchMsgMutation) ResetCtype() {
  6228. m.ctype = nil
  6229. m.addctype = nil
  6230. }
  6231. // SetCc sets the "cc" field.
  6232. func (m *BatchMsgMutation) SetCc(s string) {
  6233. m.cc = &s
  6234. }
  6235. // Cc returns the value of the "cc" field in the mutation.
  6236. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6237. v := m.cc
  6238. if v == nil {
  6239. return
  6240. }
  6241. return *v, true
  6242. }
  6243. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6244. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6246. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6247. if !m.op.Is(OpUpdateOne) {
  6248. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6249. }
  6250. if m.id == nil || m.oldValue == nil {
  6251. return v, errors.New("OldCc requires an ID field in the mutation")
  6252. }
  6253. oldValue, err := m.oldValue(ctx)
  6254. if err != nil {
  6255. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6256. }
  6257. return oldValue.Cc, nil
  6258. }
  6259. // ClearCc clears the value of the "cc" field.
  6260. func (m *BatchMsgMutation) ClearCc() {
  6261. m.cc = nil
  6262. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6263. }
  6264. // CcCleared returns if the "cc" field was cleared in this mutation.
  6265. func (m *BatchMsgMutation) CcCleared() bool {
  6266. _, ok := m.clearedFields[batchmsg.FieldCc]
  6267. return ok
  6268. }
  6269. // ResetCc resets all changes to the "cc" field.
  6270. func (m *BatchMsgMutation) ResetCc() {
  6271. m.cc = nil
  6272. delete(m.clearedFields, batchmsg.FieldCc)
  6273. }
  6274. // SetPhone sets the "phone" field.
  6275. func (m *BatchMsgMutation) SetPhone(s string) {
  6276. m.phone = &s
  6277. }
  6278. // Phone returns the value of the "phone" field in the mutation.
  6279. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6280. v := m.phone
  6281. if v == nil {
  6282. return
  6283. }
  6284. return *v, true
  6285. }
  6286. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6287. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6289. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6290. if !m.op.Is(OpUpdateOne) {
  6291. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6292. }
  6293. if m.id == nil || m.oldValue == nil {
  6294. return v, errors.New("OldPhone requires an ID field in the mutation")
  6295. }
  6296. oldValue, err := m.oldValue(ctx)
  6297. if err != nil {
  6298. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6299. }
  6300. return oldValue.Phone, nil
  6301. }
  6302. // ClearPhone clears the value of the "phone" field.
  6303. func (m *BatchMsgMutation) ClearPhone() {
  6304. m.phone = nil
  6305. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6306. }
  6307. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6308. func (m *BatchMsgMutation) PhoneCleared() bool {
  6309. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6310. return ok
  6311. }
  6312. // ResetPhone resets all changes to the "phone" field.
  6313. func (m *BatchMsgMutation) ResetPhone() {
  6314. m.phone = nil
  6315. delete(m.clearedFields, batchmsg.FieldPhone)
  6316. }
  6317. // SetTemplateName sets the "template_name" field.
  6318. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6319. m.template_name = &s
  6320. }
  6321. // TemplateName returns the value of the "template_name" field in the mutation.
  6322. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6323. v := m.template_name
  6324. if v == nil {
  6325. return
  6326. }
  6327. return *v, true
  6328. }
  6329. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6330. // If the BatchMsg 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 *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6333. if !m.op.Is(OpUpdateOne) {
  6334. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6335. }
  6336. if m.id == nil || m.oldValue == nil {
  6337. return v, errors.New("OldTemplateName 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 OldTemplateName: %w", err)
  6342. }
  6343. return oldValue.TemplateName, nil
  6344. }
  6345. // ClearTemplateName clears the value of the "template_name" field.
  6346. func (m *BatchMsgMutation) ClearTemplateName() {
  6347. m.template_name = nil
  6348. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6349. }
  6350. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6351. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6352. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6353. return ok
  6354. }
  6355. // ResetTemplateName resets all changes to the "template_name" field.
  6356. func (m *BatchMsgMutation) ResetTemplateName() {
  6357. m.template_name = nil
  6358. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6359. }
  6360. // SetTemplateCode sets the "template_code" field.
  6361. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6362. m.template_code = &s
  6363. }
  6364. // TemplateCode returns the value of the "template_code" field in the mutation.
  6365. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6366. v := m.template_code
  6367. if v == nil {
  6368. return
  6369. }
  6370. return *v, true
  6371. }
  6372. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6373. // If the BatchMsg 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 *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6376. if !m.op.Is(OpUpdateOne) {
  6377. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6378. }
  6379. if m.id == nil || m.oldValue == nil {
  6380. return v, errors.New("OldTemplateCode 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 OldTemplateCode: %w", err)
  6385. }
  6386. return oldValue.TemplateCode, nil
  6387. }
  6388. // ClearTemplateCode clears the value of the "template_code" field.
  6389. func (m *BatchMsgMutation) ClearTemplateCode() {
  6390. m.template_code = nil
  6391. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6392. }
  6393. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6394. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6395. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6396. return ok
  6397. }
  6398. // ResetTemplateCode resets all changes to the "template_code" field.
  6399. func (m *BatchMsgMutation) ResetTemplateCode() {
  6400. m.template_code = nil
  6401. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6402. }
  6403. // SetLang sets the "lang" field.
  6404. func (m *BatchMsgMutation) SetLang(s string) {
  6405. m.lang = &s
  6406. }
  6407. // Lang returns the value of the "lang" field in the mutation.
  6408. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6409. v := m.lang
  6410. if v == nil {
  6411. return
  6412. }
  6413. return *v, true
  6414. }
  6415. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6416. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6418. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6419. if !m.op.Is(OpUpdateOne) {
  6420. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6421. }
  6422. if m.id == nil || m.oldValue == nil {
  6423. return v, errors.New("OldLang requires an ID field in the mutation")
  6424. }
  6425. oldValue, err := m.oldValue(ctx)
  6426. if err != nil {
  6427. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6428. }
  6429. return oldValue.Lang, nil
  6430. }
  6431. // ClearLang clears the value of the "lang" field.
  6432. func (m *BatchMsgMutation) ClearLang() {
  6433. m.lang = nil
  6434. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6435. }
  6436. // LangCleared returns if the "lang" field was cleared in this mutation.
  6437. func (m *BatchMsgMutation) LangCleared() bool {
  6438. _, ok := m.clearedFields[batchmsg.FieldLang]
  6439. return ok
  6440. }
  6441. // ResetLang resets all changes to the "lang" field.
  6442. func (m *BatchMsgMutation) ResetLang() {
  6443. m.lang = nil
  6444. delete(m.clearedFields, batchmsg.FieldLang)
  6445. }
  6446. // Where appends a list predicates to the BatchMsgMutation builder.
  6447. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6448. m.predicates = append(m.predicates, ps...)
  6449. }
  6450. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6451. // users can use type-assertion to append predicates that do not depend on any generated package.
  6452. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6453. p := make([]predicate.BatchMsg, len(ps))
  6454. for i := range ps {
  6455. p[i] = ps[i]
  6456. }
  6457. m.Where(p...)
  6458. }
  6459. // Op returns the operation name.
  6460. func (m *BatchMsgMutation) Op() Op {
  6461. return m.op
  6462. }
  6463. // SetOp allows setting the mutation operation.
  6464. func (m *BatchMsgMutation) SetOp(op Op) {
  6465. m.op = op
  6466. }
  6467. // Type returns the node type of this mutation (BatchMsg).
  6468. func (m *BatchMsgMutation) Type() string {
  6469. return m.typ
  6470. }
  6471. // Fields returns all fields that were changed during this mutation. Note that in
  6472. // order to get all numeric fields that were incremented/decremented, call
  6473. // AddedFields().
  6474. func (m *BatchMsgMutation) Fields() []string {
  6475. fields := make([]string, 0, 24)
  6476. if m.created_at != nil {
  6477. fields = append(fields, batchmsg.FieldCreatedAt)
  6478. }
  6479. if m.updated_at != nil {
  6480. fields = append(fields, batchmsg.FieldUpdatedAt)
  6481. }
  6482. if m.deleted_at != nil {
  6483. fields = append(fields, batchmsg.FieldDeletedAt)
  6484. }
  6485. if m.status != nil {
  6486. fields = append(fields, batchmsg.FieldStatus)
  6487. }
  6488. if m.batch_no != nil {
  6489. fields = append(fields, batchmsg.FieldBatchNo)
  6490. }
  6491. if m.task_name != nil {
  6492. fields = append(fields, batchmsg.FieldTaskName)
  6493. }
  6494. if m.fromwxid != nil {
  6495. fields = append(fields, batchmsg.FieldFromwxid)
  6496. }
  6497. if m.msg != nil {
  6498. fields = append(fields, batchmsg.FieldMsg)
  6499. }
  6500. if m.tag != nil {
  6501. fields = append(fields, batchmsg.FieldTag)
  6502. }
  6503. if m.tagids != nil {
  6504. fields = append(fields, batchmsg.FieldTagids)
  6505. }
  6506. if m.total != nil {
  6507. fields = append(fields, batchmsg.FieldTotal)
  6508. }
  6509. if m.success != nil {
  6510. fields = append(fields, batchmsg.FieldSuccess)
  6511. }
  6512. if m.fail != nil {
  6513. fields = append(fields, batchmsg.FieldFail)
  6514. }
  6515. if m.start_time != nil {
  6516. fields = append(fields, batchmsg.FieldStartTime)
  6517. }
  6518. if m.stop_time != nil {
  6519. fields = append(fields, batchmsg.FieldStopTime)
  6520. }
  6521. if m.send_time != nil {
  6522. fields = append(fields, batchmsg.FieldSendTime)
  6523. }
  6524. if m._type != nil {
  6525. fields = append(fields, batchmsg.FieldType)
  6526. }
  6527. if m.organization_id != nil {
  6528. fields = append(fields, batchmsg.FieldOrganizationID)
  6529. }
  6530. if m.ctype != nil {
  6531. fields = append(fields, batchmsg.FieldCtype)
  6532. }
  6533. if m.cc != nil {
  6534. fields = append(fields, batchmsg.FieldCc)
  6535. }
  6536. if m.phone != nil {
  6537. fields = append(fields, batchmsg.FieldPhone)
  6538. }
  6539. if m.template_name != nil {
  6540. fields = append(fields, batchmsg.FieldTemplateName)
  6541. }
  6542. if m.template_code != nil {
  6543. fields = append(fields, batchmsg.FieldTemplateCode)
  6544. }
  6545. if m.lang != nil {
  6546. fields = append(fields, batchmsg.FieldLang)
  6547. }
  6548. return fields
  6549. }
  6550. // Field returns the value of a field with the given name. The second boolean
  6551. // return value indicates that this field was not set, or was not defined in the
  6552. // schema.
  6553. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6554. switch name {
  6555. case batchmsg.FieldCreatedAt:
  6556. return m.CreatedAt()
  6557. case batchmsg.FieldUpdatedAt:
  6558. return m.UpdatedAt()
  6559. case batchmsg.FieldDeletedAt:
  6560. return m.DeletedAt()
  6561. case batchmsg.FieldStatus:
  6562. return m.Status()
  6563. case batchmsg.FieldBatchNo:
  6564. return m.BatchNo()
  6565. case batchmsg.FieldTaskName:
  6566. return m.TaskName()
  6567. case batchmsg.FieldFromwxid:
  6568. return m.Fromwxid()
  6569. case batchmsg.FieldMsg:
  6570. return m.Msg()
  6571. case batchmsg.FieldTag:
  6572. return m.Tag()
  6573. case batchmsg.FieldTagids:
  6574. return m.Tagids()
  6575. case batchmsg.FieldTotal:
  6576. return m.Total()
  6577. case batchmsg.FieldSuccess:
  6578. return m.Success()
  6579. case batchmsg.FieldFail:
  6580. return m.Fail()
  6581. case batchmsg.FieldStartTime:
  6582. return m.StartTime()
  6583. case batchmsg.FieldStopTime:
  6584. return m.StopTime()
  6585. case batchmsg.FieldSendTime:
  6586. return m.SendTime()
  6587. case batchmsg.FieldType:
  6588. return m.GetType()
  6589. case batchmsg.FieldOrganizationID:
  6590. return m.OrganizationID()
  6591. case batchmsg.FieldCtype:
  6592. return m.Ctype()
  6593. case batchmsg.FieldCc:
  6594. return m.Cc()
  6595. case batchmsg.FieldPhone:
  6596. return m.Phone()
  6597. case batchmsg.FieldTemplateName:
  6598. return m.TemplateName()
  6599. case batchmsg.FieldTemplateCode:
  6600. return m.TemplateCode()
  6601. case batchmsg.FieldLang:
  6602. return m.Lang()
  6603. }
  6604. return nil, false
  6605. }
  6606. // OldField returns the old value of the field from the database. An error is
  6607. // returned if the mutation operation is not UpdateOne, or the query to the
  6608. // database failed.
  6609. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6610. switch name {
  6611. case batchmsg.FieldCreatedAt:
  6612. return m.OldCreatedAt(ctx)
  6613. case batchmsg.FieldUpdatedAt:
  6614. return m.OldUpdatedAt(ctx)
  6615. case batchmsg.FieldDeletedAt:
  6616. return m.OldDeletedAt(ctx)
  6617. case batchmsg.FieldStatus:
  6618. return m.OldStatus(ctx)
  6619. case batchmsg.FieldBatchNo:
  6620. return m.OldBatchNo(ctx)
  6621. case batchmsg.FieldTaskName:
  6622. return m.OldTaskName(ctx)
  6623. case batchmsg.FieldFromwxid:
  6624. return m.OldFromwxid(ctx)
  6625. case batchmsg.FieldMsg:
  6626. return m.OldMsg(ctx)
  6627. case batchmsg.FieldTag:
  6628. return m.OldTag(ctx)
  6629. case batchmsg.FieldTagids:
  6630. return m.OldTagids(ctx)
  6631. case batchmsg.FieldTotal:
  6632. return m.OldTotal(ctx)
  6633. case batchmsg.FieldSuccess:
  6634. return m.OldSuccess(ctx)
  6635. case batchmsg.FieldFail:
  6636. return m.OldFail(ctx)
  6637. case batchmsg.FieldStartTime:
  6638. return m.OldStartTime(ctx)
  6639. case batchmsg.FieldStopTime:
  6640. return m.OldStopTime(ctx)
  6641. case batchmsg.FieldSendTime:
  6642. return m.OldSendTime(ctx)
  6643. case batchmsg.FieldType:
  6644. return m.OldType(ctx)
  6645. case batchmsg.FieldOrganizationID:
  6646. return m.OldOrganizationID(ctx)
  6647. case batchmsg.FieldCtype:
  6648. return m.OldCtype(ctx)
  6649. case batchmsg.FieldCc:
  6650. return m.OldCc(ctx)
  6651. case batchmsg.FieldPhone:
  6652. return m.OldPhone(ctx)
  6653. case batchmsg.FieldTemplateName:
  6654. return m.OldTemplateName(ctx)
  6655. case batchmsg.FieldTemplateCode:
  6656. return m.OldTemplateCode(ctx)
  6657. case batchmsg.FieldLang:
  6658. return m.OldLang(ctx)
  6659. }
  6660. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6661. }
  6662. // SetField sets the value of a field with the given name. It returns an error if
  6663. // the field is not defined in the schema, or if the type mismatched the field
  6664. // type.
  6665. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6666. switch name {
  6667. case batchmsg.FieldCreatedAt:
  6668. v, ok := value.(time.Time)
  6669. if !ok {
  6670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6671. }
  6672. m.SetCreatedAt(v)
  6673. return nil
  6674. case batchmsg.FieldUpdatedAt:
  6675. v, ok := value.(time.Time)
  6676. if !ok {
  6677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6678. }
  6679. m.SetUpdatedAt(v)
  6680. return nil
  6681. case batchmsg.FieldDeletedAt:
  6682. v, ok := value.(time.Time)
  6683. if !ok {
  6684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6685. }
  6686. m.SetDeletedAt(v)
  6687. return nil
  6688. case batchmsg.FieldStatus:
  6689. v, ok := value.(uint8)
  6690. if !ok {
  6691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6692. }
  6693. m.SetStatus(v)
  6694. return nil
  6695. case batchmsg.FieldBatchNo:
  6696. v, ok := value.(string)
  6697. if !ok {
  6698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6699. }
  6700. m.SetBatchNo(v)
  6701. return nil
  6702. case batchmsg.FieldTaskName:
  6703. v, ok := value.(string)
  6704. if !ok {
  6705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6706. }
  6707. m.SetTaskName(v)
  6708. return nil
  6709. case batchmsg.FieldFromwxid:
  6710. v, ok := value.(string)
  6711. if !ok {
  6712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6713. }
  6714. m.SetFromwxid(v)
  6715. return nil
  6716. case batchmsg.FieldMsg:
  6717. v, ok := value.(string)
  6718. if !ok {
  6719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6720. }
  6721. m.SetMsg(v)
  6722. return nil
  6723. case batchmsg.FieldTag:
  6724. v, ok := value.(string)
  6725. if !ok {
  6726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6727. }
  6728. m.SetTag(v)
  6729. return nil
  6730. case batchmsg.FieldTagids:
  6731. v, ok := value.(string)
  6732. if !ok {
  6733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6734. }
  6735. m.SetTagids(v)
  6736. return nil
  6737. case batchmsg.FieldTotal:
  6738. v, ok := value.(int32)
  6739. if !ok {
  6740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6741. }
  6742. m.SetTotal(v)
  6743. return nil
  6744. case batchmsg.FieldSuccess:
  6745. v, ok := value.(int32)
  6746. if !ok {
  6747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6748. }
  6749. m.SetSuccess(v)
  6750. return nil
  6751. case batchmsg.FieldFail:
  6752. v, ok := value.(int32)
  6753. if !ok {
  6754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6755. }
  6756. m.SetFail(v)
  6757. return nil
  6758. case batchmsg.FieldStartTime:
  6759. v, ok := value.(time.Time)
  6760. if !ok {
  6761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6762. }
  6763. m.SetStartTime(v)
  6764. return nil
  6765. case batchmsg.FieldStopTime:
  6766. v, ok := value.(time.Time)
  6767. if !ok {
  6768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6769. }
  6770. m.SetStopTime(v)
  6771. return nil
  6772. case batchmsg.FieldSendTime:
  6773. v, ok := value.(time.Time)
  6774. if !ok {
  6775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6776. }
  6777. m.SetSendTime(v)
  6778. return nil
  6779. case batchmsg.FieldType:
  6780. v, ok := value.(int32)
  6781. if !ok {
  6782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6783. }
  6784. m.SetType(v)
  6785. return nil
  6786. case batchmsg.FieldOrganizationID:
  6787. v, ok := value.(uint64)
  6788. if !ok {
  6789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6790. }
  6791. m.SetOrganizationID(v)
  6792. return nil
  6793. case batchmsg.FieldCtype:
  6794. v, ok := value.(uint64)
  6795. if !ok {
  6796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6797. }
  6798. m.SetCtype(v)
  6799. return nil
  6800. case batchmsg.FieldCc:
  6801. v, ok := value.(string)
  6802. if !ok {
  6803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6804. }
  6805. m.SetCc(v)
  6806. return nil
  6807. case batchmsg.FieldPhone:
  6808. v, ok := value.(string)
  6809. if !ok {
  6810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6811. }
  6812. m.SetPhone(v)
  6813. return nil
  6814. case batchmsg.FieldTemplateName:
  6815. v, ok := value.(string)
  6816. if !ok {
  6817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6818. }
  6819. m.SetTemplateName(v)
  6820. return nil
  6821. case batchmsg.FieldTemplateCode:
  6822. v, ok := value.(string)
  6823. if !ok {
  6824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6825. }
  6826. m.SetTemplateCode(v)
  6827. return nil
  6828. case batchmsg.FieldLang:
  6829. v, ok := value.(string)
  6830. if !ok {
  6831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6832. }
  6833. m.SetLang(v)
  6834. return nil
  6835. }
  6836. return fmt.Errorf("unknown BatchMsg field %s", name)
  6837. }
  6838. // AddedFields returns all numeric fields that were incremented/decremented during
  6839. // this mutation.
  6840. func (m *BatchMsgMutation) AddedFields() []string {
  6841. var fields []string
  6842. if m.addstatus != nil {
  6843. fields = append(fields, batchmsg.FieldStatus)
  6844. }
  6845. if m.addtotal != nil {
  6846. fields = append(fields, batchmsg.FieldTotal)
  6847. }
  6848. if m.addsuccess != nil {
  6849. fields = append(fields, batchmsg.FieldSuccess)
  6850. }
  6851. if m.addfail != nil {
  6852. fields = append(fields, batchmsg.FieldFail)
  6853. }
  6854. if m.add_type != nil {
  6855. fields = append(fields, batchmsg.FieldType)
  6856. }
  6857. if m.addorganization_id != nil {
  6858. fields = append(fields, batchmsg.FieldOrganizationID)
  6859. }
  6860. if m.addctype != nil {
  6861. fields = append(fields, batchmsg.FieldCtype)
  6862. }
  6863. return fields
  6864. }
  6865. // AddedField returns the numeric value that was incremented/decremented on a field
  6866. // with the given name. The second boolean return value indicates that this field
  6867. // was not set, or was not defined in the schema.
  6868. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  6869. switch name {
  6870. case batchmsg.FieldStatus:
  6871. return m.AddedStatus()
  6872. case batchmsg.FieldTotal:
  6873. return m.AddedTotal()
  6874. case batchmsg.FieldSuccess:
  6875. return m.AddedSuccess()
  6876. case batchmsg.FieldFail:
  6877. return m.AddedFail()
  6878. case batchmsg.FieldType:
  6879. return m.AddedType()
  6880. case batchmsg.FieldOrganizationID:
  6881. return m.AddedOrganizationID()
  6882. case batchmsg.FieldCtype:
  6883. return m.AddedCtype()
  6884. }
  6885. return nil, false
  6886. }
  6887. // AddField adds the value to the field with the given name. It returns an error if
  6888. // the field is not defined in the schema, or if the type mismatched the field
  6889. // type.
  6890. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  6891. switch name {
  6892. case batchmsg.FieldStatus:
  6893. v, ok := value.(int8)
  6894. if !ok {
  6895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6896. }
  6897. m.AddStatus(v)
  6898. return nil
  6899. case batchmsg.FieldTotal:
  6900. v, ok := value.(int32)
  6901. if !ok {
  6902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6903. }
  6904. m.AddTotal(v)
  6905. return nil
  6906. case batchmsg.FieldSuccess:
  6907. v, ok := value.(int32)
  6908. if !ok {
  6909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6910. }
  6911. m.AddSuccess(v)
  6912. return nil
  6913. case batchmsg.FieldFail:
  6914. v, ok := value.(int32)
  6915. if !ok {
  6916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6917. }
  6918. m.AddFail(v)
  6919. return nil
  6920. case batchmsg.FieldType:
  6921. v, ok := value.(int32)
  6922. if !ok {
  6923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6924. }
  6925. m.AddType(v)
  6926. return nil
  6927. case batchmsg.FieldOrganizationID:
  6928. v, ok := value.(int64)
  6929. if !ok {
  6930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6931. }
  6932. m.AddOrganizationID(v)
  6933. return nil
  6934. case batchmsg.FieldCtype:
  6935. v, ok := value.(int64)
  6936. if !ok {
  6937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6938. }
  6939. m.AddCtype(v)
  6940. return nil
  6941. }
  6942. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  6943. }
  6944. // ClearedFields returns all nullable fields that were cleared during this
  6945. // mutation.
  6946. func (m *BatchMsgMutation) ClearedFields() []string {
  6947. var fields []string
  6948. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  6949. fields = append(fields, batchmsg.FieldDeletedAt)
  6950. }
  6951. if m.FieldCleared(batchmsg.FieldStatus) {
  6952. fields = append(fields, batchmsg.FieldStatus)
  6953. }
  6954. if m.FieldCleared(batchmsg.FieldBatchNo) {
  6955. fields = append(fields, batchmsg.FieldBatchNo)
  6956. }
  6957. if m.FieldCleared(batchmsg.FieldTaskName) {
  6958. fields = append(fields, batchmsg.FieldTaskName)
  6959. }
  6960. if m.FieldCleared(batchmsg.FieldFromwxid) {
  6961. fields = append(fields, batchmsg.FieldFromwxid)
  6962. }
  6963. if m.FieldCleared(batchmsg.FieldMsg) {
  6964. fields = append(fields, batchmsg.FieldMsg)
  6965. }
  6966. if m.FieldCleared(batchmsg.FieldTag) {
  6967. fields = append(fields, batchmsg.FieldTag)
  6968. }
  6969. if m.FieldCleared(batchmsg.FieldTagids) {
  6970. fields = append(fields, batchmsg.FieldTagids)
  6971. }
  6972. if m.FieldCleared(batchmsg.FieldTotal) {
  6973. fields = append(fields, batchmsg.FieldTotal)
  6974. }
  6975. if m.FieldCleared(batchmsg.FieldSuccess) {
  6976. fields = append(fields, batchmsg.FieldSuccess)
  6977. }
  6978. if m.FieldCleared(batchmsg.FieldFail) {
  6979. fields = append(fields, batchmsg.FieldFail)
  6980. }
  6981. if m.FieldCleared(batchmsg.FieldStartTime) {
  6982. fields = append(fields, batchmsg.FieldStartTime)
  6983. }
  6984. if m.FieldCleared(batchmsg.FieldStopTime) {
  6985. fields = append(fields, batchmsg.FieldStopTime)
  6986. }
  6987. if m.FieldCleared(batchmsg.FieldSendTime) {
  6988. fields = append(fields, batchmsg.FieldSendTime)
  6989. }
  6990. if m.FieldCleared(batchmsg.FieldType) {
  6991. fields = append(fields, batchmsg.FieldType)
  6992. }
  6993. if m.FieldCleared(batchmsg.FieldCc) {
  6994. fields = append(fields, batchmsg.FieldCc)
  6995. }
  6996. if m.FieldCleared(batchmsg.FieldPhone) {
  6997. fields = append(fields, batchmsg.FieldPhone)
  6998. }
  6999. if m.FieldCleared(batchmsg.FieldTemplateName) {
  7000. fields = append(fields, batchmsg.FieldTemplateName)
  7001. }
  7002. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  7003. fields = append(fields, batchmsg.FieldTemplateCode)
  7004. }
  7005. if m.FieldCleared(batchmsg.FieldLang) {
  7006. fields = append(fields, batchmsg.FieldLang)
  7007. }
  7008. return fields
  7009. }
  7010. // FieldCleared returns a boolean indicating if a field with the given name was
  7011. // cleared in this mutation.
  7012. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  7013. _, ok := m.clearedFields[name]
  7014. return ok
  7015. }
  7016. // ClearField clears the value of the field with the given name. It returns an
  7017. // error if the field is not defined in the schema.
  7018. func (m *BatchMsgMutation) ClearField(name string) error {
  7019. switch name {
  7020. case batchmsg.FieldDeletedAt:
  7021. m.ClearDeletedAt()
  7022. return nil
  7023. case batchmsg.FieldStatus:
  7024. m.ClearStatus()
  7025. return nil
  7026. case batchmsg.FieldBatchNo:
  7027. m.ClearBatchNo()
  7028. return nil
  7029. case batchmsg.FieldTaskName:
  7030. m.ClearTaskName()
  7031. return nil
  7032. case batchmsg.FieldFromwxid:
  7033. m.ClearFromwxid()
  7034. return nil
  7035. case batchmsg.FieldMsg:
  7036. m.ClearMsg()
  7037. return nil
  7038. case batchmsg.FieldTag:
  7039. m.ClearTag()
  7040. return nil
  7041. case batchmsg.FieldTagids:
  7042. m.ClearTagids()
  7043. return nil
  7044. case batchmsg.FieldTotal:
  7045. m.ClearTotal()
  7046. return nil
  7047. case batchmsg.FieldSuccess:
  7048. m.ClearSuccess()
  7049. return nil
  7050. case batchmsg.FieldFail:
  7051. m.ClearFail()
  7052. return nil
  7053. case batchmsg.FieldStartTime:
  7054. m.ClearStartTime()
  7055. return nil
  7056. case batchmsg.FieldStopTime:
  7057. m.ClearStopTime()
  7058. return nil
  7059. case batchmsg.FieldSendTime:
  7060. m.ClearSendTime()
  7061. return nil
  7062. case batchmsg.FieldType:
  7063. m.ClearType()
  7064. return nil
  7065. case batchmsg.FieldCc:
  7066. m.ClearCc()
  7067. return nil
  7068. case batchmsg.FieldPhone:
  7069. m.ClearPhone()
  7070. return nil
  7071. case batchmsg.FieldTemplateName:
  7072. m.ClearTemplateName()
  7073. return nil
  7074. case batchmsg.FieldTemplateCode:
  7075. m.ClearTemplateCode()
  7076. return nil
  7077. case batchmsg.FieldLang:
  7078. m.ClearLang()
  7079. return nil
  7080. }
  7081. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7082. }
  7083. // ResetField resets all changes in the mutation for the field with the given name.
  7084. // It returns an error if the field is not defined in the schema.
  7085. func (m *BatchMsgMutation) ResetField(name string) error {
  7086. switch name {
  7087. case batchmsg.FieldCreatedAt:
  7088. m.ResetCreatedAt()
  7089. return nil
  7090. case batchmsg.FieldUpdatedAt:
  7091. m.ResetUpdatedAt()
  7092. return nil
  7093. case batchmsg.FieldDeletedAt:
  7094. m.ResetDeletedAt()
  7095. return nil
  7096. case batchmsg.FieldStatus:
  7097. m.ResetStatus()
  7098. return nil
  7099. case batchmsg.FieldBatchNo:
  7100. m.ResetBatchNo()
  7101. return nil
  7102. case batchmsg.FieldTaskName:
  7103. m.ResetTaskName()
  7104. return nil
  7105. case batchmsg.FieldFromwxid:
  7106. m.ResetFromwxid()
  7107. return nil
  7108. case batchmsg.FieldMsg:
  7109. m.ResetMsg()
  7110. return nil
  7111. case batchmsg.FieldTag:
  7112. m.ResetTag()
  7113. return nil
  7114. case batchmsg.FieldTagids:
  7115. m.ResetTagids()
  7116. return nil
  7117. case batchmsg.FieldTotal:
  7118. m.ResetTotal()
  7119. return nil
  7120. case batchmsg.FieldSuccess:
  7121. m.ResetSuccess()
  7122. return nil
  7123. case batchmsg.FieldFail:
  7124. m.ResetFail()
  7125. return nil
  7126. case batchmsg.FieldStartTime:
  7127. m.ResetStartTime()
  7128. return nil
  7129. case batchmsg.FieldStopTime:
  7130. m.ResetStopTime()
  7131. return nil
  7132. case batchmsg.FieldSendTime:
  7133. m.ResetSendTime()
  7134. return nil
  7135. case batchmsg.FieldType:
  7136. m.ResetType()
  7137. return nil
  7138. case batchmsg.FieldOrganizationID:
  7139. m.ResetOrganizationID()
  7140. return nil
  7141. case batchmsg.FieldCtype:
  7142. m.ResetCtype()
  7143. return nil
  7144. case batchmsg.FieldCc:
  7145. m.ResetCc()
  7146. return nil
  7147. case batchmsg.FieldPhone:
  7148. m.ResetPhone()
  7149. return nil
  7150. case batchmsg.FieldTemplateName:
  7151. m.ResetTemplateName()
  7152. return nil
  7153. case batchmsg.FieldTemplateCode:
  7154. m.ResetTemplateCode()
  7155. return nil
  7156. case batchmsg.FieldLang:
  7157. m.ResetLang()
  7158. return nil
  7159. }
  7160. return fmt.Errorf("unknown BatchMsg field %s", name)
  7161. }
  7162. // AddedEdges returns all edge names that were set/added in this mutation.
  7163. func (m *BatchMsgMutation) AddedEdges() []string {
  7164. edges := make([]string, 0, 0)
  7165. return edges
  7166. }
  7167. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7168. // name in this mutation.
  7169. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7170. return nil
  7171. }
  7172. // RemovedEdges returns all edge names that were removed in this mutation.
  7173. func (m *BatchMsgMutation) RemovedEdges() []string {
  7174. edges := make([]string, 0, 0)
  7175. return edges
  7176. }
  7177. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7178. // the given name in this mutation.
  7179. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7180. return nil
  7181. }
  7182. // ClearedEdges returns all edge names that were cleared in this mutation.
  7183. func (m *BatchMsgMutation) ClearedEdges() []string {
  7184. edges := make([]string, 0, 0)
  7185. return edges
  7186. }
  7187. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7188. // was cleared in this mutation.
  7189. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7190. return false
  7191. }
  7192. // ClearEdge clears the value of the edge with the given name. It returns an error
  7193. // if that edge is not defined in the schema.
  7194. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7195. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7196. }
  7197. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7198. // It returns an error if the edge is not defined in the schema.
  7199. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7200. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7201. }
  7202. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7203. type CategoryMutation struct {
  7204. config
  7205. op Op
  7206. typ string
  7207. id *uint64
  7208. created_at *time.Time
  7209. updated_at *time.Time
  7210. deleted_at *time.Time
  7211. name *string
  7212. organization_id *uint64
  7213. addorganization_id *int64
  7214. clearedFields map[string]struct{}
  7215. done bool
  7216. oldValue func(context.Context) (*Category, error)
  7217. predicates []predicate.Category
  7218. }
  7219. var _ ent.Mutation = (*CategoryMutation)(nil)
  7220. // categoryOption allows management of the mutation configuration using functional options.
  7221. type categoryOption func(*CategoryMutation)
  7222. // newCategoryMutation creates new mutation for the Category entity.
  7223. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7224. m := &CategoryMutation{
  7225. config: c,
  7226. op: op,
  7227. typ: TypeCategory,
  7228. clearedFields: make(map[string]struct{}),
  7229. }
  7230. for _, opt := range opts {
  7231. opt(m)
  7232. }
  7233. return m
  7234. }
  7235. // withCategoryID sets the ID field of the mutation.
  7236. func withCategoryID(id uint64) categoryOption {
  7237. return func(m *CategoryMutation) {
  7238. var (
  7239. err error
  7240. once sync.Once
  7241. value *Category
  7242. )
  7243. m.oldValue = func(ctx context.Context) (*Category, error) {
  7244. once.Do(func() {
  7245. if m.done {
  7246. err = errors.New("querying old values post mutation is not allowed")
  7247. } else {
  7248. value, err = m.Client().Category.Get(ctx, id)
  7249. }
  7250. })
  7251. return value, err
  7252. }
  7253. m.id = &id
  7254. }
  7255. }
  7256. // withCategory sets the old Category of the mutation.
  7257. func withCategory(node *Category) categoryOption {
  7258. return func(m *CategoryMutation) {
  7259. m.oldValue = func(context.Context) (*Category, error) {
  7260. return node, nil
  7261. }
  7262. m.id = &node.ID
  7263. }
  7264. }
  7265. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7266. // executed in a transaction (ent.Tx), a transactional client is returned.
  7267. func (m CategoryMutation) Client() *Client {
  7268. client := &Client{config: m.config}
  7269. client.init()
  7270. return client
  7271. }
  7272. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7273. // it returns an error otherwise.
  7274. func (m CategoryMutation) Tx() (*Tx, error) {
  7275. if _, ok := m.driver.(*txDriver); !ok {
  7276. return nil, errors.New("ent: mutation is not running in a transaction")
  7277. }
  7278. tx := &Tx{config: m.config}
  7279. tx.init()
  7280. return tx, nil
  7281. }
  7282. // SetID sets the value of the id field. Note that this
  7283. // operation is only accepted on creation of Category entities.
  7284. func (m *CategoryMutation) SetID(id uint64) {
  7285. m.id = &id
  7286. }
  7287. // ID returns the ID value in the mutation. Note that the ID is only available
  7288. // if it was provided to the builder or after it was returned from the database.
  7289. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7290. if m.id == nil {
  7291. return
  7292. }
  7293. return *m.id, true
  7294. }
  7295. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7296. // That means, if the mutation is applied within a transaction with an isolation level such
  7297. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7298. // or updated by the mutation.
  7299. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7300. switch {
  7301. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7302. id, exists := m.ID()
  7303. if exists {
  7304. return []uint64{id}, nil
  7305. }
  7306. fallthrough
  7307. case m.op.Is(OpUpdate | OpDelete):
  7308. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7309. default:
  7310. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7311. }
  7312. }
  7313. // SetCreatedAt sets the "created_at" field.
  7314. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7315. m.created_at = &t
  7316. }
  7317. // CreatedAt returns the value of the "created_at" field in the mutation.
  7318. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7319. v := m.created_at
  7320. if v == nil {
  7321. return
  7322. }
  7323. return *v, true
  7324. }
  7325. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7326. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7328. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7329. if !m.op.Is(OpUpdateOne) {
  7330. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7331. }
  7332. if m.id == nil || m.oldValue == nil {
  7333. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7334. }
  7335. oldValue, err := m.oldValue(ctx)
  7336. if err != nil {
  7337. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7338. }
  7339. return oldValue.CreatedAt, nil
  7340. }
  7341. // ResetCreatedAt resets all changes to the "created_at" field.
  7342. func (m *CategoryMutation) ResetCreatedAt() {
  7343. m.created_at = nil
  7344. }
  7345. // SetUpdatedAt sets the "updated_at" field.
  7346. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7347. m.updated_at = &t
  7348. }
  7349. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7350. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7351. v := m.updated_at
  7352. if v == nil {
  7353. return
  7354. }
  7355. return *v, true
  7356. }
  7357. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7358. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7360. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7361. if !m.op.Is(OpUpdateOne) {
  7362. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7363. }
  7364. if m.id == nil || m.oldValue == nil {
  7365. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7366. }
  7367. oldValue, err := m.oldValue(ctx)
  7368. if err != nil {
  7369. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7370. }
  7371. return oldValue.UpdatedAt, nil
  7372. }
  7373. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7374. func (m *CategoryMutation) ResetUpdatedAt() {
  7375. m.updated_at = nil
  7376. }
  7377. // SetDeletedAt sets the "deleted_at" field.
  7378. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7379. m.deleted_at = &t
  7380. }
  7381. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7382. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7383. v := m.deleted_at
  7384. if v == nil {
  7385. return
  7386. }
  7387. return *v, true
  7388. }
  7389. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7390. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7392. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7393. if !m.op.Is(OpUpdateOne) {
  7394. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7395. }
  7396. if m.id == nil || m.oldValue == nil {
  7397. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7398. }
  7399. oldValue, err := m.oldValue(ctx)
  7400. if err != nil {
  7401. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7402. }
  7403. return oldValue.DeletedAt, nil
  7404. }
  7405. // ClearDeletedAt clears the value of the "deleted_at" field.
  7406. func (m *CategoryMutation) ClearDeletedAt() {
  7407. m.deleted_at = nil
  7408. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7409. }
  7410. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7411. func (m *CategoryMutation) DeletedAtCleared() bool {
  7412. _, ok := m.clearedFields[category.FieldDeletedAt]
  7413. return ok
  7414. }
  7415. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7416. func (m *CategoryMutation) ResetDeletedAt() {
  7417. m.deleted_at = nil
  7418. delete(m.clearedFields, category.FieldDeletedAt)
  7419. }
  7420. // SetName sets the "name" field.
  7421. func (m *CategoryMutation) SetName(s string) {
  7422. m.name = &s
  7423. }
  7424. // Name returns the value of the "name" field in the mutation.
  7425. func (m *CategoryMutation) Name() (r string, exists bool) {
  7426. v := m.name
  7427. if v == nil {
  7428. return
  7429. }
  7430. return *v, true
  7431. }
  7432. // OldName returns the old "name" field's value of the Category entity.
  7433. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7435. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7436. if !m.op.Is(OpUpdateOne) {
  7437. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7438. }
  7439. if m.id == nil || m.oldValue == nil {
  7440. return v, errors.New("OldName requires an ID field in the mutation")
  7441. }
  7442. oldValue, err := m.oldValue(ctx)
  7443. if err != nil {
  7444. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7445. }
  7446. return oldValue.Name, nil
  7447. }
  7448. // ResetName resets all changes to the "name" field.
  7449. func (m *CategoryMutation) ResetName() {
  7450. m.name = nil
  7451. }
  7452. // SetOrganizationID sets the "organization_id" field.
  7453. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7454. m.organization_id = &u
  7455. m.addorganization_id = nil
  7456. }
  7457. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7458. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7459. v := m.organization_id
  7460. if v == nil {
  7461. return
  7462. }
  7463. return *v, true
  7464. }
  7465. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7466. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7468. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7469. if !m.op.Is(OpUpdateOne) {
  7470. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7471. }
  7472. if m.id == nil || m.oldValue == nil {
  7473. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7474. }
  7475. oldValue, err := m.oldValue(ctx)
  7476. if err != nil {
  7477. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7478. }
  7479. return oldValue.OrganizationID, nil
  7480. }
  7481. // AddOrganizationID adds u to the "organization_id" field.
  7482. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7483. if m.addorganization_id != nil {
  7484. *m.addorganization_id += u
  7485. } else {
  7486. m.addorganization_id = &u
  7487. }
  7488. }
  7489. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7490. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7491. v := m.addorganization_id
  7492. if v == nil {
  7493. return
  7494. }
  7495. return *v, true
  7496. }
  7497. // ResetOrganizationID resets all changes to the "organization_id" field.
  7498. func (m *CategoryMutation) ResetOrganizationID() {
  7499. m.organization_id = nil
  7500. m.addorganization_id = nil
  7501. }
  7502. // Where appends a list predicates to the CategoryMutation builder.
  7503. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7504. m.predicates = append(m.predicates, ps...)
  7505. }
  7506. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7507. // users can use type-assertion to append predicates that do not depend on any generated package.
  7508. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7509. p := make([]predicate.Category, len(ps))
  7510. for i := range ps {
  7511. p[i] = ps[i]
  7512. }
  7513. m.Where(p...)
  7514. }
  7515. // Op returns the operation name.
  7516. func (m *CategoryMutation) Op() Op {
  7517. return m.op
  7518. }
  7519. // SetOp allows setting the mutation operation.
  7520. func (m *CategoryMutation) SetOp(op Op) {
  7521. m.op = op
  7522. }
  7523. // Type returns the node type of this mutation (Category).
  7524. func (m *CategoryMutation) Type() string {
  7525. return m.typ
  7526. }
  7527. // Fields returns all fields that were changed during this mutation. Note that in
  7528. // order to get all numeric fields that were incremented/decremented, call
  7529. // AddedFields().
  7530. func (m *CategoryMutation) Fields() []string {
  7531. fields := make([]string, 0, 5)
  7532. if m.created_at != nil {
  7533. fields = append(fields, category.FieldCreatedAt)
  7534. }
  7535. if m.updated_at != nil {
  7536. fields = append(fields, category.FieldUpdatedAt)
  7537. }
  7538. if m.deleted_at != nil {
  7539. fields = append(fields, category.FieldDeletedAt)
  7540. }
  7541. if m.name != nil {
  7542. fields = append(fields, category.FieldName)
  7543. }
  7544. if m.organization_id != nil {
  7545. fields = append(fields, category.FieldOrganizationID)
  7546. }
  7547. return fields
  7548. }
  7549. // Field returns the value of a field with the given name. The second boolean
  7550. // return value indicates that this field was not set, or was not defined in the
  7551. // schema.
  7552. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7553. switch name {
  7554. case category.FieldCreatedAt:
  7555. return m.CreatedAt()
  7556. case category.FieldUpdatedAt:
  7557. return m.UpdatedAt()
  7558. case category.FieldDeletedAt:
  7559. return m.DeletedAt()
  7560. case category.FieldName:
  7561. return m.Name()
  7562. case category.FieldOrganizationID:
  7563. return m.OrganizationID()
  7564. }
  7565. return nil, false
  7566. }
  7567. // OldField returns the old value of the field from the database. An error is
  7568. // returned if the mutation operation is not UpdateOne, or the query to the
  7569. // database failed.
  7570. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7571. switch name {
  7572. case category.FieldCreatedAt:
  7573. return m.OldCreatedAt(ctx)
  7574. case category.FieldUpdatedAt:
  7575. return m.OldUpdatedAt(ctx)
  7576. case category.FieldDeletedAt:
  7577. return m.OldDeletedAt(ctx)
  7578. case category.FieldName:
  7579. return m.OldName(ctx)
  7580. case category.FieldOrganizationID:
  7581. return m.OldOrganizationID(ctx)
  7582. }
  7583. return nil, fmt.Errorf("unknown Category field %s", name)
  7584. }
  7585. // SetField sets the value of a field with the given name. It returns an error if
  7586. // the field is not defined in the schema, or if the type mismatched the field
  7587. // type.
  7588. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7589. switch name {
  7590. case category.FieldCreatedAt:
  7591. v, ok := value.(time.Time)
  7592. if !ok {
  7593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7594. }
  7595. m.SetCreatedAt(v)
  7596. return nil
  7597. case category.FieldUpdatedAt:
  7598. v, ok := value.(time.Time)
  7599. if !ok {
  7600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7601. }
  7602. m.SetUpdatedAt(v)
  7603. return nil
  7604. case category.FieldDeletedAt:
  7605. v, ok := value.(time.Time)
  7606. if !ok {
  7607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7608. }
  7609. m.SetDeletedAt(v)
  7610. return nil
  7611. case category.FieldName:
  7612. v, ok := value.(string)
  7613. if !ok {
  7614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7615. }
  7616. m.SetName(v)
  7617. return nil
  7618. case category.FieldOrganizationID:
  7619. v, ok := value.(uint64)
  7620. if !ok {
  7621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7622. }
  7623. m.SetOrganizationID(v)
  7624. return nil
  7625. }
  7626. return fmt.Errorf("unknown Category field %s", name)
  7627. }
  7628. // AddedFields returns all numeric fields that were incremented/decremented during
  7629. // this mutation.
  7630. func (m *CategoryMutation) AddedFields() []string {
  7631. var fields []string
  7632. if m.addorganization_id != nil {
  7633. fields = append(fields, category.FieldOrganizationID)
  7634. }
  7635. return fields
  7636. }
  7637. // AddedField returns the numeric value that was incremented/decremented on a field
  7638. // with the given name. The second boolean return value indicates that this field
  7639. // was not set, or was not defined in the schema.
  7640. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7641. switch name {
  7642. case category.FieldOrganizationID:
  7643. return m.AddedOrganizationID()
  7644. }
  7645. return nil, false
  7646. }
  7647. // AddField adds the value to the field with the given name. It returns an error if
  7648. // the field is not defined in the schema, or if the type mismatched the field
  7649. // type.
  7650. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7651. switch name {
  7652. case category.FieldOrganizationID:
  7653. v, ok := value.(int64)
  7654. if !ok {
  7655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7656. }
  7657. m.AddOrganizationID(v)
  7658. return nil
  7659. }
  7660. return fmt.Errorf("unknown Category numeric field %s", name)
  7661. }
  7662. // ClearedFields returns all nullable fields that were cleared during this
  7663. // mutation.
  7664. func (m *CategoryMutation) ClearedFields() []string {
  7665. var fields []string
  7666. if m.FieldCleared(category.FieldDeletedAt) {
  7667. fields = append(fields, category.FieldDeletedAt)
  7668. }
  7669. return fields
  7670. }
  7671. // FieldCleared returns a boolean indicating if a field with the given name was
  7672. // cleared in this mutation.
  7673. func (m *CategoryMutation) FieldCleared(name string) bool {
  7674. _, ok := m.clearedFields[name]
  7675. return ok
  7676. }
  7677. // ClearField clears the value of the field with the given name. It returns an
  7678. // error if the field is not defined in the schema.
  7679. func (m *CategoryMutation) ClearField(name string) error {
  7680. switch name {
  7681. case category.FieldDeletedAt:
  7682. m.ClearDeletedAt()
  7683. return nil
  7684. }
  7685. return fmt.Errorf("unknown Category nullable field %s", name)
  7686. }
  7687. // ResetField resets all changes in the mutation for the field with the given name.
  7688. // It returns an error if the field is not defined in the schema.
  7689. func (m *CategoryMutation) ResetField(name string) error {
  7690. switch name {
  7691. case category.FieldCreatedAt:
  7692. m.ResetCreatedAt()
  7693. return nil
  7694. case category.FieldUpdatedAt:
  7695. m.ResetUpdatedAt()
  7696. return nil
  7697. case category.FieldDeletedAt:
  7698. m.ResetDeletedAt()
  7699. return nil
  7700. case category.FieldName:
  7701. m.ResetName()
  7702. return nil
  7703. case category.FieldOrganizationID:
  7704. m.ResetOrganizationID()
  7705. return nil
  7706. }
  7707. return fmt.Errorf("unknown Category field %s", name)
  7708. }
  7709. // AddedEdges returns all edge names that were set/added in this mutation.
  7710. func (m *CategoryMutation) AddedEdges() []string {
  7711. edges := make([]string, 0, 0)
  7712. return edges
  7713. }
  7714. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7715. // name in this mutation.
  7716. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7717. return nil
  7718. }
  7719. // RemovedEdges returns all edge names that were removed in this mutation.
  7720. func (m *CategoryMutation) RemovedEdges() []string {
  7721. edges := make([]string, 0, 0)
  7722. return edges
  7723. }
  7724. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7725. // the given name in this mutation.
  7726. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7727. return nil
  7728. }
  7729. // ClearedEdges returns all edge names that were cleared in this mutation.
  7730. func (m *CategoryMutation) ClearedEdges() []string {
  7731. edges := make([]string, 0, 0)
  7732. return edges
  7733. }
  7734. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7735. // was cleared in this mutation.
  7736. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7737. return false
  7738. }
  7739. // ClearEdge clears the value of the edge with the given name. It returns an error
  7740. // if that edge is not defined in the schema.
  7741. func (m *CategoryMutation) ClearEdge(name string) error {
  7742. return fmt.Errorf("unknown Category unique edge %s", name)
  7743. }
  7744. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7745. // It returns an error if the edge is not defined in the schema.
  7746. func (m *CategoryMutation) ResetEdge(name string) error {
  7747. return fmt.Errorf("unknown Category edge %s", name)
  7748. }
  7749. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7750. type ChatRecordsMutation struct {
  7751. config
  7752. op Op
  7753. typ string
  7754. id *uint64
  7755. created_at *time.Time
  7756. updated_at *time.Time
  7757. deleted_at *time.Time
  7758. content *string
  7759. content_type *uint8
  7760. addcontent_type *int8
  7761. session_id *uint64
  7762. addsession_id *int64
  7763. user_id *uint64
  7764. adduser_id *int64
  7765. bot_id *uint64
  7766. addbot_id *int64
  7767. bot_type *uint8
  7768. addbot_type *int8
  7769. clearedFields map[string]struct{}
  7770. done bool
  7771. oldValue func(context.Context) (*ChatRecords, error)
  7772. predicates []predicate.ChatRecords
  7773. }
  7774. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7775. // chatrecordsOption allows management of the mutation configuration using functional options.
  7776. type chatrecordsOption func(*ChatRecordsMutation)
  7777. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7778. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7779. m := &ChatRecordsMutation{
  7780. config: c,
  7781. op: op,
  7782. typ: TypeChatRecords,
  7783. clearedFields: make(map[string]struct{}),
  7784. }
  7785. for _, opt := range opts {
  7786. opt(m)
  7787. }
  7788. return m
  7789. }
  7790. // withChatRecordsID sets the ID field of the mutation.
  7791. func withChatRecordsID(id uint64) chatrecordsOption {
  7792. return func(m *ChatRecordsMutation) {
  7793. var (
  7794. err error
  7795. once sync.Once
  7796. value *ChatRecords
  7797. )
  7798. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7799. once.Do(func() {
  7800. if m.done {
  7801. err = errors.New("querying old values post mutation is not allowed")
  7802. } else {
  7803. value, err = m.Client().ChatRecords.Get(ctx, id)
  7804. }
  7805. })
  7806. return value, err
  7807. }
  7808. m.id = &id
  7809. }
  7810. }
  7811. // withChatRecords sets the old ChatRecords of the mutation.
  7812. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7813. return func(m *ChatRecordsMutation) {
  7814. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7815. return node, nil
  7816. }
  7817. m.id = &node.ID
  7818. }
  7819. }
  7820. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7821. // executed in a transaction (ent.Tx), a transactional client is returned.
  7822. func (m ChatRecordsMutation) Client() *Client {
  7823. client := &Client{config: m.config}
  7824. client.init()
  7825. return client
  7826. }
  7827. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7828. // it returns an error otherwise.
  7829. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7830. if _, ok := m.driver.(*txDriver); !ok {
  7831. return nil, errors.New("ent: mutation is not running in a transaction")
  7832. }
  7833. tx := &Tx{config: m.config}
  7834. tx.init()
  7835. return tx, nil
  7836. }
  7837. // SetID sets the value of the id field. Note that this
  7838. // operation is only accepted on creation of ChatRecords entities.
  7839. func (m *ChatRecordsMutation) SetID(id uint64) {
  7840. m.id = &id
  7841. }
  7842. // ID returns the ID value in the mutation. Note that the ID is only available
  7843. // if it was provided to the builder or after it was returned from the database.
  7844. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  7845. if m.id == nil {
  7846. return
  7847. }
  7848. return *m.id, true
  7849. }
  7850. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7851. // That means, if the mutation is applied within a transaction with an isolation level such
  7852. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7853. // or updated by the mutation.
  7854. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7855. switch {
  7856. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7857. id, exists := m.ID()
  7858. if exists {
  7859. return []uint64{id}, nil
  7860. }
  7861. fallthrough
  7862. case m.op.Is(OpUpdate | OpDelete):
  7863. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  7864. default:
  7865. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7866. }
  7867. }
  7868. // SetCreatedAt sets the "created_at" field.
  7869. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  7870. m.created_at = &t
  7871. }
  7872. // CreatedAt returns the value of the "created_at" field in the mutation.
  7873. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7874. v := m.created_at
  7875. if v == nil {
  7876. return
  7877. }
  7878. return *v, true
  7879. }
  7880. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  7881. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7883. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7884. if !m.op.Is(OpUpdateOne) {
  7885. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7886. }
  7887. if m.id == nil || m.oldValue == nil {
  7888. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7889. }
  7890. oldValue, err := m.oldValue(ctx)
  7891. if err != nil {
  7892. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7893. }
  7894. return oldValue.CreatedAt, nil
  7895. }
  7896. // ResetCreatedAt resets all changes to the "created_at" field.
  7897. func (m *ChatRecordsMutation) ResetCreatedAt() {
  7898. m.created_at = nil
  7899. }
  7900. // SetUpdatedAt sets the "updated_at" field.
  7901. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  7902. m.updated_at = &t
  7903. }
  7904. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7905. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7906. v := m.updated_at
  7907. if v == nil {
  7908. return
  7909. }
  7910. return *v, true
  7911. }
  7912. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  7913. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7915. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7916. if !m.op.Is(OpUpdateOne) {
  7917. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7918. }
  7919. if m.id == nil || m.oldValue == nil {
  7920. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7921. }
  7922. oldValue, err := m.oldValue(ctx)
  7923. if err != nil {
  7924. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7925. }
  7926. return oldValue.UpdatedAt, nil
  7927. }
  7928. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7929. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  7930. m.updated_at = nil
  7931. }
  7932. // SetDeletedAt sets the "deleted_at" field.
  7933. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  7934. m.deleted_at = &t
  7935. }
  7936. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7937. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  7938. v := m.deleted_at
  7939. if v == nil {
  7940. return
  7941. }
  7942. return *v, true
  7943. }
  7944. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  7945. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7947. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7948. if !m.op.Is(OpUpdateOne) {
  7949. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7950. }
  7951. if m.id == nil || m.oldValue == nil {
  7952. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7953. }
  7954. oldValue, err := m.oldValue(ctx)
  7955. if err != nil {
  7956. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7957. }
  7958. return oldValue.DeletedAt, nil
  7959. }
  7960. // ClearDeletedAt clears the value of the "deleted_at" field.
  7961. func (m *ChatRecordsMutation) ClearDeletedAt() {
  7962. m.deleted_at = nil
  7963. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  7964. }
  7965. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7966. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  7967. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  7968. return ok
  7969. }
  7970. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7971. func (m *ChatRecordsMutation) ResetDeletedAt() {
  7972. m.deleted_at = nil
  7973. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  7974. }
  7975. // SetContent sets the "content" field.
  7976. func (m *ChatRecordsMutation) SetContent(s string) {
  7977. m.content = &s
  7978. }
  7979. // Content returns the value of the "content" field in the mutation.
  7980. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  7981. v := m.content
  7982. if v == nil {
  7983. return
  7984. }
  7985. return *v, true
  7986. }
  7987. // OldContent returns the old "content" field's value of the ChatRecords entity.
  7988. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7990. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  7991. if !m.op.Is(OpUpdateOne) {
  7992. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7993. }
  7994. if m.id == nil || m.oldValue == nil {
  7995. return v, errors.New("OldContent requires an ID field in the mutation")
  7996. }
  7997. oldValue, err := m.oldValue(ctx)
  7998. if err != nil {
  7999. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8000. }
  8001. return oldValue.Content, nil
  8002. }
  8003. // ResetContent resets all changes to the "content" field.
  8004. func (m *ChatRecordsMutation) ResetContent() {
  8005. m.content = nil
  8006. }
  8007. // SetContentType sets the "content_type" field.
  8008. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  8009. m.content_type = &u
  8010. m.addcontent_type = nil
  8011. }
  8012. // ContentType returns the value of the "content_type" field in the mutation.
  8013. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  8014. v := m.content_type
  8015. if v == nil {
  8016. return
  8017. }
  8018. return *v, true
  8019. }
  8020. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  8021. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8023. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  8024. if !m.op.Is(OpUpdateOne) {
  8025. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8026. }
  8027. if m.id == nil || m.oldValue == nil {
  8028. return v, errors.New("OldContentType requires an ID field in the mutation")
  8029. }
  8030. oldValue, err := m.oldValue(ctx)
  8031. if err != nil {
  8032. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8033. }
  8034. return oldValue.ContentType, nil
  8035. }
  8036. // AddContentType adds u to the "content_type" field.
  8037. func (m *ChatRecordsMutation) AddContentType(u int8) {
  8038. if m.addcontent_type != nil {
  8039. *m.addcontent_type += u
  8040. } else {
  8041. m.addcontent_type = &u
  8042. }
  8043. }
  8044. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8045. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  8046. v := m.addcontent_type
  8047. if v == nil {
  8048. return
  8049. }
  8050. return *v, true
  8051. }
  8052. // ResetContentType resets all changes to the "content_type" field.
  8053. func (m *ChatRecordsMutation) ResetContentType() {
  8054. m.content_type = nil
  8055. m.addcontent_type = nil
  8056. }
  8057. // SetSessionID sets the "session_id" field.
  8058. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  8059. m.session_id = &u
  8060. m.addsession_id = nil
  8061. }
  8062. // SessionID returns the value of the "session_id" field in the mutation.
  8063. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  8064. v := m.session_id
  8065. if v == nil {
  8066. return
  8067. }
  8068. return *v, true
  8069. }
  8070. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  8071. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8073. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  8074. if !m.op.Is(OpUpdateOne) {
  8075. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8076. }
  8077. if m.id == nil || m.oldValue == nil {
  8078. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8079. }
  8080. oldValue, err := m.oldValue(ctx)
  8081. if err != nil {
  8082. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8083. }
  8084. return oldValue.SessionID, nil
  8085. }
  8086. // AddSessionID adds u to the "session_id" field.
  8087. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8088. if m.addsession_id != nil {
  8089. *m.addsession_id += u
  8090. } else {
  8091. m.addsession_id = &u
  8092. }
  8093. }
  8094. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8095. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8096. v := m.addsession_id
  8097. if v == nil {
  8098. return
  8099. }
  8100. return *v, true
  8101. }
  8102. // ResetSessionID resets all changes to the "session_id" field.
  8103. func (m *ChatRecordsMutation) ResetSessionID() {
  8104. m.session_id = nil
  8105. m.addsession_id = nil
  8106. }
  8107. // SetUserID sets the "user_id" field.
  8108. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8109. m.user_id = &u
  8110. m.adduser_id = nil
  8111. }
  8112. // UserID returns the value of the "user_id" field in the mutation.
  8113. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8114. v := m.user_id
  8115. if v == nil {
  8116. return
  8117. }
  8118. return *v, true
  8119. }
  8120. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8121. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8123. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8124. if !m.op.Is(OpUpdateOne) {
  8125. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8126. }
  8127. if m.id == nil || m.oldValue == nil {
  8128. return v, errors.New("OldUserID requires an ID field in the mutation")
  8129. }
  8130. oldValue, err := m.oldValue(ctx)
  8131. if err != nil {
  8132. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8133. }
  8134. return oldValue.UserID, nil
  8135. }
  8136. // AddUserID adds u to the "user_id" field.
  8137. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8138. if m.adduser_id != nil {
  8139. *m.adduser_id += u
  8140. } else {
  8141. m.adduser_id = &u
  8142. }
  8143. }
  8144. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8145. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8146. v := m.adduser_id
  8147. if v == nil {
  8148. return
  8149. }
  8150. return *v, true
  8151. }
  8152. // ResetUserID resets all changes to the "user_id" field.
  8153. func (m *ChatRecordsMutation) ResetUserID() {
  8154. m.user_id = nil
  8155. m.adduser_id = nil
  8156. }
  8157. // SetBotID sets the "bot_id" field.
  8158. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8159. m.bot_id = &u
  8160. m.addbot_id = nil
  8161. }
  8162. // BotID returns the value of the "bot_id" field in the mutation.
  8163. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8164. v := m.bot_id
  8165. if v == nil {
  8166. return
  8167. }
  8168. return *v, true
  8169. }
  8170. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8171. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8173. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8174. if !m.op.Is(OpUpdateOne) {
  8175. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8176. }
  8177. if m.id == nil || m.oldValue == nil {
  8178. return v, errors.New("OldBotID requires an ID field in the mutation")
  8179. }
  8180. oldValue, err := m.oldValue(ctx)
  8181. if err != nil {
  8182. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8183. }
  8184. return oldValue.BotID, nil
  8185. }
  8186. // AddBotID adds u to the "bot_id" field.
  8187. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8188. if m.addbot_id != nil {
  8189. *m.addbot_id += u
  8190. } else {
  8191. m.addbot_id = &u
  8192. }
  8193. }
  8194. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8195. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8196. v := m.addbot_id
  8197. if v == nil {
  8198. return
  8199. }
  8200. return *v, true
  8201. }
  8202. // ResetBotID resets all changes to the "bot_id" field.
  8203. func (m *ChatRecordsMutation) ResetBotID() {
  8204. m.bot_id = nil
  8205. m.addbot_id = nil
  8206. }
  8207. // SetBotType sets the "bot_type" field.
  8208. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8209. m.bot_type = &u
  8210. m.addbot_type = nil
  8211. }
  8212. // BotType returns the value of the "bot_type" field in the mutation.
  8213. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8214. v := m.bot_type
  8215. if v == nil {
  8216. return
  8217. }
  8218. return *v, true
  8219. }
  8220. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8221. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8223. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8224. if !m.op.Is(OpUpdateOne) {
  8225. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8226. }
  8227. if m.id == nil || m.oldValue == nil {
  8228. return v, errors.New("OldBotType requires an ID field in the mutation")
  8229. }
  8230. oldValue, err := m.oldValue(ctx)
  8231. if err != nil {
  8232. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8233. }
  8234. return oldValue.BotType, nil
  8235. }
  8236. // AddBotType adds u to the "bot_type" field.
  8237. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8238. if m.addbot_type != nil {
  8239. *m.addbot_type += u
  8240. } else {
  8241. m.addbot_type = &u
  8242. }
  8243. }
  8244. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8245. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8246. v := m.addbot_type
  8247. if v == nil {
  8248. return
  8249. }
  8250. return *v, true
  8251. }
  8252. // ResetBotType resets all changes to the "bot_type" field.
  8253. func (m *ChatRecordsMutation) ResetBotType() {
  8254. m.bot_type = nil
  8255. m.addbot_type = nil
  8256. }
  8257. // Where appends a list predicates to the ChatRecordsMutation builder.
  8258. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8259. m.predicates = append(m.predicates, ps...)
  8260. }
  8261. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8262. // users can use type-assertion to append predicates that do not depend on any generated package.
  8263. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8264. p := make([]predicate.ChatRecords, len(ps))
  8265. for i := range ps {
  8266. p[i] = ps[i]
  8267. }
  8268. m.Where(p...)
  8269. }
  8270. // Op returns the operation name.
  8271. func (m *ChatRecordsMutation) Op() Op {
  8272. return m.op
  8273. }
  8274. // SetOp allows setting the mutation operation.
  8275. func (m *ChatRecordsMutation) SetOp(op Op) {
  8276. m.op = op
  8277. }
  8278. // Type returns the node type of this mutation (ChatRecords).
  8279. func (m *ChatRecordsMutation) Type() string {
  8280. return m.typ
  8281. }
  8282. // Fields returns all fields that were changed during this mutation. Note that in
  8283. // order to get all numeric fields that were incremented/decremented, call
  8284. // AddedFields().
  8285. func (m *ChatRecordsMutation) Fields() []string {
  8286. fields := make([]string, 0, 9)
  8287. if m.created_at != nil {
  8288. fields = append(fields, chatrecords.FieldCreatedAt)
  8289. }
  8290. if m.updated_at != nil {
  8291. fields = append(fields, chatrecords.FieldUpdatedAt)
  8292. }
  8293. if m.deleted_at != nil {
  8294. fields = append(fields, chatrecords.FieldDeletedAt)
  8295. }
  8296. if m.content != nil {
  8297. fields = append(fields, chatrecords.FieldContent)
  8298. }
  8299. if m.content_type != nil {
  8300. fields = append(fields, chatrecords.FieldContentType)
  8301. }
  8302. if m.session_id != nil {
  8303. fields = append(fields, chatrecords.FieldSessionID)
  8304. }
  8305. if m.user_id != nil {
  8306. fields = append(fields, chatrecords.FieldUserID)
  8307. }
  8308. if m.bot_id != nil {
  8309. fields = append(fields, chatrecords.FieldBotID)
  8310. }
  8311. if m.bot_type != nil {
  8312. fields = append(fields, chatrecords.FieldBotType)
  8313. }
  8314. return fields
  8315. }
  8316. // Field returns the value of a field with the given name. The second boolean
  8317. // return value indicates that this field was not set, or was not defined in the
  8318. // schema.
  8319. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8320. switch name {
  8321. case chatrecords.FieldCreatedAt:
  8322. return m.CreatedAt()
  8323. case chatrecords.FieldUpdatedAt:
  8324. return m.UpdatedAt()
  8325. case chatrecords.FieldDeletedAt:
  8326. return m.DeletedAt()
  8327. case chatrecords.FieldContent:
  8328. return m.Content()
  8329. case chatrecords.FieldContentType:
  8330. return m.ContentType()
  8331. case chatrecords.FieldSessionID:
  8332. return m.SessionID()
  8333. case chatrecords.FieldUserID:
  8334. return m.UserID()
  8335. case chatrecords.FieldBotID:
  8336. return m.BotID()
  8337. case chatrecords.FieldBotType:
  8338. return m.BotType()
  8339. }
  8340. return nil, false
  8341. }
  8342. // OldField returns the old value of the field from the database. An error is
  8343. // returned if the mutation operation is not UpdateOne, or the query to the
  8344. // database failed.
  8345. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8346. switch name {
  8347. case chatrecords.FieldCreatedAt:
  8348. return m.OldCreatedAt(ctx)
  8349. case chatrecords.FieldUpdatedAt:
  8350. return m.OldUpdatedAt(ctx)
  8351. case chatrecords.FieldDeletedAt:
  8352. return m.OldDeletedAt(ctx)
  8353. case chatrecords.FieldContent:
  8354. return m.OldContent(ctx)
  8355. case chatrecords.FieldContentType:
  8356. return m.OldContentType(ctx)
  8357. case chatrecords.FieldSessionID:
  8358. return m.OldSessionID(ctx)
  8359. case chatrecords.FieldUserID:
  8360. return m.OldUserID(ctx)
  8361. case chatrecords.FieldBotID:
  8362. return m.OldBotID(ctx)
  8363. case chatrecords.FieldBotType:
  8364. return m.OldBotType(ctx)
  8365. }
  8366. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8367. }
  8368. // SetField sets the value of a field with the given name. It returns an error if
  8369. // the field is not defined in the schema, or if the type mismatched the field
  8370. // type.
  8371. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8372. switch name {
  8373. case chatrecords.FieldCreatedAt:
  8374. v, ok := value.(time.Time)
  8375. if !ok {
  8376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8377. }
  8378. m.SetCreatedAt(v)
  8379. return nil
  8380. case chatrecords.FieldUpdatedAt:
  8381. v, ok := value.(time.Time)
  8382. if !ok {
  8383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8384. }
  8385. m.SetUpdatedAt(v)
  8386. return nil
  8387. case chatrecords.FieldDeletedAt:
  8388. v, ok := value.(time.Time)
  8389. if !ok {
  8390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8391. }
  8392. m.SetDeletedAt(v)
  8393. return nil
  8394. case chatrecords.FieldContent:
  8395. v, ok := value.(string)
  8396. if !ok {
  8397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8398. }
  8399. m.SetContent(v)
  8400. return nil
  8401. case chatrecords.FieldContentType:
  8402. v, ok := value.(uint8)
  8403. if !ok {
  8404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8405. }
  8406. m.SetContentType(v)
  8407. return nil
  8408. case chatrecords.FieldSessionID:
  8409. v, ok := value.(uint64)
  8410. if !ok {
  8411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8412. }
  8413. m.SetSessionID(v)
  8414. return nil
  8415. case chatrecords.FieldUserID:
  8416. v, ok := value.(uint64)
  8417. if !ok {
  8418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8419. }
  8420. m.SetUserID(v)
  8421. return nil
  8422. case chatrecords.FieldBotID:
  8423. v, ok := value.(uint64)
  8424. if !ok {
  8425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8426. }
  8427. m.SetBotID(v)
  8428. return nil
  8429. case chatrecords.FieldBotType:
  8430. v, ok := value.(uint8)
  8431. if !ok {
  8432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8433. }
  8434. m.SetBotType(v)
  8435. return nil
  8436. }
  8437. return fmt.Errorf("unknown ChatRecords field %s", name)
  8438. }
  8439. // AddedFields returns all numeric fields that were incremented/decremented during
  8440. // this mutation.
  8441. func (m *ChatRecordsMutation) AddedFields() []string {
  8442. var fields []string
  8443. if m.addcontent_type != nil {
  8444. fields = append(fields, chatrecords.FieldContentType)
  8445. }
  8446. if m.addsession_id != nil {
  8447. fields = append(fields, chatrecords.FieldSessionID)
  8448. }
  8449. if m.adduser_id != nil {
  8450. fields = append(fields, chatrecords.FieldUserID)
  8451. }
  8452. if m.addbot_id != nil {
  8453. fields = append(fields, chatrecords.FieldBotID)
  8454. }
  8455. if m.addbot_type != nil {
  8456. fields = append(fields, chatrecords.FieldBotType)
  8457. }
  8458. return fields
  8459. }
  8460. // AddedField returns the numeric value that was incremented/decremented on a field
  8461. // with the given name. The second boolean return value indicates that this field
  8462. // was not set, or was not defined in the schema.
  8463. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8464. switch name {
  8465. case chatrecords.FieldContentType:
  8466. return m.AddedContentType()
  8467. case chatrecords.FieldSessionID:
  8468. return m.AddedSessionID()
  8469. case chatrecords.FieldUserID:
  8470. return m.AddedUserID()
  8471. case chatrecords.FieldBotID:
  8472. return m.AddedBotID()
  8473. case chatrecords.FieldBotType:
  8474. return m.AddedBotType()
  8475. }
  8476. return nil, false
  8477. }
  8478. // AddField adds the value to the field with the given name. It returns an error if
  8479. // the field is not defined in the schema, or if the type mismatched the field
  8480. // type.
  8481. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8482. switch name {
  8483. case chatrecords.FieldContentType:
  8484. v, ok := value.(int8)
  8485. if !ok {
  8486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8487. }
  8488. m.AddContentType(v)
  8489. return nil
  8490. case chatrecords.FieldSessionID:
  8491. v, ok := value.(int64)
  8492. if !ok {
  8493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8494. }
  8495. m.AddSessionID(v)
  8496. return nil
  8497. case chatrecords.FieldUserID:
  8498. v, ok := value.(int64)
  8499. if !ok {
  8500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8501. }
  8502. m.AddUserID(v)
  8503. return nil
  8504. case chatrecords.FieldBotID:
  8505. v, ok := value.(int64)
  8506. if !ok {
  8507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8508. }
  8509. m.AddBotID(v)
  8510. return nil
  8511. case chatrecords.FieldBotType:
  8512. v, ok := value.(int8)
  8513. if !ok {
  8514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8515. }
  8516. m.AddBotType(v)
  8517. return nil
  8518. }
  8519. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8520. }
  8521. // ClearedFields returns all nullable fields that were cleared during this
  8522. // mutation.
  8523. func (m *ChatRecordsMutation) ClearedFields() []string {
  8524. var fields []string
  8525. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8526. fields = append(fields, chatrecords.FieldDeletedAt)
  8527. }
  8528. return fields
  8529. }
  8530. // FieldCleared returns a boolean indicating if a field with the given name was
  8531. // cleared in this mutation.
  8532. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8533. _, ok := m.clearedFields[name]
  8534. return ok
  8535. }
  8536. // ClearField clears the value of the field with the given name. It returns an
  8537. // error if the field is not defined in the schema.
  8538. func (m *ChatRecordsMutation) ClearField(name string) error {
  8539. switch name {
  8540. case chatrecords.FieldDeletedAt:
  8541. m.ClearDeletedAt()
  8542. return nil
  8543. }
  8544. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8545. }
  8546. // ResetField resets all changes in the mutation for the field with the given name.
  8547. // It returns an error if the field is not defined in the schema.
  8548. func (m *ChatRecordsMutation) ResetField(name string) error {
  8549. switch name {
  8550. case chatrecords.FieldCreatedAt:
  8551. m.ResetCreatedAt()
  8552. return nil
  8553. case chatrecords.FieldUpdatedAt:
  8554. m.ResetUpdatedAt()
  8555. return nil
  8556. case chatrecords.FieldDeletedAt:
  8557. m.ResetDeletedAt()
  8558. return nil
  8559. case chatrecords.FieldContent:
  8560. m.ResetContent()
  8561. return nil
  8562. case chatrecords.FieldContentType:
  8563. m.ResetContentType()
  8564. return nil
  8565. case chatrecords.FieldSessionID:
  8566. m.ResetSessionID()
  8567. return nil
  8568. case chatrecords.FieldUserID:
  8569. m.ResetUserID()
  8570. return nil
  8571. case chatrecords.FieldBotID:
  8572. m.ResetBotID()
  8573. return nil
  8574. case chatrecords.FieldBotType:
  8575. m.ResetBotType()
  8576. return nil
  8577. }
  8578. return fmt.Errorf("unknown ChatRecords field %s", name)
  8579. }
  8580. // AddedEdges returns all edge names that were set/added in this mutation.
  8581. func (m *ChatRecordsMutation) AddedEdges() []string {
  8582. edges := make([]string, 0, 0)
  8583. return edges
  8584. }
  8585. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8586. // name in this mutation.
  8587. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8588. return nil
  8589. }
  8590. // RemovedEdges returns all edge names that were removed in this mutation.
  8591. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8592. edges := make([]string, 0, 0)
  8593. return edges
  8594. }
  8595. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8596. // the given name in this mutation.
  8597. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8598. return nil
  8599. }
  8600. // ClearedEdges returns all edge names that were cleared in this mutation.
  8601. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8602. edges := make([]string, 0, 0)
  8603. return edges
  8604. }
  8605. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8606. // was cleared in this mutation.
  8607. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8608. return false
  8609. }
  8610. // ClearEdge clears the value of the edge with the given name. It returns an error
  8611. // if that edge is not defined in the schema.
  8612. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8613. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8614. }
  8615. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8616. // It returns an error if the edge is not defined in the schema.
  8617. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8618. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8619. }
  8620. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8621. type ChatSessionMutation struct {
  8622. config
  8623. op Op
  8624. typ string
  8625. id *uint64
  8626. created_at *time.Time
  8627. updated_at *time.Time
  8628. deleted_at *time.Time
  8629. name *string
  8630. user_id *uint64
  8631. adduser_id *int64
  8632. bot_id *uint64
  8633. addbot_id *int64
  8634. bot_type *uint8
  8635. addbot_type *int8
  8636. clearedFields map[string]struct{}
  8637. done bool
  8638. oldValue func(context.Context) (*ChatSession, error)
  8639. predicates []predicate.ChatSession
  8640. }
  8641. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8642. // chatsessionOption allows management of the mutation configuration using functional options.
  8643. type chatsessionOption func(*ChatSessionMutation)
  8644. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8645. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8646. m := &ChatSessionMutation{
  8647. config: c,
  8648. op: op,
  8649. typ: TypeChatSession,
  8650. clearedFields: make(map[string]struct{}),
  8651. }
  8652. for _, opt := range opts {
  8653. opt(m)
  8654. }
  8655. return m
  8656. }
  8657. // withChatSessionID sets the ID field of the mutation.
  8658. func withChatSessionID(id uint64) chatsessionOption {
  8659. return func(m *ChatSessionMutation) {
  8660. var (
  8661. err error
  8662. once sync.Once
  8663. value *ChatSession
  8664. )
  8665. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8666. once.Do(func() {
  8667. if m.done {
  8668. err = errors.New("querying old values post mutation is not allowed")
  8669. } else {
  8670. value, err = m.Client().ChatSession.Get(ctx, id)
  8671. }
  8672. })
  8673. return value, err
  8674. }
  8675. m.id = &id
  8676. }
  8677. }
  8678. // withChatSession sets the old ChatSession of the mutation.
  8679. func withChatSession(node *ChatSession) chatsessionOption {
  8680. return func(m *ChatSessionMutation) {
  8681. m.oldValue = func(context.Context) (*ChatSession, error) {
  8682. return node, nil
  8683. }
  8684. m.id = &node.ID
  8685. }
  8686. }
  8687. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8688. // executed in a transaction (ent.Tx), a transactional client is returned.
  8689. func (m ChatSessionMutation) Client() *Client {
  8690. client := &Client{config: m.config}
  8691. client.init()
  8692. return client
  8693. }
  8694. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8695. // it returns an error otherwise.
  8696. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8697. if _, ok := m.driver.(*txDriver); !ok {
  8698. return nil, errors.New("ent: mutation is not running in a transaction")
  8699. }
  8700. tx := &Tx{config: m.config}
  8701. tx.init()
  8702. return tx, nil
  8703. }
  8704. // SetID sets the value of the id field. Note that this
  8705. // operation is only accepted on creation of ChatSession entities.
  8706. func (m *ChatSessionMutation) SetID(id uint64) {
  8707. m.id = &id
  8708. }
  8709. // ID returns the ID value in the mutation. Note that the ID is only available
  8710. // if it was provided to the builder or after it was returned from the database.
  8711. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8712. if m.id == nil {
  8713. return
  8714. }
  8715. return *m.id, true
  8716. }
  8717. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8718. // That means, if the mutation is applied within a transaction with an isolation level such
  8719. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8720. // or updated by the mutation.
  8721. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8722. switch {
  8723. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8724. id, exists := m.ID()
  8725. if exists {
  8726. return []uint64{id}, nil
  8727. }
  8728. fallthrough
  8729. case m.op.Is(OpUpdate | OpDelete):
  8730. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8731. default:
  8732. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8733. }
  8734. }
  8735. // SetCreatedAt sets the "created_at" field.
  8736. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8737. m.created_at = &t
  8738. }
  8739. // CreatedAt returns the value of the "created_at" field in the mutation.
  8740. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8741. v := m.created_at
  8742. if v == nil {
  8743. return
  8744. }
  8745. return *v, true
  8746. }
  8747. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8748. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8750. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8751. if !m.op.Is(OpUpdateOne) {
  8752. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8753. }
  8754. if m.id == nil || m.oldValue == nil {
  8755. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8756. }
  8757. oldValue, err := m.oldValue(ctx)
  8758. if err != nil {
  8759. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8760. }
  8761. return oldValue.CreatedAt, nil
  8762. }
  8763. // ResetCreatedAt resets all changes to the "created_at" field.
  8764. func (m *ChatSessionMutation) ResetCreatedAt() {
  8765. m.created_at = nil
  8766. }
  8767. // SetUpdatedAt sets the "updated_at" field.
  8768. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8769. m.updated_at = &t
  8770. }
  8771. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8772. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8773. v := m.updated_at
  8774. if v == nil {
  8775. return
  8776. }
  8777. return *v, true
  8778. }
  8779. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8780. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8782. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8783. if !m.op.Is(OpUpdateOne) {
  8784. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8785. }
  8786. if m.id == nil || m.oldValue == nil {
  8787. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8788. }
  8789. oldValue, err := m.oldValue(ctx)
  8790. if err != nil {
  8791. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8792. }
  8793. return oldValue.UpdatedAt, nil
  8794. }
  8795. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8796. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8797. m.updated_at = nil
  8798. }
  8799. // SetDeletedAt sets the "deleted_at" field.
  8800. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8801. m.deleted_at = &t
  8802. }
  8803. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8804. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8805. v := m.deleted_at
  8806. if v == nil {
  8807. return
  8808. }
  8809. return *v, true
  8810. }
  8811. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8812. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8814. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8815. if !m.op.Is(OpUpdateOne) {
  8816. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8817. }
  8818. if m.id == nil || m.oldValue == nil {
  8819. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8820. }
  8821. oldValue, err := m.oldValue(ctx)
  8822. if err != nil {
  8823. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8824. }
  8825. return oldValue.DeletedAt, nil
  8826. }
  8827. // ClearDeletedAt clears the value of the "deleted_at" field.
  8828. func (m *ChatSessionMutation) ClearDeletedAt() {
  8829. m.deleted_at = nil
  8830. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8831. }
  8832. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8833. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  8834. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  8835. return ok
  8836. }
  8837. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8838. func (m *ChatSessionMutation) ResetDeletedAt() {
  8839. m.deleted_at = nil
  8840. delete(m.clearedFields, chatsession.FieldDeletedAt)
  8841. }
  8842. // SetName sets the "name" field.
  8843. func (m *ChatSessionMutation) SetName(s string) {
  8844. m.name = &s
  8845. }
  8846. // Name returns the value of the "name" field in the mutation.
  8847. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  8848. v := m.name
  8849. if v == nil {
  8850. return
  8851. }
  8852. return *v, true
  8853. }
  8854. // OldName returns the old "name" field's value of the ChatSession entity.
  8855. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8857. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  8858. if !m.op.Is(OpUpdateOne) {
  8859. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8860. }
  8861. if m.id == nil || m.oldValue == nil {
  8862. return v, errors.New("OldName requires an ID field in the mutation")
  8863. }
  8864. oldValue, err := m.oldValue(ctx)
  8865. if err != nil {
  8866. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8867. }
  8868. return oldValue.Name, nil
  8869. }
  8870. // ResetName resets all changes to the "name" field.
  8871. func (m *ChatSessionMutation) ResetName() {
  8872. m.name = nil
  8873. }
  8874. // SetUserID sets the "user_id" field.
  8875. func (m *ChatSessionMutation) SetUserID(u uint64) {
  8876. m.user_id = &u
  8877. m.adduser_id = nil
  8878. }
  8879. // UserID returns the value of the "user_id" field in the mutation.
  8880. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  8881. v := m.user_id
  8882. if v == nil {
  8883. return
  8884. }
  8885. return *v, true
  8886. }
  8887. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  8888. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8890. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8891. if !m.op.Is(OpUpdateOne) {
  8892. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8893. }
  8894. if m.id == nil || m.oldValue == nil {
  8895. return v, errors.New("OldUserID requires an ID field in the mutation")
  8896. }
  8897. oldValue, err := m.oldValue(ctx)
  8898. if err != nil {
  8899. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8900. }
  8901. return oldValue.UserID, nil
  8902. }
  8903. // AddUserID adds u to the "user_id" field.
  8904. func (m *ChatSessionMutation) AddUserID(u int64) {
  8905. if m.adduser_id != nil {
  8906. *m.adduser_id += u
  8907. } else {
  8908. m.adduser_id = &u
  8909. }
  8910. }
  8911. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8912. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  8913. v := m.adduser_id
  8914. if v == nil {
  8915. return
  8916. }
  8917. return *v, true
  8918. }
  8919. // ResetUserID resets all changes to the "user_id" field.
  8920. func (m *ChatSessionMutation) ResetUserID() {
  8921. m.user_id = nil
  8922. m.adduser_id = nil
  8923. }
  8924. // SetBotID sets the "bot_id" field.
  8925. func (m *ChatSessionMutation) SetBotID(u uint64) {
  8926. m.bot_id = &u
  8927. m.addbot_id = nil
  8928. }
  8929. // BotID returns the value of the "bot_id" field in the mutation.
  8930. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  8931. v := m.bot_id
  8932. if v == nil {
  8933. return
  8934. }
  8935. return *v, true
  8936. }
  8937. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  8938. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8940. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8941. if !m.op.Is(OpUpdateOne) {
  8942. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8943. }
  8944. if m.id == nil || m.oldValue == nil {
  8945. return v, errors.New("OldBotID requires an ID field in the mutation")
  8946. }
  8947. oldValue, err := m.oldValue(ctx)
  8948. if err != nil {
  8949. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8950. }
  8951. return oldValue.BotID, nil
  8952. }
  8953. // AddBotID adds u to the "bot_id" field.
  8954. func (m *ChatSessionMutation) AddBotID(u int64) {
  8955. if m.addbot_id != nil {
  8956. *m.addbot_id += u
  8957. } else {
  8958. m.addbot_id = &u
  8959. }
  8960. }
  8961. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8962. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  8963. v := m.addbot_id
  8964. if v == nil {
  8965. return
  8966. }
  8967. return *v, true
  8968. }
  8969. // ResetBotID resets all changes to the "bot_id" field.
  8970. func (m *ChatSessionMutation) ResetBotID() {
  8971. m.bot_id = nil
  8972. m.addbot_id = nil
  8973. }
  8974. // SetBotType sets the "bot_type" field.
  8975. func (m *ChatSessionMutation) SetBotType(u uint8) {
  8976. m.bot_type = &u
  8977. m.addbot_type = nil
  8978. }
  8979. // BotType returns the value of the "bot_type" field in the mutation.
  8980. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  8981. v := m.bot_type
  8982. if v == nil {
  8983. return
  8984. }
  8985. return *v, true
  8986. }
  8987. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  8988. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8990. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8991. if !m.op.Is(OpUpdateOne) {
  8992. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8993. }
  8994. if m.id == nil || m.oldValue == nil {
  8995. return v, errors.New("OldBotType requires an ID field in the mutation")
  8996. }
  8997. oldValue, err := m.oldValue(ctx)
  8998. if err != nil {
  8999. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9000. }
  9001. return oldValue.BotType, nil
  9002. }
  9003. // AddBotType adds u to the "bot_type" field.
  9004. func (m *ChatSessionMutation) AddBotType(u int8) {
  9005. if m.addbot_type != nil {
  9006. *m.addbot_type += u
  9007. } else {
  9008. m.addbot_type = &u
  9009. }
  9010. }
  9011. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9012. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  9013. v := m.addbot_type
  9014. if v == nil {
  9015. return
  9016. }
  9017. return *v, true
  9018. }
  9019. // ResetBotType resets all changes to the "bot_type" field.
  9020. func (m *ChatSessionMutation) ResetBotType() {
  9021. m.bot_type = nil
  9022. m.addbot_type = nil
  9023. }
  9024. // Where appends a list predicates to the ChatSessionMutation builder.
  9025. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  9026. m.predicates = append(m.predicates, ps...)
  9027. }
  9028. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  9029. // users can use type-assertion to append predicates that do not depend on any generated package.
  9030. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  9031. p := make([]predicate.ChatSession, len(ps))
  9032. for i := range ps {
  9033. p[i] = ps[i]
  9034. }
  9035. m.Where(p...)
  9036. }
  9037. // Op returns the operation name.
  9038. func (m *ChatSessionMutation) Op() Op {
  9039. return m.op
  9040. }
  9041. // SetOp allows setting the mutation operation.
  9042. func (m *ChatSessionMutation) SetOp(op Op) {
  9043. m.op = op
  9044. }
  9045. // Type returns the node type of this mutation (ChatSession).
  9046. func (m *ChatSessionMutation) Type() string {
  9047. return m.typ
  9048. }
  9049. // Fields returns all fields that were changed during this mutation. Note that in
  9050. // order to get all numeric fields that were incremented/decremented, call
  9051. // AddedFields().
  9052. func (m *ChatSessionMutation) Fields() []string {
  9053. fields := make([]string, 0, 7)
  9054. if m.created_at != nil {
  9055. fields = append(fields, chatsession.FieldCreatedAt)
  9056. }
  9057. if m.updated_at != nil {
  9058. fields = append(fields, chatsession.FieldUpdatedAt)
  9059. }
  9060. if m.deleted_at != nil {
  9061. fields = append(fields, chatsession.FieldDeletedAt)
  9062. }
  9063. if m.name != nil {
  9064. fields = append(fields, chatsession.FieldName)
  9065. }
  9066. if m.user_id != nil {
  9067. fields = append(fields, chatsession.FieldUserID)
  9068. }
  9069. if m.bot_id != nil {
  9070. fields = append(fields, chatsession.FieldBotID)
  9071. }
  9072. if m.bot_type != nil {
  9073. fields = append(fields, chatsession.FieldBotType)
  9074. }
  9075. return fields
  9076. }
  9077. // Field returns the value of a field with the given name. The second boolean
  9078. // return value indicates that this field was not set, or was not defined in the
  9079. // schema.
  9080. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9081. switch name {
  9082. case chatsession.FieldCreatedAt:
  9083. return m.CreatedAt()
  9084. case chatsession.FieldUpdatedAt:
  9085. return m.UpdatedAt()
  9086. case chatsession.FieldDeletedAt:
  9087. return m.DeletedAt()
  9088. case chatsession.FieldName:
  9089. return m.Name()
  9090. case chatsession.FieldUserID:
  9091. return m.UserID()
  9092. case chatsession.FieldBotID:
  9093. return m.BotID()
  9094. case chatsession.FieldBotType:
  9095. return m.BotType()
  9096. }
  9097. return nil, false
  9098. }
  9099. // OldField returns the old value of the field from the database. An error is
  9100. // returned if the mutation operation is not UpdateOne, or the query to the
  9101. // database failed.
  9102. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9103. switch name {
  9104. case chatsession.FieldCreatedAt:
  9105. return m.OldCreatedAt(ctx)
  9106. case chatsession.FieldUpdatedAt:
  9107. return m.OldUpdatedAt(ctx)
  9108. case chatsession.FieldDeletedAt:
  9109. return m.OldDeletedAt(ctx)
  9110. case chatsession.FieldName:
  9111. return m.OldName(ctx)
  9112. case chatsession.FieldUserID:
  9113. return m.OldUserID(ctx)
  9114. case chatsession.FieldBotID:
  9115. return m.OldBotID(ctx)
  9116. case chatsession.FieldBotType:
  9117. return m.OldBotType(ctx)
  9118. }
  9119. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9120. }
  9121. // SetField sets the value of a field with the given name. It returns an error if
  9122. // the field is not defined in the schema, or if the type mismatched the field
  9123. // type.
  9124. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9125. switch name {
  9126. case chatsession.FieldCreatedAt:
  9127. v, ok := value.(time.Time)
  9128. if !ok {
  9129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9130. }
  9131. m.SetCreatedAt(v)
  9132. return nil
  9133. case chatsession.FieldUpdatedAt:
  9134. v, ok := value.(time.Time)
  9135. if !ok {
  9136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9137. }
  9138. m.SetUpdatedAt(v)
  9139. return nil
  9140. case chatsession.FieldDeletedAt:
  9141. v, ok := value.(time.Time)
  9142. if !ok {
  9143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9144. }
  9145. m.SetDeletedAt(v)
  9146. return nil
  9147. case chatsession.FieldName:
  9148. v, ok := value.(string)
  9149. if !ok {
  9150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9151. }
  9152. m.SetName(v)
  9153. return nil
  9154. case chatsession.FieldUserID:
  9155. v, ok := value.(uint64)
  9156. if !ok {
  9157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9158. }
  9159. m.SetUserID(v)
  9160. return nil
  9161. case chatsession.FieldBotID:
  9162. v, ok := value.(uint64)
  9163. if !ok {
  9164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9165. }
  9166. m.SetBotID(v)
  9167. return nil
  9168. case chatsession.FieldBotType:
  9169. v, ok := value.(uint8)
  9170. if !ok {
  9171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9172. }
  9173. m.SetBotType(v)
  9174. return nil
  9175. }
  9176. return fmt.Errorf("unknown ChatSession field %s", name)
  9177. }
  9178. // AddedFields returns all numeric fields that were incremented/decremented during
  9179. // this mutation.
  9180. func (m *ChatSessionMutation) AddedFields() []string {
  9181. var fields []string
  9182. if m.adduser_id != nil {
  9183. fields = append(fields, chatsession.FieldUserID)
  9184. }
  9185. if m.addbot_id != nil {
  9186. fields = append(fields, chatsession.FieldBotID)
  9187. }
  9188. if m.addbot_type != nil {
  9189. fields = append(fields, chatsession.FieldBotType)
  9190. }
  9191. return fields
  9192. }
  9193. // AddedField returns the numeric value that was incremented/decremented on a field
  9194. // with the given name. The second boolean return value indicates that this field
  9195. // was not set, or was not defined in the schema.
  9196. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9197. switch name {
  9198. case chatsession.FieldUserID:
  9199. return m.AddedUserID()
  9200. case chatsession.FieldBotID:
  9201. return m.AddedBotID()
  9202. case chatsession.FieldBotType:
  9203. return m.AddedBotType()
  9204. }
  9205. return nil, false
  9206. }
  9207. // AddField adds the value to the field with the given name. It returns an error if
  9208. // the field is not defined in the schema, or if the type mismatched the field
  9209. // type.
  9210. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9211. switch name {
  9212. case chatsession.FieldUserID:
  9213. v, ok := value.(int64)
  9214. if !ok {
  9215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9216. }
  9217. m.AddUserID(v)
  9218. return nil
  9219. case chatsession.FieldBotID:
  9220. v, ok := value.(int64)
  9221. if !ok {
  9222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9223. }
  9224. m.AddBotID(v)
  9225. return nil
  9226. case chatsession.FieldBotType:
  9227. v, ok := value.(int8)
  9228. if !ok {
  9229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9230. }
  9231. m.AddBotType(v)
  9232. return nil
  9233. }
  9234. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9235. }
  9236. // ClearedFields returns all nullable fields that were cleared during this
  9237. // mutation.
  9238. func (m *ChatSessionMutation) ClearedFields() []string {
  9239. var fields []string
  9240. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9241. fields = append(fields, chatsession.FieldDeletedAt)
  9242. }
  9243. return fields
  9244. }
  9245. // FieldCleared returns a boolean indicating if a field with the given name was
  9246. // cleared in this mutation.
  9247. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9248. _, ok := m.clearedFields[name]
  9249. return ok
  9250. }
  9251. // ClearField clears the value of the field with the given name. It returns an
  9252. // error if the field is not defined in the schema.
  9253. func (m *ChatSessionMutation) ClearField(name string) error {
  9254. switch name {
  9255. case chatsession.FieldDeletedAt:
  9256. m.ClearDeletedAt()
  9257. return nil
  9258. }
  9259. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9260. }
  9261. // ResetField resets all changes in the mutation for the field with the given name.
  9262. // It returns an error if the field is not defined in the schema.
  9263. func (m *ChatSessionMutation) ResetField(name string) error {
  9264. switch name {
  9265. case chatsession.FieldCreatedAt:
  9266. m.ResetCreatedAt()
  9267. return nil
  9268. case chatsession.FieldUpdatedAt:
  9269. m.ResetUpdatedAt()
  9270. return nil
  9271. case chatsession.FieldDeletedAt:
  9272. m.ResetDeletedAt()
  9273. return nil
  9274. case chatsession.FieldName:
  9275. m.ResetName()
  9276. return nil
  9277. case chatsession.FieldUserID:
  9278. m.ResetUserID()
  9279. return nil
  9280. case chatsession.FieldBotID:
  9281. m.ResetBotID()
  9282. return nil
  9283. case chatsession.FieldBotType:
  9284. m.ResetBotType()
  9285. return nil
  9286. }
  9287. return fmt.Errorf("unknown ChatSession field %s", name)
  9288. }
  9289. // AddedEdges returns all edge names that were set/added in this mutation.
  9290. func (m *ChatSessionMutation) AddedEdges() []string {
  9291. edges := make([]string, 0, 0)
  9292. return edges
  9293. }
  9294. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9295. // name in this mutation.
  9296. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9297. return nil
  9298. }
  9299. // RemovedEdges returns all edge names that were removed in this mutation.
  9300. func (m *ChatSessionMutation) RemovedEdges() []string {
  9301. edges := make([]string, 0, 0)
  9302. return edges
  9303. }
  9304. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9305. // the given name in this mutation.
  9306. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9307. return nil
  9308. }
  9309. // ClearedEdges returns all edge names that were cleared in this mutation.
  9310. func (m *ChatSessionMutation) ClearedEdges() []string {
  9311. edges := make([]string, 0, 0)
  9312. return edges
  9313. }
  9314. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9315. // was cleared in this mutation.
  9316. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9317. return false
  9318. }
  9319. // ClearEdge clears the value of the edge with the given name. It returns an error
  9320. // if that edge is not defined in the schema.
  9321. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9322. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9323. }
  9324. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9325. // It returns an error if the edge is not defined in the schema.
  9326. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9327. return fmt.Errorf("unknown ChatSession edge %s", name)
  9328. }
  9329. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  9330. type ContactMutation struct {
  9331. config
  9332. op Op
  9333. typ string
  9334. id *uint64
  9335. created_at *time.Time
  9336. updated_at *time.Time
  9337. status *uint8
  9338. addstatus *int8
  9339. deleted_at *time.Time
  9340. wx_wxid *string
  9341. _type *int
  9342. add_type *int
  9343. wxid *string
  9344. account *string
  9345. nickname *string
  9346. markname *string
  9347. headimg *string
  9348. sex *int
  9349. addsex *int
  9350. starrole *string
  9351. dontseeit *int
  9352. adddontseeit *int
  9353. dontseeme *int
  9354. adddontseeme *int
  9355. lag *string
  9356. gid *string
  9357. gname *string
  9358. v3 *string
  9359. organization_id *uint64
  9360. addorganization_id *int64
  9361. ctype *uint64
  9362. addctype *int64
  9363. cage *int
  9364. addcage *int
  9365. cname *string
  9366. carea *string
  9367. cbirthday *string
  9368. cbirtharea *string
  9369. cidcard_no *string
  9370. ctitle *string
  9371. cc *string
  9372. phone *string
  9373. clearedFields map[string]struct{}
  9374. contact_relationships map[uint64]struct{}
  9375. removedcontact_relationships map[uint64]struct{}
  9376. clearedcontact_relationships bool
  9377. contact_messages map[uint64]struct{}
  9378. removedcontact_messages map[uint64]struct{}
  9379. clearedcontact_messages bool
  9380. done bool
  9381. oldValue func(context.Context) (*Contact, error)
  9382. predicates []predicate.Contact
  9383. }
  9384. var _ ent.Mutation = (*ContactMutation)(nil)
  9385. // contactOption allows management of the mutation configuration using functional options.
  9386. type contactOption func(*ContactMutation)
  9387. // newContactMutation creates new mutation for the Contact entity.
  9388. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  9389. m := &ContactMutation{
  9390. config: c,
  9391. op: op,
  9392. typ: TypeContact,
  9393. clearedFields: make(map[string]struct{}),
  9394. }
  9395. for _, opt := range opts {
  9396. opt(m)
  9397. }
  9398. return m
  9399. }
  9400. // withContactID sets the ID field of the mutation.
  9401. func withContactID(id uint64) contactOption {
  9402. return func(m *ContactMutation) {
  9403. var (
  9404. err error
  9405. once sync.Once
  9406. value *Contact
  9407. )
  9408. m.oldValue = func(ctx context.Context) (*Contact, error) {
  9409. once.Do(func() {
  9410. if m.done {
  9411. err = errors.New("querying old values post mutation is not allowed")
  9412. } else {
  9413. value, err = m.Client().Contact.Get(ctx, id)
  9414. }
  9415. })
  9416. return value, err
  9417. }
  9418. m.id = &id
  9419. }
  9420. }
  9421. // withContact sets the old Contact of the mutation.
  9422. func withContact(node *Contact) contactOption {
  9423. return func(m *ContactMutation) {
  9424. m.oldValue = func(context.Context) (*Contact, error) {
  9425. return node, nil
  9426. }
  9427. m.id = &node.ID
  9428. }
  9429. }
  9430. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9431. // executed in a transaction (ent.Tx), a transactional client is returned.
  9432. func (m ContactMutation) Client() *Client {
  9433. client := &Client{config: m.config}
  9434. client.init()
  9435. return client
  9436. }
  9437. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9438. // it returns an error otherwise.
  9439. func (m ContactMutation) Tx() (*Tx, error) {
  9440. if _, ok := m.driver.(*txDriver); !ok {
  9441. return nil, errors.New("ent: mutation is not running in a transaction")
  9442. }
  9443. tx := &Tx{config: m.config}
  9444. tx.init()
  9445. return tx, nil
  9446. }
  9447. // SetID sets the value of the id field. Note that this
  9448. // operation is only accepted on creation of Contact entities.
  9449. func (m *ContactMutation) SetID(id uint64) {
  9450. m.id = &id
  9451. }
  9452. // ID returns the ID value in the mutation. Note that the ID is only available
  9453. // if it was provided to the builder or after it was returned from the database.
  9454. func (m *ContactMutation) ID() (id uint64, exists bool) {
  9455. if m.id == nil {
  9456. return
  9457. }
  9458. return *m.id, true
  9459. }
  9460. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9461. // That means, if the mutation is applied within a transaction with an isolation level such
  9462. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9463. // or updated by the mutation.
  9464. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  9465. switch {
  9466. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9467. id, exists := m.ID()
  9468. if exists {
  9469. return []uint64{id}, nil
  9470. }
  9471. fallthrough
  9472. case m.op.Is(OpUpdate | OpDelete):
  9473. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  9474. default:
  9475. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9476. }
  9477. }
  9478. // SetCreatedAt sets the "created_at" field.
  9479. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  9480. m.created_at = &t
  9481. }
  9482. // CreatedAt returns the value of the "created_at" field in the mutation.
  9483. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  9484. v := m.created_at
  9485. if v == nil {
  9486. return
  9487. }
  9488. return *v, true
  9489. }
  9490. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  9491. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9493. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9494. if !m.op.Is(OpUpdateOne) {
  9495. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9496. }
  9497. if m.id == nil || m.oldValue == nil {
  9498. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9499. }
  9500. oldValue, err := m.oldValue(ctx)
  9501. if err != nil {
  9502. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9503. }
  9504. return oldValue.CreatedAt, nil
  9505. }
  9506. // ResetCreatedAt resets all changes to the "created_at" field.
  9507. func (m *ContactMutation) ResetCreatedAt() {
  9508. m.created_at = nil
  9509. }
  9510. // SetUpdatedAt sets the "updated_at" field.
  9511. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  9512. m.updated_at = &t
  9513. }
  9514. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9515. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  9516. v := m.updated_at
  9517. if v == nil {
  9518. return
  9519. }
  9520. return *v, true
  9521. }
  9522. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  9523. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9525. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9526. if !m.op.Is(OpUpdateOne) {
  9527. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9528. }
  9529. if m.id == nil || m.oldValue == nil {
  9530. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9531. }
  9532. oldValue, err := m.oldValue(ctx)
  9533. if err != nil {
  9534. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9535. }
  9536. return oldValue.UpdatedAt, nil
  9537. }
  9538. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9539. func (m *ContactMutation) ResetUpdatedAt() {
  9540. m.updated_at = nil
  9541. }
  9542. // SetStatus sets the "status" field.
  9543. func (m *ContactMutation) SetStatus(u uint8) {
  9544. m.status = &u
  9545. m.addstatus = nil
  9546. }
  9547. // Status returns the value of the "status" field in the mutation.
  9548. func (m *ContactMutation) Status() (r uint8, exists bool) {
  9549. v := m.status
  9550. if v == nil {
  9551. return
  9552. }
  9553. return *v, true
  9554. }
  9555. // OldStatus returns the old "status" field's value of the Contact entity.
  9556. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9558. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9559. if !m.op.Is(OpUpdateOne) {
  9560. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9561. }
  9562. if m.id == nil || m.oldValue == nil {
  9563. return v, errors.New("OldStatus requires an ID field in the mutation")
  9564. }
  9565. oldValue, err := m.oldValue(ctx)
  9566. if err != nil {
  9567. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9568. }
  9569. return oldValue.Status, nil
  9570. }
  9571. // AddStatus adds u to the "status" field.
  9572. func (m *ContactMutation) AddStatus(u int8) {
  9573. if m.addstatus != nil {
  9574. *m.addstatus += u
  9575. } else {
  9576. m.addstatus = &u
  9577. }
  9578. }
  9579. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9580. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  9581. v := m.addstatus
  9582. if v == nil {
  9583. return
  9584. }
  9585. return *v, true
  9586. }
  9587. // ClearStatus clears the value of the "status" field.
  9588. func (m *ContactMutation) ClearStatus() {
  9589. m.status = nil
  9590. m.addstatus = nil
  9591. m.clearedFields[contact.FieldStatus] = struct{}{}
  9592. }
  9593. // StatusCleared returns if the "status" field was cleared in this mutation.
  9594. func (m *ContactMutation) StatusCleared() bool {
  9595. _, ok := m.clearedFields[contact.FieldStatus]
  9596. return ok
  9597. }
  9598. // ResetStatus resets all changes to the "status" field.
  9599. func (m *ContactMutation) ResetStatus() {
  9600. m.status = nil
  9601. m.addstatus = nil
  9602. delete(m.clearedFields, contact.FieldStatus)
  9603. }
  9604. // SetDeletedAt sets the "deleted_at" field.
  9605. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  9606. m.deleted_at = &t
  9607. }
  9608. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9609. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  9610. v := m.deleted_at
  9611. if v == nil {
  9612. return
  9613. }
  9614. return *v, true
  9615. }
  9616. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  9617. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9619. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9620. if !m.op.Is(OpUpdateOne) {
  9621. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9622. }
  9623. if m.id == nil || m.oldValue == nil {
  9624. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9625. }
  9626. oldValue, err := m.oldValue(ctx)
  9627. if err != nil {
  9628. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9629. }
  9630. return oldValue.DeletedAt, nil
  9631. }
  9632. // ClearDeletedAt clears the value of the "deleted_at" field.
  9633. func (m *ContactMutation) ClearDeletedAt() {
  9634. m.deleted_at = nil
  9635. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  9636. }
  9637. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9638. func (m *ContactMutation) DeletedAtCleared() bool {
  9639. _, ok := m.clearedFields[contact.FieldDeletedAt]
  9640. return ok
  9641. }
  9642. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9643. func (m *ContactMutation) ResetDeletedAt() {
  9644. m.deleted_at = nil
  9645. delete(m.clearedFields, contact.FieldDeletedAt)
  9646. }
  9647. // SetWxWxid sets the "wx_wxid" field.
  9648. func (m *ContactMutation) SetWxWxid(s string) {
  9649. m.wx_wxid = &s
  9650. }
  9651. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  9652. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  9653. v := m.wx_wxid
  9654. if v == nil {
  9655. return
  9656. }
  9657. return *v, true
  9658. }
  9659. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  9660. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9662. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  9663. if !m.op.Is(OpUpdateOne) {
  9664. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  9665. }
  9666. if m.id == nil || m.oldValue == nil {
  9667. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  9668. }
  9669. oldValue, err := m.oldValue(ctx)
  9670. if err != nil {
  9671. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9672. }
  9673. return oldValue.WxWxid, nil
  9674. }
  9675. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9676. func (m *ContactMutation) ResetWxWxid() {
  9677. m.wx_wxid = nil
  9678. }
  9679. // SetType sets the "type" field.
  9680. func (m *ContactMutation) SetType(i int) {
  9681. m._type = &i
  9682. m.add_type = nil
  9683. }
  9684. // GetType returns the value of the "type" field in the mutation.
  9685. func (m *ContactMutation) GetType() (r int, exists bool) {
  9686. v := m._type
  9687. if v == nil {
  9688. return
  9689. }
  9690. return *v, true
  9691. }
  9692. // OldType returns the old "type" field's value of the Contact entity.
  9693. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9695. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  9696. if !m.op.Is(OpUpdateOne) {
  9697. return v, errors.New("OldType is only allowed on UpdateOne operations")
  9698. }
  9699. if m.id == nil || m.oldValue == nil {
  9700. return v, errors.New("OldType requires an ID field in the mutation")
  9701. }
  9702. oldValue, err := m.oldValue(ctx)
  9703. if err != nil {
  9704. return v, fmt.Errorf("querying old value for OldType: %w", err)
  9705. }
  9706. return oldValue.Type, nil
  9707. }
  9708. // AddType adds i to the "type" field.
  9709. func (m *ContactMutation) AddType(i int) {
  9710. if m.add_type != nil {
  9711. *m.add_type += i
  9712. } else {
  9713. m.add_type = &i
  9714. }
  9715. }
  9716. // AddedType returns the value that was added to the "type" field in this mutation.
  9717. func (m *ContactMutation) AddedType() (r int, exists bool) {
  9718. v := m.add_type
  9719. if v == nil {
  9720. return
  9721. }
  9722. return *v, true
  9723. }
  9724. // ClearType clears the value of the "type" field.
  9725. func (m *ContactMutation) ClearType() {
  9726. m._type = nil
  9727. m.add_type = nil
  9728. m.clearedFields[contact.FieldType] = struct{}{}
  9729. }
  9730. // TypeCleared returns if the "type" field was cleared in this mutation.
  9731. func (m *ContactMutation) TypeCleared() bool {
  9732. _, ok := m.clearedFields[contact.FieldType]
  9733. return ok
  9734. }
  9735. // ResetType resets all changes to the "type" field.
  9736. func (m *ContactMutation) ResetType() {
  9737. m._type = nil
  9738. m.add_type = nil
  9739. delete(m.clearedFields, contact.FieldType)
  9740. }
  9741. // SetWxid sets the "wxid" field.
  9742. func (m *ContactMutation) SetWxid(s string) {
  9743. m.wxid = &s
  9744. }
  9745. // Wxid returns the value of the "wxid" field in the mutation.
  9746. func (m *ContactMutation) Wxid() (r string, exists bool) {
  9747. v := m.wxid
  9748. if v == nil {
  9749. return
  9750. }
  9751. return *v, true
  9752. }
  9753. // OldWxid returns the old "wxid" field's value of the Contact entity.
  9754. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9756. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  9757. if !m.op.Is(OpUpdateOne) {
  9758. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9759. }
  9760. if m.id == nil || m.oldValue == nil {
  9761. return v, errors.New("OldWxid requires an ID field in the mutation")
  9762. }
  9763. oldValue, err := m.oldValue(ctx)
  9764. if err != nil {
  9765. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9766. }
  9767. return oldValue.Wxid, nil
  9768. }
  9769. // ResetWxid resets all changes to the "wxid" field.
  9770. func (m *ContactMutation) ResetWxid() {
  9771. m.wxid = nil
  9772. }
  9773. // SetAccount sets the "account" field.
  9774. func (m *ContactMutation) SetAccount(s string) {
  9775. m.account = &s
  9776. }
  9777. // Account returns the value of the "account" field in the mutation.
  9778. func (m *ContactMutation) Account() (r string, exists bool) {
  9779. v := m.account
  9780. if v == nil {
  9781. return
  9782. }
  9783. return *v, true
  9784. }
  9785. // OldAccount returns the old "account" field's value of the Contact entity.
  9786. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9788. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  9789. if !m.op.Is(OpUpdateOne) {
  9790. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  9791. }
  9792. if m.id == nil || m.oldValue == nil {
  9793. return v, errors.New("OldAccount requires an ID field in the mutation")
  9794. }
  9795. oldValue, err := m.oldValue(ctx)
  9796. if err != nil {
  9797. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  9798. }
  9799. return oldValue.Account, nil
  9800. }
  9801. // ResetAccount resets all changes to the "account" field.
  9802. func (m *ContactMutation) ResetAccount() {
  9803. m.account = nil
  9804. }
  9805. // SetNickname sets the "nickname" field.
  9806. func (m *ContactMutation) SetNickname(s string) {
  9807. m.nickname = &s
  9808. }
  9809. // Nickname returns the value of the "nickname" field in the mutation.
  9810. func (m *ContactMutation) Nickname() (r string, exists bool) {
  9811. v := m.nickname
  9812. if v == nil {
  9813. return
  9814. }
  9815. return *v, true
  9816. }
  9817. // OldNickname returns the old "nickname" field's value of the Contact entity.
  9818. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9820. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  9821. if !m.op.Is(OpUpdateOne) {
  9822. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  9823. }
  9824. if m.id == nil || m.oldValue == nil {
  9825. return v, errors.New("OldNickname requires an ID field in the mutation")
  9826. }
  9827. oldValue, err := m.oldValue(ctx)
  9828. if err != nil {
  9829. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  9830. }
  9831. return oldValue.Nickname, nil
  9832. }
  9833. // ResetNickname resets all changes to the "nickname" field.
  9834. func (m *ContactMutation) ResetNickname() {
  9835. m.nickname = nil
  9836. }
  9837. // SetMarkname sets the "markname" field.
  9838. func (m *ContactMutation) SetMarkname(s string) {
  9839. m.markname = &s
  9840. }
  9841. // Markname returns the value of the "markname" field in the mutation.
  9842. func (m *ContactMutation) Markname() (r string, exists bool) {
  9843. v := m.markname
  9844. if v == nil {
  9845. return
  9846. }
  9847. return *v, true
  9848. }
  9849. // OldMarkname returns the old "markname" field's value of the Contact entity.
  9850. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9852. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  9853. if !m.op.Is(OpUpdateOne) {
  9854. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  9855. }
  9856. if m.id == nil || m.oldValue == nil {
  9857. return v, errors.New("OldMarkname requires an ID field in the mutation")
  9858. }
  9859. oldValue, err := m.oldValue(ctx)
  9860. if err != nil {
  9861. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  9862. }
  9863. return oldValue.Markname, nil
  9864. }
  9865. // ResetMarkname resets all changes to the "markname" field.
  9866. func (m *ContactMutation) ResetMarkname() {
  9867. m.markname = nil
  9868. }
  9869. // SetHeadimg sets the "headimg" field.
  9870. func (m *ContactMutation) SetHeadimg(s string) {
  9871. m.headimg = &s
  9872. }
  9873. // Headimg returns the value of the "headimg" field in the mutation.
  9874. func (m *ContactMutation) Headimg() (r string, exists bool) {
  9875. v := m.headimg
  9876. if v == nil {
  9877. return
  9878. }
  9879. return *v, true
  9880. }
  9881. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  9882. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9884. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  9885. if !m.op.Is(OpUpdateOne) {
  9886. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  9887. }
  9888. if m.id == nil || m.oldValue == nil {
  9889. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  9890. }
  9891. oldValue, err := m.oldValue(ctx)
  9892. if err != nil {
  9893. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  9894. }
  9895. return oldValue.Headimg, nil
  9896. }
  9897. // ResetHeadimg resets all changes to the "headimg" field.
  9898. func (m *ContactMutation) ResetHeadimg() {
  9899. m.headimg = nil
  9900. }
  9901. // SetSex sets the "sex" field.
  9902. func (m *ContactMutation) SetSex(i int) {
  9903. m.sex = &i
  9904. m.addsex = nil
  9905. }
  9906. // Sex returns the value of the "sex" field in the mutation.
  9907. func (m *ContactMutation) Sex() (r int, exists bool) {
  9908. v := m.sex
  9909. if v == nil {
  9910. return
  9911. }
  9912. return *v, true
  9913. }
  9914. // OldSex returns the old "sex" field's value of the Contact entity.
  9915. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9917. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  9918. if !m.op.Is(OpUpdateOne) {
  9919. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  9920. }
  9921. if m.id == nil || m.oldValue == nil {
  9922. return v, errors.New("OldSex requires an ID field in the mutation")
  9923. }
  9924. oldValue, err := m.oldValue(ctx)
  9925. if err != nil {
  9926. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  9927. }
  9928. return oldValue.Sex, nil
  9929. }
  9930. // AddSex adds i to the "sex" field.
  9931. func (m *ContactMutation) AddSex(i int) {
  9932. if m.addsex != nil {
  9933. *m.addsex += i
  9934. } else {
  9935. m.addsex = &i
  9936. }
  9937. }
  9938. // AddedSex returns the value that was added to the "sex" field in this mutation.
  9939. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  9940. v := m.addsex
  9941. if v == nil {
  9942. return
  9943. }
  9944. return *v, true
  9945. }
  9946. // ResetSex resets all changes to the "sex" field.
  9947. func (m *ContactMutation) ResetSex() {
  9948. m.sex = nil
  9949. m.addsex = nil
  9950. }
  9951. // SetStarrole sets the "starrole" field.
  9952. func (m *ContactMutation) SetStarrole(s string) {
  9953. m.starrole = &s
  9954. }
  9955. // Starrole returns the value of the "starrole" field in the mutation.
  9956. func (m *ContactMutation) Starrole() (r string, exists bool) {
  9957. v := m.starrole
  9958. if v == nil {
  9959. return
  9960. }
  9961. return *v, true
  9962. }
  9963. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  9964. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9966. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  9967. if !m.op.Is(OpUpdateOne) {
  9968. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  9969. }
  9970. if m.id == nil || m.oldValue == nil {
  9971. return v, errors.New("OldStarrole requires an ID field in the mutation")
  9972. }
  9973. oldValue, err := m.oldValue(ctx)
  9974. if err != nil {
  9975. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  9976. }
  9977. return oldValue.Starrole, nil
  9978. }
  9979. // ResetStarrole resets all changes to the "starrole" field.
  9980. func (m *ContactMutation) ResetStarrole() {
  9981. m.starrole = nil
  9982. }
  9983. // SetDontseeit sets the "dontseeit" field.
  9984. func (m *ContactMutation) SetDontseeit(i int) {
  9985. m.dontseeit = &i
  9986. m.adddontseeit = nil
  9987. }
  9988. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  9989. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  9990. v := m.dontseeit
  9991. if v == nil {
  9992. return
  9993. }
  9994. return *v, true
  9995. }
  9996. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  9997. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9999. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  10000. if !m.op.Is(OpUpdateOne) {
  10001. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  10002. }
  10003. if m.id == nil || m.oldValue == nil {
  10004. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  10005. }
  10006. oldValue, err := m.oldValue(ctx)
  10007. if err != nil {
  10008. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  10009. }
  10010. return oldValue.Dontseeit, nil
  10011. }
  10012. // AddDontseeit adds i to the "dontseeit" field.
  10013. func (m *ContactMutation) AddDontseeit(i int) {
  10014. if m.adddontseeit != nil {
  10015. *m.adddontseeit += i
  10016. } else {
  10017. m.adddontseeit = &i
  10018. }
  10019. }
  10020. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  10021. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  10022. v := m.adddontseeit
  10023. if v == nil {
  10024. return
  10025. }
  10026. return *v, true
  10027. }
  10028. // ResetDontseeit resets all changes to the "dontseeit" field.
  10029. func (m *ContactMutation) ResetDontseeit() {
  10030. m.dontseeit = nil
  10031. m.adddontseeit = nil
  10032. }
  10033. // SetDontseeme sets the "dontseeme" field.
  10034. func (m *ContactMutation) SetDontseeme(i int) {
  10035. m.dontseeme = &i
  10036. m.adddontseeme = nil
  10037. }
  10038. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  10039. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  10040. v := m.dontseeme
  10041. if v == nil {
  10042. return
  10043. }
  10044. return *v, true
  10045. }
  10046. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  10047. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10049. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  10050. if !m.op.Is(OpUpdateOne) {
  10051. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  10052. }
  10053. if m.id == nil || m.oldValue == nil {
  10054. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  10055. }
  10056. oldValue, err := m.oldValue(ctx)
  10057. if err != nil {
  10058. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  10059. }
  10060. return oldValue.Dontseeme, nil
  10061. }
  10062. // AddDontseeme adds i to the "dontseeme" field.
  10063. func (m *ContactMutation) AddDontseeme(i int) {
  10064. if m.adddontseeme != nil {
  10065. *m.adddontseeme += i
  10066. } else {
  10067. m.adddontseeme = &i
  10068. }
  10069. }
  10070. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  10071. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  10072. v := m.adddontseeme
  10073. if v == nil {
  10074. return
  10075. }
  10076. return *v, true
  10077. }
  10078. // ResetDontseeme resets all changes to the "dontseeme" field.
  10079. func (m *ContactMutation) ResetDontseeme() {
  10080. m.dontseeme = nil
  10081. m.adddontseeme = nil
  10082. }
  10083. // SetLag sets the "lag" field.
  10084. func (m *ContactMutation) SetLag(s string) {
  10085. m.lag = &s
  10086. }
  10087. // Lag returns the value of the "lag" field in the mutation.
  10088. func (m *ContactMutation) Lag() (r string, exists bool) {
  10089. v := m.lag
  10090. if v == nil {
  10091. return
  10092. }
  10093. return *v, true
  10094. }
  10095. // OldLag returns the old "lag" field's value of the Contact entity.
  10096. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10098. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  10099. if !m.op.Is(OpUpdateOne) {
  10100. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  10101. }
  10102. if m.id == nil || m.oldValue == nil {
  10103. return v, errors.New("OldLag requires an ID field in the mutation")
  10104. }
  10105. oldValue, err := m.oldValue(ctx)
  10106. if err != nil {
  10107. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  10108. }
  10109. return oldValue.Lag, nil
  10110. }
  10111. // ResetLag resets all changes to the "lag" field.
  10112. func (m *ContactMutation) ResetLag() {
  10113. m.lag = nil
  10114. }
  10115. // SetGid sets the "gid" field.
  10116. func (m *ContactMutation) SetGid(s string) {
  10117. m.gid = &s
  10118. }
  10119. // Gid returns the value of the "gid" field in the mutation.
  10120. func (m *ContactMutation) Gid() (r string, exists bool) {
  10121. v := m.gid
  10122. if v == nil {
  10123. return
  10124. }
  10125. return *v, true
  10126. }
  10127. // OldGid returns the old "gid" field's value of the Contact entity.
  10128. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10130. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  10131. if !m.op.Is(OpUpdateOne) {
  10132. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  10133. }
  10134. if m.id == nil || m.oldValue == nil {
  10135. return v, errors.New("OldGid requires an ID field in the mutation")
  10136. }
  10137. oldValue, err := m.oldValue(ctx)
  10138. if err != nil {
  10139. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  10140. }
  10141. return oldValue.Gid, nil
  10142. }
  10143. // ResetGid resets all changes to the "gid" field.
  10144. func (m *ContactMutation) ResetGid() {
  10145. m.gid = nil
  10146. }
  10147. // SetGname sets the "gname" field.
  10148. func (m *ContactMutation) SetGname(s string) {
  10149. m.gname = &s
  10150. }
  10151. // Gname returns the value of the "gname" field in the mutation.
  10152. func (m *ContactMutation) Gname() (r string, exists bool) {
  10153. v := m.gname
  10154. if v == nil {
  10155. return
  10156. }
  10157. return *v, true
  10158. }
  10159. // OldGname returns the old "gname" field's value of the Contact entity.
  10160. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10162. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  10163. if !m.op.Is(OpUpdateOne) {
  10164. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  10165. }
  10166. if m.id == nil || m.oldValue == nil {
  10167. return v, errors.New("OldGname requires an ID field in the mutation")
  10168. }
  10169. oldValue, err := m.oldValue(ctx)
  10170. if err != nil {
  10171. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  10172. }
  10173. return oldValue.Gname, nil
  10174. }
  10175. // ResetGname resets all changes to the "gname" field.
  10176. func (m *ContactMutation) ResetGname() {
  10177. m.gname = nil
  10178. }
  10179. // SetV3 sets the "v3" field.
  10180. func (m *ContactMutation) SetV3(s string) {
  10181. m.v3 = &s
  10182. }
  10183. // V3 returns the value of the "v3" field in the mutation.
  10184. func (m *ContactMutation) V3() (r string, exists bool) {
  10185. v := m.v3
  10186. if v == nil {
  10187. return
  10188. }
  10189. return *v, true
  10190. }
  10191. // OldV3 returns the old "v3" field's value of the Contact entity.
  10192. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10194. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  10195. if !m.op.Is(OpUpdateOne) {
  10196. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  10197. }
  10198. if m.id == nil || m.oldValue == nil {
  10199. return v, errors.New("OldV3 requires an ID field in the mutation")
  10200. }
  10201. oldValue, err := m.oldValue(ctx)
  10202. if err != nil {
  10203. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  10204. }
  10205. return oldValue.V3, nil
  10206. }
  10207. // ResetV3 resets all changes to the "v3" field.
  10208. func (m *ContactMutation) ResetV3() {
  10209. m.v3 = nil
  10210. }
  10211. // SetOrganizationID sets the "organization_id" field.
  10212. func (m *ContactMutation) SetOrganizationID(u uint64) {
  10213. m.organization_id = &u
  10214. m.addorganization_id = nil
  10215. }
  10216. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10217. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  10218. v := m.organization_id
  10219. if v == nil {
  10220. return
  10221. }
  10222. return *v, true
  10223. }
  10224. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  10225. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10227. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10228. if !m.op.Is(OpUpdateOne) {
  10229. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10230. }
  10231. if m.id == nil || m.oldValue == nil {
  10232. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10233. }
  10234. oldValue, err := m.oldValue(ctx)
  10235. if err != nil {
  10236. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10237. }
  10238. return oldValue.OrganizationID, nil
  10239. }
  10240. // AddOrganizationID adds u to the "organization_id" field.
  10241. func (m *ContactMutation) AddOrganizationID(u int64) {
  10242. if m.addorganization_id != nil {
  10243. *m.addorganization_id += u
  10244. } else {
  10245. m.addorganization_id = &u
  10246. }
  10247. }
  10248. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10249. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  10250. v := m.addorganization_id
  10251. if v == nil {
  10252. return
  10253. }
  10254. return *v, true
  10255. }
  10256. // ClearOrganizationID clears the value of the "organization_id" field.
  10257. func (m *ContactMutation) ClearOrganizationID() {
  10258. m.organization_id = nil
  10259. m.addorganization_id = nil
  10260. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  10261. }
  10262. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10263. func (m *ContactMutation) OrganizationIDCleared() bool {
  10264. _, ok := m.clearedFields[contact.FieldOrganizationID]
  10265. return ok
  10266. }
  10267. // ResetOrganizationID resets all changes to the "organization_id" field.
  10268. func (m *ContactMutation) ResetOrganizationID() {
  10269. m.organization_id = nil
  10270. m.addorganization_id = nil
  10271. delete(m.clearedFields, contact.FieldOrganizationID)
  10272. }
  10273. // SetCtype sets the "ctype" field.
  10274. func (m *ContactMutation) SetCtype(u uint64) {
  10275. m.ctype = &u
  10276. m.addctype = nil
  10277. }
  10278. // Ctype returns the value of the "ctype" field in the mutation.
  10279. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  10280. v := m.ctype
  10281. if v == nil {
  10282. return
  10283. }
  10284. return *v, true
  10285. }
  10286. // OldCtype returns the old "ctype" field's value of the Contact entity.
  10287. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10289. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  10290. if !m.op.Is(OpUpdateOne) {
  10291. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  10292. }
  10293. if m.id == nil || m.oldValue == nil {
  10294. return v, errors.New("OldCtype requires an ID field in the mutation")
  10295. }
  10296. oldValue, err := m.oldValue(ctx)
  10297. if err != nil {
  10298. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  10299. }
  10300. return oldValue.Ctype, nil
  10301. }
  10302. // AddCtype adds u to the "ctype" field.
  10303. func (m *ContactMutation) AddCtype(u int64) {
  10304. if m.addctype != nil {
  10305. *m.addctype += u
  10306. } else {
  10307. m.addctype = &u
  10308. }
  10309. }
  10310. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  10311. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  10312. v := m.addctype
  10313. if v == nil {
  10314. return
  10315. }
  10316. return *v, true
  10317. }
  10318. // ResetCtype resets all changes to the "ctype" field.
  10319. func (m *ContactMutation) ResetCtype() {
  10320. m.ctype = nil
  10321. m.addctype = nil
  10322. }
  10323. // SetCage sets the "cage" field.
  10324. func (m *ContactMutation) SetCage(i int) {
  10325. m.cage = &i
  10326. m.addcage = nil
  10327. }
  10328. // Cage returns the value of the "cage" field in the mutation.
  10329. func (m *ContactMutation) Cage() (r int, exists bool) {
  10330. v := m.cage
  10331. if v == nil {
  10332. return
  10333. }
  10334. return *v, true
  10335. }
  10336. // OldCage returns the old "cage" field's value of the Contact entity.
  10337. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10339. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  10340. if !m.op.Is(OpUpdateOne) {
  10341. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  10342. }
  10343. if m.id == nil || m.oldValue == nil {
  10344. return v, errors.New("OldCage requires an ID field in the mutation")
  10345. }
  10346. oldValue, err := m.oldValue(ctx)
  10347. if err != nil {
  10348. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  10349. }
  10350. return oldValue.Cage, nil
  10351. }
  10352. // AddCage adds i to the "cage" field.
  10353. func (m *ContactMutation) AddCage(i int) {
  10354. if m.addcage != nil {
  10355. *m.addcage += i
  10356. } else {
  10357. m.addcage = &i
  10358. }
  10359. }
  10360. // AddedCage returns the value that was added to the "cage" field in this mutation.
  10361. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  10362. v := m.addcage
  10363. if v == nil {
  10364. return
  10365. }
  10366. return *v, true
  10367. }
  10368. // ResetCage resets all changes to the "cage" field.
  10369. func (m *ContactMutation) ResetCage() {
  10370. m.cage = nil
  10371. m.addcage = nil
  10372. }
  10373. // SetCname sets the "cname" field.
  10374. func (m *ContactMutation) SetCname(s string) {
  10375. m.cname = &s
  10376. }
  10377. // Cname returns the value of the "cname" field in the mutation.
  10378. func (m *ContactMutation) Cname() (r string, exists bool) {
  10379. v := m.cname
  10380. if v == nil {
  10381. return
  10382. }
  10383. return *v, true
  10384. }
  10385. // OldCname returns the old "cname" field's value of the Contact entity.
  10386. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10388. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  10389. if !m.op.Is(OpUpdateOne) {
  10390. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  10391. }
  10392. if m.id == nil || m.oldValue == nil {
  10393. return v, errors.New("OldCname requires an ID field in the mutation")
  10394. }
  10395. oldValue, err := m.oldValue(ctx)
  10396. if err != nil {
  10397. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  10398. }
  10399. return oldValue.Cname, nil
  10400. }
  10401. // ResetCname resets all changes to the "cname" field.
  10402. func (m *ContactMutation) ResetCname() {
  10403. m.cname = nil
  10404. }
  10405. // SetCarea sets the "carea" field.
  10406. func (m *ContactMutation) SetCarea(s string) {
  10407. m.carea = &s
  10408. }
  10409. // Carea returns the value of the "carea" field in the mutation.
  10410. func (m *ContactMutation) Carea() (r string, exists bool) {
  10411. v := m.carea
  10412. if v == nil {
  10413. return
  10414. }
  10415. return *v, true
  10416. }
  10417. // OldCarea returns the old "carea" field's value of the Contact entity.
  10418. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10420. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  10421. if !m.op.Is(OpUpdateOne) {
  10422. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  10423. }
  10424. if m.id == nil || m.oldValue == nil {
  10425. return v, errors.New("OldCarea requires an ID field in the mutation")
  10426. }
  10427. oldValue, err := m.oldValue(ctx)
  10428. if err != nil {
  10429. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  10430. }
  10431. return oldValue.Carea, nil
  10432. }
  10433. // ResetCarea resets all changes to the "carea" field.
  10434. func (m *ContactMutation) ResetCarea() {
  10435. m.carea = nil
  10436. }
  10437. // SetCbirthday sets the "cbirthday" field.
  10438. func (m *ContactMutation) SetCbirthday(s string) {
  10439. m.cbirthday = &s
  10440. }
  10441. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  10442. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  10443. v := m.cbirthday
  10444. if v == nil {
  10445. return
  10446. }
  10447. return *v, true
  10448. }
  10449. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  10450. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10452. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  10453. if !m.op.Is(OpUpdateOne) {
  10454. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  10455. }
  10456. if m.id == nil || m.oldValue == nil {
  10457. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  10458. }
  10459. oldValue, err := m.oldValue(ctx)
  10460. if err != nil {
  10461. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  10462. }
  10463. return oldValue.Cbirthday, nil
  10464. }
  10465. // ResetCbirthday resets all changes to the "cbirthday" field.
  10466. func (m *ContactMutation) ResetCbirthday() {
  10467. m.cbirthday = nil
  10468. }
  10469. // SetCbirtharea sets the "cbirtharea" field.
  10470. func (m *ContactMutation) SetCbirtharea(s string) {
  10471. m.cbirtharea = &s
  10472. }
  10473. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  10474. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  10475. v := m.cbirtharea
  10476. if v == nil {
  10477. return
  10478. }
  10479. return *v, true
  10480. }
  10481. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  10482. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10484. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  10485. if !m.op.Is(OpUpdateOne) {
  10486. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  10487. }
  10488. if m.id == nil || m.oldValue == nil {
  10489. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  10490. }
  10491. oldValue, err := m.oldValue(ctx)
  10492. if err != nil {
  10493. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  10494. }
  10495. return oldValue.Cbirtharea, nil
  10496. }
  10497. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  10498. func (m *ContactMutation) ResetCbirtharea() {
  10499. m.cbirtharea = nil
  10500. }
  10501. // SetCidcardNo sets the "cidcard_no" field.
  10502. func (m *ContactMutation) SetCidcardNo(s string) {
  10503. m.cidcard_no = &s
  10504. }
  10505. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  10506. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  10507. v := m.cidcard_no
  10508. if v == nil {
  10509. return
  10510. }
  10511. return *v, true
  10512. }
  10513. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  10514. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10516. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  10517. if !m.op.Is(OpUpdateOne) {
  10518. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  10519. }
  10520. if m.id == nil || m.oldValue == nil {
  10521. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  10522. }
  10523. oldValue, err := m.oldValue(ctx)
  10524. if err != nil {
  10525. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  10526. }
  10527. return oldValue.CidcardNo, nil
  10528. }
  10529. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  10530. func (m *ContactMutation) ResetCidcardNo() {
  10531. m.cidcard_no = nil
  10532. }
  10533. // SetCtitle sets the "ctitle" field.
  10534. func (m *ContactMutation) SetCtitle(s string) {
  10535. m.ctitle = &s
  10536. }
  10537. // Ctitle returns the value of the "ctitle" field in the mutation.
  10538. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  10539. v := m.ctitle
  10540. if v == nil {
  10541. return
  10542. }
  10543. return *v, true
  10544. }
  10545. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  10546. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10548. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  10549. if !m.op.Is(OpUpdateOne) {
  10550. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  10551. }
  10552. if m.id == nil || m.oldValue == nil {
  10553. return v, errors.New("OldCtitle requires an ID field in the mutation")
  10554. }
  10555. oldValue, err := m.oldValue(ctx)
  10556. if err != nil {
  10557. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  10558. }
  10559. return oldValue.Ctitle, nil
  10560. }
  10561. // ResetCtitle resets all changes to the "ctitle" field.
  10562. func (m *ContactMutation) ResetCtitle() {
  10563. m.ctitle = nil
  10564. }
  10565. // SetCc sets the "cc" field.
  10566. func (m *ContactMutation) SetCc(s string) {
  10567. m.cc = &s
  10568. }
  10569. // Cc returns the value of the "cc" field in the mutation.
  10570. func (m *ContactMutation) Cc() (r string, exists bool) {
  10571. v := m.cc
  10572. if v == nil {
  10573. return
  10574. }
  10575. return *v, true
  10576. }
  10577. // OldCc returns the old "cc" field's value of the Contact entity.
  10578. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10580. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  10581. if !m.op.Is(OpUpdateOne) {
  10582. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  10583. }
  10584. if m.id == nil || m.oldValue == nil {
  10585. return v, errors.New("OldCc requires an ID field in the mutation")
  10586. }
  10587. oldValue, err := m.oldValue(ctx)
  10588. if err != nil {
  10589. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  10590. }
  10591. return oldValue.Cc, nil
  10592. }
  10593. // ResetCc resets all changes to the "cc" field.
  10594. func (m *ContactMutation) ResetCc() {
  10595. m.cc = nil
  10596. }
  10597. // SetPhone sets the "phone" field.
  10598. func (m *ContactMutation) SetPhone(s string) {
  10599. m.phone = &s
  10600. }
  10601. // Phone returns the value of the "phone" field in the mutation.
  10602. func (m *ContactMutation) Phone() (r string, exists bool) {
  10603. v := m.phone
  10604. if v == nil {
  10605. return
  10606. }
  10607. return *v, true
  10608. }
  10609. // OldPhone returns the old "phone" field's value of the Contact entity.
  10610. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10612. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  10613. if !m.op.Is(OpUpdateOne) {
  10614. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  10615. }
  10616. if m.id == nil || m.oldValue == nil {
  10617. return v, errors.New("OldPhone requires an ID field in the mutation")
  10618. }
  10619. oldValue, err := m.oldValue(ctx)
  10620. if err != nil {
  10621. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  10622. }
  10623. return oldValue.Phone, nil
  10624. }
  10625. // ResetPhone resets all changes to the "phone" field.
  10626. func (m *ContactMutation) ResetPhone() {
  10627. m.phone = nil
  10628. }
  10629. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  10630. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  10631. if m.contact_relationships == nil {
  10632. m.contact_relationships = make(map[uint64]struct{})
  10633. }
  10634. for i := range ids {
  10635. m.contact_relationships[ids[i]] = struct{}{}
  10636. }
  10637. }
  10638. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  10639. func (m *ContactMutation) ClearContactRelationships() {
  10640. m.clearedcontact_relationships = true
  10641. }
  10642. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  10643. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  10644. return m.clearedcontact_relationships
  10645. }
  10646. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  10647. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  10648. if m.removedcontact_relationships == nil {
  10649. m.removedcontact_relationships = make(map[uint64]struct{})
  10650. }
  10651. for i := range ids {
  10652. delete(m.contact_relationships, ids[i])
  10653. m.removedcontact_relationships[ids[i]] = struct{}{}
  10654. }
  10655. }
  10656. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  10657. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  10658. for id := range m.removedcontact_relationships {
  10659. ids = append(ids, id)
  10660. }
  10661. return
  10662. }
  10663. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  10664. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  10665. for id := range m.contact_relationships {
  10666. ids = append(ids, id)
  10667. }
  10668. return
  10669. }
  10670. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  10671. func (m *ContactMutation) ResetContactRelationships() {
  10672. m.contact_relationships = nil
  10673. m.clearedcontact_relationships = false
  10674. m.removedcontact_relationships = nil
  10675. }
  10676. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  10677. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  10678. if m.contact_messages == nil {
  10679. m.contact_messages = make(map[uint64]struct{})
  10680. }
  10681. for i := range ids {
  10682. m.contact_messages[ids[i]] = struct{}{}
  10683. }
  10684. }
  10685. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  10686. func (m *ContactMutation) ClearContactMessages() {
  10687. m.clearedcontact_messages = true
  10688. }
  10689. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  10690. func (m *ContactMutation) ContactMessagesCleared() bool {
  10691. return m.clearedcontact_messages
  10692. }
  10693. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  10694. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  10695. if m.removedcontact_messages == nil {
  10696. m.removedcontact_messages = make(map[uint64]struct{})
  10697. }
  10698. for i := range ids {
  10699. delete(m.contact_messages, ids[i])
  10700. m.removedcontact_messages[ids[i]] = struct{}{}
  10701. }
  10702. }
  10703. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  10704. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  10705. for id := range m.removedcontact_messages {
  10706. ids = append(ids, id)
  10707. }
  10708. return
  10709. }
  10710. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  10711. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  10712. for id := range m.contact_messages {
  10713. ids = append(ids, id)
  10714. }
  10715. return
  10716. }
  10717. // ResetContactMessages resets all changes to the "contact_messages" edge.
  10718. func (m *ContactMutation) ResetContactMessages() {
  10719. m.contact_messages = nil
  10720. m.clearedcontact_messages = false
  10721. m.removedcontact_messages = nil
  10722. }
  10723. // Where appends a list predicates to the ContactMutation builder.
  10724. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  10725. m.predicates = append(m.predicates, ps...)
  10726. }
  10727. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  10728. // users can use type-assertion to append predicates that do not depend on any generated package.
  10729. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  10730. p := make([]predicate.Contact, len(ps))
  10731. for i := range ps {
  10732. p[i] = ps[i]
  10733. }
  10734. m.Where(p...)
  10735. }
  10736. // Op returns the operation name.
  10737. func (m *ContactMutation) Op() Op {
  10738. return m.op
  10739. }
  10740. // SetOp allows setting the mutation operation.
  10741. func (m *ContactMutation) SetOp(op Op) {
  10742. m.op = op
  10743. }
  10744. // Type returns the node type of this mutation (Contact).
  10745. func (m *ContactMutation) Type() string {
  10746. return m.typ
  10747. }
  10748. // Fields returns all fields that were changed during this mutation. Note that in
  10749. // order to get all numeric fields that were incremented/decremented, call
  10750. // AddedFields().
  10751. func (m *ContactMutation) Fields() []string {
  10752. fields := make([]string, 0, 30)
  10753. if m.created_at != nil {
  10754. fields = append(fields, contact.FieldCreatedAt)
  10755. }
  10756. if m.updated_at != nil {
  10757. fields = append(fields, contact.FieldUpdatedAt)
  10758. }
  10759. if m.status != nil {
  10760. fields = append(fields, contact.FieldStatus)
  10761. }
  10762. if m.deleted_at != nil {
  10763. fields = append(fields, contact.FieldDeletedAt)
  10764. }
  10765. if m.wx_wxid != nil {
  10766. fields = append(fields, contact.FieldWxWxid)
  10767. }
  10768. if m._type != nil {
  10769. fields = append(fields, contact.FieldType)
  10770. }
  10771. if m.wxid != nil {
  10772. fields = append(fields, contact.FieldWxid)
  10773. }
  10774. if m.account != nil {
  10775. fields = append(fields, contact.FieldAccount)
  10776. }
  10777. if m.nickname != nil {
  10778. fields = append(fields, contact.FieldNickname)
  10779. }
  10780. if m.markname != nil {
  10781. fields = append(fields, contact.FieldMarkname)
  10782. }
  10783. if m.headimg != nil {
  10784. fields = append(fields, contact.FieldHeadimg)
  10785. }
  10786. if m.sex != nil {
  10787. fields = append(fields, contact.FieldSex)
  10788. }
  10789. if m.starrole != nil {
  10790. fields = append(fields, contact.FieldStarrole)
  10791. }
  10792. if m.dontseeit != nil {
  10793. fields = append(fields, contact.FieldDontseeit)
  10794. }
  10795. if m.dontseeme != nil {
  10796. fields = append(fields, contact.FieldDontseeme)
  10797. }
  10798. if m.lag != nil {
  10799. fields = append(fields, contact.FieldLag)
  10800. }
  10801. if m.gid != nil {
  10802. fields = append(fields, contact.FieldGid)
  10803. }
  10804. if m.gname != nil {
  10805. fields = append(fields, contact.FieldGname)
  10806. }
  10807. if m.v3 != nil {
  10808. fields = append(fields, contact.FieldV3)
  10809. }
  10810. if m.organization_id != nil {
  10811. fields = append(fields, contact.FieldOrganizationID)
  10812. }
  10813. if m.ctype != nil {
  10814. fields = append(fields, contact.FieldCtype)
  10815. }
  10816. if m.cage != nil {
  10817. fields = append(fields, contact.FieldCage)
  10818. }
  10819. if m.cname != nil {
  10820. fields = append(fields, contact.FieldCname)
  10821. }
  10822. if m.carea != nil {
  10823. fields = append(fields, contact.FieldCarea)
  10824. }
  10825. if m.cbirthday != nil {
  10826. fields = append(fields, contact.FieldCbirthday)
  10827. }
  10828. if m.cbirtharea != nil {
  10829. fields = append(fields, contact.FieldCbirtharea)
  10830. }
  10831. if m.cidcard_no != nil {
  10832. fields = append(fields, contact.FieldCidcardNo)
  10833. }
  10834. if m.ctitle != nil {
  10835. fields = append(fields, contact.FieldCtitle)
  10836. }
  10837. if m.cc != nil {
  10838. fields = append(fields, contact.FieldCc)
  10839. }
  10840. if m.phone != nil {
  10841. fields = append(fields, contact.FieldPhone)
  10842. }
  10843. return fields
  10844. }
  10845. // Field returns the value of a field with the given name. The second boolean
  10846. // return value indicates that this field was not set, or was not defined in the
  10847. // schema.
  10848. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  10849. switch name {
  10850. case contact.FieldCreatedAt:
  10851. return m.CreatedAt()
  10852. case contact.FieldUpdatedAt:
  10853. return m.UpdatedAt()
  10854. case contact.FieldStatus:
  10855. return m.Status()
  10856. case contact.FieldDeletedAt:
  10857. return m.DeletedAt()
  10858. case contact.FieldWxWxid:
  10859. return m.WxWxid()
  10860. case contact.FieldType:
  10861. return m.GetType()
  10862. case contact.FieldWxid:
  10863. return m.Wxid()
  10864. case contact.FieldAccount:
  10865. return m.Account()
  10866. case contact.FieldNickname:
  10867. return m.Nickname()
  10868. case contact.FieldMarkname:
  10869. return m.Markname()
  10870. case contact.FieldHeadimg:
  10871. return m.Headimg()
  10872. case contact.FieldSex:
  10873. return m.Sex()
  10874. case contact.FieldStarrole:
  10875. return m.Starrole()
  10876. case contact.FieldDontseeit:
  10877. return m.Dontseeit()
  10878. case contact.FieldDontseeme:
  10879. return m.Dontseeme()
  10880. case contact.FieldLag:
  10881. return m.Lag()
  10882. case contact.FieldGid:
  10883. return m.Gid()
  10884. case contact.FieldGname:
  10885. return m.Gname()
  10886. case contact.FieldV3:
  10887. return m.V3()
  10888. case contact.FieldOrganizationID:
  10889. return m.OrganizationID()
  10890. case contact.FieldCtype:
  10891. return m.Ctype()
  10892. case contact.FieldCage:
  10893. return m.Cage()
  10894. case contact.FieldCname:
  10895. return m.Cname()
  10896. case contact.FieldCarea:
  10897. return m.Carea()
  10898. case contact.FieldCbirthday:
  10899. return m.Cbirthday()
  10900. case contact.FieldCbirtharea:
  10901. return m.Cbirtharea()
  10902. case contact.FieldCidcardNo:
  10903. return m.CidcardNo()
  10904. case contact.FieldCtitle:
  10905. return m.Ctitle()
  10906. case contact.FieldCc:
  10907. return m.Cc()
  10908. case contact.FieldPhone:
  10909. return m.Phone()
  10910. }
  10911. return nil, false
  10912. }
  10913. // OldField returns the old value of the field from the database. An error is
  10914. // returned if the mutation operation is not UpdateOne, or the query to the
  10915. // database failed.
  10916. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10917. switch name {
  10918. case contact.FieldCreatedAt:
  10919. return m.OldCreatedAt(ctx)
  10920. case contact.FieldUpdatedAt:
  10921. return m.OldUpdatedAt(ctx)
  10922. case contact.FieldStatus:
  10923. return m.OldStatus(ctx)
  10924. case contact.FieldDeletedAt:
  10925. return m.OldDeletedAt(ctx)
  10926. case contact.FieldWxWxid:
  10927. return m.OldWxWxid(ctx)
  10928. case contact.FieldType:
  10929. return m.OldType(ctx)
  10930. case contact.FieldWxid:
  10931. return m.OldWxid(ctx)
  10932. case contact.FieldAccount:
  10933. return m.OldAccount(ctx)
  10934. case contact.FieldNickname:
  10935. return m.OldNickname(ctx)
  10936. case contact.FieldMarkname:
  10937. return m.OldMarkname(ctx)
  10938. case contact.FieldHeadimg:
  10939. return m.OldHeadimg(ctx)
  10940. case contact.FieldSex:
  10941. return m.OldSex(ctx)
  10942. case contact.FieldStarrole:
  10943. return m.OldStarrole(ctx)
  10944. case contact.FieldDontseeit:
  10945. return m.OldDontseeit(ctx)
  10946. case contact.FieldDontseeme:
  10947. return m.OldDontseeme(ctx)
  10948. case contact.FieldLag:
  10949. return m.OldLag(ctx)
  10950. case contact.FieldGid:
  10951. return m.OldGid(ctx)
  10952. case contact.FieldGname:
  10953. return m.OldGname(ctx)
  10954. case contact.FieldV3:
  10955. return m.OldV3(ctx)
  10956. case contact.FieldOrganizationID:
  10957. return m.OldOrganizationID(ctx)
  10958. case contact.FieldCtype:
  10959. return m.OldCtype(ctx)
  10960. case contact.FieldCage:
  10961. return m.OldCage(ctx)
  10962. case contact.FieldCname:
  10963. return m.OldCname(ctx)
  10964. case contact.FieldCarea:
  10965. return m.OldCarea(ctx)
  10966. case contact.FieldCbirthday:
  10967. return m.OldCbirthday(ctx)
  10968. case contact.FieldCbirtharea:
  10969. return m.OldCbirtharea(ctx)
  10970. case contact.FieldCidcardNo:
  10971. return m.OldCidcardNo(ctx)
  10972. case contact.FieldCtitle:
  10973. return m.OldCtitle(ctx)
  10974. case contact.FieldCc:
  10975. return m.OldCc(ctx)
  10976. case contact.FieldPhone:
  10977. return m.OldPhone(ctx)
  10978. }
  10979. return nil, fmt.Errorf("unknown Contact field %s", name)
  10980. }
  10981. // SetField sets the value of a field with the given name. It returns an error if
  10982. // the field is not defined in the schema, or if the type mismatched the field
  10983. // type.
  10984. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  10985. switch name {
  10986. case contact.FieldCreatedAt:
  10987. v, ok := value.(time.Time)
  10988. if !ok {
  10989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10990. }
  10991. m.SetCreatedAt(v)
  10992. return nil
  10993. case contact.FieldUpdatedAt:
  10994. v, ok := value.(time.Time)
  10995. if !ok {
  10996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10997. }
  10998. m.SetUpdatedAt(v)
  10999. return nil
  11000. case contact.FieldStatus:
  11001. v, ok := value.(uint8)
  11002. if !ok {
  11003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11004. }
  11005. m.SetStatus(v)
  11006. return nil
  11007. case contact.FieldDeletedAt:
  11008. v, ok := value.(time.Time)
  11009. if !ok {
  11010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11011. }
  11012. m.SetDeletedAt(v)
  11013. return nil
  11014. case contact.FieldWxWxid:
  11015. v, ok := value.(string)
  11016. if !ok {
  11017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11018. }
  11019. m.SetWxWxid(v)
  11020. return nil
  11021. case contact.FieldType:
  11022. v, ok := value.(int)
  11023. if !ok {
  11024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11025. }
  11026. m.SetType(v)
  11027. return nil
  11028. case contact.FieldWxid:
  11029. v, ok := value.(string)
  11030. if !ok {
  11031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11032. }
  11033. m.SetWxid(v)
  11034. return nil
  11035. case contact.FieldAccount:
  11036. v, ok := value.(string)
  11037. if !ok {
  11038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11039. }
  11040. m.SetAccount(v)
  11041. return nil
  11042. case contact.FieldNickname:
  11043. v, ok := value.(string)
  11044. if !ok {
  11045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11046. }
  11047. m.SetNickname(v)
  11048. return nil
  11049. case contact.FieldMarkname:
  11050. v, ok := value.(string)
  11051. if !ok {
  11052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11053. }
  11054. m.SetMarkname(v)
  11055. return nil
  11056. case contact.FieldHeadimg:
  11057. v, ok := value.(string)
  11058. if !ok {
  11059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11060. }
  11061. m.SetHeadimg(v)
  11062. return nil
  11063. case contact.FieldSex:
  11064. v, ok := value.(int)
  11065. if !ok {
  11066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11067. }
  11068. m.SetSex(v)
  11069. return nil
  11070. case contact.FieldStarrole:
  11071. v, ok := value.(string)
  11072. if !ok {
  11073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11074. }
  11075. m.SetStarrole(v)
  11076. return nil
  11077. case contact.FieldDontseeit:
  11078. v, ok := value.(int)
  11079. if !ok {
  11080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11081. }
  11082. m.SetDontseeit(v)
  11083. return nil
  11084. case contact.FieldDontseeme:
  11085. v, ok := value.(int)
  11086. if !ok {
  11087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11088. }
  11089. m.SetDontseeme(v)
  11090. return nil
  11091. case contact.FieldLag:
  11092. v, ok := value.(string)
  11093. if !ok {
  11094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11095. }
  11096. m.SetLag(v)
  11097. return nil
  11098. case contact.FieldGid:
  11099. v, ok := value.(string)
  11100. if !ok {
  11101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11102. }
  11103. m.SetGid(v)
  11104. return nil
  11105. case contact.FieldGname:
  11106. v, ok := value.(string)
  11107. if !ok {
  11108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11109. }
  11110. m.SetGname(v)
  11111. return nil
  11112. case contact.FieldV3:
  11113. v, ok := value.(string)
  11114. if !ok {
  11115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11116. }
  11117. m.SetV3(v)
  11118. return nil
  11119. case contact.FieldOrganizationID:
  11120. v, ok := value.(uint64)
  11121. if !ok {
  11122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11123. }
  11124. m.SetOrganizationID(v)
  11125. return nil
  11126. case contact.FieldCtype:
  11127. v, ok := value.(uint64)
  11128. if !ok {
  11129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11130. }
  11131. m.SetCtype(v)
  11132. return nil
  11133. case contact.FieldCage:
  11134. v, ok := value.(int)
  11135. if !ok {
  11136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11137. }
  11138. m.SetCage(v)
  11139. return nil
  11140. case contact.FieldCname:
  11141. v, ok := value.(string)
  11142. if !ok {
  11143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11144. }
  11145. m.SetCname(v)
  11146. return nil
  11147. case contact.FieldCarea:
  11148. v, ok := value.(string)
  11149. if !ok {
  11150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11151. }
  11152. m.SetCarea(v)
  11153. return nil
  11154. case contact.FieldCbirthday:
  11155. v, ok := value.(string)
  11156. if !ok {
  11157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11158. }
  11159. m.SetCbirthday(v)
  11160. return nil
  11161. case contact.FieldCbirtharea:
  11162. v, ok := value.(string)
  11163. if !ok {
  11164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11165. }
  11166. m.SetCbirtharea(v)
  11167. return nil
  11168. case contact.FieldCidcardNo:
  11169. v, ok := value.(string)
  11170. if !ok {
  11171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11172. }
  11173. m.SetCidcardNo(v)
  11174. return nil
  11175. case contact.FieldCtitle:
  11176. v, ok := value.(string)
  11177. if !ok {
  11178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11179. }
  11180. m.SetCtitle(v)
  11181. return nil
  11182. case contact.FieldCc:
  11183. v, ok := value.(string)
  11184. if !ok {
  11185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11186. }
  11187. m.SetCc(v)
  11188. return nil
  11189. case contact.FieldPhone:
  11190. v, ok := value.(string)
  11191. if !ok {
  11192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11193. }
  11194. m.SetPhone(v)
  11195. return nil
  11196. }
  11197. return fmt.Errorf("unknown Contact field %s", name)
  11198. }
  11199. // AddedFields returns all numeric fields that were incremented/decremented during
  11200. // this mutation.
  11201. func (m *ContactMutation) AddedFields() []string {
  11202. var fields []string
  11203. if m.addstatus != nil {
  11204. fields = append(fields, contact.FieldStatus)
  11205. }
  11206. if m.add_type != nil {
  11207. fields = append(fields, contact.FieldType)
  11208. }
  11209. if m.addsex != nil {
  11210. fields = append(fields, contact.FieldSex)
  11211. }
  11212. if m.adddontseeit != nil {
  11213. fields = append(fields, contact.FieldDontseeit)
  11214. }
  11215. if m.adddontseeme != nil {
  11216. fields = append(fields, contact.FieldDontseeme)
  11217. }
  11218. if m.addorganization_id != nil {
  11219. fields = append(fields, contact.FieldOrganizationID)
  11220. }
  11221. if m.addctype != nil {
  11222. fields = append(fields, contact.FieldCtype)
  11223. }
  11224. if m.addcage != nil {
  11225. fields = append(fields, contact.FieldCage)
  11226. }
  11227. return fields
  11228. }
  11229. // AddedField returns the numeric value that was incremented/decremented on a field
  11230. // with the given name. The second boolean return value indicates that this field
  11231. // was not set, or was not defined in the schema.
  11232. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  11233. switch name {
  11234. case contact.FieldStatus:
  11235. return m.AddedStatus()
  11236. case contact.FieldType:
  11237. return m.AddedType()
  11238. case contact.FieldSex:
  11239. return m.AddedSex()
  11240. case contact.FieldDontseeit:
  11241. return m.AddedDontseeit()
  11242. case contact.FieldDontseeme:
  11243. return m.AddedDontseeme()
  11244. case contact.FieldOrganizationID:
  11245. return m.AddedOrganizationID()
  11246. case contact.FieldCtype:
  11247. return m.AddedCtype()
  11248. case contact.FieldCage:
  11249. return m.AddedCage()
  11250. }
  11251. return nil, false
  11252. }
  11253. // AddField adds the value to the field with the given name. It returns an error if
  11254. // the field is not defined in the schema, or if the type mismatched the field
  11255. // type.
  11256. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  11257. switch name {
  11258. case contact.FieldStatus:
  11259. v, ok := value.(int8)
  11260. if !ok {
  11261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11262. }
  11263. m.AddStatus(v)
  11264. return nil
  11265. case contact.FieldType:
  11266. v, ok := value.(int)
  11267. if !ok {
  11268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11269. }
  11270. m.AddType(v)
  11271. return nil
  11272. case contact.FieldSex:
  11273. v, ok := value.(int)
  11274. if !ok {
  11275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11276. }
  11277. m.AddSex(v)
  11278. return nil
  11279. case contact.FieldDontseeit:
  11280. v, ok := value.(int)
  11281. if !ok {
  11282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11283. }
  11284. m.AddDontseeit(v)
  11285. return nil
  11286. case contact.FieldDontseeme:
  11287. v, ok := value.(int)
  11288. if !ok {
  11289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11290. }
  11291. m.AddDontseeme(v)
  11292. return nil
  11293. case contact.FieldOrganizationID:
  11294. v, ok := value.(int64)
  11295. if !ok {
  11296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11297. }
  11298. m.AddOrganizationID(v)
  11299. return nil
  11300. case contact.FieldCtype:
  11301. v, ok := value.(int64)
  11302. if !ok {
  11303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11304. }
  11305. m.AddCtype(v)
  11306. return nil
  11307. case contact.FieldCage:
  11308. v, ok := value.(int)
  11309. if !ok {
  11310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11311. }
  11312. m.AddCage(v)
  11313. return nil
  11314. }
  11315. return fmt.Errorf("unknown Contact numeric field %s", name)
  11316. }
  11317. // ClearedFields returns all nullable fields that were cleared during this
  11318. // mutation.
  11319. func (m *ContactMutation) ClearedFields() []string {
  11320. var fields []string
  11321. if m.FieldCleared(contact.FieldStatus) {
  11322. fields = append(fields, contact.FieldStatus)
  11323. }
  11324. if m.FieldCleared(contact.FieldDeletedAt) {
  11325. fields = append(fields, contact.FieldDeletedAt)
  11326. }
  11327. if m.FieldCleared(contact.FieldType) {
  11328. fields = append(fields, contact.FieldType)
  11329. }
  11330. if m.FieldCleared(contact.FieldOrganizationID) {
  11331. fields = append(fields, contact.FieldOrganizationID)
  11332. }
  11333. return fields
  11334. }
  11335. // FieldCleared returns a boolean indicating if a field with the given name was
  11336. // cleared in this mutation.
  11337. func (m *ContactMutation) FieldCleared(name string) bool {
  11338. _, ok := m.clearedFields[name]
  11339. return ok
  11340. }
  11341. // ClearField clears the value of the field with the given name. It returns an
  11342. // error if the field is not defined in the schema.
  11343. func (m *ContactMutation) ClearField(name string) error {
  11344. switch name {
  11345. case contact.FieldStatus:
  11346. m.ClearStatus()
  11347. return nil
  11348. case contact.FieldDeletedAt:
  11349. m.ClearDeletedAt()
  11350. return nil
  11351. case contact.FieldType:
  11352. m.ClearType()
  11353. return nil
  11354. case contact.FieldOrganizationID:
  11355. m.ClearOrganizationID()
  11356. return nil
  11357. }
  11358. return fmt.Errorf("unknown Contact nullable field %s", name)
  11359. }
  11360. // ResetField resets all changes in the mutation for the field with the given name.
  11361. // It returns an error if the field is not defined in the schema.
  11362. func (m *ContactMutation) ResetField(name string) error {
  11363. switch name {
  11364. case contact.FieldCreatedAt:
  11365. m.ResetCreatedAt()
  11366. return nil
  11367. case contact.FieldUpdatedAt:
  11368. m.ResetUpdatedAt()
  11369. return nil
  11370. case contact.FieldStatus:
  11371. m.ResetStatus()
  11372. return nil
  11373. case contact.FieldDeletedAt:
  11374. m.ResetDeletedAt()
  11375. return nil
  11376. case contact.FieldWxWxid:
  11377. m.ResetWxWxid()
  11378. return nil
  11379. case contact.FieldType:
  11380. m.ResetType()
  11381. return nil
  11382. case contact.FieldWxid:
  11383. m.ResetWxid()
  11384. return nil
  11385. case contact.FieldAccount:
  11386. m.ResetAccount()
  11387. return nil
  11388. case contact.FieldNickname:
  11389. m.ResetNickname()
  11390. return nil
  11391. case contact.FieldMarkname:
  11392. m.ResetMarkname()
  11393. return nil
  11394. case contact.FieldHeadimg:
  11395. m.ResetHeadimg()
  11396. return nil
  11397. case contact.FieldSex:
  11398. m.ResetSex()
  11399. return nil
  11400. case contact.FieldStarrole:
  11401. m.ResetStarrole()
  11402. return nil
  11403. case contact.FieldDontseeit:
  11404. m.ResetDontseeit()
  11405. return nil
  11406. case contact.FieldDontseeme:
  11407. m.ResetDontseeme()
  11408. return nil
  11409. case contact.FieldLag:
  11410. m.ResetLag()
  11411. return nil
  11412. case contact.FieldGid:
  11413. m.ResetGid()
  11414. return nil
  11415. case contact.FieldGname:
  11416. m.ResetGname()
  11417. return nil
  11418. case contact.FieldV3:
  11419. m.ResetV3()
  11420. return nil
  11421. case contact.FieldOrganizationID:
  11422. m.ResetOrganizationID()
  11423. return nil
  11424. case contact.FieldCtype:
  11425. m.ResetCtype()
  11426. return nil
  11427. case contact.FieldCage:
  11428. m.ResetCage()
  11429. return nil
  11430. case contact.FieldCname:
  11431. m.ResetCname()
  11432. return nil
  11433. case contact.FieldCarea:
  11434. m.ResetCarea()
  11435. return nil
  11436. case contact.FieldCbirthday:
  11437. m.ResetCbirthday()
  11438. return nil
  11439. case contact.FieldCbirtharea:
  11440. m.ResetCbirtharea()
  11441. return nil
  11442. case contact.FieldCidcardNo:
  11443. m.ResetCidcardNo()
  11444. return nil
  11445. case contact.FieldCtitle:
  11446. m.ResetCtitle()
  11447. return nil
  11448. case contact.FieldCc:
  11449. m.ResetCc()
  11450. return nil
  11451. case contact.FieldPhone:
  11452. m.ResetPhone()
  11453. return nil
  11454. }
  11455. return fmt.Errorf("unknown Contact field %s", name)
  11456. }
  11457. // AddedEdges returns all edge names that were set/added in this mutation.
  11458. func (m *ContactMutation) AddedEdges() []string {
  11459. edges := make([]string, 0, 2)
  11460. if m.contact_relationships != nil {
  11461. edges = append(edges, contact.EdgeContactRelationships)
  11462. }
  11463. if m.contact_messages != nil {
  11464. edges = append(edges, contact.EdgeContactMessages)
  11465. }
  11466. return edges
  11467. }
  11468. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11469. // name in this mutation.
  11470. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  11471. switch name {
  11472. case contact.EdgeContactRelationships:
  11473. ids := make([]ent.Value, 0, len(m.contact_relationships))
  11474. for id := range m.contact_relationships {
  11475. ids = append(ids, id)
  11476. }
  11477. return ids
  11478. case contact.EdgeContactMessages:
  11479. ids := make([]ent.Value, 0, len(m.contact_messages))
  11480. for id := range m.contact_messages {
  11481. ids = append(ids, id)
  11482. }
  11483. return ids
  11484. }
  11485. return nil
  11486. }
  11487. // RemovedEdges returns all edge names that were removed in this mutation.
  11488. func (m *ContactMutation) RemovedEdges() []string {
  11489. edges := make([]string, 0, 2)
  11490. if m.removedcontact_relationships != nil {
  11491. edges = append(edges, contact.EdgeContactRelationships)
  11492. }
  11493. if m.removedcontact_messages != nil {
  11494. edges = append(edges, contact.EdgeContactMessages)
  11495. }
  11496. return edges
  11497. }
  11498. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11499. // the given name in this mutation.
  11500. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  11501. switch name {
  11502. case contact.EdgeContactRelationships:
  11503. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  11504. for id := range m.removedcontact_relationships {
  11505. ids = append(ids, id)
  11506. }
  11507. return ids
  11508. case contact.EdgeContactMessages:
  11509. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  11510. for id := range m.removedcontact_messages {
  11511. ids = append(ids, id)
  11512. }
  11513. return ids
  11514. }
  11515. return nil
  11516. }
  11517. // ClearedEdges returns all edge names that were cleared in this mutation.
  11518. func (m *ContactMutation) ClearedEdges() []string {
  11519. edges := make([]string, 0, 2)
  11520. if m.clearedcontact_relationships {
  11521. edges = append(edges, contact.EdgeContactRelationships)
  11522. }
  11523. if m.clearedcontact_messages {
  11524. edges = append(edges, contact.EdgeContactMessages)
  11525. }
  11526. return edges
  11527. }
  11528. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11529. // was cleared in this mutation.
  11530. func (m *ContactMutation) EdgeCleared(name string) bool {
  11531. switch name {
  11532. case contact.EdgeContactRelationships:
  11533. return m.clearedcontact_relationships
  11534. case contact.EdgeContactMessages:
  11535. return m.clearedcontact_messages
  11536. }
  11537. return false
  11538. }
  11539. // ClearEdge clears the value of the edge with the given name. It returns an error
  11540. // if that edge is not defined in the schema.
  11541. func (m *ContactMutation) ClearEdge(name string) error {
  11542. switch name {
  11543. }
  11544. return fmt.Errorf("unknown Contact unique edge %s", name)
  11545. }
  11546. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11547. // It returns an error if the edge is not defined in the schema.
  11548. func (m *ContactMutation) ResetEdge(name string) error {
  11549. switch name {
  11550. case contact.EdgeContactRelationships:
  11551. m.ResetContactRelationships()
  11552. return nil
  11553. case contact.EdgeContactMessages:
  11554. m.ResetContactMessages()
  11555. return nil
  11556. }
  11557. return fmt.Errorf("unknown Contact edge %s", name)
  11558. }
  11559. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  11560. type CreditBalanceMutation struct {
  11561. config
  11562. op Op
  11563. typ string
  11564. id *uint64
  11565. created_at *time.Time
  11566. updated_at *time.Time
  11567. deleted_at *time.Time
  11568. user_id *string
  11569. balance *float32
  11570. addbalance *float32
  11571. status *int
  11572. addstatus *int
  11573. organization_id *uint64
  11574. addorganization_id *int64
  11575. clearedFields map[string]struct{}
  11576. done bool
  11577. oldValue func(context.Context) (*CreditBalance, error)
  11578. predicates []predicate.CreditBalance
  11579. }
  11580. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  11581. // creditbalanceOption allows management of the mutation configuration using functional options.
  11582. type creditbalanceOption func(*CreditBalanceMutation)
  11583. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  11584. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  11585. m := &CreditBalanceMutation{
  11586. config: c,
  11587. op: op,
  11588. typ: TypeCreditBalance,
  11589. clearedFields: make(map[string]struct{}),
  11590. }
  11591. for _, opt := range opts {
  11592. opt(m)
  11593. }
  11594. return m
  11595. }
  11596. // withCreditBalanceID sets the ID field of the mutation.
  11597. func withCreditBalanceID(id uint64) creditbalanceOption {
  11598. return func(m *CreditBalanceMutation) {
  11599. var (
  11600. err error
  11601. once sync.Once
  11602. value *CreditBalance
  11603. )
  11604. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  11605. once.Do(func() {
  11606. if m.done {
  11607. err = errors.New("querying old values post mutation is not allowed")
  11608. } else {
  11609. value, err = m.Client().CreditBalance.Get(ctx, id)
  11610. }
  11611. })
  11612. return value, err
  11613. }
  11614. m.id = &id
  11615. }
  11616. }
  11617. // withCreditBalance sets the old CreditBalance of the mutation.
  11618. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  11619. return func(m *CreditBalanceMutation) {
  11620. m.oldValue = func(context.Context) (*CreditBalance, error) {
  11621. return node, nil
  11622. }
  11623. m.id = &node.ID
  11624. }
  11625. }
  11626. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11627. // executed in a transaction (ent.Tx), a transactional client is returned.
  11628. func (m CreditBalanceMutation) Client() *Client {
  11629. client := &Client{config: m.config}
  11630. client.init()
  11631. return client
  11632. }
  11633. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11634. // it returns an error otherwise.
  11635. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  11636. if _, ok := m.driver.(*txDriver); !ok {
  11637. return nil, errors.New("ent: mutation is not running in a transaction")
  11638. }
  11639. tx := &Tx{config: m.config}
  11640. tx.init()
  11641. return tx, nil
  11642. }
  11643. // SetID sets the value of the id field. Note that this
  11644. // operation is only accepted on creation of CreditBalance entities.
  11645. func (m *CreditBalanceMutation) SetID(id uint64) {
  11646. m.id = &id
  11647. }
  11648. // ID returns the ID value in the mutation. Note that the ID is only available
  11649. // if it was provided to the builder or after it was returned from the database.
  11650. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  11651. if m.id == nil {
  11652. return
  11653. }
  11654. return *m.id, true
  11655. }
  11656. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11657. // That means, if the mutation is applied within a transaction with an isolation level such
  11658. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11659. // or updated by the mutation.
  11660. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  11661. switch {
  11662. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11663. id, exists := m.ID()
  11664. if exists {
  11665. return []uint64{id}, nil
  11666. }
  11667. fallthrough
  11668. case m.op.Is(OpUpdate | OpDelete):
  11669. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  11670. default:
  11671. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11672. }
  11673. }
  11674. // SetCreatedAt sets the "created_at" field.
  11675. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  11676. m.created_at = &t
  11677. }
  11678. // CreatedAt returns the value of the "created_at" field in the mutation.
  11679. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  11680. v := m.created_at
  11681. if v == nil {
  11682. return
  11683. }
  11684. return *v, true
  11685. }
  11686. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  11687. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11689. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11690. if !m.op.Is(OpUpdateOne) {
  11691. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11692. }
  11693. if m.id == nil || m.oldValue == nil {
  11694. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11695. }
  11696. oldValue, err := m.oldValue(ctx)
  11697. if err != nil {
  11698. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11699. }
  11700. return oldValue.CreatedAt, nil
  11701. }
  11702. // ResetCreatedAt resets all changes to the "created_at" field.
  11703. func (m *CreditBalanceMutation) ResetCreatedAt() {
  11704. m.created_at = nil
  11705. }
  11706. // SetUpdatedAt sets the "updated_at" field.
  11707. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  11708. m.updated_at = &t
  11709. }
  11710. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11711. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  11712. v := m.updated_at
  11713. if v == nil {
  11714. return
  11715. }
  11716. return *v, true
  11717. }
  11718. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  11719. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11721. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11722. if !m.op.Is(OpUpdateOne) {
  11723. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11724. }
  11725. if m.id == nil || m.oldValue == nil {
  11726. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11727. }
  11728. oldValue, err := m.oldValue(ctx)
  11729. if err != nil {
  11730. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11731. }
  11732. return oldValue.UpdatedAt, nil
  11733. }
  11734. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11735. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  11736. m.updated_at = nil
  11737. }
  11738. // SetDeletedAt sets the "deleted_at" field.
  11739. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  11740. m.deleted_at = &t
  11741. }
  11742. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11743. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  11744. v := m.deleted_at
  11745. if v == nil {
  11746. return
  11747. }
  11748. return *v, true
  11749. }
  11750. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  11751. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11753. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11754. if !m.op.Is(OpUpdateOne) {
  11755. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11756. }
  11757. if m.id == nil || m.oldValue == nil {
  11758. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11759. }
  11760. oldValue, err := m.oldValue(ctx)
  11761. if err != nil {
  11762. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11763. }
  11764. return oldValue.DeletedAt, nil
  11765. }
  11766. // ClearDeletedAt clears the value of the "deleted_at" field.
  11767. func (m *CreditBalanceMutation) ClearDeletedAt() {
  11768. m.deleted_at = nil
  11769. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  11770. }
  11771. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11772. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  11773. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  11774. return ok
  11775. }
  11776. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11777. func (m *CreditBalanceMutation) ResetDeletedAt() {
  11778. m.deleted_at = nil
  11779. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  11780. }
  11781. // SetUserID sets the "user_id" field.
  11782. func (m *CreditBalanceMutation) SetUserID(s string) {
  11783. m.user_id = &s
  11784. }
  11785. // UserID returns the value of the "user_id" field in the mutation.
  11786. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  11787. v := m.user_id
  11788. if v == nil {
  11789. return
  11790. }
  11791. return *v, true
  11792. }
  11793. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  11794. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11796. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  11797. if !m.op.Is(OpUpdateOne) {
  11798. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11799. }
  11800. if m.id == nil || m.oldValue == nil {
  11801. return v, errors.New("OldUserID requires an ID field in the mutation")
  11802. }
  11803. oldValue, err := m.oldValue(ctx)
  11804. if err != nil {
  11805. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11806. }
  11807. return oldValue.UserID, nil
  11808. }
  11809. // ClearUserID clears the value of the "user_id" field.
  11810. func (m *CreditBalanceMutation) ClearUserID() {
  11811. m.user_id = nil
  11812. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  11813. }
  11814. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11815. func (m *CreditBalanceMutation) UserIDCleared() bool {
  11816. _, ok := m.clearedFields[creditbalance.FieldUserID]
  11817. return ok
  11818. }
  11819. // ResetUserID resets all changes to the "user_id" field.
  11820. func (m *CreditBalanceMutation) ResetUserID() {
  11821. m.user_id = nil
  11822. delete(m.clearedFields, creditbalance.FieldUserID)
  11823. }
  11824. // SetBalance sets the "balance" field.
  11825. func (m *CreditBalanceMutation) SetBalance(f float32) {
  11826. m.balance = &f
  11827. m.addbalance = nil
  11828. }
  11829. // Balance returns the value of the "balance" field in the mutation.
  11830. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  11831. v := m.balance
  11832. if v == nil {
  11833. return
  11834. }
  11835. return *v, true
  11836. }
  11837. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  11838. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11840. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  11841. if !m.op.Is(OpUpdateOne) {
  11842. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  11843. }
  11844. if m.id == nil || m.oldValue == nil {
  11845. return v, errors.New("OldBalance requires an ID field in the mutation")
  11846. }
  11847. oldValue, err := m.oldValue(ctx)
  11848. if err != nil {
  11849. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  11850. }
  11851. return oldValue.Balance, nil
  11852. }
  11853. // AddBalance adds f to the "balance" field.
  11854. func (m *CreditBalanceMutation) AddBalance(f float32) {
  11855. if m.addbalance != nil {
  11856. *m.addbalance += f
  11857. } else {
  11858. m.addbalance = &f
  11859. }
  11860. }
  11861. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  11862. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  11863. v := m.addbalance
  11864. if v == nil {
  11865. return
  11866. }
  11867. return *v, true
  11868. }
  11869. // ResetBalance resets all changes to the "balance" field.
  11870. func (m *CreditBalanceMutation) ResetBalance() {
  11871. m.balance = nil
  11872. m.addbalance = nil
  11873. }
  11874. // SetStatus sets the "status" field.
  11875. func (m *CreditBalanceMutation) SetStatus(i int) {
  11876. m.status = &i
  11877. m.addstatus = nil
  11878. }
  11879. // Status returns the value of the "status" field in the mutation.
  11880. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  11881. v := m.status
  11882. if v == nil {
  11883. return
  11884. }
  11885. return *v, true
  11886. }
  11887. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  11888. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11890. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  11891. if !m.op.Is(OpUpdateOne) {
  11892. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11893. }
  11894. if m.id == nil || m.oldValue == nil {
  11895. return v, errors.New("OldStatus requires an ID field in the mutation")
  11896. }
  11897. oldValue, err := m.oldValue(ctx)
  11898. if err != nil {
  11899. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11900. }
  11901. return oldValue.Status, nil
  11902. }
  11903. // AddStatus adds i to the "status" field.
  11904. func (m *CreditBalanceMutation) AddStatus(i int) {
  11905. if m.addstatus != nil {
  11906. *m.addstatus += i
  11907. } else {
  11908. m.addstatus = &i
  11909. }
  11910. }
  11911. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11912. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  11913. v := m.addstatus
  11914. if v == nil {
  11915. return
  11916. }
  11917. return *v, true
  11918. }
  11919. // ClearStatus clears the value of the "status" field.
  11920. func (m *CreditBalanceMutation) ClearStatus() {
  11921. m.status = nil
  11922. m.addstatus = nil
  11923. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  11924. }
  11925. // StatusCleared returns if the "status" field was cleared in this mutation.
  11926. func (m *CreditBalanceMutation) StatusCleared() bool {
  11927. _, ok := m.clearedFields[creditbalance.FieldStatus]
  11928. return ok
  11929. }
  11930. // ResetStatus resets all changes to the "status" field.
  11931. func (m *CreditBalanceMutation) ResetStatus() {
  11932. m.status = nil
  11933. m.addstatus = nil
  11934. delete(m.clearedFields, creditbalance.FieldStatus)
  11935. }
  11936. // SetOrganizationID sets the "organization_id" field.
  11937. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  11938. m.organization_id = &u
  11939. m.addorganization_id = nil
  11940. }
  11941. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11942. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  11943. v := m.organization_id
  11944. if v == nil {
  11945. return
  11946. }
  11947. return *v, true
  11948. }
  11949. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  11950. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11952. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11953. if !m.op.Is(OpUpdateOne) {
  11954. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11955. }
  11956. if m.id == nil || m.oldValue == nil {
  11957. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11958. }
  11959. oldValue, err := m.oldValue(ctx)
  11960. if err != nil {
  11961. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11962. }
  11963. return oldValue.OrganizationID, nil
  11964. }
  11965. // AddOrganizationID adds u to the "organization_id" field.
  11966. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  11967. if m.addorganization_id != nil {
  11968. *m.addorganization_id += u
  11969. } else {
  11970. m.addorganization_id = &u
  11971. }
  11972. }
  11973. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11974. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  11975. v := m.addorganization_id
  11976. if v == nil {
  11977. return
  11978. }
  11979. return *v, true
  11980. }
  11981. // ClearOrganizationID clears the value of the "organization_id" field.
  11982. func (m *CreditBalanceMutation) ClearOrganizationID() {
  11983. m.organization_id = nil
  11984. m.addorganization_id = nil
  11985. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  11986. }
  11987. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11988. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  11989. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  11990. return ok
  11991. }
  11992. // ResetOrganizationID resets all changes to the "organization_id" field.
  11993. func (m *CreditBalanceMutation) ResetOrganizationID() {
  11994. m.organization_id = nil
  11995. m.addorganization_id = nil
  11996. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  11997. }
  11998. // Where appends a list predicates to the CreditBalanceMutation builder.
  11999. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  12000. m.predicates = append(m.predicates, ps...)
  12001. }
  12002. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  12003. // users can use type-assertion to append predicates that do not depend on any generated package.
  12004. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  12005. p := make([]predicate.CreditBalance, len(ps))
  12006. for i := range ps {
  12007. p[i] = ps[i]
  12008. }
  12009. m.Where(p...)
  12010. }
  12011. // Op returns the operation name.
  12012. func (m *CreditBalanceMutation) Op() Op {
  12013. return m.op
  12014. }
  12015. // SetOp allows setting the mutation operation.
  12016. func (m *CreditBalanceMutation) SetOp(op Op) {
  12017. m.op = op
  12018. }
  12019. // Type returns the node type of this mutation (CreditBalance).
  12020. func (m *CreditBalanceMutation) Type() string {
  12021. return m.typ
  12022. }
  12023. // Fields returns all fields that were changed during this mutation. Note that in
  12024. // order to get all numeric fields that were incremented/decremented, call
  12025. // AddedFields().
  12026. func (m *CreditBalanceMutation) Fields() []string {
  12027. fields := make([]string, 0, 7)
  12028. if m.created_at != nil {
  12029. fields = append(fields, creditbalance.FieldCreatedAt)
  12030. }
  12031. if m.updated_at != nil {
  12032. fields = append(fields, creditbalance.FieldUpdatedAt)
  12033. }
  12034. if m.deleted_at != nil {
  12035. fields = append(fields, creditbalance.FieldDeletedAt)
  12036. }
  12037. if m.user_id != nil {
  12038. fields = append(fields, creditbalance.FieldUserID)
  12039. }
  12040. if m.balance != nil {
  12041. fields = append(fields, creditbalance.FieldBalance)
  12042. }
  12043. if m.status != nil {
  12044. fields = append(fields, creditbalance.FieldStatus)
  12045. }
  12046. if m.organization_id != nil {
  12047. fields = append(fields, creditbalance.FieldOrganizationID)
  12048. }
  12049. return fields
  12050. }
  12051. // Field returns the value of a field with the given name. The second boolean
  12052. // return value indicates that this field was not set, or was not defined in the
  12053. // schema.
  12054. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  12055. switch name {
  12056. case creditbalance.FieldCreatedAt:
  12057. return m.CreatedAt()
  12058. case creditbalance.FieldUpdatedAt:
  12059. return m.UpdatedAt()
  12060. case creditbalance.FieldDeletedAt:
  12061. return m.DeletedAt()
  12062. case creditbalance.FieldUserID:
  12063. return m.UserID()
  12064. case creditbalance.FieldBalance:
  12065. return m.Balance()
  12066. case creditbalance.FieldStatus:
  12067. return m.Status()
  12068. case creditbalance.FieldOrganizationID:
  12069. return m.OrganizationID()
  12070. }
  12071. return nil, false
  12072. }
  12073. // OldField returns the old value of the field from the database. An error is
  12074. // returned if the mutation operation is not UpdateOne, or the query to the
  12075. // database failed.
  12076. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12077. switch name {
  12078. case creditbalance.FieldCreatedAt:
  12079. return m.OldCreatedAt(ctx)
  12080. case creditbalance.FieldUpdatedAt:
  12081. return m.OldUpdatedAt(ctx)
  12082. case creditbalance.FieldDeletedAt:
  12083. return m.OldDeletedAt(ctx)
  12084. case creditbalance.FieldUserID:
  12085. return m.OldUserID(ctx)
  12086. case creditbalance.FieldBalance:
  12087. return m.OldBalance(ctx)
  12088. case creditbalance.FieldStatus:
  12089. return m.OldStatus(ctx)
  12090. case creditbalance.FieldOrganizationID:
  12091. return m.OldOrganizationID(ctx)
  12092. }
  12093. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  12094. }
  12095. // SetField sets the value of a field with the given name. It returns an error if
  12096. // the field is not defined in the schema, or if the type mismatched the field
  12097. // type.
  12098. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  12099. switch name {
  12100. case creditbalance.FieldCreatedAt:
  12101. v, ok := value.(time.Time)
  12102. if !ok {
  12103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12104. }
  12105. m.SetCreatedAt(v)
  12106. return nil
  12107. case creditbalance.FieldUpdatedAt:
  12108. v, ok := value.(time.Time)
  12109. if !ok {
  12110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12111. }
  12112. m.SetUpdatedAt(v)
  12113. return nil
  12114. case creditbalance.FieldDeletedAt:
  12115. v, ok := value.(time.Time)
  12116. if !ok {
  12117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12118. }
  12119. m.SetDeletedAt(v)
  12120. return nil
  12121. case creditbalance.FieldUserID:
  12122. v, ok := value.(string)
  12123. if !ok {
  12124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12125. }
  12126. m.SetUserID(v)
  12127. return nil
  12128. case creditbalance.FieldBalance:
  12129. v, ok := value.(float32)
  12130. if !ok {
  12131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12132. }
  12133. m.SetBalance(v)
  12134. return nil
  12135. case creditbalance.FieldStatus:
  12136. v, ok := value.(int)
  12137. if !ok {
  12138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12139. }
  12140. m.SetStatus(v)
  12141. return nil
  12142. case creditbalance.FieldOrganizationID:
  12143. v, ok := value.(uint64)
  12144. if !ok {
  12145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12146. }
  12147. m.SetOrganizationID(v)
  12148. return nil
  12149. }
  12150. return fmt.Errorf("unknown CreditBalance field %s", name)
  12151. }
  12152. // AddedFields returns all numeric fields that were incremented/decremented during
  12153. // this mutation.
  12154. func (m *CreditBalanceMutation) AddedFields() []string {
  12155. var fields []string
  12156. if m.addbalance != nil {
  12157. fields = append(fields, creditbalance.FieldBalance)
  12158. }
  12159. if m.addstatus != nil {
  12160. fields = append(fields, creditbalance.FieldStatus)
  12161. }
  12162. if m.addorganization_id != nil {
  12163. fields = append(fields, creditbalance.FieldOrganizationID)
  12164. }
  12165. return fields
  12166. }
  12167. // AddedField returns the numeric value that was incremented/decremented on a field
  12168. // with the given name. The second boolean return value indicates that this field
  12169. // was not set, or was not defined in the schema.
  12170. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  12171. switch name {
  12172. case creditbalance.FieldBalance:
  12173. return m.AddedBalance()
  12174. case creditbalance.FieldStatus:
  12175. return m.AddedStatus()
  12176. case creditbalance.FieldOrganizationID:
  12177. return m.AddedOrganizationID()
  12178. }
  12179. return nil, false
  12180. }
  12181. // AddField adds the value to the field with the given name. It returns an error if
  12182. // the field is not defined in the schema, or if the type mismatched the field
  12183. // type.
  12184. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  12185. switch name {
  12186. case creditbalance.FieldBalance:
  12187. v, ok := value.(float32)
  12188. if !ok {
  12189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12190. }
  12191. m.AddBalance(v)
  12192. return nil
  12193. case creditbalance.FieldStatus:
  12194. v, ok := value.(int)
  12195. if !ok {
  12196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12197. }
  12198. m.AddStatus(v)
  12199. return nil
  12200. case creditbalance.FieldOrganizationID:
  12201. v, ok := value.(int64)
  12202. if !ok {
  12203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12204. }
  12205. m.AddOrganizationID(v)
  12206. return nil
  12207. }
  12208. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  12209. }
  12210. // ClearedFields returns all nullable fields that were cleared during this
  12211. // mutation.
  12212. func (m *CreditBalanceMutation) ClearedFields() []string {
  12213. var fields []string
  12214. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  12215. fields = append(fields, creditbalance.FieldDeletedAt)
  12216. }
  12217. if m.FieldCleared(creditbalance.FieldUserID) {
  12218. fields = append(fields, creditbalance.FieldUserID)
  12219. }
  12220. if m.FieldCleared(creditbalance.FieldStatus) {
  12221. fields = append(fields, creditbalance.FieldStatus)
  12222. }
  12223. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  12224. fields = append(fields, creditbalance.FieldOrganizationID)
  12225. }
  12226. return fields
  12227. }
  12228. // FieldCleared returns a boolean indicating if a field with the given name was
  12229. // cleared in this mutation.
  12230. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  12231. _, ok := m.clearedFields[name]
  12232. return ok
  12233. }
  12234. // ClearField clears the value of the field with the given name. It returns an
  12235. // error if the field is not defined in the schema.
  12236. func (m *CreditBalanceMutation) ClearField(name string) error {
  12237. switch name {
  12238. case creditbalance.FieldDeletedAt:
  12239. m.ClearDeletedAt()
  12240. return nil
  12241. case creditbalance.FieldUserID:
  12242. m.ClearUserID()
  12243. return nil
  12244. case creditbalance.FieldStatus:
  12245. m.ClearStatus()
  12246. return nil
  12247. case creditbalance.FieldOrganizationID:
  12248. m.ClearOrganizationID()
  12249. return nil
  12250. }
  12251. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  12252. }
  12253. // ResetField resets all changes in the mutation for the field with the given name.
  12254. // It returns an error if the field is not defined in the schema.
  12255. func (m *CreditBalanceMutation) ResetField(name string) error {
  12256. switch name {
  12257. case creditbalance.FieldCreatedAt:
  12258. m.ResetCreatedAt()
  12259. return nil
  12260. case creditbalance.FieldUpdatedAt:
  12261. m.ResetUpdatedAt()
  12262. return nil
  12263. case creditbalance.FieldDeletedAt:
  12264. m.ResetDeletedAt()
  12265. return nil
  12266. case creditbalance.FieldUserID:
  12267. m.ResetUserID()
  12268. return nil
  12269. case creditbalance.FieldBalance:
  12270. m.ResetBalance()
  12271. return nil
  12272. case creditbalance.FieldStatus:
  12273. m.ResetStatus()
  12274. return nil
  12275. case creditbalance.FieldOrganizationID:
  12276. m.ResetOrganizationID()
  12277. return nil
  12278. }
  12279. return fmt.Errorf("unknown CreditBalance field %s", name)
  12280. }
  12281. // AddedEdges returns all edge names that were set/added in this mutation.
  12282. func (m *CreditBalanceMutation) AddedEdges() []string {
  12283. edges := make([]string, 0, 0)
  12284. return edges
  12285. }
  12286. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12287. // name in this mutation.
  12288. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  12289. return nil
  12290. }
  12291. // RemovedEdges returns all edge names that were removed in this mutation.
  12292. func (m *CreditBalanceMutation) RemovedEdges() []string {
  12293. edges := make([]string, 0, 0)
  12294. return edges
  12295. }
  12296. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12297. // the given name in this mutation.
  12298. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  12299. return nil
  12300. }
  12301. // ClearedEdges returns all edge names that were cleared in this mutation.
  12302. func (m *CreditBalanceMutation) ClearedEdges() []string {
  12303. edges := make([]string, 0, 0)
  12304. return edges
  12305. }
  12306. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12307. // was cleared in this mutation.
  12308. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  12309. return false
  12310. }
  12311. // ClearEdge clears the value of the edge with the given name. It returns an error
  12312. // if that edge is not defined in the schema.
  12313. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  12314. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  12315. }
  12316. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12317. // It returns an error if the edge is not defined in the schema.
  12318. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  12319. return fmt.Errorf("unknown CreditBalance edge %s", name)
  12320. }
  12321. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  12322. type CreditUsageMutation struct {
  12323. config
  12324. op Op
  12325. typ string
  12326. id *uint64
  12327. created_at *time.Time
  12328. updated_at *time.Time
  12329. deleted_at *time.Time
  12330. user_id *string
  12331. number *float32
  12332. addnumber *float32
  12333. status *int
  12334. addstatus *int
  12335. ntype *int
  12336. addntype *int
  12337. table *string
  12338. organization_id *uint64
  12339. addorganization_id *int64
  12340. nid *uint64
  12341. addnid *int64
  12342. reason *string
  12343. operator *string
  12344. clearedFields map[string]struct{}
  12345. done bool
  12346. oldValue func(context.Context) (*CreditUsage, error)
  12347. predicates []predicate.CreditUsage
  12348. }
  12349. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  12350. // creditusageOption allows management of the mutation configuration using functional options.
  12351. type creditusageOption func(*CreditUsageMutation)
  12352. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  12353. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  12354. m := &CreditUsageMutation{
  12355. config: c,
  12356. op: op,
  12357. typ: TypeCreditUsage,
  12358. clearedFields: make(map[string]struct{}),
  12359. }
  12360. for _, opt := range opts {
  12361. opt(m)
  12362. }
  12363. return m
  12364. }
  12365. // withCreditUsageID sets the ID field of the mutation.
  12366. func withCreditUsageID(id uint64) creditusageOption {
  12367. return func(m *CreditUsageMutation) {
  12368. var (
  12369. err error
  12370. once sync.Once
  12371. value *CreditUsage
  12372. )
  12373. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  12374. once.Do(func() {
  12375. if m.done {
  12376. err = errors.New("querying old values post mutation is not allowed")
  12377. } else {
  12378. value, err = m.Client().CreditUsage.Get(ctx, id)
  12379. }
  12380. })
  12381. return value, err
  12382. }
  12383. m.id = &id
  12384. }
  12385. }
  12386. // withCreditUsage sets the old CreditUsage of the mutation.
  12387. func withCreditUsage(node *CreditUsage) creditusageOption {
  12388. return func(m *CreditUsageMutation) {
  12389. m.oldValue = func(context.Context) (*CreditUsage, error) {
  12390. return node, nil
  12391. }
  12392. m.id = &node.ID
  12393. }
  12394. }
  12395. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12396. // executed in a transaction (ent.Tx), a transactional client is returned.
  12397. func (m CreditUsageMutation) Client() *Client {
  12398. client := &Client{config: m.config}
  12399. client.init()
  12400. return client
  12401. }
  12402. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12403. // it returns an error otherwise.
  12404. func (m CreditUsageMutation) Tx() (*Tx, error) {
  12405. if _, ok := m.driver.(*txDriver); !ok {
  12406. return nil, errors.New("ent: mutation is not running in a transaction")
  12407. }
  12408. tx := &Tx{config: m.config}
  12409. tx.init()
  12410. return tx, nil
  12411. }
  12412. // SetID sets the value of the id field. Note that this
  12413. // operation is only accepted on creation of CreditUsage entities.
  12414. func (m *CreditUsageMutation) SetID(id uint64) {
  12415. m.id = &id
  12416. }
  12417. // ID returns the ID value in the mutation. Note that the ID is only available
  12418. // if it was provided to the builder or after it was returned from the database.
  12419. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  12420. if m.id == nil {
  12421. return
  12422. }
  12423. return *m.id, true
  12424. }
  12425. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12426. // That means, if the mutation is applied within a transaction with an isolation level such
  12427. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12428. // or updated by the mutation.
  12429. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  12430. switch {
  12431. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12432. id, exists := m.ID()
  12433. if exists {
  12434. return []uint64{id}, nil
  12435. }
  12436. fallthrough
  12437. case m.op.Is(OpUpdate | OpDelete):
  12438. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  12439. default:
  12440. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12441. }
  12442. }
  12443. // SetCreatedAt sets the "created_at" field.
  12444. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  12445. m.created_at = &t
  12446. }
  12447. // CreatedAt returns the value of the "created_at" field in the mutation.
  12448. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  12449. v := m.created_at
  12450. if v == nil {
  12451. return
  12452. }
  12453. return *v, true
  12454. }
  12455. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  12456. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12458. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12459. if !m.op.Is(OpUpdateOne) {
  12460. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12461. }
  12462. if m.id == nil || m.oldValue == nil {
  12463. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12464. }
  12465. oldValue, err := m.oldValue(ctx)
  12466. if err != nil {
  12467. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12468. }
  12469. return oldValue.CreatedAt, nil
  12470. }
  12471. // ResetCreatedAt resets all changes to the "created_at" field.
  12472. func (m *CreditUsageMutation) ResetCreatedAt() {
  12473. m.created_at = nil
  12474. }
  12475. // SetUpdatedAt sets the "updated_at" field.
  12476. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  12477. m.updated_at = &t
  12478. }
  12479. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12480. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  12481. v := m.updated_at
  12482. if v == nil {
  12483. return
  12484. }
  12485. return *v, true
  12486. }
  12487. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  12488. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12490. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12491. if !m.op.Is(OpUpdateOne) {
  12492. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12493. }
  12494. if m.id == nil || m.oldValue == nil {
  12495. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12496. }
  12497. oldValue, err := m.oldValue(ctx)
  12498. if err != nil {
  12499. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12500. }
  12501. return oldValue.UpdatedAt, nil
  12502. }
  12503. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12504. func (m *CreditUsageMutation) ResetUpdatedAt() {
  12505. m.updated_at = nil
  12506. }
  12507. // SetDeletedAt sets the "deleted_at" field.
  12508. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  12509. m.deleted_at = &t
  12510. }
  12511. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12512. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  12513. v := m.deleted_at
  12514. if v == nil {
  12515. return
  12516. }
  12517. return *v, true
  12518. }
  12519. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  12520. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12522. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12523. if !m.op.Is(OpUpdateOne) {
  12524. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12525. }
  12526. if m.id == nil || m.oldValue == nil {
  12527. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12528. }
  12529. oldValue, err := m.oldValue(ctx)
  12530. if err != nil {
  12531. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12532. }
  12533. return oldValue.DeletedAt, nil
  12534. }
  12535. // ClearDeletedAt clears the value of the "deleted_at" field.
  12536. func (m *CreditUsageMutation) ClearDeletedAt() {
  12537. m.deleted_at = nil
  12538. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  12539. }
  12540. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12541. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  12542. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  12543. return ok
  12544. }
  12545. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12546. func (m *CreditUsageMutation) ResetDeletedAt() {
  12547. m.deleted_at = nil
  12548. delete(m.clearedFields, creditusage.FieldDeletedAt)
  12549. }
  12550. // SetUserID sets the "user_id" field.
  12551. func (m *CreditUsageMutation) SetUserID(s string) {
  12552. m.user_id = &s
  12553. }
  12554. // UserID returns the value of the "user_id" field in the mutation.
  12555. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  12556. v := m.user_id
  12557. if v == nil {
  12558. return
  12559. }
  12560. return *v, true
  12561. }
  12562. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  12563. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12565. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  12566. if !m.op.Is(OpUpdateOne) {
  12567. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  12568. }
  12569. if m.id == nil || m.oldValue == nil {
  12570. return v, errors.New("OldUserID requires an ID field in the mutation")
  12571. }
  12572. oldValue, err := m.oldValue(ctx)
  12573. if err != nil {
  12574. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  12575. }
  12576. return oldValue.UserID, nil
  12577. }
  12578. // ClearUserID clears the value of the "user_id" field.
  12579. func (m *CreditUsageMutation) ClearUserID() {
  12580. m.user_id = nil
  12581. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  12582. }
  12583. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  12584. func (m *CreditUsageMutation) UserIDCleared() bool {
  12585. _, ok := m.clearedFields[creditusage.FieldUserID]
  12586. return ok
  12587. }
  12588. // ResetUserID resets all changes to the "user_id" field.
  12589. func (m *CreditUsageMutation) ResetUserID() {
  12590. m.user_id = nil
  12591. delete(m.clearedFields, creditusage.FieldUserID)
  12592. }
  12593. // SetNumber sets the "number" field.
  12594. func (m *CreditUsageMutation) SetNumber(f float32) {
  12595. m.number = &f
  12596. m.addnumber = nil
  12597. }
  12598. // Number returns the value of the "number" field in the mutation.
  12599. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  12600. v := m.number
  12601. if v == nil {
  12602. return
  12603. }
  12604. return *v, true
  12605. }
  12606. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  12607. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12609. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  12610. if !m.op.Is(OpUpdateOne) {
  12611. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  12612. }
  12613. if m.id == nil || m.oldValue == nil {
  12614. return v, errors.New("OldNumber requires an ID field in the mutation")
  12615. }
  12616. oldValue, err := m.oldValue(ctx)
  12617. if err != nil {
  12618. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  12619. }
  12620. return oldValue.Number, nil
  12621. }
  12622. // AddNumber adds f to the "number" field.
  12623. func (m *CreditUsageMutation) AddNumber(f float32) {
  12624. if m.addnumber != nil {
  12625. *m.addnumber += f
  12626. } else {
  12627. m.addnumber = &f
  12628. }
  12629. }
  12630. // AddedNumber returns the value that was added to the "number" field in this mutation.
  12631. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  12632. v := m.addnumber
  12633. if v == nil {
  12634. return
  12635. }
  12636. return *v, true
  12637. }
  12638. // ResetNumber resets all changes to the "number" field.
  12639. func (m *CreditUsageMutation) ResetNumber() {
  12640. m.number = nil
  12641. m.addnumber = nil
  12642. }
  12643. // SetStatus sets the "status" field.
  12644. func (m *CreditUsageMutation) SetStatus(i int) {
  12645. m.status = &i
  12646. m.addstatus = nil
  12647. }
  12648. // Status returns the value of the "status" field in the mutation.
  12649. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  12650. v := m.status
  12651. if v == nil {
  12652. return
  12653. }
  12654. return *v, true
  12655. }
  12656. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  12657. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12659. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  12660. if !m.op.Is(OpUpdateOne) {
  12661. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12662. }
  12663. if m.id == nil || m.oldValue == nil {
  12664. return v, errors.New("OldStatus requires an ID field in the mutation")
  12665. }
  12666. oldValue, err := m.oldValue(ctx)
  12667. if err != nil {
  12668. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12669. }
  12670. return oldValue.Status, nil
  12671. }
  12672. // AddStatus adds i to the "status" field.
  12673. func (m *CreditUsageMutation) AddStatus(i int) {
  12674. if m.addstatus != nil {
  12675. *m.addstatus += i
  12676. } else {
  12677. m.addstatus = &i
  12678. }
  12679. }
  12680. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12681. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  12682. v := m.addstatus
  12683. if v == nil {
  12684. return
  12685. }
  12686. return *v, true
  12687. }
  12688. // ClearStatus clears the value of the "status" field.
  12689. func (m *CreditUsageMutation) ClearStatus() {
  12690. m.status = nil
  12691. m.addstatus = nil
  12692. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  12693. }
  12694. // StatusCleared returns if the "status" field was cleared in this mutation.
  12695. func (m *CreditUsageMutation) StatusCleared() bool {
  12696. _, ok := m.clearedFields[creditusage.FieldStatus]
  12697. return ok
  12698. }
  12699. // ResetStatus resets all changes to the "status" field.
  12700. func (m *CreditUsageMutation) ResetStatus() {
  12701. m.status = nil
  12702. m.addstatus = nil
  12703. delete(m.clearedFields, creditusage.FieldStatus)
  12704. }
  12705. // SetNtype sets the "ntype" field.
  12706. func (m *CreditUsageMutation) SetNtype(i int) {
  12707. m.ntype = &i
  12708. m.addntype = nil
  12709. }
  12710. // Ntype returns the value of the "ntype" field in the mutation.
  12711. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  12712. v := m.ntype
  12713. if v == nil {
  12714. return
  12715. }
  12716. return *v, true
  12717. }
  12718. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  12719. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12721. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  12722. if !m.op.Is(OpUpdateOne) {
  12723. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  12724. }
  12725. if m.id == nil || m.oldValue == nil {
  12726. return v, errors.New("OldNtype requires an ID field in the mutation")
  12727. }
  12728. oldValue, err := m.oldValue(ctx)
  12729. if err != nil {
  12730. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  12731. }
  12732. return oldValue.Ntype, nil
  12733. }
  12734. // AddNtype adds i to the "ntype" field.
  12735. func (m *CreditUsageMutation) AddNtype(i int) {
  12736. if m.addntype != nil {
  12737. *m.addntype += i
  12738. } else {
  12739. m.addntype = &i
  12740. }
  12741. }
  12742. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  12743. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  12744. v := m.addntype
  12745. if v == nil {
  12746. return
  12747. }
  12748. return *v, true
  12749. }
  12750. // ResetNtype resets all changes to the "ntype" field.
  12751. func (m *CreditUsageMutation) ResetNtype() {
  12752. m.ntype = nil
  12753. m.addntype = nil
  12754. }
  12755. // SetTable sets the "table" field.
  12756. func (m *CreditUsageMutation) SetTable(s string) {
  12757. m.table = &s
  12758. }
  12759. // Table returns the value of the "table" field in the mutation.
  12760. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  12761. v := m.table
  12762. if v == nil {
  12763. return
  12764. }
  12765. return *v, true
  12766. }
  12767. // OldTable returns the old "table" field's value of the CreditUsage entity.
  12768. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12770. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  12771. if !m.op.Is(OpUpdateOne) {
  12772. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  12773. }
  12774. if m.id == nil || m.oldValue == nil {
  12775. return v, errors.New("OldTable requires an ID field in the mutation")
  12776. }
  12777. oldValue, err := m.oldValue(ctx)
  12778. if err != nil {
  12779. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  12780. }
  12781. return oldValue.Table, nil
  12782. }
  12783. // ResetTable resets all changes to the "table" field.
  12784. func (m *CreditUsageMutation) ResetTable() {
  12785. m.table = nil
  12786. }
  12787. // SetOrganizationID sets the "organization_id" field.
  12788. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  12789. m.organization_id = &u
  12790. m.addorganization_id = nil
  12791. }
  12792. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12793. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  12794. v := m.organization_id
  12795. if v == nil {
  12796. return
  12797. }
  12798. return *v, true
  12799. }
  12800. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  12801. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12803. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12804. if !m.op.Is(OpUpdateOne) {
  12805. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12806. }
  12807. if m.id == nil || m.oldValue == nil {
  12808. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12809. }
  12810. oldValue, err := m.oldValue(ctx)
  12811. if err != nil {
  12812. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12813. }
  12814. return oldValue.OrganizationID, nil
  12815. }
  12816. // AddOrganizationID adds u to the "organization_id" field.
  12817. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  12818. if m.addorganization_id != nil {
  12819. *m.addorganization_id += u
  12820. } else {
  12821. m.addorganization_id = &u
  12822. }
  12823. }
  12824. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12825. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  12826. v := m.addorganization_id
  12827. if v == nil {
  12828. return
  12829. }
  12830. return *v, true
  12831. }
  12832. // ClearOrganizationID clears the value of the "organization_id" field.
  12833. func (m *CreditUsageMutation) ClearOrganizationID() {
  12834. m.organization_id = nil
  12835. m.addorganization_id = nil
  12836. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  12837. }
  12838. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12839. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  12840. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  12841. return ok
  12842. }
  12843. // ResetOrganizationID resets all changes to the "organization_id" field.
  12844. func (m *CreditUsageMutation) ResetOrganizationID() {
  12845. m.organization_id = nil
  12846. m.addorganization_id = nil
  12847. delete(m.clearedFields, creditusage.FieldOrganizationID)
  12848. }
  12849. // SetNid sets the "nid" field.
  12850. func (m *CreditUsageMutation) SetNid(u uint64) {
  12851. m.nid = &u
  12852. m.addnid = nil
  12853. }
  12854. // Nid returns the value of the "nid" field in the mutation.
  12855. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  12856. v := m.nid
  12857. if v == nil {
  12858. return
  12859. }
  12860. return *v, true
  12861. }
  12862. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  12863. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12865. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  12866. if !m.op.Is(OpUpdateOne) {
  12867. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  12868. }
  12869. if m.id == nil || m.oldValue == nil {
  12870. return v, errors.New("OldNid requires an ID field in the mutation")
  12871. }
  12872. oldValue, err := m.oldValue(ctx)
  12873. if err != nil {
  12874. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  12875. }
  12876. return oldValue.Nid, nil
  12877. }
  12878. // AddNid adds u to the "nid" field.
  12879. func (m *CreditUsageMutation) AddNid(u int64) {
  12880. if m.addnid != nil {
  12881. *m.addnid += u
  12882. } else {
  12883. m.addnid = &u
  12884. }
  12885. }
  12886. // AddedNid returns the value that was added to the "nid" field in this mutation.
  12887. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  12888. v := m.addnid
  12889. if v == nil {
  12890. return
  12891. }
  12892. return *v, true
  12893. }
  12894. // ResetNid resets all changes to the "nid" field.
  12895. func (m *CreditUsageMutation) ResetNid() {
  12896. m.nid = nil
  12897. m.addnid = nil
  12898. }
  12899. // SetReason sets the "reason" field.
  12900. func (m *CreditUsageMutation) SetReason(s string) {
  12901. m.reason = &s
  12902. }
  12903. // Reason returns the value of the "reason" field in the mutation.
  12904. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  12905. v := m.reason
  12906. if v == nil {
  12907. return
  12908. }
  12909. return *v, true
  12910. }
  12911. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  12912. // If the CreditUsage 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 *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  12915. if !m.op.Is(OpUpdateOne) {
  12916. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  12917. }
  12918. if m.id == nil || m.oldValue == nil {
  12919. return v, errors.New("OldReason 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 OldReason: %w", err)
  12924. }
  12925. return oldValue.Reason, nil
  12926. }
  12927. // ResetReason resets all changes to the "reason" field.
  12928. func (m *CreditUsageMutation) ResetReason() {
  12929. m.reason = nil
  12930. }
  12931. // SetOperator sets the "operator" field.
  12932. func (m *CreditUsageMutation) SetOperator(s string) {
  12933. m.operator = &s
  12934. }
  12935. // Operator returns the value of the "operator" field in the mutation.
  12936. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  12937. v := m.operator
  12938. if v == nil {
  12939. return
  12940. }
  12941. return *v, true
  12942. }
  12943. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  12944. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12946. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  12947. if !m.op.Is(OpUpdateOne) {
  12948. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  12949. }
  12950. if m.id == nil || m.oldValue == nil {
  12951. return v, errors.New("OldOperator requires an ID field in the mutation")
  12952. }
  12953. oldValue, err := m.oldValue(ctx)
  12954. if err != nil {
  12955. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  12956. }
  12957. return oldValue.Operator, nil
  12958. }
  12959. // ResetOperator resets all changes to the "operator" field.
  12960. func (m *CreditUsageMutation) ResetOperator() {
  12961. m.operator = nil
  12962. }
  12963. // Where appends a list predicates to the CreditUsageMutation builder.
  12964. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  12965. m.predicates = append(m.predicates, ps...)
  12966. }
  12967. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  12968. // users can use type-assertion to append predicates that do not depend on any generated package.
  12969. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  12970. p := make([]predicate.CreditUsage, len(ps))
  12971. for i := range ps {
  12972. p[i] = ps[i]
  12973. }
  12974. m.Where(p...)
  12975. }
  12976. // Op returns the operation name.
  12977. func (m *CreditUsageMutation) Op() Op {
  12978. return m.op
  12979. }
  12980. // SetOp allows setting the mutation operation.
  12981. func (m *CreditUsageMutation) SetOp(op Op) {
  12982. m.op = op
  12983. }
  12984. // Type returns the node type of this mutation (CreditUsage).
  12985. func (m *CreditUsageMutation) Type() string {
  12986. return m.typ
  12987. }
  12988. // Fields returns all fields that were changed during this mutation. Note that in
  12989. // order to get all numeric fields that were incremented/decremented, call
  12990. // AddedFields().
  12991. func (m *CreditUsageMutation) Fields() []string {
  12992. fields := make([]string, 0, 12)
  12993. if m.created_at != nil {
  12994. fields = append(fields, creditusage.FieldCreatedAt)
  12995. }
  12996. if m.updated_at != nil {
  12997. fields = append(fields, creditusage.FieldUpdatedAt)
  12998. }
  12999. if m.deleted_at != nil {
  13000. fields = append(fields, creditusage.FieldDeletedAt)
  13001. }
  13002. if m.user_id != nil {
  13003. fields = append(fields, creditusage.FieldUserID)
  13004. }
  13005. if m.number != nil {
  13006. fields = append(fields, creditusage.FieldNumber)
  13007. }
  13008. if m.status != nil {
  13009. fields = append(fields, creditusage.FieldStatus)
  13010. }
  13011. if m.ntype != nil {
  13012. fields = append(fields, creditusage.FieldNtype)
  13013. }
  13014. if m.table != nil {
  13015. fields = append(fields, creditusage.FieldTable)
  13016. }
  13017. if m.organization_id != nil {
  13018. fields = append(fields, creditusage.FieldOrganizationID)
  13019. }
  13020. if m.nid != nil {
  13021. fields = append(fields, creditusage.FieldNid)
  13022. }
  13023. if m.reason != nil {
  13024. fields = append(fields, creditusage.FieldReason)
  13025. }
  13026. if m.operator != nil {
  13027. fields = append(fields, creditusage.FieldOperator)
  13028. }
  13029. return fields
  13030. }
  13031. // Field returns the value of a field with the given name. The second boolean
  13032. // return value indicates that this field was not set, or was not defined in the
  13033. // schema.
  13034. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  13035. switch name {
  13036. case creditusage.FieldCreatedAt:
  13037. return m.CreatedAt()
  13038. case creditusage.FieldUpdatedAt:
  13039. return m.UpdatedAt()
  13040. case creditusage.FieldDeletedAt:
  13041. return m.DeletedAt()
  13042. case creditusage.FieldUserID:
  13043. return m.UserID()
  13044. case creditusage.FieldNumber:
  13045. return m.Number()
  13046. case creditusage.FieldStatus:
  13047. return m.Status()
  13048. case creditusage.FieldNtype:
  13049. return m.Ntype()
  13050. case creditusage.FieldTable:
  13051. return m.Table()
  13052. case creditusage.FieldOrganizationID:
  13053. return m.OrganizationID()
  13054. case creditusage.FieldNid:
  13055. return m.Nid()
  13056. case creditusage.FieldReason:
  13057. return m.Reason()
  13058. case creditusage.FieldOperator:
  13059. return m.Operator()
  13060. }
  13061. return nil, false
  13062. }
  13063. // OldField returns the old value of the field from the database. An error is
  13064. // returned if the mutation operation is not UpdateOne, or the query to the
  13065. // database failed.
  13066. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13067. switch name {
  13068. case creditusage.FieldCreatedAt:
  13069. return m.OldCreatedAt(ctx)
  13070. case creditusage.FieldUpdatedAt:
  13071. return m.OldUpdatedAt(ctx)
  13072. case creditusage.FieldDeletedAt:
  13073. return m.OldDeletedAt(ctx)
  13074. case creditusage.FieldUserID:
  13075. return m.OldUserID(ctx)
  13076. case creditusage.FieldNumber:
  13077. return m.OldNumber(ctx)
  13078. case creditusage.FieldStatus:
  13079. return m.OldStatus(ctx)
  13080. case creditusage.FieldNtype:
  13081. return m.OldNtype(ctx)
  13082. case creditusage.FieldTable:
  13083. return m.OldTable(ctx)
  13084. case creditusage.FieldOrganizationID:
  13085. return m.OldOrganizationID(ctx)
  13086. case creditusage.FieldNid:
  13087. return m.OldNid(ctx)
  13088. case creditusage.FieldReason:
  13089. return m.OldReason(ctx)
  13090. case creditusage.FieldOperator:
  13091. return m.OldOperator(ctx)
  13092. }
  13093. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  13094. }
  13095. // SetField sets the value of a field with the given name. It returns an error if
  13096. // the field is not defined in the schema, or if the type mismatched the field
  13097. // type.
  13098. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  13099. switch name {
  13100. case creditusage.FieldCreatedAt:
  13101. v, ok := value.(time.Time)
  13102. if !ok {
  13103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13104. }
  13105. m.SetCreatedAt(v)
  13106. return nil
  13107. case creditusage.FieldUpdatedAt:
  13108. v, ok := value.(time.Time)
  13109. if !ok {
  13110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13111. }
  13112. m.SetUpdatedAt(v)
  13113. return nil
  13114. case creditusage.FieldDeletedAt:
  13115. v, ok := value.(time.Time)
  13116. if !ok {
  13117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13118. }
  13119. m.SetDeletedAt(v)
  13120. return nil
  13121. case creditusage.FieldUserID:
  13122. v, ok := value.(string)
  13123. if !ok {
  13124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13125. }
  13126. m.SetUserID(v)
  13127. return nil
  13128. case creditusage.FieldNumber:
  13129. v, ok := value.(float32)
  13130. if !ok {
  13131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13132. }
  13133. m.SetNumber(v)
  13134. return nil
  13135. case creditusage.FieldStatus:
  13136. v, ok := value.(int)
  13137. if !ok {
  13138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13139. }
  13140. m.SetStatus(v)
  13141. return nil
  13142. case creditusage.FieldNtype:
  13143. v, ok := value.(int)
  13144. if !ok {
  13145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13146. }
  13147. m.SetNtype(v)
  13148. return nil
  13149. case creditusage.FieldTable:
  13150. v, ok := value.(string)
  13151. if !ok {
  13152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13153. }
  13154. m.SetTable(v)
  13155. return nil
  13156. case creditusage.FieldOrganizationID:
  13157. v, ok := value.(uint64)
  13158. if !ok {
  13159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13160. }
  13161. m.SetOrganizationID(v)
  13162. return nil
  13163. case creditusage.FieldNid:
  13164. v, ok := value.(uint64)
  13165. if !ok {
  13166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13167. }
  13168. m.SetNid(v)
  13169. return nil
  13170. case creditusage.FieldReason:
  13171. v, ok := value.(string)
  13172. if !ok {
  13173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13174. }
  13175. m.SetReason(v)
  13176. return nil
  13177. case creditusage.FieldOperator:
  13178. v, ok := value.(string)
  13179. if !ok {
  13180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13181. }
  13182. m.SetOperator(v)
  13183. return nil
  13184. }
  13185. return fmt.Errorf("unknown CreditUsage field %s", name)
  13186. }
  13187. // AddedFields returns all numeric fields that were incremented/decremented during
  13188. // this mutation.
  13189. func (m *CreditUsageMutation) AddedFields() []string {
  13190. var fields []string
  13191. if m.addnumber != nil {
  13192. fields = append(fields, creditusage.FieldNumber)
  13193. }
  13194. if m.addstatus != nil {
  13195. fields = append(fields, creditusage.FieldStatus)
  13196. }
  13197. if m.addntype != nil {
  13198. fields = append(fields, creditusage.FieldNtype)
  13199. }
  13200. if m.addorganization_id != nil {
  13201. fields = append(fields, creditusage.FieldOrganizationID)
  13202. }
  13203. if m.addnid != nil {
  13204. fields = append(fields, creditusage.FieldNid)
  13205. }
  13206. return fields
  13207. }
  13208. // AddedField returns the numeric value that was incremented/decremented on a field
  13209. // with the given name. The second boolean return value indicates that this field
  13210. // was not set, or was not defined in the schema.
  13211. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  13212. switch name {
  13213. case creditusage.FieldNumber:
  13214. return m.AddedNumber()
  13215. case creditusage.FieldStatus:
  13216. return m.AddedStatus()
  13217. case creditusage.FieldNtype:
  13218. return m.AddedNtype()
  13219. case creditusage.FieldOrganizationID:
  13220. return m.AddedOrganizationID()
  13221. case creditusage.FieldNid:
  13222. return m.AddedNid()
  13223. }
  13224. return nil, false
  13225. }
  13226. // AddField adds the value to the field with the given name. It returns an error if
  13227. // the field is not defined in the schema, or if the type mismatched the field
  13228. // type.
  13229. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  13230. switch name {
  13231. case creditusage.FieldNumber:
  13232. v, ok := value.(float32)
  13233. if !ok {
  13234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13235. }
  13236. m.AddNumber(v)
  13237. return nil
  13238. case creditusage.FieldStatus:
  13239. v, ok := value.(int)
  13240. if !ok {
  13241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13242. }
  13243. m.AddStatus(v)
  13244. return nil
  13245. case creditusage.FieldNtype:
  13246. v, ok := value.(int)
  13247. if !ok {
  13248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13249. }
  13250. m.AddNtype(v)
  13251. return nil
  13252. case creditusage.FieldOrganizationID:
  13253. v, ok := value.(int64)
  13254. if !ok {
  13255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13256. }
  13257. m.AddOrganizationID(v)
  13258. return nil
  13259. case creditusage.FieldNid:
  13260. v, ok := value.(int64)
  13261. if !ok {
  13262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13263. }
  13264. m.AddNid(v)
  13265. return nil
  13266. }
  13267. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  13268. }
  13269. // ClearedFields returns all nullable fields that were cleared during this
  13270. // mutation.
  13271. func (m *CreditUsageMutation) ClearedFields() []string {
  13272. var fields []string
  13273. if m.FieldCleared(creditusage.FieldDeletedAt) {
  13274. fields = append(fields, creditusage.FieldDeletedAt)
  13275. }
  13276. if m.FieldCleared(creditusage.FieldUserID) {
  13277. fields = append(fields, creditusage.FieldUserID)
  13278. }
  13279. if m.FieldCleared(creditusage.FieldStatus) {
  13280. fields = append(fields, creditusage.FieldStatus)
  13281. }
  13282. if m.FieldCleared(creditusage.FieldOrganizationID) {
  13283. fields = append(fields, creditusage.FieldOrganizationID)
  13284. }
  13285. return fields
  13286. }
  13287. // FieldCleared returns a boolean indicating if a field with the given name was
  13288. // cleared in this mutation.
  13289. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  13290. _, ok := m.clearedFields[name]
  13291. return ok
  13292. }
  13293. // ClearField clears the value of the field with the given name. It returns an
  13294. // error if the field is not defined in the schema.
  13295. func (m *CreditUsageMutation) ClearField(name string) error {
  13296. switch name {
  13297. case creditusage.FieldDeletedAt:
  13298. m.ClearDeletedAt()
  13299. return nil
  13300. case creditusage.FieldUserID:
  13301. m.ClearUserID()
  13302. return nil
  13303. case creditusage.FieldStatus:
  13304. m.ClearStatus()
  13305. return nil
  13306. case creditusage.FieldOrganizationID:
  13307. m.ClearOrganizationID()
  13308. return nil
  13309. }
  13310. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  13311. }
  13312. // ResetField resets all changes in the mutation for the field with the given name.
  13313. // It returns an error if the field is not defined in the schema.
  13314. func (m *CreditUsageMutation) ResetField(name string) error {
  13315. switch name {
  13316. case creditusage.FieldCreatedAt:
  13317. m.ResetCreatedAt()
  13318. return nil
  13319. case creditusage.FieldUpdatedAt:
  13320. m.ResetUpdatedAt()
  13321. return nil
  13322. case creditusage.FieldDeletedAt:
  13323. m.ResetDeletedAt()
  13324. return nil
  13325. case creditusage.FieldUserID:
  13326. m.ResetUserID()
  13327. return nil
  13328. case creditusage.FieldNumber:
  13329. m.ResetNumber()
  13330. return nil
  13331. case creditusage.FieldStatus:
  13332. m.ResetStatus()
  13333. return nil
  13334. case creditusage.FieldNtype:
  13335. m.ResetNtype()
  13336. return nil
  13337. case creditusage.FieldTable:
  13338. m.ResetTable()
  13339. return nil
  13340. case creditusage.FieldOrganizationID:
  13341. m.ResetOrganizationID()
  13342. return nil
  13343. case creditusage.FieldNid:
  13344. m.ResetNid()
  13345. return nil
  13346. case creditusage.FieldReason:
  13347. m.ResetReason()
  13348. return nil
  13349. case creditusage.FieldOperator:
  13350. m.ResetOperator()
  13351. return nil
  13352. }
  13353. return fmt.Errorf("unknown CreditUsage field %s", name)
  13354. }
  13355. // AddedEdges returns all edge names that were set/added in this mutation.
  13356. func (m *CreditUsageMutation) AddedEdges() []string {
  13357. edges := make([]string, 0, 0)
  13358. return edges
  13359. }
  13360. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13361. // name in this mutation.
  13362. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  13363. return nil
  13364. }
  13365. // RemovedEdges returns all edge names that were removed in this mutation.
  13366. func (m *CreditUsageMutation) RemovedEdges() []string {
  13367. edges := make([]string, 0, 0)
  13368. return edges
  13369. }
  13370. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13371. // the given name in this mutation.
  13372. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  13373. return nil
  13374. }
  13375. // ClearedEdges returns all edge names that were cleared in this mutation.
  13376. func (m *CreditUsageMutation) ClearedEdges() []string {
  13377. edges := make([]string, 0, 0)
  13378. return edges
  13379. }
  13380. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13381. // was cleared in this mutation.
  13382. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  13383. return false
  13384. }
  13385. // ClearEdge clears the value of the edge with the given name. It returns an error
  13386. // if that edge is not defined in the schema.
  13387. func (m *CreditUsageMutation) ClearEdge(name string) error {
  13388. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  13389. }
  13390. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13391. // It returns an error if the edge is not defined in the schema.
  13392. func (m *CreditUsageMutation) ResetEdge(name string) error {
  13393. return fmt.Errorf("unknown CreditUsage edge %s", name)
  13394. }
  13395. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  13396. type EmployeeMutation struct {
  13397. config
  13398. op Op
  13399. typ string
  13400. id *uint64
  13401. created_at *time.Time
  13402. updated_at *time.Time
  13403. deleted_at *time.Time
  13404. title *string
  13405. avatar *string
  13406. tags *string
  13407. hire_count *int
  13408. addhire_count *int
  13409. service_count *int
  13410. addservice_count *int
  13411. achievement_count *int
  13412. addachievement_count *int
  13413. intro *string
  13414. estimate *string
  13415. skill *string
  13416. ability_type *string
  13417. scene *string
  13418. switch_in *string
  13419. video_url *string
  13420. organization_id *uint64
  13421. addorganization_id *int64
  13422. category_id *uint64
  13423. addcategory_id *int64
  13424. api_base *string
  13425. api_key *string
  13426. ai_info *string
  13427. is_vip *int
  13428. addis_vip *int
  13429. chat_url *string
  13430. clearedFields map[string]struct{}
  13431. em_work_experiences map[uint64]struct{}
  13432. removedem_work_experiences map[uint64]struct{}
  13433. clearedem_work_experiences bool
  13434. em_tutorial map[uint64]struct{}
  13435. removedem_tutorial map[uint64]struct{}
  13436. clearedem_tutorial bool
  13437. done bool
  13438. oldValue func(context.Context) (*Employee, error)
  13439. predicates []predicate.Employee
  13440. }
  13441. var _ ent.Mutation = (*EmployeeMutation)(nil)
  13442. // employeeOption allows management of the mutation configuration using functional options.
  13443. type employeeOption func(*EmployeeMutation)
  13444. // newEmployeeMutation creates new mutation for the Employee entity.
  13445. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  13446. m := &EmployeeMutation{
  13447. config: c,
  13448. op: op,
  13449. typ: TypeEmployee,
  13450. clearedFields: make(map[string]struct{}),
  13451. }
  13452. for _, opt := range opts {
  13453. opt(m)
  13454. }
  13455. return m
  13456. }
  13457. // withEmployeeID sets the ID field of the mutation.
  13458. func withEmployeeID(id uint64) employeeOption {
  13459. return func(m *EmployeeMutation) {
  13460. var (
  13461. err error
  13462. once sync.Once
  13463. value *Employee
  13464. )
  13465. m.oldValue = func(ctx context.Context) (*Employee, error) {
  13466. once.Do(func() {
  13467. if m.done {
  13468. err = errors.New("querying old values post mutation is not allowed")
  13469. } else {
  13470. value, err = m.Client().Employee.Get(ctx, id)
  13471. }
  13472. })
  13473. return value, err
  13474. }
  13475. m.id = &id
  13476. }
  13477. }
  13478. // withEmployee sets the old Employee of the mutation.
  13479. func withEmployee(node *Employee) employeeOption {
  13480. return func(m *EmployeeMutation) {
  13481. m.oldValue = func(context.Context) (*Employee, error) {
  13482. return node, nil
  13483. }
  13484. m.id = &node.ID
  13485. }
  13486. }
  13487. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13488. // executed in a transaction (ent.Tx), a transactional client is returned.
  13489. func (m EmployeeMutation) Client() *Client {
  13490. client := &Client{config: m.config}
  13491. client.init()
  13492. return client
  13493. }
  13494. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13495. // it returns an error otherwise.
  13496. func (m EmployeeMutation) Tx() (*Tx, error) {
  13497. if _, ok := m.driver.(*txDriver); !ok {
  13498. return nil, errors.New("ent: mutation is not running in a transaction")
  13499. }
  13500. tx := &Tx{config: m.config}
  13501. tx.init()
  13502. return tx, nil
  13503. }
  13504. // SetID sets the value of the id field. Note that this
  13505. // operation is only accepted on creation of Employee entities.
  13506. func (m *EmployeeMutation) SetID(id uint64) {
  13507. m.id = &id
  13508. }
  13509. // ID returns the ID value in the mutation. Note that the ID is only available
  13510. // if it was provided to the builder or after it was returned from the database.
  13511. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  13512. if m.id == nil {
  13513. return
  13514. }
  13515. return *m.id, true
  13516. }
  13517. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13518. // That means, if the mutation is applied within a transaction with an isolation level such
  13519. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13520. // or updated by the mutation.
  13521. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  13522. switch {
  13523. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13524. id, exists := m.ID()
  13525. if exists {
  13526. return []uint64{id}, nil
  13527. }
  13528. fallthrough
  13529. case m.op.Is(OpUpdate | OpDelete):
  13530. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  13531. default:
  13532. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13533. }
  13534. }
  13535. // SetCreatedAt sets the "created_at" field.
  13536. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  13537. m.created_at = &t
  13538. }
  13539. // CreatedAt returns the value of the "created_at" field in the mutation.
  13540. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  13541. v := m.created_at
  13542. if v == nil {
  13543. return
  13544. }
  13545. return *v, true
  13546. }
  13547. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  13548. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13550. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13551. if !m.op.Is(OpUpdateOne) {
  13552. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13553. }
  13554. if m.id == nil || m.oldValue == nil {
  13555. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13556. }
  13557. oldValue, err := m.oldValue(ctx)
  13558. if err != nil {
  13559. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13560. }
  13561. return oldValue.CreatedAt, nil
  13562. }
  13563. // ResetCreatedAt resets all changes to the "created_at" field.
  13564. func (m *EmployeeMutation) ResetCreatedAt() {
  13565. m.created_at = nil
  13566. }
  13567. // SetUpdatedAt sets the "updated_at" field.
  13568. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  13569. m.updated_at = &t
  13570. }
  13571. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13572. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  13573. v := m.updated_at
  13574. if v == nil {
  13575. return
  13576. }
  13577. return *v, true
  13578. }
  13579. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  13580. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13582. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13583. if !m.op.Is(OpUpdateOne) {
  13584. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13585. }
  13586. if m.id == nil || m.oldValue == nil {
  13587. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13588. }
  13589. oldValue, err := m.oldValue(ctx)
  13590. if err != nil {
  13591. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13592. }
  13593. return oldValue.UpdatedAt, nil
  13594. }
  13595. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13596. func (m *EmployeeMutation) ResetUpdatedAt() {
  13597. m.updated_at = nil
  13598. }
  13599. // SetDeletedAt sets the "deleted_at" field.
  13600. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  13601. m.deleted_at = &t
  13602. }
  13603. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13604. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  13605. v := m.deleted_at
  13606. if v == nil {
  13607. return
  13608. }
  13609. return *v, true
  13610. }
  13611. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  13612. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13614. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13615. if !m.op.Is(OpUpdateOne) {
  13616. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13617. }
  13618. if m.id == nil || m.oldValue == nil {
  13619. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13620. }
  13621. oldValue, err := m.oldValue(ctx)
  13622. if err != nil {
  13623. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13624. }
  13625. return oldValue.DeletedAt, nil
  13626. }
  13627. // ClearDeletedAt clears the value of the "deleted_at" field.
  13628. func (m *EmployeeMutation) ClearDeletedAt() {
  13629. m.deleted_at = nil
  13630. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  13631. }
  13632. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13633. func (m *EmployeeMutation) DeletedAtCleared() bool {
  13634. _, ok := m.clearedFields[employee.FieldDeletedAt]
  13635. return ok
  13636. }
  13637. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13638. func (m *EmployeeMutation) ResetDeletedAt() {
  13639. m.deleted_at = nil
  13640. delete(m.clearedFields, employee.FieldDeletedAt)
  13641. }
  13642. // SetTitle sets the "title" field.
  13643. func (m *EmployeeMutation) SetTitle(s string) {
  13644. m.title = &s
  13645. }
  13646. // Title returns the value of the "title" field in the mutation.
  13647. func (m *EmployeeMutation) Title() (r string, exists bool) {
  13648. v := m.title
  13649. if v == nil {
  13650. return
  13651. }
  13652. return *v, true
  13653. }
  13654. // OldTitle returns the old "title" field's value of the Employee entity.
  13655. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13657. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  13658. if !m.op.Is(OpUpdateOne) {
  13659. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13660. }
  13661. if m.id == nil || m.oldValue == nil {
  13662. return v, errors.New("OldTitle requires an ID field in the mutation")
  13663. }
  13664. oldValue, err := m.oldValue(ctx)
  13665. if err != nil {
  13666. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13667. }
  13668. return oldValue.Title, nil
  13669. }
  13670. // ResetTitle resets all changes to the "title" field.
  13671. func (m *EmployeeMutation) ResetTitle() {
  13672. m.title = nil
  13673. }
  13674. // SetAvatar sets the "avatar" field.
  13675. func (m *EmployeeMutation) SetAvatar(s string) {
  13676. m.avatar = &s
  13677. }
  13678. // Avatar returns the value of the "avatar" field in the mutation.
  13679. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  13680. v := m.avatar
  13681. if v == nil {
  13682. return
  13683. }
  13684. return *v, true
  13685. }
  13686. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  13687. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13689. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  13690. if !m.op.Is(OpUpdateOne) {
  13691. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  13692. }
  13693. if m.id == nil || m.oldValue == nil {
  13694. return v, errors.New("OldAvatar requires an ID field in the mutation")
  13695. }
  13696. oldValue, err := m.oldValue(ctx)
  13697. if err != nil {
  13698. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  13699. }
  13700. return oldValue.Avatar, nil
  13701. }
  13702. // ResetAvatar resets all changes to the "avatar" field.
  13703. func (m *EmployeeMutation) ResetAvatar() {
  13704. m.avatar = nil
  13705. }
  13706. // SetTags sets the "tags" field.
  13707. func (m *EmployeeMutation) SetTags(s string) {
  13708. m.tags = &s
  13709. }
  13710. // Tags returns the value of the "tags" field in the mutation.
  13711. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  13712. v := m.tags
  13713. if v == nil {
  13714. return
  13715. }
  13716. return *v, true
  13717. }
  13718. // OldTags returns the old "tags" field's value of the Employee entity.
  13719. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13721. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  13722. if !m.op.Is(OpUpdateOne) {
  13723. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  13724. }
  13725. if m.id == nil || m.oldValue == nil {
  13726. return v, errors.New("OldTags requires an ID field in the mutation")
  13727. }
  13728. oldValue, err := m.oldValue(ctx)
  13729. if err != nil {
  13730. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  13731. }
  13732. return oldValue.Tags, nil
  13733. }
  13734. // ResetTags resets all changes to the "tags" field.
  13735. func (m *EmployeeMutation) ResetTags() {
  13736. m.tags = nil
  13737. }
  13738. // SetHireCount sets the "hire_count" field.
  13739. func (m *EmployeeMutation) SetHireCount(i int) {
  13740. m.hire_count = &i
  13741. m.addhire_count = nil
  13742. }
  13743. // HireCount returns the value of the "hire_count" field in the mutation.
  13744. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  13745. v := m.hire_count
  13746. if v == nil {
  13747. return
  13748. }
  13749. return *v, true
  13750. }
  13751. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  13752. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13754. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  13755. if !m.op.Is(OpUpdateOne) {
  13756. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  13757. }
  13758. if m.id == nil || m.oldValue == nil {
  13759. return v, errors.New("OldHireCount requires an ID field in the mutation")
  13760. }
  13761. oldValue, err := m.oldValue(ctx)
  13762. if err != nil {
  13763. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  13764. }
  13765. return oldValue.HireCount, nil
  13766. }
  13767. // AddHireCount adds i to the "hire_count" field.
  13768. func (m *EmployeeMutation) AddHireCount(i int) {
  13769. if m.addhire_count != nil {
  13770. *m.addhire_count += i
  13771. } else {
  13772. m.addhire_count = &i
  13773. }
  13774. }
  13775. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  13776. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  13777. v := m.addhire_count
  13778. if v == nil {
  13779. return
  13780. }
  13781. return *v, true
  13782. }
  13783. // ResetHireCount resets all changes to the "hire_count" field.
  13784. func (m *EmployeeMutation) ResetHireCount() {
  13785. m.hire_count = nil
  13786. m.addhire_count = nil
  13787. }
  13788. // SetServiceCount sets the "service_count" field.
  13789. func (m *EmployeeMutation) SetServiceCount(i int) {
  13790. m.service_count = &i
  13791. m.addservice_count = nil
  13792. }
  13793. // ServiceCount returns the value of the "service_count" field in the mutation.
  13794. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  13795. v := m.service_count
  13796. if v == nil {
  13797. return
  13798. }
  13799. return *v, true
  13800. }
  13801. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  13802. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13804. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  13805. if !m.op.Is(OpUpdateOne) {
  13806. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  13807. }
  13808. if m.id == nil || m.oldValue == nil {
  13809. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  13810. }
  13811. oldValue, err := m.oldValue(ctx)
  13812. if err != nil {
  13813. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  13814. }
  13815. return oldValue.ServiceCount, nil
  13816. }
  13817. // AddServiceCount adds i to the "service_count" field.
  13818. func (m *EmployeeMutation) AddServiceCount(i int) {
  13819. if m.addservice_count != nil {
  13820. *m.addservice_count += i
  13821. } else {
  13822. m.addservice_count = &i
  13823. }
  13824. }
  13825. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  13826. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  13827. v := m.addservice_count
  13828. if v == nil {
  13829. return
  13830. }
  13831. return *v, true
  13832. }
  13833. // ResetServiceCount resets all changes to the "service_count" field.
  13834. func (m *EmployeeMutation) ResetServiceCount() {
  13835. m.service_count = nil
  13836. m.addservice_count = nil
  13837. }
  13838. // SetAchievementCount sets the "achievement_count" field.
  13839. func (m *EmployeeMutation) SetAchievementCount(i int) {
  13840. m.achievement_count = &i
  13841. m.addachievement_count = nil
  13842. }
  13843. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  13844. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  13845. v := m.achievement_count
  13846. if v == nil {
  13847. return
  13848. }
  13849. return *v, true
  13850. }
  13851. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  13852. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13854. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  13855. if !m.op.Is(OpUpdateOne) {
  13856. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  13857. }
  13858. if m.id == nil || m.oldValue == nil {
  13859. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  13860. }
  13861. oldValue, err := m.oldValue(ctx)
  13862. if err != nil {
  13863. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  13864. }
  13865. return oldValue.AchievementCount, nil
  13866. }
  13867. // AddAchievementCount adds i to the "achievement_count" field.
  13868. func (m *EmployeeMutation) AddAchievementCount(i int) {
  13869. if m.addachievement_count != nil {
  13870. *m.addachievement_count += i
  13871. } else {
  13872. m.addachievement_count = &i
  13873. }
  13874. }
  13875. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  13876. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  13877. v := m.addachievement_count
  13878. if v == nil {
  13879. return
  13880. }
  13881. return *v, true
  13882. }
  13883. // ResetAchievementCount resets all changes to the "achievement_count" field.
  13884. func (m *EmployeeMutation) ResetAchievementCount() {
  13885. m.achievement_count = nil
  13886. m.addachievement_count = nil
  13887. }
  13888. // SetIntro sets the "intro" field.
  13889. func (m *EmployeeMutation) SetIntro(s string) {
  13890. m.intro = &s
  13891. }
  13892. // Intro returns the value of the "intro" field in the mutation.
  13893. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  13894. v := m.intro
  13895. if v == nil {
  13896. return
  13897. }
  13898. return *v, true
  13899. }
  13900. // OldIntro returns the old "intro" field's value of the Employee entity.
  13901. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13903. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  13904. if !m.op.Is(OpUpdateOne) {
  13905. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  13906. }
  13907. if m.id == nil || m.oldValue == nil {
  13908. return v, errors.New("OldIntro requires an ID field in the mutation")
  13909. }
  13910. oldValue, err := m.oldValue(ctx)
  13911. if err != nil {
  13912. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  13913. }
  13914. return oldValue.Intro, nil
  13915. }
  13916. // ResetIntro resets all changes to the "intro" field.
  13917. func (m *EmployeeMutation) ResetIntro() {
  13918. m.intro = nil
  13919. }
  13920. // SetEstimate sets the "estimate" field.
  13921. func (m *EmployeeMutation) SetEstimate(s string) {
  13922. m.estimate = &s
  13923. }
  13924. // Estimate returns the value of the "estimate" field in the mutation.
  13925. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  13926. v := m.estimate
  13927. if v == nil {
  13928. return
  13929. }
  13930. return *v, true
  13931. }
  13932. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  13933. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13935. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  13936. if !m.op.Is(OpUpdateOne) {
  13937. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  13938. }
  13939. if m.id == nil || m.oldValue == nil {
  13940. return v, errors.New("OldEstimate requires an ID field in the mutation")
  13941. }
  13942. oldValue, err := m.oldValue(ctx)
  13943. if err != nil {
  13944. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  13945. }
  13946. return oldValue.Estimate, nil
  13947. }
  13948. // ResetEstimate resets all changes to the "estimate" field.
  13949. func (m *EmployeeMutation) ResetEstimate() {
  13950. m.estimate = nil
  13951. }
  13952. // SetSkill sets the "skill" field.
  13953. func (m *EmployeeMutation) SetSkill(s string) {
  13954. m.skill = &s
  13955. }
  13956. // Skill returns the value of the "skill" field in the mutation.
  13957. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  13958. v := m.skill
  13959. if v == nil {
  13960. return
  13961. }
  13962. return *v, true
  13963. }
  13964. // OldSkill returns the old "skill" field's value of the Employee entity.
  13965. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13967. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  13968. if !m.op.Is(OpUpdateOne) {
  13969. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  13970. }
  13971. if m.id == nil || m.oldValue == nil {
  13972. return v, errors.New("OldSkill requires an ID field in the mutation")
  13973. }
  13974. oldValue, err := m.oldValue(ctx)
  13975. if err != nil {
  13976. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  13977. }
  13978. return oldValue.Skill, nil
  13979. }
  13980. // ResetSkill resets all changes to the "skill" field.
  13981. func (m *EmployeeMutation) ResetSkill() {
  13982. m.skill = nil
  13983. }
  13984. // SetAbilityType sets the "ability_type" field.
  13985. func (m *EmployeeMutation) SetAbilityType(s string) {
  13986. m.ability_type = &s
  13987. }
  13988. // AbilityType returns the value of the "ability_type" field in the mutation.
  13989. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  13990. v := m.ability_type
  13991. if v == nil {
  13992. return
  13993. }
  13994. return *v, true
  13995. }
  13996. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  13997. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13999. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  14000. if !m.op.Is(OpUpdateOne) {
  14001. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  14002. }
  14003. if m.id == nil || m.oldValue == nil {
  14004. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  14005. }
  14006. oldValue, err := m.oldValue(ctx)
  14007. if err != nil {
  14008. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  14009. }
  14010. return oldValue.AbilityType, nil
  14011. }
  14012. // ResetAbilityType resets all changes to the "ability_type" field.
  14013. func (m *EmployeeMutation) ResetAbilityType() {
  14014. m.ability_type = nil
  14015. }
  14016. // SetScene sets the "scene" field.
  14017. func (m *EmployeeMutation) SetScene(s string) {
  14018. m.scene = &s
  14019. }
  14020. // Scene returns the value of the "scene" field in the mutation.
  14021. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  14022. v := m.scene
  14023. if v == nil {
  14024. return
  14025. }
  14026. return *v, true
  14027. }
  14028. // OldScene returns the old "scene" field's value of the Employee entity.
  14029. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14031. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  14032. if !m.op.Is(OpUpdateOne) {
  14033. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  14034. }
  14035. if m.id == nil || m.oldValue == nil {
  14036. return v, errors.New("OldScene requires an ID field in the mutation")
  14037. }
  14038. oldValue, err := m.oldValue(ctx)
  14039. if err != nil {
  14040. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  14041. }
  14042. return oldValue.Scene, nil
  14043. }
  14044. // ResetScene resets all changes to the "scene" field.
  14045. func (m *EmployeeMutation) ResetScene() {
  14046. m.scene = nil
  14047. }
  14048. // SetSwitchIn sets the "switch_in" field.
  14049. func (m *EmployeeMutation) SetSwitchIn(s string) {
  14050. m.switch_in = &s
  14051. }
  14052. // SwitchIn returns the value of the "switch_in" field in the mutation.
  14053. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  14054. v := m.switch_in
  14055. if v == nil {
  14056. return
  14057. }
  14058. return *v, true
  14059. }
  14060. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  14061. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14063. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  14064. if !m.op.Is(OpUpdateOne) {
  14065. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  14066. }
  14067. if m.id == nil || m.oldValue == nil {
  14068. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  14069. }
  14070. oldValue, err := m.oldValue(ctx)
  14071. if err != nil {
  14072. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  14073. }
  14074. return oldValue.SwitchIn, nil
  14075. }
  14076. // ResetSwitchIn resets all changes to the "switch_in" field.
  14077. func (m *EmployeeMutation) ResetSwitchIn() {
  14078. m.switch_in = nil
  14079. }
  14080. // SetVideoURL sets the "video_url" field.
  14081. func (m *EmployeeMutation) SetVideoURL(s string) {
  14082. m.video_url = &s
  14083. }
  14084. // VideoURL returns the value of the "video_url" field in the mutation.
  14085. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  14086. v := m.video_url
  14087. if v == nil {
  14088. return
  14089. }
  14090. return *v, true
  14091. }
  14092. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  14093. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14095. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  14096. if !m.op.Is(OpUpdateOne) {
  14097. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  14098. }
  14099. if m.id == nil || m.oldValue == nil {
  14100. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  14101. }
  14102. oldValue, err := m.oldValue(ctx)
  14103. if err != nil {
  14104. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  14105. }
  14106. return oldValue.VideoURL, nil
  14107. }
  14108. // ResetVideoURL resets all changes to the "video_url" field.
  14109. func (m *EmployeeMutation) ResetVideoURL() {
  14110. m.video_url = nil
  14111. }
  14112. // SetOrganizationID sets the "organization_id" field.
  14113. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  14114. m.organization_id = &u
  14115. m.addorganization_id = nil
  14116. }
  14117. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14118. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  14119. v := m.organization_id
  14120. if v == nil {
  14121. return
  14122. }
  14123. return *v, true
  14124. }
  14125. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  14126. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14128. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14129. if !m.op.Is(OpUpdateOne) {
  14130. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14131. }
  14132. if m.id == nil || m.oldValue == nil {
  14133. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14134. }
  14135. oldValue, err := m.oldValue(ctx)
  14136. if err != nil {
  14137. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14138. }
  14139. return oldValue.OrganizationID, nil
  14140. }
  14141. // AddOrganizationID adds u to the "organization_id" field.
  14142. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  14143. if m.addorganization_id != nil {
  14144. *m.addorganization_id += u
  14145. } else {
  14146. m.addorganization_id = &u
  14147. }
  14148. }
  14149. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14150. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  14151. v := m.addorganization_id
  14152. if v == nil {
  14153. return
  14154. }
  14155. return *v, true
  14156. }
  14157. // ResetOrganizationID resets all changes to the "organization_id" field.
  14158. func (m *EmployeeMutation) ResetOrganizationID() {
  14159. m.organization_id = nil
  14160. m.addorganization_id = nil
  14161. }
  14162. // SetCategoryID sets the "category_id" field.
  14163. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  14164. m.category_id = &u
  14165. m.addcategory_id = nil
  14166. }
  14167. // CategoryID returns the value of the "category_id" field in the mutation.
  14168. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  14169. v := m.category_id
  14170. if v == nil {
  14171. return
  14172. }
  14173. return *v, true
  14174. }
  14175. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  14176. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14178. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  14179. if !m.op.Is(OpUpdateOne) {
  14180. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  14181. }
  14182. if m.id == nil || m.oldValue == nil {
  14183. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  14184. }
  14185. oldValue, err := m.oldValue(ctx)
  14186. if err != nil {
  14187. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  14188. }
  14189. return oldValue.CategoryID, nil
  14190. }
  14191. // AddCategoryID adds u to the "category_id" field.
  14192. func (m *EmployeeMutation) AddCategoryID(u int64) {
  14193. if m.addcategory_id != nil {
  14194. *m.addcategory_id += u
  14195. } else {
  14196. m.addcategory_id = &u
  14197. }
  14198. }
  14199. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  14200. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  14201. v := m.addcategory_id
  14202. if v == nil {
  14203. return
  14204. }
  14205. return *v, true
  14206. }
  14207. // ResetCategoryID resets all changes to the "category_id" field.
  14208. func (m *EmployeeMutation) ResetCategoryID() {
  14209. m.category_id = nil
  14210. m.addcategory_id = nil
  14211. }
  14212. // SetAPIBase sets the "api_base" field.
  14213. func (m *EmployeeMutation) SetAPIBase(s string) {
  14214. m.api_base = &s
  14215. }
  14216. // APIBase returns the value of the "api_base" field in the mutation.
  14217. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  14218. v := m.api_base
  14219. if v == nil {
  14220. return
  14221. }
  14222. return *v, true
  14223. }
  14224. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  14225. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14227. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  14228. if !m.op.Is(OpUpdateOne) {
  14229. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  14230. }
  14231. if m.id == nil || m.oldValue == nil {
  14232. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  14233. }
  14234. oldValue, err := m.oldValue(ctx)
  14235. if err != nil {
  14236. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  14237. }
  14238. return oldValue.APIBase, nil
  14239. }
  14240. // ResetAPIBase resets all changes to the "api_base" field.
  14241. func (m *EmployeeMutation) ResetAPIBase() {
  14242. m.api_base = nil
  14243. }
  14244. // SetAPIKey sets the "api_key" field.
  14245. func (m *EmployeeMutation) SetAPIKey(s string) {
  14246. m.api_key = &s
  14247. }
  14248. // APIKey returns the value of the "api_key" field in the mutation.
  14249. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  14250. v := m.api_key
  14251. if v == nil {
  14252. return
  14253. }
  14254. return *v, true
  14255. }
  14256. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  14257. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14259. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  14260. if !m.op.Is(OpUpdateOne) {
  14261. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  14262. }
  14263. if m.id == nil || m.oldValue == nil {
  14264. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  14265. }
  14266. oldValue, err := m.oldValue(ctx)
  14267. if err != nil {
  14268. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  14269. }
  14270. return oldValue.APIKey, nil
  14271. }
  14272. // ResetAPIKey resets all changes to the "api_key" field.
  14273. func (m *EmployeeMutation) ResetAPIKey() {
  14274. m.api_key = nil
  14275. }
  14276. // SetAiInfo sets the "ai_info" field.
  14277. func (m *EmployeeMutation) SetAiInfo(s string) {
  14278. m.ai_info = &s
  14279. }
  14280. // AiInfo returns the value of the "ai_info" field in the mutation.
  14281. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  14282. v := m.ai_info
  14283. if v == nil {
  14284. return
  14285. }
  14286. return *v, true
  14287. }
  14288. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  14289. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14291. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  14292. if !m.op.Is(OpUpdateOne) {
  14293. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  14294. }
  14295. if m.id == nil || m.oldValue == nil {
  14296. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  14297. }
  14298. oldValue, err := m.oldValue(ctx)
  14299. if err != nil {
  14300. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  14301. }
  14302. return oldValue.AiInfo, nil
  14303. }
  14304. // ClearAiInfo clears the value of the "ai_info" field.
  14305. func (m *EmployeeMutation) ClearAiInfo() {
  14306. m.ai_info = nil
  14307. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  14308. }
  14309. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  14310. func (m *EmployeeMutation) AiInfoCleared() bool {
  14311. _, ok := m.clearedFields[employee.FieldAiInfo]
  14312. return ok
  14313. }
  14314. // ResetAiInfo resets all changes to the "ai_info" field.
  14315. func (m *EmployeeMutation) ResetAiInfo() {
  14316. m.ai_info = nil
  14317. delete(m.clearedFields, employee.FieldAiInfo)
  14318. }
  14319. // SetIsVip sets the "is_vip" field.
  14320. func (m *EmployeeMutation) SetIsVip(i int) {
  14321. m.is_vip = &i
  14322. m.addis_vip = nil
  14323. }
  14324. // IsVip returns the value of the "is_vip" field in the mutation.
  14325. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  14326. v := m.is_vip
  14327. if v == nil {
  14328. return
  14329. }
  14330. return *v, true
  14331. }
  14332. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  14333. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14335. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  14336. if !m.op.Is(OpUpdateOne) {
  14337. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  14338. }
  14339. if m.id == nil || m.oldValue == nil {
  14340. return v, errors.New("OldIsVip requires an ID field in the mutation")
  14341. }
  14342. oldValue, err := m.oldValue(ctx)
  14343. if err != nil {
  14344. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  14345. }
  14346. return oldValue.IsVip, nil
  14347. }
  14348. // AddIsVip adds i to the "is_vip" field.
  14349. func (m *EmployeeMutation) AddIsVip(i int) {
  14350. if m.addis_vip != nil {
  14351. *m.addis_vip += i
  14352. } else {
  14353. m.addis_vip = &i
  14354. }
  14355. }
  14356. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  14357. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  14358. v := m.addis_vip
  14359. if v == nil {
  14360. return
  14361. }
  14362. return *v, true
  14363. }
  14364. // ResetIsVip resets all changes to the "is_vip" field.
  14365. func (m *EmployeeMutation) ResetIsVip() {
  14366. m.is_vip = nil
  14367. m.addis_vip = nil
  14368. }
  14369. // SetChatURL sets the "chat_url" field.
  14370. func (m *EmployeeMutation) SetChatURL(s string) {
  14371. m.chat_url = &s
  14372. }
  14373. // ChatURL returns the value of the "chat_url" field in the mutation.
  14374. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  14375. v := m.chat_url
  14376. if v == nil {
  14377. return
  14378. }
  14379. return *v, true
  14380. }
  14381. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  14382. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14384. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  14385. if !m.op.Is(OpUpdateOne) {
  14386. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  14387. }
  14388. if m.id == nil || m.oldValue == nil {
  14389. return v, errors.New("OldChatURL requires an ID field in the mutation")
  14390. }
  14391. oldValue, err := m.oldValue(ctx)
  14392. if err != nil {
  14393. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  14394. }
  14395. return oldValue.ChatURL, nil
  14396. }
  14397. // ResetChatURL resets all changes to the "chat_url" field.
  14398. func (m *EmployeeMutation) ResetChatURL() {
  14399. m.chat_url = nil
  14400. }
  14401. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  14402. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  14403. if m.em_work_experiences == nil {
  14404. m.em_work_experiences = make(map[uint64]struct{})
  14405. }
  14406. for i := range ids {
  14407. m.em_work_experiences[ids[i]] = struct{}{}
  14408. }
  14409. }
  14410. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  14411. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  14412. m.clearedem_work_experiences = true
  14413. }
  14414. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  14415. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  14416. return m.clearedem_work_experiences
  14417. }
  14418. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  14419. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  14420. if m.removedem_work_experiences == nil {
  14421. m.removedem_work_experiences = make(map[uint64]struct{})
  14422. }
  14423. for i := range ids {
  14424. delete(m.em_work_experiences, ids[i])
  14425. m.removedem_work_experiences[ids[i]] = struct{}{}
  14426. }
  14427. }
  14428. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  14429. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  14430. for id := range m.removedem_work_experiences {
  14431. ids = append(ids, id)
  14432. }
  14433. return
  14434. }
  14435. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  14436. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  14437. for id := range m.em_work_experiences {
  14438. ids = append(ids, id)
  14439. }
  14440. return
  14441. }
  14442. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  14443. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  14444. m.em_work_experiences = nil
  14445. m.clearedem_work_experiences = false
  14446. m.removedem_work_experiences = nil
  14447. }
  14448. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  14449. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  14450. if m.em_tutorial == nil {
  14451. m.em_tutorial = make(map[uint64]struct{})
  14452. }
  14453. for i := range ids {
  14454. m.em_tutorial[ids[i]] = struct{}{}
  14455. }
  14456. }
  14457. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  14458. func (m *EmployeeMutation) ClearEmTutorial() {
  14459. m.clearedem_tutorial = true
  14460. }
  14461. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  14462. func (m *EmployeeMutation) EmTutorialCleared() bool {
  14463. return m.clearedem_tutorial
  14464. }
  14465. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  14466. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  14467. if m.removedem_tutorial == nil {
  14468. m.removedem_tutorial = make(map[uint64]struct{})
  14469. }
  14470. for i := range ids {
  14471. delete(m.em_tutorial, ids[i])
  14472. m.removedem_tutorial[ids[i]] = struct{}{}
  14473. }
  14474. }
  14475. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  14476. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  14477. for id := range m.removedem_tutorial {
  14478. ids = append(ids, id)
  14479. }
  14480. return
  14481. }
  14482. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  14483. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  14484. for id := range m.em_tutorial {
  14485. ids = append(ids, id)
  14486. }
  14487. return
  14488. }
  14489. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  14490. func (m *EmployeeMutation) ResetEmTutorial() {
  14491. m.em_tutorial = nil
  14492. m.clearedem_tutorial = false
  14493. m.removedem_tutorial = nil
  14494. }
  14495. // Where appends a list predicates to the EmployeeMutation builder.
  14496. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  14497. m.predicates = append(m.predicates, ps...)
  14498. }
  14499. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  14500. // users can use type-assertion to append predicates that do not depend on any generated package.
  14501. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  14502. p := make([]predicate.Employee, len(ps))
  14503. for i := range ps {
  14504. p[i] = ps[i]
  14505. }
  14506. m.Where(p...)
  14507. }
  14508. // Op returns the operation name.
  14509. func (m *EmployeeMutation) Op() Op {
  14510. return m.op
  14511. }
  14512. // SetOp allows setting the mutation operation.
  14513. func (m *EmployeeMutation) SetOp(op Op) {
  14514. m.op = op
  14515. }
  14516. // Type returns the node type of this mutation (Employee).
  14517. func (m *EmployeeMutation) Type() string {
  14518. return m.typ
  14519. }
  14520. // Fields returns all fields that were changed during this mutation. Note that in
  14521. // order to get all numeric fields that were incremented/decremented, call
  14522. // AddedFields().
  14523. func (m *EmployeeMutation) Fields() []string {
  14524. fields := make([]string, 0, 23)
  14525. if m.created_at != nil {
  14526. fields = append(fields, employee.FieldCreatedAt)
  14527. }
  14528. if m.updated_at != nil {
  14529. fields = append(fields, employee.FieldUpdatedAt)
  14530. }
  14531. if m.deleted_at != nil {
  14532. fields = append(fields, employee.FieldDeletedAt)
  14533. }
  14534. if m.title != nil {
  14535. fields = append(fields, employee.FieldTitle)
  14536. }
  14537. if m.avatar != nil {
  14538. fields = append(fields, employee.FieldAvatar)
  14539. }
  14540. if m.tags != nil {
  14541. fields = append(fields, employee.FieldTags)
  14542. }
  14543. if m.hire_count != nil {
  14544. fields = append(fields, employee.FieldHireCount)
  14545. }
  14546. if m.service_count != nil {
  14547. fields = append(fields, employee.FieldServiceCount)
  14548. }
  14549. if m.achievement_count != nil {
  14550. fields = append(fields, employee.FieldAchievementCount)
  14551. }
  14552. if m.intro != nil {
  14553. fields = append(fields, employee.FieldIntro)
  14554. }
  14555. if m.estimate != nil {
  14556. fields = append(fields, employee.FieldEstimate)
  14557. }
  14558. if m.skill != nil {
  14559. fields = append(fields, employee.FieldSkill)
  14560. }
  14561. if m.ability_type != nil {
  14562. fields = append(fields, employee.FieldAbilityType)
  14563. }
  14564. if m.scene != nil {
  14565. fields = append(fields, employee.FieldScene)
  14566. }
  14567. if m.switch_in != nil {
  14568. fields = append(fields, employee.FieldSwitchIn)
  14569. }
  14570. if m.video_url != nil {
  14571. fields = append(fields, employee.FieldVideoURL)
  14572. }
  14573. if m.organization_id != nil {
  14574. fields = append(fields, employee.FieldOrganizationID)
  14575. }
  14576. if m.category_id != nil {
  14577. fields = append(fields, employee.FieldCategoryID)
  14578. }
  14579. if m.api_base != nil {
  14580. fields = append(fields, employee.FieldAPIBase)
  14581. }
  14582. if m.api_key != nil {
  14583. fields = append(fields, employee.FieldAPIKey)
  14584. }
  14585. if m.ai_info != nil {
  14586. fields = append(fields, employee.FieldAiInfo)
  14587. }
  14588. if m.is_vip != nil {
  14589. fields = append(fields, employee.FieldIsVip)
  14590. }
  14591. if m.chat_url != nil {
  14592. fields = append(fields, employee.FieldChatURL)
  14593. }
  14594. return fields
  14595. }
  14596. // Field returns the value of a field with the given name. The second boolean
  14597. // return value indicates that this field was not set, or was not defined in the
  14598. // schema.
  14599. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  14600. switch name {
  14601. case employee.FieldCreatedAt:
  14602. return m.CreatedAt()
  14603. case employee.FieldUpdatedAt:
  14604. return m.UpdatedAt()
  14605. case employee.FieldDeletedAt:
  14606. return m.DeletedAt()
  14607. case employee.FieldTitle:
  14608. return m.Title()
  14609. case employee.FieldAvatar:
  14610. return m.Avatar()
  14611. case employee.FieldTags:
  14612. return m.Tags()
  14613. case employee.FieldHireCount:
  14614. return m.HireCount()
  14615. case employee.FieldServiceCount:
  14616. return m.ServiceCount()
  14617. case employee.FieldAchievementCount:
  14618. return m.AchievementCount()
  14619. case employee.FieldIntro:
  14620. return m.Intro()
  14621. case employee.FieldEstimate:
  14622. return m.Estimate()
  14623. case employee.FieldSkill:
  14624. return m.Skill()
  14625. case employee.FieldAbilityType:
  14626. return m.AbilityType()
  14627. case employee.FieldScene:
  14628. return m.Scene()
  14629. case employee.FieldSwitchIn:
  14630. return m.SwitchIn()
  14631. case employee.FieldVideoURL:
  14632. return m.VideoURL()
  14633. case employee.FieldOrganizationID:
  14634. return m.OrganizationID()
  14635. case employee.FieldCategoryID:
  14636. return m.CategoryID()
  14637. case employee.FieldAPIBase:
  14638. return m.APIBase()
  14639. case employee.FieldAPIKey:
  14640. return m.APIKey()
  14641. case employee.FieldAiInfo:
  14642. return m.AiInfo()
  14643. case employee.FieldIsVip:
  14644. return m.IsVip()
  14645. case employee.FieldChatURL:
  14646. return m.ChatURL()
  14647. }
  14648. return nil, false
  14649. }
  14650. // OldField returns the old value of the field from the database. An error is
  14651. // returned if the mutation operation is not UpdateOne, or the query to the
  14652. // database failed.
  14653. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14654. switch name {
  14655. case employee.FieldCreatedAt:
  14656. return m.OldCreatedAt(ctx)
  14657. case employee.FieldUpdatedAt:
  14658. return m.OldUpdatedAt(ctx)
  14659. case employee.FieldDeletedAt:
  14660. return m.OldDeletedAt(ctx)
  14661. case employee.FieldTitle:
  14662. return m.OldTitle(ctx)
  14663. case employee.FieldAvatar:
  14664. return m.OldAvatar(ctx)
  14665. case employee.FieldTags:
  14666. return m.OldTags(ctx)
  14667. case employee.FieldHireCount:
  14668. return m.OldHireCount(ctx)
  14669. case employee.FieldServiceCount:
  14670. return m.OldServiceCount(ctx)
  14671. case employee.FieldAchievementCount:
  14672. return m.OldAchievementCount(ctx)
  14673. case employee.FieldIntro:
  14674. return m.OldIntro(ctx)
  14675. case employee.FieldEstimate:
  14676. return m.OldEstimate(ctx)
  14677. case employee.FieldSkill:
  14678. return m.OldSkill(ctx)
  14679. case employee.FieldAbilityType:
  14680. return m.OldAbilityType(ctx)
  14681. case employee.FieldScene:
  14682. return m.OldScene(ctx)
  14683. case employee.FieldSwitchIn:
  14684. return m.OldSwitchIn(ctx)
  14685. case employee.FieldVideoURL:
  14686. return m.OldVideoURL(ctx)
  14687. case employee.FieldOrganizationID:
  14688. return m.OldOrganizationID(ctx)
  14689. case employee.FieldCategoryID:
  14690. return m.OldCategoryID(ctx)
  14691. case employee.FieldAPIBase:
  14692. return m.OldAPIBase(ctx)
  14693. case employee.FieldAPIKey:
  14694. return m.OldAPIKey(ctx)
  14695. case employee.FieldAiInfo:
  14696. return m.OldAiInfo(ctx)
  14697. case employee.FieldIsVip:
  14698. return m.OldIsVip(ctx)
  14699. case employee.FieldChatURL:
  14700. return m.OldChatURL(ctx)
  14701. }
  14702. return nil, fmt.Errorf("unknown Employee field %s", name)
  14703. }
  14704. // SetField sets the value of a field with the given name. It returns an error if
  14705. // the field is not defined in the schema, or if the type mismatched the field
  14706. // type.
  14707. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  14708. switch name {
  14709. case employee.FieldCreatedAt:
  14710. v, ok := value.(time.Time)
  14711. if !ok {
  14712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14713. }
  14714. m.SetCreatedAt(v)
  14715. return nil
  14716. case employee.FieldUpdatedAt:
  14717. v, ok := value.(time.Time)
  14718. if !ok {
  14719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14720. }
  14721. m.SetUpdatedAt(v)
  14722. return nil
  14723. case employee.FieldDeletedAt:
  14724. v, ok := value.(time.Time)
  14725. if !ok {
  14726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14727. }
  14728. m.SetDeletedAt(v)
  14729. return nil
  14730. case employee.FieldTitle:
  14731. v, ok := value.(string)
  14732. if !ok {
  14733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14734. }
  14735. m.SetTitle(v)
  14736. return nil
  14737. case employee.FieldAvatar:
  14738. v, ok := value.(string)
  14739. if !ok {
  14740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14741. }
  14742. m.SetAvatar(v)
  14743. return nil
  14744. case employee.FieldTags:
  14745. v, ok := value.(string)
  14746. if !ok {
  14747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14748. }
  14749. m.SetTags(v)
  14750. return nil
  14751. case employee.FieldHireCount:
  14752. v, ok := value.(int)
  14753. if !ok {
  14754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14755. }
  14756. m.SetHireCount(v)
  14757. return nil
  14758. case employee.FieldServiceCount:
  14759. v, ok := value.(int)
  14760. if !ok {
  14761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14762. }
  14763. m.SetServiceCount(v)
  14764. return nil
  14765. case employee.FieldAchievementCount:
  14766. v, ok := value.(int)
  14767. if !ok {
  14768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14769. }
  14770. m.SetAchievementCount(v)
  14771. return nil
  14772. case employee.FieldIntro:
  14773. v, ok := value.(string)
  14774. if !ok {
  14775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14776. }
  14777. m.SetIntro(v)
  14778. return nil
  14779. case employee.FieldEstimate:
  14780. v, ok := value.(string)
  14781. if !ok {
  14782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14783. }
  14784. m.SetEstimate(v)
  14785. return nil
  14786. case employee.FieldSkill:
  14787. v, ok := value.(string)
  14788. if !ok {
  14789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14790. }
  14791. m.SetSkill(v)
  14792. return nil
  14793. case employee.FieldAbilityType:
  14794. v, ok := value.(string)
  14795. if !ok {
  14796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14797. }
  14798. m.SetAbilityType(v)
  14799. return nil
  14800. case employee.FieldScene:
  14801. v, ok := value.(string)
  14802. if !ok {
  14803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14804. }
  14805. m.SetScene(v)
  14806. return nil
  14807. case employee.FieldSwitchIn:
  14808. v, ok := value.(string)
  14809. if !ok {
  14810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14811. }
  14812. m.SetSwitchIn(v)
  14813. return nil
  14814. case employee.FieldVideoURL:
  14815. v, ok := value.(string)
  14816. if !ok {
  14817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14818. }
  14819. m.SetVideoURL(v)
  14820. return nil
  14821. case employee.FieldOrganizationID:
  14822. v, ok := value.(uint64)
  14823. if !ok {
  14824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14825. }
  14826. m.SetOrganizationID(v)
  14827. return nil
  14828. case employee.FieldCategoryID:
  14829. v, ok := value.(uint64)
  14830. if !ok {
  14831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14832. }
  14833. m.SetCategoryID(v)
  14834. return nil
  14835. case employee.FieldAPIBase:
  14836. v, ok := value.(string)
  14837. if !ok {
  14838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14839. }
  14840. m.SetAPIBase(v)
  14841. return nil
  14842. case employee.FieldAPIKey:
  14843. v, ok := value.(string)
  14844. if !ok {
  14845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14846. }
  14847. m.SetAPIKey(v)
  14848. return nil
  14849. case employee.FieldAiInfo:
  14850. v, ok := value.(string)
  14851. if !ok {
  14852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14853. }
  14854. m.SetAiInfo(v)
  14855. return nil
  14856. case employee.FieldIsVip:
  14857. v, ok := value.(int)
  14858. if !ok {
  14859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14860. }
  14861. m.SetIsVip(v)
  14862. return nil
  14863. case employee.FieldChatURL:
  14864. v, ok := value.(string)
  14865. if !ok {
  14866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14867. }
  14868. m.SetChatURL(v)
  14869. return nil
  14870. }
  14871. return fmt.Errorf("unknown Employee field %s", name)
  14872. }
  14873. // AddedFields returns all numeric fields that were incremented/decremented during
  14874. // this mutation.
  14875. func (m *EmployeeMutation) AddedFields() []string {
  14876. var fields []string
  14877. if m.addhire_count != nil {
  14878. fields = append(fields, employee.FieldHireCount)
  14879. }
  14880. if m.addservice_count != nil {
  14881. fields = append(fields, employee.FieldServiceCount)
  14882. }
  14883. if m.addachievement_count != nil {
  14884. fields = append(fields, employee.FieldAchievementCount)
  14885. }
  14886. if m.addorganization_id != nil {
  14887. fields = append(fields, employee.FieldOrganizationID)
  14888. }
  14889. if m.addcategory_id != nil {
  14890. fields = append(fields, employee.FieldCategoryID)
  14891. }
  14892. if m.addis_vip != nil {
  14893. fields = append(fields, employee.FieldIsVip)
  14894. }
  14895. return fields
  14896. }
  14897. // AddedField returns the numeric value that was incremented/decremented on a field
  14898. // with the given name. The second boolean return value indicates that this field
  14899. // was not set, or was not defined in the schema.
  14900. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  14901. switch name {
  14902. case employee.FieldHireCount:
  14903. return m.AddedHireCount()
  14904. case employee.FieldServiceCount:
  14905. return m.AddedServiceCount()
  14906. case employee.FieldAchievementCount:
  14907. return m.AddedAchievementCount()
  14908. case employee.FieldOrganizationID:
  14909. return m.AddedOrganizationID()
  14910. case employee.FieldCategoryID:
  14911. return m.AddedCategoryID()
  14912. case employee.FieldIsVip:
  14913. return m.AddedIsVip()
  14914. }
  14915. return nil, false
  14916. }
  14917. // AddField adds the value to the field with the given name. It returns an error if
  14918. // the field is not defined in the schema, or if the type mismatched the field
  14919. // type.
  14920. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  14921. switch name {
  14922. case employee.FieldHireCount:
  14923. v, ok := value.(int)
  14924. if !ok {
  14925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14926. }
  14927. m.AddHireCount(v)
  14928. return nil
  14929. case employee.FieldServiceCount:
  14930. v, ok := value.(int)
  14931. if !ok {
  14932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14933. }
  14934. m.AddServiceCount(v)
  14935. return nil
  14936. case employee.FieldAchievementCount:
  14937. v, ok := value.(int)
  14938. if !ok {
  14939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14940. }
  14941. m.AddAchievementCount(v)
  14942. return nil
  14943. case employee.FieldOrganizationID:
  14944. v, ok := value.(int64)
  14945. if !ok {
  14946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14947. }
  14948. m.AddOrganizationID(v)
  14949. return nil
  14950. case employee.FieldCategoryID:
  14951. v, ok := value.(int64)
  14952. if !ok {
  14953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14954. }
  14955. m.AddCategoryID(v)
  14956. return nil
  14957. case employee.FieldIsVip:
  14958. v, ok := value.(int)
  14959. if !ok {
  14960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14961. }
  14962. m.AddIsVip(v)
  14963. return nil
  14964. }
  14965. return fmt.Errorf("unknown Employee numeric field %s", name)
  14966. }
  14967. // ClearedFields returns all nullable fields that were cleared during this
  14968. // mutation.
  14969. func (m *EmployeeMutation) ClearedFields() []string {
  14970. var fields []string
  14971. if m.FieldCleared(employee.FieldDeletedAt) {
  14972. fields = append(fields, employee.FieldDeletedAt)
  14973. }
  14974. if m.FieldCleared(employee.FieldAiInfo) {
  14975. fields = append(fields, employee.FieldAiInfo)
  14976. }
  14977. return fields
  14978. }
  14979. // FieldCleared returns a boolean indicating if a field with the given name was
  14980. // cleared in this mutation.
  14981. func (m *EmployeeMutation) FieldCleared(name string) bool {
  14982. _, ok := m.clearedFields[name]
  14983. return ok
  14984. }
  14985. // ClearField clears the value of the field with the given name. It returns an
  14986. // error if the field is not defined in the schema.
  14987. func (m *EmployeeMutation) ClearField(name string) error {
  14988. switch name {
  14989. case employee.FieldDeletedAt:
  14990. m.ClearDeletedAt()
  14991. return nil
  14992. case employee.FieldAiInfo:
  14993. m.ClearAiInfo()
  14994. return nil
  14995. }
  14996. return fmt.Errorf("unknown Employee nullable field %s", name)
  14997. }
  14998. // ResetField resets all changes in the mutation for the field with the given name.
  14999. // It returns an error if the field is not defined in the schema.
  15000. func (m *EmployeeMutation) ResetField(name string) error {
  15001. switch name {
  15002. case employee.FieldCreatedAt:
  15003. m.ResetCreatedAt()
  15004. return nil
  15005. case employee.FieldUpdatedAt:
  15006. m.ResetUpdatedAt()
  15007. return nil
  15008. case employee.FieldDeletedAt:
  15009. m.ResetDeletedAt()
  15010. return nil
  15011. case employee.FieldTitle:
  15012. m.ResetTitle()
  15013. return nil
  15014. case employee.FieldAvatar:
  15015. m.ResetAvatar()
  15016. return nil
  15017. case employee.FieldTags:
  15018. m.ResetTags()
  15019. return nil
  15020. case employee.FieldHireCount:
  15021. m.ResetHireCount()
  15022. return nil
  15023. case employee.FieldServiceCount:
  15024. m.ResetServiceCount()
  15025. return nil
  15026. case employee.FieldAchievementCount:
  15027. m.ResetAchievementCount()
  15028. return nil
  15029. case employee.FieldIntro:
  15030. m.ResetIntro()
  15031. return nil
  15032. case employee.FieldEstimate:
  15033. m.ResetEstimate()
  15034. return nil
  15035. case employee.FieldSkill:
  15036. m.ResetSkill()
  15037. return nil
  15038. case employee.FieldAbilityType:
  15039. m.ResetAbilityType()
  15040. return nil
  15041. case employee.FieldScene:
  15042. m.ResetScene()
  15043. return nil
  15044. case employee.FieldSwitchIn:
  15045. m.ResetSwitchIn()
  15046. return nil
  15047. case employee.FieldVideoURL:
  15048. m.ResetVideoURL()
  15049. return nil
  15050. case employee.FieldOrganizationID:
  15051. m.ResetOrganizationID()
  15052. return nil
  15053. case employee.FieldCategoryID:
  15054. m.ResetCategoryID()
  15055. return nil
  15056. case employee.FieldAPIBase:
  15057. m.ResetAPIBase()
  15058. return nil
  15059. case employee.FieldAPIKey:
  15060. m.ResetAPIKey()
  15061. return nil
  15062. case employee.FieldAiInfo:
  15063. m.ResetAiInfo()
  15064. return nil
  15065. case employee.FieldIsVip:
  15066. m.ResetIsVip()
  15067. return nil
  15068. case employee.FieldChatURL:
  15069. m.ResetChatURL()
  15070. return nil
  15071. }
  15072. return fmt.Errorf("unknown Employee field %s", name)
  15073. }
  15074. // AddedEdges returns all edge names that were set/added in this mutation.
  15075. func (m *EmployeeMutation) AddedEdges() []string {
  15076. edges := make([]string, 0, 2)
  15077. if m.em_work_experiences != nil {
  15078. edges = append(edges, employee.EdgeEmWorkExperiences)
  15079. }
  15080. if m.em_tutorial != nil {
  15081. edges = append(edges, employee.EdgeEmTutorial)
  15082. }
  15083. return edges
  15084. }
  15085. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15086. // name in this mutation.
  15087. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  15088. switch name {
  15089. case employee.EdgeEmWorkExperiences:
  15090. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  15091. for id := range m.em_work_experiences {
  15092. ids = append(ids, id)
  15093. }
  15094. return ids
  15095. case employee.EdgeEmTutorial:
  15096. ids := make([]ent.Value, 0, len(m.em_tutorial))
  15097. for id := range m.em_tutorial {
  15098. ids = append(ids, id)
  15099. }
  15100. return ids
  15101. }
  15102. return nil
  15103. }
  15104. // RemovedEdges returns all edge names that were removed in this mutation.
  15105. func (m *EmployeeMutation) RemovedEdges() []string {
  15106. edges := make([]string, 0, 2)
  15107. if m.removedem_work_experiences != nil {
  15108. edges = append(edges, employee.EdgeEmWorkExperiences)
  15109. }
  15110. if m.removedem_tutorial != nil {
  15111. edges = append(edges, employee.EdgeEmTutorial)
  15112. }
  15113. return edges
  15114. }
  15115. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15116. // the given name in this mutation.
  15117. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  15118. switch name {
  15119. case employee.EdgeEmWorkExperiences:
  15120. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  15121. for id := range m.removedem_work_experiences {
  15122. ids = append(ids, id)
  15123. }
  15124. return ids
  15125. case employee.EdgeEmTutorial:
  15126. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  15127. for id := range m.removedem_tutorial {
  15128. ids = append(ids, id)
  15129. }
  15130. return ids
  15131. }
  15132. return nil
  15133. }
  15134. // ClearedEdges returns all edge names that were cleared in this mutation.
  15135. func (m *EmployeeMutation) ClearedEdges() []string {
  15136. edges := make([]string, 0, 2)
  15137. if m.clearedem_work_experiences {
  15138. edges = append(edges, employee.EdgeEmWorkExperiences)
  15139. }
  15140. if m.clearedem_tutorial {
  15141. edges = append(edges, employee.EdgeEmTutorial)
  15142. }
  15143. return edges
  15144. }
  15145. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15146. // was cleared in this mutation.
  15147. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  15148. switch name {
  15149. case employee.EdgeEmWorkExperiences:
  15150. return m.clearedem_work_experiences
  15151. case employee.EdgeEmTutorial:
  15152. return m.clearedem_tutorial
  15153. }
  15154. return false
  15155. }
  15156. // ClearEdge clears the value of the edge with the given name. It returns an error
  15157. // if that edge is not defined in the schema.
  15158. func (m *EmployeeMutation) ClearEdge(name string) error {
  15159. switch name {
  15160. }
  15161. return fmt.Errorf("unknown Employee unique edge %s", name)
  15162. }
  15163. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15164. // It returns an error if the edge is not defined in the schema.
  15165. func (m *EmployeeMutation) ResetEdge(name string) error {
  15166. switch name {
  15167. case employee.EdgeEmWorkExperiences:
  15168. m.ResetEmWorkExperiences()
  15169. return nil
  15170. case employee.EdgeEmTutorial:
  15171. m.ResetEmTutorial()
  15172. return nil
  15173. }
  15174. return fmt.Errorf("unknown Employee edge %s", name)
  15175. }
  15176. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  15177. type EmployeeConfigMutation struct {
  15178. config
  15179. op Op
  15180. typ string
  15181. id *uint64
  15182. created_at *time.Time
  15183. updated_at *time.Time
  15184. deleted_at *time.Time
  15185. stype *string
  15186. title *string
  15187. photo *string
  15188. organization_id *uint64
  15189. addorganization_id *int64
  15190. clearedFields map[string]struct{}
  15191. done bool
  15192. oldValue func(context.Context) (*EmployeeConfig, error)
  15193. predicates []predicate.EmployeeConfig
  15194. }
  15195. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  15196. // employeeconfigOption allows management of the mutation configuration using functional options.
  15197. type employeeconfigOption func(*EmployeeConfigMutation)
  15198. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  15199. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  15200. m := &EmployeeConfigMutation{
  15201. config: c,
  15202. op: op,
  15203. typ: TypeEmployeeConfig,
  15204. clearedFields: make(map[string]struct{}),
  15205. }
  15206. for _, opt := range opts {
  15207. opt(m)
  15208. }
  15209. return m
  15210. }
  15211. // withEmployeeConfigID sets the ID field of the mutation.
  15212. func withEmployeeConfigID(id uint64) employeeconfigOption {
  15213. return func(m *EmployeeConfigMutation) {
  15214. var (
  15215. err error
  15216. once sync.Once
  15217. value *EmployeeConfig
  15218. )
  15219. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  15220. once.Do(func() {
  15221. if m.done {
  15222. err = errors.New("querying old values post mutation is not allowed")
  15223. } else {
  15224. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  15225. }
  15226. })
  15227. return value, err
  15228. }
  15229. m.id = &id
  15230. }
  15231. }
  15232. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  15233. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  15234. return func(m *EmployeeConfigMutation) {
  15235. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  15236. return node, nil
  15237. }
  15238. m.id = &node.ID
  15239. }
  15240. }
  15241. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15242. // executed in a transaction (ent.Tx), a transactional client is returned.
  15243. func (m EmployeeConfigMutation) Client() *Client {
  15244. client := &Client{config: m.config}
  15245. client.init()
  15246. return client
  15247. }
  15248. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15249. // it returns an error otherwise.
  15250. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  15251. if _, ok := m.driver.(*txDriver); !ok {
  15252. return nil, errors.New("ent: mutation is not running in a transaction")
  15253. }
  15254. tx := &Tx{config: m.config}
  15255. tx.init()
  15256. return tx, nil
  15257. }
  15258. // SetID sets the value of the id field. Note that this
  15259. // operation is only accepted on creation of EmployeeConfig entities.
  15260. func (m *EmployeeConfigMutation) SetID(id uint64) {
  15261. m.id = &id
  15262. }
  15263. // ID returns the ID value in the mutation. Note that the ID is only available
  15264. // if it was provided to the builder or after it was returned from the database.
  15265. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  15266. if m.id == nil {
  15267. return
  15268. }
  15269. return *m.id, true
  15270. }
  15271. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15272. // That means, if the mutation is applied within a transaction with an isolation level such
  15273. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15274. // or updated by the mutation.
  15275. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  15276. switch {
  15277. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15278. id, exists := m.ID()
  15279. if exists {
  15280. return []uint64{id}, nil
  15281. }
  15282. fallthrough
  15283. case m.op.Is(OpUpdate | OpDelete):
  15284. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  15285. default:
  15286. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15287. }
  15288. }
  15289. // SetCreatedAt sets the "created_at" field.
  15290. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  15291. m.created_at = &t
  15292. }
  15293. // CreatedAt returns the value of the "created_at" field in the mutation.
  15294. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  15295. v := m.created_at
  15296. if v == nil {
  15297. return
  15298. }
  15299. return *v, true
  15300. }
  15301. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  15302. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15304. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15305. if !m.op.Is(OpUpdateOne) {
  15306. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15307. }
  15308. if m.id == nil || m.oldValue == nil {
  15309. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15310. }
  15311. oldValue, err := m.oldValue(ctx)
  15312. if err != nil {
  15313. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15314. }
  15315. return oldValue.CreatedAt, nil
  15316. }
  15317. // ResetCreatedAt resets all changes to the "created_at" field.
  15318. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  15319. m.created_at = nil
  15320. }
  15321. // SetUpdatedAt sets the "updated_at" field.
  15322. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  15323. m.updated_at = &t
  15324. }
  15325. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15326. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  15327. v := m.updated_at
  15328. if v == nil {
  15329. return
  15330. }
  15331. return *v, true
  15332. }
  15333. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  15334. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15336. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15337. if !m.op.Is(OpUpdateOne) {
  15338. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15339. }
  15340. if m.id == nil || m.oldValue == nil {
  15341. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15342. }
  15343. oldValue, err := m.oldValue(ctx)
  15344. if err != nil {
  15345. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15346. }
  15347. return oldValue.UpdatedAt, nil
  15348. }
  15349. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15350. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  15351. m.updated_at = nil
  15352. }
  15353. // SetDeletedAt sets the "deleted_at" field.
  15354. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  15355. m.deleted_at = &t
  15356. }
  15357. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15358. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  15359. v := m.deleted_at
  15360. if v == nil {
  15361. return
  15362. }
  15363. return *v, true
  15364. }
  15365. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  15366. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15368. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15369. if !m.op.Is(OpUpdateOne) {
  15370. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15371. }
  15372. if m.id == nil || m.oldValue == nil {
  15373. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15374. }
  15375. oldValue, err := m.oldValue(ctx)
  15376. if err != nil {
  15377. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15378. }
  15379. return oldValue.DeletedAt, nil
  15380. }
  15381. // ClearDeletedAt clears the value of the "deleted_at" field.
  15382. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  15383. m.deleted_at = nil
  15384. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  15385. }
  15386. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15387. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  15388. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  15389. return ok
  15390. }
  15391. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15392. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  15393. m.deleted_at = nil
  15394. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  15395. }
  15396. // SetStype sets the "stype" field.
  15397. func (m *EmployeeConfigMutation) SetStype(s string) {
  15398. m.stype = &s
  15399. }
  15400. // Stype returns the value of the "stype" field in the mutation.
  15401. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  15402. v := m.stype
  15403. if v == nil {
  15404. return
  15405. }
  15406. return *v, true
  15407. }
  15408. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  15409. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15411. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  15412. if !m.op.Is(OpUpdateOne) {
  15413. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  15414. }
  15415. if m.id == nil || m.oldValue == nil {
  15416. return v, errors.New("OldStype requires an ID field in the mutation")
  15417. }
  15418. oldValue, err := m.oldValue(ctx)
  15419. if err != nil {
  15420. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  15421. }
  15422. return oldValue.Stype, nil
  15423. }
  15424. // ResetStype resets all changes to the "stype" field.
  15425. func (m *EmployeeConfigMutation) ResetStype() {
  15426. m.stype = nil
  15427. }
  15428. // SetTitle sets the "title" field.
  15429. func (m *EmployeeConfigMutation) SetTitle(s string) {
  15430. m.title = &s
  15431. }
  15432. // Title returns the value of the "title" field in the mutation.
  15433. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  15434. v := m.title
  15435. if v == nil {
  15436. return
  15437. }
  15438. return *v, true
  15439. }
  15440. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  15441. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15443. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  15444. if !m.op.Is(OpUpdateOne) {
  15445. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15446. }
  15447. if m.id == nil || m.oldValue == nil {
  15448. return v, errors.New("OldTitle requires an ID field in the mutation")
  15449. }
  15450. oldValue, err := m.oldValue(ctx)
  15451. if err != nil {
  15452. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15453. }
  15454. return oldValue.Title, nil
  15455. }
  15456. // ResetTitle resets all changes to the "title" field.
  15457. func (m *EmployeeConfigMutation) ResetTitle() {
  15458. m.title = nil
  15459. }
  15460. // SetPhoto sets the "photo" field.
  15461. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  15462. m.photo = &s
  15463. }
  15464. // Photo returns the value of the "photo" field in the mutation.
  15465. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  15466. v := m.photo
  15467. if v == nil {
  15468. return
  15469. }
  15470. return *v, true
  15471. }
  15472. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  15473. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15475. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  15476. if !m.op.Is(OpUpdateOne) {
  15477. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  15478. }
  15479. if m.id == nil || m.oldValue == nil {
  15480. return v, errors.New("OldPhoto requires an ID field in the mutation")
  15481. }
  15482. oldValue, err := m.oldValue(ctx)
  15483. if err != nil {
  15484. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  15485. }
  15486. return oldValue.Photo, nil
  15487. }
  15488. // ResetPhoto resets all changes to the "photo" field.
  15489. func (m *EmployeeConfigMutation) ResetPhoto() {
  15490. m.photo = nil
  15491. }
  15492. // SetOrganizationID sets the "organization_id" field.
  15493. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  15494. m.organization_id = &u
  15495. m.addorganization_id = nil
  15496. }
  15497. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15498. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  15499. v := m.organization_id
  15500. if v == nil {
  15501. return
  15502. }
  15503. return *v, true
  15504. }
  15505. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  15506. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15508. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15509. if !m.op.Is(OpUpdateOne) {
  15510. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15511. }
  15512. if m.id == nil || m.oldValue == nil {
  15513. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15514. }
  15515. oldValue, err := m.oldValue(ctx)
  15516. if err != nil {
  15517. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15518. }
  15519. return oldValue.OrganizationID, nil
  15520. }
  15521. // AddOrganizationID adds u to the "organization_id" field.
  15522. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  15523. if m.addorganization_id != nil {
  15524. *m.addorganization_id += u
  15525. } else {
  15526. m.addorganization_id = &u
  15527. }
  15528. }
  15529. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15530. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  15531. v := m.addorganization_id
  15532. if v == nil {
  15533. return
  15534. }
  15535. return *v, true
  15536. }
  15537. // ClearOrganizationID clears the value of the "organization_id" field.
  15538. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  15539. m.organization_id = nil
  15540. m.addorganization_id = nil
  15541. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  15542. }
  15543. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15544. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  15545. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  15546. return ok
  15547. }
  15548. // ResetOrganizationID resets all changes to the "organization_id" field.
  15549. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  15550. m.organization_id = nil
  15551. m.addorganization_id = nil
  15552. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  15553. }
  15554. // Where appends a list predicates to the EmployeeConfigMutation builder.
  15555. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  15556. m.predicates = append(m.predicates, ps...)
  15557. }
  15558. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  15559. // users can use type-assertion to append predicates that do not depend on any generated package.
  15560. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  15561. p := make([]predicate.EmployeeConfig, len(ps))
  15562. for i := range ps {
  15563. p[i] = ps[i]
  15564. }
  15565. m.Where(p...)
  15566. }
  15567. // Op returns the operation name.
  15568. func (m *EmployeeConfigMutation) Op() Op {
  15569. return m.op
  15570. }
  15571. // SetOp allows setting the mutation operation.
  15572. func (m *EmployeeConfigMutation) SetOp(op Op) {
  15573. m.op = op
  15574. }
  15575. // Type returns the node type of this mutation (EmployeeConfig).
  15576. func (m *EmployeeConfigMutation) Type() string {
  15577. return m.typ
  15578. }
  15579. // Fields returns all fields that were changed during this mutation. Note that in
  15580. // order to get all numeric fields that were incremented/decremented, call
  15581. // AddedFields().
  15582. func (m *EmployeeConfigMutation) Fields() []string {
  15583. fields := make([]string, 0, 7)
  15584. if m.created_at != nil {
  15585. fields = append(fields, employeeconfig.FieldCreatedAt)
  15586. }
  15587. if m.updated_at != nil {
  15588. fields = append(fields, employeeconfig.FieldUpdatedAt)
  15589. }
  15590. if m.deleted_at != nil {
  15591. fields = append(fields, employeeconfig.FieldDeletedAt)
  15592. }
  15593. if m.stype != nil {
  15594. fields = append(fields, employeeconfig.FieldStype)
  15595. }
  15596. if m.title != nil {
  15597. fields = append(fields, employeeconfig.FieldTitle)
  15598. }
  15599. if m.photo != nil {
  15600. fields = append(fields, employeeconfig.FieldPhoto)
  15601. }
  15602. if m.organization_id != nil {
  15603. fields = append(fields, employeeconfig.FieldOrganizationID)
  15604. }
  15605. return fields
  15606. }
  15607. // Field returns the value of a field with the given name. The second boolean
  15608. // return value indicates that this field was not set, or was not defined in the
  15609. // schema.
  15610. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  15611. switch name {
  15612. case employeeconfig.FieldCreatedAt:
  15613. return m.CreatedAt()
  15614. case employeeconfig.FieldUpdatedAt:
  15615. return m.UpdatedAt()
  15616. case employeeconfig.FieldDeletedAt:
  15617. return m.DeletedAt()
  15618. case employeeconfig.FieldStype:
  15619. return m.Stype()
  15620. case employeeconfig.FieldTitle:
  15621. return m.Title()
  15622. case employeeconfig.FieldPhoto:
  15623. return m.Photo()
  15624. case employeeconfig.FieldOrganizationID:
  15625. return m.OrganizationID()
  15626. }
  15627. return nil, false
  15628. }
  15629. // OldField returns the old value of the field from the database. An error is
  15630. // returned if the mutation operation is not UpdateOne, or the query to the
  15631. // database failed.
  15632. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15633. switch name {
  15634. case employeeconfig.FieldCreatedAt:
  15635. return m.OldCreatedAt(ctx)
  15636. case employeeconfig.FieldUpdatedAt:
  15637. return m.OldUpdatedAt(ctx)
  15638. case employeeconfig.FieldDeletedAt:
  15639. return m.OldDeletedAt(ctx)
  15640. case employeeconfig.FieldStype:
  15641. return m.OldStype(ctx)
  15642. case employeeconfig.FieldTitle:
  15643. return m.OldTitle(ctx)
  15644. case employeeconfig.FieldPhoto:
  15645. return m.OldPhoto(ctx)
  15646. case employeeconfig.FieldOrganizationID:
  15647. return m.OldOrganizationID(ctx)
  15648. }
  15649. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  15650. }
  15651. // SetField sets the value of a field with the given name. It returns an error if
  15652. // the field is not defined in the schema, or if the type mismatched the field
  15653. // type.
  15654. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  15655. switch name {
  15656. case employeeconfig.FieldCreatedAt:
  15657. v, ok := value.(time.Time)
  15658. if !ok {
  15659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15660. }
  15661. m.SetCreatedAt(v)
  15662. return nil
  15663. case employeeconfig.FieldUpdatedAt:
  15664. v, ok := value.(time.Time)
  15665. if !ok {
  15666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15667. }
  15668. m.SetUpdatedAt(v)
  15669. return nil
  15670. case employeeconfig.FieldDeletedAt:
  15671. v, ok := value.(time.Time)
  15672. if !ok {
  15673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15674. }
  15675. m.SetDeletedAt(v)
  15676. return nil
  15677. case employeeconfig.FieldStype:
  15678. v, ok := value.(string)
  15679. if !ok {
  15680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15681. }
  15682. m.SetStype(v)
  15683. return nil
  15684. case employeeconfig.FieldTitle:
  15685. v, ok := value.(string)
  15686. if !ok {
  15687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15688. }
  15689. m.SetTitle(v)
  15690. return nil
  15691. case employeeconfig.FieldPhoto:
  15692. v, ok := value.(string)
  15693. if !ok {
  15694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15695. }
  15696. m.SetPhoto(v)
  15697. return nil
  15698. case employeeconfig.FieldOrganizationID:
  15699. v, ok := value.(uint64)
  15700. if !ok {
  15701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15702. }
  15703. m.SetOrganizationID(v)
  15704. return nil
  15705. }
  15706. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15707. }
  15708. // AddedFields returns all numeric fields that were incremented/decremented during
  15709. // this mutation.
  15710. func (m *EmployeeConfigMutation) AddedFields() []string {
  15711. var fields []string
  15712. if m.addorganization_id != nil {
  15713. fields = append(fields, employeeconfig.FieldOrganizationID)
  15714. }
  15715. return fields
  15716. }
  15717. // AddedField returns the numeric value that was incremented/decremented on a field
  15718. // with the given name. The second boolean return value indicates that this field
  15719. // was not set, or was not defined in the schema.
  15720. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  15721. switch name {
  15722. case employeeconfig.FieldOrganizationID:
  15723. return m.AddedOrganizationID()
  15724. }
  15725. return nil, false
  15726. }
  15727. // AddField adds the value to the field with the given name. It returns an error if
  15728. // the field is not defined in the schema, or if the type mismatched the field
  15729. // type.
  15730. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  15731. switch name {
  15732. case employeeconfig.FieldOrganizationID:
  15733. v, ok := value.(int64)
  15734. if !ok {
  15735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15736. }
  15737. m.AddOrganizationID(v)
  15738. return nil
  15739. }
  15740. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  15741. }
  15742. // ClearedFields returns all nullable fields that were cleared during this
  15743. // mutation.
  15744. func (m *EmployeeConfigMutation) ClearedFields() []string {
  15745. var fields []string
  15746. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  15747. fields = append(fields, employeeconfig.FieldDeletedAt)
  15748. }
  15749. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  15750. fields = append(fields, employeeconfig.FieldOrganizationID)
  15751. }
  15752. return fields
  15753. }
  15754. // FieldCleared returns a boolean indicating if a field with the given name was
  15755. // cleared in this mutation.
  15756. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  15757. _, ok := m.clearedFields[name]
  15758. return ok
  15759. }
  15760. // ClearField clears the value of the field with the given name. It returns an
  15761. // error if the field is not defined in the schema.
  15762. func (m *EmployeeConfigMutation) ClearField(name string) error {
  15763. switch name {
  15764. case employeeconfig.FieldDeletedAt:
  15765. m.ClearDeletedAt()
  15766. return nil
  15767. case employeeconfig.FieldOrganizationID:
  15768. m.ClearOrganizationID()
  15769. return nil
  15770. }
  15771. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  15772. }
  15773. // ResetField resets all changes in the mutation for the field with the given name.
  15774. // It returns an error if the field is not defined in the schema.
  15775. func (m *EmployeeConfigMutation) ResetField(name string) error {
  15776. switch name {
  15777. case employeeconfig.FieldCreatedAt:
  15778. m.ResetCreatedAt()
  15779. return nil
  15780. case employeeconfig.FieldUpdatedAt:
  15781. m.ResetUpdatedAt()
  15782. return nil
  15783. case employeeconfig.FieldDeletedAt:
  15784. m.ResetDeletedAt()
  15785. return nil
  15786. case employeeconfig.FieldStype:
  15787. m.ResetStype()
  15788. return nil
  15789. case employeeconfig.FieldTitle:
  15790. m.ResetTitle()
  15791. return nil
  15792. case employeeconfig.FieldPhoto:
  15793. m.ResetPhoto()
  15794. return nil
  15795. case employeeconfig.FieldOrganizationID:
  15796. m.ResetOrganizationID()
  15797. return nil
  15798. }
  15799. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15800. }
  15801. // AddedEdges returns all edge names that were set/added in this mutation.
  15802. func (m *EmployeeConfigMutation) AddedEdges() []string {
  15803. edges := make([]string, 0, 0)
  15804. return edges
  15805. }
  15806. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15807. // name in this mutation.
  15808. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  15809. return nil
  15810. }
  15811. // RemovedEdges returns all edge names that were removed in this mutation.
  15812. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  15813. edges := make([]string, 0, 0)
  15814. return edges
  15815. }
  15816. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15817. // the given name in this mutation.
  15818. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  15819. return nil
  15820. }
  15821. // ClearedEdges returns all edge names that were cleared in this mutation.
  15822. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  15823. edges := make([]string, 0, 0)
  15824. return edges
  15825. }
  15826. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15827. // was cleared in this mutation.
  15828. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  15829. return false
  15830. }
  15831. // ClearEdge clears the value of the edge with the given name. It returns an error
  15832. // if that edge is not defined in the schema.
  15833. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  15834. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  15835. }
  15836. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15837. // It returns an error if the edge is not defined in the schema.
  15838. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  15839. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  15840. }
  15841. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  15842. type LabelMutation struct {
  15843. config
  15844. op Op
  15845. typ string
  15846. id *uint64
  15847. created_at *time.Time
  15848. updated_at *time.Time
  15849. status *uint8
  15850. addstatus *int8
  15851. _type *int
  15852. add_type *int
  15853. name *string
  15854. from *int
  15855. addfrom *int
  15856. mode *int
  15857. addmode *int
  15858. conditions *string
  15859. organization_id *uint64
  15860. addorganization_id *int64
  15861. clearedFields map[string]struct{}
  15862. label_relationships map[uint64]struct{}
  15863. removedlabel_relationships map[uint64]struct{}
  15864. clearedlabel_relationships bool
  15865. done bool
  15866. oldValue func(context.Context) (*Label, error)
  15867. predicates []predicate.Label
  15868. }
  15869. var _ ent.Mutation = (*LabelMutation)(nil)
  15870. // labelOption allows management of the mutation configuration using functional options.
  15871. type labelOption func(*LabelMutation)
  15872. // newLabelMutation creates new mutation for the Label entity.
  15873. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  15874. m := &LabelMutation{
  15875. config: c,
  15876. op: op,
  15877. typ: TypeLabel,
  15878. clearedFields: make(map[string]struct{}),
  15879. }
  15880. for _, opt := range opts {
  15881. opt(m)
  15882. }
  15883. return m
  15884. }
  15885. // withLabelID sets the ID field of the mutation.
  15886. func withLabelID(id uint64) labelOption {
  15887. return func(m *LabelMutation) {
  15888. var (
  15889. err error
  15890. once sync.Once
  15891. value *Label
  15892. )
  15893. m.oldValue = func(ctx context.Context) (*Label, error) {
  15894. once.Do(func() {
  15895. if m.done {
  15896. err = errors.New("querying old values post mutation is not allowed")
  15897. } else {
  15898. value, err = m.Client().Label.Get(ctx, id)
  15899. }
  15900. })
  15901. return value, err
  15902. }
  15903. m.id = &id
  15904. }
  15905. }
  15906. // withLabel sets the old Label of the mutation.
  15907. func withLabel(node *Label) labelOption {
  15908. return func(m *LabelMutation) {
  15909. m.oldValue = func(context.Context) (*Label, error) {
  15910. return node, nil
  15911. }
  15912. m.id = &node.ID
  15913. }
  15914. }
  15915. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15916. // executed in a transaction (ent.Tx), a transactional client is returned.
  15917. func (m LabelMutation) Client() *Client {
  15918. client := &Client{config: m.config}
  15919. client.init()
  15920. return client
  15921. }
  15922. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15923. // it returns an error otherwise.
  15924. func (m LabelMutation) Tx() (*Tx, error) {
  15925. if _, ok := m.driver.(*txDriver); !ok {
  15926. return nil, errors.New("ent: mutation is not running in a transaction")
  15927. }
  15928. tx := &Tx{config: m.config}
  15929. tx.init()
  15930. return tx, nil
  15931. }
  15932. // SetID sets the value of the id field. Note that this
  15933. // operation is only accepted on creation of Label entities.
  15934. func (m *LabelMutation) SetID(id uint64) {
  15935. m.id = &id
  15936. }
  15937. // ID returns the ID value in the mutation. Note that the ID is only available
  15938. // if it was provided to the builder or after it was returned from the database.
  15939. func (m *LabelMutation) ID() (id uint64, exists bool) {
  15940. if m.id == nil {
  15941. return
  15942. }
  15943. return *m.id, true
  15944. }
  15945. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15946. // That means, if the mutation is applied within a transaction with an isolation level such
  15947. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15948. // or updated by the mutation.
  15949. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  15950. switch {
  15951. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15952. id, exists := m.ID()
  15953. if exists {
  15954. return []uint64{id}, nil
  15955. }
  15956. fallthrough
  15957. case m.op.Is(OpUpdate | OpDelete):
  15958. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  15959. default:
  15960. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15961. }
  15962. }
  15963. // SetCreatedAt sets the "created_at" field.
  15964. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  15965. m.created_at = &t
  15966. }
  15967. // CreatedAt returns the value of the "created_at" field in the mutation.
  15968. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  15969. v := m.created_at
  15970. if v == nil {
  15971. return
  15972. }
  15973. return *v, true
  15974. }
  15975. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  15976. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15978. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15979. if !m.op.Is(OpUpdateOne) {
  15980. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15981. }
  15982. if m.id == nil || m.oldValue == nil {
  15983. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15984. }
  15985. oldValue, err := m.oldValue(ctx)
  15986. if err != nil {
  15987. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15988. }
  15989. return oldValue.CreatedAt, nil
  15990. }
  15991. // ResetCreatedAt resets all changes to the "created_at" field.
  15992. func (m *LabelMutation) ResetCreatedAt() {
  15993. m.created_at = nil
  15994. }
  15995. // SetUpdatedAt sets the "updated_at" field.
  15996. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  15997. m.updated_at = &t
  15998. }
  15999. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16000. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  16001. v := m.updated_at
  16002. if v == nil {
  16003. return
  16004. }
  16005. return *v, true
  16006. }
  16007. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  16008. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16010. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16011. if !m.op.Is(OpUpdateOne) {
  16012. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16013. }
  16014. if m.id == nil || m.oldValue == nil {
  16015. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16016. }
  16017. oldValue, err := m.oldValue(ctx)
  16018. if err != nil {
  16019. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16020. }
  16021. return oldValue.UpdatedAt, nil
  16022. }
  16023. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16024. func (m *LabelMutation) ResetUpdatedAt() {
  16025. m.updated_at = nil
  16026. }
  16027. // SetStatus sets the "status" field.
  16028. func (m *LabelMutation) SetStatus(u uint8) {
  16029. m.status = &u
  16030. m.addstatus = nil
  16031. }
  16032. // Status returns the value of the "status" field in the mutation.
  16033. func (m *LabelMutation) Status() (r uint8, exists bool) {
  16034. v := m.status
  16035. if v == nil {
  16036. return
  16037. }
  16038. return *v, true
  16039. }
  16040. // OldStatus returns the old "status" field's value of the Label entity.
  16041. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16043. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16044. if !m.op.Is(OpUpdateOne) {
  16045. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16046. }
  16047. if m.id == nil || m.oldValue == nil {
  16048. return v, errors.New("OldStatus requires an ID field in the mutation")
  16049. }
  16050. oldValue, err := m.oldValue(ctx)
  16051. if err != nil {
  16052. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16053. }
  16054. return oldValue.Status, nil
  16055. }
  16056. // AddStatus adds u to the "status" field.
  16057. func (m *LabelMutation) AddStatus(u int8) {
  16058. if m.addstatus != nil {
  16059. *m.addstatus += u
  16060. } else {
  16061. m.addstatus = &u
  16062. }
  16063. }
  16064. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16065. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  16066. v := m.addstatus
  16067. if v == nil {
  16068. return
  16069. }
  16070. return *v, true
  16071. }
  16072. // ClearStatus clears the value of the "status" field.
  16073. func (m *LabelMutation) ClearStatus() {
  16074. m.status = nil
  16075. m.addstatus = nil
  16076. m.clearedFields[label.FieldStatus] = struct{}{}
  16077. }
  16078. // StatusCleared returns if the "status" field was cleared in this mutation.
  16079. func (m *LabelMutation) StatusCleared() bool {
  16080. _, ok := m.clearedFields[label.FieldStatus]
  16081. return ok
  16082. }
  16083. // ResetStatus resets all changes to the "status" field.
  16084. func (m *LabelMutation) ResetStatus() {
  16085. m.status = nil
  16086. m.addstatus = nil
  16087. delete(m.clearedFields, label.FieldStatus)
  16088. }
  16089. // SetType sets the "type" field.
  16090. func (m *LabelMutation) SetType(i int) {
  16091. m._type = &i
  16092. m.add_type = nil
  16093. }
  16094. // GetType returns the value of the "type" field in the mutation.
  16095. func (m *LabelMutation) GetType() (r int, exists bool) {
  16096. v := m._type
  16097. if v == nil {
  16098. return
  16099. }
  16100. return *v, true
  16101. }
  16102. // OldType returns the old "type" field's value of the Label entity.
  16103. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16105. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  16106. if !m.op.Is(OpUpdateOne) {
  16107. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16108. }
  16109. if m.id == nil || m.oldValue == nil {
  16110. return v, errors.New("OldType requires an ID field in the mutation")
  16111. }
  16112. oldValue, err := m.oldValue(ctx)
  16113. if err != nil {
  16114. return v, fmt.Errorf("querying old value for OldType: %w", err)
  16115. }
  16116. return oldValue.Type, nil
  16117. }
  16118. // AddType adds i to the "type" field.
  16119. func (m *LabelMutation) AddType(i int) {
  16120. if m.add_type != nil {
  16121. *m.add_type += i
  16122. } else {
  16123. m.add_type = &i
  16124. }
  16125. }
  16126. // AddedType returns the value that was added to the "type" field in this mutation.
  16127. func (m *LabelMutation) AddedType() (r int, exists bool) {
  16128. v := m.add_type
  16129. if v == nil {
  16130. return
  16131. }
  16132. return *v, true
  16133. }
  16134. // ResetType resets all changes to the "type" field.
  16135. func (m *LabelMutation) ResetType() {
  16136. m._type = nil
  16137. m.add_type = nil
  16138. }
  16139. // SetName sets the "name" field.
  16140. func (m *LabelMutation) SetName(s string) {
  16141. m.name = &s
  16142. }
  16143. // Name returns the value of the "name" field in the mutation.
  16144. func (m *LabelMutation) Name() (r string, exists bool) {
  16145. v := m.name
  16146. if v == nil {
  16147. return
  16148. }
  16149. return *v, true
  16150. }
  16151. // OldName returns the old "name" field's value of the Label entity.
  16152. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16154. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  16155. if !m.op.Is(OpUpdateOne) {
  16156. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16157. }
  16158. if m.id == nil || m.oldValue == nil {
  16159. return v, errors.New("OldName requires an ID field in the mutation")
  16160. }
  16161. oldValue, err := m.oldValue(ctx)
  16162. if err != nil {
  16163. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16164. }
  16165. return oldValue.Name, nil
  16166. }
  16167. // ResetName resets all changes to the "name" field.
  16168. func (m *LabelMutation) ResetName() {
  16169. m.name = nil
  16170. }
  16171. // SetFrom sets the "from" field.
  16172. func (m *LabelMutation) SetFrom(i int) {
  16173. m.from = &i
  16174. m.addfrom = nil
  16175. }
  16176. // From returns the value of the "from" field in the mutation.
  16177. func (m *LabelMutation) From() (r int, exists bool) {
  16178. v := m.from
  16179. if v == nil {
  16180. return
  16181. }
  16182. return *v, true
  16183. }
  16184. // OldFrom returns the old "from" field's value of the Label entity.
  16185. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16187. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  16188. if !m.op.Is(OpUpdateOne) {
  16189. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  16190. }
  16191. if m.id == nil || m.oldValue == nil {
  16192. return v, errors.New("OldFrom requires an ID field in the mutation")
  16193. }
  16194. oldValue, err := m.oldValue(ctx)
  16195. if err != nil {
  16196. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  16197. }
  16198. return oldValue.From, nil
  16199. }
  16200. // AddFrom adds i to the "from" field.
  16201. func (m *LabelMutation) AddFrom(i int) {
  16202. if m.addfrom != nil {
  16203. *m.addfrom += i
  16204. } else {
  16205. m.addfrom = &i
  16206. }
  16207. }
  16208. // AddedFrom returns the value that was added to the "from" field in this mutation.
  16209. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  16210. v := m.addfrom
  16211. if v == nil {
  16212. return
  16213. }
  16214. return *v, true
  16215. }
  16216. // ResetFrom resets all changes to the "from" field.
  16217. func (m *LabelMutation) ResetFrom() {
  16218. m.from = nil
  16219. m.addfrom = nil
  16220. }
  16221. // SetMode sets the "mode" field.
  16222. func (m *LabelMutation) SetMode(i int) {
  16223. m.mode = &i
  16224. m.addmode = nil
  16225. }
  16226. // Mode returns the value of the "mode" field in the mutation.
  16227. func (m *LabelMutation) Mode() (r int, exists bool) {
  16228. v := m.mode
  16229. if v == nil {
  16230. return
  16231. }
  16232. return *v, true
  16233. }
  16234. // OldMode returns the old "mode" field's value of the Label entity.
  16235. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16237. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  16238. if !m.op.Is(OpUpdateOne) {
  16239. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  16240. }
  16241. if m.id == nil || m.oldValue == nil {
  16242. return v, errors.New("OldMode requires an ID field in the mutation")
  16243. }
  16244. oldValue, err := m.oldValue(ctx)
  16245. if err != nil {
  16246. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  16247. }
  16248. return oldValue.Mode, nil
  16249. }
  16250. // AddMode adds i to the "mode" field.
  16251. func (m *LabelMutation) AddMode(i int) {
  16252. if m.addmode != nil {
  16253. *m.addmode += i
  16254. } else {
  16255. m.addmode = &i
  16256. }
  16257. }
  16258. // AddedMode returns the value that was added to the "mode" field in this mutation.
  16259. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  16260. v := m.addmode
  16261. if v == nil {
  16262. return
  16263. }
  16264. return *v, true
  16265. }
  16266. // ResetMode resets all changes to the "mode" field.
  16267. func (m *LabelMutation) ResetMode() {
  16268. m.mode = nil
  16269. m.addmode = nil
  16270. }
  16271. // SetConditions sets the "conditions" field.
  16272. func (m *LabelMutation) SetConditions(s string) {
  16273. m.conditions = &s
  16274. }
  16275. // Conditions returns the value of the "conditions" field in the mutation.
  16276. func (m *LabelMutation) Conditions() (r string, exists bool) {
  16277. v := m.conditions
  16278. if v == nil {
  16279. return
  16280. }
  16281. return *v, true
  16282. }
  16283. // OldConditions returns the old "conditions" field's value of the Label entity.
  16284. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16286. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  16287. if !m.op.Is(OpUpdateOne) {
  16288. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16289. }
  16290. if m.id == nil || m.oldValue == nil {
  16291. return v, errors.New("OldConditions requires an ID field in the mutation")
  16292. }
  16293. oldValue, err := m.oldValue(ctx)
  16294. if err != nil {
  16295. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16296. }
  16297. return oldValue.Conditions, nil
  16298. }
  16299. // ClearConditions clears the value of the "conditions" field.
  16300. func (m *LabelMutation) ClearConditions() {
  16301. m.conditions = nil
  16302. m.clearedFields[label.FieldConditions] = struct{}{}
  16303. }
  16304. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  16305. func (m *LabelMutation) ConditionsCleared() bool {
  16306. _, ok := m.clearedFields[label.FieldConditions]
  16307. return ok
  16308. }
  16309. // ResetConditions resets all changes to the "conditions" field.
  16310. func (m *LabelMutation) ResetConditions() {
  16311. m.conditions = nil
  16312. delete(m.clearedFields, label.FieldConditions)
  16313. }
  16314. // SetOrganizationID sets the "organization_id" field.
  16315. func (m *LabelMutation) SetOrganizationID(u uint64) {
  16316. m.organization_id = &u
  16317. m.addorganization_id = nil
  16318. }
  16319. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16320. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  16321. v := m.organization_id
  16322. if v == nil {
  16323. return
  16324. }
  16325. return *v, true
  16326. }
  16327. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  16328. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16330. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16331. if !m.op.Is(OpUpdateOne) {
  16332. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16333. }
  16334. if m.id == nil || m.oldValue == nil {
  16335. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16336. }
  16337. oldValue, err := m.oldValue(ctx)
  16338. if err != nil {
  16339. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16340. }
  16341. return oldValue.OrganizationID, nil
  16342. }
  16343. // AddOrganizationID adds u to the "organization_id" field.
  16344. func (m *LabelMutation) AddOrganizationID(u int64) {
  16345. if m.addorganization_id != nil {
  16346. *m.addorganization_id += u
  16347. } else {
  16348. m.addorganization_id = &u
  16349. }
  16350. }
  16351. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16352. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  16353. v := m.addorganization_id
  16354. if v == nil {
  16355. return
  16356. }
  16357. return *v, true
  16358. }
  16359. // ClearOrganizationID clears the value of the "organization_id" field.
  16360. func (m *LabelMutation) ClearOrganizationID() {
  16361. m.organization_id = nil
  16362. m.addorganization_id = nil
  16363. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  16364. }
  16365. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16366. func (m *LabelMutation) OrganizationIDCleared() bool {
  16367. _, ok := m.clearedFields[label.FieldOrganizationID]
  16368. return ok
  16369. }
  16370. // ResetOrganizationID resets all changes to the "organization_id" field.
  16371. func (m *LabelMutation) ResetOrganizationID() {
  16372. m.organization_id = nil
  16373. m.addorganization_id = nil
  16374. delete(m.clearedFields, label.FieldOrganizationID)
  16375. }
  16376. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  16377. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  16378. if m.label_relationships == nil {
  16379. m.label_relationships = make(map[uint64]struct{})
  16380. }
  16381. for i := range ids {
  16382. m.label_relationships[ids[i]] = struct{}{}
  16383. }
  16384. }
  16385. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  16386. func (m *LabelMutation) ClearLabelRelationships() {
  16387. m.clearedlabel_relationships = true
  16388. }
  16389. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  16390. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  16391. return m.clearedlabel_relationships
  16392. }
  16393. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  16394. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  16395. if m.removedlabel_relationships == nil {
  16396. m.removedlabel_relationships = make(map[uint64]struct{})
  16397. }
  16398. for i := range ids {
  16399. delete(m.label_relationships, ids[i])
  16400. m.removedlabel_relationships[ids[i]] = struct{}{}
  16401. }
  16402. }
  16403. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  16404. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  16405. for id := range m.removedlabel_relationships {
  16406. ids = append(ids, id)
  16407. }
  16408. return
  16409. }
  16410. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  16411. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  16412. for id := range m.label_relationships {
  16413. ids = append(ids, id)
  16414. }
  16415. return
  16416. }
  16417. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  16418. func (m *LabelMutation) ResetLabelRelationships() {
  16419. m.label_relationships = nil
  16420. m.clearedlabel_relationships = false
  16421. m.removedlabel_relationships = nil
  16422. }
  16423. // Where appends a list predicates to the LabelMutation builder.
  16424. func (m *LabelMutation) Where(ps ...predicate.Label) {
  16425. m.predicates = append(m.predicates, ps...)
  16426. }
  16427. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  16428. // users can use type-assertion to append predicates that do not depend on any generated package.
  16429. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  16430. p := make([]predicate.Label, len(ps))
  16431. for i := range ps {
  16432. p[i] = ps[i]
  16433. }
  16434. m.Where(p...)
  16435. }
  16436. // Op returns the operation name.
  16437. func (m *LabelMutation) Op() Op {
  16438. return m.op
  16439. }
  16440. // SetOp allows setting the mutation operation.
  16441. func (m *LabelMutation) SetOp(op Op) {
  16442. m.op = op
  16443. }
  16444. // Type returns the node type of this mutation (Label).
  16445. func (m *LabelMutation) Type() string {
  16446. return m.typ
  16447. }
  16448. // Fields returns all fields that were changed during this mutation. Note that in
  16449. // order to get all numeric fields that were incremented/decremented, call
  16450. // AddedFields().
  16451. func (m *LabelMutation) Fields() []string {
  16452. fields := make([]string, 0, 9)
  16453. if m.created_at != nil {
  16454. fields = append(fields, label.FieldCreatedAt)
  16455. }
  16456. if m.updated_at != nil {
  16457. fields = append(fields, label.FieldUpdatedAt)
  16458. }
  16459. if m.status != nil {
  16460. fields = append(fields, label.FieldStatus)
  16461. }
  16462. if m._type != nil {
  16463. fields = append(fields, label.FieldType)
  16464. }
  16465. if m.name != nil {
  16466. fields = append(fields, label.FieldName)
  16467. }
  16468. if m.from != nil {
  16469. fields = append(fields, label.FieldFrom)
  16470. }
  16471. if m.mode != nil {
  16472. fields = append(fields, label.FieldMode)
  16473. }
  16474. if m.conditions != nil {
  16475. fields = append(fields, label.FieldConditions)
  16476. }
  16477. if m.organization_id != nil {
  16478. fields = append(fields, label.FieldOrganizationID)
  16479. }
  16480. return fields
  16481. }
  16482. // Field returns the value of a field with the given name. The second boolean
  16483. // return value indicates that this field was not set, or was not defined in the
  16484. // schema.
  16485. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  16486. switch name {
  16487. case label.FieldCreatedAt:
  16488. return m.CreatedAt()
  16489. case label.FieldUpdatedAt:
  16490. return m.UpdatedAt()
  16491. case label.FieldStatus:
  16492. return m.Status()
  16493. case label.FieldType:
  16494. return m.GetType()
  16495. case label.FieldName:
  16496. return m.Name()
  16497. case label.FieldFrom:
  16498. return m.From()
  16499. case label.FieldMode:
  16500. return m.Mode()
  16501. case label.FieldConditions:
  16502. return m.Conditions()
  16503. case label.FieldOrganizationID:
  16504. return m.OrganizationID()
  16505. }
  16506. return nil, false
  16507. }
  16508. // OldField returns the old value of the field from the database. An error is
  16509. // returned if the mutation operation is not UpdateOne, or the query to the
  16510. // database failed.
  16511. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16512. switch name {
  16513. case label.FieldCreatedAt:
  16514. return m.OldCreatedAt(ctx)
  16515. case label.FieldUpdatedAt:
  16516. return m.OldUpdatedAt(ctx)
  16517. case label.FieldStatus:
  16518. return m.OldStatus(ctx)
  16519. case label.FieldType:
  16520. return m.OldType(ctx)
  16521. case label.FieldName:
  16522. return m.OldName(ctx)
  16523. case label.FieldFrom:
  16524. return m.OldFrom(ctx)
  16525. case label.FieldMode:
  16526. return m.OldMode(ctx)
  16527. case label.FieldConditions:
  16528. return m.OldConditions(ctx)
  16529. case label.FieldOrganizationID:
  16530. return m.OldOrganizationID(ctx)
  16531. }
  16532. return nil, fmt.Errorf("unknown Label field %s", name)
  16533. }
  16534. // SetField sets the value of a field with the given name. It returns an error if
  16535. // the field is not defined in the schema, or if the type mismatched the field
  16536. // type.
  16537. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  16538. switch name {
  16539. case label.FieldCreatedAt:
  16540. v, ok := value.(time.Time)
  16541. if !ok {
  16542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16543. }
  16544. m.SetCreatedAt(v)
  16545. return nil
  16546. case label.FieldUpdatedAt:
  16547. v, ok := value.(time.Time)
  16548. if !ok {
  16549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16550. }
  16551. m.SetUpdatedAt(v)
  16552. return nil
  16553. case label.FieldStatus:
  16554. v, ok := value.(uint8)
  16555. if !ok {
  16556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16557. }
  16558. m.SetStatus(v)
  16559. return nil
  16560. case label.FieldType:
  16561. v, ok := value.(int)
  16562. if !ok {
  16563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16564. }
  16565. m.SetType(v)
  16566. return nil
  16567. case label.FieldName:
  16568. v, ok := value.(string)
  16569. if !ok {
  16570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16571. }
  16572. m.SetName(v)
  16573. return nil
  16574. case label.FieldFrom:
  16575. v, ok := value.(int)
  16576. if !ok {
  16577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16578. }
  16579. m.SetFrom(v)
  16580. return nil
  16581. case label.FieldMode:
  16582. v, ok := value.(int)
  16583. if !ok {
  16584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16585. }
  16586. m.SetMode(v)
  16587. return nil
  16588. case label.FieldConditions:
  16589. v, ok := value.(string)
  16590. if !ok {
  16591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16592. }
  16593. m.SetConditions(v)
  16594. return nil
  16595. case label.FieldOrganizationID:
  16596. v, ok := value.(uint64)
  16597. if !ok {
  16598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16599. }
  16600. m.SetOrganizationID(v)
  16601. return nil
  16602. }
  16603. return fmt.Errorf("unknown Label field %s", name)
  16604. }
  16605. // AddedFields returns all numeric fields that were incremented/decremented during
  16606. // this mutation.
  16607. func (m *LabelMutation) AddedFields() []string {
  16608. var fields []string
  16609. if m.addstatus != nil {
  16610. fields = append(fields, label.FieldStatus)
  16611. }
  16612. if m.add_type != nil {
  16613. fields = append(fields, label.FieldType)
  16614. }
  16615. if m.addfrom != nil {
  16616. fields = append(fields, label.FieldFrom)
  16617. }
  16618. if m.addmode != nil {
  16619. fields = append(fields, label.FieldMode)
  16620. }
  16621. if m.addorganization_id != nil {
  16622. fields = append(fields, label.FieldOrganizationID)
  16623. }
  16624. return fields
  16625. }
  16626. // AddedField returns the numeric value that was incremented/decremented on a field
  16627. // with the given name. The second boolean return value indicates that this field
  16628. // was not set, or was not defined in the schema.
  16629. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  16630. switch name {
  16631. case label.FieldStatus:
  16632. return m.AddedStatus()
  16633. case label.FieldType:
  16634. return m.AddedType()
  16635. case label.FieldFrom:
  16636. return m.AddedFrom()
  16637. case label.FieldMode:
  16638. return m.AddedMode()
  16639. case label.FieldOrganizationID:
  16640. return m.AddedOrganizationID()
  16641. }
  16642. return nil, false
  16643. }
  16644. // AddField adds the value to the field with the given name. It returns an error if
  16645. // the field is not defined in the schema, or if the type mismatched the field
  16646. // type.
  16647. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  16648. switch name {
  16649. case label.FieldStatus:
  16650. v, ok := value.(int8)
  16651. if !ok {
  16652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16653. }
  16654. m.AddStatus(v)
  16655. return nil
  16656. case label.FieldType:
  16657. v, ok := value.(int)
  16658. if !ok {
  16659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16660. }
  16661. m.AddType(v)
  16662. return nil
  16663. case label.FieldFrom:
  16664. v, ok := value.(int)
  16665. if !ok {
  16666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16667. }
  16668. m.AddFrom(v)
  16669. return nil
  16670. case label.FieldMode:
  16671. v, ok := value.(int)
  16672. if !ok {
  16673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16674. }
  16675. m.AddMode(v)
  16676. return nil
  16677. case label.FieldOrganizationID:
  16678. v, ok := value.(int64)
  16679. if !ok {
  16680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16681. }
  16682. m.AddOrganizationID(v)
  16683. return nil
  16684. }
  16685. return fmt.Errorf("unknown Label numeric field %s", name)
  16686. }
  16687. // ClearedFields returns all nullable fields that were cleared during this
  16688. // mutation.
  16689. func (m *LabelMutation) ClearedFields() []string {
  16690. var fields []string
  16691. if m.FieldCleared(label.FieldStatus) {
  16692. fields = append(fields, label.FieldStatus)
  16693. }
  16694. if m.FieldCleared(label.FieldConditions) {
  16695. fields = append(fields, label.FieldConditions)
  16696. }
  16697. if m.FieldCleared(label.FieldOrganizationID) {
  16698. fields = append(fields, label.FieldOrganizationID)
  16699. }
  16700. return fields
  16701. }
  16702. // FieldCleared returns a boolean indicating if a field with the given name was
  16703. // cleared in this mutation.
  16704. func (m *LabelMutation) FieldCleared(name string) bool {
  16705. _, ok := m.clearedFields[name]
  16706. return ok
  16707. }
  16708. // ClearField clears the value of the field with the given name. It returns an
  16709. // error if the field is not defined in the schema.
  16710. func (m *LabelMutation) ClearField(name string) error {
  16711. switch name {
  16712. case label.FieldStatus:
  16713. m.ClearStatus()
  16714. return nil
  16715. case label.FieldConditions:
  16716. m.ClearConditions()
  16717. return nil
  16718. case label.FieldOrganizationID:
  16719. m.ClearOrganizationID()
  16720. return nil
  16721. }
  16722. return fmt.Errorf("unknown Label nullable field %s", name)
  16723. }
  16724. // ResetField resets all changes in the mutation for the field with the given name.
  16725. // It returns an error if the field is not defined in the schema.
  16726. func (m *LabelMutation) ResetField(name string) error {
  16727. switch name {
  16728. case label.FieldCreatedAt:
  16729. m.ResetCreatedAt()
  16730. return nil
  16731. case label.FieldUpdatedAt:
  16732. m.ResetUpdatedAt()
  16733. return nil
  16734. case label.FieldStatus:
  16735. m.ResetStatus()
  16736. return nil
  16737. case label.FieldType:
  16738. m.ResetType()
  16739. return nil
  16740. case label.FieldName:
  16741. m.ResetName()
  16742. return nil
  16743. case label.FieldFrom:
  16744. m.ResetFrom()
  16745. return nil
  16746. case label.FieldMode:
  16747. m.ResetMode()
  16748. return nil
  16749. case label.FieldConditions:
  16750. m.ResetConditions()
  16751. return nil
  16752. case label.FieldOrganizationID:
  16753. m.ResetOrganizationID()
  16754. return nil
  16755. }
  16756. return fmt.Errorf("unknown Label field %s", name)
  16757. }
  16758. // AddedEdges returns all edge names that were set/added in this mutation.
  16759. func (m *LabelMutation) AddedEdges() []string {
  16760. edges := make([]string, 0, 1)
  16761. if m.label_relationships != nil {
  16762. edges = append(edges, label.EdgeLabelRelationships)
  16763. }
  16764. return edges
  16765. }
  16766. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16767. // name in this mutation.
  16768. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  16769. switch name {
  16770. case label.EdgeLabelRelationships:
  16771. ids := make([]ent.Value, 0, len(m.label_relationships))
  16772. for id := range m.label_relationships {
  16773. ids = append(ids, id)
  16774. }
  16775. return ids
  16776. }
  16777. return nil
  16778. }
  16779. // RemovedEdges returns all edge names that were removed in this mutation.
  16780. func (m *LabelMutation) RemovedEdges() []string {
  16781. edges := make([]string, 0, 1)
  16782. if m.removedlabel_relationships != nil {
  16783. edges = append(edges, label.EdgeLabelRelationships)
  16784. }
  16785. return edges
  16786. }
  16787. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16788. // the given name in this mutation.
  16789. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  16790. switch name {
  16791. case label.EdgeLabelRelationships:
  16792. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  16793. for id := range m.removedlabel_relationships {
  16794. ids = append(ids, id)
  16795. }
  16796. return ids
  16797. }
  16798. return nil
  16799. }
  16800. // ClearedEdges returns all edge names that were cleared in this mutation.
  16801. func (m *LabelMutation) ClearedEdges() []string {
  16802. edges := make([]string, 0, 1)
  16803. if m.clearedlabel_relationships {
  16804. edges = append(edges, label.EdgeLabelRelationships)
  16805. }
  16806. return edges
  16807. }
  16808. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16809. // was cleared in this mutation.
  16810. func (m *LabelMutation) EdgeCleared(name string) bool {
  16811. switch name {
  16812. case label.EdgeLabelRelationships:
  16813. return m.clearedlabel_relationships
  16814. }
  16815. return false
  16816. }
  16817. // ClearEdge clears the value of the edge with the given name. It returns an error
  16818. // if that edge is not defined in the schema.
  16819. func (m *LabelMutation) ClearEdge(name string) error {
  16820. switch name {
  16821. }
  16822. return fmt.Errorf("unknown Label unique edge %s", name)
  16823. }
  16824. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16825. // It returns an error if the edge is not defined in the schema.
  16826. func (m *LabelMutation) ResetEdge(name string) error {
  16827. switch name {
  16828. case label.EdgeLabelRelationships:
  16829. m.ResetLabelRelationships()
  16830. return nil
  16831. }
  16832. return fmt.Errorf("unknown Label edge %s", name)
  16833. }
  16834. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  16835. type LabelRelationshipMutation struct {
  16836. config
  16837. op Op
  16838. typ string
  16839. id *uint64
  16840. created_at *time.Time
  16841. updated_at *time.Time
  16842. status *uint8
  16843. addstatus *int8
  16844. organization_id *uint64
  16845. addorganization_id *int64
  16846. clearedFields map[string]struct{}
  16847. contacts *uint64
  16848. clearedcontacts bool
  16849. labels *uint64
  16850. clearedlabels bool
  16851. done bool
  16852. oldValue func(context.Context) (*LabelRelationship, error)
  16853. predicates []predicate.LabelRelationship
  16854. }
  16855. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  16856. // labelrelationshipOption allows management of the mutation configuration using functional options.
  16857. type labelrelationshipOption func(*LabelRelationshipMutation)
  16858. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  16859. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  16860. m := &LabelRelationshipMutation{
  16861. config: c,
  16862. op: op,
  16863. typ: TypeLabelRelationship,
  16864. clearedFields: make(map[string]struct{}),
  16865. }
  16866. for _, opt := range opts {
  16867. opt(m)
  16868. }
  16869. return m
  16870. }
  16871. // withLabelRelationshipID sets the ID field of the mutation.
  16872. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  16873. return func(m *LabelRelationshipMutation) {
  16874. var (
  16875. err error
  16876. once sync.Once
  16877. value *LabelRelationship
  16878. )
  16879. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  16880. once.Do(func() {
  16881. if m.done {
  16882. err = errors.New("querying old values post mutation is not allowed")
  16883. } else {
  16884. value, err = m.Client().LabelRelationship.Get(ctx, id)
  16885. }
  16886. })
  16887. return value, err
  16888. }
  16889. m.id = &id
  16890. }
  16891. }
  16892. // withLabelRelationship sets the old LabelRelationship of the mutation.
  16893. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  16894. return func(m *LabelRelationshipMutation) {
  16895. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  16896. return node, nil
  16897. }
  16898. m.id = &node.ID
  16899. }
  16900. }
  16901. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16902. // executed in a transaction (ent.Tx), a transactional client is returned.
  16903. func (m LabelRelationshipMutation) Client() *Client {
  16904. client := &Client{config: m.config}
  16905. client.init()
  16906. return client
  16907. }
  16908. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16909. // it returns an error otherwise.
  16910. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  16911. if _, ok := m.driver.(*txDriver); !ok {
  16912. return nil, errors.New("ent: mutation is not running in a transaction")
  16913. }
  16914. tx := &Tx{config: m.config}
  16915. tx.init()
  16916. return tx, nil
  16917. }
  16918. // SetID sets the value of the id field. Note that this
  16919. // operation is only accepted on creation of LabelRelationship entities.
  16920. func (m *LabelRelationshipMutation) SetID(id uint64) {
  16921. m.id = &id
  16922. }
  16923. // ID returns the ID value in the mutation. Note that the ID is only available
  16924. // if it was provided to the builder or after it was returned from the database.
  16925. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  16926. if m.id == nil {
  16927. return
  16928. }
  16929. return *m.id, true
  16930. }
  16931. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16932. // That means, if the mutation is applied within a transaction with an isolation level such
  16933. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16934. // or updated by the mutation.
  16935. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  16936. switch {
  16937. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16938. id, exists := m.ID()
  16939. if exists {
  16940. return []uint64{id}, nil
  16941. }
  16942. fallthrough
  16943. case m.op.Is(OpUpdate | OpDelete):
  16944. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  16945. default:
  16946. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16947. }
  16948. }
  16949. // SetCreatedAt sets the "created_at" field.
  16950. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  16951. m.created_at = &t
  16952. }
  16953. // CreatedAt returns the value of the "created_at" field in the mutation.
  16954. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  16955. v := m.created_at
  16956. if v == nil {
  16957. return
  16958. }
  16959. return *v, true
  16960. }
  16961. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  16962. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16964. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16965. if !m.op.Is(OpUpdateOne) {
  16966. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16967. }
  16968. if m.id == nil || m.oldValue == nil {
  16969. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16970. }
  16971. oldValue, err := m.oldValue(ctx)
  16972. if err != nil {
  16973. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16974. }
  16975. return oldValue.CreatedAt, nil
  16976. }
  16977. // ResetCreatedAt resets all changes to the "created_at" field.
  16978. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  16979. m.created_at = nil
  16980. }
  16981. // SetUpdatedAt sets the "updated_at" field.
  16982. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  16983. m.updated_at = &t
  16984. }
  16985. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16986. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  16987. v := m.updated_at
  16988. if v == nil {
  16989. return
  16990. }
  16991. return *v, true
  16992. }
  16993. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  16994. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16996. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16997. if !m.op.Is(OpUpdateOne) {
  16998. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16999. }
  17000. if m.id == nil || m.oldValue == nil {
  17001. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17002. }
  17003. oldValue, err := m.oldValue(ctx)
  17004. if err != nil {
  17005. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17006. }
  17007. return oldValue.UpdatedAt, nil
  17008. }
  17009. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17010. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  17011. m.updated_at = nil
  17012. }
  17013. // SetStatus sets the "status" field.
  17014. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  17015. m.status = &u
  17016. m.addstatus = nil
  17017. }
  17018. // Status returns the value of the "status" field in the mutation.
  17019. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  17020. v := m.status
  17021. if v == nil {
  17022. return
  17023. }
  17024. return *v, true
  17025. }
  17026. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  17027. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17029. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17030. if !m.op.Is(OpUpdateOne) {
  17031. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17032. }
  17033. if m.id == nil || m.oldValue == nil {
  17034. return v, errors.New("OldStatus requires an ID field in the mutation")
  17035. }
  17036. oldValue, err := m.oldValue(ctx)
  17037. if err != nil {
  17038. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17039. }
  17040. return oldValue.Status, nil
  17041. }
  17042. // AddStatus adds u to the "status" field.
  17043. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  17044. if m.addstatus != nil {
  17045. *m.addstatus += u
  17046. } else {
  17047. m.addstatus = &u
  17048. }
  17049. }
  17050. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17051. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  17052. v := m.addstatus
  17053. if v == nil {
  17054. return
  17055. }
  17056. return *v, true
  17057. }
  17058. // ClearStatus clears the value of the "status" field.
  17059. func (m *LabelRelationshipMutation) ClearStatus() {
  17060. m.status = nil
  17061. m.addstatus = nil
  17062. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  17063. }
  17064. // StatusCleared returns if the "status" field was cleared in this mutation.
  17065. func (m *LabelRelationshipMutation) StatusCleared() bool {
  17066. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  17067. return ok
  17068. }
  17069. // ResetStatus resets all changes to the "status" field.
  17070. func (m *LabelRelationshipMutation) ResetStatus() {
  17071. m.status = nil
  17072. m.addstatus = nil
  17073. delete(m.clearedFields, labelrelationship.FieldStatus)
  17074. }
  17075. // SetLabelID sets the "label_id" field.
  17076. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  17077. m.labels = &u
  17078. }
  17079. // LabelID returns the value of the "label_id" field in the mutation.
  17080. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  17081. v := m.labels
  17082. if v == nil {
  17083. return
  17084. }
  17085. return *v, true
  17086. }
  17087. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  17088. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17090. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  17091. if !m.op.Is(OpUpdateOne) {
  17092. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  17093. }
  17094. if m.id == nil || m.oldValue == nil {
  17095. return v, errors.New("OldLabelID requires an ID field in the mutation")
  17096. }
  17097. oldValue, err := m.oldValue(ctx)
  17098. if err != nil {
  17099. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  17100. }
  17101. return oldValue.LabelID, nil
  17102. }
  17103. // ResetLabelID resets all changes to the "label_id" field.
  17104. func (m *LabelRelationshipMutation) ResetLabelID() {
  17105. m.labels = nil
  17106. }
  17107. // SetContactID sets the "contact_id" field.
  17108. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  17109. m.contacts = &u
  17110. }
  17111. // ContactID returns the value of the "contact_id" field in the mutation.
  17112. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  17113. v := m.contacts
  17114. if v == nil {
  17115. return
  17116. }
  17117. return *v, true
  17118. }
  17119. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  17120. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17122. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  17123. if !m.op.Is(OpUpdateOne) {
  17124. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  17125. }
  17126. if m.id == nil || m.oldValue == nil {
  17127. return v, errors.New("OldContactID requires an ID field in the mutation")
  17128. }
  17129. oldValue, err := m.oldValue(ctx)
  17130. if err != nil {
  17131. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  17132. }
  17133. return oldValue.ContactID, nil
  17134. }
  17135. // ResetContactID resets all changes to the "contact_id" field.
  17136. func (m *LabelRelationshipMutation) ResetContactID() {
  17137. m.contacts = nil
  17138. }
  17139. // SetOrganizationID sets the "organization_id" field.
  17140. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  17141. m.organization_id = &u
  17142. m.addorganization_id = nil
  17143. }
  17144. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17145. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  17146. v := m.organization_id
  17147. if v == nil {
  17148. return
  17149. }
  17150. return *v, true
  17151. }
  17152. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  17153. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17155. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17156. if !m.op.Is(OpUpdateOne) {
  17157. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17158. }
  17159. if m.id == nil || m.oldValue == nil {
  17160. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17161. }
  17162. oldValue, err := m.oldValue(ctx)
  17163. if err != nil {
  17164. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17165. }
  17166. return oldValue.OrganizationID, nil
  17167. }
  17168. // AddOrganizationID adds u to the "organization_id" field.
  17169. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  17170. if m.addorganization_id != nil {
  17171. *m.addorganization_id += u
  17172. } else {
  17173. m.addorganization_id = &u
  17174. }
  17175. }
  17176. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17177. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  17178. v := m.addorganization_id
  17179. if v == nil {
  17180. return
  17181. }
  17182. return *v, true
  17183. }
  17184. // ClearOrganizationID clears the value of the "organization_id" field.
  17185. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  17186. m.organization_id = nil
  17187. m.addorganization_id = nil
  17188. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  17189. }
  17190. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17191. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  17192. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  17193. return ok
  17194. }
  17195. // ResetOrganizationID resets all changes to the "organization_id" field.
  17196. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  17197. m.organization_id = nil
  17198. m.addorganization_id = nil
  17199. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  17200. }
  17201. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  17202. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  17203. m.contacts = &id
  17204. }
  17205. // ClearContacts clears the "contacts" edge to the Contact entity.
  17206. func (m *LabelRelationshipMutation) ClearContacts() {
  17207. m.clearedcontacts = true
  17208. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  17209. }
  17210. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  17211. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  17212. return m.clearedcontacts
  17213. }
  17214. // ContactsID returns the "contacts" edge ID in the mutation.
  17215. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  17216. if m.contacts != nil {
  17217. return *m.contacts, true
  17218. }
  17219. return
  17220. }
  17221. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  17222. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17223. // ContactsID instead. It exists only for internal usage by the builders.
  17224. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  17225. if id := m.contacts; id != nil {
  17226. ids = append(ids, *id)
  17227. }
  17228. return
  17229. }
  17230. // ResetContacts resets all changes to the "contacts" edge.
  17231. func (m *LabelRelationshipMutation) ResetContacts() {
  17232. m.contacts = nil
  17233. m.clearedcontacts = false
  17234. }
  17235. // SetLabelsID sets the "labels" edge to the Label entity by id.
  17236. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  17237. m.labels = &id
  17238. }
  17239. // ClearLabels clears the "labels" edge to the Label entity.
  17240. func (m *LabelRelationshipMutation) ClearLabels() {
  17241. m.clearedlabels = true
  17242. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  17243. }
  17244. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  17245. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  17246. return m.clearedlabels
  17247. }
  17248. // LabelsID returns the "labels" edge ID in the mutation.
  17249. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  17250. if m.labels != nil {
  17251. return *m.labels, true
  17252. }
  17253. return
  17254. }
  17255. // LabelsIDs returns the "labels" edge IDs in the mutation.
  17256. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17257. // LabelsID instead. It exists only for internal usage by the builders.
  17258. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  17259. if id := m.labels; id != nil {
  17260. ids = append(ids, *id)
  17261. }
  17262. return
  17263. }
  17264. // ResetLabels resets all changes to the "labels" edge.
  17265. func (m *LabelRelationshipMutation) ResetLabels() {
  17266. m.labels = nil
  17267. m.clearedlabels = false
  17268. }
  17269. // Where appends a list predicates to the LabelRelationshipMutation builder.
  17270. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  17271. m.predicates = append(m.predicates, ps...)
  17272. }
  17273. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  17274. // users can use type-assertion to append predicates that do not depend on any generated package.
  17275. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  17276. p := make([]predicate.LabelRelationship, len(ps))
  17277. for i := range ps {
  17278. p[i] = ps[i]
  17279. }
  17280. m.Where(p...)
  17281. }
  17282. // Op returns the operation name.
  17283. func (m *LabelRelationshipMutation) Op() Op {
  17284. return m.op
  17285. }
  17286. // SetOp allows setting the mutation operation.
  17287. func (m *LabelRelationshipMutation) SetOp(op Op) {
  17288. m.op = op
  17289. }
  17290. // Type returns the node type of this mutation (LabelRelationship).
  17291. func (m *LabelRelationshipMutation) Type() string {
  17292. return m.typ
  17293. }
  17294. // Fields returns all fields that were changed during this mutation. Note that in
  17295. // order to get all numeric fields that were incremented/decremented, call
  17296. // AddedFields().
  17297. func (m *LabelRelationshipMutation) Fields() []string {
  17298. fields := make([]string, 0, 6)
  17299. if m.created_at != nil {
  17300. fields = append(fields, labelrelationship.FieldCreatedAt)
  17301. }
  17302. if m.updated_at != nil {
  17303. fields = append(fields, labelrelationship.FieldUpdatedAt)
  17304. }
  17305. if m.status != nil {
  17306. fields = append(fields, labelrelationship.FieldStatus)
  17307. }
  17308. if m.labels != nil {
  17309. fields = append(fields, labelrelationship.FieldLabelID)
  17310. }
  17311. if m.contacts != nil {
  17312. fields = append(fields, labelrelationship.FieldContactID)
  17313. }
  17314. if m.organization_id != nil {
  17315. fields = append(fields, labelrelationship.FieldOrganizationID)
  17316. }
  17317. return fields
  17318. }
  17319. // Field returns the value of a field with the given name. The second boolean
  17320. // return value indicates that this field was not set, or was not defined in the
  17321. // schema.
  17322. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  17323. switch name {
  17324. case labelrelationship.FieldCreatedAt:
  17325. return m.CreatedAt()
  17326. case labelrelationship.FieldUpdatedAt:
  17327. return m.UpdatedAt()
  17328. case labelrelationship.FieldStatus:
  17329. return m.Status()
  17330. case labelrelationship.FieldLabelID:
  17331. return m.LabelID()
  17332. case labelrelationship.FieldContactID:
  17333. return m.ContactID()
  17334. case labelrelationship.FieldOrganizationID:
  17335. return m.OrganizationID()
  17336. }
  17337. return nil, false
  17338. }
  17339. // OldField returns the old value of the field from the database. An error is
  17340. // returned if the mutation operation is not UpdateOne, or the query to the
  17341. // database failed.
  17342. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17343. switch name {
  17344. case labelrelationship.FieldCreatedAt:
  17345. return m.OldCreatedAt(ctx)
  17346. case labelrelationship.FieldUpdatedAt:
  17347. return m.OldUpdatedAt(ctx)
  17348. case labelrelationship.FieldStatus:
  17349. return m.OldStatus(ctx)
  17350. case labelrelationship.FieldLabelID:
  17351. return m.OldLabelID(ctx)
  17352. case labelrelationship.FieldContactID:
  17353. return m.OldContactID(ctx)
  17354. case labelrelationship.FieldOrganizationID:
  17355. return m.OldOrganizationID(ctx)
  17356. }
  17357. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  17358. }
  17359. // SetField sets the value of a field with the given name. It returns an error if
  17360. // the field is not defined in the schema, or if the type mismatched the field
  17361. // type.
  17362. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  17363. switch name {
  17364. case labelrelationship.FieldCreatedAt:
  17365. v, ok := value.(time.Time)
  17366. if !ok {
  17367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17368. }
  17369. m.SetCreatedAt(v)
  17370. return nil
  17371. case labelrelationship.FieldUpdatedAt:
  17372. v, ok := value.(time.Time)
  17373. if !ok {
  17374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17375. }
  17376. m.SetUpdatedAt(v)
  17377. return nil
  17378. case labelrelationship.FieldStatus:
  17379. v, ok := value.(uint8)
  17380. if !ok {
  17381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17382. }
  17383. m.SetStatus(v)
  17384. return nil
  17385. case labelrelationship.FieldLabelID:
  17386. v, ok := value.(uint64)
  17387. if !ok {
  17388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17389. }
  17390. m.SetLabelID(v)
  17391. return nil
  17392. case labelrelationship.FieldContactID:
  17393. v, ok := value.(uint64)
  17394. if !ok {
  17395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17396. }
  17397. m.SetContactID(v)
  17398. return nil
  17399. case labelrelationship.FieldOrganizationID:
  17400. v, ok := value.(uint64)
  17401. if !ok {
  17402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17403. }
  17404. m.SetOrganizationID(v)
  17405. return nil
  17406. }
  17407. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17408. }
  17409. // AddedFields returns all numeric fields that were incremented/decremented during
  17410. // this mutation.
  17411. func (m *LabelRelationshipMutation) AddedFields() []string {
  17412. var fields []string
  17413. if m.addstatus != nil {
  17414. fields = append(fields, labelrelationship.FieldStatus)
  17415. }
  17416. if m.addorganization_id != nil {
  17417. fields = append(fields, labelrelationship.FieldOrganizationID)
  17418. }
  17419. return fields
  17420. }
  17421. // AddedField returns the numeric value that was incremented/decremented on a field
  17422. // with the given name. The second boolean return value indicates that this field
  17423. // was not set, or was not defined in the schema.
  17424. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  17425. switch name {
  17426. case labelrelationship.FieldStatus:
  17427. return m.AddedStatus()
  17428. case labelrelationship.FieldOrganizationID:
  17429. return m.AddedOrganizationID()
  17430. }
  17431. return nil, false
  17432. }
  17433. // AddField adds the value to the field with the given name. It returns an error if
  17434. // the field is not defined in the schema, or if the type mismatched the field
  17435. // type.
  17436. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  17437. switch name {
  17438. case labelrelationship.FieldStatus:
  17439. v, ok := value.(int8)
  17440. if !ok {
  17441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17442. }
  17443. m.AddStatus(v)
  17444. return nil
  17445. case labelrelationship.FieldOrganizationID:
  17446. v, ok := value.(int64)
  17447. if !ok {
  17448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17449. }
  17450. m.AddOrganizationID(v)
  17451. return nil
  17452. }
  17453. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  17454. }
  17455. // ClearedFields returns all nullable fields that were cleared during this
  17456. // mutation.
  17457. func (m *LabelRelationshipMutation) ClearedFields() []string {
  17458. var fields []string
  17459. if m.FieldCleared(labelrelationship.FieldStatus) {
  17460. fields = append(fields, labelrelationship.FieldStatus)
  17461. }
  17462. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  17463. fields = append(fields, labelrelationship.FieldOrganizationID)
  17464. }
  17465. return fields
  17466. }
  17467. // FieldCleared returns a boolean indicating if a field with the given name was
  17468. // cleared in this mutation.
  17469. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  17470. _, ok := m.clearedFields[name]
  17471. return ok
  17472. }
  17473. // ClearField clears the value of the field with the given name. It returns an
  17474. // error if the field is not defined in the schema.
  17475. func (m *LabelRelationshipMutation) ClearField(name string) error {
  17476. switch name {
  17477. case labelrelationship.FieldStatus:
  17478. m.ClearStatus()
  17479. return nil
  17480. case labelrelationship.FieldOrganizationID:
  17481. m.ClearOrganizationID()
  17482. return nil
  17483. }
  17484. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  17485. }
  17486. // ResetField resets all changes in the mutation for the field with the given name.
  17487. // It returns an error if the field is not defined in the schema.
  17488. func (m *LabelRelationshipMutation) ResetField(name string) error {
  17489. switch name {
  17490. case labelrelationship.FieldCreatedAt:
  17491. m.ResetCreatedAt()
  17492. return nil
  17493. case labelrelationship.FieldUpdatedAt:
  17494. m.ResetUpdatedAt()
  17495. return nil
  17496. case labelrelationship.FieldStatus:
  17497. m.ResetStatus()
  17498. return nil
  17499. case labelrelationship.FieldLabelID:
  17500. m.ResetLabelID()
  17501. return nil
  17502. case labelrelationship.FieldContactID:
  17503. m.ResetContactID()
  17504. return nil
  17505. case labelrelationship.FieldOrganizationID:
  17506. m.ResetOrganizationID()
  17507. return nil
  17508. }
  17509. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17510. }
  17511. // AddedEdges returns all edge names that were set/added in this mutation.
  17512. func (m *LabelRelationshipMutation) AddedEdges() []string {
  17513. edges := make([]string, 0, 2)
  17514. if m.contacts != nil {
  17515. edges = append(edges, labelrelationship.EdgeContacts)
  17516. }
  17517. if m.labels != nil {
  17518. edges = append(edges, labelrelationship.EdgeLabels)
  17519. }
  17520. return edges
  17521. }
  17522. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17523. // name in this mutation.
  17524. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  17525. switch name {
  17526. case labelrelationship.EdgeContacts:
  17527. if id := m.contacts; id != nil {
  17528. return []ent.Value{*id}
  17529. }
  17530. case labelrelationship.EdgeLabels:
  17531. if id := m.labels; id != nil {
  17532. return []ent.Value{*id}
  17533. }
  17534. }
  17535. return nil
  17536. }
  17537. // RemovedEdges returns all edge names that were removed in this mutation.
  17538. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  17539. edges := make([]string, 0, 2)
  17540. return edges
  17541. }
  17542. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17543. // the given name in this mutation.
  17544. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  17545. return nil
  17546. }
  17547. // ClearedEdges returns all edge names that were cleared in this mutation.
  17548. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  17549. edges := make([]string, 0, 2)
  17550. if m.clearedcontacts {
  17551. edges = append(edges, labelrelationship.EdgeContacts)
  17552. }
  17553. if m.clearedlabels {
  17554. edges = append(edges, labelrelationship.EdgeLabels)
  17555. }
  17556. return edges
  17557. }
  17558. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17559. // was cleared in this mutation.
  17560. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  17561. switch name {
  17562. case labelrelationship.EdgeContacts:
  17563. return m.clearedcontacts
  17564. case labelrelationship.EdgeLabels:
  17565. return m.clearedlabels
  17566. }
  17567. return false
  17568. }
  17569. // ClearEdge clears the value of the edge with the given name. It returns an error
  17570. // if that edge is not defined in the schema.
  17571. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  17572. switch name {
  17573. case labelrelationship.EdgeContacts:
  17574. m.ClearContacts()
  17575. return nil
  17576. case labelrelationship.EdgeLabels:
  17577. m.ClearLabels()
  17578. return nil
  17579. }
  17580. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  17581. }
  17582. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17583. // It returns an error if the edge is not defined in the schema.
  17584. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  17585. switch name {
  17586. case labelrelationship.EdgeContacts:
  17587. m.ResetContacts()
  17588. return nil
  17589. case labelrelationship.EdgeLabels:
  17590. m.ResetLabels()
  17591. return nil
  17592. }
  17593. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  17594. }
  17595. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  17596. type LabelTaggingMutation struct {
  17597. config
  17598. op Op
  17599. typ string
  17600. id *uint64
  17601. created_at *time.Time
  17602. updated_at *time.Time
  17603. status *uint8
  17604. addstatus *int8
  17605. deleted_at *time.Time
  17606. organization_id *uint64
  17607. addorganization_id *int64
  17608. _type *int
  17609. add_type *int
  17610. conditions *string
  17611. action_label_add *[]uint64
  17612. appendaction_label_add []uint64
  17613. action_label_del *[]uint64
  17614. appendaction_label_del []uint64
  17615. clearedFields map[string]struct{}
  17616. done bool
  17617. oldValue func(context.Context) (*LabelTagging, error)
  17618. predicates []predicate.LabelTagging
  17619. }
  17620. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  17621. // labeltaggingOption allows management of the mutation configuration using functional options.
  17622. type labeltaggingOption func(*LabelTaggingMutation)
  17623. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  17624. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  17625. m := &LabelTaggingMutation{
  17626. config: c,
  17627. op: op,
  17628. typ: TypeLabelTagging,
  17629. clearedFields: make(map[string]struct{}),
  17630. }
  17631. for _, opt := range opts {
  17632. opt(m)
  17633. }
  17634. return m
  17635. }
  17636. // withLabelTaggingID sets the ID field of the mutation.
  17637. func withLabelTaggingID(id uint64) labeltaggingOption {
  17638. return func(m *LabelTaggingMutation) {
  17639. var (
  17640. err error
  17641. once sync.Once
  17642. value *LabelTagging
  17643. )
  17644. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  17645. once.Do(func() {
  17646. if m.done {
  17647. err = errors.New("querying old values post mutation is not allowed")
  17648. } else {
  17649. value, err = m.Client().LabelTagging.Get(ctx, id)
  17650. }
  17651. })
  17652. return value, err
  17653. }
  17654. m.id = &id
  17655. }
  17656. }
  17657. // withLabelTagging sets the old LabelTagging of the mutation.
  17658. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  17659. return func(m *LabelTaggingMutation) {
  17660. m.oldValue = func(context.Context) (*LabelTagging, error) {
  17661. return node, nil
  17662. }
  17663. m.id = &node.ID
  17664. }
  17665. }
  17666. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17667. // executed in a transaction (ent.Tx), a transactional client is returned.
  17668. func (m LabelTaggingMutation) Client() *Client {
  17669. client := &Client{config: m.config}
  17670. client.init()
  17671. return client
  17672. }
  17673. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17674. // it returns an error otherwise.
  17675. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  17676. if _, ok := m.driver.(*txDriver); !ok {
  17677. return nil, errors.New("ent: mutation is not running in a transaction")
  17678. }
  17679. tx := &Tx{config: m.config}
  17680. tx.init()
  17681. return tx, nil
  17682. }
  17683. // SetID sets the value of the id field. Note that this
  17684. // operation is only accepted on creation of LabelTagging entities.
  17685. func (m *LabelTaggingMutation) SetID(id uint64) {
  17686. m.id = &id
  17687. }
  17688. // ID returns the ID value in the mutation. Note that the ID is only available
  17689. // if it was provided to the builder or after it was returned from the database.
  17690. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  17691. if m.id == nil {
  17692. return
  17693. }
  17694. return *m.id, true
  17695. }
  17696. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17697. // That means, if the mutation is applied within a transaction with an isolation level such
  17698. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17699. // or updated by the mutation.
  17700. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  17701. switch {
  17702. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17703. id, exists := m.ID()
  17704. if exists {
  17705. return []uint64{id}, nil
  17706. }
  17707. fallthrough
  17708. case m.op.Is(OpUpdate | OpDelete):
  17709. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  17710. default:
  17711. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17712. }
  17713. }
  17714. // SetCreatedAt sets the "created_at" field.
  17715. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  17716. m.created_at = &t
  17717. }
  17718. // CreatedAt returns the value of the "created_at" field in the mutation.
  17719. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  17720. v := m.created_at
  17721. if v == nil {
  17722. return
  17723. }
  17724. return *v, true
  17725. }
  17726. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  17727. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17729. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17730. if !m.op.Is(OpUpdateOne) {
  17731. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17732. }
  17733. if m.id == nil || m.oldValue == nil {
  17734. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17735. }
  17736. oldValue, err := m.oldValue(ctx)
  17737. if err != nil {
  17738. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17739. }
  17740. return oldValue.CreatedAt, nil
  17741. }
  17742. // ResetCreatedAt resets all changes to the "created_at" field.
  17743. func (m *LabelTaggingMutation) ResetCreatedAt() {
  17744. m.created_at = nil
  17745. }
  17746. // SetUpdatedAt sets the "updated_at" field.
  17747. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  17748. m.updated_at = &t
  17749. }
  17750. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17751. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  17752. v := m.updated_at
  17753. if v == nil {
  17754. return
  17755. }
  17756. return *v, true
  17757. }
  17758. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  17759. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17761. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17762. if !m.op.Is(OpUpdateOne) {
  17763. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17764. }
  17765. if m.id == nil || m.oldValue == nil {
  17766. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17767. }
  17768. oldValue, err := m.oldValue(ctx)
  17769. if err != nil {
  17770. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17771. }
  17772. return oldValue.UpdatedAt, nil
  17773. }
  17774. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17775. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  17776. m.updated_at = nil
  17777. }
  17778. // SetStatus sets the "status" field.
  17779. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  17780. m.status = &u
  17781. m.addstatus = nil
  17782. }
  17783. // Status returns the value of the "status" field in the mutation.
  17784. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  17785. v := m.status
  17786. if v == nil {
  17787. return
  17788. }
  17789. return *v, true
  17790. }
  17791. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  17792. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17794. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17795. if !m.op.Is(OpUpdateOne) {
  17796. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17797. }
  17798. if m.id == nil || m.oldValue == nil {
  17799. return v, errors.New("OldStatus requires an ID field in the mutation")
  17800. }
  17801. oldValue, err := m.oldValue(ctx)
  17802. if err != nil {
  17803. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17804. }
  17805. return oldValue.Status, nil
  17806. }
  17807. // AddStatus adds u to the "status" field.
  17808. func (m *LabelTaggingMutation) AddStatus(u int8) {
  17809. if m.addstatus != nil {
  17810. *m.addstatus += u
  17811. } else {
  17812. m.addstatus = &u
  17813. }
  17814. }
  17815. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17816. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  17817. v := m.addstatus
  17818. if v == nil {
  17819. return
  17820. }
  17821. return *v, true
  17822. }
  17823. // ClearStatus clears the value of the "status" field.
  17824. func (m *LabelTaggingMutation) ClearStatus() {
  17825. m.status = nil
  17826. m.addstatus = nil
  17827. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  17828. }
  17829. // StatusCleared returns if the "status" field was cleared in this mutation.
  17830. func (m *LabelTaggingMutation) StatusCleared() bool {
  17831. _, ok := m.clearedFields[labeltagging.FieldStatus]
  17832. return ok
  17833. }
  17834. // ResetStatus resets all changes to the "status" field.
  17835. func (m *LabelTaggingMutation) ResetStatus() {
  17836. m.status = nil
  17837. m.addstatus = nil
  17838. delete(m.clearedFields, labeltagging.FieldStatus)
  17839. }
  17840. // SetDeletedAt sets the "deleted_at" field.
  17841. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  17842. m.deleted_at = &t
  17843. }
  17844. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17845. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  17846. v := m.deleted_at
  17847. if v == nil {
  17848. return
  17849. }
  17850. return *v, true
  17851. }
  17852. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  17853. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17855. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17856. if !m.op.Is(OpUpdateOne) {
  17857. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17858. }
  17859. if m.id == nil || m.oldValue == nil {
  17860. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17861. }
  17862. oldValue, err := m.oldValue(ctx)
  17863. if err != nil {
  17864. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17865. }
  17866. return oldValue.DeletedAt, nil
  17867. }
  17868. // ClearDeletedAt clears the value of the "deleted_at" field.
  17869. func (m *LabelTaggingMutation) ClearDeletedAt() {
  17870. m.deleted_at = nil
  17871. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  17872. }
  17873. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17874. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  17875. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  17876. return ok
  17877. }
  17878. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17879. func (m *LabelTaggingMutation) ResetDeletedAt() {
  17880. m.deleted_at = nil
  17881. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  17882. }
  17883. // SetOrganizationID sets the "organization_id" field.
  17884. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  17885. m.organization_id = &u
  17886. m.addorganization_id = nil
  17887. }
  17888. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17889. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  17890. v := m.organization_id
  17891. if v == nil {
  17892. return
  17893. }
  17894. return *v, true
  17895. }
  17896. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  17897. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17899. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17900. if !m.op.Is(OpUpdateOne) {
  17901. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17902. }
  17903. if m.id == nil || m.oldValue == nil {
  17904. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17905. }
  17906. oldValue, err := m.oldValue(ctx)
  17907. if err != nil {
  17908. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17909. }
  17910. return oldValue.OrganizationID, nil
  17911. }
  17912. // AddOrganizationID adds u to the "organization_id" field.
  17913. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  17914. if m.addorganization_id != nil {
  17915. *m.addorganization_id += u
  17916. } else {
  17917. m.addorganization_id = &u
  17918. }
  17919. }
  17920. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17921. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  17922. v := m.addorganization_id
  17923. if v == nil {
  17924. return
  17925. }
  17926. return *v, true
  17927. }
  17928. // ResetOrganizationID resets all changes to the "organization_id" field.
  17929. func (m *LabelTaggingMutation) ResetOrganizationID() {
  17930. m.organization_id = nil
  17931. m.addorganization_id = nil
  17932. }
  17933. // SetType sets the "type" field.
  17934. func (m *LabelTaggingMutation) SetType(i int) {
  17935. m._type = &i
  17936. m.add_type = nil
  17937. }
  17938. // GetType returns the value of the "type" field in the mutation.
  17939. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  17940. v := m._type
  17941. if v == nil {
  17942. return
  17943. }
  17944. return *v, true
  17945. }
  17946. // OldType returns the old "type" field's value of the LabelTagging entity.
  17947. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17949. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  17950. if !m.op.Is(OpUpdateOne) {
  17951. return v, errors.New("OldType is only allowed on UpdateOne operations")
  17952. }
  17953. if m.id == nil || m.oldValue == nil {
  17954. return v, errors.New("OldType requires an ID field in the mutation")
  17955. }
  17956. oldValue, err := m.oldValue(ctx)
  17957. if err != nil {
  17958. return v, fmt.Errorf("querying old value for OldType: %w", err)
  17959. }
  17960. return oldValue.Type, nil
  17961. }
  17962. // AddType adds i to the "type" field.
  17963. func (m *LabelTaggingMutation) AddType(i int) {
  17964. if m.add_type != nil {
  17965. *m.add_type += i
  17966. } else {
  17967. m.add_type = &i
  17968. }
  17969. }
  17970. // AddedType returns the value that was added to the "type" field in this mutation.
  17971. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  17972. v := m.add_type
  17973. if v == nil {
  17974. return
  17975. }
  17976. return *v, true
  17977. }
  17978. // ResetType resets all changes to the "type" field.
  17979. func (m *LabelTaggingMutation) ResetType() {
  17980. m._type = nil
  17981. m.add_type = nil
  17982. }
  17983. // SetConditions sets the "conditions" field.
  17984. func (m *LabelTaggingMutation) SetConditions(s string) {
  17985. m.conditions = &s
  17986. }
  17987. // Conditions returns the value of the "conditions" field in the mutation.
  17988. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  17989. v := m.conditions
  17990. if v == nil {
  17991. return
  17992. }
  17993. return *v, true
  17994. }
  17995. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  17996. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17998. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  17999. if !m.op.Is(OpUpdateOne) {
  18000. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  18001. }
  18002. if m.id == nil || m.oldValue == nil {
  18003. return v, errors.New("OldConditions requires an ID field in the mutation")
  18004. }
  18005. oldValue, err := m.oldValue(ctx)
  18006. if err != nil {
  18007. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  18008. }
  18009. return oldValue.Conditions, nil
  18010. }
  18011. // ResetConditions resets all changes to the "conditions" field.
  18012. func (m *LabelTaggingMutation) ResetConditions() {
  18013. m.conditions = nil
  18014. }
  18015. // SetActionLabelAdd sets the "action_label_add" field.
  18016. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  18017. m.action_label_add = &u
  18018. m.appendaction_label_add = nil
  18019. }
  18020. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18021. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18022. v := m.action_label_add
  18023. if v == nil {
  18024. return
  18025. }
  18026. return *v, true
  18027. }
  18028. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  18029. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18031. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18032. if !m.op.Is(OpUpdateOne) {
  18033. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18034. }
  18035. if m.id == nil || m.oldValue == nil {
  18036. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18037. }
  18038. oldValue, err := m.oldValue(ctx)
  18039. if err != nil {
  18040. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18041. }
  18042. return oldValue.ActionLabelAdd, nil
  18043. }
  18044. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18045. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  18046. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18047. }
  18048. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18049. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18050. if len(m.appendaction_label_add) == 0 {
  18051. return nil, false
  18052. }
  18053. return m.appendaction_label_add, true
  18054. }
  18055. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18056. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  18057. m.action_label_add = nil
  18058. m.appendaction_label_add = nil
  18059. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  18060. }
  18061. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18062. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  18063. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  18064. return ok
  18065. }
  18066. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18067. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  18068. m.action_label_add = nil
  18069. m.appendaction_label_add = nil
  18070. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  18071. }
  18072. // SetActionLabelDel sets the "action_label_del" field.
  18073. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  18074. m.action_label_del = &u
  18075. m.appendaction_label_del = nil
  18076. }
  18077. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18078. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  18079. v := m.action_label_del
  18080. if v == nil {
  18081. return
  18082. }
  18083. return *v, true
  18084. }
  18085. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  18086. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18088. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18089. if !m.op.Is(OpUpdateOne) {
  18090. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18091. }
  18092. if m.id == nil || m.oldValue == nil {
  18093. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18094. }
  18095. oldValue, err := m.oldValue(ctx)
  18096. if err != nil {
  18097. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18098. }
  18099. return oldValue.ActionLabelDel, nil
  18100. }
  18101. // AppendActionLabelDel adds u to the "action_label_del" field.
  18102. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  18103. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18104. }
  18105. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18106. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18107. if len(m.appendaction_label_del) == 0 {
  18108. return nil, false
  18109. }
  18110. return m.appendaction_label_del, true
  18111. }
  18112. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18113. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  18114. m.action_label_del = nil
  18115. m.appendaction_label_del = nil
  18116. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  18117. }
  18118. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18119. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  18120. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  18121. return ok
  18122. }
  18123. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18124. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  18125. m.action_label_del = nil
  18126. m.appendaction_label_del = nil
  18127. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  18128. }
  18129. // Where appends a list predicates to the LabelTaggingMutation builder.
  18130. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  18131. m.predicates = append(m.predicates, ps...)
  18132. }
  18133. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  18134. // users can use type-assertion to append predicates that do not depend on any generated package.
  18135. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  18136. p := make([]predicate.LabelTagging, len(ps))
  18137. for i := range ps {
  18138. p[i] = ps[i]
  18139. }
  18140. m.Where(p...)
  18141. }
  18142. // Op returns the operation name.
  18143. func (m *LabelTaggingMutation) Op() Op {
  18144. return m.op
  18145. }
  18146. // SetOp allows setting the mutation operation.
  18147. func (m *LabelTaggingMutation) SetOp(op Op) {
  18148. m.op = op
  18149. }
  18150. // Type returns the node type of this mutation (LabelTagging).
  18151. func (m *LabelTaggingMutation) Type() string {
  18152. return m.typ
  18153. }
  18154. // Fields returns all fields that were changed during this mutation. Note that in
  18155. // order to get all numeric fields that were incremented/decremented, call
  18156. // AddedFields().
  18157. func (m *LabelTaggingMutation) Fields() []string {
  18158. fields := make([]string, 0, 9)
  18159. if m.created_at != nil {
  18160. fields = append(fields, labeltagging.FieldCreatedAt)
  18161. }
  18162. if m.updated_at != nil {
  18163. fields = append(fields, labeltagging.FieldUpdatedAt)
  18164. }
  18165. if m.status != nil {
  18166. fields = append(fields, labeltagging.FieldStatus)
  18167. }
  18168. if m.deleted_at != nil {
  18169. fields = append(fields, labeltagging.FieldDeletedAt)
  18170. }
  18171. if m.organization_id != nil {
  18172. fields = append(fields, labeltagging.FieldOrganizationID)
  18173. }
  18174. if m._type != nil {
  18175. fields = append(fields, labeltagging.FieldType)
  18176. }
  18177. if m.conditions != nil {
  18178. fields = append(fields, labeltagging.FieldConditions)
  18179. }
  18180. if m.action_label_add != nil {
  18181. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18182. }
  18183. if m.action_label_del != nil {
  18184. fields = append(fields, labeltagging.FieldActionLabelDel)
  18185. }
  18186. return fields
  18187. }
  18188. // Field returns the value of a field with the given name. The second boolean
  18189. // return value indicates that this field was not set, or was not defined in the
  18190. // schema.
  18191. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  18192. switch name {
  18193. case labeltagging.FieldCreatedAt:
  18194. return m.CreatedAt()
  18195. case labeltagging.FieldUpdatedAt:
  18196. return m.UpdatedAt()
  18197. case labeltagging.FieldStatus:
  18198. return m.Status()
  18199. case labeltagging.FieldDeletedAt:
  18200. return m.DeletedAt()
  18201. case labeltagging.FieldOrganizationID:
  18202. return m.OrganizationID()
  18203. case labeltagging.FieldType:
  18204. return m.GetType()
  18205. case labeltagging.FieldConditions:
  18206. return m.Conditions()
  18207. case labeltagging.FieldActionLabelAdd:
  18208. return m.ActionLabelAdd()
  18209. case labeltagging.FieldActionLabelDel:
  18210. return m.ActionLabelDel()
  18211. }
  18212. return nil, false
  18213. }
  18214. // OldField returns the old value of the field from the database. An error is
  18215. // returned if the mutation operation is not UpdateOne, or the query to the
  18216. // database failed.
  18217. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18218. switch name {
  18219. case labeltagging.FieldCreatedAt:
  18220. return m.OldCreatedAt(ctx)
  18221. case labeltagging.FieldUpdatedAt:
  18222. return m.OldUpdatedAt(ctx)
  18223. case labeltagging.FieldStatus:
  18224. return m.OldStatus(ctx)
  18225. case labeltagging.FieldDeletedAt:
  18226. return m.OldDeletedAt(ctx)
  18227. case labeltagging.FieldOrganizationID:
  18228. return m.OldOrganizationID(ctx)
  18229. case labeltagging.FieldType:
  18230. return m.OldType(ctx)
  18231. case labeltagging.FieldConditions:
  18232. return m.OldConditions(ctx)
  18233. case labeltagging.FieldActionLabelAdd:
  18234. return m.OldActionLabelAdd(ctx)
  18235. case labeltagging.FieldActionLabelDel:
  18236. return m.OldActionLabelDel(ctx)
  18237. }
  18238. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  18239. }
  18240. // SetField sets the value of a field with the given name. It returns an error if
  18241. // the field is not defined in the schema, or if the type mismatched the field
  18242. // type.
  18243. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  18244. switch name {
  18245. case labeltagging.FieldCreatedAt:
  18246. v, ok := value.(time.Time)
  18247. if !ok {
  18248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18249. }
  18250. m.SetCreatedAt(v)
  18251. return nil
  18252. case labeltagging.FieldUpdatedAt:
  18253. v, ok := value.(time.Time)
  18254. if !ok {
  18255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18256. }
  18257. m.SetUpdatedAt(v)
  18258. return nil
  18259. case labeltagging.FieldStatus:
  18260. v, ok := value.(uint8)
  18261. if !ok {
  18262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18263. }
  18264. m.SetStatus(v)
  18265. return nil
  18266. case labeltagging.FieldDeletedAt:
  18267. v, ok := value.(time.Time)
  18268. if !ok {
  18269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18270. }
  18271. m.SetDeletedAt(v)
  18272. return nil
  18273. case labeltagging.FieldOrganizationID:
  18274. v, ok := value.(uint64)
  18275. if !ok {
  18276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18277. }
  18278. m.SetOrganizationID(v)
  18279. return nil
  18280. case labeltagging.FieldType:
  18281. v, ok := value.(int)
  18282. if !ok {
  18283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18284. }
  18285. m.SetType(v)
  18286. return nil
  18287. case labeltagging.FieldConditions:
  18288. v, ok := value.(string)
  18289. if !ok {
  18290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18291. }
  18292. m.SetConditions(v)
  18293. return nil
  18294. case labeltagging.FieldActionLabelAdd:
  18295. v, ok := value.([]uint64)
  18296. if !ok {
  18297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18298. }
  18299. m.SetActionLabelAdd(v)
  18300. return nil
  18301. case labeltagging.FieldActionLabelDel:
  18302. v, ok := value.([]uint64)
  18303. if !ok {
  18304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18305. }
  18306. m.SetActionLabelDel(v)
  18307. return nil
  18308. }
  18309. return fmt.Errorf("unknown LabelTagging field %s", name)
  18310. }
  18311. // AddedFields returns all numeric fields that were incremented/decremented during
  18312. // this mutation.
  18313. func (m *LabelTaggingMutation) AddedFields() []string {
  18314. var fields []string
  18315. if m.addstatus != nil {
  18316. fields = append(fields, labeltagging.FieldStatus)
  18317. }
  18318. if m.addorganization_id != nil {
  18319. fields = append(fields, labeltagging.FieldOrganizationID)
  18320. }
  18321. if m.add_type != nil {
  18322. fields = append(fields, labeltagging.FieldType)
  18323. }
  18324. return fields
  18325. }
  18326. // AddedField returns the numeric value that was incremented/decremented on a field
  18327. // with the given name. The second boolean return value indicates that this field
  18328. // was not set, or was not defined in the schema.
  18329. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  18330. switch name {
  18331. case labeltagging.FieldStatus:
  18332. return m.AddedStatus()
  18333. case labeltagging.FieldOrganizationID:
  18334. return m.AddedOrganizationID()
  18335. case labeltagging.FieldType:
  18336. return m.AddedType()
  18337. }
  18338. return nil, false
  18339. }
  18340. // AddField adds the value to the field with the given name. It returns an error if
  18341. // the field is not defined in the schema, or if the type mismatched the field
  18342. // type.
  18343. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  18344. switch name {
  18345. case labeltagging.FieldStatus:
  18346. v, ok := value.(int8)
  18347. if !ok {
  18348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18349. }
  18350. m.AddStatus(v)
  18351. return nil
  18352. case labeltagging.FieldOrganizationID:
  18353. v, ok := value.(int64)
  18354. if !ok {
  18355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18356. }
  18357. m.AddOrganizationID(v)
  18358. return nil
  18359. case labeltagging.FieldType:
  18360. v, ok := value.(int)
  18361. if !ok {
  18362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18363. }
  18364. m.AddType(v)
  18365. return nil
  18366. }
  18367. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  18368. }
  18369. // ClearedFields returns all nullable fields that were cleared during this
  18370. // mutation.
  18371. func (m *LabelTaggingMutation) ClearedFields() []string {
  18372. var fields []string
  18373. if m.FieldCleared(labeltagging.FieldStatus) {
  18374. fields = append(fields, labeltagging.FieldStatus)
  18375. }
  18376. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  18377. fields = append(fields, labeltagging.FieldDeletedAt)
  18378. }
  18379. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  18380. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18381. }
  18382. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  18383. fields = append(fields, labeltagging.FieldActionLabelDel)
  18384. }
  18385. return fields
  18386. }
  18387. // FieldCleared returns a boolean indicating if a field with the given name was
  18388. // cleared in this mutation.
  18389. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  18390. _, ok := m.clearedFields[name]
  18391. return ok
  18392. }
  18393. // ClearField clears the value of the field with the given name. It returns an
  18394. // error if the field is not defined in the schema.
  18395. func (m *LabelTaggingMutation) ClearField(name string) error {
  18396. switch name {
  18397. case labeltagging.FieldStatus:
  18398. m.ClearStatus()
  18399. return nil
  18400. case labeltagging.FieldDeletedAt:
  18401. m.ClearDeletedAt()
  18402. return nil
  18403. case labeltagging.FieldActionLabelAdd:
  18404. m.ClearActionLabelAdd()
  18405. return nil
  18406. case labeltagging.FieldActionLabelDel:
  18407. m.ClearActionLabelDel()
  18408. return nil
  18409. }
  18410. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  18411. }
  18412. // ResetField resets all changes in the mutation for the field with the given name.
  18413. // It returns an error if the field is not defined in the schema.
  18414. func (m *LabelTaggingMutation) ResetField(name string) error {
  18415. switch name {
  18416. case labeltagging.FieldCreatedAt:
  18417. m.ResetCreatedAt()
  18418. return nil
  18419. case labeltagging.FieldUpdatedAt:
  18420. m.ResetUpdatedAt()
  18421. return nil
  18422. case labeltagging.FieldStatus:
  18423. m.ResetStatus()
  18424. return nil
  18425. case labeltagging.FieldDeletedAt:
  18426. m.ResetDeletedAt()
  18427. return nil
  18428. case labeltagging.FieldOrganizationID:
  18429. m.ResetOrganizationID()
  18430. return nil
  18431. case labeltagging.FieldType:
  18432. m.ResetType()
  18433. return nil
  18434. case labeltagging.FieldConditions:
  18435. m.ResetConditions()
  18436. return nil
  18437. case labeltagging.FieldActionLabelAdd:
  18438. m.ResetActionLabelAdd()
  18439. return nil
  18440. case labeltagging.FieldActionLabelDel:
  18441. m.ResetActionLabelDel()
  18442. return nil
  18443. }
  18444. return fmt.Errorf("unknown LabelTagging field %s", name)
  18445. }
  18446. // AddedEdges returns all edge names that were set/added in this mutation.
  18447. func (m *LabelTaggingMutation) AddedEdges() []string {
  18448. edges := make([]string, 0, 0)
  18449. return edges
  18450. }
  18451. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18452. // name in this mutation.
  18453. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  18454. return nil
  18455. }
  18456. // RemovedEdges returns all edge names that were removed in this mutation.
  18457. func (m *LabelTaggingMutation) RemovedEdges() []string {
  18458. edges := make([]string, 0, 0)
  18459. return edges
  18460. }
  18461. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18462. // the given name in this mutation.
  18463. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  18464. return nil
  18465. }
  18466. // ClearedEdges returns all edge names that were cleared in this mutation.
  18467. func (m *LabelTaggingMutation) ClearedEdges() []string {
  18468. edges := make([]string, 0, 0)
  18469. return edges
  18470. }
  18471. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18472. // was cleared in this mutation.
  18473. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  18474. return false
  18475. }
  18476. // ClearEdge clears the value of the edge with the given name. It returns an error
  18477. // if that edge is not defined in the schema.
  18478. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  18479. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  18480. }
  18481. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18482. // It returns an error if the edge is not defined in the schema.
  18483. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  18484. return fmt.Errorf("unknown LabelTagging edge %s", name)
  18485. }
  18486. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  18487. type MessageMutation struct {
  18488. config
  18489. op Op
  18490. typ string
  18491. id *int
  18492. wx_wxid *string
  18493. wxid *string
  18494. content *string
  18495. clearedFields map[string]struct{}
  18496. done bool
  18497. oldValue func(context.Context) (*Message, error)
  18498. predicates []predicate.Message
  18499. }
  18500. var _ ent.Mutation = (*MessageMutation)(nil)
  18501. // messageOption allows management of the mutation configuration using functional options.
  18502. type messageOption func(*MessageMutation)
  18503. // newMessageMutation creates new mutation for the Message entity.
  18504. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  18505. m := &MessageMutation{
  18506. config: c,
  18507. op: op,
  18508. typ: TypeMessage,
  18509. clearedFields: make(map[string]struct{}),
  18510. }
  18511. for _, opt := range opts {
  18512. opt(m)
  18513. }
  18514. return m
  18515. }
  18516. // withMessageID sets the ID field of the mutation.
  18517. func withMessageID(id int) messageOption {
  18518. return func(m *MessageMutation) {
  18519. var (
  18520. err error
  18521. once sync.Once
  18522. value *Message
  18523. )
  18524. m.oldValue = func(ctx context.Context) (*Message, error) {
  18525. once.Do(func() {
  18526. if m.done {
  18527. err = errors.New("querying old values post mutation is not allowed")
  18528. } else {
  18529. value, err = m.Client().Message.Get(ctx, id)
  18530. }
  18531. })
  18532. return value, err
  18533. }
  18534. m.id = &id
  18535. }
  18536. }
  18537. // withMessage sets the old Message of the mutation.
  18538. func withMessage(node *Message) messageOption {
  18539. return func(m *MessageMutation) {
  18540. m.oldValue = func(context.Context) (*Message, error) {
  18541. return node, nil
  18542. }
  18543. m.id = &node.ID
  18544. }
  18545. }
  18546. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18547. // executed in a transaction (ent.Tx), a transactional client is returned.
  18548. func (m MessageMutation) Client() *Client {
  18549. client := &Client{config: m.config}
  18550. client.init()
  18551. return client
  18552. }
  18553. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18554. // it returns an error otherwise.
  18555. func (m MessageMutation) Tx() (*Tx, error) {
  18556. if _, ok := m.driver.(*txDriver); !ok {
  18557. return nil, errors.New("ent: mutation is not running in a transaction")
  18558. }
  18559. tx := &Tx{config: m.config}
  18560. tx.init()
  18561. return tx, nil
  18562. }
  18563. // ID returns the ID value in the mutation. Note that the ID is only available
  18564. // if it was provided to the builder or after it was returned from the database.
  18565. func (m *MessageMutation) ID() (id int, exists bool) {
  18566. if m.id == nil {
  18567. return
  18568. }
  18569. return *m.id, true
  18570. }
  18571. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18572. // That means, if the mutation is applied within a transaction with an isolation level such
  18573. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18574. // or updated by the mutation.
  18575. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  18576. switch {
  18577. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18578. id, exists := m.ID()
  18579. if exists {
  18580. return []int{id}, nil
  18581. }
  18582. fallthrough
  18583. case m.op.Is(OpUpdate | OpDelete):
  18584. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  18585. default:
  18586. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18587. }
  18588. }
  18589. // SetWxWxid sets the "wx_wxid" field.
  18590. func (m *MessageMutation) SetWxWxid(s string) {
  18591. m.wx_wxid = &s
  18592. }
  18593. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  18594. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  18595. v := m.wx_wxid
  18596. if v == nil {
  18597. return
  18598. }
  18599. return *v, true
  18600. }
  18601. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  18602. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18604. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  18605. if !m.op.Is(OpUpdateOne) {
  18606. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  18607. }
  18608. if m.id == nil || m.oldValue == nil {
  18609. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  18610. }
  18611. oldValue, err := m.oldValue(ctx)
  18612. if err != nil {
  18613. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  18614. }
  18615. return oldValue.WxWxid, nil
  18616. }
  18617. // ClearWxWxid clears the value of the "wx_wxid" field.
  18618. func (m *MessageMutation) ClearWxWxid() {
  18619. m.wx_wxid = nil
  18620. m.clearedFields[message.FieldWxWxid] = struct{}{}
  18621. }
  18622. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  18623. func (m *MessageMutation) WxWxidCleared() bool {
  18624. _, ok := m.clearedFields[message.FieldWxWxid]
  18625. return ok
  18626. }
  18627. // ResetWxWxid resets all changes to the "wx_wxid" field.
  18628. func (m *MessageMutation) ResetWxWxid() {
  18629. m.wx_wxid = nil
  18630. delete(m.clearedFields, message.FieldWxWxid)
  18631. }
  18632. // SetWxid sets the "wxid" field.
  18633. func (m *MessageMutation) SetWxid(s string) {
  18634. m.wxid = &s
  18635. }
  18636. // Wxid returns the value of the "wxid" field in the mutation.
  18637. func (m *MessageMutation) Wxid() (r string, exists bool) {
  18638. v := m.wxid
  18639. if v == nil {
  18640. return
  18641. }
  18642. return *v, true
  18643. }
  18644. // OldWxid returns the old "wxid" field's value of the Message entity.
  18645. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18647. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  18648. if !m.op.Is(OpUpdateOne) {
  18649. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  18650. }
  18651. if m.id == nil || m.oldValue == nil {
  18652. return v, errors.New("OldWxid requires an ID field in the mutation")
  18653. }
  18654. oldValue, err := m.oldValue(ctx)
  18655. if err != nil {
  18656. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  18657. }
  18658. return oldValue.Wxid, nil
  18659. }
  18660. // ResetWxid resets all changes to the "wxid" field.
  18661. func (m *MessageMutation) ResetWxid() {
  18662. m.wxid = nil
  18663. }
  18664. // SetContent sets the "content" field.
  18665. func (m *MessageMutation) SetContent(s string) {
  18666. m.content = &s
  18667. }
  18668. // Content returns the value of the "content" field in the mutation.
  18669. func (m *MessageMutation) Content() (r string, exists bool) {
  18670. v := m.content
  18671. if v == nil {
  18672. return
  18673. }
  18674. return *v, true
  18675. }
  18676. // OldContent returns the old "content" field's value of the Message entity.
  18677. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18679. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  18680. if !m.op.Is(OpUpdateOne) {
  18681. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18682. }
  18683. if m.id == nil || m.oldValue == nil {
  18684. return v, errors.New("OldContent requires an ID field in the mutation")
  18685. }
  18686. oldValue, err := m.oldValue(ctx)
  18687. if err != nil {
  18688. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18689. }
  18690. return oldValue.Content, nil
  18691. }
  18692. // ResetContent resets all changes to the "content" field.
  18693. func (m *MessageMutation) ResetContent() {
  18694. m.content = nil
  18695. }
  18696. // Where appends a list predicates to the MessageMutation builder.
  18697. func (m *MessageMutation) Where(ps ...predicate.Message) {
  18698. m.predicates = append(m.predicates, ps...)
  18699. }
  18700. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  18701. // users can use type-assertion to append predicates that do not depend on any generated package.
  18702. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  18703. p := make([]predicate.Message, len(ps))
  18704. for i := range ps {
  18705. p[i] = ps[i]
  18706. }
  18707. m.Where(p...)
  18708. }
  18709. // Op returns the operation name.
  18710. func (m *MessageMutation) Op() Op {
  18711. return m.op
  18712. }
  18713. // SetOp allows setting the mutation operation.
  18714. func (m *MessageMutation) SetOp(op Op) {
  18715. m.op = op
  18716. }
  18717. // Type returns the node type of this mutation (Message).
  18718. func (m *MessageMutation) Type() string {
  18719. return m.typ
  18720. }
  18721. // Fields returns all fields that were changed during this mutation. Note that in
  18722. // order to get all numeric fields that were incremented/decremented, call
  18723. // AddedFields().
  18724. func (m *MessageMutation) Fields() []string {
  18725. fields := make([]string, 0, 3)
  18726. if m.wx_wxid != nil {
  18727. fields = append(fields, message.FieldWxWxid)
  18728. }
  18729. if m.wxid != nil {
  18730. fields = append(fields, message.FieldWxid)
  18731. }
  18732. if m.content != nil {
  18733. fields = append(fields, message.FieldContent)
  18734. }
  18735. return fields
  18736. }
  18737. // Field returns the value of a field with the given name. The second boolean
  18738. // return value indicates that this field was not set, or was not defined in the
  18739. // schema.
  18740. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  18741. switch name {
  18742. case message.FieldWxWxid:
  18743. return m.WxWxid()
  18744. case message.FieldWxid:
  18745. return m.Wxid()
  18746. case message.FieldContent:
  18747. return m.Content()
  18748. }
  18749. return nil, false
  18750. }
  18751. // OldField returns the old value of the field from the database. An error is
  18752. // returned if the mutation operation is not UpdateOne, or the query to the
  18753. // database failed.
  18754. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18755. switch name {
  18756. case message.FieldWxWxid:
  18757. return m.OldWxWxid(ctx)
  18758. case message.FieldWxid:
  18759. return m.OldWxid(ctx)
  18760. case message.FieldContent:
  18761. return m.OldContent(ctx)
  18762. }
  18763. return nil, fmt.Errorf("unknown Message field %s", name)
  18764. }
  18765. // SetField sets the value of a field with the given name. It returns an error if
  18766. // the field is not defined in the schema, or if the type mismatched the field
  18767. // type.
  18768. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  18769. switch name {
  18770. case message.FieldWxWxid:
  18771. v, ok := value.(string)
  18772. if !ok {
  18773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18774. }
  18775. m.SetWxWxid(v)
  18776. return nil
  18777. case message.FieldWxid:
  18778. v, ok := value.(string)
  18779. if !ok {
  18780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18781. }
  18782. m.SetWxid(v)
  18783. return nil
  18784. case message.FieldContent:
  18785. v, ok := value.(string)
  18786. if !ok {
  18787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18788. }
  18789. m.SetContent(v)
  18790. return nil
  18791. }
  18792. return fmt.Errorf("unknown Message field %s", name)
  18793. }
  18794. // AddedFields returns all numeric fields that were incremented/decremented during
  18795. // this mutation.
  18796. func (m *MessageMutation) AddedFields() []string {
  18797. return nil
  18798. }
  18799. // AddedField returns the numeric value that was incremented/decremented on a field
  18800. // with the given name. The second boolean return value indicates that this field
  18801. // was not set, or was not defined in the schema.
  18802. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  18803. return nil, false
  18804. }
  18805. // AddField adds the value to the field with the given name. It returns an error if
  18806. // the field is not defined in the schema, or if the type mismatched the field
  18807. // type.
  18808. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  18809. switch name {
  18810. }
  18811. return fmt.Errorf("unknown Message numeric field %s", name)
  18812. }
  18813. // ClearedFields returns all nullable fields that were cleared during this
  18814. // mutation.
  18815. func (m *MessageMutation) ClearedFields() []string {
  18816. var fields []string
  18817. if m.FieldCleared(message.FieldWxWxid) {
  18818. fields = append(fields, message.FieldWxWxid)
  18819. }
  18820. return fields
  18821. }
  18822. // FieldCleared returns a boolean indicating if a field with the given name was
  18823. // cleared in this mutation.
  18824. func (m *MessageMutation) FieldCleared(name string) bool {
  18825. _, ok := m.clearedFields[name]
  18826. return ok
  18827. }
  18828. // ClearField clears the value of the field with the given name. It returns an
  18829. // error if the field is not defined in the schema.
  18830. func (m *MessageMutation) ClearField(name string) error {
  18831. switch name {
  18832. case message.FieldWxWxid:
  18833. m.ClearWxWxid()
  18834. return nil
  18835. }
  18836. return fmt.Errorf("unknown Message nullable field %s", name)
  18837. }
  18838. // ResetField resets all changes in the mutation for the field with the given name.
  18839. // It returns an error if the field is not defined in the schema.
  18840. func (m *MessageMutation) ResetField(name string) error {
  18841. switch name {
  18842. case message.FieldWxWxid:
  18843. m.ResetWxWxid()
  18844. return nil
  18845. case message.FieldWxid:
  18846. m.ResetWxid()
  18847. return nil
  18848. case message.FieldContent:
  18849. m.ResetContent()
  18850. return nil
  18851. }
  18852. return fmt.Errorf("unknown Message field %s", name)
  18853. }
  18854. // AddedEdges returns all edge names that were set/added in this mutation.
  18855. func (m *MessageMutation) AddedEdges() []string {
  18856. edges := make([]string, 0, 0)
  18857. return edges
  18858. }
  18859. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18860. // name in this mutation.
  18861. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  18862. return nil
  18863. }
  18864. // RemovedEdges returns all edge names that were removed in this mutation.
  18865. func (m *MessageMutation) RemovedEdges() []string {
  18866. edges := make([]string, 0, 0)
  18867. return edges
  18868. }
  18869. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18870. // the given name in this mutation.
  18871. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  18872. return nil
  18873. }
  18874. // ClearedEdges returns all edge names that were cleared in this mutation.
  18875. func (m *MessageMutation) ClearedEdges() []string {
  18876. edges := make([]string, 0, 0)
  18877. return edges
  18878. }
  18879. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18880. // was cleared in this mutation.
  18881. func (m *MessageMutation) EdgeCleared(name string) bool {
  18882. return false
  18883. }
  18884. // ClearEdge clears the value of the edge with the given name. It returns an error
  18885. // if that edge is not defined in the schema.
  18886. func (m *MessageMutation) ClearEdge(name string) error {
  18887. return fmt.Errorf("unknown Message unique edge %s", name)
  18888. }
  18889. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18890. // It returns an error if the edge is not defined in the schema.
  18891. func (m *MessageMutation) ResetEdge(name string) error {
  18892. return fmt.Errorf("unknown Message edge %s", name)
  18893. }
  18894. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  18895. type MessageRecordsMutation struct {
  18896. config
  18897. op Op
  18898. typ string
  18899. id *uint64
  18900. created_at *time.Time
  18901. updated_at *time.Time
  18902. status *uint8
  18903. addstatus *int8
  18904. bot_wxid *string
  18905. contact_type *int
  18906. addcontact_type *int
  18907. contact_wxid *string
  18908. content_type *int
  18909. addcontent_type *int
  18910. content *string
  18911. meta *custom_types.Meta
  18912. error_detail *string
  18913. send_time *time.Time
  18914. source_type *int
  18915. addsource_type *int
  18916. organization_id *uint64
  18917. addorganization_id *int64
  18918. clearedFields map[string]struct{}
  18919. sop_stage *uint64
  18920. clearedsop_stage bool
  18921. sop_node *uint64
  18922. clearedsop_node bool
  18923. message_contact *uint64
  18924. clearedmessage_contact bool
  18925. done bool
  18926. oldValue func(context.Context) (*MessageRecords, error)
  18927. predicates []predicate.MessageRecords
  18928. }
  18929. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  18930. // messagerecordsOption allows management of the mutation configuration using functional options.
  18931. type messagerecordsOption func(*MessageRecordsMutation)
  18932. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  18933. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  18934. m := &MessageRecordsMutation{
  18935. config: c,
  18936. op: op,
  18937. typ: TypeMessageRecords,
  18938. clearedFields: make(map[string]struct{}),
  18939. }
  18940. for _, opt := range opts {
  18941. opt(m)
  18942. }
  18943. return m
  18944. }
  18945. // withMessageRecordsID sets the ID field of the mutation.
  18946. func withMessageRecordsID(id uint64) messagerecordsOption {
  18947. return func(m *MessageRecordsMutation) {
  18948. var (
  18949. err error
  18950. once sync.Once
  18951. value *MessageRecords
  18952. )
  18953. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  18954. once.Do(func() {
  18955. if m.done {
  18956. err = errors.New("querying old values post mutation is not allowed")
  18957. } else {
  18958. value, err = m.Client().MessageRecords.Get(ctx, id)
  18959. }
  18960. })
  18961. return value, err
  18962. }
  18963. m.id = &id
  18964. }
  18965. }
  18966. // withMessageRecords sets the old MessageRecords of the mutation.
  18967. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  18968. return func(m *MessageRecordsMutation) {
  18969. m.oldValue = func(context.Context) (*MessageRecords, error) {
  18970. return node, nil
  18971. }
  18972. m.id = &node.ID
  18973. }
  18974. }
  18975. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18976. // executed in a transaction (ent.Tx), a transactional client is returned.
  18977. func (m MessageRecordsMutation) Client() *Client {
  18978. client := &Client{config: m.config}
  18979. client.init()
  18980. return client
  18981. }
  18982. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18983. // it returns an error otherwise.
  18984. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  18985. if _, ok := m.driver.(*txDriver); !ok {
  18986. return nil, errors.New("ent: mutation is not running in a transaction")
  18987. }
  18988. tx := &Tx{config: m.config}
  18989. tx.init()
  18990. return tx, nil
  18991. }
  18992. // SetID sets the value of the id field. Note that this
  18993. // operation is only accepted on creation of MessageRecords entities.
  18994. func (m *MessageRecordsMutation) SetID(id uint64) {
  18995. m.id = &id
  18996. }
  18997. // ID returns the ID value in the mutation. Note that the ID is only available
  18998. // if it was provided to the builder or after it was returned from the database.
  18999. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  19000. if m.id == nil {
  19001. return
  19002. }
  19003. return *m.id, true
  19004. }
  19005. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19006. // That means, if the mutation is applied within a transaction with an isolation level such
  19007. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19008. // or updated by the mutation.
  19009. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  19010. switch {
  19011. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19012. id, exists := m.ID()
  19013. if exists {
  19014. return []uint64{id}, nil
  19015. }
  19016. fallthrough
  19017. case m.op.Is(OpUpdate | OpDelete):
  19018. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  19019. default:
  19020. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19021. }
  19022. }
  19023. // SetCreatedAt sets the "created_at" field.
  19024. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  19025. m.created_at = &t
  19026. }
  19027. // CreatedAt returns the value of the "created_at" field in the mutation.
  19028. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  19029. v := m.created_at
  19030. if v == nil {
  19031. return
  19032. }
  19033. return *v, true
  19034. }
  19035. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  19036. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19038. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19039. if !m.op.Is(OpUpdateOne) {
  19040. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19041. }
  19042. if m.id == nil || m.oldValue == nil {
  19043. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19044. }
  19045. oldValue, err := m.oldValue(ctx)
  19046. if err != nil {
  19047. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19048. }
  19049. return oldValue.CreatedAt, nil
  19050. }
  19051. // ResetCreatedAt resets all changes to the "created_at" field.
  19052. func (m *MessageRecordsMutation) ResetCreatedAt() {
  19053. m.created_at = nil
  19054. }
  19055. // SetUpdatedAt sets the "updated_at" field.
  19056. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  19057. m.updated_at = &t
  19058. }
  19059. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19060. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  19061. v := m.updated_at
  19062. if v == nil {
  19063. return
  19064. }
  19065. return *v, true
  19066. }
  19067. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  19068. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19070. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19071. if !m.op.Is(OpUpdateOne) {
  19072. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19073. }
  19074. if m.id == nil || m.oldValue == nil {
  19075. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19076. }
  19077. oldValue, err := m.oldValue(ctx)
  19078. if err != nil {
  19079. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19080. }
  19081. return oldValue.UpdatedAt, nil
  19082. }
  19083. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19084. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  19085. m.updated_at = nil
  19086. }
  19087. // SetStatus sets the "status" field.
  19088. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  19089. m.status = &u
  19090. m.addstatus = nil
  19091. }
  19092. // Status returns the value of the "status" field in the mutation.
  19093. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  19094. v := m.status
  19095. if v == nil {
  19096. return
  19097. }
  19098. return *v, true
  19099. }
  19100. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  19101. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19103. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19104. if !m.op.Is(OpUpdateOne) {
  19105. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19106. }
  19107. if m.id == nil || m.oldValue == nil {
  19108. return v, errors.New("OldStatus requires an ID field in the mutation")
  19109. }
  19110. oldValue, err := m.oldValue(ctx)
  19111. if err != nil {
  19112. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19113. }
  19114. return oldValue.Status, nil
  19115. }
  19116. // AddStatus adds u to the "status" field.
  19117. func (m *MessageRecordsMutation) AddStatus(u int8) {
  19118. if m.addstatus != nil {
  19119. *m.addstatus += u
  19120. } else {
  19121. m.addstatus = &u
  19122. }
  19123. }
  19124. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19125. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  19126. v := m.addstatus
  19127. if v == nil {
  19128. return
  19129. }
  19130. return *v, true
  19131. }
  19132. // ClearStatus clears the value of the "status" field.
  19133. func (m *MessageRecordsMutation) ClearStatus() {
  19134. m.status = nil
  19135. m.addstatus = nil
  19136. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  19137. }
  19138. // StatusCleared returns if the "status" field was cleared in this mutation.
  19139. func (m *MessageRecordsMutation) StatusCleared() bool {
  19140. _, ok := m.clearedFields[messagerecords.FieldStatus]
  19141. return ok
  19142. }
  19143. // ResetStatus resets all changes to the "status" field.
  19144. func (m *MessageRecordsMutation) ResetStatus() {
  19145. m.status = nil
  19146. m.addstatus = nil
  19147. delete(m.clearedFields, messagerecords.FieldStatus)
  19148. }
  19149. // SetBotWxid sets the "bot_wxid" field.
  19150. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  19151. m.bot_wxid = &s
  19152. }
  19153. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  19154. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  19155. v := m.bot_wxid
  19156. if v == nil {
  19157. return
  19158. }
  19159. return *v, true
  19160. }
  19161. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  19162. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19164. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  19165. if !m.op.Is(OpUpdateOne) {
  19166. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  19167. }
  19168. if m.id == nil || m.oldValue == nil {
  19169. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  19170. }
  19171. oldValue, err := m.oldValue(ctx)
  19172. if err != nil {
  19173. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  19174. }
  19175. return oldValue.BotWxid, nil
  19176. }
  19177. // ResetBotWxid resets all changes to the "bot_wxid" field.
  19178. func (m *MessageRecordsMutation) ResetBotWxid() {
  19179. m.bot_wxid = nil
  19180. }
  19181. // SetContactID sets the "contact_id" field.
  19182. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  19183. m.message_contact = &u
  19184. }
  19185. // ContactID returns the value of the "contact_id" field in the mutation.
  19186. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  19187. v := m.message_contact
  19188. if v == nil {
  19189. return
  19190. }
  19191. return *v, true
  19192. }
  19193. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  19194. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19196. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  19197. if !m.op.Is(OpUpdateOne) {
  19198. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  19199. }
  19200. if m.id == nil || m.oldValue == nil {
  19201. return v, errors.New("OldContactID requires an ID field in the mutation")
  19202. }
  19203. oldValue, err := m.oldValue(ctx)
  19204. if err != nil {
  19205. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  19206. }
  19207. return oldValue.ContactID, nil
  19208. }
  19209. // ClearContactID clears the value of the "contact_id" field.
  19210. func (m *MessageRecordsMutation) ClearContactID() {
  19211. m.message_contact = nil
  19212. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19213. }
  19214. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  19215. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  19216. _, ok := m.clearedFields[messagerecords.FieldContactID]
  19217. return ok
  19218. }
  19219. // ResetContactID resets all changes to the "contact_id" field.
  19220. func (m *MessageRecordsMutation) ResetContactID() {
  19221. m.message_contact = nil
  19222. delete(m.clearedFields, messagerecords.FieldContactID)
  19223. }
  19224. // SetContactType sets the "contact_type" field.
  19225. func (m *MessageRecordsMutation) SetContactType(i int) {
  19226. m.contact_type = &i
  19227. m.addcontact_type = nil
  19228. }
  19229. // ContactType returns the value of the "contact_type" field in the mutation.
  19230. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  19231. v := m.contact_type
  19232. if v == nil {
  19233. return
  19234. }
  19235. return *v, true
  19236. }
  19237. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  19238. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19240. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  19241. if !m.op.Is(OpUpdateOne) {
  19242. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  19243. }
  19244. if m.id == nil || m.oldValue == nil {
  19245. return v, errors.New("OldContactType requires an ID field in the mutation")
  19246. }
  19247. oldValue, err := m.oldValue(ctx)
  19248. if err != nil {
  19249. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  19250. }
  19251. return oldValue.ContactType, nil
  19252. }
  19253. // AddContactType adds i to the "contact_type" field.
  19254. func (m *MessageRecordsMutation) AddContactType(i int) {
  19255. if m.addcontact_type != nil {
  19256. *m.addcontact_type += i
  19257. } else {
  19258. m.addcontact_type = &i
  19259. }
  19260. }
  19261. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  19262. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  19263. v := m.addcontact_type
  19264. if v == nil {
  19265. return
  19266. }
  19267. return *v, true
  19268. }
  19269. // ResetContactType resets all changes to the "contact_type" field.
  19270. func (m *MessageRecordsMutation) ResetContactType() {
  19271. m.contact_type = nil
  19272. m.addcontact_type = nil
  19273. }
  19274. // SetContactWxid sets the "contact_wxid" field.
  19275. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  19276. m.contact_wxid = &s
  19277. }
  19278. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  19279. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  19280. v := m.contact_wxid
  19281. if v == nil {
  19282. return
  19283. }
  19284. return *v, true
  19285. }
  19286. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  19287. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19289. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  19290. if !m.op.Is(OpUpdateOne) {
  19291. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  19292. }
  19293. if m.id == nil || m.oldValue == nil {
  19294. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  19295. }
  19296. oldValue, err := m.oldValue(ctx)
  19297. if err != nil {
  19298. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  19299. }
  19300. return oldValue.ContactWxid, nil
  19301. }
  19302. // ResetContactWxid resets all changes to the "contact_wxid" field.
  19303. func (m *MessageRecordsMutation) ResetContactWxid() {
  19304. m.contact_wxid = nil
  19305. }
  19306. // SetContentType sets the "content_type" field.
  19307. func (m *MessageRecordsMutation) SetContentType(i int) {
  19308. m.content_type = &i
  19309. m.addcontent_type = nil
  19310. }
  19311. // ContentType returns the value of the "content_type" field in the mutation.
  19312. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  19313. v := m.content_type
  19314. if v == nil {
  19315. return
  19316. }
  19317. return *v, true
  19318. }
  19319. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  19320. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19322. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  19323. if !m.op.Is(OpUpdateOne) {
  19324. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  19325. }
  19326. if m.id == nil || m.oldValue == nil {
  19327. return v, errors.New("OldContentType requires an ID field in the mutation")
  19328. }
  19329. oldValue, err := m.oldValue(ctx)
  19330. if err != nil {
  19331. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  19332. }
  19333. return oldValue.ContentType, nil
  19334. }
  19335. // AddContentType adds i to the "content_type" field.
  19336. func (m *MessageRecordsMutation) AddContentType(i int) {
  19337. if m.addcontent_type != nil {
  19338. *m.addcontent_type += i
  19339. } else {
  19340. m.addcontent_type = &i
  19341. }
  19342. }
  19343. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  19344. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  19345. v := m.addcontent_type
  19346. if v == nil {
  19347. return
  19348. }
  19349. return *v, true
  19350. }
  19351. // ResetContentType resets all changes to the "content_type" field.
  19352. func (m *MessageRecordsMutation) ResetContentType() {
  19353. m.content_type = nil
  19354. m.addcontent_type = nil
  19355. }
  19356. // SetContent sets the "content" field.
  19357. func (m *MessageRecordsMutation) SetContent(s string) {
  19358. m.content = &s
  19359. }
  19360. // Content returns the value of the "content" field in the mutation.
  19361. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  19362. v := m.content
  19363. if v == nil {
  19364. return
  19365. }
  19366. return *v, true
  19367. }
  19368. // OldContent returns the old "content" field's value of the MessageRecords entity.
  19369. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19371. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  19372. if !m.op.Is(OpUpdateOne) {
  19373. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  19374. }
  19375. if m.id == nil || m.oldValue == nil {
  19376. return v, errors.New("OldContent requires an ID field in the mutation")
  19377. }
  19378. oldValue, err := m.oldValue(ctx)
  19379. if err != nil {
  19380. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  19381. }
  19382. return oldValue.Content, nil
  19383. }
  19384. // ResetContent resets all changes to the "content" field.
  19385. func (m *MessageRecordsMutation) ResetContent() {
  19386. m.content = nil
  19387. }
  19388. // SetMeta sets the "meta" field.
  19389. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  19390. m.meta = &ct
  19391. }
  19392. // Meta returns the value of the "meta" field in the mutation.
  19393. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  19394. v := m.meta
  19395. if v == nil {
  19396. return
  19397. }
  19398. return *v, true
  19399. }
  19400. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  19401. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19403. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  19404. if !m.op.Is(OpUpdateOne) {
  19405. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  19406. }
  19407. if m.id == nil || m.oldValue == nil {
  19408. return v, errors.New("OldMeta requires an ID field in the mutation")
  19409. }
  19410. oldValue, err := m.oldValue(ctx)
  19411. if err != nil {
  19412. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  19413. }
  19414. return oldValue.Meta, nil
  19415. }
  19416. // ClearMeta clears the value of the "meta" field.
  19417. func (m *MessageRecordsMutation) ClearMeta() {
  19418. m.meta = nil
  19419. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  19420. }
  19421. // MetaCleared returns if the "meta" field was cleared in this mutation.
  19422. func (m *MessageRecordsMutation) MetaCleared() bool {
  19423. _, ok := m.clearedFields[messagerecords.FieldMeta]
  19424. return ok
  19425. }
  19426. // ResetMeta resets all changes to the "meta" field.
  19427. func (m *MessageRecordsMutation) ResetMeta() {
  19428. m.meta = nil
  19429. delete(m.clearedFields, messagerecords.FieldMeta)
  19430. }
  19431. // SetErrorDetail sets the "error_detail" field.
  19432. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  19433. m.error_detail = &s
  19434. }
  19435. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  19436. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  19437. v := m.error_detail
  19438. if v == nil {
  19439. return
  19440. }
  19441. return *v, true
  19442. }
  19443. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  19444. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19446. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  19447. if !m.op.Is(OpUpdateOne) {
  19448. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  19449. }
  19450. if m.id == nil || m.oldValue == nil {
  19451. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  19452. }
  19453. oldValue, err := m.oldValue(ctx)
  19454. if err != nil {
  19455. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  19456. }
  19457. return oldValue.ErrorDetail, nil
  19458. }
  19459. // ResetErrorDetail resets all changes to the "error_detail" field.
  19460. func (m *MessageRecordsMutation) ResetErrorDetail() {
  19461. m.error_detail = nil
  19462. }
  19463. // SetSendTime sets the "send_time" field.
  19464. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  19465. m.send_time = &t
  19466. }
  19467. // SendTime returns the value of the "send_time" field in the mutation.
  19468. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  19469. v := m.send_time
  19470. if v == nil {
  19471. return
  19472. }
  19473. return *v, true
  19474. }
  19475. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  19476. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19478. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  19479. if !m.op.Is(OpUpdateOne) {
  19480. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  19481. }
  19482. if m.id == nil || m.oldValue == nil {
  19483. return v, errors.New("OldSendTime requires an ID field in the mutation")
  19484. }
  19485. oldValue, err := m.oldValue(ctx)
  19486. if err != nil {
  19487. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  19488. }
  19489. return oldValue.SendTime, nil
  19490. }
  19491. // ClearSendTime clears the value of the "send_time" field.
  19492. func (m *MessageRecordsMutation) ClearSendTime() {
  19493. m.send_time = nil
  19494. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  19495. }
  19496. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  19497. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  19498. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  19499. return ok
  19500. }
  19501. // ResetSendTime resets all changes to the "send_time" field.
  19502. func (m *MessageRecordsMutation) ResetSendTime() {
  19503. m.send_time = nil
  19504. delete(m.clearedFields, messagerecords.FieldSendTime)
  19505. }
  19506. // SetSourceType sets the "source_type" field.
  19507. func (m *MessageRecordsMutation) SetSourceType(i int) {
  19508. m.source_type = &i
  19509. m.addsource_type = nil
  19510. }
  19511. // SourceType returns the value of the "source_type" field in the mutation.
  19512. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  19513. v := m.source_type
  19514. if v == nil {
  19515. return
  19516. }
  19517. return *v, true
  19518. }
  19519. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  19520. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19522. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  19523. if !m.op.Is(OpUpdateOne) {
  19524. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  19525. }
  19526. if m.id == nil || m.oldValue == nil {
  19527. return v, errors.New("OldSourceType requires an ID field in the mutation")
  19528. }
  19529. oldValue, err := m.oldValue(ctx)
  19530. if err != nil {
  19531. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  19532. }
  19533. return oldValue.SourceType, nil
  19534. }
  19535. // AddSourceType adds i to the "source_type" field.
  19536. func (m *MessageRecordsMutation) AddSourceType(i int) {
  19537. if m.addsource_type != nil {
  19538. *m.addsource_type += i
  19539. } else {
  19540. m.addsource_type = &i
  19541. }
  19542. }
  19543. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  19544. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  19545. v := m.addsource_type
  19546. if v == nil {
  19547. return
  19548. }
  19549. return *v, true
  19550. }
  19551. // ResetSourceType resets all changes to the "source_type" field.
  19552. func (m *MessageRecordsMutation) ResetSourceType() {
  19553. m.source_type = nil
  19554. m.addsource_type = nil
  19555. }
  19556. // SetSourceID sets the "source_id" field.
  19557. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  19558. m.sop_stage = &u
  19559. }
  19560. // SourceID returns the value of the "source_id" field in the mutation.
  19561. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  19562. v := m.sop_stage
  19563. if v == nil {
  19564. return
  19565. }
  19566. return *v, true
  19567. }
  19568. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  19569. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19571. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  19572. if !m.op.Is(OpUpdateOne) {
  19573. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  19574. }
  19575. if m.id == nil || m.oldValue == nil {
  19576. return v, errors.New("OldSourceID requires an ID field in the mutation")
  19577. }
  19578. oldValue, err := m.oldValue(ctx)
  19579. if err != nil {
  19580. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  19581. }
  19582. return oldValue.SourceID, nil
  19583. }
  19584. // ClearSourceID clears the value of the "source_id" field.
  19585. func (m *MessageRecordsMutation) ClearSourceID() {
  19586. m.sop_stage = nil
  19587. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19588. }
  19589. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  19590. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  19591. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  19592. return ok
  19593. }
  19594. // ResetSourceID resets all changes to the "source_id" field.
  19595. func (m *MessageRecordsMutation) ResetSourceID() {
  19596. m.sop_stage = nil
  19597. delete(m.clearedFields, messagerecords.FieldSourceID)
  19598. }
  19599. // SetSubSourceID sets the "sub_source_id" field.
  19600. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  19601. m.sop_node = &u
  19602. }
  19603. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  19604. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  19605. v := m.sop_node
  19606. if v == nil {
  19607. return
  19608. }
  19609. return *v, true
  19610. }
  19611. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  19612. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19614. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  19615. if !m.op.Is(OpUpdateOne) {
  19616. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  19617. }
  19618. if m.id == nil || m.oldValue == nil {
  19619. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  19620. }
  19621. oldValue, err := m.oldValue(ctx)
  19622. if err != nil {
  19623. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  19624. }
  19625. return oldValue.SubSourceID, nil
  19626. }
  19627. // ClearSubSourceID clears the value of the "sub_source_id" field.
  19628. func (m *MessageRecordsMutation) ClearSubSourceID() {
  19629. m.sop_node = nil
  19630. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19631. }
  19632. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  19633. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  19634. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  19635. return ok
  19636. }
  19637. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  19638. func (m *MessageRecordsMutation) ResetSubSourceID() {
  19639. m.sop_node = nil
  19640. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  19641. }
  19642. // SetOrganizationID sets the "organization_id" field.
  19643. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  19644. m.organization_id = &u
  19645. m.addorganization_id = nil
  19646. }
  19647. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19648. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  19649. v := m.organization_id
  19650. if v == nil {
  19651. return
  19652. }
  19653. return *v, true
  19654. }
  19655. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  19656. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19658. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19659. if !m.op.Is(OpUpdateOne) {
  19660. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19661. }
  19662. if m.id == nil || m.oldValue == nil {
  19663. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19664. }
  19665. oldValue, err := m.oldValue(ctx)
  19666. if err != nil {
  19667. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19668. }
  19669. return oldValue.OrganizationID, nil
  19670. }
  19671. // AddOrganizationID adds u to the "organization_id" field.
  19672. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  19673. if m.addorganization_id != nil {
  19674. *m.addorganization_id += u
  19675. } else {
  19676. m.addorganization_id = &u
  19677. }
  19678. }
  19679. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19680. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  19681. v := m.addorganization_id
  19682. if v == nil {
  19683. return
  19684. }
  19685. return *v, true
  19686. }
  19687. // ClearOrganizationID clears the value of the "organization_id" field.
  19688. func (m *MessageRecordsMutation) ClearOrganizationID() {
  19689. m.organization_id = nil
  19690. m.addorganization_id = nil
  19691. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  19692. }
  19693. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19694. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  19695. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  19696. return ok
  19697. }
  19698. // ResetOrganizationID resets all changes to the "organization_id" field.
  19699. func (m *MessageRecordsMutation) ResetOrganizationID() {
  19700. m.organization_id = nil
  19701. m.addorganization_id = nil
  19702. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  19703. }
  19704. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  19705. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  19706. m.sop_stage = &id
  19707. }
  19708. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  19709. func (m *MessageRecordsMutation) ClearSopStage() {
  19710. m.clearedsop_stage = true
  19711. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19712. }
  19713. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  19714. func (m *MessageRecordsMutation) SopStageCleared() bool {
  19715. return m.SourceIDCleared() || m.clearedsop_stage
  19716. }
  19717. // SopStageID returns the "sop_stage" edge ID in the mutation.
  19718. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  19719. if m.sop_stage != nil {
  19720. return *m.sop_stage, true
  19721. }
  19722. return
  19723. }
  19724. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  19725. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19726. // SopStageID instead. It exists only for internal usage by the builders.
  19727. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  19728. if id := m.sop_stage; id != nil {
  19729. ids = append(ids, *id)
  19730. }
  19731. return
  19732. }
  19733. // ResetSopStage resets all changes to the "sop_stage" edge.
  19734. func (m *MessageRecordsMutation) ResetSopStage() {
  19735. m.sop_stage = nil
  19736. m.clearedsop_stage = false
  19737. }
  19738. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  19739. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  19740. m.sop_node = &id
  19741. }
  19742. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  19743. func (m *MessageRecordsMutation) ClearSopNode() {
  19744. m.clearedsop_node = true
  19745. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19746. }
  19747. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  19748. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  19749. return m.SubSourceIDCleared() || m.clearedsop_node
  19750. }
  19751. // SopNodeID returns the "sop_node" edge ID in the mutation.
  19752. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  19753. if m.sop_node != nil {
  19754. return *m.sop_node, true
  19755. }
  19756. return
  19757. }
  19758. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  19759. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19760. // SopNodeID instead. It exists only for internal usage by the builders.
  19761. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  19762. if id := m.sop_node; id != nil {
  19763. ids = append(ids, *id)
  19764. }
  19765. return
  19766. }
  19767. // ResetSopNode resets all changes to the "sop_node" edge.
  19768. func (m *MessageRecordsMutation) ResetSopNode() {
  19769. m.sop_node = nil
  19770. m.clearedsop_node = false
  19771. }
  19772. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  19773. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  19774. m.message_contact = &id
  19775. }
  19776. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  19777. func (m *MessageRecordsMutation) ClearMessageContact() {
  19778. m.clearedmessage_contact = true
  19779. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19780. }
  19781. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  19782. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  19783. return m.ContactIDCleared() || m.clearedmessage_contact
  19784. }
  19785. // MessageContactID returns the "message_contact" edge ID in the mutation.
  19786. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  19787. if m.message_contact != nil {
  19788. return *m.message_contact, true
  19789. }
  19790. return
  19791. }
  19792. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  19793. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19794. // MessageContactID instead. It exists only for internal usage by the builders.
  19795. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  19796. if id := m.message_contact; id != nil {
  19797. ids = append(ids, *id)
  19798. }
  19799. return
  19800. }
  19801. // ResetMessageContact resets all changes to the "message_contact" edge.
  19802. func (m *MessageRecordsMutation) ResetMessageContact() {
  19803. m.message_contact = nil
  19804. m.clearedmessage_contact = false
  19805. }
  19806. // Where appends a list predicates to the MessageRecordsMutation builder.
  19807. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  19808. m.predicates = append(m.predicates, ps...)
  19809. }
  19810. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  19811. // users can use type-assertion to append predicates that do not depend on any generated package.
  19812. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  19813. p := make([]predicate.MessageRecords, len(ps))
  19814. for i := range ps {
  19815. p[i] = ps[i]
  19816. }
  19817. m.Where(p...)
  19818. }
  19819. // Op returns the operation name.
  19820. func (m *MessageRecordsMutation) Op() Op {
  19821. return m.op
  19822. }
  19823. // SetOp allows setting the mutation operation.
  19824. func (m *MessageRecordsMutation) SetOp(op Op) {
  19825. m.op = op
  19826. }
  19827. // Type returns the node type of this mutation (MessageRecords).
  19828. func (m *MessageRecordsMutation) Type() string {
  19829. return m.typ
  19830. }
  19831. // Fields returns all fields that were changed during this mutation. Note that in
  19832. // order to get all numeric fields that were incremented/decremented, call
  19833. // AddedFields().
  19834. func (m *MessageRecordsMutation) Fields() []string {
  19835. fields := make([]string, 0, 16)
  19836. if m.created_at != nil {
  19837. fields = append(fields, messagerecords.FieldCreatedAt)
  19838. }
  19839. if m.updated_at != nil {
  19840. fields = append(fields, messagerecords.FieldUpdatedAt)
  19841. }
  19842. if m.status != nil {
  19843. fields = append(fields, messagerecords.FieldStatus)
  19844. }
  19845. if m.bot_wxid != nil {
  19846. fields = append(fields, messagerecords.FieldBotWxid)
  19847. }
  19848. if m.message_contact != nil {
  19849. fields = append(fields, messagerecords.FieldContactID)
  19850. }
  19851. if m.contact_type != nil {
  19852. fields = append(fields, messagerecords.FieldContactType)
  19853. }
  19854. if m.contact_wxid != nil {
  19855. fields = append(fields, messagerecords.FieldContactWxid)
  19856. }
  19857. if m.content_type != nil {
  19858. fields = append(fields, messagerecords.FieldContentType)
  19859. }
  19860. if m.content != nil {
  19861. fields = append(fields, messagerecords.FieldContent)
  19862. }
  19863. if m.meta != nil {
  19864. fields = append(fields, messagerecords.FieldMeta)
  19865. }
  19866. if m.error_detail != nil {
  19867. fields = append(fields, messagerecords.FieldErrorDetail)
  19868. }
  19869. if m.send_time != nil {
  19870. fields = append(fields, messagerecords.FieldSendTime)
  19871. }
  19872. if m.source_type != nil {
  19873. fields = append(fields, messagerecords.FieldSourceType)
  19874. }
  19875. if m.sop_stage != nil {
  19876. fields = append(fields, messagerecords.FieldSourceID)
  19877. }
  19878. if m.sop_node != nil {
  19879. fields = append(fields, messagerecords.FieldSubSourceID)
  19880. }
  19881. if m.organization_id != nil {
  19882. fields = append(fields, messagerecords.FieldOrganizationID)
  19883. }
  19884. return fields
  19885. }
  19886. // Field returns the value of a field with the given name. The second boolean
  19887. // return value indicates that this field was not set, or was not defined in the
  19888. // schema.
  19889. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  19890. switch name {
  19891. case messagerecords.FieldCreatedAt:
  19892. return m.CreatedAt()
  19893. case messagerecords.FieldUpdatedAt:
  19894. return m.UpdatedAt()
  19895. case messagerecords.FieldStatus:
  19896. return m.Status()
  19897. case messagerecords.FieldBotWxid:
  19898. return m.BotWxid()
  19899. case messagerecords.FieldContactID:
  19900. return m.ContactID()
  19901. case messagerecords.FieldContactType:
  19902. return m.ContactType()
  19903. case messagerecords.FieldContactWxid:
  19904. return m.ContactWxid()
  19905. case messagerecords.FieldContentType:
  19906. return m.ContentType()
  19907. case messagerecords.FieldContent:
  19908. return m.Content()
  19909. case messagerecords.FieldMeta:
  19910. return m.Meta()
  19911. case messagerecords.FieldErrorDetail:
  19912. return m.ErrorDetail()
  19913. case messagerecords.FieldSendTime:
  19914. return m.SendTime()
  19915. case messagerecords.FieldSourceType:
  19916. return m.SourceType()
  19917. case messagerecords.FieldSourceID:
  19918. return m.SourceID()
  19919. case messagerecords.FieldSubSourceID:
  19920. return m.SubSourceID()
  19921. case messagerecords.FieldOrganizationID:
  19922. return m.OrganizationID()
  19923. }
  19924. return nil, false
  19925. }
  19926. // OldField returns the old value of the field from the database. An error is
  19927. // returned if the mutation operation is not UpdateOne, or the query to the
  19928. // database failed.
  19929. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19930. switch name {
  19931. case messagerecords.FieldCreatedAt:
  19932. return m.OldCreatedAt(ctx)
  19933. case messagerecords.FieldUpdatedAt:
  19934. return m.OldUpdatedAt(ctx)
  19935. case messagerecords.FieldStatus:
  19936. return m.OldStatus(ctx)
  19937. case messagerecords.FieldBotWxid:
  19938. return m.OldBotWxid(ctx)
  19939. case messagerecords.FieldContactID:
  19940. return m.OldContactID(ctx)
  19941. case messagerecords.FieldContactType:
  19942. return m.OldContactType(ctx)
  19943. case messagerecords.FieldContactWxid:
  19944. return m.OldContactWxid(ctx)
  19945. case messagerecords.FieldContentType:
  19946. return m.OldContentType(ctx)
  19947. case messagerecords.FieldContent:
  19948. return m.OldContent(ctx)
  19949. case messagerecords.FieldMeta:
  19950. return m.OldMeta(ctx)
  19951. case messagerecords.FieldErrorDetail:
  19952. return m.OldErrorDetail(ctx)
  19953. case messagerecords.FieldSendTime:
  19954. return m.OldSendTime(ctx)
  19955. case messagerecords.FieldSourceType:
  19956. return m.OldSourceType(ctx)
  19957. case messagerecords.FieldSourceID:
  19958. return m.OldSourceID(ctx)
  19959. case messagerecords.FieldSubSourceID:
  19960. return m.OldSubSourceID(ctx)
  19961. case messagerecords.FieldOrganizationID:
  19962. return m.OldOrganizationID(ctx)
  19963. }
  19964. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  19965. }
  19966. // SetField sets the value of a field with the given name. It returns an error if
  19967. // the field is not defined in the schema, or if the type mismatched the field
  19968. // type.
  19969. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  19970. switch name {
  19971. case messagerecords.FieldCreatedAt:
  19972. v, ok := value.(time.Time)
  19973. if !ok {
  19974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19975. }
  19976. m.SetCreatedAt(v)
  19977. return nil
  19978. case messagerecords.FieldUpdatedAt:
  19979. v, ok := value.(time.Time)
  19980. if !ok {
  19981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19982. }
  19983. m.SetUpdatedAt(v)
  19984. return nil
  19985. case messagerecords.FieldStatus:
  19986. v, ok := value.(uint8)
  19987. if !ok {
  19988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19989. }
  19990. m.SetStatus(v)
  19991. return nil
  19992. case messagerecords.FieldBotWxid:
  19993. v, ok := value.(string)
  19994. if !ok {
  19995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19996. }
  19997. m.SetBotWxid(v)
  19998. return nil
  19999. case messagerecords.FieldContactID:
  20000. v, ok := value.(uint64)
  20001. if !ok {
  20002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20003. }
  20004. m.SetContactID(v)
  20005. return nil
  20006. case messagerecords.FieldContactType:
  20007. v, ok := value.(int)
  20008. if !ok {
  20009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20010. }
  20011. m.SetContactType(v)
  20012. return nil
  20013. case messagerecords.FieldContactWxid:
  20014. v, ok := value.(string)
  20015. if !ok {
  20016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20017. }
  20018. m.SetContactWxid(v)
  20019. return nil
  20020. case messagerecords.FieldContentType:
  20021. v, ok := value.(int)
  20022. if !ok {
  20023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20024. }
  20025. m.SetContentType(v)
  20026. return nil
  20027. case messagerecords.FieldContent:
  20028. v, ok := value.(string)
  20029. if !ok {
  20030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20031. }
  20032. m.SetContent(v)
  20033. return nil
  20034. case messagerecords.FieldMeta:
  20035. v, ok := value.(custom_types.Meta)
  20036. if !ok {
  20037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20038. }
  20039. m.SetMeta(v)
  20040. return nil
  20041. case messagerecords.FieldErrorDetail:
  20042. v, ok := value.(string)
  20043. if !ok {
  20044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20045. }
  20046. m.SetErrorDetail(v)
  20047. return nil
  20048. case messagerecords.FieldSendTime:
  20049. v, ok := value.(time.Time)
  20050. if !ok {
  20051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20052. }
  20053. m.SetSendTime(v)
  20054. return nil
  20055. case messagerecords.FieldSourceType:
  20056. v, ok := value.(int)
  20057. if !ok {
  20058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20059. }
  20060. m.SetSourceType(v)
  20061. return nil
  20062. case messagerecords.FieldSourceID:
  20063. v, ok := value.(uint64)
  20064. if !ok {
  20065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20066. }
  20067. m.SetSourceID(v)
  20068. return nil
  20069. case messagerecords.FieldSubSourceID:
  20070. v, ok := value.(uint64)
  20071. if !ok {
  20072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20073. }
  20074. m.SetSubSourceID(v)
  20075. return nil
  20076. case messagerecords.FieldOrganizationID:
  20077. v, ok := value.(uint64)
  20078. if !ok {
  20079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20080. }
  20081. m.SetOrganizationID(v)
  20082. return nil
  20083. }
  20084. return fmt.Errorf("unknown MessageRecords field %s", name)
  20085. }
  20086. // AddedFields returns all numeric fields that were incremented/decremented during
  20087. // this mutation.
  20088. func (m *MessageRecordsMutation) AddedFields() []string {
  20089. var fields []string
  20090. if m.addstatus != nil {
  20091. fields = append(fields, messagerecords.FieldStatus)
  20092. }
  20093. if m.addcontact_type != nil {
  20094. fields = append(fields, messagerecords.FieldContactType)
  20095. }
  20096. if m.addcontent_type != nil {
  20097. fields = append(fields, messagerecords.FieldContentType)
  20098. }
  20099. if m.addsource_type != nil {
  20100. fields = append(fields, messagerecords.FieldSourceType)
  20101. }
  20102. if m.addorganization_id != nil {
  20103. fields = append(fields, messagerecords.FieldOrganizationID)
  20104. }
  20105. return fields
  20106. }
  20107. // AddedField returns the numeric value that was incremented/decremented on a field
  20108. // with the given name. The second boolean return value indicates that this field
  20109. // was not set, or was not defined in the schema.
  20110. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  20111. switch name {
  20112. case messagerecords.FieldStatus:
  20113. return m.AddedStatus()
  20114. case messagerecords.FieldContactType:
  20115. return m.AddedContactType()
  20116. case messagerecords.FieldContentType:
  20117. return m.AddedContentType()
  20118. case messagerecords.FieldSourceType:
  20119. return m.AddedSourceType()
  20120. case messagerecords.FieldOrganizationID:
  20121. return m.AddedOrganizationID()
  20122. }
  20123. return nil, false
  20124. }
  20125. // AddField adds the value to the field with the given name. It returns an error if
  20126. // the field is not defined in the schema, or if the type mismatched the field
  20127. // type.
  20128. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  20129. switch name {
  20130. case messagerecords.FieldStatus:
  20131. v, ok := value.(int8)
  20132. if !ok {
  20133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20134. }
  20135. m.AddStatus(v)
  20136. return nil
  20137. case messagerecords.FieldContactType:
  20138. v, ok := value.(int)
  20139. if !ok {
  20140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20141. }
  20142. m.AddContactType(v)
  20143. return nil
  20144. case messagerecords.FieldContentType:
  20145. v, ok := value.(int)
  20146. if !ok {
  20147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20148. }
  20149. m.AddContentType(v)
  20150. return nil
  20151. case messagerecords.FieldSourceType:
  20152. v, ok := value.(int)
  20153. if !ok {
  20154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20155. }
  20156. m.AddSourceType(v)
  20157. return nil
  20158. case messagerecords.FieldOrganizationID:
  20159. v, ok := value.(int64)
  20160. if !ok {
  20161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20162. }
  20163. m.AddOrganizationID(v)
  20164. return nil
  20165. }
  20166. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  20167. }
  20168. // ClearedFields returns all nullable fields that were cleared during this
  20169. // mutation.
  20170. func (m *MessageRecordsMutation) ClearedFields() []string {
  20171. var fields []string
  20172. if m.FieldCleared(messagerecords.FieldStatus) {
  20173. fields = append(fields, messagerecords.FieldStatus)
  20174. }
  20175. if m.FieldCleared(messagerecords.FieldContactID) {
  20176. fields = append(fields, messagerecords.FieldContactID)
  20177. }
  20178. if m.FieldCleared(messagerecords.FieldMeta) {
  20179. fields = append(fields, messagerecords.FieldMeta)
  20180. }
  20181. if m.FieldCleared(messagerecords.FieldSendTime) {
  20182. fields = append(fields, messagerecords.FieldSendTime)
  20183. }
  20184. if m.FieldCleared(messagerecords.FieldSourceID) {
  20185. fields = append(fields, messagerecords.FieldSourceID)
  20186. }
  20187. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  20188. fields = append(fields, messagerecords.FieldSubSourceID)
  20189. }
  20190. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  20191. fields = append(fields, messagerecords.FieldOrganizationID)
  20192. }
  20193. return fields
  20194. }
  20195. // FieldCleared returns a boolean indicating if a field with the given name was
  20196. // cleared in this mutation.
  20197. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  20198. _, ok := m.clearedFields[name]
  20199. return ok
  20200. }
  20201. // ClearField clears the value of the field with the given name. It returns an
  20202. // error if the field is not defined in the schema.
  20203. func (m *MessageRecordsMutation) ClearField(name string) error {
  20204. switch name {
  20205. case messagerecords.FieldStatus:
  20206. m.ClearStatus()
  20207. return nil
  20208. case messagerecords.FieldContactID:
  20209. m.ClearContactID()
  20210. return nil
  20211. case messagerecords.FieldMeta:
  20212. m.ClearMeta()
  20213. return nil
  20214. case messagerecords.FieldSendTime:
  20215. m.ClearSendTime()
  20216. return nil
  20217. case messagerecords.FieldSourceID:
  20218. m.ClearSourceID()
  20219. return nil
  20220. case messagerecords.FieldSubSourceID:
  20221. m.ClearSubSourceID()
  20222. return nil
  20223. case messagerecords.FieldOrganizationID:
  20224. m.ClearOrganizationID()
  20225. return nil
  20226. }
  20227. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  20228. }
  20229. // ResetField resets all changes in the mutation for the field with the given name.
  20230. // It returns an error if the field is not defined in the schema.
  20231. func (m *MessageRecordsMutation) ResetField(name string) error {
  20232. switch name {
  20233. case messagerecords.FieldCreatedAt:
  20234. m.ResetCreatedAt()
  20235. return nil
  20236. case messagerecords.FieldUpdatedAt:
  20237. m.ResetUpdatedAt()
  20238. return nil
  20239. case messagerecords.FieldStatus:
  20240. m.ResetStatus()
  20241. return nil
  20242. case messagerecords.FieldBotWxid:
  20243. m.ResetBotWxid()
  20244. return nil
  20245. case messagerecords.FieldContactID:
  20246. m.ResetContactID()
  20247. return nil
  20248. case messagerecords.FieldContactType:
  20249. m.ResetContactType()
  20250. return nil
  20251. case messagerecords.FieldContactWxid:
  20252. m.ResetContactWxid()
  20253. return nil
  20254. case messagerecords.FieldContentType:
  20255. m.ResetContentType()
  20256. return nil
  20257. case messagerecords.FieldContent:
  20258. m.ResetContent()
  20259. return nil
  20260. case messagerecords.FieldMeta:
  20261. m.ResetMeta()
  20262. return nil
  20263. case messagerecords.FieldErrorDetail:
  20264. m.ResetErrorDetail()
  20265. return nil
  20266. case messagerecords.FieldSendTime:
  20267. m.ResetSendTime()
  20268. return nil
  20269. case messagerecords.FieldSourceType:
  20270. m.ResetSourceType()
  20271. return nil
  20272. case messagerecords.FieldSourceID:
  20273. m.ResetSourceID()
  20274. return nil
  20275. case messagerecords.FieldSubSourceID:
  20276. m.ResetSubSourceID()
  20277. return nil
  20278. case messagerecords.FieldOrganizationID:
  20279. m.ResetOrganizationID()
  20280. return nil
  20281. }
  20282. return fmt.Errorf("unknown MessageRecords field %s", name)
  20283. }
  20284. // AddedEdges returns all edge names that were set/added in this mutation.
  20285. func (m *MessageRecordsMutation) AddedEdges() []string {
  20286. edges := make([]string, 0, 3)
  20287. if m.sop_stage != nil {
  20288. edges = append(edges, messagerecords.EdgeSopStage)
  20289. }
  20290. if m.sop_node != nil {
  20291. edges = append(edges, messagerecords.EdgeSopNode)
  20292. }
  20293. if m.message_contact != nil {
  20294. edges = append(edges, messagerecords.EdgeMessageContact)
  20295. }
  20296. return edges
  20297. }
  20298. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20299. // name in this mutation.
  20300. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  20301. switch name {
  20302. case messagerecords.EdgeSopStage:
  20303. if id := m.sop_stage; id != nil {
  20304. return []ent.Value{*id}
  20305. }
  20306. case messagerecords.EdgeSopNode:
  20307. if id := m.sop_node; id != nil {
  20308. return []ent.Value{*id}
  20309. }
  20310. case messagerecords.EdgeMessageContact:
  20311. if id := m.message_contact; id != nil {
  20312. return []ent.Value{*id}
  20313. }
  20314. }
  20315. return nil
  20316. }
  20317. // RemovedEdges returns all edge names that were removed in this mutation.
  20318. func (m *MessageRecordsMutation) RemovedEdges() []string {
  20319. edges := make([]string, 0, 3)
  20320. return edges
  20321. }
  20322. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20323. // the given name in this mutation.
  20324. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  20325. return nil
  20326. }
  20327. // ClearedEdges returns all edge names that were cleared in this mutation.
  20328. func (m *MessageRecordsMutation) ClearedEdges() []string {
  20329. edges := make([]string, 0, 3)
  20330. if m.clearedsop_stage {
  20331. edges = append(edges, messagerecords.EdgeSopStage)
  20332. }
  20333. if m.clearedsop_node {
  20334. edges = append(edges, messagerecords.EdgeSopNode)
  20335. }
  20336. if m.clearedmessage_contact {
  20337. edges = append(edges, messagerecords.EdgeMessageContact)
  20338. }
  20339. return edges
  20340. }
  20341. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20342. // was cleared in this mutation.
  20343. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  20344. switch name {
  20345. case messagerecords.EdgeSopStage:
  20346. return m.clearedsop_stage
  20347. case messagerecords.EdgeSopNode:
  20348. return m.clearedsop_node
  20349. case messagerecords.EdgeMessageContact:
  20350. return m.clearedmessage_contact
  20351. }
  20352. return false
  20353. }
  20354. // ClearEdge clears the value of the edge with the given name. It returns an error
  20355. // if that edge is not defined in the schema.
  20356. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  20357. switch name {
  20358. case messagerecords.EdgeSopStage:
  20359. m.ClearSopStage()
  20360. return nil
  20361. case messagerecords.EdgeSopNode:
  20362. m.ClearSopNode()
  20363. return nil
  20364. case messagerecords.EdgeMessageContact:
  20365. m.ClearMessageContact()
  20366. return nil
  20367. }
  20368. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  20369. }
  20370. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20371. // It returns an error if the edge is not defined in the schema.
  20372. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  20373. switch name {
  20374. case messagerecords.EdgeSopStage:
  20375. m.ResetSopStage()
  20376. return nil
  20377. case messagerecords.EdgeSopNode:
  20378. m.ResetSopNode()
  20379. return nil
  20380. case messagerecords.EdgeMessageContact:
  20381. m.ResetMessageContact()
  20382. return nil
  20383. }
  20384. return fmt.Errorf("unknown MessageRecords edge %s", name)
  20385. }
  20386. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  20387. type MsgMutation struct {
  20388. config
  20389. op Op
  20390. typ string
  20391. id *uint64
  20392. created_at *time.Time
  20393. updated_at *time.Time
  20394. deleted_at *time.Time
  20395. status *uint8
  20396. addstatus *int8
  20397. fromwxid *string
  20398. toid *string
  20399. msgtype *int32
  20400. addmsgtype *int32
  20401. msg *string
  20402. batch_no *string
  20403. cc *string
  20404. phone *string
  20405. clearedFields map[string]struct{}
  20406. done bool
  20407. oldValue func(context.Context) (*Msg, error)
  20408. predicates []predicate.Msg
  20409. }
  20410. var _ ent.Mutation = (*MsgMutation)(nil)
  20411. // msgOption allows management of the mutation configuration using functional options.
  20412. type msgOption func(*MsgMutation)
  20413. // newMsgMutation creates new mutation for the Msg entity.
  20414. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  20415. m := &MsgMutation{
  20416. config: c,
  20417. op: op,
  20418. typ: TypeMsg,
  20419. clearedFields: make(map[string]struct{}),
  20420. }
  20421. for _, opt := range opts {
  20422. opt(m)
  20423. }
  20424. return m
  20425. }
  20426. // withMsgID sets the ID field of the mutation.
  20427. func withMsgID(id uint64) msgOption {
  20428. return func(m *MsgMutation) {
  20429. var (
  20430. err error
  20431. once sync.Once
  20432. value *Msg
  20433. )
  20434. m.oldValue = func(ctx context.Context) (*Msg, error) {
  20435. once.Do(func() {
  20436. if m.done {
  20437. err = errors.New("querying old values post mutation is not allowed")
  20438. } else {
  20439. value, err = m.Client().Msg.Get(ctx, id)
  20440. }
  20441. })
  20442. return value, err
  20443. }
  20444. m.id = &id
  20445. }
  20446. }
  20447. // withMsg sets the old Msg of the mutation.
  20448. func withMsg(node *Msg) msgOption {
  20449. return func(m *MsgMutation) {
  20450. m.oldValue = func(context.Context) (*Msg, error) {
  20451. return node, nil
  20452. }
  20453. m.id = &node.ID
  20454. }
  20455. }
  20456. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20457. // executed in a transaction (ent.Tx), a transactional client is returned.
  20458. func (m MsgMutation) Client() *Client {
  20459. client := &Client{config: m.config}
  20460. client.init()
  20461. return client
  20462. }
  20463. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20464. // it returns an error otherwise.
  20465. func (m MsgMutation) Tx() (*Tx, error) {
  20466. if _, ok := m.driver.(*txDriver); !ok {
  20467. return nil, errors.New("ent: mutation is not running in a transaction")
  20468. }
  20469. tx := &Tx{config: m.config}
  20470. tx.init()
  20471. return tx, nil
  20472. }
  20473. // SetID sets the value of the id field. Note that this
  20474. // operation is only accepted on creation of Msg entities.
  20475. func (m *MsgMutation) SetID(id uint64) {
  20476. m.id = &id
  20477. }
  20478. // ID returns the ID value in the mutation. Note that the ID is only available
  20479. // if it was provided to the builder or after it was returned from the database.
  20480. func (m *MsgMutation) ID() (id uint64, exists bool) {
  20481. if m.id == nil {
  20482. return
  20483. }
  20484. return *m.id, true
  20485. }
  20486. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20487. // That means, if the mutation is applied within a transaction with an isolation level such
  20488. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20489. // or updated by the mutation.
  20490. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  20491. switch {
  20492. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20493. id, exists := m.ID()
  20494. if exists {
  20495. return []uint64{id}, nil
  20496. }
  20497. fallthrough
  20498. case m.op.Is(OpUpdate | OpDelete):
  20499. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  20500. default:
  20501. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20502. }
  20503. }
  20504. // SetCreatedAt sets the "created_at" field.
  20505. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  20506. m.created_at = &t
  20507. }
  20508. // CreatedAt returns the value of the "created_at" field in the mutation.
  20509. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  20510. v := m.created_at
  20511. if v == nil {
  20512. return
  20513. }
  20514. return *v, true
  20515. }
  20516. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  20517. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20519. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20520. if !m.op.Is(OpUpdateOne) {
  20521. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20522. }
  20523. if m.id == nil || m.oldValue == nil {
  20524. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20525. }
  20526. oldValue, err := m.oldValue(ctx)
  20527. if err != nil {
  20528. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20529. }
  20530. return oldValue.CreatedAt, nil
  20531. }
  20532. // ResetCreatedAt resets all changes to the "created_at" field.
  20533. func (m *MsgMutation) ResetCreatedAt() {
  20534. m.created_at = nil
  20535. }
  20536. // SetUpdatedAt sets the "updated_at" field.
  20537. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  20538. m.updated_at = &t
  20539. }
  20540. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20541. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  20542. v := m.updated_at
  20543. if v == nil {
  20544. return
  20545. }
  20546. return *v, true
  20547. }
  20548. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  20549. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20551. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20552. if !m.op.Is(OpUpdateOne) {
  20553. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20554. }
  20555. if m.id == nil || m.oldValue == nil {
  20556. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20557. }
  20558. oldValue, err := m.oldValue(ctx)
  20559. if err != nil {
  20560. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20561. }
  20562. return oldValue.UpdatedAt, nil
  20563. }
  20564. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20565. func (m *MsgMutation) ResetUpdatedAt() {
  20566. m.updated_at = nil
  20567. }
  20568. // SetDeletedAt sets the "deleted_at" field.
  20569. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  20570. m.deleted_at = &t
  20571. }
  20572. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20573. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  20574. v := m.deleted_at
  20575. if v == nil {
  20576. return
  20577. }
  20578. return *v, true
  20579. }
  20580. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  20581. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20583. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20584. if !m.op.Is(OpUpdateOne) {
  20585. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20586. }
  20587. if m.id == nil || m.oldValue == nil {
  20588. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20589. }
  20590. oldValue, err := m.oldValue(ctx)
  20591. if err != nil {
  20592. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20593. }
  20594. return oldValue.DeletedAt, nil
  20595. }
  20596. // ClearDeletedAt clears the value of the "deleted_at" field.
  20597. func (m *MsgMutation) ClearDeletedAt() {
  20598. m.deleted_at = nil
  20599. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  20600. }
  20601. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20602. func (m *MsgMutation) DeletedAtCleared() bool {
  20603. _, ok := m.clearedFields[msg.FieldDeletedAt]
  20604. return ok
  20605. }
  20606. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20607. func (m *MsgMutation) ResetDeletedAt() {
  20608. m.deleted_at = nil
  20609. delete(m.clearedFields, msg.FieldDeletedAt)
  20610. }
  20611. // SetStatus sets the "status" field.
  20612. func (m *MsgMutation) SetStatus(u uint8) {
  20613. m.status = &u
  20614. m.addstatus = nil
  20615. }
  20616. // Status returns the value of the "status" field in the mutation.
  20617. func (m *MsgMutation) Status() (r uint8, exists bool) {
  20618. v := m.status
  20619. if v == nil {
  20620. return
  20621. }
  20622. return *v, true
  20623. }
  20624. // OldStatus returns the old "status" field's value of the Msg entity.
  20625. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20627. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20628. if !m.op.Is(OpUpdateOne) {
  20629. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20630. }
  20631. if m.id == nil || m.oldValue == nil {
  20632. return v, errors.New("OldStatus requires an ID field in the mutation")
  20633. }
  20634. oldValue, err := m.oldValue(ctx)
  20635. if err != nil {
  20636. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20637. }
  20638. return oldValue.Status, nil
  20639. }
  20640. // AddStatus adds u to the "status" field.
  20641. func (m *MsgMutation) AddStatus(u int8) {
  20642. if m.addstatus != nil {
  20643. *m.addstatus += u
  20644. } else {
  20645. m.addstatus = &u
  20646. }
  20647. }
  20648. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20649. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  20650. v := m.addstatus
  20651. if v == nil {
  20652. return
  20653. }
  20654. return *v, true
  20655. }
  20656. // ClearStatus clears the value of the "status" field.
  20657. func (m *MsgMutation) ClearStatus() {
  20658. m.status = nil
  20659. m.addstatus = nil
  20660. m.clearedFields[msg.FieldStatus] = struct{}{}
  20661. }
  20662. // StatusCleared returns if the "status" field was cleared in this mutation.
  20663. func (m *MsgMutation) StatusCleared() bool {
  20664. _, ok := m.clearedFields[msg.FieldStatus]
  20665. return ok
  20666. }
  20667. // ResetStatus resets all changes to the "status" field.
  20668. func (m *MsgMutation) ResetStatus() {
  20669. m.status = nil
  20670. m.addstatus = nil
  20671. delete(m.clearedFields, msg.FieldStatus)
  20672. }
  20673. // SetFromwxid sets the "fromwxid" field.
  20674. func (m *MsgMutation) SetFromwxid(s string) {
  20675. m.fromwxid = &s
  20676. }
  20677. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  20678. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  20679. v := m.fromwxid
  20680. if v == nil {
  20681. return
  20682. }
  20683. return *v, true
  20684. }
  20685. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  20686. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20688. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  20689. if !m.op.Is(OpUpdateOne) {
  20690. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  20691. }
  20692. if m.id == nil || m.oldValue == nil {
  20693. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  20694. }
  20695. oldValue, err := m.oldValue(ctx)
  20696. if err != nil {
  20697. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  20698. }
  20699. return oldValue.Fromwxid, nil
  20700. }
  20701. // ClearFromwxid clears the value of the "fromwxid" field.
  20702. func (m *MsgMutation) ClearFromwxid() {
  20703. m.fromwxid = nil
  20704. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  20705. }
  20706. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  20707. func (m *MsgMutation) FromwxidCleared() bool {
  20708. _, ok := m.clearedFields[msg.FieldFromwxid]
  20709. return ok
  20710. }
  20711. // ResetFromwxid resets all changes to the "fromwxid" field.
  20712. func (m *MsgMutation) ResetFromwxid() {
  20713. m.fromwxid = nil
  20714. delete(m.clearedFields, msg.FieldFromwxid)
  20715. }
  20716. // SetToid sets the "toid" field.
  20717. func (m *MsgMutation) SetToid(s string) {
  20718. m.toid = &s
  20719. }
  20720. // Toid returns the value of the "toid" field in the mutation.
  20721. func (m *MsgMutation) Toid() (r string, exists bool) {
  20722. v := m.toid
  20723. if v == nil {
  20724. return
  20725. }
  20726. return *v, true
  20727. }
  20728. // OldToid returns the old "toid" field's value of the Msg entity.
  20729. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20731. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  20732. if !m.op.Is(OpUpdateOne) {
  20733. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  20734. }
  20735. if m.id == nil || m.oldValue == nil {
  20736. return v, errors.New("OldToid requires an ID field in the mutation")
  20737. }
  20738. oldValue, err := m.oldValue(ctx)
  20739. if err != nil {
  20740. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  20741. }
  20742. return oldValue.Toid, nil
  20743. }
  20744. // ClearToid clears the value of the "toid" field.
  20745. func (m *MsgMutation) ClearToid() {
  20746. m.toid = nil
  20747. m.clearedFields[msg.FieldToid] = struct{}{}
  20748. }
  20749. // ToidCleared returns if the "toid" field was cleared in this mutation.
  20750. func (m *MsgMutation) ToidCleared() bool {
  20751. _, ok := m.clearedFields[msg.FieldToid]
  20752. return ok
  20753. }
  20754. // ResetToid resets all changes to the "toid" field.
  20755. func (m *MsgMutation) ResetToid() {
  20756. m.toid = nil
  20757. delete(m.clearedFields, msg.FieldToid)
  20758. }
  20759. // SetMsgtype sets the "msgtype" field.
  20760. func (m *MsgMutation) SetMsgtype(i int32) {
  20761. m.msgtype = &i
  20762. m.addmsgtype = nil
  20763. }
  20764. // Msgtype returns the value of the "msgtype" field in the mutation.
  20765. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  20766. v := m.msgtype
  20767. if v == nil {
  20768. return
  20769. }
  20770. return *v, true
  20771. }
  20772. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  20773. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20775. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  20776. if !m.op.Is(OpUpdateOne) {
  20777. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  20778. }
  20779. if m.id == nil || m.oldValue == nil {
  20780. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  20781. }
  20782. oldValue, err := m.oldValue(ctx)
  20783. if err != nil {
  20784. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  20785. }
  20786. return oldValue.Msgtype, nil
  20787. }
  20788. // AddMsgtype adds i to the "msgtype" field.
  20789. func (m *MsgMutation) AddMsgtype(i int32) {
  20790. if m.addmsgtype != nil {
  20791. *m.addmsgtype += i
  20792. } else {
  20793. m.addmsgtype = &i
  20794. }
  20795. }
  20796. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  20797. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  20798. v := m.addmsgtype
  20799. if v == nil {
  20800. return
  20801. }
  20802. return *v, true
  20803. }
  20804. // ClearMsgtype clears the value of the "msgtype" field.
  20805. func (m *MsgMutation) ClearMsgtype() {
  20806. m.msgtype = nil
  20807. m.addmsgtype = nil
  20808. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  20809. }
  20810. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  20811. func (m *MsgMutation) MsgtypeCleared() bool {
  20812. _, ok := m.clearedFields[msg.FieldMsgtype]
  20813. return ok
  20814. }
  20815. // ResetMsgtype resets all changes to the "msgtype" field.
  20816. func (m *MsgMutation) ResetMsgtype() {
  20817. m.msgtype = nil
  20818. m.addmsgtype = nil
  20819. delete(m.clearedFields, msg.FieldMsgtype)
  20820. }
  20821. // SetMsg sets the "msg" field.
  20822. func (m *MsgMutation) SetMsg(s string) {
  20823. m.msg = &s
  20824. }
  20825. // Msg returns the value of the "msg" field in the mutation.
  20826. func (m *MsgMutation) Msg() (r string, exists bool) {
  20827. v := m.msg
  20828. if v == nil {
  20829. return
  20830. }
  20831. return *v, true
  20832. }
  20833. // OldMsg returns the old "msg" field's value of the Msg entity.
  20834. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20836. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  20837. if !m.op.Is(OpUpdateOne) {
  20838. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  20839. }
  20840. if m.id == nil || m.oldValue == nil {
  20841. return v, errors.New("OldMsg requires an ID field in the mutation")
  20842. }
  20843. oldValue, err := m.oldValue(ctx)
  20844. if err != nil {
  20845. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  20846. }
  20847. return oldValue.Msg, nil
  20848. }
  20849. // ClearMsg clears the value of the "msg" field.
  20850. func (m *MsgMutation) ClearMsg() {
  20851. m.msg = nil
  20852. m.clearedFields[msg.FieldMsg] = struct{}{}
  20853. }
  20854. // MsgCleared returns if the "msg" field was cleared in this mutation.
  20855. func (m *MsgMutation) MsgCleared() bool {
  20856. _, ok := m.clearedFields[msg.FieldMsg]
  20857. return ok
  20858. }
  20859. // ResetMsg resets all changes to the "msg" field.
  20860. func (m *MsgMutation) ResetMsg() {
  20861. m.msg = nil
  20862. delete(m.clearedFields, msg.FieldMsg)
  20863. }
  20864. // SetBatchNo sets the "batch_no" field.
  20865. func (m *MsgMutation) SetBatchNo(s string) {
  20866. m.batch_no = &s
  20867. }
  20868. // BatchNo returns the value of the "batch_no" field in the mutation.
  20869. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  20870. v := m.batch_no
  20871. if v == nil {
  20872. return
  20873. }
  20874. return *v, true
  20875. }
  20876. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  20877. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20879. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  20880. if !m.op.Is(OpUpdateOne) {
  20881. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  20882. }
  20883. if m.id == nil || m.oldValue == nil {
  20884. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  20885. }
  20886. oldValue, err := m.oldValue(ctx)
  20887. if err != nil {
  20888. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  20889. }
  20890. return oldValue.BatchNo, nil
  20891. }
  20892. // ClearBatchNo clears the value of the "batch_no" field.
  20893. func (m *MsgMutation) ClearBatchNo() {
  20894. m.batch_no = nil
  20895. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  20896. }
  20897. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  20898. func (m *MsgMutation) BatchNoCleared() bool {
  20899. _, ok := m.clearedFields[msg.FieldBatchNo]
  20900. return ok
  20901. }
  20902. // ResetBatchNo resets all changes to the "batch_no" field.
  20903. func (m *MsgMutation) ResetBatchNo() {
  20904. m.batch_no = nil
  20905. delete(m.clearedFields, msg.FieldBatchNo)
  20906. }
  20907. // SetCc sets the "cc" field.
  20908. func (m *MsgMutation) SetCc(s string) {
  20909. m.cc = &s
  20910. }
  20911. // Cc returns the value of the "cc" field in the mutation.
  20912. func (m *MsgMutation) Cc() (r string, exists bool) {
  20913. v := m.cc
  20914. if v == nil {
  20915. return
  20916. }
  20917. return *v, true
  20918. }
  20919. // OldCc returns the old "cc" field's value of the Msg entity.
  20920. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20922. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  20923. if !m.op.Is(OpUpdateOne) {
  20924. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  20925. }
  20926. if m.id == nil || m.oldValue == nil {
  20927. return v, errors.New("OldCc requires an ID field in the mutation")
  20928. }
  20929. oldValue, err := m.oldValue(ctx)
  20930. if err != nil {
  20931. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  20932. }
  20933. return oldValue.Cc, nil
  20934. }
  20935. // ResetCc resets all changes to the "cc" field.
  20936. func (m *MsgMutation) ResetCc() {
  20937. m.cc = nil
  20938. }
  20939. // SetPhone sets the "phone" field.
  20940. func (m *MsgMutation) SetPhone(s string) {
  20941. m.phone = &s
  20942. }
  20943. // Phone returns the value of the "phone" field in the mutation.
  20944. func (m *MsgMutation) Phone() (r string, exists bool) {
  20945. v := m.phone
  20946. if v == nil {
  20947. return
  20948. }
  20949. return *v, true
  20950. }
  20951. // OldPhone returns the old "phone" field's value of the Msg entity.
  20952. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20954. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  20955. if !m.op.Is(OpUpdateOne) {
  20956. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  20957. }
  20958. if m.id == nil || m.oldValue == nil {
  20959. return v, errors.New("OldPhone requires an ID field in the mutation")
  20960. }
  20961. oldValue, err := m.oldValue(ctx)
  20962. if err != nil {
  20963. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  20964. }
  20965. return oldValue.Phone, nil
  20966. }
  20967. // ResetPhone resets all changes to the "phone" field.
  20968. func (m *MsgMutation) ResetPhone() {
  20969. m.phone = nil
  20970. }
  20971. // Where appends a list predicates to the MsgMutation builder.
  20972. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  20973. m.predicates = append(m.predicates, ps...)
  20974. }
  20975. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  20976. // users can use type-assertion to append predicates that do not depend on any generated package.
  20977. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  20978. p := make([]predicate.Msg, len(ps))
  20979. for i := range ps {
  20980. p[i] = ps[i]
  20981. }
  20982. m.Where(p...)
  20983. }
  20984. // Op returns the operation name.
  20985. func (m *MsgMutation) Op() Op {
  20986. return m.op
  20987. }
  20988. // SetOp allows setting the mutation operation.
  20989. func (m *MsgMutation) SetOp(op Op) {
  20990. m.op = op
  20991. }
  20992. // Type returns the node type of this mutation (Msg).
  20993. func (m *MsgMutation) Type() string {
  20994. return m.typ
  20995. }
  20996. // Fields returns all fields that were changed during this mutation. Note that in
  20997. // order to get all numeric fields that were incremented/decremented, call
  20998. // AddedFields().
  20999. func (m *MsgMutation) Fields() []string {
  21000. fields := make([]string, 0, 11)
  21001. if m.created_at != nil {
  21002. fields = append(fields, msg.FieldCreatedAt)
  21003. }
  21004. if m.updated_at != nil {
  21005. fields = append(fields, msg.FieldUpdatedAt)
  21006. }
  21007. if m.deleted_at != nil {
  21008. fields = append(fields, msg.FieldDeletedAt)
  21009. }
  21010. if m.status != nil {
  21011. fields = append(fields, msg.FieldStatus)
  21012. }
  21013. if m.fromwxid != nil {
  21014. fields = append(fields, msg.FieldFromwxid)
  21015. }
  21016. if m.toid != nil {
  21017. fields = append(fields, msg.FieldToid)
  21018. }
  21019. if m.msgtype != nil {
  21020. fields = append(fields, msg.FieldMsgtype)
  21021. }
  21022. if m.msg != nil {
  21023. fields = append(fields, msg.FieldMsg)
  21024. }
  21025. if m.batch_no != nil {
  21026. fields = append(fields, msg.FieldBatchNo)
  21027. }
  21028. if m.cc != nil {
  21029. fields = append(fields, msg.FieldCc)
  21030. }
  21031. if m.phone != nil {
  21032. fields = append(fields, msg.FieldPhone)
  21033. }
  21034. return fields
  21035. }
  21036. // Field returns the value of a field with the given name. The second boolean
  21037. // return value indicates that this field was not set, or was not defined in the
  21038. // schema.
  21039. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  21040. switch name {
  21041. case msg.FieldCreatedAt:
  21042. return m.CreatedAt()
  21043. case msg.FieldUpdatedAt:
  21044. return m.UpdatedAt()
  21045. case msg.FieldDeletedAt:
  21046. return m.DeletedAt()
  21047. case msg.FieldStatus:
  21048. return m.Status()
  21049. case msg.FieldFromwxid:
  21050. return m.Fromwxid()
  21051. case msg.FieldToid:
  21052. return m.Toid()
  21053. case msg.FieldMsgtype:
  21054. return m.Msgtype()
  21055. case msg.FieldMsg:
  21056. return m.Msg()
  21057. case msg.FieldBatchNo:
  21058. return m.BatchNo()
  21059. case msg.FieldCc:
  21060. return m.Cc()
  21061. case msg.FieldPhone:
  21062. return m.Phone()
  21063. }
  21064. return nil, false
  21065. }
  21066. // OldField returns the old value of the field from the database. An error is
  21067. // returned if the mutation operation is not UpdateOne, or the query to the
  21068. // database failed.
  21069. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21070. switch name {
  21071. case msg.FieldCreatedAt:
  21072. return m.OldCreatedAt(ctx)
  21073. case msg.FieldUpdatedAt:
  21074. return m.OldUpdatedAt(ctx)
  21075. case msg.FieldDeletedAt:
  21076. return m.OldDeletedAt(ctx)
  21077. case msg.FieldStatus:
  21078. return m.OldStatus(ctx)
  21079. case msg.FieldFromwxid:
  21080. return m.OldFromwxid(ctx)
  21081. case msg.FieldToid:
  21082. return m.OldToid(ctx)
  21083. case msg.FieldMsgtype:
  21084. return m.OldMsgtype(ctx)
  21085. case msg.FieldMsg:
  21086. return m.OldMsg(ctx)
  21087. case msg.FieldBatchNo:
  21088. return m.OldBatchNo(ctx)
  21089. case msg.FieldCc:
  21090. return m.OldCc(ctx)
  21091. case msg.FieldPhone:
  21092. return m.OldPhone(ctx)
  21093. }
  21094. return nil, fmt.Errorf("unknown Msg field %s", name)
  21095. }
  21096. // SetField sets the value of a field with the given name. It returns an error if
  21097. // the field is not defined in the schema, or if the type mismatched the field
  21098. // type.
  21099. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  21100. switch name {
  21101. case msg.FieldCreatedAt:
  21102. v, ok := value.(time.Time)
  21103. if !ok {
  21104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21105. }
  21106. m.SetCreatedAt(v)
  21107. return nil
  21108. case msg.FieldUpdatedAt:
  21109. v, ok := value.(time.Time)
  21110. if !ok {
  21111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21112. }
  21113. m.SetUpdatedAt(v)
  21114. return nil
  21115. case msg.FieldDeletedAt:
  21116. v, ok := value.(time.Time)
  21117. if !ok {
  21118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21119. }
  21120. m.SetDeletedAt(v)
  21121. return nil
  21122. case msg.FieldStatus:
  21123. v, ok := value.(uint8)
  21124. if !ok {
  21125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21126. }
  21127. m.SetStatus(v)
  21128. return nil
  21129. case msg.FieldFromwxid:
  21130. v, ok := value.(string)
  21131. if !ok {
  21132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21133. }
  21134. m.SetFromwxid(v)
  21135. return nil
  21136. case msg.FieldToid:
  21137. v, ok := value.(string)
  21138. if !ok {
  21139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21140. }
  21141. m.SetToid(v)
  21142. return nil
  21143. case msg.FieldMsgtype:
  21144. v, ok := value.(int32)
  21145. if !ok {
  21146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21147. }
  21148. m.SetMsgtype(v)
  21149. return nil
  21150. case msg.FieldMsg:
  21151. v, ok := value.(string)
  21152. if !ok {
  21153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21154. }
  21155. m.SetMsg(v)
  21156. return nil
  21157. case msg.FieldBatchNo:
  21158. v, ok := value.(string)
  21159. if !ok {
  21160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21161. }
  21162. m.SetBatchNo(v)
  21163. return nil
  21164. case msg.FieldCc:
  21165. v, ok := value.(string)
  21166. if !ok {
  21167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21168. }
  21169. m.SetCc(v)
  21170. return nil
  21171. case msg.FieldPhone:
  21172. v, ok := value.(string)
  21173. if !ok {
  21174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21175. }
  21176. m.SetPhone(v)
  21177. return nil
  21178. }
  21179. return fmt.Errorf("unknown Msg field %s", name)
  21180. }
  21181. // AddedFields returns all numeric fields that were incremented/decremented during
  21182. // this mutation.
  21183. func (m *MsgMutation) AddedFields() []string {
  21184. var fields []string
  21185. if m.addstatus != nil {
  21186. fields = append(fields, msg.FieldStatus)
  21187. }
  21188. if m.addmsgtype != nil {
  21189. fields = append(fields, msg.FieldMsgtype)
  21190. }
  21191. return fields
  21192. }
  21193. // AddedField returns the numeric value that was incremented/decremented on a field
  21194. // with the given name. The second boolean return value indicates that this field
  21195. // was not set, or was not defined in the schema.
  21196. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  21197. switch name {
  21198. case msg.FieldStatus:
  21199. return m.AddedStatus()
  21200. case msg.FieldMsgtype:
  21201. return m.AddedMsgtype()
  21202. }
  21203. return nil, false
  21204. }
  21205. // AddField adds the value to the field with the given name. It returns an error if
  21206. // the field is not defined in the schema, or if the type mismatched the field
  21207. // type.
  21208. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  21209. switch name {
  21210. case msg.FieldStatus:
  21211. v, ok := value.(int8)
  21212. if !ok {
  21213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21214. }
  21215. m.AddStatus(v)
  21216. return nil
  21217. case msg.FieldMsgtype:
  21218. v, ok := value.(int32)
  21219. if !ok {
  21220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21221. }
  21222. m.AddMsgtype(v)
  21223. return nil
  21224. }
  21225. return fmt.Errorf("unknown Msg numeric field %s", name)
  21226. }
  21227. // ClearedFields returns all nullable fields that were cleared during this
  21228. // mutation.
  21229. func (m *MsgMutation) ClearedFields() []string {
  21230. var fields []string
  21231. if m.FieldCleared(msg.FieldDeletedAt) {
  21232. fields = append(fields, msg.FieldDeletedAt)
  21233. }
  21234. if m.FieldCleared(msg.FieldStatus) {
  21235. fields = append(fields, msg.FieldStatus)
  21236. }
  21237. if m.FieldCleared(msg.FieldFromwxid) {
  21238. fields = append(fields, msg.FieldFromwxid)
  21239. }
  21240. if m.FieldCleared(msg.FieldToid) {
  21241. fields = append(fields, msg.FieldToid)
  21242. }
  21243. if m.FieldCleared(msg.FieldMsgtype) {
  21244. fields = append(fields, msg.FieldMsgtype)
  21245. }
  21246. if m.FieldCleared(msg.FieldMsg) {
  21247. fields = append(fields, msg.FieldMsg)
  21248. }
  21249. if m.FieldCleared(msg.FieldBatchNo) {
  21250. fields = append(fields, msg.FieldBatchNo)
  21251. }
  21252. return fields
  21253. }
  21254. // FieldCleared returns a boolean indicating if a field with the given name was
  21255. // cleared in this mutation.
  21256. func (m *MsgMutation) FieldCleared(name string) bool {
  21257. _, ok := m.clearedFields[name]
  21258. return ok
  21259. }
  21260. // ClearField clears the value of the field with the given name. It returns an
  21261. // error if the field is not defined in the schema.
  21262. func (m *MsgMutation) ClearField(name string) error {
  21263. switch name {
  21264. case msg.FieldDeletedAt:
  21265. m.ClearDeletedAt()
  21266. return nil
  21267. case msg.FieldStatus:
  21268. m.ClearStatus()
  21269. return nil
  21270. case msg.FieldFromwxid:
  21271. m.ClearFromwxid()
  21272. return nil
  21273. case msg.FieldToid:
  21274. m.ClearToid()
  21275. return nil
  21276. case msg.FieldMsgtype:
  21277. m.ClearMsgtype()
  21278. return nil
  21279. case msg.FieldMsg:
  21280. m.ClearMsg()
  21281. return nil
  21282. case msg.FieldBatchNo:
  21283. m.ClearBatchNo()
  21284. return nil
  21285. }
  21286. return fmt.Errorf("unknown Msg nullable field %s", name)
  21287. }
  21288. // ResetField resets all changes in the mutation for the field with the given name.
  21289. // It returns an error if the field is not defined in the schema.
  21290. func (m *MsgMutation) ResetField(name string) error {
  21291. switch name {
  21292. case msg.FieldCreatedAt:
  21293. m.ResetCreatedAt()
  21294. return nil
  21295. case msg.FieldUpdatedAt:
  21296. m.ResetUpdatedAt()
  21297. return nil
  21298. case msg.FieldDeletedAt:
  21299. m.ResetDeletedAt()
  21300. return nil
  21301. case msg.FieldStatus:
  21302. m.ResetStatus()
  21303. return nil
  21304. case msg.FieldFromwxid:
  21305. m.ResetFromwxid()
  21306. return nil
  21307. case msg.FieldToid:
  21308. m.ResetToid()
  21309. return nil
  21310. case msg.FieldMsgtype:
  21311. m.ResetMsgtype()
  21312. return nil
  21313. case msg.FieldMsg:
  21314. m.ResetMsg()
  21315. return nil
  21316. case msg.FieldBatchNo:
  21317. m.ResetBatchNo()
  21318. return nil
  21319. case msg.FieldCc:
  21320. m.ResetCc()
  21321. return nil
  21322. case msg.FieldPhone:
  21323. m.ResetPhone()
  21324. return nil
  21325. }
  21326. return fmt.Errorf("unknown Msg field %s", name)
  21327. }
  21328. // AddedEdges returns all edge names that were set/added in this mutation.
  21329. func (m *MsgMutation) AddedEdges() []string {
  21330. edges := make([]string, 0, 0)
  21331. return edges
  21332. }
  21333. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21334. // name in this mutation.
  21335. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  21336. return nil
  21337. }
  21338. // RemovedEdges returns all edge names that were removed in this mutation.
  21339. func (m *MsgMutation) RemovedEdges() []string {
  21340. edges := make([]string, 0, 0)
  21341. return edges
  21342. }
  21343. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21344. // the given name in this mutation.
  21345. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  21346. return nil
  21347. }
  21348. // ClearedEdges returns all edge names that were cleared in this mutation.
  21349. func (m *MsgMutation) ClearedEdges() []string {
  21350. edges := make([]string, 0, 0)
  21351. return edges
  21352. }
  21353. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21354. // was cleared in this mutation.
  21355. func (m *MsgMutation) EdgeCleared(name string) bool {
  21356. return false
  21357. }
  21358. // ClearEdge clears the value of the edge with the given name. It returns an error
  21359. // if that edge is not defined in the schema.
  21360. func (m *MsgMutation) ClearEdge(name string) error {
  21361. return fmt.Errorf("unknown Msg unique edge %s", name)
  21362. }
  21363. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21364. // It returns an error if the edge is not defined in the schema.
  21365. func (m *MsgMutation) ResetEdge(name string) error {
  21366. return fmt.Errorf("unknown Msg edge %s", name)
  21367. }
  21368. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  21369. type PayRechargeMutation struct {
  21370. config
  21371. op Op
  21372. typ string
  21373. id *uint64
  21374. created_at *time.Time
  21375. updated_at *time.Time
  21376. deleted_at *time.Time
  21377. user_id *string
  21378. number *float32
  21379. addnumber *float32
  21380. status *int
  21381. addstatus *int
  21382. money *float32
  21383. addmoney *float32
  21384. out_trade_no *string
  21385. organization_id *uint64
  21386. addorganization_id *int64
  21387. clearedFields map[string]struct{}
  21388. done bool
  21389. oldValue func(context.Context) (*PayRecharge, error)
  21390. predicates []predicate.PayRecharge
  21391. }
  21392. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  21393. // payrechargeOption allows management of the mutation configuration using functional options.
  21394. type payrechargeOption func(*PayRechargeMutation)
  21395. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  21396. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  21397. m := &PayRechargeMutation{
  21398. config: c,
  21399. op: op,
  21400. typ: TypePayRecharge,
  21401. clearedFields: make(map[string]struct{}),
  21402. }
  21403. for _, opt := range opts {
  21404. opt(m)
  21405. }
  21406. return m
  21407. }
  21408. // withPayRechargeID sets the ID field of the mutation.
  21409. func withPayRechargeID(id uint64) payrechargeOption {
  21410. return func(m *PayRechargeMutation) {
  21411. var (
  21412. err error
  21413. once sync.Once
  21414. value *PayRecharge
  21415. )
  21416. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  21417. once.Do(func() {
  21418. if m.done {
  21419. err = errors.New("querying old values post mutation is not allowed")
  21420. } else {
  21421. value, err = m.Client().PayRecharge.Get(ctx, id)
  21422. }
  21423. })
  21424. return value, err
  21425. }
  21426. m.id = &id
  21427. }
  21428. }
  21429. // withPayRecharge sets the old PayRecharge of the mutation.
  21430. func withPayRecharge(node *PayRecharge) payrechargeOption {
  21431. return func(m *PayRechargeMutation) {
  21432. m.oldValue = func(context.Context) (*PayRecharge, error) {
  21433. return node, nil
  21434. }
  21435. m.id = &node.ID
  21436. }
  21437. }
  21438. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21439. // executed in a transaction (ent.Tx), a transactional client is returned.
  21440. func (m PayRechargeMutation) Client() *Client {
  21441. client := &Client{config: m.config}
  21442. client.init()
  21443. return client
  21444. }
  21445. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21446. // it returns an error otherwise.
  21447. func (m PayRechargeMutation) Tx() (*Tx, error) {
  21448. if _, ok := m.driver.(*txDriver); !ok {
  21449. return nil, errors.New("ent: mutation is not running in a transaction")
  21450. }
  21451. tx := &Tx{config: m.config}
  21452. tx.init()
  21453. return tx, nil
  21454. }
  21455. // SetID sets the value of the id field. Note that this
  21456. // operation is only accepted on creation of PayRecharge entities.
  21457. func (m *PayRechargeMutation) SetID(id uint64) {
  21458. m.id = &id
  21459. }
  21460. // ID returns the ID value in the mutation. Note that the ID is only available
  21461. // if it was provided to the builder or after it was returned from the database.
  21462. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  21463. if m.id == nil {
  21464. return
  21465. }
  21466. return *m.id, true
  21467. }
  21468. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21469. // That means, if the mutation is applied within a transaction with an isolation level such
  21470. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21471. // or updated by the mutation.
  21472. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  21473. switch {
  21474. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21475. id, exists := m.ID()
  21476. if exists {
  21477. return []uint64{id}, nil
  21478. }
  21479. fallthrough
  21480. case m.op.Is(OpUpdate | OpDelete):
  21481. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  21482. default:
  21483. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21484. }
  21485. }
  21486. // SetCreatedAt sets the "created_at" field.
  21487. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  21488. m.created_at = &t
  21489. }
  21490. // CreatedAt returns the value of the "created_at" field in the mutation.
  21491. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  21492. v := m.created_at
  21493. if v == nil {
  21494. return
  21495. }
  21496. return *v, true
  21497. }
  21498. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  21499. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21501. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21502. if !m.op.Is(OpUpdateOne) {
  21503. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21504. }
  21505. if m.id == nil || m.oldValue == nil {
  21506. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21507. }
  21508. oldValue, err := m.oldValue(ctx)
  21509. if err != nil {
  21510. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21511. }
  21512. return oldValue.CreatedAt, nil
  21513. }
  21514. // ResetCreatedAt resets all changes to the "created_at" field.
  21515. func (m *PayRechargeMutation) ResetCreatedAt() {
  21516. m.created_at = nil
  21517. }
  21518. // SetUpdatedAt sets the "updated_at" field.
  21519. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  21520. m.updated_at = &t
  21521. }
  21522. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21523. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  21524. v := m.updated_at
  21525. if v == nil {
  21526. return
  21527. }
  21528. return *v, true
  21529. }
  21530. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  21531. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21533. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21534. if !m.op.Is(OpUpdateOne) {
  21535. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21536. }
  21537. if m.id == nil || m.oldValue == nil {
  21538. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21539. }
  21540. oldValue, err := m.oldValue(ctx)
  21541. if err != nil {
  21542. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21543. }
  21544. return oldValue.UpdatedAt, nil
  21545. }
  21546. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21547. func (m *PayRechargeMutation) ResetUpdatedAt() {
  21548. m.updated_at = nil
  21549. }
  21550. // SetDeletedAt sets the "deleted_at" field.
  21551. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  21552. m.deleted_at = &t
  21553. }
  21554. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21555. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  21556. v := m.deleted_at
  21557. if v == nil {
  21558. return
  21559. }
  21560. return *v, true
  21561. }
  21562. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  21563. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21565. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21566. if !m.op.Is(OpUpdateOne) {
  21567. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21568. }
  21569. if m.id == nil || m.oldValue == nil {
  21570. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21571. }
  21572. oldValue, err := m.oldValue(ctx)
  21573. if err != nil {
  21574. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21575. }
  21576. return oldValue.DeletedAt, nil
  21577. }
  21578. // ClearDeletedAt clears the value of the "deleted_at" field.
  21579. func (m *PayRechargeMutation) ClearDeletedAt() {
  21580. m.deleted_at = nil
  21581. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  21582. }
  21583. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21584. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  21585. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  21586. return ok
  21587. }
  21588. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21589. func (m *PayRechargeMutation) ResetDeletedAt() {
  21590. m.deleted_at = nil
  21591. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  21592. }
  21593. // SetUserID sets the "user_id" field.
  21594. func (m *PayRechargeMutation) SetUserID(s string) {
  21595. m.user_id = &s
  21596. }
  21597. // UserID returns the value of the "user_id" field in the mutation.
  21598. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  21599. v := m.user_id
  21600. if v == nil {
  21601. return
  21602. }
  21603. return *v, true
  21604. }
  21605. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  21606. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21608. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  21609. if !m.op.Is(OpUpdateOne) {
  21610. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  21611. }
  21612. if m.id == nil || m.oldValue == nil {
  21613. return v, errors.New("OldUserID requires an ID field in the mutation")
  21614. }
  21615. oldValue, err := m.oldValue(ctx)
  21616. if err != nil {
  21617. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  21618. }
  21619. return oldValue.UserID, nil
  21620. }
  21621. // ResetUserID resets all changes to the "user_id" field.
  21622. func (m *PayRechargeMutation) ResetUserID() {
  21623. m.user_id = nil
  21624. }
  21625. // SetNumber sets the "number" field.
  21626. func (m *PayRechargeMutation) SetNumber(f float32) {
  21627. m.number = &f
  21628. m.addnumber = nil
  21629. }
  21630. // Number returns the value of the "number" field in the mutation.
  21631. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  21632. v := m.number
  21633. if v == nil {
  21634. return
  21635. }
  21636. return *v, true
  21637. }
  21638. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  21639. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21641. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  21642. if !m.op.Is(OpUpdateOne) {
  21643. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  21644. }
  21645. if m.id == nil || m.oldValue == nil {
  21646. return v, errors.New("OldNumber requires an ID field in the mutation")
  21647. }
  21648. oldValue, err := m.oldValue(ctx)
  21649. if err != nil {
  21650. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  21651. }
  21652. return oldValue.Number, nil
  21653. }
  21654. // AddNumber adds f to the "number" field.
  21655. func (m *PayRechargeMutation) AddNumber(f float32) {
  21656. if m.addnumber != nil {
  21657. *m.addnumber += f
  21658. } else {
  21659. m.addnumber = &f
  21660. }
  21661. }
  21662. // AddedNumber returns the value that was added to the "number" field in this mutation.
  21663. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  21664. v := m.addnumber
  21665. if v == nil {
  21666. return
  21667. }
  21668. return *v, true
  21669. }
  21670. // ResetNumber resets all changes to the "number" field.
  21671. func (m *PayRechargeMutation) ResetNumber() {
  21672. m.number = nil
  21673. m.addnumber = nil
  21674. }
  21675. // SetStatus sets the "status" field.
  21676. func (m *PayRechargeMutation) SetStatus(i int) {
  21677. m.status = &i
  21678. m.addstatus = nil
  21679. }
  21680. // Status returns the value of the "status" field in the mutation.
  21681. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  21682. v := m.status
  21683. if v == nil {
  21684. return
  21685. }
  21686. return *v, true
  21687. }
  21688. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  21689. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21691. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  21692. if !m.op.Is(OpUpdateOne) {
  21693. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21694. }
  21695. if m.id == nil || m.oldValue == nil {
  21696. return v, errors.New("OldStatus requires an ID field in the mutation")
  21697. }
  21698. oldValue, err := m.oldValue(ctx)
  21699. if err != nil {
  21700. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21701. }
  21702. return oldValue.Status, nil
  21703. }
  21704. // AddStatus adds i to the "status" field.
  21705. func (m *PayRechargeMutation) AddStatus(i int) {
  21706. if m.addstatus != nil {
  21707. *m.addstatus += i
  21708. } else {
  21709. m.addstatus = &i
  21710. }
  21711. }
  21712. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21713. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  21714. v := m.addstatus
  21715. if v == nil {
  21716. return
  21717. }
  21718. return *v, true
  21719. }
  21720. // ClearStatus clears the value of the "status" field.
  21721. func (m *PayRechargeMutation) ClearStatus() {
  21722. m.status = nil
  21723. m.addstatus = nil
  21724. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  21725. }
  21726. // StatusCleared returns if the "status" field was cleared in this mutation.
  21727. func (m *PayRechargeMutation) StatusCleared() bool {
  21728. _, ok := m.clearedFields[payrecharge.FieldStatus]
  21729. return ok
  21730. }
  21731. // ResetStatus resets all changes to the "status" field.
  21732. func (m *PayRechargeMutation) ResetStatus() {
  21733. m.status = nil
  21734. m.addstatus = nil
  21735. delete(m.clearedFields, payrecharge.FieldStatus)
  21736. }
  21737. // SetMoney sets the "money" field.
  21738. func (m *PayRechargeMutation) SetMoney(f float32) {
  21739. m.money = &f
  21740. m.addmoney = nil
  21741. }
  21742. // Money returns the value of the "money" field in the mutation.
  21743. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  21744. v := m.money
  21745. if v == nil {
  21746. return
  21747. }
  21748. return *v, true
  21749. }
  21750. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  21751. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21753. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  21754. if !m.op.Is(OpUpdateOne) {
  21755. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  21756. }
  21757. if m.id == nil || m.oldValue == nil {
  21758. return v, errors.New("OldMoney requires an ID field in the mutation")
  21759. }
  21760. oldValue, err := m.oldValue(ctx)
  21761. if err != nil {
  21762. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  21763. }
  21764. return oldValue.Money, nil
  21765. }
  21766. // AddMoney adds f to the "money" field.
  21767. func (m *PayRechargeMutation) AddMoney(f float32) {
  21768. if m.addmoney != nil {
  21769. *m.addmoney += f
  21770. } else {
  21771. m.addmoney = &f
  21772. }
  21773. }
  21774. // AddedMoney returns the value that was added to the "money" field in this mutation.
  21775. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  21776. v := m.addmoney
  21777. if v == nil {
  21778. return
  21779. }
  21780. return *v, true
  21781. }
  21782. // ClearMoney clears the value of the "money" field.
  21783. func (m *PayRechargeMutation) ClearMoney() {
  21784. m.money = nil
  21785. m.addmoney = nil
  21786. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  21787. }
  21788. // MoneyCleared returns if the "money" field was cleared in this mutation.
  21789. func (m *PayRechargeMutation) MoneyCleared() bool {
  21790. _, ok := m.clearedFields[payrecharge.FieldMoney]
  21791. return ok
  21792. }
  21793. // ResetMoney resets all changes to the "money" field.
  21794. func (m *PayRechargeMutation) ResetMoney() {
  21795. m.money = nil
  21796. m.addmoney = nil
  21797. delete(m.clearedFields, payrecharge.FieldMoney)
  21798. }
  21799. // SetOutTradeNo sets the "out_trade_no" field.
  21800. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  21801. m.out_trade_no = &s
  21802. }
  21803. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  21804. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  21805. v := m.out_trade_no
  21806. if v == nil {
  21807. return
  21808. }
  21809. return *v, true
  21810. }
  21811. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  21812. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21814. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  21815. if !m.op.Is(OpUpdateOne) {
  21816. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  21817. }
  21818. if m.id == nil || m.oldValue == nil {
  21819. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  21820. }
  21821. oldValue, err := m.oldValue(ctx)
  21822. if err != nil {
  21823. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  21824. }
  21825. return oldValue.OutTradeNo, nil
  21826. }
  21827. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  21828. func (m *PayRechargeMutation) ClearOutTradeNo() {
  21829. m.out_trade_no = nil
  21830. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  21831. }
  21832. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  21833. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  21834. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  21835. return ok
  21836. }
  21837. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  21838. func (m *PayRechargeMutation) ResetOutTradeNo() {
  21839. m.out_trade_no = nil
  21840. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  21841. }
  21842. // SetOrganizationID sets the "organization_id" field.
  21843. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  21844. m.organization_id = &u
  21845. m.addorganization_id = nil
  21846. }
  21847. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21848. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  21849. v := m.organization_id
  21850. if v == nil {
  21851. return
  21852. }
  21853. return *v, true
  21854. }
  21855. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  21856. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21858. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21859. if !m.op.Is(OpUpdateOne) {
  21860. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21861. }
  21862. if m.id == nil || m.oldValue == nil {
  21863. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21864. }
  21865. oldValue, err := m.oldValue(ctx)
  21866. if err != nil {
  21867. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21868. }
  21869. return oldValue.OrganizationID, nil
  21870. }
  21871. // AddOrganizationID adds u to the "organization_id" field.
  21872. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  21873. if m.addorganization_id != nil {
  21874. *m.addorganization_id += u
  21875. } else {
  21876. m.addorganization_id = &u
  21877. }
  21878. }
  21879. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21880. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  21881. v := m.addorganization_id
  21882. if v == nil {
  21883. return
  21884. }
  21885. return *v, true
  21886. }
  21887. // ResetOrganizationID resets all changes to the "organization_id" field.
  21888. func (m *PayRechargeMutation) ResetOrganizationID() {
  21889. m.organization_id = nil
  21890. m.addorganization_id = nil
  21891. }
  21892. // Where appends a list predicates to the PayRechargeMutation builder.
  21893. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  21894. m.predicates = append(m.predicates, ps...)
  21895. }
  21896. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  21897. // users can use type-assertion to append predicates that do not depend on any generated package.
  21898. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  21899. p := make([]predicate.PayRecharge, len(ps))
  21900. for i := range ps {
  21901. p[i] = ps[i]
  21902. }
  21903. m.Where(p...)
  21904. }
  21905. // Op returns the operation name.
  21906. func (m *PayRechargeMutation) Op() Op {
  21907. return m.op
  21908. }
  21909. // SetOp allows setting the mutation operation.
  21910. func (m *PayRechargeMutation) SetOp(op Op) {
  21911. m.op = op
  21912. }
  21913. // Type returns the node type of this mutation (PayRecharge).
  21914. func (m *PayRechargeMutation) Type() string {
  21915. return m.typ
  21916. }
  21917. // Fields returns all fields that were changed during this mutation. Note that in
  21918. // order to get all numeric fields that were incremented/decremented, call
  21919. // AddedFields().
  21920. func (m *PayRechargeMutation) Fields() []string {
  21921. fields := make([]string, 0, 9)
  21922. if m.created_at != nil {
  21923. fields = append(fields, payrecharge.FieldCreatedAt)
  21924. }
  21925. if m.updated_at != nil {
  21926. fields = append(fields, payrecharge.FieldUpdatedAt)
  21927. }
  21928. if m.deleted_at != nil {
  21929. fields = append(fields, payrecharge.FieldDeletedAt)
  21930. }
  21931. if m.user_id != nil {
  21932. fields = append(fields, payrecharge.FieldUserID)
  21933. }
  21934. if m.number != nil {
  21935. fields = append(fields, payrecharge.FieldNumber)
  21936. }
  21937. if m.status != nil {
  21938. fields = append(fields, payrecharge.FieldStatus)
  21939. }
  21940. if m.money != nil {
  21941. fields = append(fields, payrecharge.FieldMoney)
  21942. }
  21943. if m.out_trade_no != nil {
  21944. fields = append(fields, payrecharge.FieldOutTradeNo)
  21945. }
  21946. if m.organization_id != nil {
  21947. fields = append(fields, payrecharge.FieldOrganizationID)
  21948. }
  21949. return fields
  21950. }
  21951. // Field returns the value of a field with the given name. The second boolean
  21952. // return value indicates that this field was not set, or was not defined in the
  21953. // schema.
  21954. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  21955. switch name {
  21956. case payrecharge.FieldCreatedAt:
  21957. return m.CreatedAt()
  21958. case payrecharge.FieldUpdatedAt:
  21959. return m.UpdatedAt()
  21960. case payrecharge.FieldDeletedAt:
  21961. return m.DeletedAt()
  21962. case payrecharge.FieldUserID:
  21963. return m.UserID()
  21964. case payrecharge.FieldNumber:
  21965. return m.Number()
  21966. case payrecharge.FieldStatus:
  21967. return m.Status()
  21968. case payrecharge.FieldMoney:
  21969. return m.Money()
  21970. case payrecharge.FieldOutTradeNo:
  21971. return m.OutTradeNo()
  21972. case payrecharge.FieldOrganizationID:
  21973. return m.OrganizationID()
  21974. }
  21975. return nil, false
  21976. }
  21977. // OldField returns the old value of the field from the database. An error is
  21978. // returned if the mutation operation is not UpdateOne, or the query to the
  21979. // database failed.
  21980. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21981. switch name {
  21982. case payrecharge.FieldCreatedAt:
  21983. return m.OldCreatedAt(ctx)
  21984. case payrecharge.FieldUpdatedAt:
  21985. return m.OldUpdatedAt(ctx)
  21986. case payrecharge.FieldDeletedAt:
  21987. return m.OldDeletedAt(ctx)
  21988. case payrecharge.FieldUserID:
  21989. return m.OldUserID(ctx)
  21990. case payrecharge.FieldNumber:
  21991. return m.OldNumber(ctx)
  21992. case payrecharge.FieldStatus:
  21993. return m.OldStatus(ctx)
  21994. case payrecharge.FieldMoney:
  21995. return m.OldMoney(ctx)
  21996. case payrecharge.FieldOutTradeNo:
  21997. return m.OldOutTradeNo(ctx)
  21998. case payrecharge.FieldOrganizationID:
  21999. return m.OldOrganizationID(ctx)
  22000. }
  22001. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  22002. }
  22003. // SetField sets the value of a field with the given name. It returns an error if
  22004. // the field is not defined in the schema, or if the type mismatched the field
  22005. // type.
  22006. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  22007. switch name {
  22008. case payrecharge.FieldCreatedAt:
  22009. v, ok := value.(time.Time)
  22010. if !ok {
  22011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22012. }
  22013. m.SetCreatedAt(v)
  22014. return nil
  22015. case payrecharge.FieldUpdatedAt:
  22016. v, ok := value.(time.Time)
  22017. if !ok {
  22018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22019. }
  22020. m.SetUpdatedAt(v)
  22021. return nil
  22022. case payrecharge.FieldDeletedAt:
  22023. v, ok := value.(time.Time)
  22024. if !ok {
  22025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22026. }
  22027. m.SetDeletedAt(v)
  22028. return nil
  22029. case payrecharge.FieldUserID:
  22030. v, ok := value.(string)
  22031. if !ok {
  22032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22033. }
  22034. m.SetUserID(v)
  22035. return nil
  22036. case payrecharge.FieldNumber:
  22037. v, ok := value.(float32)
  22038. if !ok {
  22039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22040. }
  22041. m.SetNumber(v)
  22042. return nil
  22043. case payrecharge.FieldStatus:
  22044. v, ok := value.(int)
  22045. if !ok {
  22046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22047. }
  22048. m.SetStatus(v)
  22049. return nil
  22050. case payrecharge.FieldMoney:
  22051. v, ok := value.(float32)
  22052. if !ok {
  22053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22054. }
  22055. m.SetMoney(v)
  22056. return nil
  22057. case payrecharge.FieldOutTradeNo:
  22058. v, ok := value.(string)
  22059. if !ok {
  22060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22061. }
  22062. m.SetOutTradeNo(v)
  22063. return nil
  22064. case payrecharge.FieldOrganizationID:
  22065. v, ok := value.(uint64)
  22066. if !ok {
  22067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22068. }
  22069. m.SetOrganizationID(v)
  22070. return nil
  22071. }
  22072. return fmt.Errorf("unknown PayRecharge field %s", name)
  22073. }
  22074. // AddedFields returns all numeric fields that were incremented/decremented during
  22075. // this mutation.
  22076. func (m *PayRechargeMutation) AddedFields() []string {
  22077. var fields []string
  22078. if m.addnumber != nil {
  22079. fields = append(fields, payrecharge.FieldNumber)
  22080. }
  22081. if m.addstatus != nil {
  22082. fields = append(fields, payrecharge.FieldStatus)
  22083. }
  22084. if m.addmoney != nil {
  22085. fields = append(fields, payrecharge.FieldMoney)
  22086. }
  22087. if m.addorganization_id != nil {
  22088. fields = append(fields, payrecharge.FieldOrganizationID)
  22089. }
  22090. return fields
  22091. }
  22092. // AddedField returns the numeric value that was incremented/decremented on a field
  22093. // with the given name. The second boolean return value indicates that this field
  22094. // was not set, or was not defined in the schema.
  22095. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  22096. switch name {
  22097. case payrecharge.FieldNumber:
  22098. return m.AddedNumber()
  22099. case payrecharge.FieldStatus:
  22100. return m.AddedStatus()
  22101. case payrecharge.FieldMoney:
  22102. return m.AddedMoney()
  22103. case payrecharge.FieldOrganizationID:
  22104. return m.AddedOrganizationID()
  22105. }
  22106. return nil, false
  22107. }
  22108. // AddField adds the value to the field with the given name. It returns an error if
  22109. // the field is not defined in the schema, or if the type mismatched the field
  22110. // type.
  22111. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  22112. switch name {
  22113. case payrecharge.FieldNumber:
  22114. v, ok := value.(float32)
  22115. if !ok {
  22116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22117. }
  22118. m.AddNumber(v)
  22119. return nil
  22120. case payrecharge.FieldStatus:
  22121. v, ok := value.(int)
  22122. if !ok {
  22123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22124. }
  22125. m.AddStatus(v)
  22126. return nil
  22127. case payrecharge.FieldMoney:
  22128. v, ok := value.(float32)
  22129. if !ok {
  22130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22131. }
  22132. m.AddMoney(v)
  22133. return nil
  22134. case payrecharge.FieldOrganizationID:
  22135. v, ok := value.(int64)
  22136. if !ok {
  22137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22138. }
  22139. m.AddOrganizationID(v)
  22140. return nil
  22141. }
  22142. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  22143. }
  22144. // ClearedFields returns all nullable fields that were cleared during this
  22145. // mutation.
  22146. func (m *PayRechargeMutation) ClearedFields() []string {
  22147. var fields []string
  22148. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  22149. fields = append(fields, payrecharge.FieldDeletedAt)
  22150. }
  22151. if m.FieldCleared(payrecharge.FieldStatus) {
  22152. fields = append(fields, payrecharge.FieldStatus)
  22153. }
  22154. if m.FieldCleared(payrecharge.FieldMoney) {
  22155. fields = append(fields, payrecharge.FieldMoney)
  22156. }
  22157. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  22158. fields = append(fields, payrecharge.FieldOutTradeNo)
  22159. }
  22160. return fields
  22161. }
  22162. // FieldCleared returns a boolean indicating if a field with the given name was
  22163. // cleared in this mutation.
  22164. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  22165. _, ok := m.clearedFields[name]
  22166. return ok
  22167. }
  22168. // ClearField clears the value of the field with the given name. It returns an
  22169. // error if the field is not defined in the schema.
  22170. func (m *PayRechargeMutation) ClearField(name string) error {
  22171. switch name {
  22172. case payrecharge.FieldDeletedAt:
  22173. m.ClearDeletedAt()
  22174. return nil
  22175. case payrecharge.FieldStatus:
  22176. m.ClearStatus()
  22177. return nil
  22178. case payrecharge.FieldMoney:
  22179. m.ClearMoney()
  22180. return nil
  22181. case payrecharge.FieldOutTradeNo:
  22182. m.ClearOutTradeNo()
  22183. return nil
  22184. }
  22185. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  22186. }
  22187. // ResetField resets all changes in the mutation for the field with the given name.
  22188. // It returns an error if the field is not defined in the schema.
  22189. func (m *PayRechargeMutation) ResetField(name string) error {
  22190. switch name {
  22191. case payrecharge.FieldCreatedAt:
  22192. m.ResetCreatedAt()
  22193. return nil
  22194. case payrecharge.FieldUpdatedAt:
  22195. m.ResetUpdatedAt()
  22196. return nil
  22197. case payrecharge.FieldDeletedAt:
  22198. m.ResetDeletedAt()
  22199. return nil
  22200. case payrecharge.FieldUserID:
  22201. m.ResetUserID()
  22202. return nil
  22203. case payrecharge.FieldNumber:
  22204. m.ResetNumber()
  22205. return nil
  22206. case payrecharge.FieldStatus:
  22207. m.ResetStatus()
  22208. return nil
  22209. case payrecharge.FieldMoney:
  22210. m.ResetMoney()
  22211. return nil
  22212. case payrecharge.FieldOutTradeNo:
  22213. m.ResetOutTradeNo()
  22214. return nil
  22215. case payrecharge.FieldOrganizationID:
  22216. m.ResetOrganizationID()
  22217. return nil
  22218. }
  22219. return fmt.Errorf("unknown PayRecharge field %s", name)
  22220. }
  22221. // AddedEdges returns all edge names that were set/added in this mutation.
  22222. func (m *PayRechargeMutation) AddedEdges() []string {
  22223. edges := make([]string, 0, 0)
  22224. return edges
  22225. }
  22226. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22227. // name in this mutation.
  22228. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  22229. return nil
  22230. }
  22231. // RemovedEdges returns all edge names that were removed in this mutation.
  22232. func (m *PayRechargeMutation) RemovedEdges() []string {
  22233. edges := make([]string, 0, 0)
  22234. return edges
  22235. }
  22236. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22237. // the given name in this mutation.
  22238. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  22239. return nil
  22240. }
  22241. // ClearedEdges returns all edge names that were cleared in this mutation.
  22242. func (m *PayRechargeMutation) ClearedEdges() []string {
  22243. edges := make([]string, 0, 0)
  22244. return edges
  22245. }
  22246. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22247. // was cleared in this mutation.
  22248. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  22249. return false
  22250. }
  22251. // ClearEdge clears the value of the edge with the given name. It returns an error
  22252. // if that edge is not defined in the schema.
  22253. func (m *PayRechargeMutation) ClearEdge(name string) error {
  22254. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  22255. }
  22256. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22257. // It returns an error if the edge is not defined in the schema.
  22258. func (m *PayRechargeMutation) ResetEdge(name string) error {
  22259. return fmt.Errorf("unknown PayRecharge edge %s", name)
  22260. }
  22261. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  22262. type ServerMutation struct {
  22263. config
  22264. op Op
  22265. typ string
  22266. id *uint64
  22267. created_at *time.Time
  22268. updated_at *time.Time
  22269. status *uint8
  22270. addstatus *int8
  22271. deleted_at *time.Time
  22272. name *string
  22273. public_ip *string
  22274. private_ip *string
  22275. admin_port *string
  22276. clearedFields map[string]struct{}
  22277. wxs map[uint64]struct{}
  22278. removedwxs map[uint64]struct{}
  22279. clearedwxs bool
  22280. done bool
  22281. oldValue func(context.Context) (*Server, error)
  22282. predicates []predicate.Server
  22283. }
  22284. var _ ent.Mutation = (*ServerMutation)(nil)
  22285. // serverOption allows management of the mutation configuration using functional options.
  22286. type serverOption func(*ServerMutation)
  22287. // newServerMutation creates new mutation for the Server entity.
  22288. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  22289. m := &ServerMutation{
  22290. config: c,
  22291. op: op,
  22292. typ: TypeServer,
  22293. clearedFields: make(map[string]struct{}),
  22294. }
  22295. for _, opt := range opts {
  22296. opt(m)
  22297. }
  22298. return m
  22299. }
  22300. // withServerID sets the ID field of the mutation.
  22301. func withServerID(id uint64) serverOption {
  22302. return func(m *ServerMutation) {
  22303. var (
  22304. err error
  22305. once sync.Once
  22306. value *Server
  22307. )
  22308. m.oldValue = func(ctx context.Context) (*Server, error) {
  22309. once.Do(func() {
  22310. if m.done {
  22311. err = errors.New("querying old values post mutation is not allowed")
  22312. } else {
  22313. value, err = m.Client().Server.Get(ctx, id)
  22314. }
  22315. })
  22316. return value, err
  22317. }
  22318. m.id = &id
  22319. }
  22320. }
  22321. // withServer sets the old Server of the mutation.
  22322. func withServer(node *Server) serverOption {
  22323. return func(m *ServerMutation) {
  22324. m.oldValue = func(context.Context) (*Server, error) {
  22325. return node, nil
  22326. }
  22327. m.id = &node.ID
  22328. }
  22329. }
  22330. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22331. // executed in a transaction (ent.Tx), a transactional client is returned.
  22332. func (m ServerMutation) Client() *Client {
  22333. client := &Client{config: m.config}
  22334. client.init()
  22335. return client
  22336. }
  22337. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22338. // it returns an error otherwise.
  22339. func (m ServerMutation) Tx() (*Tx, error) {
  22340. if _, ok := m.driver.(*txDriver); !ok {
  22341. return nil, errors.New("ent: mutation is not running in a transaction")
  22342. }
  22343. tx := &Tx{config: m.config}
  22344. tx.init()
  22345. return tx, nil
  22346. }
  22347. // SetID sets the value of the id field. Note that this
  22348. // operation is only accepted on creation of Server entities.
  22349. func (m *ServerMutation) SetID(id uint64) {
  22350. m.id = &id
  22351. }
  22352. // ID returns the ID value in the mutation. Note that the ID is only available
  22353. // if it was provided to the builder or after it was returned from the database.
  22354. func (m *ServerMutation) ID() (id uint64, exists bool) {
  22355. if m.id == nil {
  22356. return
  22357. }
  22358. return *m.id, true
  22359. }
  22360. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22361. // That means, if the mutation is applied within a transaction with an isolation level such
  22362. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22363. // or updated by the mutation.
  22364. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  22365. switch {
  22366. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22367. id, exists := m.ID()
  22368. if exists {
  22369. return []uint64{id}, nil
  22370. }
  22371. fallthrough
  22372. case m.op.Is(OpUpdate | OpDelete):
  22373. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  22374. default:
  22375. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22376. }
  22377. }
  22378. // SetCreatedAt sets the "created_at" field.
  22379. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  22380. m.created_at = &t
  22381. }
  22382. // CreatedAt returns the value of the "created_at" field in the mutation.
  22383. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  22384. v := m.created_at
  22385. if v == nil {
  22386. return
  22387. }
  22388. return *v, true
  22389. }
  22390. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  22391. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22393. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22394. if !m.op.Is(OpUpdateOne) {
  22395. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22396. }
  22397. if m.id == nil || m.oldValue == nil {
  22398. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22399. }
  22400. oldValue, err := m.oldValue(ctx)
  22401. if err != nil {
  22402. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22403. }
  22404. return oldValue.CreatedAt, nil
  22405. }
  22406. // ResetCreatedAt resets all changes to the "created_at" field.
  22407. func (m *ServerMutation) ResetCreatedAt() {
  22408. m.created_at = nil
  22409. }
  22410. // SetUpdatedAt sets the "updated_at" field.
  22411. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  22412. m.updated_at = &t
  22413. }
  22414. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22415. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  22416. v := m.updated_at
  22417. if v == nil {
  22418. return
  22419. }
  22420. return *v, true
  22421. }
  22422. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  22423. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22425. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22426. if !m.op.Is(OpUpdateOne) {
  22427. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22428. }
  22429. if m.id == nil || m.oldValue == nil {
  22430. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22431. }
  22432. oldValue, err := m.oldValue(ctx)
  22433. if err != nil {
  22434. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22435. }
  22436. return oldValue.UpdatedAt, nil
  22437. }
  22438. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22439. func (m *ServerMutation) ResetUpdatedAt() {
  22440. m.updated_at = nil
  22441. }
  22442. // SetStatus sets the "status" field.
  22443. func (m *ServerMutation) SetStatus(u uint8) {
  22444. m.status = &u
  22445. m.addstatus = nil
  22446. }
  22447. // Status returns the value of the "status" field in the mutation.
  22448. func (m *ServerMutation) Status() (r uint8, exists bool) {
  22449. v := m.status
  22450. if v == nil {
  22451. return
  22452. }
  22453. return *v, true
  22454. }
  22455. // OldStatus returns the old "status" field's value of the Server entity.
  22456. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22458. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22459. if !m.op.Is(OpUpdateOne) {
  22460. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22461. }
  22462. if m.id == nil || m.oldValue == nil {
  22463. return v, errors.New("OldStatus requires an ID field in the mutation")
  22464. }
  22465. oldValue, err := m.oldValue(ctx)
  22466. if err != nil {
  22467. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22468. }
  22469. return oldValue.Status, nil
  22470. }
  22471. // AddStatus adds u to the "status" field.
  22472. func (m *ServerMutation) AddStatus(u int8) {
  22473. if m.addstatus != nil {
  22474. *m.addstatus += u
  22475. } else {
  22476. m.addstatus = &u
  22477. }
  22478. }
  22479. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22480. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  22481. v := m.addstatus
  22482. if v == nil {
  22483. return
  22484. }
  22485. return *v, true
  22486. }
  22487. // ClearStatus clears the value of the "status" field.
  22488. func (m *ServerMutation) ClearStatus() {
  22489. m.status = nil
  22490. m.addstatus = nil
  22491. m.clearedFields[server.FieldStatus] = struct{}{}
  22492. }
  22493. // StatusCleared returns if the "status" field was cleared in this mutation.
  22494. func (m *ServerMutation) StatusCleared() bool {
  22495. _, ok := m.clearedFields[server.FieldStatus]
  22496. return ok
  22497. }
  22498. // ResetStatus resets all changes to the "status" field.
  22499. func (m *ServerMutation) ResetStatus() {
  22500. m.status = nil
  22501. m.addstatus = nil
  22502. delete(m.clearedFields, server.FieldStatus)
  22503. }
  22504. // SetDeletedAt sets the "deleted_at" field.
  22505. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  22506. m.deleted_at = &t
  22507. }
  22508. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22509. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  22510. v := m.deleted_at
  22511. if v == nil {
  22512. return
  22513. }
  22514. return *v, true
  22515. }
  22516. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  22517. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22519. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22520. if !m.op.Is(OpUpdateOne) {
  22521. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22522. }
  22523. if m.id == nil || m.oldValue == nil {
  22524. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22525. }
  22526. oldValue, err := m.oldValue(ctx)
  22527. if err != nil {
  22528. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22529. }
  22530. return oldValue.DeletedAt, nil
  22531. }
  22532. // ClearDeletedAt clears the value of the "deleted_at" field.
  22533. func (m *ServerMutation) ClearDeletedAt() {
  22534. m.deleted_at = nil
  22535. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  22536. }
  22537. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22538. func (m *ServerMutation) DeletedAtCleared() bool {
  22539. _, ok := m.clearedFields[server.FieldDeletedAt]
  22540. return ok
  22541. }
  22542. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22543. func (m *ServerMutation) ResetDeletedAt() {
  22544. m.deleted_at = nil
  22545. delete(m.clearedFields, server.FieldDeletedAt)
  22546. }
  22547. // SetName sets the "name" field.
  22548. func (m *ServerMutation) SetName(s string) {
  22549. m.name = &s
  22550. }
  22551. // Name returns the value of the "name" field in the mutation.
  22552. func (m *ServerMutation) Name() (r string, exists bool) {
  22553. v := m.name
  22554. if v == nil {
  22555. return
  22556. }
  22557. return *v, true
  22558. }
  22559. // OldName returns the old "name" field's value of the Server entity.
  22560. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22562. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  22563. if !m.op.Is(OpUpdateOne) {
  22564. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22565. }
  22566. if m.id == nil || m.oldValue == nil {
  22567. return v, errors.New("OldName requires an ID field in the mutation")
  22568. }
  22569. oldValue, err := m.oldValue(ctx)
  22570. if err != nil {
  22571. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22572. }
  22573. return oldValue.Name, nil
  22574. }
  22575. // ResetName resets all changes to the "name" field.
  22576. func (m *ServerMutation) ResetName() {
  22577. m.name = nil
  22578. }
  22579. // SetPublicIP sets the "public_ip" field.
  22580. func (m *ServerMutation) SetPublicIP(s string) {
  22581. m.public_ip = &s
  22582. }
  22583. // PublicIP returns the value of the "public_ip" field in the mutation.
  22584. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  22585. v := m.public_ip
  22586. if v == nil {
  22587. return
  22588. }
  22589. return *v, true
  22590. }
  22591. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  22592. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22594. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  22595. if !m.op.Is(OpUpdateOne) {
  22596. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  22597. }
  22598. if m.id == nil || m.oldValue == nil {
  22599. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  22600. }
  22601. oldValue, err := m.oldValue(ctx)
  22602. if err != nil {
  22603. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  22604. }
  22605. return oldValue.PublicIP, nil
  22606. }
  22607. // ResetPublicIP resets all changes to the "public_ip" field.
  22608. func (m *ServerMutation) ResetPublicIP() {
  22609. m.public_ip = nil
  22610. }
  22611. // SetPrivateIP sets the "private_ip" field.
  22612. func (m *ServerMutation) SetPrivateIP(s string) {
  22613. m.private_ip = &s
  22614. }
  22615. // PrivateIP returns the value of the "private_ip" field in the mutation.
  22616. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  22617. v := m.private_ip
  22618. if v == nil {
  22619. return
  22620. }
  22621. return *v, true
  22622. }
  22623. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  22624. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22626. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  22627. if !m.op.Is(OpUpdateOne) {
  22628. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  22629. }
  22630. if m.id == nil || m.oldValue == nil {
  22631. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  22632. }
  22633. oldValue, err := m.oldValue(ctx)
  22634. if err != nil {
  22635. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  22636. }
  22637. return oldValue.PrivateIP, nil
  22638. }
  22639. // ResetPrivateIP resets all changes to the "private_ip" field.
  22640. func (m *ServerMutation) ResetPrivateIP() {
  22641. m.private_ip = nil
  22642. }
  22643. // SetAdminPort sets the "admin_port" field.
  22644. func (m *ServerMutation) SetAdminPort(s string) {
  22645. m.admin_port = &s
  22646. }
  22647. // AdminPort returns the value of the "admin_port" field in the mutation.
  22648. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  22649. v := m.admin_port
  22650. if v == nil {
  22651. return
  22652. }
  22653. return *v, true
  22654. }
  22655. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  22656. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22658. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  22659. if !m.op.Is(OpUpdateOne) {
  22660. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  22661. }
  22662. if m.id == nil || m.oldValue == nil {
  22663. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  22664. }
  22665. oldValue, err := m.oldValue(ctx)
  22666. if err != nil {
  22667. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  22668. }
  22669. return oldValue.AdminPort, nil
  22670. }
  22671. // ResetAdminPort resets all changes to the "admin_port" field.
  22672. func (m *ServerMutation) ResetAdminPort() {
  22673. m.admin_port = nil
  22674. }
  22675. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  22676. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  22677. if m.wxs == nil {
  22678. m.wxs = make(map[uint64]struct{})
  22679. }
  22680. for i := range ids {
  22681. m.wxs[ids[i]] = struct{}{}
  22682. }
  22683. }
  22684. // ClearWxs clears the "wxs" edge to the Wx entity.
  22685. func (m *ServerMutation) ClearWxs() {
  22686. m.clearedwxs = true
  22687. }
  22688. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  22689. func (m *ServerMutation) WxsCleared() bool {
  22690. return m.clearedwxs
  22691. }
  22692. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  22693. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  22694. if m.removedwxs == nil {
  22695. m.removedwxs = make(map[uint64]struct{})
  22696. }
  22697. for i := range ids {
  22698. delete(m.wxs, ids[i])
  22699. m.removedwxs[ids[i]] = struct{}{}
  22700. }
  22701. }
  22702. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  22703. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  22704. for id := range m.removedwxs {
  22705. ids = append(ids, id)
  22706. }
  22707. return
  22708. }
  22709. // WxsIDs returns the "wxs" edge IDs in the mutation.
  22710. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  22711. for id := range m.wxs {
  22712. ids = append(ids, id)
  22713. }
  22714. return
  22715. }
  22716. // ResetWxs resets all changes to the "wxs" edge.
  22717. func (m *ServerMutation) ResetWxs() {
  22718. m.wxs = nil
  22719. m.clearedwxs = false
  22720. m.removedwxs = nil
  22721. }
  22722. // Where appends a list predicates to the ServerMutation builder.
  22723. func (m *ServerMutation) Where(ps ...predicate.Server) {
  22724. m.predicates = append(m.predicates, ps...)
  22725. }
  22726. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  22727. // users can use type-assertion to append predicates that do not depend on any generated package.
  22728. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  22729. p := make([]predicate.Server, len(ps))
  22730. for i := range ps {
  22731. p[i] = ps[i]
  22732. }
  22733. m.Where(p...)
  22734. }
  22735. // Op returns the operation name.
  22736. func (m *ServerMutation) Op() Op {
  22737. return m.op
  22738. }
  22739. // SetOp allows setting the mutation operation.
  22740. func (m *ServerMutation) SetOp(op Op) {
  22741. m.op = op
  22742. }
  22743. // Type returns the node type of this mutation (Server).
  22744. func (m *ServerMutation) Type() string {
  22745. return m.typ
  22746. }
  22747. // Fields returns all fields that were changed during this mutation. Note that in
  22748. // order to get all numeric fields that were incremented/decremented, call
  22749. // AddedFields().
  22750. func (m *ServerMutation) Fields() []string {
  22751. fields := make([]string, 0, 8)
  22752. if m.created_at != nil {
  22753. fields = append(fields, server.FieldCreatedAt)
  22754. }
  22755. if m.updated_at != nil {
  22756. fields = append(fields, server.FieldUpdatedAt)
  22757. }
  22758. if m.status != nil {
  22759. fields = append(fields, server.FieldStatus)
  22760. }
  22761. if m.deleted_at != nil {
  22762. fields = append(fields, server.FieldDeletedAt)
  22763. }
  22764. if m.name != nil {
  22765. fields = append(fields, server.FieldName)
  22766. }
  22767. if m.public_ip != nil {
  22768. fields = append(fields, server.FieldPublicIP)
  22769. }
  22770. if m.private_ip != nil {
  22771. fields = append(fields, server.FieldPrivateIP)
  22772. }
  22773. if m.admin_port != nil {
  22774. fields = append(fields, server.FieldAdminPort)
  22775. }
  22776. return fields
  22777. }
  22778. // Field returns the value of a field with the given name. The second boolean
  22779. // return value indicates that this field was not set, or was not defined in the
  22780. // schema.
  22781. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  22782. switch name {
  22783. case server.FieldCreatedAt:
  22784. return m.CreatedAt()
  22785. case server.FieldUpdatedAt:
  22786. return m.UpdatedAt()
  22787. case server.FieldStatus:
  22788. return m.Status()
  22789. case server.FieldDeletedAt:
  22790. return m.DeletedAt()
  22791. case server.FieldName:
  22792. return m.Name()
  22793. case server.FieldPublicIP:
  22794. return m.PublicIP()
  22795. case server.FieldPrivateIP:
  22796. return m.PrivateIP()
  22797. case server.FieldAdminPort:
  22798. return m.AdminPort()
  22799. }
  22800. return nil, false
  22801. }
  22802. // OldField returns the old value of the field from the database. An error is
  22803. // returned if the mutation operation is not UpdateOne, or the query to the
  22804. // database failed.
  22805. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22806. switch name {
  22807. case server.FieldCreatedAt:
  22808. return m.OldCreatedAt(ctx)
  22809. case server.FieldUpdatedAt:
  22810. return m.OldUpdatedAt(ctx)
  22811. case server.FieldStatus:
  22812. return m.OldStatus(ctx)
  22813. case server.FieldDeletedAt:
  22814. return m.OldDeletedAt(ctx)
  22815. case server.FieldName:
  22816. return m.OldName(ctx)
  22817. case server.FieldPublicIP:
  22818. return m.OldPublicIP(ctx)
  22819. case server.FieldPrivateIP:
  22820. return m.OldPrivateIP(ctx)
  22821. case server.FieldAdminPort:
  22822. return m.OldAdminPort(ctx)
  22823. }
  22824. return nil, fmt.Errorf("unknown Server field %s", name)
  22825. }
  22826. // SetField sets the value of a field with the given name. It returns an error if
  22827. // the field is not defined in the schema, or if the type mismatched the field
  22828. // type.
  22829. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  22830. switch name {
  22831. case server.FieldCreatedAt:
  22832. v, ok := value.(time.Time)
  22833. if !ok {
  22834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22835. }
  22836. m.SetCreatedAt(v)
  22837. return nil
  22838. case server.FieldUpdatedAt:
  22839. v, ok := value.(time.Time)
  22840. if !ok {
  22841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22842. }
  22843. m.SetUpdatedAt(v)
  22844. return nil
  22845. case server.FieldStatus:
  22846. v, ok := value.(uint8)
  22847. if !ok {
  22848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22849. }
  22850. m.SetStatus(v)
  22851. return nil
  22852. case server.FieldDeletedAt:
  22853. v, ok := value.(time.Time)
  22854. if !ok {
  22855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22856. }
  22857. m.SetDeletedAt(v)
  22858. return nil
  22859. case server.FieldName:
  22860. v, ok := value.(string)
  22861. if !ok {
  22862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22863. }
  22864. m.SetName(v)
  22865. return nil
  22866. case server.FieldPublicIP:
  22867. v, ok := value.(string)
  22868. if !ok {
  22869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22870. }
  22871. m.SetPublicIP(v)
  22872. return nil
  22873. case server.FieldPrivateIP:
  22874. v, ok := value.(string)
  22875. if !ok {
  22876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22877. }
  22878. m.SetPrivateIP(v)
  22879. return nil
  22880. case server.FieldAdminPort:
  22881. v, ok := value.(string)
  22882. if !ok {
  22883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22884. }
  22885. m.SetAdminPort(v)
  22886. return nil
  22887. }
  22888. return fmt.Errorf("unknown Server field %s", name)
  22889. }
  22890. // AddedFields returns all numeric fields that were incremented/decremented during
  22891. // this mutation.
  22892. func (m *ServerMutation) AddedFields() []string {
  22893. var fields []string
  22894. if m.addstatus != nil {
  22895. fields = append(fields, server.FieldStatus)
  22896. }
  22897. return fields
  22898. }
  22899. // AddedField returns the numeric value that was incremented/decremented on a field
  22900. // with the given name. The second boolean return value indicates that this field
  22901. // was not set, or was not defined in the schema.
  22902. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  22903. switch name {
  22904. case server.FieldStatus:
  22905. return m.AddedStatus()
  22906. }
  22907. return nil, false
  22908. }
  22909. // AddField adds the value to the field with the given name. It returns an error if
  22910. // the field is not defined in the schema, or if the type mismatched the field
  22911. // type.
  22912. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  22913. switch name {
  22914. case server.FieldStatus:
  22915. v, ok := value.(int8)
  22916. if !ok {
  22917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22918. }
  22919. m.AddStatus(v)
  22920. return nil
  22921. }
  22922. return fmt.Errorf("unknown Server numeric field %s", name)
  22923. }
  22924. // ClearedFields returns all nullable fields that were cleared during this
  22925. // mutation.
  22926. func (m *ServerMutation) ClearedFields() []string {
  22927. var fields []string
  22928. if m.FieldCleared(server.FieldStatus) {
  22929. fields = append(fields, server.FieldStatus)
  22930. }
  22931. if m.FieldCleared(server.FieldDeletedAt) {
  22932. fields = append(fields, server.FieldDeletedAt)
  22933. }
  22934. return fields
  22935. }
  22936. // FieldCleared returns a boolean indicating if a field with the given name was
  22937. // cleared in this mutation.
  22938. func (m *ServerMutation) FieldCleared(name string) bool {
  22939. _, ok := m.clearedFields[name]
  22940. return ok
  22941. }
  22942. // ClearField clears the value of the field with the given name. It returns an
  22943. // error if the field is not defined in the schema.
  22944. func (m *ServerMutation) ClearField(name string) error {
  22945. switch name {
  22946. case server.FieldStatus:
  22947. m.ClearStatus()
  22948. return nil
  22949. case server.FieldDeletedAt:
  22950. m.ClearDeletedAt()
  22951. return nil
  22952. }
  22953. return fmt.Errorf("unknown Server nullable field %s", name)
  22954. }
  22955. // ResetField resets all changes in the mutation for the field with the given name.
  22956. // It returns an error if the field is not defined in the schema.
  22957. func (m *ServerMutation) ResetField(name string) error {
  22958. switch name {
  22959. case server.FieldCreatedAt:
  22960. m.ResetCreatedAt()
  22961. return nil
  22962. case server.FieldUpdatedAt:
  22963. m.ResetUpdatedAt()
  22964. return nil
  22965. case server.FieldStatus:
  22966. m.ResetStatus()
  22967. return nil
  22968. case server.FieldDeletedAt:
  22969. m.ResetDeletedAt()
  22970. return nil
  22971. case server.FieldName:
  22972. m.ResetName()
  22973. return nil
  22974. case server.FieldPublicIP:
  22975. m.ResetPublicIP()
  22976. return nil
  22977. case server.FieldPrivateIP:
  22978. m.ResetPrivateIP()
  22979. return nil
  22980. case server.FieldAdminPort:
  22981. m.ResetAdminPort()
  22982. return nil
  22983. }
  22984. return fmt.Errorf("unknown Server field %s", name)
  22985. }
  22986. // AddedEdges returns all edge names that were set/added in this mutation.
  22987. func (m *ServerMutation) AddedEdges() []string {
  22988. edges := make([]string, 0, 1)
  22989. if m.wxs != nil {
  22990. edges = append(edges, server.EdgeWxs)
  22991. }
  22992. return edges
  22993. }
  22994. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22995. // name in this mutation.
  22996. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  22997. switch name {
  22998. case server.EdgeWxs:
  22999. ids := make([]ent.Value, 0, len(m.wxs))
  23000. for id := range m.wxs {
  23001. ids = append(ids, id)
  23002. }
  23003. return ids
  23004. }
  23005. return nil
  23006. }
  23007. // RemovedEdges returns all edge names that were removed in this mutation.
  23008. func (m *ServerMutation) RemovedEdges() []string {
  23009. edges := make([]string, 0, 1)
  23010. if m.removedwxs != nil {
  23011. edges = append(edges, server.EdgeWxs)
  23012. }
  23013. return edges
  23014. }
  23015. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23016. // the given name in this mutation.
  23017. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  23018. switch name {
  23019. case server.EdgeWxs:
  23020. ids := make([]ent.Value, 0, len(m.removedwxs))
  23021. for id := range m.removedwxs {
  23022. ids = append(ids, id)
  23023. }
  23024. return ids
  23025. }
  23026. return nil
  23027. }
  23028. // ClearedEdges returns all edge names that were cleared in this mutation.
  23029. func (m *ServerMutation) ClearedEdges() []string {
  23030. edges := make([]string, 0, 1)
  23031. if m.clearedwxs {
  23032. edges = append(edges, server.EdgeWxs)
  23033. }
  23034. return edges
  23035. }
  23036. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23037. // was cleared in this mutation.
  23038. func (m *ServerMutation) EdgeCleared(name string) bool {
  23039. switch name {
  23040. case server.EdgeWxs:
  23041. return m.clearedwxs
  23042. }
  23043. return false
  23044. }
  23045. // ClearEdge clears the value of the edge with the given name. It returns an error
  23046. // if that edge is not defined in the schema.
  23047. func (m *ServerMutation) ClearEdge(name string) error {
  23048. switch name {
  23049. }
  23050. return fmt.Errorf("unknown Server unique edge %s", name)
  23051. }
  23052. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23053. // It returns an error if the edge is not defined in the schema.
  23054. func (m *ServerMutation) ResetEdge(name string) error {
  23055. switch name {
  23056. case server.EdgeWxs:
  23057. m.ResetWxs()
  23058. return nil
  23059. }
  23060. return fmt.Errorf("unknown Server edge %s", name)
  23061. }
  23062. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  23063. type SopNodeMutation struct {
  23064. config
  23065. op Op
  23066. typ string
  23067. id *uint64
  23068. created_at *time.Time
  23069. updated_at *time.Time
  23070. status *uint8
  23071. addstatus *int8
  23072. deleted_at *time.Time
  23073. parent_id *uint64
  23074. addparent_id *int64
  23075. name *string
  23076. condition_type *int
  23077. addcondition_type *int
  23078. condition_list *[]string
  23079. appendcondition_list []string
  23080. no_reply_condition *uint64
  23081. addno_reply_condition *int64
  23082. no_reply_unit *string
  23083. action_message *[]custom_types.Action
  23084. appendaction_message []custom_types.Action
  23085. action_label_add *[]uint64
  23086. appendaction_label_add []uint64
  23087. action_label_del *[]uint64
  23088. appendaction_label_del []uint64
  23089. action_forward **custom_types.ActionForward
  23090. clearedFields map[string]struct{}
  23091. sop_stage *uint64
  23092. clearedsop_stage bool
  23093. node_messages map[uint64]struct{}
  23094. removednode_messages map[uint64]struct{}
  23095. clearednode_messages bool
  23096. done bool
  23097. oldValue func(context.Context) (*SopNode, error)
  23098. predicates []predicate.SopNode
  23099. }
  23100. var _ ent.Mutation = (*SopNodeMutation)(nil)
  23101. // sopnodeOption allows management of the mutation configuration using functional options.
  23102. type sopnodeOption func(*SopNodeMutation)
  23103. // newSopNodeMutation creates new mutation for the SopNode entity.
  23104. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  23105. m := &SopNodeMutation{
  23106. config: c,
  23107. op: op,
  23108. typ: TypeSopNode,
  23109. clearedFields: make(map[string]struct{}),
  23110. }
  23111. for _, opt := range opts {
  23112. opt(m)
  23113. }
  23114. return m
  23115. }
  23116. // withSopNodeID sets the ID field of the mutation.
  23117. func withSopNodeID(id uint64) sopnodeOption {
  23118. return func(m *SopNodeMutation) {
  23119. var (
  23120. err error
  23121. once sync.Once
  23122. value *SopNode
  23123. )
  23124. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  23125. once.Do(func() {
  23126. if m.done {
  23127. err = errors.New("querying old values post mutation is not allowed")
  23128. } else {
  23129. value, err = m.Client().SopNode.Get(ctx, id)
  23130. }
  23131. })
  23132. return value, err
  23133. }
  23134. m.id = &id
  23135. }
  23136. }
  23137. // withSopNode sets the old SopNode of the mutation.
  23138. func withSopNode(node *SopNode) sopnodeOption {
  23139. return func(m *SopNodeMutation) {
  23140. m.oldValue = func(context.Context) (*SopNode, error) {
  23141. return node, nil
  23142. }
  23143. m.id = &node.ID
  23144. }
  23145. }
  23146. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23147. // executed in a transaction (ent.Tx), a transactional client is returned.
  23148. func (m SopNodeMutation) Client() *Client {
  23149. client := &Client{config: m.config}
  23150. client.init()
  23151. return client
  23152. }
  23153. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23154. // it returns an error otherwise.
  23155. func (m SopNodeMutation) Tx() (*Tx, error) {
  23156. if _, ok := m.driver.(*txDriver); !ok {
  23157. return nil, errors.New("ent: mutation is not running in a transaction")
  23158. }
  23159. tx := &Tx{config: m.config}
  23160. tx.init()
  23161. return tx, nil
  23162. }
  23163. // SetID sets the value of the id field. Note that this
  23164. // operation is only accepted on creation of SopNode entities.
  23165. func (m *SopNodeMutation) SetID(id uint64) {
  23166. m.id = &id
  23167. }
  23168. // ID returns the ID value in the mutation. Note that the ID is only available
  23169. // if it was provided to the builder or after it was returned from the database.
  23170. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  23171. if m.id == nil {
  23172. return
  23173. }
  23174. return *m.id, true
  23175. }
  23176. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23177. // That means, if the mutation is applied within a transaction with an isolation level such
  23178. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23179. // or updated by the mutation.
  23180. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  23181. switch {
  23182. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23183. id, exists := m.ID()
  23184. if exists {
  23185. return []uint64{id}, nil
  23186. }
  23187. fallthrough
  23188. case m.op.Is(OpUpdate | OpDelete):
  23189. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  23190. default:
  23191. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23192. }
  23193. }
  23194. // SetCreatedAt sets the "created_at" field.
  23195. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  23196. m.created_at = &t
  23197. }
  23198. // CreatedAt returns the value of the "created_at" field in the mutation.
  23199. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  23200. v := m.created_at
  23201. if v == nil {
  23202. return
  23203. }
  23204. return *v, true
  23205. }
  23206. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  23207. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23209. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23210. if !m.op.Is(OpUpdateOne) {
  23211. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23212. }
  23213. if m.id == nil || m.oldValue == nil {
  23214. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23215. }
  23216. oldValue, err := m.oldValue(ctx)
  23217. if err != nil {
  23218. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23219. }
  23220. return oldValue.CreatedAt, nil
  23221. }
  23222. // ResetCreatedAt resets all changes to the "created_at" field.
  23223. func (m *SopNodeMutation) ResetCreatedAt() {
  23224. m.created_at = nil
  23225. }
  23226. // SetUpdatedAt sets the "updated_at" field.
  23227. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  23228. m.updated_at = &t
  23229. }
  23230. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23231. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  23232. v := m.updated_at
  23233. if v == nil {
  23234. return
  23235. }
  23236. return *v, true
  23237. }
  23238. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  23239. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23241. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23242. if !m.op.Is(OpUpdateOne) {
  23243. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23244. }
  23245. if m.id == nil || m.oldValue == nil {
  23246. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23247. }
  23248. oldValue, err := m.oldValue(ctx)
  23249. if err != nil {
  23250. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23251. }
  23252. return oldValue.UpdatedAt, nil
  23253. }
  23254. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23255. func (m *SopNodeMutation) ResetUpdatedAt() {
  23256. m.updated_at = nil
  23257. }
  23258. // SetStatus sets the "status" field.
  23259. func (m *SopNodeMutation) SetStatus(u uint8) {
  23260. m.status = &u
  23261. m.addstatus = nil
  23262. }
  23263. // Status returns the value of the "status" field in the mutation.
  23264. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  23265. v := m.status
  23266. if v == nil {
  23267. return
  23268. }
  23269. return *v, true
  23270. }
  23271. // OldStatus returns the old "status" field's value of the SopNode entity.
  23272. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23274. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23275. if !m.op.Is(OpUpdateOne) {
  23276. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23277. }
  23278. if m.id == nil || m.oldValue == nil {
  23279. return v, errors.New("OldStatus requires an ID field in the mutation")
  23280. }
  23281. oldValue, err := m.oldValue(ctx)
  23282. if err != nil {
  23283. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23284. }
  23285. return oldValue.Status, nil
  23286. }
  23287. // AddStatus adds u to the "status" field.
  23288. func (m *SopNodeMutation) AddStatus(u int8) {
  23289. if m.addstatus != nil {
  23290. *m.addstatus += u
  23291. } else {
  23292. m.addstatus = &u
  23293. }
  23294. }
  23295. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23296. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  23297. v := m.addstatus
  23298. if v == nil {
  23299. return
  23300. }
  23301. return *v, true
  23302. }
  23303. // ClearStatus clears the value of the "status" field.
  23304. func (m *SopNodeMutation) ClearStatus() {
  23305. m.status = nil
  23306. m.addstatus = nil
  23307. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  23308. }
  23309. // StatusCleared returns if the "status" field was cleared in this mutation.
  23310. func (m *SopNodeMutation) StatusCleared() bool {
  23311. _, ok := m.clearedFields[sopnode.FieldStatus]
  23312. return ok
  23313. }
  23314. // ResetStatus resets all changes to the "status" field.
  23315. func (m *SopNodeMutation) ResetStatus() {
  23316. m.status = nil
  23317. m.addstatus = nil
  23318. delete(m.clearedFields, sopnode.FieldStatus)
  23319. }
  23320. // SetDeletedAt sets the "deleted_at" field.
  23321. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  23322. m.deleted_at = &t
  23323. }
  23324. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23325. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  23326. v := m.deleted_at
  23327. if v == nil {
  23328. return
  23329. }
  23330. return *v, true
  23331. }
  23332. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  23333. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23335. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23336. if !m.op.Is(OpUpdateOne) {
  23337. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23338. }
  23339. if m.id == nil || m.oldValue == nil {
  23340. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23341. }
  23342. oldValue, err := m.oldValue(ctx)
  23343. if err != nil {
  23344. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23345. }
  23346. return oldValue.DeletedAt, nil
  23347. }
  23348. // ClearDeletedAt clears the value of the "deleted_at" field.
  23349. func (m *SopNodeMutation) ClearDeletedAt() {
  23350. m.deleted_at = nil
  23351. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  23352. }
  23353. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23354. func (m *SopNodeMutation) DeletedAtCleared() bool {
  23355. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  23356. return ok
  23357. }
  23358. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23359. func (m *SopNodeMutation) ResetDeletedAt() {
  23360. m.deleted_at = nil
  23361. delete(m.clearedFields, sopnode.FieldDeletedAt)
  23362. }
  23363. // SetStageID sets the "stage_id" field.
  23364. func (m *SopNodeMutation) SetStageID(u uint64) {
  23365. m.sop_stage = &u
  23366. }
  23367. // StageID returns the value of the "stage_id" field in the mutation.
  23368. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  23369. v := m.sop_stage
  23370. if v == nil {
  23371. return
  23372. }
  23373. return *v, true
  23374. }
  23375. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  23376. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23378. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  23379. if !m.op.Is(OpUpdateOne) {
  23380. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  23381. }
  23382. if m.id == nil || m.oldValue == nil {
  23383. return v, errors.New("OldStageID requires an ID field in the mutation")
  23384. }
  23385. oldValue, err := m.oldValue(ctx)
  23386. if err != nil {
  23387. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  23388. }
  23389. return oldValue.StageID, nil
  23390. }
  23391. // ResetStageID resets all changes to the "stage_id" field.
  23392. func (m *SopNodeMutation) ResetStageID() {
  23393. m.sop_stage = nil
  23394. }
  23395. // SetParentID sets the "parent_id" field.
  23396. func (m *SopNodeMutation) SetParentID(u uint64) {
  23397. m.parent_id = &u
  23398. m.addparent_id = nil
  23399. }
  23400. // ParentID returns the value of the "parent_id" field in the mutation.
  23401. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  23402. v := m.parent_id
  23403. if v == nil {
  23404. return
  23405. }
  23406. return *v, true
  23407. }
  23408. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  23409. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23411. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  23412. if !m.op.Is(OpUpdateOne) {
  23413. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  23414. }
  23415. if m.id == nil || m.oldValue == nil {
  23416. return v, errors.New("OldParentID requires an ID field in the mutation")
  23417. }
  23418. oldValue, err := m.oldValue(ctx)
  23419. if err != nil {
  23420. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  23421. }
  23422. return oldValue.ParentID, nil
  23423. }
  23424. // AddParentID adds u to the "parent_id" field.
  23425. func (m *SopNodeMutation) AddParentID(u int64) {
  23426. if m.addparent_id != nil {
  23427. *m.addparent_id += u
  23428. } else {
  23429. m.addparent_id = &u
  23430. }
  23431. }
  23432. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  23433. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  23434. v := m.addparent_id
  23435. if v == nil {
  23436. return
  23437. }
  23438. return *v, true
  23439. }
  23440. // ResetParentID resets all changes to the "parent_id" field.
  23441. func (m *SopNodeMutation) ResetParentID() {
  23442. m.parent_id = nil
  23443. m.addparent_id = nil
  23444. }
  23445. // SetName sets the "name" field.
  23446. func (m *SopNodeMutation) SetName(s string) {
  23447. m.name = &s
  23448. }
  23449. // Name returns the value of the "name" field in the mutation.
  23450. func (m *SopNodeMutation) Name() (r string, exists bool) {
  23451. v := m.name
  23452. if v == nil {
  23453. return
  23454. }
  23455. return *v, true
  23456. }
  23457. // OldName returns the old "name" field's value of the SopNode entity.
  23458. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23460. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  23461. if !m.op.Is(OpUpdateOne) {
  23462. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23463. }
  23464. if m.id == nil || m.oldValue == nil {
  23465. return v, errors.New("OldName requires an ID field in the mutation")
  23466. }
  23467. oldValue, err := m.oldValue(ctx)
  23468. if err != nil {
  23469. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23470. }
  23471. return oldValue.Name, nil
  23472. }
  23473. // ResetName resets all changes to the "name" field.
  23474. func (m *SopNodeMutation) ResetName() {
  23475. m.name = nil
  23476. }
  23477. // SetConditionType sets the "condition_type" field.
  23478. func (m *SopNodeMutation) SetConditionType(i int) {
  23479. m.condition_type = &i
  23480. m.addcondition_type = nil
  23481. }
  23482. // ConditionType returns the value of the "condition_type" field in the mutation.
  23483. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  23484. v := m.condition_type
  23485. if v == nil {
  23486. return
  23487. }
  23488. return *v, true
  23489. }
  23490. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  23491. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23493. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23494. if !m.op.Is(OpUpdateOne) {
  23495. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23496. }
  23497. if m.id == nil || m.oldValue == nil {
  23498. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23499. }
  23500. oldValue, err := m.oldValue(ctx)
  23501. if err != nil {
  23502. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23503. }
  23504. return oldValue.ConditionType, nil
  23505. }
  23506. // AddConditionType adds i to the "condition_type" field.
  23507. func (m *SopNodeMutation) AddConditionType(i int) {
  23508. if m.addcondition_type != nil {
  23509. *m.addcondition_type += i
  23510. } else {
  23511. m.addcondition_type = &i
  23512. }
  23513. }
  23514. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23515. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  23516. v := m.addcondition_type
  23517. if v == nil {
  23518. return
  23519. }
  23520. return *v, true
  23521. }
  23522. // ResetConditionType resets all changes to the "condition_type" field.
  23523. func (m *SopNodeMutation) ResetConditionType() {
  23524. m.condition_type = nil
  23525. m.addcondition_type = nil
  23526. }
  23527. // SetConditionList sets the "condition_list" field.
  23528. func (m *SopNodeMutation) SetConditionList(s []string) {
  23529. m.condition_list = &s
  23530. m.appendcondition_list = nil
  23531. }
  23532. // ConditionList returns the value of the "condition_list" field in the mutation.
  23533. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  23534. v := m.condition_list
  23535. if v == nil {
  23536. return
  23537. }
  23538. return *v, true
  23539. }
  23540. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  23541. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23543. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  23544. if !m.op.Is(OpUpdateOne) {
  23545. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23546. }
  23547. if m.id == nil || m.oldValue == nil {
  23548. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23549. }
  23550. oldValue, err := m.oldValue(ctx)
  23551. if err != nil {
  23552. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23553. }
  23554. return oldValue.ConditionList, nil
  23555. }
  23556. // AppendConditionList adds s to the "condition_list" field.
  23557. func (m *SopNodeMutation) AppendConditionList(s []string) {
  23558. m.appendcondition_list = append(m.appendcondition_list, s...)
  23559. }
  23560. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23561. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  23562. if len(m.appendcondition_list) == 0 {
  23563. return nil, false
  23564. }
  23565. return m.appendcondition_list, true
  23566. }
  23567. // ClearConditionList clears the value of the "condition_list" field.
  23568. func (m *SopNodeMutation) ClearConditionList() {
  23569. m.condition_list = nil
  23570. m.appendcondition_list = nil
  23571. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  23572. }
  23573. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  23574. func (m *SopNodeMutation) ConditionListCleared() bool {
  23575. _, ok := m.clearedFields[sopnode.FieldConditionList]
  23576. return ok
  23577. }
  23578. // ResetConditionList resets all changes to the "condition_list" field.
  23579. func (m *SopNodeMutation) ResetConditionList() {
  23580. m.condition_list = nil
  23581. m.appendcondition_list = nil
  23582. delete(m.clearedFields, sopnode.FieldConditionList)
  23583. }
  23584. // SetNoReplyCondition sets the "no_reply_condition" field.
  23585. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  23586. m.no_reply_condition = &u
  23587. m.addno_reply_condition = nil
  23588. }
  23589. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  23590. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  23591. v := m.no_reply_condition
  23592. if v == nil {
  23593. return
  23594. }
  23595. return *v, true
  23596. }
  23597. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  23598. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23600. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  23601. if !m.op.Is(OpUpdateOne) {
  23602. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  23603. }
  23604. if m.id == nil || m.oldValue == nil {
  23605. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  23606. }
  23607. oldValue, err := m.oldValue(ctx)
  23608. if err != nil {
  23609. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  23610. }
  23611. return oldValue.NoReplyCondition, nil
  23612. }
  23613. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  23614. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  23615. if m.addno_reply_condition != nil {
  23616. *m.addno_reply_condition += u
  23617. } else {
  23618. m.addno_reply_condition = &u
  23619. }
  23620. }
  23621. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  23622. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  23623. v := m.addno_reply_condition
  23624. if v == nil {
  23625. return
  23626. }
  23627. return *v, true
  23628. }
  23629. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  23630. func (m *SopNodeMutation) ResetNoReplyCondition() {
  23631. m.no_reply_condition = nil
  23632. m.addno_reply_condition = nil
  23633. }
  23634. // SetNoReplyUnit sets the "no_reply_unit" field.
  23635. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  23636. m.no_reply_unit = &s
  23637. }
  23638. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  23639. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  23640. v := m.no_reply_unit
  23641. if v == nil {
  23642. return
  23643. }
  23644. return *v, true
  23645. }
  23646. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  23647. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23649. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  23650. if !m.op.Is(OpUpdateOne) {
  23651. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  23652. }
  23653. if m.id == nil || m.oldValue == nil {
  23654. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  23655. }
  23656. oldValue, err := m.oldValue(ctx)
  23657. if err != nil {
  23658. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  23659. }
  23660. return oldValue.NoReplyUnit, nil
  23661. }
  23662. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  23663. func (m *SopNodeMutation) ResetNoReplyUnit() {
  23664. m.no_reply_unit = nil
  23665. }
  23666. // SetActionMessage sets the "action_message" field.
  23667. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  23668. m.action_message = &ct
  23669. m.appendaction_message = nil
  23670. }
  23671. // ActionMessage returns the value of the "action_message" field in the mutation.
  23672. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23673. v := m.action_message
  23674. if v == nil {
  23675. return
  23676. }
  23677. return *v, true
  23678. }
  23679. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  23680. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23682. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23683. if !m.op.Is(OpUpdateOne) {
  23684. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23685. }
  23686. if m.id == nil || m.oldValue == nil {
  23687. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23688. }
  23689. oldValue, err := m.oldValue(ctx)
  23690. if err != nil {
  23691. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23692. }
  23693. return oldValue.ActionMessage, nil
  23694. }
  23695. // AppendActionMessage adds ct to the "action_message" field.
  23696. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  23697. m.appendaction_message = append(m.appendaction_message, ct...)
  23698. }
  23699. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23700. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23701. if len(m.appendaction_message) == 0 {
  23702. return nil, false
  23703. }
  23704. return m.appendaction_message, true
  23705. }
  23706. // ClearActionMessage clears the value of the "action_message" field.
  23707. func (m *SopNodeMutation) ClearActionMessage() {
  23708. m.action_message = nil
  23709. m.appendaction_message = nil
  23710. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  23711. }
  23712. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  23713. func (m *SopNodeMutation) ActionMessageCleared() bool {
  23714. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  23715. return ok
  23716. }
  23717. // ResetActionMessage resets all changes to the "action_message" field.
  23718. func (m *SopNodeMutation) ResetActionMessage() {
  23719. m.action_message = nil
  23720. m.appendaction_message = nil
  23721. delete(m.clearedFields, sopnode.FieldActionMessage)
  23722. }
  23723. // SetActionLabelAdd sets the "action_label_add" field.
  23724. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  23725. m.action_label_add = &u
  23726. m.appendaction_label_add = nil
  23727. }
  23728. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23729. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23730. v := m.action_label_add
  23731. if v == nil {
  23732. return
  23733. }
  23734. return *v, true
  23735. }
  23736. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  23737. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23739. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23740. if !m.op.Is(OpUpdateOne) {
  23741. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23742. }
  23743. if m.id == nil || m.oldValue == nil {
  23744. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23745. }
  23746. oldValue, err := m.oldValue(ctx)
  23747. if err != nil {
  23748. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23749. }
  23750. return oldValue.ActionLabelAdd, nil
  23751. }
  23752. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23753. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  23754. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23755. }
  23756. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23757. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23758. if len(m.appendaction_label_add) == 0 {
  23759. return nil, false
  23760. }
  23761. return m.appendaction_label_add, true
  23762. }
  23763. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23764. func (m *SopNodeMutation) ClearActionLabelAdd() {
  23765. m.action_label_add = nil
  23766. m.appendaction_label_add = nil
  23767. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  23768. }
  23769. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23770. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  23771. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  23772. return ok
  23773. }
  23774. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23775. func (m *SopNodeMutation) ResetActionLabelAdd() {
  23776. m.action_label_add = nil
  23777. m.appendaction_label_add = nil
  23778. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  23779. }
  23780. // SetActionLabelDel sets the "action_label_del" field.
  23781. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  23782. m.action_label_del = &u
  23783. m.appendaction_label_del = nil
  23784. }
  23785. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23786. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  23787. v := m.action_label_del
  23788. if v == nil {
  23789. return
  23790. }
  23791. return *v, true
  23792. }
  23793. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  23794. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23796. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23797. if !m.op.Is(OpUpdateOne) {
  23798. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23799. }
  23800. if m.id == nil || m.oldValue == nil {
  23801. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23802. }
  23803. oldValue, err := m.oldValue(ctx)
  23804. if err != nil {
  23805. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23806. }
  23807. return oldValue.ActionLabelDel, nil
  23808. }
  23809. // AppendActionLabelDel adds u to the "action_label_del" field.
  23810. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  23811. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23812. }
  23813. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23814. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23815. if len(m.appendaction_label_del) == 0 {
  23816. return nil, false
  23817. }
  23818. return m.appendaction_label_del, true
  23819. }
  23820. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23821. func (m *SopNodeMutation) ClearActionLabelDel() {
  23822. m.action_label_del = nil
  23823. m.appendaction_label_del = nil
  23824. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  23825. }
  23826. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23827. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  23828. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  23829. return ok
  23830. }
  23831. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23832. func (m *SopNodeMutation) ResetActionLabelDel() {
  23833. m.action_label_del = nil
  23834. m.appendaction_label_del = nil
  23835. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  23836. }
  23837. // SetActionForward sets the "action_forward" field.
  23838. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  23839. m.action_forward = &ctf
  23840. }
  23841. // ActionForward returns the value of the "action_forward" field in the mutation.
  23842. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  23843. v := m.action_forward
  23844. if v == nil {
  23845. return
  23846. }
  23847. return *v, true
  23848. }
  23849. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  23850. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23852. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  23853. if !m.op.Is(OpUpdateOne) {
  23854. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  23855. }
  23856. if m.id == nil || m.oldValue == nil {
  23857. return v, errors.New("OldActionForward requires an ID field in the mutation")
  23858. }
  23859. oldValue, err := m.oldValue(ctx)
  23860. if err != nil {
  23861. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  23862. }
  23863. return oldValue.ActionForward, nil
  23864. }
  23865. // ClearActionForward clears the value of the "action_forward" field.
  23866. func (m *SopNodeMutation) ClearActionForward() {
  23867. m.action_forward = nil
  23868. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  23869. }
  23870. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  23871. func (m *SopNodeMutation) ActionForwardCleared() bool {
  23872. _, ok := m.clearedFields[sopnode.FieldActionForward]
  23873. return ok
  23874. }
  23875. // ResetActionForward resets all changes to the "action_forward" field.
  23876. func (m *SopNodeMutation) ResetActionForward() {
  23877. m.action_forward = nil
  23878. delete(m.clearedFields, sopnode.FieldActionForward)
  23879. }
  23880. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  23881. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  23882. m.sop_stage = &id
  23883. }
  23884. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  23885. func (m *SopNodeMutation) ClearSopStage() {
  23886. m.clearedsop_stage = true
  23887. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  23888. }
  23889. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  23890. func (m *SopNodeMutation) SopStageCleared() bool {
  23891. return m.clearedsop_stage
  23892. }
  23893. // SopStageID returns the "sop_stage" edge ID in the mutation.
  23894. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  23895. if m.sop_stage != nil {
  23896. return *m.sop_stage, true
  23897. }
  23898. return
  23899. }
  23900. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  23901. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23902. // SopStageID instead. It exists only for internal usage by the builders.
  23903. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  23904. if id := m.sop_stage; id != nil {
  23905. ids = append(ids, *id)
  23906. }
  23907. return
  23908. }
  23909. // ResetSopStage resets all changes to the "sop_stage" edge.
  23910. func (m *SopNodeMutation) ResetSopStage() {
  23911. m.sop_stage = nil
  23912. m.clearedsop_stage = false
  23913. }
  23914. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  23915. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  23916. if m.node_messages == nil {
  23917. m.node_messages = make(map[uint64]struct{})
  23918. }
  23919. for i := range ids {
  23920. m.node_messages[ids[i]] = struct{}{}
  23921. }
  23922. }
  23923. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  23924. func (m *SopNodeMutation) ClearNodeMessages() {
  23925. m.clearednode_messages = true
  23926. }
  23927. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  23928. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  23929. return m.clearednode_messages
  23930. }
  23931. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  23932. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  23933. if m.removednode_messages == nil {
  23934. m.removednode_messages = make(map[uint64]struct{})
  23935. }
  23936. for i := range ids {
  23937. delete(m.node_messages, ids[i])
  23938. m.removednode_messages[ids[i]] = struct{}{}
  23939. }
  23940. }
  23941. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  23942. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  23943. for id := range m.removednode_messages {
  23944. ids = append(ids, id)
  23945. }
  23946. return
  23947. }
  23948. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  23949. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  23950. for id := range m.node_messages {
  23951. ids = append(ids, id)
  23952. }
  23953. return
  23954. }
  23955. // ResetNodeMessages resets all changes to the "node_messages" edge.
  23956. func (m *SopNodeMutation) ResetNodeMessages() {
  23957. m.node_messages = nil
  23958. m.clearednode_messages = false
  23959. m.removednode_messages = nil
  23960. }
  23961. // Where appends a list predicates to the SopNodeMutation builder.
  23962. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  23963. m.predicates = append(m.predicates, ps...)
  23964. }
  23965. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  23966. // users can use type-assertion to append predicates that do not depend on any generated package.
  23967. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  23968. p := make([]predicate.SopNode, len(ps))
  23969. for i := range ps {
  23970. p[i] = ps[i]
  23971. }
  23972. m.Where(p...)
  23973. }
  23974. // Op returns the operation name.
  23975. func (m *SopNodeMutation) Op() Op {
  23976. return m.op
  23977. }
  23978. // SetOp allows setting the mutation operation.
  23979. func (m *SopNodeMutation) SetOp(op Op) {
  23980. m.op = op
  23981. }
  23982. // Type returns the node type of this mutation (SopNode).
  23983. func (m *SopNodeMutation) Type() string {
  23984. return m.typ
  23985. }
  23986. // Fields returns all fields that were changed during this mutation. Note that in
  23987. // order to get all numeric fields that were incremented/decremented, call
  23988. // AddedFields().
  23989. func (m *SopNodeMutation) Fields() []string {
  23990. fields := make([]string, 0, 15)
  23991. if m.created_at != nil {
  23992. fields = append(fields, sopnode.FieldCreatedAt)
  23993. }
  23994. if m.updated_at != nil {
  23995. fields = append(fields, sopnode.FieldUpdatedAt)
  23996. }
  23997. if m.status != nil {
  23998. fields = append(fields, sopnode.FieldStatus)
  23999. }
  24000. if m.deleted_at != nil {
  24001. fields = append(fields, sopnode.FieldDeletedAt)
  24002. }
  24003. if m.sop_stage != nil {
  24004. fields = append(fields, sopnode.FieldStageID)
  24005. }
  24006. if m.parent_id != nil {
  24007. fields = append(fields, sopnode.FieldParentID)
  24008. }
  24009. if m.name != nil {
  24010. fields = append(fields, sopnode.FieldName)
  24011. }
  24012. if m.condition_type != nil {
  24013. fields = append(fields, sopnode.FieldConditionType)
  24014. }
  24015. if m.condition_list != nil {
  24016. fields = append(fields, sopnode.FieldConditionList)
  24017. }
  24018. if m.no_reply_condition != nil {
  24019. fields = append(fields, sopnode.FieldNoReplyCondition)
  24020. }
  24021. if m.no_reply_unit != nil {
  24022. fields = append(fields, sopnode.FieldNoReplyUnit)
  24023. }
  24024. if m.action_message != nil {
  24025. fields = append(fields, sopnode.FieldActionMessage)
  24026. }
  24027. if m.action_label_add != nil {
  24028. fields = append(fields, sopnode.FieldActionLabelAdd)
  24029. }
  24030. if m.action_label_del != nil {
  24031. fields = append(fields, sopnode.FieldActionLabelDel)
  24032. }
  24033. if m.action_forward != nil {
  24034. fields = append(fields, sopnode.FieldActionForward)
  24035. }
  24036. return fields
  24037. }
  24038. // Field returns the value of a field with the given name. The second boolean
  24039. // return value indicates that this field was not set, or was not defined in the
  24040. // schema.
  24041. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  24042. switch name {
  24043. case sopnode.FieldCreatedAt:
  24044. return m.CreatedAt()
  24045. case sopnode.FieldUpdatedAt:
  24046. return m.UpdatedAt()
  24047. case sopnode.FieldStatus:
  24048. return m.Status()
  24049. case sopnode.FieldDeletedAt:
  24050. return m.DeletedAt()
  24051. case sopnode.FieldStageID:
  24052. return m.StageID()
  24053. case sopnode.FieldParentID:
  24054. return m.ParentID()
  24055. case sopnode.FieldName:
  24056. return m.Name()
  24057. case sopnode.FieldConditionType:
  24058. return m.ConditionType()
  24059. case sopnode.FieldConditionList:
  24060. return m.ConditionList()
  24061. case sopnode.FieldNoReplyCondition:
  24062. return m.NoReplyCondition()
  24063. case sopnode.FieldNoReplyUnit:
  24064. return m.NoReplyUnit()
  24065. case sopnode.FieldActionMessage:
  24066. return m.ActionMessage()
  24067. case sopnode.FieldActionLabelAdd:
  24068. return m.ActionLabelAdd()
  24069. case sopnode.FieldActionLabelDel:
  24070. return m.ActionLabelDel()
  24071. case sopnode.FieldActionForward:
  24072. return m.ActionForward()
  24073. }
  24074. return nil, false
  24075. }
  24076. // OldField returns the old value of the field from the database. An error is
  24077. // returned if the mutation operation is not UpdateOne, or the query to the
  24078. // database failed.
  24079. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24080. switch name {
  24081. case sopnode.FieldCreatedAt:
  24082. return m.OldCreatedAt(ctx)
  24083. case sopnode.FieldUpdatedAt:
  24084. return m.OldUpdatedAt(ctx)
  24085. case sopnode.FieldStatus:
  24086. return m.OldStatus(ctx)
  24087. case sopnode.FieldDeletedAt:
  24088. return m.OldDeletedAt(ctx)
  24089. case sopnode.FieldStageID:
  24090. return m.OldStageID(ctx)
  24091. case sopnode.FieldParentID:
  24092. return m.OldParentID(ctx)
  24093. case sopnode.FieldName:
  24094. return m.OldName(ctx)
  24095. case sopnode.FieldConditionType:
  24096. return m.OldConditionType(ctx)
  24097. case sopnode.FieldConditionList:
  24098. return m.OldConditionList(ctx)
  24099. case sopnode.FieldNoReplyCondition:
  24100. return m.OldNoReplyCondition(ctx)
  24101. case sopnode.FieldNoReplyUnit:
  24102. return m.OldNoReplyUnit(ctx)
  24103. case sopnode.FieldActionMessage:
  24104. return m.OldActionMessage(ctx)
  24105. case sopnode.FieldActionLabelAdd:
  24106. return m.OldActionLabelAdd(ctx)
  24107. case sopnode.FieldActionLabelDel:
  24108. return m.OldActionLabelDel(ctx)
  24109. case sopnode.FieldActionForward:
  24110. return m.OldActionForward(ctx)
  24111. }
  24112. return nil, fmt.Errorf("unknown SopNode field %s", name)
  24113. }
  24114. // SetField sets the value of a field with the given name. It returns an error if
  24115. // the field is not defined in the schema, or if the type mismatched the field
  24116. // type.
  24117. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  24118. switch name {
  24119. case sopnode.FieldCreatedAt:
  24120. v, ok := value.(time.Time)
  24121. if !ok {
  24122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24123. }
  24124. m.SetCreatedAt(v)
  24125. return nil
  24126. case sopnode.FieldUpdatedAt:
  24127. v, ok := value.(time.Time)
  24128. if !ok {
  24129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24130. }
  24131. m.SetUpdatedAt(v)
  24132. return nil
  24133. case sopnode.FieldStatus:
  24134. v, ok := value.(uint8)
  24135. if !ok {
  24136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24137. }
  24138. m.SetStatus(v)
  24139. return nil
  24140. case sopnode.FieldDeletedAt:
  24141. v, ok := value.(time.Time)
  24142. if !ok {
  24143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24144. }
  24145. m.SetDeletedAt(v)
  24146. return nil
  24147. case sopnode.FieldStageID:
  24148. v, ok := value.(uint64)
  24149. if !ok {
  24150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24151. }
  24152. m.SetStageID(v)
  24153. return nil
  24154. case sopnode.FieldParentID:
  24155. v, ok := value.(uint64)
  24156. if !ok {
  24157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24158. }
  24159. m.SetParentID(v)
  24160. return nil
  24161. case sopnode.FieldName:
  24162. v, ok := value.(string)
  24163. if !ok {
  24164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24165. }
  24166. m.SetName(v)
  24167. return nil
  24168. case sopnode.FieldConditionType:
  24169. v, ok := value.(int)
  24170. if !ok {
  24171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24172. }
  24173. m.SetConditionType(v)
  24174. return nil
  24175. case sopnode.FieldConditionList:
  24176. v, ok := value.([]string)
  24177. if !ok {
  24178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24179. }
  24180. m.SetConditionList(v)
  24181. return nil
  24182. case sopnode.FieldNoReplyCondition:
  24183. v, ok := value.(uint64)
  24184. if !ok {
  24185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24186. }
  24187. m.SetNoReplyCondition(v)
  24188. return nil
  24189. case sopnode.FieldNoReplyUnit:
  24190. v, ok := value.(string)
  24191. if !ok {
  24192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24193. }
  24194. m.SetNoReplyUnit(v)
  24195. return nil
  24196. case sopnode.FieldActionMessage:
  24197. v, ok := value.([]custom_types.Action)
  24198. if !ok {
  24199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24200. }
  24201. m.SetActionMessage(v)
  24202. return nil
  24203. case sopnode.FieldActionLabelAdd:
  24204. v, ok := value.([]uint64)
  24205. if !ok {
  24206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24207. }
  24208. m.SetActionLabelAdd(v)
  24209. return nil
  24210. case sopnode.FieldActionLabelDel:
  24211. v, ok := value.([]uint64)
  24212. if !ok {
  24213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24214. }
  24215. m.SetActionLabelDel(v)
  24216. return nil
  24217. case sopnode.FieldActionForward:
  24218. v, ok := value.(*custom_types.ActionForward)
  24219. if !ok {
  24220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24221. }
  24222. m.SetActionForward(v)
  24223. return nil
  24224. }
  24225. return fmt.Errorf("unknown SopNode field %s", name)
  24226. }
  24227. // AddedFields returns all numeric fields that were incremented/decremented during
  24228. // this mutation.
  24229. func (m *SopNodeMutation) AddedFields() []string {
  24230. var fields []string
  24231. if m.addstatus != nil {
  24232. fields = append(fields, sopnode.FieldStatus)
  24233. }
  24234. if m.addparent_id != nil {
  24235. fields = append(fields, sopnode.FieldParentID)
  24236. }
  24237. if m.addcondition_type != nil {
  24238. fields = append(fields, sopnode.FieldConditionType)
  24239. }
  24240. if m.addno_reply_condition != nil {
  24241. fields = append(fields, sopnode.FieldNoReplyCondition)
  24242. }
  24243. return fields
  24244. }
  24245. // AddedField returns the numeric value that was incremented/decremented on a field
  24246. // with the given name. The second boolean return value indicates that this field
  24247. // was not set, or was not defined in the schema.
  24248. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  24249. switch name {
  24250. case sopnode.FieldStatus:
  24251. return m.AddedStatus()
  24252. case sopnode.FieldParentID:
  24253. return m.AddedParentID()
  24254. case sopnode.FieldConditionType:
  24255. return m.AddedConditionType()
  24256. case sopnode.FieldNoReplyCondition:
  24257. return m.AddedNoReplyCondition()
  24258. }
  24259. return nil, false
  24260. }
  24261. // AddField adds the value to the field with the given name. It returns an error if
  24262. // the field is not defined in the schema, or if the type mismatched the field
  24263. // type.
  24264. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  24265. switch name {
  24266. case sopnode.FieldStatus:
  24267. v, ok := value.(int8)
  24268. if !ok {
  24269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24270. }
  24271. m.AddStatus(v)
  24272. return nil
  24273. case sopnode.FieldParentID:
  24274. v, ok := value.(int64)
  24275. if !ok {
  24276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24277. }
  24278. m.AddParentID(v)
  24279. return nil
  24280. case sopnode.FieldConditionType:
  24281. v, ok := value.(int)
  24282. if !ok {
  24283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24284. }
  24285. m.AddConditionType(v)
  24286. return nil
  24287. case sopnode.FieldNoReplyCondition:
  24288. v, ok := value.(int64)
  24289. if !ok {
  24290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24291. }
  24292. m.AddNoReplyCondition(v)
  24293. return nil
  24294. }
  24295. return fmt.Errorf("unknown SopNode numeric field %s", name)
  24296. }
  24297. // ClearedFields returns all nullable fields that were cleared during this
  24298. // mutation.
  24299. func (m *SopNodeMutation) ClearedFields() []string {
  24300. var fields []string
  24301. if m.FieldCleared(sopnode.FieldStatus) {
  24302. fields = append(fields, sopnode.FieldStatus)
  24303. }
  24304. if m.FieldCleared(sopnode.FieldDeletedAt) {
  24305. fields = append(fields, sopnode.FieldDeletedAt)
  24306. }
  24307. if m.FieldCleared(sopnode.FieldConditionList) {
  24308. fields = append(fields, sopnode.FieldConditionList)
  24309. }
  24310. if m.FieldCleared(sopnode.FieldActionMessage) {
  24311. fields = append(fields, sopnode.FieldActionMessage)
  24312. }
  24313. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  24314. fields = append(fields, sopnode.FieldActionLabelAdd)
  24315. }
  24316. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  24317. fields = append(fields, sopnode.FieldActionLabelDel)
  24318. }
  24319. if m.FieldCleared(sopnode.FieldActionForward) {
  24320. fields = append(fields, sopnode.FieldActionForward)
  24321. }
  24322. return fields
  24323. }
  24324. // FieldCleared returns a boolean indicating if a field with the given name was
  24325. // cleared in this mutation.
  24326. func (m *SopNodeMutation) FieldCleared(name string) bool {
  24327. _, ok := m.clearedFields[name]
  24328. return ok
  24329. }
  24330. // ClearField clears the value of the field with the given name. It returns an
  24331. // error if the field is not defined in the schema.
  24332. func (m *SopNodeMutation) ClearField(name string) error {
  24333. switch name {
  24334. case sopnode.FieldStatus:
  24335. m.ClearStatus()
  24336. return nil
  24337. case sopnode.FieldDeletedAt:
  24338. m.ClearDeletedAt()
  24339. return nil
  24340. case sopnode.FieldConditionList:
  24341. m.ClearConditionList()
  24342. return nil
  24343. case sopnode.FieldActionMessage:
  24344. m.ClearActionMessage()
  24345. return nil
  24346. case sopnode.FieldActionLabelAdd:
  24347. m.ClearActionLabelAdd()
  24348. return nil
  24349. case sopnode.FieldActionLabelDel:
  24350. m.ClearActionLabelDel()
  24351. return nil
  24352. case sopnode.FieldActionForward:
  24353. m.ClearActionForward()
  24354. return nil
  24355. }
  24356. return fmt.Errorf("unknown SopNode nullable field %s", name)
  24357. }
  24358. // ResetField resets all changes in the mutation for the field with the given name.
  24359. // It returns an error if the field is not defined in the schema.
  24360. func (m *SopNodeMutation) ResetField(name string) error {
  24361. switch name {
  24362. case sopnode.FieldCreatedAt:
  24363. m.ResetCreatedAt()
  24364. return nil
  24365. case sopnode.FieldUpdatedAt:
  24366. m.ResetUpdatedAt()
  24367. return nil
  24368. case sopnode.FieldStatus:
  24369. m.ResetStatus()
  24370. return nil
  24371. case sopnode.FieldDeletedAt:
  24372. m.ResetDeletedAt()
  24373. return nil
  24374. case sopnode.FieldStageID:
  24375. m.ResetStageID()
  24376. return nil
  24377. case sopnode.FieldParentID:
  24378. m.ResetParentID()
  24379. return nil
  24380. case sopnode.FieldName:
  24381. m.ResetName()
  24382. return nil
  24383. case sopnode.FieldConditionType:
  24384. m.ResetConditionType()
  24385. return nil
  24386. case sopnode.FieldConditionList:
  24387. m.ResetConditionList()
  24388. return nil
  24389. case sopnode.FieldNoReplyCondition:
  24390. m.ResetNoReplyCondition()
  24391. return nil
  24392. case sopnode.FieldNoReplyUnit:
  24393. m.ResetNoReplyUnit()
  24394. return nil
  24395. case sopnode.FieldActionMessage:
  24396. m.ResetActionMessage()
  24397. return nil
  24398. case sopnode.FieldActionLabelAdd:
  24399. m.ResetActionLabelAdd()
  24400. return nil
  24401. case sopnode.FieldActionLabelDel:
  24402. m.ResetActionLabelDel()
  24403. return nil
  24404. case sopnode.FieldActionForward:
  24405. m.ResetActionForward()
  24406. return nil
  24407. }
  24408. return fmt.Errorf("unknown SopNode field %s", name)
  24409. }
  24410. // AddedEdges returns all edge names that were set/added in this mutation.
  24411. func (m *SopNodeMutation) AddedEdges() []string {
  24412. edges := make([]string, 0, 2)
  24413. if m.sop_stage != nil {
  24414. edges = append(edges, sopnode.EdgeSopStage)
  24415. }
  24416. if m.node_messages != nil {
  24417. edges = append(edges, sopnode.EdgeNodeMessages)
  24418. }
  24419. return edges
  24420. }
  24421. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24422. // name in this mutation.
  24423. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  24424. switch name {
  24425. case sopnode.EdgeSopStage:
  24426. if id := m.sop_stage; id != nil {
  24427. return []ent.Value{*id}
  24428. }
  24429. case sopnode.EdgeNodeMessages:
  24430. ids := make([]ent.Value, 0, len(m.node_messages))
  24431. for id := range m.node_messages {
  24432. ids = append(ids, id)
  24433. }
  24434. return ids
  24435. }
  24436. return nil
  24437. }
  24438. // RemovedEdges returns all edge names that were removed in this mutation.
  24439. func (m *SopNodeMutation) RemovedEdges() []string {
  24440. edges := make([]string, 0, 2)
  24441. if m.removednode_messages != nil {
  24442. edges = append(edges, sopnode.EdgeNodeMessages)
  24443. }
  24444. return edges
  24445. }
  24446. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24447. // the given name in this mutation.
  24448. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  24449. switch name {
  24450. case sopnode.EdgeNodeMessages:
  24451. ids := make([]ent.Value, 0, len(m.removednode_messages))
  24452. for id := range m.removednode_messages {
  24453. ids = append(ids, id)
  24454. }
  24455. return ids
  24456. }
  24457. return nil
  24458. }
  24459. // ClearedEdges returns all edge names that were cleared in this mutation.
  24460. func (m *SopNodeMutation) ClearedEdges() []string {
  24461. edges := make([]string, 0, 2)
  24462. if m.clearedsop_stage {
  24463. edges = append(edges, sopnode.EdgeSopStage)
  24464. }
  24465. if m.clearednode_messages {
  24466. edges = append(edges, sopnode.EdgeNodeMessages)
  24467. }
  24468. return edges
  24469. }
  24470. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24471. // was cleared in this mutation.
  24472. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  24473. switch name {
  24474. case sopnode.EdgeSopStage:
  24475. return m.clearedsop_stage
  24476. case sopnode.EdgeNodeMessages:
  24477. return m.clearednode_messages
  24478. }
  24479. return false
  24480. }
  24481. // ClearEdge clears the value of the edge with the given name. It returns an error
  24482. // if that edge is not defined in the schema.
  24483. func (m *SopNodeMutation) ClearEdge(name string) error {
  24484. switch name {
  24485. case sopnode.EdgeSopStage:
  24486. m.ClearSopStage()
  24487. return nil
  24488. }
  24489. return fmt.Errorf("unknown SopNode unique edge %s", name)
  24490. }
  24491. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24492. // It returns an error if the edge is not defined in the schema.
  24493. func (m *SopNodeMutation) ResetEdge(name string) error {
  24494. switch name {
  24495. case sopnode.EdgeSopStage:
  24496. m.ResetSopStage()
  24497. return nil
  24498. case sopnode.EdgeNodeMessages:
  24499. m.ResetNodeMessages()
  24500. return nil
  24501. }
  24502. return fmt.Errorf("unknown SopNode edge %s", name)
  24503. }
  24504. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  24505. type SopStageMutation struct {
  24506. config
  24507. op Op
  24508. typ string
  24509. id *uint64
  24510. created_at *time.Time
  24511. updated_at *time.Time
  24512. status *uint8
  24513. addstatus *int8
  24514. deleted_at *time.Time
  24515. name *string
  24516. condition_type *int
  24517. addcondition_type *int
  24518. condition_operator *int
  24519. addcondition_operator *int
  24520. condition_list *[]custom_types.Condition
  24521. appendcondition_list []custom_types.Condition
  24522. action_message *[]custom_types.Action
  24523. appendaction_message []custom_types.Action
  24524. action_label_add *[]uint64
  24525. appendaction_label_add []uint64
  24526. action_label_del *[]uint64
  24527. appendaction_label_del []uint64
  24528. action_forward **custom_types.ActionForward
  24529. index_sort *int
  24530. addindex_sort *int
  24531. clearedFields map[string]struct{}
  24532. sop_task *uint64
  24533. clearedsop_task bool
  24534. stage_nodes map[uint64]struct{}
  24535. removedstage_nodes map[uint64]struct{}
  24536. clearedstage_nodes bool
  24537. stage_messages map[uint64]struct{}
  24538. removedstage_messages map[uint64]struct{}
  24539. clearedstage_messages bool
  24540. done bool
  24541. oldValue func(context.Context) (*SopStage, error)
  24542. predicates []predicate.SopStage
  24543. }
  24544. var _ ent.Mutation = (*SopStageMutation)(nil)
  24545. // sopstageOption allows management of the mutation configuration using functional options.
  24546. type sopstageOption func(*SopStageMutation)
  24547. // newSopStageMutation creates new mutation for the SopStage entity.
  24548. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  24549. m := &SopStageMutation{
  24550. config: c,
  24551. op: op,
  24552. typ: TypeSopStage,
  24553. clearedFields: make(map[string]struct{}),
  24554. }
  24555. for _, opt := range opts {
  24556. opt(m)
  24557. }
  24558. return m
  24559. }
  24560. // withSopStageID sets the ID field of the mutation.
  24561. func withSopStageID(id uint64) sopstageOption {
  24562. return func(m *SopStageMutation) {
  24563. var (
  24564. err error
  24565. once sync.Once
  24566. value *SopStage
  24567. )
  24568. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  24569. once.Do(func() {
  24570. if m.done {
  24571. err = errors.New("querying old values post mutation is not allowed")
  24572. } else {
  24573. value, err = m.Client().SopStage.Get(ctx, id)
  24574. }
  24575. })
  24576. return value, err
  24577. }
  24578. m.id = &id
  24579. }
  24580. }
  24581. // withSopStage sets the old SopStage of the mutation.
  24582. func withSopStage(node *SopStage) sopstageOption {
  24583. return func(m *SopStageMutation) {
  24584. m.oldValue = func(context.Context) (*SopStage, error) {
  24585. return node, nil
  24586. }
  24587. m.id = &node.ID
  24588. }
  24589. }
  24590. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24591. // executed in a transaction (ent.Tx), a transactional client is returned.
  24592. func (m SopStageMutation) Client() *Client {
  24593. client := &Client{config: m.config}
  24594. client.init()
  24595. return client
  24596. }
  24597. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24598. // it returns an error otherwise.
  24599. func (m SopStageMutation) Tx() (*Tx, error) {
  24600. if _, ok := m.driver.(*txDriver); !ok {
  24601. return nil, errors.New("ent: mutation is not running in a transaction")
  24602. }
  24603. tx := &Tx{config: m.config}
  24604. tx.init()
  24605. return tx, nil
  24606. }
  24607. // SetID sets the value of the id field. Note that this
  24608. // operation is only accepted on creation of SopStage entities.
  24609. func (m *SopStageMutation) SetID(id uint64) {
  24610. m.id = &id
  24611. }
  24612. // ID returns the ID value in the mutation. Note that the ID is only available
  24613. // if it was provided to the builder or after it was returned from the database.
  24614. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  24615. if m.id == nil {
  24616. return
  24617. }
  24618. return *m.id, true
  24619. }
  24620. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24621. // That means, if the mutation is applied within a transaction with an isolation level such
  24622. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24623. // or updated by the mutation.
  24624. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  24625. switch {
  24626. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24627. id, exists := m.ID()
  24628. if exists {
  24629. return []uint64{id}, nil
  24630. }
  24631. fallthrough
  24632. case m.op.Is(OpUpdate | OpDelete):
  24633. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  24634. default:
  24635. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24636. }
  24637. }
  24638. // SetCreatedAt sets the "created_at" field.
  24639. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  24640. m.created_at = &t
  24641. }
  24642. // CreatedAt returns the value of the "created_at" field in the mutation.
  24643. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  24644. v := m.created_at
  24645. if v == nil {
  24646. return
  24647. }
  24648. return *v, true
  24649. }
  24650. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  24651. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24653. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24654. if !m.op.Is(OpUpdateOne) {
  24655. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24656. }
  24657. if m.id == nil || m.oldValue == nil {
  24658. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24659. }
  24660. oldValue, err := m.oldValue(ctx)
  24661. if err != nil {
  24662. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24663. }
  24664. return oldValue.CreatedAt, nil
  24665. }
  24666. // ResetCreatedAt resets all changes to the "created_at" field.
  24667. func (m *SopStageMutation) ResetCreatedAt() {
  24668. m.created_at = nil
  24669. }
  24670. // SetUpdatedAt sets the "updated_at" field.
  24671. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  24672. m.updated_at = &t
  24673. }
  24674. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24675. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  24676. v := m.updated_at
  24677. if v == nil {
  24678. return
  24679. }
  24680. return *v, true
  24681. }
  24682. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  24683. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24685. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24686. if !m.op.Is(OpUpdateOne) {
  24687. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24688. }
  24689. if m.id == nil || m.oldValue == nil {
  24690. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24691. }
  24692. oldValue, err := m.oldValue(ctx)
  24693. if err != nil {
  24694. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24695. }
  24696. return oldValue.UpdatedAt, nil
  24697. }
  24698. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24699. func (m *SopStageMutation) ResetUpdatedAt() {
  24700. m.updated_at = nil
  24701. }
  24702. // SetStatus sets the "status" field.
  24703. func (m *SopStageMutation) SetStatus(u uint8) {
  24704. m.status = &u
  24705. m.addstatus = nil
  24706. }
  24707. // Status returns the value of the "status" field in the mutation.
  24708. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  24709. v := m.status
  24710. if v == nil {
  24711. return
  24712. }
  24713. return *v, true
  24714. }
  24715. // OldStatus returns the old "status" field's value of the SopStage entity.
  24716. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24718. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24719. if !m.op.Is(OpUpdateOne) {
  24720. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24721. }
  24722. if m.id == nil || m.oldValue == nil {
  24723. return v, errors.New("OldStatus requires an ID field in the mutation")
  24724. }
  24725. oldValue, err := m.oldValue(ctx)
  24726. if err != nil {
  24727. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24728. }
  24729. return oldValue.Status, nil
  24730. }
  24731. // AddStatus adds u to the "status" field.
  24732. func (m *SopStageMutation) AddStatus(u int8) {
  24733. if m.addstatus != nil {
  24734. *m.addstatus += u
  24735. } else {
  24736. m.addstatus = &u
  24737. }
  24738. }
  24739. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24740. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  24741. v := m.addstatus
  24742. if v == nil {
  24743. return
  24744. }
  24745. return *v, true
  24746. }
  24747. // ClearStatus clears the value of the "status" field.
  24748. func (m *SopStageMutation) ClearStatus() {
  24749. m.status = nil
  24750. m.addstatus = nil
  24751. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  24752. }
  24753. // StatusCleared returns if the "status" field was cleared in this mutation.
  24754. func (m *SopStageMutation) StatusCleared() bool {
  24755. _, ok := m.clearedFields[sopstage.FieldStatus]
  24756. return ok
  24757. }
  24758. // ResetStatus resets all changes to the "status" field.
  24759. func (m *SopStageMutation) ResetStatus() {
  24760. m.status = nil
  24761. m.addstatus = nil
  24762. delete(m.clearedFields, sopstage.FieldStatus)
  24763. }
  24764. // SetDeletedAt sets the "deleted_at" field.
  24765. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  24766. m.deleted_at = &t
  24767. }
  24768. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24769. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  24770. v := m.deleted_at
  24771. if v == nil {
  24772. return
  24773. }
  24774. return *v, true
  24775. }
  24776. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  24777. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24779. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24780. if !m.op.Is(OpUpdateOne) {
  24781. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24782. }
  24783. if m.id == nil || m.oldValue == nil {
  24784. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24785. }
  24786. oldValue, err := m.oldValue(ctx)
  24787. if err != nil {
  24788. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24789. }
  24790. return oldValue.DeletedAt, nil
  24791. }
  24792. // ClearDeletedAt clears the value of the "deleted_at" field.
  24793. func (m *SopStageMutation) ClearDeletedAt() {
  24794. m.deleted_at = nil
  24795. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  24796. }
  24797. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24798. func (m *SopStageMutation) DeletedAtCleared() bool {
  24799. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  24800. return ok
  24801. }
  24802. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24803. func (m *SopStageMutation) ResetDeletedAt() {
  24804. m.deleted_at = nil
  24805. delete(m.clearedFields, sopstage.FieldDeletedAt)
  24806. }
  24807. // SetTaskID sets the "task_id" field.
  24808. func (m *SopStageMutation) SetTaskID(u uint64) {
  24809. m.sop_task = &u
  24810. }
  24811. // TaskID returns the value of the "task_id" field in the mutation.
  24812. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  24813. v := m.sop_task
  24814. if v == nil {
  24815. return
  24816. }
  24817. return *v, true
  24818. }
  24819. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  24820. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24822. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  24823. if !m.op.Is(OpUpdateOne) {
  24824. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  24825. }
  24826. if m.id == nil || m.oldValue == nil {
  24827. return v, errors.New("OldTaskID requires an ID field in the mutation")
  24828. }
  24829. oldValue, err := m.oldValue(ctx)
  24830. if err != nil {
  24831. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  24832. }
  24833. return oldValue.TaskID, nil
  24834. }
  24835. // ResetTaskID resets all changes to the "task_id" field.
  24836. func (m *SopStageMutation) ResetTaskID() {
  24837. m.sop_task = nil
  24838. }
  24839. // SetName sets the "name" field.
  24840. func (m *SopStageMutation) SetName(s string) {
  24841. m.name = &s
  24842. }
  24843. // Name returns the value of the "name" field in the mutation.
  24844. func (m *SopStageMutation) Name() (r string, exists bool) {
  24845. v := m.name
  24846. if v == nil {
  24847. return
  24848. }
  24849. return *v, true
  24850. }
  24851. // OldName returns the old "name" field's value of the SopStage entity.
  24852. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24854. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  24855. if !m.op.Is(OpUpdateOne) {
  24856. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24857. }
  24858. if m.id == nil || m.oldValue == nil {
  24859. return v, errors.New("OldName requires an ID field in the mutation")
  24860. }
  24861. oldValue, err := m.oldValue(ctx)
  24862. if err != nil {
  24863. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24864. }
  24865. return oldValue.Name, nil
  24866. }
  24867. // ResetName resets all changes to the "name" field.
  24868. func (m *SopStageMutation) ResetName() {
  24869. m.name = nil
  24870. }
  24871. // SetConditionType sets the "condition_type" field.
  24872. func (m *SopStageMutation) SetConditionType(i int) {
  24873. m.condition_type = &i
  24874. m.addcondition_type = nil
  24875. }
  24876. // ConditionType returns the value of the "condition_type" field in the mutation.
  24877. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  24878. v := m.condition_type
  24879. if v == nil {
  24880. return
  24881. }
  24882. return *v, true
  24883. }
  24884. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  24885. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24887. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  24888. if !m.op.Is(OpUpdateOne) {
  24889. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  24890. }
  24891. if m.id == nil || m.oldValue == nil {
  24892. return v, errors.New("OldConditionType requires an ID field in the mutation")
  24893. }
  24894. oldValue, err := m.oldValue(ctx)
  24895. if err != nil {
  24896. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  24897. }
  24898. return oldValue.ConditionType, nil
  24899. }
  24900. // AddConditionType adds i to the "condition_type" field.
  24901. func (m *SopStageMutation) AddConditionType(i int) {
  24902. if m.addcondition_type != nil {
  24903. *m.addcondition_type += i
  24904. } else {
  24905. m.addcondition_type = &i
  24906. }
  24907. }
  24908. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  24909. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  24910. v := m.addcondition_type
  24911. if v == nil {
  24912. return
  24913. }
  24914. return *v, true
  24915. }
  24916. // ResetConditionType resets all changes to the "condition_type" field.
  24917. func (m *SopStageMutation) ResetConditionType() {
  24918. m.condition_type = nil
  24919. m.addcondition_type = nil
  24920. }
  24921. // SetConditionOperator sets the "condition_operator" field.
  24922. func (m *SopStageMutation) SetConditionOperator(i int) {
  24923. m.condition_operator = &i
  24924. m.addcondition_operator = nil
  24925. }
  24926. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  24927. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  24928. v := m.condition_operator
  24929. if v == nil {
  24930. return
  24931. }
  24932. return *v, true
  24933. }
  24934. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  24935. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24937. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  24938. if !m.op.Is(OpUpdateOne) {
  24939. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  24940. }
  24941. if m.id == nil || m.oldValue == nil {
  24942. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  24943. }
  24944. oldValue, err := m.oldValue(ctx)
  24945. if err != nil {
  24946. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  24947. }
  24948. return oldValue.ConditionOperator, nil
  24949. }
  24950. // AddConditionOperator adds i to the "condition_operator" field.
  24951. func (m *SopStageMutation) AddConditionOperator(i int) {
  24952. if m.addcondition_operator != nil {
  24953. *m.addcondition_operator += i
  24954. } else {
  24955. m.addcondition_operator = &i
  24956. }
  24957. }
  24958. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  24959. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  24960. v := m.addcondition_operator
  24961. if v == nil {
  24962. return
  24963. }
  24964. return *v, true
  24965. }
  24966. // ResetConditionOperator resets all changes to the "condition_operator" field.
  24967. func (m *SopStageMutation) ResetConditionOperator() {
  24968. m.condition_operator = nil
  24969. m.addcondition_operator = nil
  24970. }
  24971. // SetConditionList sets the "condition_list" field.
  24972. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  24973. m.condition_list = &ct
  24974. m.appendcondition_list = nil
  24975. }
  24976. // ConditionList returns the value of the "condition_list" field in the mutation.
  24977. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  24978. v := m.condition_list
  24979. if v == nil {
  24980. return
  24981. }
  24982. return *v, true
  24983. }
  24984. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  24985. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24987. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  24988. if !m.op.Is(OpUpdateOne) {
  24989. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  24990. }
  24991. if m.id == nil || m.oldValue == nil {
  24992. return v, errors.New("OldConditionList requires an ID field in the mutation")
  24993. }
  24994. oldValue, err := m.oldValue(ctx)
  24995. if err != nil {
  24996. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  24997. }
  24998. return oldValue.ConditionList, nil
  24999. }
  25000. // AppendConditionList adds ct to the "condition_list" field.
  25001. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  25002. m.appendcondition_list = append(m.appendcondition_list, ct...)
  25003. }
  25004. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  25005. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  25006. if len(m.appendcondition_list) == 0 {
  25007. return nil, false
  25008. }
  25009. return m.appendcondition_list, true
  25010. }
  25011. // ResetConditionList resets all changes to the "condition_list" field.
  25012. func (m *SopStageMutation) ResetConditionList() {
  25013. m.condition_list = nil
  25014. m.appendcondition_list = nil
  25015. }
  25016. // SetActionMessage sets the "action_message" field.
  25017. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  25018. m.action_message = &ct
  25019. m.appendaction_message = nil
  25020. }
  25021. // ActionMessage returns the value of the "action_message" field in the mutation.
  25022. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  25023. v := m.action_message
  25024. if v == nil {
  25025. return
  25026. }
  25027. return *v, true
  25028. }
  25029. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  25030. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25032. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  25033. if !m.op.Is(OpUpdateOne) {
  25034. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  25035. }
  25036. if m.id == nil || m.oldValue == nil {
  25037. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  25038. }
  25039. oldValue, err := m.oldValue(ctx)
  25040. if err != nil {
  25041. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  25042. }
  25043. return oldValue.ActionMessage, nil
  25044. }
  25045. // AppendActionMessage adds ct to the "action_message" field.
  25046. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  25047. m.appendaction_message = append(m.appendaction_message, ct...)
  25048. }
  25049. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  25050. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  25051. if len(m.appendaction_message) == 0 {
  25052. return nil, false
  25053. }
  25054. return m.appendaction_message, true
  25055. }
  25056. // ClearActionMessage clears the value of the "action_message" field.
  25057. func (m *SopStageMutation) ClearActionMessage() {
  25058. m.action_message = nil
  25059. m.appendaction_message = nil
  25060. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  25061. }
  25062. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  25063. func (m *SopStageMutation) ActionMessageCleared() bool {
  25064. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  25065. return ok
  25066. }
  25067. // ResetActionMessage resets all changes to the "action_message" field.
  25068. func (m *SopStageMutation) ResetActionMessage() {
  25069. m.action_message = nil
  25070. m.appendaction_message = nil
  25071. delete(m.clearedFields, sopstage.FieldActionMessage)
  25072. }
  25073. // SetActionLabelAdd sets the "action_label_add" field.
  25074. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  25075. m.action_label_add = &u
  25076. m.appendaction_label_add = nil
  25077. }
  25078. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  25079. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  25080. v := m.action_label_add
  25081. if v == nil {
  25082. return
  25083. }
  25084. return *v, true
  25085. }
  25086. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  25087. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25089. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  25090. if !m.op.Is(OpUpdateOne) {
  25091. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  25092. }
  25093. if m.id == nil || m.oldValue == nil {
  25094. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  25095. }
  25096. oldValue, err := m.oldValue(ctx)
  25097. if err != nil {
  25098. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  25099. }
  25100. return oldValue.ActionLabelAdd, nil
  25101. }
  25102. // AppendActionLabelAdd adds u to the "action_label_add" field.
  25103. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  25104. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  25105. }
  25106. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  25107. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  25108. if len(m.appendaction_label_add) == 0 {
  25109. return nil, false
  25110. }
  25111. return m.appendaction_label_add, true
  25112. }
  25113. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  25114. func (m *SopStageMutation) ClearActionLabelAdd() {
  25115. m.action_label_add = nil
  25116. m.appendaction_label_add = nil
  25117. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  25118. }
  25119. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  25120. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  25121. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  25122. return ok
  25123. }
  25124. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  25125. func (m *SopStageMutation) ResetActionLabelAdd() {
  25126. m.action_label_add = nil
  25127. m.appendaction_label_add = nil
  25128. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  25129. }
  25130. // SetActionLabelDel sets the "action_label_del" field.
  25131. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  25132. m.action_label_del = &u
  25133. m.appendaction_label_del = nil
  25134. }
  25135. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  25136. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  25137. v := m.action_label_del
  25138. if v == nil {
  25139. return
  25140. }
  25141. return *v, true
  25142. }
  25143. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  25144. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25146. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  25147. if !m.op.Is(OpUpdateOne) {
  25148. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  25149. }
  25150. if m.id == nil || m.oldValue == nil {
  25151. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  25152. }
  25153. oldValue, err := m.oldValue(ctx)
  25154. if err != nil {
  25155. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  25156. }
  25157. return oldValue.ActionLabelDel, nil
  25158. }
  25159. // AppendActionLabelDel adds u to the "action_label_del" field.
  25160. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  25161. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25162. }
  25163. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25164. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25165. if len(m.appendaction_label_del) == 0 {
  25166. return nil, false
  25167. }
  25168. return m.appendaction_label_del, true
  25169. }
  25170. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25171. func (m *SopStageMutation) ClearActionLabelDel() {
  25172. m.action_label_del = nil
  25173. m.appendaction_label_del = nil
  25174. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  25175. }
  25176. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25177. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  25178. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  25179. return ok
  25180. }
  25181. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25182. func (m *SopStageMutation) ResetActionLabelDel() {
  25183. m.action_label_del = nil
  25184. m.appendaction_label_del = nil
  25185. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  25186. }
  25187. // SetActionForward sets the "action_forward" field.
  25188. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25189. m.action_forward = &ctf
  25190. }
  25191. // ActionForward returns the value of the "action_forward" field in the mutation.
  25192. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25193. v := m.action_forward
  25194. if v == nil {
  25195. return
  25196. }
  25197. return *v, true
  25198. }
  25199. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  25200. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25202. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25203. if !m.op.Is(OpUpdateOne) {
  25204. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25205. }
  25206. if m.id == nil || m.oldValue == nil {
  25207. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25208. }
  25209. oldValue, err := m.oldValue(ctx)
  25210. if err != nil {
  25211. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25212. }
  25213. return oldValue.ActionForward, nil
  25214. }
  25215. // ClearActionForward clears the value of the "action_forward" field.
  25216. func (m *SopStageMutation) ClearActionForward() {
  25217. m.action_forward = nil
  25218. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  25219. }
  25220. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25221. func (m *SopStageMutation) ActionForwardCleared() bool {
  25222. _, ok := m.clearedFields[sopstage.FieldActionForward]
  25223. return ok
  25224. }
  25225. // ResetActionForward resets all changes to the "action_forward" field.
  25226. func (m *SopStageMutation) ResetActionForward() {
  25227. m.action_forward = nil
  25228. delete(m.clearedFields, sopstage.FieldActionForward)
  25229. }
  25230. // SetIndexSort sets the "index_sort" field.
  25231. func (m *SopStageMutation) SetIndexSort(i int) {
  25232. m.index_sort = &i
  25233. m.addindex_sort = nil
  25234. }
  25235. // IndexSort returns the value of the "index_sort" field in the mutation.
  25236. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  25237. v := m.index_sort
  25238. if v == nil {
  25239. return
  25240. }
  25241. return *v, true
  25242. }
  25243. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  25244. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25246. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  25247. if !m.op.Is(OpUpdateOne) {
  25248. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  25249. }
  25250. if m.id == nil || m.oldValue == nil {
  25251. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  25252. }
  25253. oldValue, err := m.oldValue(ctx)
  25254. if err != nil {
  25255. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  25256. }
  25257. return oldValue.IndexSort, nil
  25258. }
  25259. // AddIndexSort adds i to the "index_sort" field.
  25260. func (m *SopStageMutation) AddIndexSort(i int) {
  25261. if m.addindex_sort != nil {
  25262. *m.addindex_sort += i
  25263. } else {
  25264. m.addindex_sort = &i
  25265. }
  25266. }
  25267. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  25268. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  25269. v := m.addindex_sort
  25270. if v == nil {
  25271. return
  25272. }
  25273. return *v, true
  25274. }
  25275. // ClearIndexSort clears the value of the "index_sort" field.
  25276. func (m *SopStageMutation) ClearIndexSort() {
  25277. m.index_sort = nil
  25278. m.addindex_sort = nil
  25279. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  25280. }
  25281. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  25282. func (m *SopStageMutation) IndexSortCleared() bool {
  25283. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  25284. return ok
  25285. }
  25286. // ResetIndexSort resets all changes to the "index_sort" field.
  25287. func (m *SopStageMutation) ResetIndexSort() {
  25288. m.index_sort = nil
  25289. m.addindex_sort = nil
  25290. delete(m.clearedFields, sopstage.FieldIndexSort)
  25291. }
  25292. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  25293. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  25294. m.sop_task = &id
  25295. }
  25296. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  25297. func (m *SopStageMutation) ClearSopTask() {
  25298. m.clearedsop_task = true
  25299. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  25300. }
  25301. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  25302. func (m *SopStageMutation) SopTaskCleared() bool {
  25303. return m.clearedsop_task
  25304. }
  25305. // SopTaskID returns the "sop_task" edge ID in the mutation.
  25306. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  25307. if m.sop_task != nil {
  25308. return *m.sop_task, true
  25309. }
  25310. return
  25311. }
  25312. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  25313. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25314. // SopTaskID instead. It exists only for internal usage by the builders.
  25315. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  25316. if id := m.sop_task; id != nil {
  25317. ids = append(ids, *id)
  25318. }
  25319. return
  25320. }
  25321. // ResetSopTask resets all changes to the "sop_task" edge.
  25322. func (m *SopStageMutation) ResetSopTask() {
  25323. m.sop_task = nil
  25324. m.clearedsop_task = false
  25325. }
  25326. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  25327. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  25328. if m.stage_nodes == nil {
  25329. m.stage_nodes = make(map[uint64]struct{})
  25330. }
  25331. for i := range ids {
  25332. m.stage_nodes[ids[i]] = struct{}{}
  25333. }
  25334. }
  25335. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  25336. func (m *SopStageMutation) ClearStageNodes() {
  25337. m.clearedstage_nodes = true
  25338. }
  25339. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  25340. func (m *SopStageMutation) StageNodesCleared() bool {
  25341. return m.clearedstage_nodes
  25342. }
  25343. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  25344. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  25345. if m.removedstage_nodes == nil {
  25346. m.removedstage_nodes = make(map[uint64]struct{})
  25347. }
  25348. for i := range ids {
  25349. delete(m.stage_nodes, ids[i])
  25350. m.removedstage_nodes[ids[i]] = struct{}{}
  25351. }
  25352. }
  25353. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  25354. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  25355. for id := range m.removedstage_nodes {
  25356. ids = append(ids, id)
  25357. }
  25358. return
  25359. }
  25360. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  25361. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  25362. for id := range m.stage_nodes {
  25363. ids = append(ids, id)
  25364. }
  25365. return
  25366. }
  25367. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  25368. func (m *SopStageMutation) ResetStageNodes() {
  25369. m.stage_nodes = nil
  25370. m.clearedstage_nodes = false
  25371. m.removedstage_nodes = nil
  25372. }
  25373. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  25374. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  25375. if m.stage_messages == nil {
  25376. m.stage_messages = make(map[uint64]struct{})
  25377. }
  25378. for i := range ids {
  25379. m.stage_messages[ids[i]] = struct{}{}
  25380. }
  25381. }
  25382. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  25383. func (m *SopStageMutation) ClearStageMessages() {
  25384. m.clearedstage_messages = true
  25385. }
  25386. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  25387. func (m *SopStageMutation) StageMessagesCleared() bool {
  25388. return m.clearedstage_messages
  25389. }
  25390. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  25391. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  25392. if m.removedstage_messages == nil {
  25393. m.removedstage_messages = make(map[uint64]struct{})
  25394. }
  25395. for i := range ids {
  25396. delete(m.stage_messages, ids[i])
  25397. m.removedstage_messages[ids[i]] = struct{}{}
  25398. }
  25399. }
  25400. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  25401. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  25402. for id := range m.removedstage_messages {
  25403. ids = append(ids, id)
  25404. }
  25405. return
  25406. }
  25407. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  25408. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  25409. for id := range m.stage_messages {
  25410. ids = append(ids, id)
  25411. }
  25412. return
  25413. }
  25414. // ResetStageMessages resets all changes to the "stage_messages" edge.
  25415. func (m *SopStageMutation) ResetStageMessages() {
  25416. m.stage_messages = nil
  25417. m.clearedstage_messages = false
  25418. m.removedstage_messages = nil
  25419. }
  25420. // Where appends a list predicates to the SopStageMutation builder.
  25421. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  25422. m.predicates = append(m.predicates, ps...)
  25423. }
  25424. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  25425. // users can use type-assertion to append predicates that do not depend on any generated package.
  25426. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  25427. p := make([]predicate.SopStage, len(ps))
  25428. for i := range ps {
  25429. p[i] = ps[i]
  25430. }
  25431. m.Where(p...)
  25432. }
  25433. // Op returns the operation name.
  25434. func (m *SopStageMutation) Op() Op {
  25435. return m.op
  25436. }
  25437. // SetOp allows setting the mutation operation.
  25438. func (m *SopStageMutation) SetOp(op Op) {
  25439. m.op = op
  25440. }
  25441. // Type returns the node type of this mutation (SopStage).
  25442. func (m *SopStageMutation) Type() string {
  25443. return m.typ
  25444. }
  25445. // Fields returns all fields that were changed during this mutation. Note that in
  25446. // order to get all numeric fields that were incremented/decremented, call
  25447. // AddedFields().
  25448. func (m *SopStageMutation) Fields() []string {
  25449. fields := make([]string, 0, 14)
  25450. if m.created_at != nil {
  25451. fields = append(fields, sopstage.FieldCreatedAt)
  25452. }
  25453. if m.updated_at != nil {
  25454. fields = append(fields, sopstage.FieldUpdatedAt)
  25455. }
  25456. if m.status != nil {
  25457. fields = append(fields, sopstage.FieldStatus)
  25458. }
  25459. if m.deleted_at != nil {
  25460. fields = append(fields, sopstage.FieldDeletedAt)
  25461. }
  25462. if m.sop_task != nil {
  25463. fields = append(fields, sopstage.FieldTaskID)
  25464. }
  25465. if m.name != nil {
  25466. fields = append(fields, sopstage.FieldName)
  25467. }
  25468. if m.condition_type != nil {
  25469. fields = append(fields, sopstage.FieldConditionType)
  25470. }
  25471. if m.condition_operator != nil {
  25472. fields = append(fields, sopstage.FieldConditionOperator)
  25473. }
  25474. if m.condition_list != nil {
  25475. fields = append(fields, sopstage.FieldConditionList)
  25476. }
  25477. if m.action_message != nil {
  25478. fields = append(fields, sopstage.FieldActionMessage)
  25479. }
  25480. if m.action_label_add != nil {
  25481. fields = append(fields, sopstage.FieldActionLabelAdd)
  25482. }
  25483. if m.action_label_del != nil {
  25484. fields = append(fields, sopstage.FieldActionLabelDel)
  25485. }
  25486. if m.action_forward != nil {
  25487. fields = append(fields, sopstage.FieldActionForward)
  25488. }
  25489. if m.index_sort != nil {
  25490. fields = append(fields, sopstage.FieldIndexSort)
  25491. }
  25492. return fields
  25493. }
  25494. // Field returns the value of a field with the given name. The second boolean
  25495. // return value indicates that this field was not set, or was not defined in the
  25496. // schema.
  25497. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  25498. switch name {
  25499. case sopstage.FieldCreatedAt:
  25500. return m.CreatedAt()
  25501. case sopstage.FieldUpdatedAt:
  25502. return m.UpdatedAt()
  25503. case sopstage.FieldStatus:
  25504. return m.Status()
  25505. case sopstage.FieldDeletedAt:
  25506. return m.DeletedAt()
  25507. case sopstage.FieldTaskID:
  25508. return m.TaskID()
  25509. case sopstage.FieldName:
  25510. return m.Name()
  25511. case sopstage.FieldConditionType:
  25512. return m.ConditionType()
  25513. case sopstage.FieldConditionOperator:
  25514. return m.ConditionOperator()
  25515. case sopstage.FieldConditionList:
  25516. return m.ConditionList()
  25517. case sopstage.FieldActionMessage:
  25518. return m.ActionMessage()
  25519. case sopstage.FieldActionLabelAdd:
  25520. return m.ActionLabelAdd()
  25521. case sopstage.FieldActionLabelDel:
  25522. return m.ActionLabelDel()
  25523. case sopstage.FieldActionForward:
  25524. return m.ActionForward()
  25525. case sopstage.FieldIndexSort:
  25526. return m.IndexSort()
  25527. }
  25528. return nil, false
  25529. }
  25530. // OldField returns the old value of the field from the database. An error is
  25531. // returned if the mutation operation is not UpdateOne, or the query to the
  25532. // database failed.
  25533. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25534. switch name {
  25535. case sopstage.FieldCreatedAt:
  25536. return m.OldCreatedAt(ctx)
  25537. case sopstage.FieldUpdatedAt:
  25538. return m.OldUpdatedAt(ctx)
  25539. case sopstage.FieldStatus:
  25540. return m.OldStatus(ctx)
  25541. case sopstage.FieldDeletedAt:
  25542. return m.OldDeletedAt(ctx)
  25543. case sopstage.FieldTaskID:
  25544. return m.OldTaskID(ctx)
  25545. case sopstage.FieldName:
  25546. return m.OldName(ctx)
  25547. case sopstage.FieldConditionType:
  25548. return m.OldConditionType(ctx)
  25549. case sopstage.FieldConditionOperator:
  25550. return m.OldConditionOperator(ctx)
  25551. case sopstage.FieldConditionList:
  25552. return m.OldConditionList(ctx)
  25553. case sopstage.FieldActionMessage:
  25554. return m.OldActionMessage(ctx)
  25555. case sopstage.FieldActionLabelAdd:
  25556. return m.OldActionLabelAdd(ctx)
  25557. case sopstage.FieldActionLabelDel:
  25558. return m.OldActionLabelDel(ctx)
  25559. case sopstage.FieldActionForward:
  25560. return m.OldActionForward(ctx)
  25561. case sopstage.FieldIndexSort:
  25562. return m.OldIndexSort(ctx)
  25563. }
  25564. return nil, fmt.Errorf("unknown SopStage field %s", name)
  25565. }
  25566. // SetField sets the value of a field with the given name. It returns an error if
  25567. // the field is not defined in the schema, or if the type mismatched the field
  25568. // type.
  25569. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  25570. switch name {
  25571. case sopstage.FieldCreatedAt:
  25572. v, ok := value.(time.Time)
  25573. if !ok {
  25574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25575. }
  25576. m.SetCreatedAt(v)
  25577. return nil
  25578. case sopstage.FieldUpdatedAt:
  25579. v, ok := value.(time.Time)
  25580. if !ok {
  25581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25582. }
  25583. m.SetUpdatedAt(v)
  25584. return nil
  25585. case sopstage.FieldStatus:
  25586. v, ok := value.(uint8)
  25587. if !ok {
  25588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25589. }
  25590. m.SetStatus(v)
  25591. return nil
  25592. case sopstage.FieldDeletedAt:
  25593. v, ok := value.(time.Time)
  25594. if !ok {
  25595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25596. }
  25597. m.SetDeletedAt(v)
  25598. return nil
  25599. case sopstage.FieldTaskID:
  25600. v, ok := value.(uint64)
  25601. if !ok {
  25602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25603. }
  25604. m.SetTaskID(v)
  25605. return nil
  25606. case sopstage.FieldName:
  25607. v, ok := value.(string)
  25608. if !ok {
  25609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25610. }
  25611. m.SetName(v)
  25612. return nil
  25613. case sopstage.FieldConditionType:
  25614. v, ok := value.(int)
  25615. if !ok {
  25616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25617. }
  25618. m.SetConditionType(v)
  25619. return nil
  25620. case sopstage.FieldConditionOperator:
  25621. v, ok := value.(int)
  25622. if !ok {
  25623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25624. }
  25625. m.SetConditionOperator(v)
  25626. return nil
  25627. case sopstage.FieldConditionList:
  25628. v, ok := value.([]custom_types.Condition)
  25629. if !ok {
  25630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25631. }
  25632. m.SetConditionList(v)
  25633. return nil
  25634. case sopstage.FieldActionMessage:
  25635. v, ok := value.([]custom_types.Action)
  25636. if !ok {
  25637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25638. }
  25639. m.SetActionMessage(v)
  25640. return nil
  25641. case sopstage.FieldActionLabelAdd:
  25642. v, ok := value.([]uint64)
  25643. if !ok {
  25644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25645. }
  25646. m.SetActionLabelAdd(v)
  25647. return nil
  25648. case sopstage.FieldActionLabelDel:
  25649. v, ok := value.([]uint64)
  25650. if !ok {
  25651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25652. }
  25653. m.SetActionLabelDel(v)
  25654. return nil
  25655. case sopstage.FieldActionForward:
  25656. v, ok := value.(*custom_types.ActionForward)
  25657. if !ok {
  25658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25659. }
  25660. m.SetActionForward(v)
  25661. return nil
  25662. case sopstage.FieldIndexSort:
  25663. v, ok := value.(int)
  25664. if !ok {
  25665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25666. }
  25667. m.SetIndexSort(v)
  25668. return nil
  25669. }
  25670. return fmt.Errorf("unknown SopStage field %s", name)
  25671. }
  25672. // AddedFields returns all numeric fields that were incremented/decremented during
  25673. // this mutation.
  25674. func (m *SopStageMutation) AddedFields() []string {
  25675. var fields []string
  25676. if m.addstatus != nil {
  25677. fields = append(fields, sopstage.FieldStatus)
  25678. }
  25679. if m.addcondition_type != nil {
  25680. fields = append(fields, sopstage.FieldConditionType)
  25681. }
  25682. if m.addcondition_operator != nil {
  25683. fields = append(fields, sopstage.FieldConditionOperator)
  25684. }
  25685. if m.addindex_sort != nil {
  25686. fields = append(fields, sopstage.FieldIndexSort)
  25687. }
  25688. return fields
  25689. }
  25690. // AddedField returns the numeric value that was incremented/decremented on a field
  25691. // with the given name. The second boolean return value indicates that this field
  25692. // was not set, or was not defined in the schema.
  25693. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  25694. switch name {
  25695. case sopstage.FieldStatus:
  25696. return m.AddedStatus()
  25697. case sopstage.FieldConditionType:
  25698. return m.AddedConditionType()
  25699. case sopstage.FieldConditionOperator:
  25700. return m.AddedConditionOperator()
  25701. case sopstage.FieldIndexSort:
  25702. return m.AddedIndexSort()
  25703. }
  25704. return nil, false
  25705. }
  25706. // AddField adds the value to the field with the given name. It returns an error if
  25707. // the field is not defined in the schema, or if the type mismatched the field
  25708. // type.
  25709. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  25710. switch name {
  25711. case sopstage.FieldStatus:
  25712. v, ok := value.(int8)
  25713. if !ok {
  25714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25715. }
  25716. m.AddStatus(v)
  25717. return nil
  25718. case sopstage.FieldConditionType:
  25719. v, ok := value.(int)
  25720. if !ok {
  25721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25722. }
  25723. m.AddConditionType(v)
  25724. return nil
  25725. case sopstage.FieldConditionOperator:
  25726. v, ok := value.(int)
  25727. if !ok {
  25728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25729. }
  25730. m.AddConditionOperator(v)
  25731. return nil
  25732. case sopstage.FieldIndexSort:
  25733. v, ok := value.(int)
  25734. if !ok {
  25735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25736. }
  25737. m.AddIndexSort(v)
  25738. return nil
  25739. }
  25740. return fmt.Errorf("unknown SopStage numeric field %s", name)
  25741. }
  25742. // ClearedFields returns all nullable fields that were cleared during this
  25743. // mutation.
  25744. func (m *SopStageMutation) ClearedFields() []string {
  25745. var fields []string
  25746. if m.FieldCleared(sopstage.FieldStatus) {
  25747. fields = append(fields, sopstage.FieldStatus)
  25748. }
  25749. if m.FieldCleared(sopstage.FieldDeletedAt) {
  25750. fields = append(fields, sopstage.FieldDeletedAt)
  25751. }
  25752. if m.FieldCleared(sopstage.FieldActionMessage) {
  25753. fields = append(fields, sopstage.FieldActionMessage)
  25754. }
  25755. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  25756. fields = append(fields, sopstage.FieldActionLabelAdd)
  25757. }
  25758. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  25759. fields = append(fields, sopstage.FieldActionLabelDel)
  25760. }
  25761. if m.FieldCleared(sopstage.FieldActionForward) {
  25762. fields = append(fields, sopstage.FieldActionForward)
  25763. }
  25764. if m.FieldCleared(sopstage.FieldIndexSort) {
  25765. fields = append(fields, sopstage.FieldIndexSort)
  25766. }
  25767. return fields
  25768. }
  25769. // FieldCleared returns a boolean indicating if a field with the given name was
  25770. // cleared in this mutation.
  25771. func (m *SopStageMutation) FieldCleared(name string) bool {
  25772. _, ok := m.clearedFields[name]
  25773. return ok
  25774. }
  25775. // ClearField clears the value of the field with the given name. It returns an
  25776. // error if the field is not defined in the schema.
  25777. func (m *SopStageMutation) ClearField(name string) error {
  25778. switch name {
  25779. case sopstage.FieldStatus:
  25780. m.ClearStatus()
  25781. return nil
  25782. case sopstage.FieldDeletedAt:
  25783. m.ClearDeletedAt()
  25784. return nil
  25785. case sopstage.FieldActionMessage:
  25786. m.ClearActionMessage()
  25787. return nil
  25788. case sopstage.FieldActionLabelAdd:
  25789. m.ClearActionLabelAdd()
  25790. return nil
  25791. case sopstage.FieldActionLabelDel:
  25792. m.ClearActionLabelDel()
  25793. return nil
  25794. case sopstage.FieldActionForward:
  25795. m.ClearActionForward()
  25796. return nil
  25797. case sopstage.FieldIndexSort:
  25798. m.ClearIndexSort()
  25799. return nil
  25800. }
  25801. return fmt.Errorf("unknown SopStage nullable field %s", name)
  25802. }
  25803. // ResetField resets all changes in the mutation for the field with the given name.
  25804. // It returns an error if the field is not defined in the schema.
  25805. func (m *SopStageMutation) ResetField(name string) error {
  25806. switch name {
  25807. case sopstage.FieldCreatedAt:
  25808. m.ResetCreatedAt()
  25809. return nil
  25810. case sopstage.FieldUpdatedAt:
  25811. m.ResetUpdatedAt()
  25812. return nil
  25813. case sopstage.FieldStatus:
  25814. m.ResetStatus()
  25815. return nil
  25816. case sopstage.FieldDeletedAt:
  25817. m.ResetDeletedAt()
  25818. return nil
  25819. case sopstage.FieldTaskID:
  25820. m.ResetTaskID()
  25821. return nil
  25822. case sopstage.FieldName:
  25823. m.ResetName()
  25824. return nil
  25825. case sopstage.FieldConditionType:
  25826. m.ResetConditionType()
  25827. return nil
  25828. case sopstage.FieldConditionOperator:
  25829. m.ResetConditionOperator()
  25830. return nil
  25831. case sopstage.FieldConditionList:
  25832. m.ResetConditionList()
  25833. return nil
  25834. case sopstage.FieldActionMessage:
  25835. m.ResetActionMessage()
  25836. return nil
  25837. case sopstage.FieldActionLabelAdd:
  25838. m.ResetActionLabelAdd()
  25839. return nil
  25840. case sopstage.FieldActionLabelDel:
  25841. m.ResetActionLabelDel()
  25842. return nil
  25843. case sopstage.FieldActionForward:
  25844. m.ResetActionForward()
  25845. return nil
  25846. case sopstage.FieldIndexSort:
  25847. m.ResetIndexSort()
  25848. return nil
  25849. }
  25850. return fmt.Errorf("unknown SopStage field %s", name)
  25851. }
  25852. // AddedEdges returns all edge names that were set/added in this mutation.
  25853. func (m *SopStageMutation) AddedEdges() []string {
  25854. edges := make([]string, 0, 3)
  25855. if m.sop_task != nil {
  25856. edges = append(edges, sopstage.EdgeSopTask)
  25857. }
  25858. if m.stage_nodes != nil {
  25859. edges = append(edges, sopstage.EdgeStageNodes)
  25860. }
  25861. if m.stage_messages != nil {
  25862. edges = append(edges, sopstage.EdgeStageMessages)
  25863. }
  25864. return edges
  25865. }
  25866. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25867. // name in this mutation.
  25868. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  25869. switch name {
  25870. case sopstage.EdgeSopTask:
  25871. if id := m.sop_task; id != nil {
  25872. return []ent.Value{*id}
  25873. }
  25874. case sopstage.EdgeStageNodes:
  25875. ids := make([]ent.Value, 0, len(m.stage_nodes))
  25876. for id := range m.stage_nodes {
  25877. ids = append(ids, id)
  25878. }
  25879. return ids
  25880. case sopstage.EdgeStageMessages:
  25881. ids := make([]ent.Value, 0, len(m.stage_messages))
  25882. for id := range m.stage_messages {
  25883. ids = append(ids, id)
  25884. }
  25885. return ids
  25886. }
  25887. return nil
  25888. }
  25889. // RemovedEdges returns all edge names that were removed in this mutation.
  25890. func (m *SopStageMutation) RemovedEdges() []string {
  25891. edges := make([]string, 0, 3)
  25892. if m.removedstage_nodes != nil {
  25893. edges = append(edges, sopstage.EdgeStageNodes)
  25894. }
  25895. if m.removedstage_messages != nil {
  25896. edges = append(edges, sopstage.EdgeStageMessages)
  25897. }
  25898. return edges
  25899. }
  25900. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25901. // the given name in this mutation.
  25902. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  25903. switch name {
  25904. case sopstage.EdgeStageNodes:
  25905. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  25906. for id := range m.removedstage_nodes {
  25907. ids = append(ids, id)
  25908. }
  25909. return ids
  25910. case sopstage.EdgeStageMessages:
  25911. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  25912. for id := range m.removedstage_messages {
  25913. ids = append(ids, id)
  25914. }
  25915. return ids
  25916. }
  25917. return nil
  25918. }
  25919. // ClearedEdges returns all edge names that were cleared in this mutation.
  25920. func (m *SopStageMutation) ClearedEdges() []string {
  25921. edges := make([]string, 0, 3)
  25922. if m.clearedsop_task {
  25923. edges = append(edges, sopstage.EdgeSopTask)
  25924. }
  25925. if m.clearedstage_nodes {
  25926. edges = append(edges, sopstage.EdgeStageNodes)
  25927. }
  25928. if m.clearedstage_messages {
  25929. edges = append(edges, sopstage.EdgeStageMessages)
  25930. }
  25931. return edges
  25932. }
  25933. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25934. // was cleared in this mutation.
  25935. func (m *SopStageMutation) EdgeCleared(name string) bool {
  25936. switch name {
  25937. case sopstage.EdgeSopTask:
  25938. return m.clearedsop_task
  25939. case sopstage.EdgeStageNodes:
  25940. return m.clearedstage_nodes
  25941. case sopstage.EdgeStageMessages:
  25942. return m.clearedstage_messages
  25943. }
  25944. return false
  25945. }
  25946. // ClearEdge clears the value of the edge with the given name. It returns an error
  25947. // if that edge is not defined in the schema.
  25948. func (m *SopStageMutation) ClearEdge(name string) error {
  25949. switch name {
  25950. case sopstage.EdgeSopTask:
  25951. m.ClearSopTask()
  25952. return nil
  25953. }
  25954. return fmt.Errorf("unknown SopStage unique edge %s", name)
  25955. }
  25956. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25957. // It returns an error if the edge is not defined in the schema.
  25958. func (m *SopStageMutation) ResetEdge(name string) error {
  25959. switch name {
  25960. case sopstage.EdgeSopTask:
  25961. m.ResetSopTask()
  25962. return nil
  25963. case sopstage.EdgeStageNodes:
  25964. m.ResetStageNodes()
  25965. return nil
  25966. case sopstage.EdgeStageMessages:
  25967. m.ResetStageMessages()
  25968. return nil
  25969. }
  25970. return fmt.Errorf("unknown SopStage edge %s", name)
  25971. }
  25972. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  25973. type SopTaskMutation struct {
  25974. config
  25975. op Op
  25976. typ string
  25977. id *uint64
  25978. created_at *time.Time
  25979. updated_at *time.Time
  25980. status *uint8
  25981. addstatus *int8
  25982. deleted_at *time.Time
  25983. name *string
  25984. bot_wxid_list *[]string
  25985. appendbot_wxid_list []string
  25986. _type *int
  25987. add_type *int
  25988. plan_start_time *time.Time
  25989. plan_end_time *time.Time
  25990. creator_id *string
  25991. organization_id *uint64
  25992. addorganization_id *int64
  25993. token *[]string
  25994. appendtoken []string
  25995. clearedFields map[string]struct{}
  25996. task_stages map[uint64]struct{}
  25997. removedtask_stages map[uint64]struct{}
  25998. clearedtask_stages bool
  25999. done bool
  26000. oldValue func(context.Context) (*SopTask, error)
  26001. predicates []predicate.SopTask
  26002. }
  26003. var _ ent.Mutation = (*SopTaskMutation)(nil)
  26004. // soptaskOption allows management of the mutation configuration using functional options.
  26005. type soptaskOption func(*SopTaskMutation)
  26006. // newSopTaskMutation creates new mutation for the SopTask entity.
  26007. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  26008. m := &SopTaskMutation{
  26009. config: c,
  26010. op: op,
  26011. typ: TypeSopTask,
  26012. clearedFields: make(map[string]struct{}),
  26013. }
  26014. for _, opt := range opts {
  26015. opt(m)
  26016. }
  26017. return m
  26018. }
  26019. // withSopTaskID sets the ID field of the mutation.
  26020. func withSopTaskID(id uint64) soptaskOption {
  26021. return func(m *SopTaskMutation) {
  26022. var (
  26023. err error
  26024. once sync.Once
  26025. value *SopTask
  26026. )
  26027. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  26028. once.Do(func() {
  26029. if m.done {
  26030. err = errors.New("querying old values post mutation is not allowed")
  26031. } else {
  26032. value, err = m.Client().SopTask.Get(ctx, id)
  26033. }
  26034. })
  26035. return value, err
  26036. }
  26037. m.id = &id
  26038. }
  26039. }
  26040. // withSopTask sets the old SopTask of the mutation.
  26041. func withSopTask(node *SopTask) soptaskOption {
  26042. return func(m *SopTaskMutation) {
  26043. m.oldValue = func(context.Context) (*SopTask, error) {
  26044. return node, nil
  26045. }
  26046. m.id = &node.ID
  26047. }
  26048. }
  26049. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26050. // executed in a transaction (ent.Tx), a transactional client is returned.
  26051. func (m SopTaskMutation) Client() *Client {
  26052. client := &Client{config: m.config}
  26053. client.init()
  26054. return client
  26055. }
  26056. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26057. // it returns an error otherwise.
  26058. func (m SopTaskMutation) Tx() (*Tx, error) {
  26059. if _, ok := m.driver.(*txDriver); !ok {
  26060. return nil, errors.New("ent: mutation is not running in a transaction")
  26061. }
  26062. tx := &Tx{config: m.config}
  26063. tx.init()
  26064. return tx, nil
  26065. }
  26066. // SetID sets the value of the id field. Note that this
  26067. // operation is only accepted on creation of SopTask entities.
  26068. func (m *SopTaskMutation) SetID(id uint64) {
  26069. m.id = &id
  26070. }
  26071. // ID returns the ID value in the mutation. Note that the ID is only available
  26072. // if it was provided to the builder or after it was returned from the database.
  26073. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  26074. if m.id == nil {
  26075. return
  26076. }
  26077. return *m.id, true
  26078. }
  26079. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26080. // That means, if the mutation is applied within a transaction with an isolation level such
  26081. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26082. // or updated by the mutation.
  26083. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  26084. switch {
  26085. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26086. id, exists := m.ID()
  26087. if exists {
  26088. return []uint64{id}, nil
  26089. }
  26090. fallthrough
  26091. case m.op.Is(OpUpdate | OpDelete):
  26092. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  26093. default:
  26094. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26095. }
  26096. }
  26097. // SetCreatedAt sets the "created_at" field.
  26098. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  26099. m.created_at = &t
  26100. }
  26101. // CreatedAt returns the value of the "created_at" field in the mutation.
  26102. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  26103. v := m.created_at
  26104. if v == nil {
  26105. return
  26106. }
  26107. return *v, true
  26108. }
  26109. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  26110. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26112. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26113. if !m.op.Is(OpUpdateOne) {
  26114. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26115. }
  26116. if m.id == nil || m.oldValue == nil {
  26117. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26118. }
  26119. oldValue, err := m.oldValue(ctx)
  26120. if err != nil {
  26121. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26122. }
  26123. return oldValue.CreatedAt, nil
  26124. }
  26125. // ResetCreatedAt resets all changes to the "created_at" field.
  26126. func (m *SopTaskMutation) ResetCreatedAt() {
  26127. m.created_at = nil
  26128. }
  26129. // SetUpdatedAt sets the "updated_at" field.
  26130. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  26131. m.updated_at = &t
  26132. }
  26133. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26134. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  26135. v := m.updated_at
  26136. if v == nil {
  26137. return
  26138. }
  26139. return *v, true
  26140. }
  26141. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  26142. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26144. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26145. if !m.op.Is(OpUpdateOne) {
  26146. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26147. }
  26148. if m.id == nil || m.oldValue == nil {
  26149. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26150. }
  26151. oldValue, err := m.oldValue(ctx)
  26152. if err != nil {
  26153. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26154. }
  26155. return oldValue.UpdatedAt, nil
  26156. }
  26157. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26158. func (m *SopTaskMutation) ResetUpdatedAt() {
  26159. m.updated_at = nil
  26160. }
  26161. // SetStatus sets the "status" field.
  26162. func (m *SopTaskMutation) SetStatus(u uint8) {
  26163. m.status = &u
  26164. m.addstatus = nil
  26165. }
  26166. // Status returns the value of the "status" field in the mutation.
  26167. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  26168. v := m.status
  26169. if v == nil {
  26170. return
  26171. }
  26172. return *v, true
  26173. }
  26174. // OldStatus returns the old "status" field's value of the SopTask entity.
  26175. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26177. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26178. if !m.op.Is(OpUpdateOne) {
  26179. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26180. }
  26181. if m.id == nil || m.oldValue == nil {
  26182. return v, errors.New("OldStatus requires an ID field in the mutation")
  26183. }
  26184. oldValue, err := m.oldValue(ctx)
  26185. if err != nil {
  26186. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26187. }
  26188. return oldValue.Status, nil
  26189. }
  26190. // AddStatus adds u to the "status" field.
  26191. func (m *SopTaskMutation) AddStatus(u int8) {
  26192. if m.addstatus != nil {
  26193. *m.addstatus += u
  26194. } else {
  26195. m.addstatus = &u
  26196. }
  26197. }
  26198. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26199. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  26200. v := m.addstatus
  26201. if v == nil {
  26202. return
  26203. }
  26204. return *v, true
  26205. }
  26206. // ClearStatus clears the value of the "status" field.
  26207. func (m *SopTaskMutation) ClearStatus() {
  26208. m.status = nil
  26209. m.addstatus = nil
  26210. m.clearedFields[soptask.FieldStatus] = struct{}{}
  26211. }
  26212. // StatusCleared returns if the "status" field was cleared in this mutation.
  26213. func (m *SopTaskMutation) StatusCleared() bool {
  26214. _, ok := m.clearedFields[soptask.FieldStatus]
  26215. return ok
  26216. }
  26217. // ResetStatus resets all changes to the "status" field.
  26218. func (m *SopTaskMutation) ResetStatus() {
  26219. m.status = nil
  26220. m.addstatus = nil
  26221. delete(m.clearedFields, soptask.FieldStatus)
  26222. }
  26223. // SetDeletedAt sets the "deleted_at" field.
  26224. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  26225. m.deleted_at = &t
  26226. }
  26227. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26228. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  26229. v := m.deleted_at
  26230. if v == nil {
  26231. return
  26232. }
  26233. return *v, true
  26234. }
  26235. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  26236. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26238. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26239. if !m.op.Is(OpUpdateOne) {
  26240. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26241. }
  26242. if m.id == nil || m.oldValue == nil {
  26243. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26244. }
  26245. oldValue, err := m.oldValue(ctx)
  26246. if err != nil {
  26247. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26248. }
  26249. return oldValue.DeletedAt, nil
  26250. }
  26251. // ClearDeletedAt clears the value of the "deleted_at" field.
  26252. func (m *SopTaskMutation) ClearDeletedAt() {
  26253. m.deleted_at = nil
  26254. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  26255. }
  26256. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26257. func (m *SopTaskMutation) DeletedAtCleared() bool {
  26258. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  26259. return ok
  26260. }
  26261. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26262. func (m *SopTaskMutation) ResetDeletedAt() {
  26263. m.deleted_at = nil
  26264. delete(m.clearedFields, soptask.FieldDeletedAt)
  26265. }
  26266. // SetName sets the "name" field.
  26267. func (m *SopTaskMutation) SetName(s string) {
  26268. m.name = &s
  26269. }
  26270. // Name returns the value of the "name" field in the mutation.
  26271. func (m *SopTaskMutation) Name() (r string, exists bool) {
  26272. v := m.name
  26273. if v == nil {
  26274. return
  26275. }
  26276. return *v, true
  26277. }
  26278. // OldName returns the old "name" field's value of the SopTask entity.
  26279. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26281. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  26282. if !m.op.Is(OpUpdateOne) {
  26283. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26284. }
  26285. if m.id == nil || m.oldValue == nil {
  26286. return v, errors.New("OldName requires an ID field in the mutation")
  26287. }
  26288. oldValue, err := m.oldValue(ctx)
  26289. if err != nil {
  26290. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26291. }
  26292. return oldValue.Name, nil
  26293. }
  26294. // ResetName resets all changes to the "name" field.
  26295. func (m *SopTaskMutation) ResetName() {
  26296. m.name = nil
  26297. }
  26298. // SetBotWxidList sets the "bot_wxid_list" field.
  26299. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  26300. m.bot_wxid_list = &s
  26301. m.appendbot_wxid_list = nil
  26302. }
  26303. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  26304. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  26305. v := m.bot_wxid_list
  26306. if v == nil {
  26307. return
  26308. }
  26309. return *v, true
  26310. }
  26311. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  26312. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26314. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  26315. if !m.op.Is(OpUpdateOne) {
  26316. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  26317. }
  26318. if m.id == nil || m.oldValue == nil {
  26319. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  26320. }
  26321. oldValue, err := m.oldValue(ctx)
  26322. if err != nil {
  26323. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  26324. }
  26325. return oldValue.BotWxidList, nil
  26326. }
  26327. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  26328. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  26329. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  26330. }
  26331. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  26332. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  26333. if len(m.appendbot_wxid_list) == 0 {
  26334. return nil, false
  26335. }
  26336. return m.appendbot_wxid_list, true
  26337. }
  26338. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  26339. func (m *SopTaskMutation) ClearBotWxidList() {
  26340. m.bot_wxid_list = nil
  26341. m.appendbot_wxid_list = nil
  26342. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  26343. }
  26344. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  26345. func (m *SopTaskMutation) BotWxidListCleared() bool {
  26346. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  26347. return ok
  26348. }
  26349. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  26350. func (m *SopTaskMutation) ResetBotWxidList() {
  26351. m.bot_wxid_list = nil
  26352. m.appendbot_wxid_list = nil
  26353. delete(m.clearedFields, soptask.FieldBotWxidList)
  26354. }
  26355. // SetType sets the "type" field.
  26356. func (m *SopTaskMutation) SetType(i int) {
  26357. m._type = &i
  26358. m.add_type = nil
  26359. }
  26360. // GetType returns the value of the "type" field in the mutation.
  26361. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  26362. v := m._type
  26363. if v == nil {
  26364. return
  26365. }
  26366. return *v, true
  26367. }
  26368. // OldType returns the old "type" field's value of the SopTask entity.
  26369. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26371. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  26372. if !m.op.Is(OpUpdateOne) {
  26373. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26374. }
  26375. if m.id == nil || m.oldValue == nil {
  26376. return v, errors.New("OldType requires an ID field in the mutation")
  26377. }
  26378. oldValue, err := m.oldValue(ctx)
  26379. if err != nil {
  26380. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26381. }
  26382. return oldValue.Type, nil
  26383. }
  26384. // AddType adds i to the "type" field.
  26385. func (m *SopTaskMutation) AddType(i int) {
  26386. if m.add_type != nil {
  26387. *m.add_type += i
  26388. } else {
  26389. m.add_type = &i
  26390. }
  26391. }
  26392. // AddedType returns the value that was added to the "type" field in this mutation.
  26393. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  26394. v := m.add_type
  26395. if v == nil {
  26396. return
  26397. }
  26398. return *v, true
  26399. }
  26400. // ResetType resets all changes to the "type" field.
  26401. func (m *SopTaskMutation) ResetType() {
  26402. m._type = nil
  26403. m.add_type = nil
  26404. }
  26405. // SetPlanStartTime sets the "plan_start_time" field.
  26406. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  26407. m.plan_start_time = &t
  26408. }
  26409. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  26410. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  26411. v := m.plan_start_time
  26412. if v == nil {
  26413. return
  26414. }
  26415. return *v, true
  26416. }
  26417. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  26418. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26420. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  26421. if !m.op.Is(OpUpdateOne) {
  26422. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  26423. }
  26424. if m.id == nil || m.oldValue == nil {
  26425. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  26426. }
  26427. oldValue, err := m.oldValue(ctx)
  26428. if err != nil {
  26429. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  26430. }
  26431. return oldValue.PlanStartTime, nil
  26432. }
  26433. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  26434. func (m *SopTaskMutation) ClearPlanStartTime() {
  26435. m.plan_start_time = nil
  26436. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  26437. }
  26438. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  26439. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  26440. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  26441. return ok
  26442. }
  26443. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  26444. func (m *SopTaskMutation) ResetPlanStartTime() {
  26445. m.plan_start_time = nil
  26446. delete(m.clearedFields, soptask.FieldPlanStartTime)
  26447. }
  26448. // SetPlanEndTime sets the "plan_end_time" field.
  26449. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  26450. m.plan_end_time = &t
  26451. }
  26452. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  26453. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  26454. v := m.plan_end_time
  26455. if v == nil {
  26456. return
  26457. }
  26458. return *v, true
  26459. }
  26460. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  26461. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26463. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  26464. if !m.op.Is(OpUpdateOne) {
  26465. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  26466. }
  26467. if m.id == nil || m.oldValue == nil {
  26468. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  26469. }
  26470. oldValue, err := m.oldValue(ctx)
  26471. if err != nil {
  26472. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  26473. }
  26474. return oldValue.PlanEndTime, nil
  26475. }
  26476. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  26477. func (m *SopTaskMutation) ClearPlanEndTime() {
  26478. m.plan_end_time = nil
  26479. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  26480. }
  26481. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  26482. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  26483. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  26484. return ok
  26485. }
  26486. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  26487. func (m *SopTaskMutation) ResetPlanEndTime() {
  26488. m.plan_end_time = nil
  26489. delete(m.clearedFields, soptask.FieldPlanEndTime)
  26490. }
  26491. // SetCreatorID sets the "creator_id" field.
  26492. func (m *SopTaskMutation) SetCreatorID(s string) {
  26493. m.creator_id = &s
  26494. }
  26495. // CreatorID returns the value of the "creator_id" field in the mutation.
  26496. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  26497. v := m.creator_id
  26498. if v == nil {
  26499. return
  26500. }
  26501. return *v, true
  26502. }
  26503. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  26504. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26506. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  26507. if !m.op.Is(OpUpdateOne) {
  26508. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  26509. }
  26510. if m.id == nil || m.oldValue == nil {
  26511. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  26512. }
  26513. oldValue, err := m.oldValue(ctx)
  26514. if err != nil {
  26515. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  26516. }
  26517. return oldValue.CreatorID, nil
  26518. }
  26519. // ClearCreatorID clears the value of the "creator_id" field.
  26520. func (m *SopTaskMutation) ClearCreatorID() {
  26521. m.creator_id = nil
  26522. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  26523. }
  26524. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  26525. func (m *SopTaskMutation) CreatorIDCleared() bool {
  26526. _, ok := m.clearedFields[soptask.FieldCreatorID]
  26527. return ok
  26528. }
  26529. // ResetCreatorID resets all changes to the "creator_id" field.
  26530. func (m *SopTaskMutation) ResetCreatorID() {
  26531. m.creator_id = nil
  26532. delete(m.clearedFields, soptask.FieldCreatorID)
  26533. }
  26534. // SetOrganizationID sets the "organization_id" field.
  26535. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  26536. m.organization_id = &u
  26537. m.addorganization_id = nil
  26538. }
  26539. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26540. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  26541. v := m.organization_id
  26542. if v == nil {
  26543. return
  26544. }
  26545. return *v, true
  26546. }
  26547. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  26548. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26550. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26551. if !m.op.Is(OpUpdateOne) {
  26552. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26553. }
  26554. if m.id == nil || m.oldValue == nil {
  26555. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26556. }
  26557. oldValue, err := m.oldValue(ctx)
  26558. if err != nil {
  26559. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26560. }
  26561. return oldValue.OrganizationID, nil
  26562. }
  26563. // AddOrganizationID adds u to the "organization_id" field.
  26564. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  26565. if m.addorganization_id != nil {
  26566. *m.addorganization_id += u
  26567. } else {
  26568. m.addorganization_id = &u
  26569. }
  26570. }
  26571. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26572. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  26573. v := m.addorganization_id
  26574. if v == nil {
  26575. return
  26576. }
  26577. return *v, true
  26578. }
  26579. // ClearOrganizationID clears the value of the "organization_id" field.
  26580. func (m *SopTaskMutation) ClearOrganizationID() {
  26581. m.organization_id = nil
  26582. m.addorganization_id = nil
  26583. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  26584. }
  26585. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  26586. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  26587. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  26588. return ok
  26589. }
  26590. // ResetOrganizationID resets all changes to the "organization_id" field.
  26591. func (m *SopTaskMutation) ResetOrganizationID() {
  26592. m.organization_id = nil
  26593. m.addorganization_id = nil
  26594. delete(m.clearedFields, soptask.FieldOrganizationID)
  26595. }
  26596. // SetToken sets the "token" field.
  26597. func (m *SopTaskMutation) SetToken(s []string) {
  26598. m.token = &s
  26599. m.appendtoken = nil
  26600. }
  26601. // Token returns the value of the "token" field in the mutation.
  26602. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  26603. v := m.token
  26604. if v == nil {
  26605. return
  26606. }
  26607. return *v, true
  26608. }
  26609. // OldToken returns the old "token" field's value of the SopTask entity.
  26610. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26612. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  26613. if !m.op.Is(OpUpdateOne) {
  26614. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26615. }
  26616. if m.id == nil || m.oldValue == nil {
  26617. return v, errors.New("OldToken requires an ID field in the mutation")
  26618. }
  26619. oldValue, err := m.oldValue(ctx)
  26620. if err != nil {
  26621. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26622. }
  26623. return oldValue.Token, nil
  26624. }
  26625. // AppendToken adds s to the "token" field.
  26626. func (m *SopTaskMutation) AppendToken(s []string) {
  26627. m.appendtoken = append(m.appendtoken, s...)
  26628. }
  26629. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  26630. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  26631. if len(m.appendtoken) == 0 {
  26632. return nil, false
  26633. }
  26634. return m.appendtoken, true
  26635. }
  26636. // ClearToken clears the value of the "token" field.
  26637. func (m *SopTaskMutation) ClearToken() {
  26638. m.token = nil
  26639. m.appendtoken = nil
  26640. m.clearedFields[soptask.FieldToken] = struct{}{}
  26641. }
  26642. // TokenCleared returns if the "token" field was cleared in this mutation.
  26643. func (m *SopTaskMutation) TokenCleared() bool {
  26644. _, ok := m.clearedFields[soptask.FieldToken]
  26645. return ok
  26646. }
  26647. // ResetToken resets all changes to the "token" field.
  26648. func (m *SopTaskMutation) ResetToken() {
  26649. m.token = nil
  26650. m.appendtoken = nil
  26651. delete(m.clearedFields, soptask.FieldToken)
  26652. }
  26653. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  26654. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  26655. if m.task_stages == nil {
  26656. m.task_stages = make(map[uint64]struct{})
  26657. }
  26658. for i := range ids {
  26659. m.task_stages[ids[i]] = struct{}{}
  26660. }
  26661. }
  26662. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  26663. func (m *SopTaskMutation) ClearTaskStages() {
  26664. m.clearedtask_stages = true
  26665. }
  26666. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  26667. func (m *SopTaskMutation) TaskStagesCleared() bool {
  26668. return m.clearedtask_stages
  26669. }
  26670. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  26671. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  26672. if m.removedtask_stages == nil {
  26673. m.removedtask_stages = make(map[uint64]struct{})
  26674. }
  26675. for i := range ids {
  26676. delete(m.task_stages, ids[i])
  26677. m.removedtask_stages[ids[i]] = struct{}{}
  26678. }
  26679. }
  26680. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  26681. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  26682. for id := range m.removedtask_stages {
  26683. ids = append(ids, id)
  26684. }
  26685. return
  26686. }
  26687. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  26688. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  26689. for id := range m.task_stages {
  26690. ids = append(ids, id)
  26691. }
  26692. return
  26693. }
  26694. // ResetTaskStages resets all changes to the "task_stages" edge.
  26695. func (m *SopTaskMutation) ResetTaskStages() {
  26696. m.task_stages = nil
  26697. m.clearedtask_stages = false
  26698. m.removedtask_stages = nil
  26699. }
  26700. // Where appends a list predicates to the SopTaskMutation builder.
  26701. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  26702. m.predicates = append(m.predicates, ps...)
  26703. }
  26704. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  26705. // users can use type-assertion to append predicates that do not depend on any generated package.
  26706. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  26707. p := make([]predicate.SopTask, len(ps))
  26708. for i := range ps {
  26709. p[i] = ps[i]
  26710. }
  26711. m.Where(p...)
  26712. }
  26713. // Op returns the operation name.
  26714. func (m *SopTaskMutation) Op() Op {
  26715. return m.op
  26716. }
  26717. // SetOp allows setting the mutation operation.
  26718. func (m *SopTaskMutation) SetOp(op Op) {
  26719. m.op = op
  26720. }
  26721. // Type returns the node type of this mutation (SopTask).
  26722. func (m *SopTaskMutation) Type() string {
  26723. return m.typ
  26724. }
  26725. // Fields returns all fields that were changed during this mutation. Note that in
  26726. // order to get all numeric fields that were incremented/decremented, call
  26727. // AddedFields().
  26728. func (m *SopTaskMutation) Fields() []string {
  26729. fields := make([]string, 0, 12)
  26730. if m.created_at != nil {
  26731. fields = append(fields, soptask.FieldCreatedAt)
  26732. }
  26733. if m.updated_at != nil {
  26734. fields = append(fields, soptask.FieldUpdatedAt)
  26735. }
  26736. if m.status != nil {
  26737. fields = append(fields, soptask.FieldStatus)
  26738. }
  26739. if m.deleted_at != nil {
  26740. fields = append(fields, soptask.FieldDeletedAt)
  26741. }
  26742. if m.name != nil {
  26743. fields = append(fields, soptask.FieldName)
  26744. }
  26745. if m.bot_wxid_list != nil {
  26746. fields = append(fields, soptask.FieldBotWxidList)
  26747. }
  26748. if m._type != nil {
  26749. fields = append(fields, soptask.FieldType)
  26750. }
  26751. if m.plan_start_time != nil {
  26752. fields = append(fields, soptask.FieldPlanStartTime)
  26753. }
  26754. if m.plan_end_time != nil {
  26755. fields = append(fields, soptask.FieldPlanEndTime)
  26756. }
  26757. if m.creator_id != nil {
  26758. fields = append(fields, soptask.FieldCreatorID)
  26759. }
  26760. if m.organization_id != nil {
  26761. fields = append(fields, soptask.FieldOrganizationID)
  26762. }
  26763. if m.token != nil {
  26764. fields = append(fields, soptask.FieldToken)
  26765. }
  26766. return fields
  26767. }
  26768. // Field returns the value of a field with the given name. The second boolean
  26769. // return value indicates that this field was not set, or was not defined in the
  26770. // schema.
  26771. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  26772. switch name {
  26773. case soptask.FieldCreatedAt:
  26774. return m.CreatedAt()
  26775. case soptask.FieldUpdatedAt:
  26776. return m.UpdatedAt()
  26777. case soptask.FieldStatus:
  26778. return m.Status()
  26779. case soptask.FieldDeletedAt:
  26780. return m.DeletedAt()
  26781. case soptask.FieldName:
  26782. return m.Name()
  26783. case soptask.FieldBotWxidList:
  26784. return m.BotWxidList()
  26785. case soptask.FieldType:
  26786. return m.GetType()
  26787. case soptask.FieldPlanStartTime:
  26788. return m.PlanStartTime()
  26789. case soptask.FieldPlanEndTime:
  26790. return m.PlanEndTime()
  26791. case soptask.FieldCreatorID:
  26792. return m.CreatorID()
  26793. case soptask.FieldOrganizationID:
  26794. return m.OrganizationID()
  26795. case soptask.FieldToken:
  26796. return m.Token()
  26797. }
  26798. return nil, false
  26799. }
  26800. // OldField returns the old value of the field from the database. An error is
  26801. // returned if the mutation operation is not UpdateOne, or the query to the
  26802. // database failed.
  26803. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26804. switch name {
  26805. case soptask.FieldCreatedAt:
  26806. return m.OldCreatedAt(ctx)
  26807. case soptask.FieldUpdatedAt:
  26808. return m.OldUpdatedAt(ctx)
  26809. case soptask.FieldStatus:
  26810. return m.OldStatus(ctx)
  26811. case soptask.FieldDeletedAt:
  26812. return m.OldDeletedAt(ctx)
  26813. case soptask.FieldName:
  26814. return m.OldName(ctx)
  26815. case soptask.FieldBotWxidList:
  26816. return m.OldBotWxidList(ctx)
  26817. case soptask.FieldType:
  26818. return m.OldType(ctx)
  26819. case soptask.FieldPlanStartTime:
  26820. return m.OldPlanStartTime(ctx)
  26821. case soptask.FieldPlanEndTime:
  26822. return m.OldPlanEndTime(ctx)
  26823. case soptask.FieldCreatorID:
  26824. return m.OldCreatorID(ctx)
  26825. case soptask.FieldOrganizationID:
  26826. return m.OldOrganizationID(ctx)
  26827. case soptask.FieldToken:
  26828. return m.OldToken(ctx)
  26829. }
  26830. return nil, fmt.Errorf("unknown SopTask field %s", name)
  26831. }
  26832. // SetField sets the value of a field with the given name. It returns an error if
  26833. // the field is not defined in the schema, or if the type mismatched the field
  26834. // type.
  26835. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  26836. switch name {
  26837. case soptask.FieldCreatedAt:
  26838. v, ok := value.(time.Time)
  26839. if !ok {
  26840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26841. }
  26842. m.SetCreatedAt(v)
  26843. return nil
  26844. case soptask.FieldUpdatedAt:
  26845. v, ok := value.(time.Time)
  26846. if !ok {
  26847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26848. }
  26849. m.SetUpdatedAt(v)
  26850. return nil
  26851. case soptask.FieldStatus:
  26852. v, ok := value.(uint8)
  26853. if !ok {
  26854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26855. }
  26856. m.SetStatus(v)
  26857. return nil
  26858. case soptask.FieldDeletedAt:
  26859. v, ok := value.(time.Time)
  26860. if !ok {
  26861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26862. }
  26863. m.SetDeletedAt(v)
  26864. return nil
  26865. case soptask.FieldName:
  26866. v, ok := value.(string)
  26867. if !ok {
  26868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26869. }
  26870. m.SetName(v)
  26871. return nil
  26872. case soptask.FieldBotWxidList:
  26873. v, ok := value.([]string)
  26874. if !ok {
  26875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26876. }
  26877. m.SetBotWxidList(v)
  26878. return nil
  26879. case soptask.FieldType:
  26880. v, ok := value.(int)
  26881. if !ok {
  26882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26883. }
  26884. m.SetType(v)
  26885. return nil
  26886. case soptask.FieldPlanStartTime:
  26887. v, ok := value.(time.Time)
  26888. if !ok {
  26889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26890. }
  26891. m.SetPlanStartTime(v)
  26892. return nil
  26893. case soptask.FieldPlanEndTime:
  26894. v, ok := value.(time.Time)
  26895. if !ok {
  26896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26897. }
  26898. m.SetPlanEndTime(v)
  26899. return nil
  26900. case soptask.FieldCreatorID:
  26901. v, ok := value.(string)
  26902. if !ok {
  26903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26904. }
  26905. m.SetCreatorID(v)
  26906. return nil
  26907. case soptask.FieldOrganizationID:
  26908. v, ok := value.(uint64)
  26909. if !ok {
  26910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26911. }
  26912. m.SetOrganizationID(v)
  26913. return nil
  26914. case soptask.FieldToken:
  26915. v, ok := value.([]string)
  26916. if !ok {
  26917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26918. }
  26919. m.SetToken(v)
  26920. return nil
  26921. }
  26922. return fmt.Errorf("unknown SopTask field %s", name)
  26923. }
  26924. // AddedFields returns all numeric fields that were incremented/decremented during
  26925. // this mutation.
  26926. func (m *SopTaskMutation) AddedFields() []string {
  26927. var fields []string
  26928. if m.addstatus != nil {
  26929. fields = append(fields, soptask.FieldStatus)
  26930. }
  26931. if m.add_type != nil {
  26932. fields = append(fields, soptask.FieldType)
  26933. }
  26934. if m.addorganization_id != nil {
  26935. fields = append(fields, soptask.FieldOrganizationID)
  26936. }
  26937. return fields
  26938. }
  26939. // AddedField returns the numeric value that was incremented/decremented on a field
  26940. // with the given name. The second boolean return value indicates that this field
  26941. // was not set, or was not defined in the schema.
  26942. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  26943. switch name {
  26944. case soptask.FieldStatus:
  26945. return m.AddedStatus()
  26946. case soptask.FieldType:
  26947. return m.AddedType()
  26948. case soptask.FieldOrganizationID:
  26949. return m.AddedOrganizationID()
  26950. }
  26951. return nil, false
  26952. }
  26953. // AddField adds the value to the field with the given name. It returns an error if
  26954. // the field is not defined in the schema, or if the type mismatched the field
  26955. // type.
  26956. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  26957. switch name {
  26958. case soptask.FieldStatus:
  26959. v, ok := value.(int8)
  26960. if !ok {
  26961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26962. }
  26963. m.AddStatus(v)
  26964. return nil
  26965. case soptask.FieldType:
  26966. v, ok := value.(int)
  26967. if !ok {
  26968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26969. }
  26970. m.AddType(v)
  26971. return nil
  26972. case soptask.FieldOrganizationID:
  26973. v, ok := value.(int64)
  26974. if !ok {
  26975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26976. }
  26977. m.AddOrganizationID(v)
  26978. return nil
  26979. }
  26980. return fmt.Errorf("unknown SopTask numeric field %s", name)
  26981. }
  26982. // ClearedFields returns all nullable fields that were cleared during this
  26983. // mutation.
  26984. func (m *SopTaskMutation) ClearedFields() []string {
  26985. var fields []string
  26986. if m.FieldCleared(soptask.FieldStatus) {
  26987. fields = append(fields, soptask.FieldStatus)
  26988. }
  26989. if m.FieldCleared(soptask.FieldDeletedAt) {
  26990. fields = append(fields, soptask.FieldDeletedAt)
  26991. }
  26992. if m.FieldCleared(soptask.FieldBotWxidList) {
  26993. fields = append(fields, soptask.FieldBotWxidList)
  26994. }
  26995. if m.FieldCleared(soptask.FieldPlanStartTime) {
  26996. fields = append(fields, soptask.FieldPlanStartTime)
  26997. }
  26998. if m.FieldCleared(soptask.FieldPlanEndTime) {
  26999. fields = append(fields, soptask.FieldPlanEndTime)
  27000. }
  27001. if m.FieldCleared(soptask.FieldCreatorID) {
  27002. fields = append(fields, soptask.FieldCreatorID)
  27003. }
  27004. if m.FieldCleared(soptask.FieldOrganizationID) {
  27005. fields = append(fields, soptask.FieldOrganizationID)
  27006. }
  27007. if m.FieldCleared(soptask.FieldToken) {
  27008. fields = append(fields, soptask.FieldToken)
  27009. }
  27010. return fields
  27011. }
  27012. // FieldCleared returns a boolean indicating if a field with the given name was
  27013. // cleared in this mutation.
  27014. func (m *SopTaskMutation) FieldCleared(name string) bool {
  27015. _, ok := m.clearedFields[name]
  27016. return ok
  27017. }
  27018. // ClearField clears the value of the field with the given name. It returns an
  27019. // error if the field is not defined in the schema.
  27020. func (m *SopTaskMutation) ClearField(name string) error {
  27021. switch name {
  27022. case soptask.FieldStatus:
  27023. m.ClearStatus()
  27024. return nil
  27025. case soptask.FieldDeletedAt:
  27026. m.ClearDeletedAt()
  27027. return nil
  27028. case soptask.FieldBotWxidList:
  27029. m.ClearBotWxidList()
  27030. return nil
  27031. case soptask.FieldPlanStartTime:
  27032. m.ClearPlanStartTime()
  27033. return nil
  27034. case soptask.FieldPlanEndTime:
  27035. m.ClearPlanEndTime()
  27036. return nil
  27037. case soptask.FieldCreatorID:
  27038. m.ClearCreatorID()
  27039. return nil
  27040. case soptask.FieldOrganizationID:
  27041. m.ClearOrganizationID()
  27042. return nil
  27043. case soptask.FieldToken:
  27044. m.ClearToken()
  27045. return nil
  27046. }
  27047. return fmt.Errorf("unknown SopTask nullable field %s", name)
  27048. }
  27049. // ResetField resets all changes in the mutation for the field with the given name.
  27050. // It returns an error if the field is not defined in the schema.
  27051. func (m *SopTaskMutation) ResetField(name string) error {
  27052. switch name {
  27053. case soptask.FieldCreatedAt:
  27054. m.ResetCreatedAt()
  27055. return nil
  27056. case soptask.FieldUpdatedAt:
  27057. m.ResetUpdatedAt()
  27058. return nil
  27059. case soptask.FieldStatus:
  27060. m.ResetStatus()
  27061. return nil
  27062. case soptask.FieldDeletedAt:
  27063. m.ResetDeletedAt()
  27064. return nil
  27065. case soptask.FieldName:
  27066. m.ResetName()
  27067. return nil
  27068. case soptask.FieldBotWxidList:
  27069. m.ResetBotWxidList()
  27070. return nil
  27071. case soptask.FieldType:
  27072. m.ResetType()
  27073. return nil
  27074. case soptask.FieldPlanStartTime:
  27075. m.ResetPlanStartTime()
  27076. return nil
  27077. case soptask.FieldPlanEndTime:
  27078. m.ResetPlanEndTime()
  27079. return nil
  27080. case soptask.FieldCreatorID:
  27081. m.ResetCreatorID()
  27082. return nil
  27083. case soptask.FieldOrganizationID:
  27084. m.ResetOrganizationID()
  27085. return nil
  27086. case soptask.FieldToken:
  27087. m.ResetToken()
  27088. return nil
  27089. }
  27090. return fmt.Errorf("unknown SopTask field %s", name)
  27091. }
  27092. // AddedEdges returns all edge names that were set/added in this mutation.
  27093. func (m *SopTaskMutation) AddedEdges() []string {
  27094. edges := make([]string, 0, 1)
  27095. if m.task_stages != nil {
  27096. edges = append(edges, soptask.EdgeTaskStages)
  27097. }
  27098. return edges
  27099. }
  27100. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27101. // name in this mutation.
  27102. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  27103. switch name {
  27104. case soptask.EdgeTaskStages:
  27105. ids := make([]ent.Value, 0, len(m.task_stages))
  27106. for id := range m.task_stages {
  27107. ids = append(ids, id)
  27108. }
  27109. return ids
  27110. }
  27111. return nil
  27112. }
  27113. // RemovedEdges returns all edge names that were removed in this mutation.
  27114. func (m *SopTaskMutation) RemovedEdges() []string {
  27115. edges := make([]string, 0, 1)
  27116. if m.removedtask_stages != nil {
  27117. edges = append(edges, soptask.EdgeTaskStages)
  27118. }
  27119. return edges
  27120. }
  27121. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27122. // the given name in this mutation.
  27123. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  27124. switch name {
  27125. case soptask.EdgeTaskStages:
  27126. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  27127. for id := range m.removedtask_stages {
  27128. ids = append(ids, id)
  27129. }
  27130. return ids
  27131. }
  27132. return nil
  27133. }
  27134. // ClearedEdges returns all edge names that were cleared in this mutation.
  27135. func (m *SopTaskMutation) ClearedEdges() []string {
  27136. edges := make([]string, 0, 1)
  27137. if m.clearedtask_stages {
  27138. edges = append(edges, soptask.EdgeTaskStages)
  27139. }
  27140. return edges
  27141. }
  27142. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27143. // was cleared in this mutation.
  27144. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  27145. switch name {
  27146. case soptask.EdgeTaskStages:
  27147. return m.clearedtask_stages
  27148. }
  27149. return false
  27150. }
  27151. // ClearEdge clears the value of the edge with the given name. It returns an error
  27152. // if that edge is not defined in the schema.
  27153. func (m *SopTaskMutation) ClearEdge(name string) error {
  27154. switch name {
  27155. }
  27156. return fmt.Errorf("unknown SopTask unique edge %s", name)
  27157. }
  27158. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27159. // It returns an error if the edge is not defined in the schema.
  27160. func (m *SopTaskMutation) ResetEdge(name string) error {
  27161. switch name {
  27162. case soptask.EdgeTaskStages:
  27163. m.ResetTaskStages()
  27164. return nil
  27165. }
  27166. return fmt.Errorf("unknown SopTask edge %s", name)
  27167. }
  27168. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  27169. type TokenMutation struct {
  27170. config
  27171. op Op
  27172. typ string
  27173. id *uint64
  27174. created_at *time.Time
  27175. updated_at *time.Time
  27176. deleted_at *time.Time
  27177. expire_at *time.Time
  27178. token *string
  27179. mac *string
  27180. organization_id *uint64
  27181. addorganization_id *int64
  27182. custom_agent_base *string
  27183. custom_agent_key *string
  27184. openai_base *string
  27185. openai_key *string
  27186. clearedFields map[string]struct{}
  27187. agent *uint64
  27188. clearedagent bool
  27189. done bool
  27190. oldValue func(context.Context) (*Token, error)
  27191. predicates []predicate.Token
  27192. }
  27193. var _ ent.Mutation = (*TokenMutation)(nil)
  27194. // tokenOption allows management of the mutation configuration using functional options.
  27195. type tokenOption func(*TokenMutation)
  27196. // newTokenMutation creates new mutation for the Token entity.
  27197. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  27198. m := &TokenMutation{
  27199. config: c,
  27200. op: op,
  27201. typ: TypeToken,
  27202. clearedFields: make(map[string]struct{}),
  27203. }
  27204. for _, opt := range opts {
  27205. opt(m)
  27206. }
  27207. return m
  27208. }
  27209. // withTokenID sets the ID field of the mutation.
  27210. func withTokenID(id uint64) tokenOption {
  27211. return func(m *TokenMutation) {
  27212. var (
  27213. err error
  27214. once sync.Once
  27215. value *Token
  27216. )
  27217. m.oldValue = func(ctx context.Context) (*Token, error) {
  27218. once.Do(func() {
  27219. if m.done {
  27220. err = errors.New("querying old values post mutation is not allowed")
  27221. } else {
  27222. value, err = m.Client().Token.Get(ctx, id)
  27223. }
  27224. })
  27225. return value, err
  27226. }
  27227. m.id = &id
  27228. }
  27229. }
  27230. // withToken sets the old Token of the mutation.
  27231. func withToken(node *Token) tokenOption {
  27232. return func(m *TokenMutation) {
  27233. m.oldValue = func(context.Context) (*Token, error) {
  27234. return node, nil
  27235. }
  27236. m.id = &node.ID
  27237. }
  27238. }
  27239. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27240. // executed in a transaction (ent.Tx), a transactional client is returned.
  27241. func (m TokenMutation) Client() *Client {
  27242. client := &Client{config: m.config}
  27243. client.init()
  27244. return client
  27245. }
  27246. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27247. // it returns an error otherwise.
  27248. func (m TokenMutation) Tx() (*Tx, error) {
  27249. if _, ok := m.driver.(*txDriver); !ok {
  27250. return nil, errors.New("ent: mutation is not running in a transaction")
  27251. }
  27252. tx := &Tx{config: m.config}
  27253. tx.init()
  27254. return tx, nil
  27255. }
  27256. // SetID sets the value of the id field. Note that this
  27257. // operation is only accepted on creation of Token entities.
  27258. func (m *TokenMutation) SetID(id uint64) {
  27259. m.id = &id
  27260. }
  27261. // ID returns the ID value in the mutation. Note that the ID is only available
  27262. // if it was provided to the builder or after it was returned from the database.
  27263. func (m *TokenMutation) ID() (id uint64, exists bool) {
  27264. if m.id == nil {
  27265. return
  27266. }
  27267. return *m.id, true
  27268. }
  27269. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27270. // That means, if the mutation is applied within a transaction with an isolation level such
  27271. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27272. // or updated by the mutation.
  27273. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  27274. switch {
  27275. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27276. id, exists := m.ID()
  27277. if exists {
  27278. return []uint64{id}, nil
  27279. }
  27280. fallthrough
  27281. case m.op.Is(OpUpdate | OpDelete):
  27282. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  27283. default:
  27284. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27285. }
  27286. }
  27287. // SetCreatedAt sets the "created_at" field.
  27288. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  27289. m.created_at = &t
  27290. }
  27291. // CreatedAt returns the value of the "created_at" field in the mutation.
  27292. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  27293. v := m.created_at
  27294. if v == nil {
  27295. return
  27296. }
  27297. return *v, true
  27298. }
  27299. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  27300. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27302. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27303. if !m.op.Is(OpUpdateOne) {
  27304. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27305. }
  27306. if m.id == nil || m.oldValue == nil {
  27307. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27308. }
  27309. oldValue, err := m.oldValue(ctx)
  27310. if err != nil {
  27311. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27312. }
  27313. return oldValue.CreatedAt, nil
  27314. }
  27315. // ResetCreatedAt resets all changes to the "created_at" field.
  27316. func (m *TokenMutation) ResetCreatedAt() {
  27317. m.created_at = nil
  27318. }
  27319. // SetUpdatedAt sets the "updated_at" field.
  27320. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  27321. m.updated_at = &t
  27322. }
  27323. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27324. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  27325. v := m.updated_at
  27326. if v == nil {
  27327. return
  27328. }
  27329. return *v, true
  27330. }
  27331. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  27332. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27334. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27335. if !m.op.Is(OpUpdateOne) {
  27336. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27337. }
  27338. if m.id == nil || m.oldValue == nil {
  27339. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27340. }
  27341. oldValue, err := m.oldValue(ctx)
  27342. if err != nil {
  27343. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27344. }
  27345. return oldValue.UpdatedAt, nil
  27346. }
  27347. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27348. func (m *TokenMutation) ResetUpdatedAt() {
  27349. m.updated_at = nil
  27350. }
  27351. // SetDeletedAt sets the "deleted_at" field.
  27352. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  27353. m.deleted_at = &t
  27354. }
  27355. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27356. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  27357. v := m.deleted_at
  27358. if v == nil {
  27359. return
  27360. }
  27361. return *v, true
  27362. }
  27363. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  27364. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27366. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27367. if !m.op.Is(OpUpdateOne) {
  27368. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27369. }
  27370. if m.id == nil || m.oldValue == nil {
  27371. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27372. }
  27373. oldValue, err := m.oldValue(ctx)
  27374. if err != nil {
  27375. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27376. }
  27377. return oldValue.DeletedAt, nil
  27378. }
  27379. // ClearDeletedAt clears the value of the "deleted_at" field.
  27380. func (m *TokenMutation) ClearDeletedAt() {
  27381. m.deleted_at = nil
  27382. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  27383. }
  27384. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27385. func (m *TokenMutation) DeletedAtCleared() bool {
  27386. _, ok := m.clearedFields[token.FieldDeletedAt]
  27387. return ok
  27388. }
  27389. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27390. func (m *TokenMutation) ResetDeletedAt() {
  27391. m.deleted_at = nil
  27392. delete(m.clearedFields, token.FieldDeletedAt)
  27393. }
  27394. // SetExpireAt sets the "expire_at" field.
  27395. func (m *TokenMutation) SetExpireAt(t time.Time) {
  27396. m.expire_at = &t
  27397. }
  27398. // ExpireAt returns the value of the "expire_at" field in the mutation.
  27399. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  27400. v := m.expire_at
  27401. if v == nil {
  27402. return
  27403. }
  27404. return *v, true
  27405. }
  27406. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  27407. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27409. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  27410. if !m.op.Is(OpUpdateOne) {
  27411. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  27412. }
  27413. if m.id == nil || m.oldValue == nil {
  27414. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  27415. }
  27416. oldValue, err := m.oldValue(ctx)
  27417. if err != nil {
  27418. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  27419. }
  27420. return oldValue.ExpireAt, nil
  27421. }
  27422. // ClearExpireAt clears the value of the "expire_at" field.
  27423. func (m *TokenMutation) ClearExpireAt() {
  27424. m.expire_at = nil
  27425. m.clearedFields[token.FieldExpireAt] = struct{}{}
  27426. }
  27427. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  27428. func (m *TokenMutation) ExpireAtCleared() bool {
  27429. _, ok := m.clearedFields[token.FieldExpireAt]
  27430. return ok
  27431. }
  27432. // ResetExpireAt resets all changes to the "expire_at" field.
  27433. func (m *TokenMutation) ResetExpireAt() {
  27434. m.expire_at = nil
  27435. delete(m.clearedFields, token.FieldExpireAt)
  27436. }
  27437. // SetToken sets the "token" field.
  27438. func (m *TokenMutation) SetToken(s string) {
  27439. m.token = &s
  27440. }
  27441. // Token returns the value of the "token" field in the mutation.
  27442. func (m *TokenMutation) Token() (r string, exists bool) {
  27443. v := m.token
  27444. if v == nil {
  27445. return
  27446. }
  27447. return *v, true
  27448. }
  27449. // OldToken returns the old "token" field's value of the Token entity.
  27450. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27452. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  27453. if !m.op.Is(OpUpdateOne) {
  27454. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  27455. }
  27456. if m.id == nil || m.oldValue == nil {
  27457. return v, errors.New("OldToken requires an ID field in the mutation")
  27458. }
  27459. oldValue, err := m.oldValue(ctx)
  27460. if err != nil {
  27461. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  27462. }
  27463. return oldValue.Token, nil
  27464. }
  27465. // ClearToken clears the value of the "token" field.
  27466. func (m *TokenMutation) ClearToken() {
  27467. m.token = nil
  27468. m.clearedFields[token.FieldToken] = struct{}{}
  27469. }
  27470. // TokenCleared returns if the "token" field was cleared in this mutation.
  27471. func (m *TokenMutation) TokenCleared() bool {
  27472. _, ok := m.clearedFields[token.FieldToken]
  27473. return ok
  27474. }
  27475. // ResetToken resets all changes to the "token" field.
  27476. func (m *TokenMutation) ResetToken() {
  27477. m.token = nil
  27478. delete(m.clearedFields, token.FieldToken)
  27479. }
  27480. // SetMAC sets the "mac" field.
  27481. func (m *TokenMutation) SetMAC(s string) {
  27482. m.mac = &s
  27483. }
  27484. // MAC returns the value of the "mac" field in the mutation.
  27485. func (m *TokenMutation) MAC() (r string, exists bool) {
  27486. v := m.mac
  27487. if v == nil {
  27488. return
  27489. }
  27490. return *v, true
  27491. }
  27492. // OldMAC returns the old "mac" field's value of the Token entity.
  27493. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27495. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  27496. if !m.op.Is(OpUpdateOne) {
  27497. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  27498. }
  27499. if m.id == nil || m.oldValue == nil {
  27500. return v, errors.New("OldMAC requires an ID field in the mutation")
  27501. }
  27502. oldValue, err := m.oldValue(ctx)
  27503. if err != nil {
  27504. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  27505. }
  27506. return oldValue.MAC, nil
  27507. }
  27508. // ClearMAC clears the value of the "mac" field.
  27509. func (m *TokenMutation) ClearMAC() {
  27510. m.mac = nil
  27511. m.clearedFields[token.FieldMAC] = struct{}{}
  27512. }
  27513. // MACCleared returns if the "mac" field was cleared in this mutation.
  27514. func (m *TokenMutation) MACCleared() bool {
  27515. _, ok := m.clearedFields[token.FieldMAC]
  27516. return ok
  27517. }
  27518. // ResetMAC resets all changes to the "mac" field.
  27519. func (m *TokenMutation) ResetMAC() {
  27520. m.mac = nil
  27521. delete(m.clearedFields, token.FieldMAC)
  27522. }
  27523. // SetOrganizationID sets the "organization_id" field.
  27524. func (m *TokenMutation) SetOrganizationID(u uint64) {
  27525. m.organization_id = &u
  27526. m.addorganization_id = nil
  27527. }
  27528. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27529. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  27530. v := m.organization_id
  27531. if v == nil {
  27532. return
  27533. }
  27534. return *v, true
  27535. }
  27536. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  27537. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27539. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27540. if !m.op.Is(OpUpdateOne) {
  27541. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27542. }
  27543. if m.id == nil || m.oldValue == nil {
  27544. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27545. }
  27546. oldValue, err := m.oldValue(ctx)
  27547. if err != nil {
  27548. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27549. }
  27550. return oldValue.OrganizationID, nil
  27551. }
  27552. // AddOrganizationID adds u to the "organization_id" field.
  27553. func (m *TokenMutation) AddOrganizationID(u int64) {
  27554. if m.addorganization_id != nil {
  27555. *m.addorganization_id += u
  27556. } else {
  27557. m.addorganization_id = &u
  27558. }
  27559. }
  27560. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27561. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  27562. v := m.addorganization_id
  27563. if v == nil {
  27564. return
  27565. }
  27566. return *v, true
  27567. }
  27568. // ResetOrganizationID resets all changes to the "organization_id" field.
  27569. func (m *TokenMutation) ResetOrganizationID() {
  27570. m.organization_id = nil
  27571. m.addorganization_id = nil
  27572. }
  27573. // SetAgentID sets the "agent_id" field.
  27574. func (m *TokenMutation) SetAgentID(u uint64) {
  27575. m.agent = &u
  27576. }
  27577. // AgentID returns the value of the "agent_id" field in the mutation.
  27578. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  27579. v := m.agent
  27580. if v == nil {
  27581. return
  27582. }
  27583. return *v, true
  27584. }
  27585. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  27586. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27588. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  27589. if !m.op.Is(OpUpdateOne) {
  27590. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  27591. }
  27592. if m.id == nil || m.oldValue == nil {
  27593. return v, errors.New("OldAgentID requires an ID field in the mutation")
  27594. }
  27595. oldValue, err := m.oldValue(ctx)
  27596. if err != nil {
  27597. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  27598. }
  27599. return oldValue.AgentID, nil
  27600. }
  27601. // ResetAgentID resets all changes to the "agent_id" field.
  27602. func (m *TokenMutation) ResetAgentID() {
  27603. m.agent = nil
  27604. }
  27605. // SetCustomAgentBase sets the "custom_agent_base" field.
  27606. func (m *TokenMutation) SetCustomAgentBase(s string) {
  27607. m.custom_agent_base = &s
  27608. }
  27609. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  27610. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  27611. v := m.custom_agent_base
  27612. if v == nil {
  27613. return
  27614. }
  27615. return *v, true
  27616. }
  27617. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  27618. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27620. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  27621. if !m.op.Is(OpUpdateOne) {
  27622. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  27623. }
  27624. if m.id == nil || m.oldValue == nil {
  27625. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  27626. }
  27627. oldValue, err := m.oldValue(ctx)
  27628. if err != nil {
  27629. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  27630. }
  27631. return oldValue.CustomAgentBase, nil
  27632. }
  27633. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  27634. func (m *TokenMutation) ClearCustomAgentBase() {
  27635. m.custom_agent_base = nil
  27636. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  27637. }
  27638. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  27639. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  27640. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  27641. return ok
  27642. }
  27643. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  27644. func (m *TokenMutation) ResetCustomAgentBase() {
  27645. m.custom_agent_base = nil
  27646. delete(m.clearedFields, token.FieldCustomAgentBase)
  27647. }
  27648. // SetCustomAgentKey sets the "custom_agent_key" field.
  27649. func (m *TokenMutation) SetCustomAgentKey(s string) {
  27650. m.custom_agent_key = &s
  27651. }
  27652. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  27653. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  27654. v := m.custom_agent_key
  27655. if v == nil {
  27656. return
  27657. }
  27658. return *v, true
  27659. }
  27660. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  27661. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27663. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  27664. if !m.op.Is(OpUpdateOne) {
  27665. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  27666. }
  27667. if m.id == nil || m.oldValue == nil {
  27668. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  27669. }
  27670. oldValue, err := m.oldValue(ctx)
  27671. if err != nil {
  27672. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  27673. }
  27674. return oldValue.CustomAgentKey, nil
  27675. }
  27676. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  27677. func (m *TokenMutation) ClearCustomAgentKey() {
  27678. m.custom_agent_key = nil
  27679. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  27680. }
  27681. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  27682. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  27683. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  27684. return ok
  27685. }
  27686. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  27687. func (m *TokenMutation) ResetCustomAgentKey() {
  27688. m.custom_agent_key = nil
  27689. delete(m.clearedFields, token.FieldCustomAgentKey)
  27690. }
  27691. // SetOpenaiBase sets the "openai_base" field.
  27692. func (m *TokenMutation) SetOpenaiBase(s string) {
  27693. m.openai_base = &s
  27694. }
  27695. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  27696. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  27697. v := m.openai_base
  27698. if v == nil {
  27699. return
  27700. }
  27701. return *v, true
  27702. }
  27703. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  27704. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27706. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  27707. if !m.op.Is(OpUpdateOne) {
  27708. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  27709. }
  27710. if m.id == nil || m.oldValue == nil {
  27711. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  27712. }
  27713. oldValue, err := m.oldValue(ctx)
  27714. if err != nil {
  27715. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  27716. }
  27717. return oldValue.OpenaiBase, nil
  27718. }
  27719. // ClearOpenaiBase clears the value of the "openai_base" field.
  27720. func (m *TokenMutation) ClearOpenaiBase() {
  27721. m.openai_base = nil
  27722. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  27723. }
  27724. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  27725. func (m *TokenMutation) OpenaiBaseCleared() bool {
  27726. _, ok := m.clearedFields[token.FieldOpenaiBase]
  27727. return ok
  27728. }
  27729. // ResetOpenaiBase resets all changes to the "openai_base" field.
  27730. func (m *TokenMutation) ResetOpenaiBase() {
  27731. m.openai_base = nil
  27732. delete(m.clearedFields, token.FieldOpenaiBase)
  27733. }
  27734. // SetOpenaiKey sets the "openai_key" field.
  27735. func (m *TokenMutation) SetOpenaiKey(s string) {
  27736. m.openai_key = &s
  27737. }
  27738. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  27739. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  27740. v := m.openai_key
  27741. if v == nil {
  27742. return
  27743. }
  27744. return *v, true
  27745. }
  27746. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  27747. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27749. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  27750. if !m.op.Is(OpUpdateOne) {
  27751. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  27752. }
  27753. if m.id == nil || m.oldValue == nil {
  27754. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  27755. }
  27756. oldValue, err := m.oldValue(ctx)
  27757. if err != nil {
  27758. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  27759. }
  27760. return oldValue.OpenaiKey, nil
  27761. }
  27762. // ClearOpenaiKey clears the value of the "openai_key" field.
  27763. func (m *TokenMutation) ClearOpenaiKey() {
  27764. m.openai_key = nil
  27765. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  27766. }
  27767. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  27768. func (m *TokenMutation) OpenaiKeyCleared() bool {
  27769. _, ok := m.clearedFields[token.FieldOpenaiKey]
  27770. return ok
  27771. }
  27772. // ResetOpenaiKey resets all changes to the "openai_key" field.
  27773. func (m *TokenMutation) ResetOpenaiKey() {
  27774. m.openai_key = nil
  27775. delete(m.clearedFields, token.FieldOpenaiKey)
  27776. }
  27777. // ClearAgent clears the "agent" edge to the Agent entity.
  27778. func (m *TokenMutation) ClearAgent() {
  27779. m.clearedagent = true
  27780. m.clearedFields[token.FieldAgentID] = struct{}{}
  27781. }
  27782. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  27783. func (m *TokenMutation) AgentCleared() bool {
  27784. return m.clearedagent
  27785. }
  27786. // AgentIDs returns the "agent" edge IDs in the mutation.
  27787. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27788. // AgentID instead. It exists only for internal usage by the builders.
  27789. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  27790. if id := m.agent; id != nil {
  27791. ids = append(ids, *id)
  27792. }
  27793. return
  27794. }
  27795. // ResetAgent resets all changes to the "agent" edge.
  27796. func (m *TokenMutation) ResetAgent() {
  27797. m.agent = nil
  27798. m.clearedagent = false
  27799. }
  27800. // Where appends a list predicates to the TokenMutation builder.
  27801. func (m *TokenMutation) Where(ps ...predicate.Token) {
  27802. m.predicates = append(m.predicates, ps...)
  27803. }
  27804. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  27805. // users can use type-assertion to append predicates that do not depend on any generated package.
  27806. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  27807. p := make([]predicate.Token, len(ps))
  27808. for i := range ps {
  27809. p[i] = ps[i]
  27810. }
  27811. m.Where(p...)
  27812. }
  27813. // Op returns the operation name.
  27814. func (m *TokenMutation) Op() Op {
  27815. return m.op
  27816. }
  27817. // SetOp allows setting the mutation operation.
  27818. func (m *TokenMutation) SetOp(op Op) {
  27819. m.op = op
  27820. }
  27821. // Type returns the node type of this mutation (Token).
  27822. func (m *TokenMutation) Type() string {
  27823. return m.typ
  27824. }
  27825. // Fields returns all fields that were changed during this mutation. Note that in
  27826. // order to get all numeric fields that were incremented/decremented, call
  27827. // AddedFields().
  27828. func (m *TokenMutation) Fields() []string {
  27829. fields := make([]string, 0, 12)
  27830. if m.created_at != nil {
  27831. fields = append(fields, token.FieldCreatedAt)
  27832. }
  27833. if m.updated_at != nil {
  27834. fields = append(fields, token.FieldUpdatedAt)
  27835. }
  27836. if m.deleted_at != nil {
  27837. fields = append(fields, token.FieldDeletedAt)
  27838. }
  27839. if m.expire_at != nil {
  27840. fields = append(fields, token.FieldExpireAt)
  27841. }
  27842. if m.token != nil {
  27843. fields = append(fields, token.FieldToken)
  27844. }
  27845. if m.mac != nil {
  27846. fields = append(fields, token.FieldMAC)
  27847. }
  27848. if m.organization_id != nil {
  27849. fields = append(fields, token.FieldOrganizationID)
  27850. }
  27851. if m.agent != nil {
  27852. fields = append(fields, token.FieldAgentID)
  27853. }
  27854. if m.custom_agent_base != nil {
  27855. fields = append(fields, token.FieldCustomAgentBase)
  27856. }
  27857. if m.custom_agent_key != nil {
  27858. fields = append(fields, token.FieldCustomAgentKey)
  27859. }
  27860. if m.openai_base != nil {
  27861. fields = append(fields, token.FieldOpenaiBase)
  27862. }
  27863. if m.openai_key != nil {
  27864. fields = append(fields, token.FieldOpenaiKey)
  27865. }
  27866. return fields
  27867. }
  27868. // Field returns the value of a field with the given name. The second boolean
  27869. // return value indicates that this field was not set, or was not defined in the
  27870. // schema.
  27871. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  27872. switch name {
  27873. case token.FieldCreatedAt:
  27874. return m.CreatedAt()
  27875. case token.FieldUpdatedAt:
  27876. return m.UpdatedAt()
  27877. case token.FieldDeletedAt:
  27878. return m.DeletedAt()
  27879. case token.FieldExpireAt:
  27880. return m.ExpireAt()
  27881. case token.FieldToken:
  27882. return m.Token()
  27883. case token.FieldMAC:
  27884. return m.MAC()
  27885. case token.FieldOrganizationID:
  27886. return m.OrganizationID()
  27887. case token.FieldAgentID:
  27888. return m.AgentID()
  27889. case token.FieldCustomAgentBase:
  27890. return m.CustomAgentBase()
  27891. case token.FieldCustomAgentKey:
  27892. return m.CustomAgentKey()
  27893. case token.FieldOpenaiBase:
  27894. return m.OpenaiBase()
  27895. case token.FieldOpenaiKey:
  27896. return m.OpenaiKey()
  27897. }
  27898. return nil, false
  27899. }
  27900. // OldField returns the old value of the field from the database. An error is
  27901. // returned if the mutation operation is not UpdateOne, or the query to the
  27902. // database failed.
  27903. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27904. switch name {
  27905. case token.FieldCreatedAt:
  27906. return m.OldCreatedAt(ctx)
  27907. case token.FieldUpdatedAt:
  27908. return m.OldUpdatedAt(ctx)
  27909. case token.FieldDeletedAt:
  27910. return m.OldDeletedAt(ctx)
  27911. case token.FieldExpireAt:
  27912. return m.OldExpireAt(ctx)
  27913. case token.FieldToken:
  27914. return m.OldToken(ctx)
  27915. case token.FieldMAC:
  27916. return m.OldMAC(ctx)
  27917. case token.FieldOrganizationID:
  27918. return m.OldOrganizationID(ctx)
  27919. case token.FieldAgentID:
  27920. return m.OldAgentID(ctx)
  27921. case token.FieldCustomAgentBase:
  27922. return m.OldCustomAgentBase(ctx)
  27923. case token.FieldCustomAgentKey:
  27924. return m.OldCustomAgentKey(ctx)
  27925. case token.FieldOpenaiBase:
  27926. return m.OldOpenaiBase(ctx)
  27927. case token.FieldOpenaiKey:
  27928. return m.OldOpenaiKey(ctx)
  27929. }
  27930. return nil, fmt.Errorf("unknown Token field %s", name)
  27931. }
  27932. // SetField sets the value of a field with the given name. It returns an error if
  27933. // the field is not defined in the schema, or if the type mismatched the field
  27934. // type.
  27935. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  27936. switch name {
  27937. case token.FieldCreatedAt:
  27938. v, ok := value.(time.Time)
  27939. if !ok {
  27940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27941. }
  27942. m.SetCreatedAt(v)
  27943. return nil
  27944. case token.FieldUpdatedAt:
  27945. v, ok := value.(time.Time)
  27946. if !ok {
  27947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27948. }
  27949. m.SetUpdatedAt(v)
  27950. return nil
  27951. case token.FieldDeletedAt:
  27952. v, ok := value.(time.Time)
  27953. if !ok {
  27954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27955. }
  27956. m.SetDeletedAt(v)
  27957. return nil
  27958. case token.FieldExpireAt:
  27959. v, ok := value.(time.Time)
  27960. if !ok {
  27961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27962. }
  27963. m.SetExpireAt(v)
  27964. return nil
  27965. case token.FieldToken:
  27966. v, ok := value.(string)
  27967. if !ok {
  27968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27969. }
  27970. m.SetToken(v)
  27971. return nil
  27972. case token.FieldMAC:
  27973. v, ok := value.(string)
  27974. if !ok {
  27975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27976. }
  27977. m.SetMAC(v)
  27978. return nil
  27979. case token.FieldOrganizationID:
  27980. v, ok := value.(uint64)
  27981. if !ok {
  27982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27983. }
  27984. m.SetOrganizationID(v)
  27985. return nil
  27986. case token.FieldAgentID:
  27987. v, ok := value.(uint64)
  27988. if !ok {
  27989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27990. }
  27991. m.SetAgentID(v)
  27992. return nil
  27993. case token.FieldCustomAgentBase:
  27994. v, ok := value.(string)
  27995. if !ok {
  27996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27997. }
  27998. m.SetCustomAgentBase(v)
  27999. return nil
  28000. case token.FieldCustomAgentKey:
  28001. v, ok := value.(string)
  28002. if !ok {
  28003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28004. }
  28005. m.SetCustomAgentKey(v)
  28006. return nil
  28007. case token.FieldOpenaiBase:
  28008. v, ok := value.(string)
  28009. if !ok {
  28010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28011. }
  28012. m.SetOpenaiBase(v)
  28013. return nil
  28014. case token.FieldOpenaiKey:
  28015. v, ok := value.(string)
  28016. if !ok {
  28017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28018. }
  28019. m.SetOpenaiKey(v)
  28020. return nil
  28021. }
  28022. return fmt.Errorf("unknown Token field %s", name)
  28023. }
  28024. // AddedFields returns all numeric fields that were incremented/decremented during
  28025. // this mutation.
  28026. func (m *TokenMutation) AddedFields() []string {
  28027. var fields []string
  28028. if m.addorganization_id != nil {
  28029. fields = append(fields, token.FieldOrganizationID)
  28030. }
  28031. return fields
  28032. }
  28033. // AddedField returns the numeric value that was incremented/decremented on a field
  28034. // with the given name. The second boolean return value indicates that this field
  28035. // was not set, or was not defined in the schema.
  28036. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  28037. switch name {
  28038. case token.FieldOrganizationID:
  28039. return m.AddedOrganizationID()
  28040. }
  28041. return nil, false
  28042. }
  28043. // AddField adds the value to the field with the given name. It returns an error if
  28044. // the field is not defined in the schema, or if the type mismatched the field
  28045. // type.
  28046. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  28047. switch name {
  28048. case token.FieldOrganizationID:
  28049. v, ok := value.(int64)
  28050. if !ok {
  28051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28052. }
  28053. m.AddOrganizationID(v)
  28054. return nil
  28055. }
  28056. return fmt.Errorf("unknown Token numeric field %s", name)
  28057. }
  28058. // ClearedFields returns all nullable fields that were cleared during this
  28059. // mutation.
  28060. func (m *TokenMutation) ClearedFields() []string {
  28061. var fields []string
  28062. if m.FieldCleared(token.FieldDeletedAt) {
  28063. fields = append(fields, token.FieldDeletedAt)
  28064. }
  28065. if m.FieldCleared(token.FieldExpireAt) {
  28066. fields = append(fields, token.FieldExpireAt)
  28067. }
  28068. if m.FieldCleared(token.FieldToken) {
  28069. fields = append(fields, token.FieldToken)
  28070. }
  28071. if m.FieldCleared(token.FieldMAC) {
  28072. fields = append(fields, token.FieldMAC)
  28073. }
  28074. if m.FieldCleared(token.FieldCustomAgentBase) {
  28075. fields = append(fields, token.FieldCustomAgentBase)
  28076. }
  28077. if m.FieldCleared(token.FieldCustomAgentKey) {
  28078. fields = append(fields, token.FieldCustomAgentKey)
  28079. }
  28080. if m.FieldCleared(token.FieldOpenaiBase) {
  28081. fields = append(fields, token.FieldOpenaiBase)
  28082. }
  28083. if m.FieldCleared(token.FieldOpenaiKey) {
  28084. fields = append(fields, token.FieldOpenaiKey)
  28085. }
  28086. return fields
  28087. }
  28088. // FieldCleared returns a boolean indicating if a field with the given name was
  28089. // cleared in this mutation.
  28090. func (m *TokenMutation) FieldCleared(name string) bool {
  28091. _, ok := m.clearedFields[name]
  28092. return ok
  28093. }
  28094. // ClearField clears the value of the field with the given name. It returns an
  28095. // error if the field is not defined in the schema.
  28096. func (m *TokenMutation) ClearField(name string) error {
  28097. switch name {
  28098. case token.FieldDeletedAt:
  28099. m.ClearDeletedAt()
  28100. return nil
  28101. case token.FieldExpireAt:
  28102. m.ClearExpireAt()
  28103. return nil
  28104. case token.FieldToken:
  28105. m.ClearToken()
  28106. return nil
  28107. case token.FieldMAC:
  28108. m.ClearMAC()
  28109. return nil
  28110. case token.FieldCustomAgentBase:
  28111. m.ClearCustomAgentBase()
  28112. return nil
  28113. case token.FieldCustomAgentKey:
  28114. m.ClearCustomAgentKey()
  28115. return nil
  28116. case token.FieldOpenaiBase:
  28117. m.ClearOpenaiBase()
  28118. return nil
  28119. case token.FieldOpenaiKey:
  28120. m.ClearOpenaiKey()
  28121. return nil
  28122. }
  28123. return fmt.Errorf("unknown Token nullable field %s", name)
  28124. }
  28125. // ResetField resets all changes in the mutation for the field with the given name.
  28126. // It returns an error if the field is not defined in the schema.
  28127. func (m *TokenMutation) ResetField(name string) error {
  28128. switch name {
  28129. case token.FieldCreatedAt:
  28130. m.ResetCreatedAt()
  28131. return nil
  28132. case token.FieldUpdatedAt:
  28133. m.ResetUpdatedAt()
  28134. return nil
  28135. case token.FieldDeletedAt:
  28136. m.ResetDeletedAt()
  28137. return nil
  28138. case token.FieldExpireAt:
  28139. m.ResetExpireAt()
  28140. return nil
  28141. case token.FieldToken:
  28142. m.ResetToken()
  28143. return nil
  28144. case token.FieldMAC:
  28145. m.ResetMAC()
  28146. return nil
  28147. case token.FieldOrganizationID:
  28148. m.ResetOrganizationID()
  28149. return nil
  28150. case token.FieldAgentID:
  28151. m.ResetAgentID()
  28152. return nil
  28153. case token.FieldCustomAgentBase:
  28154. m.ResetCustomAgentBase()
  28155. return nil
  28156. case token.FieldCustomAgentKey:
  28157. m.ResetCustomAgentKey()
  28158. return nil
  28159. case token.FieldOpenaiBase:
  28160. m.ResetOpenaiBase()
  28161. return nil
  28162. case token.FieldOpenaiKey:
  28163. m.ResetOpenaiKey()
  28164. return nil
  28165. }
  28166. return fmt.Errorf("unknown Token field %s", name)
  28167. }
  28168. // AddedEdges returns all edge names that were set/added in this mutation.
  28169. func (m *TokenMutation) AddedEdges() []string {
  28170. edges := make([]string, 0, 1)
  28171. if m.agent != nil {
  28172. edges = append(edges, token.EdgeAgent)
  28173. }
  28174. return edges
  28175. }
  28176. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28177. // name in this mutation.
  28178. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  28179. switch name {
  28180. case token.EdgeAgent:
  28181. if id := m.agent; id != nil {
  28182. return []ent.Value{*id}
  28183. }
  28184. }
  28185. return nil
  28186. }
  28187. // RemovedEdges returns all edge names that were removed in this mutation.
  28188. func (m *TokenMutation) RemovedEdges() []string {
  28189. edges := make([]string, 0, 1)
  28190. return edges
  28191. }
  28192. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28193. // the given name in this mutation.
  28194. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  28195. return nil
  28196. }
  28197. // ClearedEdges returns all edge names that were cleared in this mutation.
  28198. func (m *TokenMutation) ClearedEdges() []string {
  28199. edges := make([]string, 0, 1)
  28200. if m.clearedagent {
  28201. edges = append(edges, token.EdgeAgent)
  28202. }
  28203. return edges
  28204. }
  28205. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28206. // was cleared in this mutation.
  28207. func (m *TokenMutation) EdgeCleared(name string) bool {
  28208. switch name {
  28209. case token.EdgeAgent:
  28210. return m.clearedagent
  28211. }
  28212. return false
  28213. }
  28214. // ClearEdge clears the value of the edge with the given name. It returns an error
  28215. // if that edge is not defined in the schema.
  28216. func (m *TokenMutation) ClearEdge(name string) error {
  28217. switch name {
  28218. case token.EdgeAgent:
  28219. m.ClearAgent()
  28220. return nil
  28221. }
  28222. return fmt.Errorf("unknown Token unique edge %s", name)
  28223. }
  28224. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28225. // It returns an error if the edge is not defined in the schema.
  28226. func (m *TokenMutation) ResetEdge(name string) error {
  28227. switch name {
  28228. case token.EdgeAgent:
  28229. m.ResetAgent()
  28230. return nil
  28231. }
  28232. return fmt.Errorf("unknown Token edge %s", name)
  28233. }
  28234. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  28235. type TutorialMutation struct {
  28236. config
  28237. op Op
  28238. typ string
  28239. id *uint64
  28240. created_at *time.Time
  28241. updated_at *time.Time
  28242. deleted_at *time.Time
  28243. index *int
  28244. addindex *int
  28245. title *string
  28246. content *string
  28247. organization_id *uint64
  28248. addorganization_id *int64
  28249. clearedFields map[string]struct{}
  28250. employee *uint64
  28251. clearedemployee bool
  28252. done bool
  28253. oldValue func(context.Context) (*Tutorial, error)
  28254. predicates []predicate.Tutorial
  28255. }
  28256. var _ ent.Mutation = (*TutorialMutation)(nil)
  28257. // tutorialOption allows management of the mutation configuration using functional options.
  28258. type tutorialOption func(*TutorialMutation)
  28259. // newTutorialMutation creates new mutation for the Tutorial entity.
  28260. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  28261. m := &TutorialMutation{
  28262. config: c,
  28263. op: op,
  28264. typ: TypeTutorial,
  28265. clearedFields: make(map[string]struct{}),
  28266. }
  28267. for _, opt := range opts {
  28268. opt(m)
  28269. }
  28270. return m
  28271. }
  28272. // withTutorialID sets the ID field of the mutation.
  28273. func withTutorialID(id uint64) tutorialOption {
  28274. return func(m *TutorialMutation) {
  28275. var (
  28276. err error
  28277. once sync.Once
  28278. value *Tutorial
  28279. )
  28280. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  28281. once.Do(func() {
  28282. if m.done {
  28283. err = errors.New("querying old values post mutation is not allowed")
  28284. } else {
  28285. value, err = m.Client().Tutorial.Get(ctx, id)
  28286. }
  28287. })
  28288. return value, err
  28289. }
  28290. m.id = &id
  28291. }
  28292. }
  28293. // withTutorial sets the old Tutorial of the mutation.
  28294. func withTutorial(node *Tutorial) tutorialOption {
  28295. return func(m *TutorialMutation) {
  28296. m.oldValue = func(context.Context) (*Tutorial, error) {
  28297. return node, nil
  28298. }
  28299. m.id = &node.ID
  28300. }
  28301. }
  28302. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28303. // executed in a transaction (ent.Tx), a transactional client is returned.
  28304. func (m TutorialMutation) Client() *Client {
  28305. client := &Client{config: m.config}
  28306. client.init()
  28307. return client
  28308. }
  28309. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28310. // it returns an error otherwise.
  28311. func (m TutorialMutation) Tx() (*Tx, error) {
  28312. if _, ok := m.driver.(*txDriver); !ok {
  28313. return nil, errors.New("ent: mutation is not running in a transaction")
  28314. }
  28315. tx := &Tx{config: m.config}
  28316. tx.init()
  28317. return tx, nil
  28318. }
  28319. // SetID sets the value of the id field. Note that this
  28320. // operation is only accepted on creation of Tutorial entities.
  28321. func (m *TutorialMutation) SetID(id uint64) {
  28322. m.id = &id
  28323. }
  28324. // ID returns the ID value in the mutation. Note that the ID is only available
  28325. // if it was provided to the builder or after it was returned from the database.
  28326. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  28327. if m.id == nil {
  28328. return
  28329. }
  28330. return *m.id, true
  28331. }
  28332. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28333. // That means, if the mutation is applied within a transaction with an isolation level such
  28334. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28335. // or updated by the mutation.
  28336. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  28337. switch {
  28338. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28339. id, exists := m.ID()
  28340. if exists {
  28341. return []uint64{id}, nil
  28342. }
  28343. fallthrough
  28344. case m.op.Is(OpUpdate | OpDelete):
  28345. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  28346. default:
  28347. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28348. }
  28349. }
  28350. // SetCreatedAt sets the "created_at" field.
  28351. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  28352. m.created_at = &t
  28353. }
  28354. // CreatedAt returns the value of the "created_at" field in the mutation.
  28355. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  28356. v := m.created_at
  28357. if v == nil {
  28358. return
  28359. }
  28360. return *v, true
  28361. }
  28362. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  28363. // If the Tutorial 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 *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28366. if !m.op.Is(OpUpdateOne) {
  28367. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28368. }
  28369. if m.id == nil || m.oldValue == nil {
  28370. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  28375. }
  28376. return oldValue.CreatedAt, nil
  28377. }
  28378. // ResetCreatedAt resets all changes to the "created_at" field.
  28379. func (m *TutorialMutation) ResetCreatedAt() {
  28380. m.created_at = nil
  28381. }
  28382. // SetUpdatedAt sets the "updated_at" field.
  28383. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  28384. m.updated_at = &t
  28385. }
  28386. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28387. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  28388. v := m.updated_at
  28389. if v == nil {
  28390. return
  28391. }
  28392. return *v, true
  28393. }
  28394. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  28395. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28397. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28398. if !m.op.Is(OpUpdateOne) {
  28399. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28400. }
  28401. if m.id == nil || m.oldValue == nil {
  28402. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28403. }
  28404. oldValue, err := m.oldValue(ctx)
  28405. if err != nil {
  28406. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28407. }
  28408. return oldValue.UpdatedAt, nil
  28409. }
  28410. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28411. func (m *TutorialMutation) ResetUpdatedAt() {
  28412. m.updated_at = nil
  28413. }
  28414. // SetDeletedAt sets the "deleted_at" field.
  28415. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  28416. m.deleted_at = &t
  28417. }
  28418. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28419. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  28420. v := m.deleted_at
  28421. if v == nil {
  28422. return
  28423. }
  28424. return *v, true
  28425. }
  28426. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  28427. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28429. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28430. if !m.op.Is(OpUpdateOne) {
  28431. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28432. }
  28433. if m.id == nil || m.oldValue == nil {
  28434. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28435. }
  28436. oldValue, err := m.oldValue(ctx)
  28437. if err != nil {
  28438. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28439. }
  28440. return oldValue.DeletedAt, nil
  28441. }
  28442. // ClearDeletedAt clears the value of the "deleted_at" field.
  28443. func (m *TutorialMutation) ClearDeletedAt() {
  28444. m.deleted_at = nil
  28445. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  28446. }
  28447. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28448. func (m *TutorialMutation) DeletedAtCleared() bool {
  28449. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  28450. return ok
  28451. }
  28452. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28453. func (m *TutorialMutation) ResetDeletedAt() {
  28454. m.deleted_at = nil
  28455. delete(m.clearedFields, tutorial.FieldDeletedAt)
  28456. }
  28457. // SetEmployeeID sets the "employee_id" field.
  28458. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  28459. m.employee = &u
  28460. }
  28461. // EmployeeID returns the value of the "employee_id" field in the mutation.
  28462. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  28463. v := m.employee
  28464. if v == nil {
  28465. return
  28466. }
  28467. return *v, true
  28468. }
  28469. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  28470. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28472. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  28473. if !m.op.Is(OpUpdateOne) {
  28474. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  28475. }
  28476. if m.id == nil || m.oldValue == nil {
  28477. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  28478. }
  28479. oldValue, err := m.oldValue(ctx)
  28480. if err != nil {
  28481. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  28482. }
  28483. return oldValue.EmployeeID, nil
  28484. }
  28485. // ResetEmployeeID resets all changes to the "employee_id" field.
  28486. func (m *TutorialMutation) ResetEmployeeID() {
  28487. m.employee = nil
  28488. }
  28489. // SetIndex sets the "index" field.
  28490. func (m *TutorialMutation) SetIndex(i int) {
  28491. m.index = &i
  28492. m.addindex = nil
  28493. }
  28494. // Index returns the value of the "index" field in the mutation.
  28495. func (m *TutorialMutation) Index() (r int, exists bool) {
  28496. v := m.index
  28497. if v == nil {
  28498. return
  28499. }
  28500. return *v, true
  28501. }
  28502. // OldIndex returns the old "index" field's value of the Tutorial entity.
  28503. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28505. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  28506. if !m.op.Is(OpUpdateOne) {
  28507. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  28508. }
  28509. if m.id == nil || m.oldValue == nil {
  28510. return v, errors.New("OldIndex requires an ID field in the mutation")
  28511. }
  28512. oldValue, err := m.oldValue(ctx)
  28513. if err != nil {
  28514. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  28515. }
  28516. return oldValue.Index, nil
  28517. }
  28518. // AddIndex adds i to the "index" field.
  28519. func (m *TutorialMutation) AddIndex(i int) {
  28520. if m.addindex != nil {
  28521. *m.addindex += i
  28522. } else {
  28523. m.addindex = &i
  28524. }
  28525. }
  28526. // AddedIndex returns the value that was added to the "index" field in this mutation.
  28527. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  28528. v := m.addindex
  28529. if v == nil {
  28530. return
  28531. }
  28532. return *v, true
  28533. }
  28534. // ResetIndex resets all changes to the "index" field.
  28535. func (m *TutorialMutation) ResetIndex() {
  28536. m.index = nil
  28537. m.addindex = nil
  28538. }
  28539. // SetTitle sets the "title" field.
  28540. func (m *TutorialMutation) SetTitle(s string) {
  28541. m.title = &s
  28542. }
  28543. // Title returns the value of the "title" field in the mutation.
  28544. func (m *TutorialMutation) Title() (r string, exists bool) {
  28545. v := m.title
  28546. if v == nil {
  28547. return
  28548. }
  28549. return *v, true
  28550. }
  28551. // OldTitle returns the old "title" field's value of the Tutorial entity.
  28552. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28554. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  28555. if !m.op.Is(OpUpdateOne) {
  28556. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  28557. }
  28558. if m.id == nil || m.oldValue == nil {
  28559. return v, errors.New("OldTitle requires an ID field in the mutation")
  28560. }
  28561. oldValue, err := m.oldValue(ctx)
  28562. if err != nil {
  28563. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  28564. }
  28565. return oldValue.Title, nil
  28566. }
  28567. // ResetTitle resets all changes to the "title" field.
  28568. func (m *TutorialMutation) ResetTitle() {
  28569. m.title = nil
  28570. }
  28571. // SetContent sets the "content" field.
  28572. func (m *TutorialMutation) SetContent(s string) {
  28573. m.content = &s
  28574. }
  28575. // Content returns the value of the "content" field in the mutation.
  28576. func (m *TutorialMutation) Content() (r string, exists bool) {
  28577. v := m.content
  28578. if v == nil {
  28579. return
  28580. }
  28581. return *v, true
  28582. }
  28583. // OldContent returns the old "content" field's value of the Tutorial entity.
  28584. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28586. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  28587. if !m.op.Is(OpUpdateOne) {
  28588. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  28589. }
  28590. if m.id == nil || m.oldValue == nil {
  28591. return v, errors.New("OldContent requires an ID field in the mutation")
  28592. }
  28593. oldValue, err := m.oldValue(ctx)
  28594. if err != nil {
  28595. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  28596. }
  28597. return oldValue.Content, nil
  28598. }
  28599. // ResetContent resets all changes to the "content" field.
  28600. func (m *TutorialMutation) ResetContent() {
  28601. m.content = nil
  28602. }
  28603. // SetOrganizationID sets the "organization_id" field.
  28604. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  28605. m.organization_id = &u
  28606. m.addorganization_id = nil
  28607. }
  28608. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28609. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  28610. v := m.organization_id
  28611. if v == nil {
  28612. return
  28613. }
  28614. return *v, true
  28615. }
  28616. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  28617. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28619. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28620. if !m.op.Is(OpUpdateOne) {
  28621. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28622. }
  28623. if m.id == nil || m.oldValue == nil {
  28624. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28625. }
  28626. oldValue, err := m.oldValue(ctx)
  28627. if err != nil {
  28628. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28629. }
  28630. return oldValue.OrganizationID, nil
  28631. }
  28632. // AddOrganizationID adds u to the "organization_id" field.
  28633. func (m *TutorialMutation) AddOrganizationID(u int64) {
  28634. if m.addorganization_id != nil {
  28635. *m.addorganization_id += u
  28636. } else {
  28637. m.addorganization_id = &u
  28638. }
  28639. }
  28640. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28641. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  28642. v := m.addorganization_id
  28643. if v == nil {
  28644. return
  28645. }
  28646. return *v, true
  28647. }
  28648. // ResetOrganizationID resets all changes to the "organization_id" field.
  28649. func (m *TutorialMutation) ResetOrganizationID() {
  28650. m.organization_id = nil
  28651. m.addorganization_id = nil
  28652. }
  28653. // ClearEmployee clears the "employee" edge to the Employee entity.
  28654. func (m *TutorialMutation) ClearEmployee() {
  28655. m.clearedemployee = true
  28656. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  28657. }
  28658. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  28659. func (m *TutorialMutation) EmployeeCleared() bool {
  28660. return m.clearedemployee
  28661. }
  28662. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  28663. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28664. // EmployeeID instead. It exists only for internal usage by the builders.
  28665. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  28666. if id := m.employee; id != nil {
  28667. ids = append(ids, *id)
  28668. }
  28669. return
  28670. }
  28671. // ResetEmployee resets all changes to the "employee" edge.
  28672. func (m *TutorialMutation) ResetEmployee() {
  28673. m.employee = nil
  28674. m.clearedemployee = false
  28675. }
  28676. // Where appends a list predicates to the TutorialMutation builder.
  28677. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  28678. m.predicates = append(m.predicates, ps...)
  28679. }
  28680. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  28681. // users can use type-assertion to append predicates that do not depend on any generated package.
  28682. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  28683. p := make([]predicate.Tutorial, len(ps))
  28684. for i := range ps {
  28685. p[i] = ps[i]
  28686. }
  28687. m.Where(p...)
  28688. }
  28689. // Op returns the operation name.
  28690. func (m *TutorialMutation) Op() Op {
  28691. return m.op
  28692. }
  28693. // SetOp allows setting the mutation operation.
  28694. func (m *TutorialMutation) SetOp(op Op) {
  28695. m.op = op
  28696. }
  28697. // Type returns the node type of this mutation (Tutorial).
  28698. func (m *TutorialMutation) Type() string {
  28699. return m.typ
  28700. }
  28701. // Fields returns all fields that were changed during this mutation. Note that in
  28702. // order to get all numeric fields that were incremented/decremented, call
  28703. // AddedFields().
  28704. func (m *TutorialMutation) Fields() []string {
  28705. fields := make([]string, 0, 8)
  28706. if m.created_at != nil {
  28707. fields = append(fields, tutorial.FieldCreatedAt)
  28708. }
  28709. if m.updated_at != nil {
  28710. fields = append(fields, tutorial.FieldUpdatedAt)
  28711. }
  28712. if m.deleted_at != nil {
  28713. fields = append(fields, tutorial.FieldDeletedAt)
  28714. }
  28715. if m.employee != nil {
  28716. fields = append(fields, tutorial.FieldEmployeeID)
  28717. }
  28718. if m.index != nil {
  28719. fields = append(fields, tutorial.FieldIndex)
  28720. }
  28721. if m.title != nil {
  28722. fields = append(fields, tutorial.FieldTitle)
  28723. }
  28724. if m.content != nil {
  28725. fields = append(fields, tutorial.FieldContent)
  28726. }
  28727. if m.organization_id != nil {
  28728. fields = append(fields, tutorial.FieldOrganizationID)
  28729. }
  28730. return fields
  28731. }
  28732. // Field returns the value of a field with the given name. The second boolean
  28733. // return value indicates that this field was not set, or was not defined in the
  28734. // schema.
  28735. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  28736. switch name {
  28737. case tutorial.FieldCreatedAt:
  28738. return m.CreatedAt()
  28739. case tutorial.FieldUpdatedAt:
  28740. return m.UpdatedAt()
  28741. case tutorial.FieldDeletedAt:
  28742. return m.DeletedAt()
  28743. case tutorial.FieldEmployeeID:
  28744. return m.EmployeeID()
  28745. case tutorial.FieldIndex:
  28746. return m.Index()
  28747. case tutorial.FieldTitle:
  28748. return m.Title()
  28749. case tutorial.FieldContent:
  28750. return m.Content()
  28751. case tutorial.FieldOrganizationID:
  28752. return m.OrganizationID()
  28753. }
  28754. return nil, false
  28755. }
  28756. // OldField returns the old value of the field from the database. An error is
  28757. // returned if the mutation operation is not UpdateOne, or the query to the
  28758. // database failed.
  28759. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28760. switch name {
  28761. case tutorial.FieldCreatedAt:
  28762. return m.OldCreatedAt(ctx)
  28763. case tutorial.FieldUpdatedAt:
  28764. return m.OldUpdatedAt(ctx)
  28765. case tutorial.FieldDeletedAt:
  28766. return m.OldDeletedAt(ctx)
  28767. case tutorial.FieldEmployeeID:
  28768. return m.OldEmployeeID(ctx)
  28769. case tutorial.FieldIndex:
  28770. return m.OldIndex(ctx)
  28771. case tutorial.FieldTitle:
  28772. return m.OldTitle(ctx)
  28773. case tutorial.FieldContent:
  28774. return m.OldContent(ctx)
  28775. case tutorial.FieldOrganizationID:
  28776. return m.OldOrganizationID(ctx)
  28777. }
  28778. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  28779. }
  28780. // SetField sets the value of a field with the given name. It returns an error if
  28781. // the field is not defined in the schema, or if the type mismatched the field
  28782. // type.
  28783. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  28784. switch name {
  28785. case tutorial.FieldCreatedAt:
  28786. v, ok := value.(time.Time)
  28787. if !ok {
  28788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28789. }
  28790. m.SetCreatedAt(v)
  28791. return nil
  28792. case tutorial.FieldUpdatedAt:
  28793. v, ok := value.(time.Time)
  28794. if !ok {
  28795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28796. }
  28797. m.SetUpdatedAt(v)
  28798. return nil
  28799. case tutorial.FieldDeletedAt:
  28800. v, ok := value.(time.Time)
  28801. if !ok {
  28802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28803. }
  28804. m.SetDeletedAt(v)
  28805. return nil
  28806. case tutorial.FieldEmployeeID:
  28807. v, ok := value.(uint64)
  28808. if !ok {
  28809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28810. }
  28811. m.SetEmployeeID(v)
  28812. return nil
  28813. case tutorial.FieldIndex:
  28814. v, ok := value.(int)
  28815. if !ok {
  28816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28817. }
  28818. m.SetIndex(v)
  28819. return nil
  28820. case tutorial.FieldTitle:
  28821. v, ok := value.(string)
  28822. if !ok {
  28823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28824. }
  28825. m.SetTitle(v)
  28826. return nil
  28827. case tutorial.FieldContent:
  28828. v, ok := value.(string)
  28829. if !ok {
  28830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28831. }
  28832. m.SetContent(v)
  28833. return nil
  28834. case tutorial.FieldOrganizationID:
  28835. v, ok := value.(uint64)
  28836. if !ok {
  28837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28838. }
  28839. m.SetOrganizationID(v)
  28840. return nil
  28841. }
  28842. return fmt.Errorf("unknown Tutorial field %s", name)
  28843. }
  28844. // AddedFields returns all numeric fields that were incremented/decremented during
  28845. // this mutation.
  28846. func (m *TutorialMutation) AddedFields() []string {
  28847. var fields []string
  28848. if m.addindex != nil {
  28849. fields = append(fields, tutorial.FieldIndex)
  28850. }
  28851. if m.addorganization_id != nil {
  28852. fields = append(fields, tutorial.FieldOrganizationID)
  28853. }
  28854. return fields
  28855. }
  28856. // AddedField returns the numeric value that was incremented/decremented on a field
  28857. // with the given name. The second boolean return value indicates that this field
  28858. // was not set, or was not defined in the schema.
  28859. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  28860. switch name {
  28861. case tutorial.FieldIndex:
  28862. return m.AddedIndex()
  28863. case tutorial.FieldOrganizationID:
  28864. return m.AddedOrganizationID()
  28865. }
  28866. return nil, false
  28867. }
  28868. // AddField adds the value to the field with the given name. It returns an error if
  28869. // the field is not defined in the schema, or if the type mismatched the field
  28870. // type.
  28871. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  28872. switch name {
  28873. case tutorial.FieldIndex:
  28874. v, ok := value.(int)
  28875. if !ok {
  28876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28877. }
  28878. m.AddIndex(v)
  28879. return nil
  28880. case tutorial.FieldOrganizationID:
  28881. v, ok := value.(int64)
  28882. if !ok {
  28883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28884. }
  28885. m.AddOrganizationID(v)
  28886. return nil
  28887. }
  28888. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  28889. }
  28890. // ClearedFields returns all nullable fields that were cleared during this
  28891. // mutation.
  28892. func (m *TutorialMutation) ClearedFields() []string {
  28893. var fields []string
  28894. if m.FieldCleared(tutorial.FieldDeletedAt) {
  28895. fields = append(fields, tutorial.FieldDeletedAt)
  28896. }
  28897. return fields
  28898. }
  28899. // FieldCleared returns a boolean indicating if a field with the given name was
  28900. // cleared in this mutation.
  28901. func (m *TutorialMutation) FieldCleared(name string) bool {
  28902. _, ok := m.clearedFields[name]
  28903. return ok
  28904. }
  28905. // ClearField clears the value of the field with the given name. It returns an
  28906. // error if the field is not defined in the schema.
  28907. func (m *TutorialMutation) ClearField(name string) error {
  28908. switch name {
  28909. case tutorial.FieldDeletedAt:
  28910. m.ClearDeletedAt()
  28911. return nil
  28912. }
  28913. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  28914. }
  28915. // ResetField resets all changes in the mutation for the field with the given name.
  28916. // It returns an error if the field is not defined in the schema.
  28917. func (m *TutorialMutation) ResetField(name string) error {
  28918. switch name {
  28919. case tutorial.FieldCreatedAt:
  28920. m.ResetCreatedAt()
  28921. return nil
  28922. case tutorial.FieldUpdatedAt:
  28923. m.ResetUpdatedAt()
  28924. return nil
  28925. case tutorial.FieldDeletedAt:
  28926. m.ResetDeletedAt()
  28927. return nil
  28928. case tutorial.FieldEmployeeID:
  28929. m.ResetEmployeeID()
  28930. return nil
  28931. case tutorial.FieldIndex:
  28932. m.ResetIndex()
  28933. return nil
  28934. case tutorial.FieldTitle:
  28935. m.ResetTitle()
  28936. return nil
  28937. case tutorial.FieldContent:
  28938. m.ResetContent()
  28939. return nil
  28940. case tutorial.FieldOrganizationID:
  28941. m.ResetOrganizationID()
  28942. return nil
  28943. }
  28944. return fmt.Errorf("unknown Tutorial field %s", name)
  28945. }
  28946. // AddedEdges returns all edge names that were set/added in this mutation.
  28947. func (m *TutorialMutation) AddedEdges() []string {
  28948. edges := make([]string, 0, 1)
  28949. if m.employee != nil {
  28950. edges = append(edges, tutorial.EdgeEmployee)
  28951. }
  28952. return edges
  28953. }
  28954. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28955. // name in this mutation.
  28956. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  28957. switch name {
  28958. case tutorial.EdgeEmployee:
  28959. if id := m.employee; id != nil {
  28960. return []ent.Value{*id}
  28961. }
  28962. }
  28963. return nil
  28964. }
  28965. // RemovedEdges returns all edge names that were removed in this mutation.
  28966. func (m *TutorialMutation) RemovedEdges() []string {
  28967. edges := make([]string, 0, 1)
  28968. return edges
  28969. }
  28970. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28971. // the given name in this mutation.
  28972. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  28973. return nil
  28974. }
  28975. // ClearedEdges returns all edge names that were cleared in this mutation.
  28976. func (m *TutorialMutation) ClearedEdges() []string {
  28977. edges := make([]string, 0, 1)
  28978. if m.clearedemployee {
  28979. edges = append(edges, tutorial.EdgeEmployee)
  28980. }
  28981. return edges
  28982. }
  28983. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28984. // was cleared in this mutation.
  28985. func (m *TutorialMutation) EdgeCleared(name string) bool {
  28986. switch name {
  28987. case tutorial.EdgeEmployee:
  28988. return m.clearedemployee
  28989. }
  28990. return false
  28991. }
  28992. // ClearEdge clears the value of the edge with the given name. It returns an error
  28993. // if that edge is not defined in the schema.
  28994. func (m *TutorialMutation) ClearEdge(name string) error {
  28995. switch name {
  28996. case tutorial.EdgeEmployee:
  28997. m.ClearEmployee()
  28998. return nil
  28999. }
  29000. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  29001. }
  29002. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29003. // It returns an error if the edge is not defined in the schema.
  29004. func (m *TutorialMutation) ResetEdge(name string) error {
  29005. switch name {
  29006. case tutorial.EdgeEmployee:
  29007. m.ResetEmployee()
  29008. return nil
  29009. }
  29010. return fmt.Errorf("unknown Tutorial edge %s", name)
  29011. }
  29012. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  29013. type UsageDetailMutation struct {
  29014. config
  29015. op Op
  29016. typ string
  29017. id *uint64
  29018. created_at *time.Time
  29019. updated_at *time.Time
  29020. status *uint8
  29021. addstatus *int8
  29022. _type *int
  29023. add_type *int
  29024. bot_id *string
  29025. receiver_id *string
  29026. app *int
  29027. addapp *int
  29028. session_id *uint64
  29029. addsession_id *int64
  29030. request *string
  29031. response *string
  29032. original_data *custom_types.OriginalData
  29033. total_tokens *uint64
  29034. addtotal_tokens *int64
  29035. prompt_tokens *uint64
  29036. addprompt_tokens *int64
  29037. completion_tokens *uint64
  29038. addcompletion_tokens *int64
  29039. organization_id *uint64
  29040. addorganization_id *int64
  29041. clearedFields map[string]struct{}
  29042. done bool
  29043. oldValue func(context.Context) (*UsageDetail, error)
  29044. predicates []predicate.UsageDetail
  29045. }
  29046. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  29047. // usagedetailOption allows management of the mutation configuration using functional options.
  29048. type usagedetailOption func(*UsageDetailMutation)
  29049. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  29050. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  29051. m := &UsageDetailMutation{
  29052. config: c,
  29053. op: op,
  29054. typ: TypeUsageDetail,
  29055. clearedFields: make(map[string]struct{}),
  29056. }
  29057. for _, opt := range opts {
  29058. opt(m)
  29059. }
  29060. return m
  29061. }
  29062. // withUsageDetailID sets the ID field of the mutation.
  29063. func withUsageDetailID(id uint64) usagedetailOption {
  29064. return func(m *UsageDetailMutation) {
  29065. var (
  29066. err error
  29067. once sync.Once
  29068. value *UsageDetail
  29069. )
  29070. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  29071. once.Do(func() {
  29072. if m.done {
  29073. err = errors.New("querying old values post mutation is not allowed")
  29074. } else {
  29075. value, err = m.Client().UsageDetail.Get(ctx, id)
  29076. }
  29077. })
  29078. return value, err
  29079. }
  29080. m.id = &id
  29081. }
  29082. }
  29083. // withUsageDetail sets the old UsageDetail of the mutation.
  29084. func withUsageDetail(node *UsageDetail) usagedetailOption {
  29085. return func(m *UsageDetailMutation) {
  29086. m.oldValue = func(context.Context) (*UsageDetail, error) {
  29087. return node, nil
  29088. }
  29089. m.id = &node.ID
  29090. }
  29091. }
  29092. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29093. // executed in a transaction (ent.Tx), a transactional client is returned.
  29094. func (m UsageDetailMutation) Client() *Client {
  29095. client := &Client{config: m.config}
  29096. client.init()
  29097. return client
  29098. }
  29099. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29100. // it returns an error otherwise.
  29101. func (m UsageDetailMutation) Tx() (*Tx, error) {
  29102. if _, ok := m.driver.(*txDriver); !ok {
  29103. return nil, errors.New("ent: mutation is not running in a transaction")
  29104. }
  29105. tx := &Tx{config: m.config}
  29106. tx.init()
  29107. return tx, nil
  29108. }
  29109. // SetID sets the value of the id field. Note that this
  29110. // operation is only accepted on creation of UsageDetail entities.
  29111. func (m *UsageDetailMutation) SetID(id uint64) {
  29112. m.id = &id
  29113. }
  29114. // ID returns the ID value in the mutation. Note that the ID is only available
  29115. // if it was provided to the builder or after it was returned from the database.
  29116. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  29117. if m.id == nil {
  29118. return
  29119. }
  29120. return *m.id, true
  29121. }
  29122. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29123. // That means, if the mutation is applied within a transaction with an isolation level such
  29124. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29125. // or updated by the mutation.
  29126. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  29127. switch {
  29128. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29129. id, exists := m.ID()
  29130. if exists {
  29131. return []uint64{id}, nil
  29132. }
  29133. fallthrough
  29134. case m.op.Is(OpUpdate | OpDelete):
  29135. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  29136. default:
  29137. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29138. }
  29139. }
  29140. // SetCreatedAt sets the "created_at" field.
  29141. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  29142. m.created_at = &t
  29143. }
  29144. // CreatedAt returns the value of the "created_at" field in the mutation.
  29145. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  29146. v := m.created_at
  29147. if v == nil {
  29148. return
  29149. }
  29150. return *v, true
  29151. }
  29152. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  29153. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29155. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29156. if !m.op.Is(OpUpdateOne) {
  29157. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29158. }
  29159. if m.id == nil || m.oldValue == nil {
  29160. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29161. }
  29162. oldValue, err := m.oldValue(ctx)
  29163. if err != nil {
  29164. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29165. }
  29166. return oldValue.CreatedAt, nil
  29167. }
  29168. // ResetCreatedAt resets all changes to the "created_at" field.
  29169. func (m *UsageDetailMutation) ResetCreatedAt() {
  29170. m.created_at = nil
  29171. }
  29172. // SetUpdatedAt sets the "updated_at" field.
  29173. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  29174. m.updated_at = &t
  29175. }
  29176. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29177. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  29178. v := m.updated_at
  29179. if v == nil {
  29180. return
  29181. }
  29182. return *v, true
  29183. }
  29184. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  29185. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29187. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29188. if !m.op.Is(OpUpdateOne) {
  29189. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29190. }
  29191. if m.id == nil || m.oldValue == nil {
  29192. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29193. }
  29194. oldValue, err := m.oldValue(ctx)
  29195. if err != nil {
  29196. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29197. }
  29198. return oldValue.UpdatedAt, nil
  29199. }
  29200. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29201. func (m *UsageDetailMutation) ResetUpdatedAt() {
  29202. m.updated_at = nil
  29203. }
  29204. // SetStatus sets the "status" field.
  29205. func (m *UsageDetailMutation) SetStatus(u uint8) {
  29206. m.status = &u
  29207. m.addstatus = nil
  29208. }
  29209. // Status returns the value of the "status" field in the mutation.
  29210. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  29211. v := m.status
  29212. if v == nil {
  29213. return
  29214. }
  29215. return *v, true
  29216. }
  29217. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  29218. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29220. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29221. if !m.op.Is(OpUpdateOne) {
  29222. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29223. }
  29224. if m.id == nil || m.oldValue == nil {
  29225. return v, errors.New("OldStatus requires an ID field in the mutation")
  29226. }
  29227. oldValue, err := m.oldValue(ctx)
  29228. if err != nil {
  29229. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29230. }
  29231. return oldValue.Status, nil
  29232. }
  29233. // AddStatus adds u to the "status" field.
  29234. func (m *UsageDetailMutation) AddStatus(u int8) {
  29235. if m.addstatus != nil {
  29236. *m.addstatus += u
  29237. } else {
  29238. m.addstatus = &u
  29239. }
  29240. }
  29241. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29242. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  29243. v := m.addstatus
  29244. if v == nil {
  29245. return
  29246. }
  29247. return *v, true
  29248. }
  29249. // ClearStatus clears the value of the "status" field.
  29250. func (m *UsageDetailMutation) ClearStatus() {
  29251. m.status = nil
  29252. m.addstatus = nil
  29253. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  29254. }
  29255. // StatusCleared returns if the "status" field was cleared in this mutation.
  29256. func (m *UsageDetailMutation) StatusCleared() bool {
  29257. _, ok := m.clearedFields[usagedetail.FieldStatus]
  29258. return ok
  29259. }
  29260. // ResetStatus resets all changes to the "status" field.
  29261. func (m *UsageDetailMutation) ResetStatus() {
  29262. m.status = nil
  29263. m.addstatus = nil
  29264. delete(m.clearedFields, usagedetail.FieldStatus)
  29265. }
  29266. // SetType sets the "type" field.
  29267. func (m *UsageDetailMutation) SetType(i int) {
  29268. m._type = &i
  29269. m.add_type = nil
  29270. }
  29271. // GetType returns the value of the "type" field in the mutation.
  29272. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  29273. v := m._type
  29274. if v == nil {
  29275. return
  29276. }
  29277. return *v, true
  29278. }
  29279. // OldType returns the old "type" field's value of the UsageDetail entity.
  29280. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29282. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  29283. if !m.op.Is(OpUpdateOne) {
  29284. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29285. }
  29286. if m.id == nil || m.oldValue == nil {
  29287. return v, errors.New("OldType requires an ID field in the mutation")
  29288. }
  29289. oldValue, err := m.oldValue(ctx)
  29290. if err != nil {
  29291. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29292. }
  29293. return oldValue.Type, nil
  29294. }
  29295. // AddType adds i to the "type" field.
  29296. func (m *UsageDetailMutation) AddType(i int) {
  29297. if m.add_type != nil {
  29298. *m.add_type += i
  29299. } else {
  29300. m.add_type = &i
  29301. }
  29302. }
  29303. // AddedType returns the value that was added to the "type" field in this mutation.
  29304. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  29305. v := m.add_type
  29306. if v == nil {
  29307. return
  29308. }
  29309. return *v, true
  29310. }
  29311. // ClearType clears the value of the "type" field.
  29312. func (m *UsageDetailMutation) ClearType() {
  29313. m._type = nil
  29314. m.add_type = nil
  29315. m.clearedFields[usagedetail.FieldType] = struct{}{}
  29316. }
  29317. // TypeCleared returns if the "type" field was cleared in this mutation.
  29318. func (m *UsageDetailMutation) TypeCleared() bool {
  29319. _, ok := m.clearedFields[usagedetail.FieldType]
  29320. return ok
  29321. }
  29322. // ResetType resets all changes to the "type" field.
  29323. func (m *UsageDetailMutation) ResetType() {
  29324. m._type = nil
  29325. m.add_type = nil
  29326. delete(m.clearedFields, usagedetail.FieldType)
  29327. }
  29328. // SetBotID sets the "bot_id" field.
  29329. func (m *UsageDetailMutation) SetBotID(s string) {
  29330. m.bot_id = &s
  29331. }
  29332. // BotID returns the value of the "bot_id" field in the mutation.
  29333. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  29334. v := m.bot_id
  29335. if v == nil {
  29336. return
  29337. }
  29338. return *v, true
  29339. }
  29340. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  29341. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29343. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  29344. if !m.op.Is(OpUpdateOne) {
  29345. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29346. }
  29347. if m.id == nil || m.oldValue == nil {
  29348. return v, errors.New("OldBotID requires an ID field in the mutation")
  29349. }
  29350. oldValue, err := m.oldValue(ctx)
  29351. if err != nil {
  29352. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29353. }
  29354. return oldValue.BotID, nil
  29355. }
  29356. // ResetBotID resets all changes to the "bot_id" field.
  29357. func (m *UsageDetailMutation) ResetBotID() {
  29358. m.bot_id = nil
  29359. }
  29360. // SetReceiverID sets the "receiver_id" field.
  29361. func (m *UsageDetailMutation) SetReceiverID(s string) {
  29362. m.receiver_id = &s
  29363. }
  29364. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  29365. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  29366. v := m.receiver_id
  29367. if v == nil {
  29368. return
  29369. }
  29370. return *v, true
  29371. }
  29372. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  29373. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29375. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  29376. if !m.op.Is(OpUpdateOne) {
  29377. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  29378. }
  29379. if m.id == nil || m.oldValue == nil {
  29380. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  29381. }
  29382. oldValue, err := m.oldValue(ctx)
  29383. if err != nil {
  29384. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  29385. }
  29386. return oldValue.ReceiverID, nil
  29387. }
  29388. // ResetReceiverID resets all changes to the "receiver_id" field.
  29389. func (m *UsageDetailMutation) ResetReceiverID() {
  29390. m.receiver_id = nil
  29391. }
  29392. // SetApp sets the "app" field.
  29393. func (m *UsageDetailMutation) SetApp(i int) {
  29394. m.app = &i
  29395. m.addapp = nil
  29396. }
  29397. // App returns the value of the "app" field in the mutation.
  29398. func (m *UsageDetailMutation) App() (r int, exists bool) {
  29399. v := m.app
  29400. if v == nil {
  29401. return
  29402. }
  29403. return *v, true
  29404. }
  29405. // OldApp returns the old "app" field's value of the UsageDetail entity.
  29406. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29408. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  29409. if !m.op.Is(OpUpdateOne) {
  29410. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  29411. }
  29412. if m.id == nil || m.oldValue == nil {
  29413. return v, errors.New("OldApp requires an ID field in the mutation")
  29414. }
  29415. oldValue, err := m.oldValue(ctx)
  29416. if err != nil {
  29417. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  29418. }
  29419. return oldValue.App, nil
  29420. }
  29421. // AddApp adds i to the "app" field.
  29422. func (m *UsageDetailMutation) AddApp(i int) {
  29423. if m.addapp != nil {
  29424. *m.addapp += i
  29425. } else {
  29426. m.addapp = &i
  29427. }
  29428. }
  29429. // AddedApp returns the value that was added to the "app" field in this mutation.
  29430. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  29431. v := m.addapp
  29432. if v == nil {
  29433. return
  29434. }
  29435. return *v, true
  29436. }
  29437. // ClearApp clears the value of the "app" field.
  29438. func (m *UsageDetailMutation) ClearApp() {
  29439. m.app = nil
  29440. m.addapp = nil
  29441. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  29442. }
  29443. // AppCleared returns if the "app" field was cleared in this mutation.
  29444. func (m *UsageDetailMutation) AppCleared() bool {
  29445. _, ok := m.clearedFields[usagedetail.FieldApp]
  29446. return ok
  29447. }
  29448. // ResetApp resets all changes to the "app" field.
  29449. func (m *UsageDetailMutation) ResetApp() {
  29450. m.app = nil
  29451. m.addapp = nil
  29452. delete(m.clearedFields, usagedetail.FieldApp)
  29453. }
  29454. // SetSessionID sets the "session_id" field.
  29455. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  29456. m.session_id = &u
  29457. m.addsession_id = nil
  29458. }
  29459. // SessionID returns the value of the "session_id" field in the mutation.
  29460. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  29461. v := m.session_id
  29462. if v == nil {
  29463. return
  29464. }
  29465. return *v, true
  29466. }
  29467. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  29468. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29470. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  29471. if !m.op.Is(OpUpdateOne) {
  29472. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  29473. }
  29474. if m.id == nil || m.oldValue == nil {
  29475. return v, errors.New("OldSessionID requires an ID field in the mutation")
  29476. }
  29477. oldValue, err := m.oldValue(ctx)
  29478. if err != nil {
  29479. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  29480. }
  29481. return oldValue.SessionID, nil
  29482. }
  29483. // AddSessionID adds u to the "session_id" field.
  29484. func (m *UsageDetailMutation) AddSessionID(u int64) {
  29485. if m.addsession_id != nil {
  29486. *m.addsession_id += u
  29487. } else {
  29488. m.addsession_id = &u
  29489. }
  29490. }
  29491. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  29492. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  29493. v := m.addsession_id
  29494. if v == nil {
  29495. return
  29496. }
  29497. return *v, true
  29498. }
  29499. // ClearSessionID clears the value of the "session_id" field.
  29500. func (m *UsageDetailMutation) ClearSessionID() {
  29501. m.session_id = nil
  29502. m.addsession_id = nil
  29503. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  29504. }
  29505. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  29506. func (m *UsageDetailMutation) SessionIDCleared() bool {
  29507. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  29508. return ok
  29509. }
  29510. // ResetSessionID resets all changes to the "session_id" field.
  29511. func (m *UsageDetailMutation) ResetSessionID() {
  29512. m.session_id = nil
  29513. m.addsession_id = nil
  29514. delete(m.clearedFields, usagedetail.FieldSessionID)
  29515. }
  29516. // SetRequest sets the "request" field.
  29517. func (m *UsageDetailMutation) SetRequest(s string) {
  29518. m.request = &s
  29519. }
  29520. // Request returns the value of the "request" field in the mutation.
  29521. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  29522. v := m.request
  29523. if v == nil {
  29524. return
  29525. }
  29526. return *v, true
  29527. }
  29528. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  29529. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29531. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  29532. if !m.op.Is(OpUpdateOne) {
  29533. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  29534. }
  29535. if m.id == nil || m.oldValue == nil {
  29536. return v, errors.New("OldRequest requires an ID field in the mutation")
  29537. }
  29538. oldValue, err := m.oldValue(ctx)
  29539. if err != nil {
  29540. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  29541. }
  29542. return oldValue.Request, nil
  29543. }
  29544. // ResetRequest resets all changes to the "request" field.
  29545. func (m *UsageDetailMutation) ResetRequest() {
  29546. m.request = nil
  29547. }
  29548. // SetResponse sets the "response" field.
  29549. func (m *UsageDetailMutation) SetResponse(s string) {
  29550. m.response = &s
  29551. }
  29552. // Response returns the value of the "response" field in the mutation.
  29553. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  29554. v := m.response
  29555. if v == nil {
  29556. return
  29557. }
  29558. return *v, true
  29559. }
  29560. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  29561. // If the UsageDetail 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 *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  29564. if !m.op.Is(OpUpdateOne) {
  29565. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  29566. }
  29567. if m.id == nil || m.oldValue == nil {
  29568. return v, errors.New("OldResponse 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 OldResponse: %w", err)
  29573. }
  29574. return oldValue.Response, nil
  29575. }
  29576. // ResetResponse resets all changes to the "response" field.
  29577. func (m *UsageDetailMutation) ResetResponse() {
  29578. m.response = nil
  29579. }
  29580. // SetOriginalData sets the "original_data" field.
  29581. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  29582. m.original_data = &ctd
  29583. }
  29584. // OriginalData returns the value of the "original_data" field in the mutation.
  29585. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  29586. v := m.original_data
  29587. if v == nil {
  29588. return
  29589. }
  29590. return *v, true
  29591. }
  29592. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  29593. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29595. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  29596. if !m.op.Is(OpUpdateOne) {
  29597. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  29598. }
  29599. if m.id == nil || m.oldValue == nil {
  29600. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  29601. }
  29602. oldValue, err := m.oldValue(ctx)
  29603. if err != nil {
  29604. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  29605. }
  29606. return oldValue.OriginalData, nil
  29607. }
  29608. // ResetOriginalData resets all changes to the "original_data" field.
  29609. func (m *UsageDetailMutation) ResetOriginalData() {
  29610. m.original_data = nil
  29611. }
  29612. // SetTotalTokens sets the "total_tokens" field.
  29613. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  29614. m.total_tokens = &u
  29615. m.addtotal_tokens = nil
  29616. }
  29617. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  29618. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  29619. v := m.total_tokens
  29620. if v == nil {
  29621. return
  29622. }
  29623. return *v, true
  29624. }
  29625. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  29626. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29628. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  29629. if !m.op.Is(OpUpdateOne) {
  29630. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  29631. }
  29632. if m.id == nil || m.oldValue == nil {
  29633. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  29634. }
  29635. oldValue, err := m.oldValue(ctx)
  29636. if err != nil {
  29637. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  29638. }
  29639. return oldValue.TotalTokens, nil
  29640. }
  29641. // AddTotalTokens adds u to the "total_tokens" field.
  29642. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  29643. if m.addtotal_tokens != nil {
  29644. *m.addtotal_tokens += u
  29645. } else {
  29646. m.addtotal_tokens = &u
  29647. }
  29648. }
  29649. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  29650. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  29651. v := m.addtotal_tokens
  29652. if v == nil {
  29653. return
  29654. }
  29655. return *v, true
  29656. }
  29657. // ClearTotalTokens clears the value of the "total_tokens" field.
  29658. func (m *UsageDetailMutation) ClearTotalTokens() {
  29659. m.total_tokens = nil
  29660. m.addtotal_tokens = nil
  29661. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  29662. }
  29663. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  29664. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  29665. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  29666. return ok
  29667. }
  29668. // ResetTotalTokens resets all changes to the "total_tokens" field.
  29669. func (m *UsageDetailMutation) ResetTotalTokens() {
  29670. m.total_tokens = nil
  29671. m.addtotal_tokens = nil
  29672. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  29673. }
  29674. // SetPromptTokens sets the "prompt_tokens" field.
  29675. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  29676. m.prompt_tokens = &u
  29677. m.addprompt_tokens = nil
  29678. }
  29679. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  29680. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  29681. v := m.prompt_tokens
  29682. if v == nil {
  29683. return
  29684. }
  29685. return *v, true
  29686. }
  29687. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  29688. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29690. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  29691. if !m.op.Is(OpUpdateOne) {
  29692. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  29693. }
  29694. if m.id == nil || m.oldValue == nil {
  29695. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  29696. }
  29697. oldValue, err := m.oldValue(ctx)
  29698. if err != nil {
  29699. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  29700. }
  29701. return oldValue.PromptTokens, nil
  29702. }
  29703. // AddPromptTokens adds u to the "prompt_tokens" field.
  29704. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  29705. if m.addprompt_tokens != nil {
  29706. *m.addprompt_tokens += u
  29707. } else {
  29708. m.addprompt_tokens = &u
  29709. }
  29710. }
  29711. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  29712. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  29713. v := m.addprompt_tokens
  29714. if v == nil {
  29715. return
  29716. }
  29717. return *v, true
  29718. }
  29719. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  29720. func (m *UsageDetailMutation) ClearPromptTokens() {
  29721. m.prompt_tokens = nil
  29722. m.addprompt_tokens = nil
  29723. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  29724. }
  29725. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  29726. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  29727. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  29728. return ok
  29729. }
  29730. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  29731. func (m *UsageDetailMutation) ResetPromptTokens() {
  29732. m.prompt_tokens = nil
  29733. m.addprompt_tokens = nil
  29734. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  29735. }
  29736. // SetCompletionTokens sets the "completion_tokens" field.
  29737. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  29738. m.completion_tokens = &u
  29739. m.addcompletion_tokens = nil
  29740. }
  29741. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  29742. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  29743. v := m.completion_tokens
  29744. if v == nil {
  29745. return
  29746. }
  29747. return *v, true
  29748. }
  29749. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  29750. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29752. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  29753. if !m.op.Is(OpUpdateOne) {
  29754. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  29755. }
  29756. if m.id == nil || m.oldValue == nil {
  29757. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  29758. }
  29759. oldValue, err := m.oldValue(ctx)
  29760. if err != nil {
  29761. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  29762. }
  29763. return oldValue.CompletionTokens, nil
  29764. }
  29765. // AddCompletionTokens adds u to the "completion_tokens" field.
  29766. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  29767. if m.addcompletion_tokens != nil {
  29768. *m.addcompletion_tokens += u
  29769. } else {
  29770. m.addcompletion_tokens = &u
  29771. }
  29772. }
  29773. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  29774. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  29775. v := m.addcompletion_tokens
  29776. if v == nil {
  29777. return
  29778. }
  29779. return *v, true
  29780. }
  29781. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  29782. func (m *UsageDetailMutation) ClearCompletionTokens() {
  29783. m.completion_tokens = nil
  29784. m.addcompletion_tokens = nil
  29785. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  29786. }
  29787. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  29788. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  29789. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  29790. return ok
  29791. }
  29792. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  29793. func (m *UsageDetailMutation) ResetCompletionTokens() {
  29794. m.completion_tokens = nil
  29795. m.addcompletion_tokens = nil
  29796. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  29797. }
  29798. // SetOrganizationID sets the "organization_id" field.
  29799. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  29800. m.organization_id = &u
  29801. m.addorganization_id = nil
  29802. }
  29803. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29804. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  29805. v := m.organization_id
  29806. if v == nil {
  29807. return
  29808. }
  29809. return *v, true
  29810. }
  29811. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  29812. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29814. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29815. if !m.op.Is(OpUpdateOne) {
  29816. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29817. }
  29818. if m.id == nil || m.oldValue == nil {
  29819. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29820. }
  29821. oldValue, err := m.oldValue(ctx)
  29822. if err != nil {
  29823. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29824. }
  29825. return oldValue.OrganizationID, nil
  29826. }
  29827. // AddOrganizationID adds u to the "organization_id" field.
  29828. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  29829. if m.addorganization_id != nil {
  29830. *m.addorganization_id += u
  29831. } else {
  29832. m.addorganization_id = &u
  29833. }
  29834. }
  29835. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29836. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  29837. v := m.addorganization_id
  29838. if v == nil {
  29839. return
  29840. }
  29841. return *v, true
  29842. }
  29843. // ClearOrganizationID clears the value of the "organization_id" field.
  29844. func (m *UsageDetailMutation) ClearOrganizationID() {
  29845. m.organization_id = nil
  29846. m.addorganization_id = nil
  29847. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  29848. }
  29849. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29850. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  29851. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  29852. return ok
  29853. }
  29854. // ResetOrganizationID resets all changes to the "organization_id" field.
  29855. func (m *UsageDetailMutation) ResetOrganizationID() {
  29856. m.organization_id = nil
  29857. m.addorganization_id = nil
  29858. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  29859. }
  29860. // Where appends a list predicates to the UsageDetailMutation builder.
  29861. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  29862. m.predicates = append(m.predicates, ps...)
  29863. }
  29864. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  29865. // users can use type-assertion to append predicates that do not depend on any generated package.
  29866. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  29867. p := make([]predicate.UsageDetail, len(ps))
  29868. for i := range ps {
  29869. p[i] = ps[i]
  29870. }
  29871. m.Where(p...)
  29872. }
  29873. // Op returns the operation name.
  29874. func (m *UsageDetailMutation) Op() Op {
  29875. return m.op
  29876. }
  29877. // SetOp allows setting the mutation operation.
  29878. func (m *UsageDetailMutation) SetOp(op Op) {
  29879. m.op = op
  29880. }
  29881. // Type returns the node type of this mutation (UsageDetail).
  29882. func (m *UsageDetailMutation) Type() string {
  29883. return m.typ
  29884. }
  29885. // Fields returns all fields that were changed during this mutation. Note that in
  29886. // order to get all numeric fields that were incremented/decremented, call
  29887. // AddedFields().
  29888. func (m *UsageDetailMutation) Fields() []string {
  29889. fields := make([]string, 0, 15)
  29890. if m.created_at != nil {
  29891. fields = append(fields, usagedetail.FieldCreatedAt)
  29892. }
  29893. if m.updated_at != nil {
  29894. fields = append(fields, usagedetail.FieldUpdatedAt)
  29895. }
  29896. if m.status != nil {
  29897. fields = append(fields, usagedetail.FieldStatus)
  29898. }
  29899. if m._type != nil {
  29900. fields = append(fields, usagedetail.FieldType)
  29901. }
  29902. if m.bot_id != nil {
  29903. fields = append(fields, usagedetail.FieldBotID)
  29904. }
  29905. if m.receiver_id != nil {
  29906. fields = append(fields, usagedetail.FieldReceiverID)
  29907. }
  29908. if m.app != nil {
  29909. fields = append(fields, usagedetail.FieldApp)
  29910. }
  29911. if m.session_id != nil {
  29912. fields = append(fields, usagedetail.FieldSessionID)
  29913. }
  29914. if m.request != nil {
  29915. fields = append(fields, usagedetail.FieldRequest)
  29916. }
  29917. if m.response != nil {
  29918. fields = append(fields, usagedetail.FieldResponse)
  29919. }
  29920. if m.original_data != nil {
  29921. fields = append(fields, usagedetail.FieldOriginalData)
  29922. }
  29923. if m.total_tokens != nil {
  29924. fields = append(fields, usagedetail.FieldTotalTokens)
  29925. }
  29926. if m.prompt_tokens != nil {
  29927. fields = append(fields, usagedetail.FieldPromptTokens)
  29928. }
  29929. if m.completion_tokens != nil {
  29930. fields = append(fields, usagedetail.FieldCompletionTokens)
  29931. }
  29932. if m.organization_id != nil {
  29933. fields = append(fields, usagedetail.FieldOrganizationID)
  29934. }
  29935. return fields
  29936. }
  29937. // Field returns the value of a field with the given name. The second boolean
  29938. // return value indicates that this field was not set, or was not defined in the
  29939. // schema.
  29940. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  29941. switch name {
  29942. case usagedetail.FieldCreatedAt:
  29943. return m.CreatedAt()
  29944. case usagedetail.FieldUpdatedAt:
  29945. return m.UpdatedAt()
  29946. case usagedetail.FieldStatus:
  29947. return m.Status()
  29948. case usagedetail.FieldType:
  29949. return m.GetType()
  29950. case usagedetail.FieldBotID:
  29951. return m.BotID()
  29952. case usagedetail.FieldReceiverID:
  29953. return m.ReceiverID()
  29954. case usagedetail.FieldApp:
  29955. return m.App()
  29956. case usagedetail.FieldSessionID:
  29957. return m.SessionID()
  29958. case usagedetail.FieldRequest:
  29959. return m.Request()
  29960. case usagedetail.FieldResponse:
  29961. return m.Response()
  29962. case usagedetail.FieldOriginalData:
  29963. return m.OriginalData()
  29964. case usagedetail.FieldTotalTokens:
  29965. return m.TotalTokens()
  29966. case usagedetail.FieldPromptTokens:
  29967. return m.PromptTokens()
  29968. case usagedetail.FieldCompletionTokens:
  29969. return m.CompletionTokens()
  29970. case usagedetail.FieldOrganizationID:
  29971. return m.OrganizationID()
  29972. }
  29973. return nil, false
  29974. }
  29975. // OldField returns the old value of the field from the database. An error is
  29976. // returned if the mutation operation is not UpdateOne, or the query to the
  29977. // database failed.
  29978. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29979. switch name {
  29980. case usagedetail.FieldCreatedAt:
  29981. return m.OldCreatedAt(ctx)
  29982. case usagedetail.FieldUpdatedAt:
  29983. return m.OldUpdatedAt(ctx)
  29984. case usagedetail.FieldStatus:
  29985. return m.OldStatus(ctx)
  29986. case usagedetail.FieldType:
  29987. return m.OldType(ctx)
  29988. case usagedetail.FieldBotID:
  29989. return m.OldBotID(ctx)
  29990. case usagedetail.FieldReceiverID:
  29991. return m.OldReceiverID(ctx)
  29992. case usagedetail.FieldApp:
  29993. return m.OldApp(ctx)
  29994. case usagedetail.FieldSessionID:
  29995. return m.OldSessionID(ctx)
  29996. case usagedetail.FieldRequest:
  29997. return m.OldRequest(ctx)
  29998. case usagedetail.FieldResponse:
  29999. return m.OldResponse(ctx)
  30000. case usagedetail.FieldOriginalData:
  30001. return m.OldOriginalData(ctx)
  30002. case usagedetail.FieldTotalTokens:
  30003. return m.OldTotalTokens(ctx)
  30004. case usagedetail.FieldPromptTokens:
  30005. return m.OldPromptTokens(ctx)
  30006. case usagedetail.FieldCompletionTokens:
  30007. return m.OldCompletionTokens(ctx)
  30008. case usagedetail.FieldOrganizationID:
  30009. return m.OldOrganizationID(ctx)
  30010. }
  30011. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  30012. }
  30013. // SetField sets the value of a field with the given name. It returns an error if
  30014. // the field is not defined in the schema, or if the type mismatched the field
  30015. // type.
  30016. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  30017. switch name {
  30018. case usagedetail.FieldCreatedAt:
  30019. v, ok := value.(time.Time)
  30020. if !ok {
  30021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30022. }
  30023. m.SetCreatedAt(v)
  30024. return nil
  30025. case usagedetail.FieldUpdatedAt:
  30026. v, ok := value.(time.Time)
  30027. if !ok {
  30028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30029. }
  30030. m.SetUpdatedAt(v)
  30031. return nil
  30032. case usagedetail.FieldStatus:
  30033. v, ok := value.(uint8)
  30034. if !ok {
  30035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30036. }
  30037. m.SetStatus(v)
  30038. return nil
  30039. case usagedetail.FieldType:
  30040. v, ok := value.(int)
  30041. if !ok {
  30042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30043. }
  30044. m.SetType(v)
  30045. return nil
  30046. case usagedetail.FieldBotID:
  30047. v, ok := value.(string)
  30048. if !ok {
  30049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30050. }
  30051. m.SetBotID(v)
  30052. return nil
  30053. case usagedetail.FieldReceiverID:
  30054. v, ok := value.(string)
  30055. if !ok {
  30056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30057. }
  30058. m.SetReceiverID(v)
  30059. return nil
  30060. case usagedetail.FieldApp:
  30061. v, ok := value.(int)
  30062. if !ok {
  30063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30064. }
  30065. m.SetApp(v)
  30066. return nil
  30067. case usagedetail.FieldSessionID:
  30068. v, ok := value.(uint64)
  30069. if !ok {
  30070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30071. }
  30072. m.SetSessionID(v)
  30073. return nil
  30074. case usagedetail.FieldRequest:
  30075. v, ok := value.(string)
  30076. if !ok {
  30077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30078. }
  30079. m.SetRequest(v)
  30080. return nil
  30081. case usagedetail.FieldResponse:
  30082. v, ok := value.(string)
  30083. if !ok {
  30084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30085. }
  30086. m.SetResponse(v)
  30087. return nil
  30088. case usagedetail.FieldOriginalData:
  30089. v, ok := value.(custom_types.OriginalData)
  30090. if !ok {
  30091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30092. }
  30093. m.SetOriginalData(v)
  30094. return nil
  30095. case usagedetail.FieldTotalTokens:
  30096. v, ok := value.(uint64)
  30097. if !ok {
  30098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30099. }
  30100. m.SetTotalTokens(v)
  30101. return nil
  30102. case usagedetail.FieldPromptTokens:
  30103. v, ok := value.(uint64)
  30104. if !ok {
  30105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30106. }
  30107. m.SetPromptTokens(v)
  30108. return nil
  30109. case usagedetail.FieldCompletionTokens:
  30110. v, ok := value.(uint64)
  30111. if !ok {
  30112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30113. }
  30114. m.SetCompletionTokens(v)
  30115. return nil
  30116. case usagedetail.FieldOrganizationID:
  30117. v, ok := value.(uint64)
  30118. if !ok {
  30119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30120. }
  30121. m.SetOrganizationID(v)
  30122. return nil
  30123. }
  30124. return fmt.Errorf("unknown UsageDetail field %s", name)
  30125. }
  30126. // AddedFields returns all numeric fields that were incremented/decremented during
  30127. // this mutation.
  30128. func (m *UsageDetailMutation) AddedFields() []string {
  30129. var fields []string
  30130. if m.addstatus != nil {
  30131. fields = append(fields, usagedetail.FieldStatus)
  30132. }
  30133. if m.add_type != nil {
  30134. fields = append(fields, usagedetail.FieldType)
  30135. }
  30136. if m.addapp != nil {
  30137. fields = append(fields, usagedetail.FieldApp)
  30138. }
  30139. if m.addsession_id != nil {
  30140. fields = append(fields, usagedetail.FieldSessionID)
  30141. }
  30142. if m.addtotal_tokens != nil {
  30143. fields = append(fields, usagedetail.FieldTotalTokens)
  30144. }
  30145. if m.addprompt_tokens != nil {
  30146. fields = append(fields, usagedetail.FieldPromptTokens)
  30147. }
  30148. if m.addcompletion_tokens != nil {
  30149. fields = append(fields, usagedetail.FieldCompletionTokens)
  30150. }
  30151. if m.addorganization_id != nil {
  30152. fields = append(fields, usagedetail.FieldOrganizationID)
  30153. }
  30154. return fields
  30155. }
  30156. // AddedField returns the numeric value that was incremented/decremented on a field
  30157. // with the given name. The second boolean return value indicates that this field
  30158. // was not set, or was not defined in the schema.
  30159. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  30160. switch name {
  30161. case usagedetail.FieldStatus:
  30162. return m.AddedStatus()
  30163. case usagedetail.FieldType:
  30164. return m.AddedType()
  30165. case usagedetail.FieldApp:
  30166. return m.AddedApp()
  30167. case usagedetail.FieldSessionID:
  30168. return m.AddedSessionID()
  30169. case usagedetail.FieldTotalTokens:
  30170. return m.AddedTotalTokens()
  30171. case usagedetail.FieldPromptTokens:
  30172. return m.AddedPromptTokens()
  30173. case usagedetail.FieldCompletionTokens:
  30174. return m.AddedCompletionTokens()
  30175. case usagedetail.FieldOrganizationID:
  30176. return m.AddedOrganizationID()
  30177. }
  30178. return nil, false
  30179. }
  30180. // AddField adds the value to the field with the given name. It returns an error if
  30181. // the field is not defined in the schema, or if the type mismatched the field
  30182. // type.
  30183. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  30184. switch name {
  30185. case usagedetail.FieldStatus:
  30186. v, ok := value.(int8)
  30187. if !ok {
  30188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30189. }
  30190. m.AddStatus(v)
  30191. return nil
  30192. case usagedetail.FieldType:
  30193. v, ok := value.(int)
  30194. if !ok {
  30195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30196. }
  30197. m.AddType(v)
  30198. return nil
  30199. case usagedetail.FieldApp:
  30200. v, ok := value.(int)
  30201. if !ok {
  30202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30203. }
  30204. m.AddApp(v)
  30205. return nil
  30206. case usagedetail.FieldSessionID:
  30207. v, ok := value.(int64)
  30208. if !ok {
  30209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30210. }
  30211. m.AddSessionID(v)
  30212. return nil
  30213. case usagedetail.FieldTotalTokens:
  30214. v, ok := value.(int64)
  30215. if !ok {
  30216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30217. }
  30218. m.AddTotalTokens(v)
  30219. return nil
  30220. case usagedetail.FieldPromptTokens:
  30221. v, ok := value.(int64)
  30222. if !ok {
  30223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30224. }
  30225. m.AddPromptTokens(v)
  30226. return nil
  30227. case usagedetail.FieldCompletionTokens:
  30228. v, ok := value.(int64)
  30229. if !ok {
  30230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30231. }
  30232. m.AddCompletionTokens(v)
  30233. return nil
  30234. case usagedetail.FieldOrganizationID:
  30235. v, ok := value.(int64)
  30236. if !ok {
  30237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30238. }
  30239. m.AddOrganizationID(v)
  30240. return nil
  30241. }
  30242. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  30243. }
  30244. // ClearedFields returns all nullable fields that were cleared during this
  30245. // mutation.
  30246. func (m *UsageDetailMutation) ClearedFields() []string {
  30247. var fields []string
  30248. if m.FieldCleared(usagedetail.FieldStatus) {
  30249. fields = append(fields, usagedetail.FieldStatus)
  30250. }
  30251. if m.FieldCleared(usagedetail.FieldType) {
  30252. fields = append(fields, usagedetail.FieldType)
  30253. }
  30254. if m.FieldCleared(usagedetail.FieldApp) {
  30255. fields = append(fields, usagedetail.FieldApp)
  30256. }
  30257. if m.FieldCleared(usagedetail.FieldSessionID) {
  30258. fields = append(fields, usagedetail.FieldSessionID)
  30259. }
  30260. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  30261. fields = append(fields, usagedetail.FieldTotalTokens)
  30262. }
  30263. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  30264. fields = append(fields, usagedetail.FieldPromptTokens)
  30265. }
  30266. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  30267. fields = append(fields, usagedetail.FieldCompletionTokens)
  30268. }
  30269. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  30270. fields = append(fields, usagedetail.FieldOrganizationID)
  30271. }
  30272. return fields
  30273. }
  30274. // FieldCleared returns a boolean indicating if a field with the given name was
  30275. // cleared in this mutation.
  30276. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  30277. _, ok := m.clearedFields[name]
  30278. return ok
  30279. }
  30280. // ClearField clears the value of the field with the given name. It returns an
  30281. // error if the field is not defined in the schema.
  30282. func (m *UsageDetailMutation) ClearField(name string) error {
  30283. switch name {
  30284. case usagedetail.FieldStatus:
  30285. m.ClearStatus()
  30286. return nil
  30287. case usagedetail.FieldType:
  30288. m.ClearType()
  30289. return nil
  30290. case usagedetail.FieldApp:
  30291. m.ClearApp()
  30292. return nil
  30293. case usagedetail.FieldSessionID:
  30294. m.ClearSessionID()
  30295. return nil
  30296. case usagedetail.FieldTotalTokens:
  30297. m.ClearTotalTokens()
  30298. return nil
  30299. case usagedetail.FieldPromptTokens:
  30300. m.ClearPromptTokens()
  30301. return nil
  30302. case usagedetail.FieldCompletionTokens:
  30303. m.ClearCompletionTokens()
  30304. return nil
  30305. case usagedetail.FieldOrganizationID:
  30306. m.ClearOrganizationID()
  30307. return nil
  30308. }
  30309. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  30310. }
  30311. // ResetField resets all changes in the mutation for the field with the given name.
  30312. // It returns an error if the field is not defined in the schema.
  30313. func (m *UsageDetailMutation) ResetField(name string) error {
  30314. switch name {
  30315. case usagedetail.FieldCreatedAt:
  30316. m.ResetCreatedAt()
  30317. return nil
  30318. case usagedetail.FieldUpdatedAt:
  30319. m.ResetUpdatedAt()
  30320. return nil
  30321. case usagedetail.FieldStatus:
  30322. m.ResetStatus()
  30323. return nil
  30324. case usagedetail.FieldType:
  30325. m.ResetType()
  30326. return nil
  30327. case usagedetail.FieldBotID:
  30328. m.ResetBotID()
  30329. return nil
  30330. case usagedetail.FieldReceiverID:
  30331. m.ResetReceiverID()
  30332. return nil
  30333. case usagedetail.FieldApp:
  30334. m.ResetApp()
  30335. return nil
  30336. case usagedetail.FieldSessionID:
  30337. m.ResetSessionID()
  30338. return nil
  30339. case usagedetail.FieldRequest:
  30340. m.ResetRequest()
  30341. return nil
  30342. case usagedetail.FieldResponse:
  30343. m.ResetResponse()
  30344. return nil
  30345. case usagedetail.FieldOriginalData:
  30346. m.ResetOriginalData()
  30347. return nil
  30348. case usagedetail.FieldTotalTokens:
  30349. m.ResetTotalTokens()
  30350. return nil
  30351. case usagedetail.FieldPromptTokens:
  30352. m.ResetPromptTokens()
  30353. return nil
  30354. case usagedetail.FieldCompletionTokens:
  30355. m.ResetCompletionTokens()
  30356. return nil
  30357. case usagedetail.FieldOrganizationID:
  30358. m.ResetOrganizationID()
  30359. return nil
  30360. }
  30361. return fmt.Errorf("unknown UsageDetail field %s", name)
  30362. }
  30363. // AddedEdges returns all edge names that were set/added in this mutation.
  30364. func (m *UsageDetailMutation) AddedEdges() []string {
  30365. edges := make([]string, 0, 0)
  30366. return edges
  30367. }
  30368. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30369. // name in this mutation.
  30370. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  30371. return nil
  30372. }
  30373. // RemovedEdges returns all edge names that were removed in this mutation.
  30374. func (m *UsageDetailMutation) RemovedEdges() []string {
  30375. edges := make([]string, 0, 0)
  30376. return edges
  30377. }
  30378. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30379. // the given name in this mutation.
  30380. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  30381. return nil
  30382. }
  30383. // ClearedEdges returns all edge names that were cleared in this mutation.
  30384. func (m *UsageDetailMutation) ClearedEdges() []string {
  30385. edges := make([]string, 0, 0)
  30386. return edges
  30387. }
  30388. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30389. // was cleared in this mutation.
  30390. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  30391. return false
  30392. }
  30393. // ClearEdge clears the value of the edge with the given name. It returns an error
  30394. // if that edge is not defined in the schema.
  30395. func (m *UsageDetailMutation) ClearEdge(name string) error {
  30396. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  30397. }
  30398. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30399. // It returns an error if the edge is not defined in the schema.
  30400. func (m *UsageDetailMutation) ResetEdge(name string) error {
  30401. return fmt.Errorf("unknown UsageDetail edge %s", name)
  30402. }
  30403. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  30404. type UsageStatisticDayMutation struct {
  30405. config
  30406. op Op
  30407. typ string
  30408. id *uint64
  30409. created_at *time.Time
  30410. updated_at *time.Time
  30411. status *uint8
  30412. addstatus *int8
  30413. deleted_at *time.Time
  30414. addtime *uint64
  30415. addaddtime *int64
  30416. _type *int
  30417. add_type *int
  30418. bot_id *string
  30419. organization_id *uint64
  30420. addorganization_id *int64
  30421. ai_response *uint64
  30422. addai_response *int64
  30423. sop_run *uint64
  30424. addsop_run *int64
  30425. total_friend *uint64
  30426. addtotal_friend *int64
  30427. total_group *uint64
  30428. addtotal_group *int64
  30429. account_balance *uint64
  30430. addaccount_balance *int64
  30431. consume_token *uint64
  30432. addconsume_token *int64
  30433. active_user *uint64
  30434. addactive_user *int64
  30435. new_user *int64
  30436. addnew_user *int64
  30437. label_dist *[]custom_types.LabelDist
  30438. appendlabel_dist []custom_types.LabelDist
  30439. clearedFields map[string]struct{}
  30440. done bool
  30441. oldValue func(context.Context) (*UsageStatisticDay, error)
  30442. predicates []predicate.UsageStatisticDay
  30443. }
  30444. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  30445. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  30446. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  30447. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  30448. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  30449. m := &UsageStatisticDayMutation{
  30450. config: c,
  30451. op: op,
  30452. typ: TypeUsageStatisticDay,
  30453. clearedFields: make(map[string]struct{}),
  30454. }
  30455. for _, opt := range opts {
  30456. opt(m)
  30457. }
  30458. return m
  30459. }
  30460. // withUsageStatisticDayID sets the ID field of the mutation.
  30461. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  30462. return func(m *UsageStatisticDayMutation) {
  30463. var (
  30464. err error
  30465. once sync.Once
  30466. value *UsageStatisticDay
  30467. )
  30468. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  30469. once.Do(func() {
  30470. if m.done {
  30471. err = errors.New("querying old values post mutation is not allowed")
  30472. } else {
  30473. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  30474. }
  30475. })
  30476. return value, err
  30477. }
  30478. m.id = &id
  30479. }
  30480. }
  30481. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  30482. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  30483. return func(m *UsageStatisticDayMutation) {
  30484. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  30485. return node, nil
  30486. }
  30487. m.id = &node.ID
  30488. }
  30489. }
  30490. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30491. // executed in a transaction (ent.Tx), a transactional client is returned.
  30492. func (m UsageStatisticDayMutation) Client() *Client {
  30493. client := &Client{config: m.config}
  30494. client.init()
  30495. return client
  30496. }
  30497. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30498. // it returns an error otherwise.
  30499. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  30500. if _, ok := m.driver.(*txDriver); !ok {
  30501. return nil, errors.New("ent: mutation is not running in a transaction")
  30502. }
  30503. tx := &Tx{config: m.config}
  30504. tx.init()
  30505. return tx, nil
  30506. }
  30507. // SetID sets the value of the id field. Note that this
  30508. // operation is only accepted on creation of UsageStatisticDay entities.
  30509. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  30510. m.id = &id
  30511. }
  30512. // ID returns the ID value in the mutation. Note that the ID is only available
  30513. // if it was provided to the builder or after it was returned from the database.
  30514. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  30515. if m.id == nil {
  30516. return
  30517. }
  30518. return *m.id, true
  30519. }
  30520. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30521. // That means, if the mutation is applied within a transaction with an isolation level such
  30522. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30523. // or updated by the mutation.
  30524. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  30525. switch {
  30526. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30527. id, exists := m.ID()
  30528. if exists {
  30529. return []uint64{id}, nil
  30530. }
  30531. fallthrough
  30532. case m.op.Is(OpUpdate | OpDelete):
  30533. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  30534. default:
  30535. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30536. }
  30537. }
  30538. // SetCreatedAt sets the "created_at" field.
  30539. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  30540. m.created_at = &t
  30541. }
  30542. // CreatedAt returns the value of the "created_at" field in the mutation.
  30543. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  30544. v := m.created_at
  30545. if v == nil {
  30546. return
  30547. }
  30548. return *v, true
  30549. }
  30550. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  30551. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30553. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30554. if !m.op.Is(OpUpdateOne) {
  30555. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30556. }
  30557. if m.id == nil || m.oldValue == nil {
  30558. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30559. }
  30560. oldValue, err := m.oldValue(ctx)
  30561. if err != nil {
  30562. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30563. }
  30564. return oldValue.CreatedAt, nil
  30565. }
  30566. // ResetCreatedAt resets all changes to the "created_at" field.
  30567. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  30568. m.created_at = nil
  30569. }
  30570. // SetUpdatedAt sets the "updated_at" field.
  30571. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  30572. m.updated_at = &t
  30573. }
  30574. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30575. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  30576. v := m.updated_at
  30577. if v == nil {
  30578. return
  30579. }
  30580. return *v, true
  30581. }
  30582. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  30583. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30585. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30586. if !m.op.Is(OpUpdateOne) {
  30587. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30588. }
  30589. if m.id == nil || m.oldValue == nil {
  30590. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30591. }
  30592. oldValue, err := m.oldValue(ctx)
  30593. if err != nil {
  30594. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30595. }
  30596. return oldValue.UpdatedAt, nil
  30597. }
  30598. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30599. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  30600. m.updated_at = nil
  30601. }
  30602. // SetStatus sets the "status" field.
  30603. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  30604. m.status = &u
  30605. m.addstatus = nil
  30606. }
  30607. // Status returns the value of the "status" field in the mutation.
  30608. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  30609. v := m.status
  30610. if v == nil {
  30611. return
  30612. }
  30613. return *v, true
  30614. }
  30615. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  30616. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30618. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30619. if !m.op.Is(OpUpdateOne) {
  30620. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30621. }
  30622. if m.id == nil || m.oldValue == nil {
  30623. return v, errors.New("OldStatus requires an ID field in the mutation")
  30624. }
  30625. oldValue, err := m.oldValue(ctx)
  30626. if err != nil {
  30627. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30628. }
  30629. return oldValue.Status, nil
  30630. }
  30631. // AddStatus adds u to the "status" field.
  30632. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  30633. if m.addstatus != nil {
  30634. *m.addstatus += u
  30635. } else {
  30636. m.addstatus = &u
  30637. }
  30638. }
  30639. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30640. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  30641. v := m.addstatus
  30642. if v == nil {
  30643. return
  30644. }
  30645. return *v, true
  30646. }
  30647. // ClearStatus clears the value of the "status" field.
  30648. func (m *UsageStatisticDayMutation) ClearStatus() {
  30649. m.status = nil
  30650. m.addstatus = nil
  30651. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  30652. }
  30653. // StatusCleared returns if the "status" field was cleared in this mutation.
  30654. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  30655. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  30656. return ok
  30657. }
  30658. // ResetStatus resets all changes to the "status" field.
  30659. func (m *UsageStatisticDayMutation) ResetStatus() {
  30660. m.status = nil
  30661. m.addstatus = nil
  30662. delete(m.clearedFields, usagestatisticday.FieldStatus)
  30663. }
  30664. // SetDeletedAt sets the "deleted_at" field.
  30665. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  30666. m.deleted_at = &t
  30667. }
  30668. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30669. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  30670. v := m.deleted_at
  30671. if v == nil {
  30672. return
  30673. }
  30674. return *v, true
  30675. }
  30676. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  30677. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30679. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30680. if !m.op.Is(OpUpdateOne) {
  30681. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30682. }
  30683. if m.id == nil || m.oldValue == nil {
  30684. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30685. }
  30686. oldValue, err := m.oldValue(ctx)
  30687. if err != nil {
  30688. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30689. }
  30690. return oldValue.DeletedAt, nil
  30691. }
  30692. // ClearDeletedAt clears the value of the "deleted_at" field.
  30693. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  30694. m.deleted_at = nil
  30695. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  30696. }
  30697. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30698. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  30699. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  30700. return ok
  30701. }
  30702. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30703. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  30704. m.deleted_at = nil
  30705. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  30706. }
  30707. // SetAddtime sets the "addtime" field.
  30708. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  30709. m.addtime = &u
  30710. m.addaddtime = nil
  30711. }
  30712. // Addtime returns the value of the "addtime" field in the mutation.
  30713. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  30714. v := m.addtime
  30715. if v == nil {
  30716. return
  30717. }
  30718. return *v, true
  30719. }
  30720. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  30721. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30723. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  30724. if !m.op.Is(OpUpdateOne) {
  30725. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  30726. }
  30727. if m.id == nil || m.oldValue == nil {
  30728. return v, errors.New("OldAddtime requires an ID field in the mutation")
  30729. }
  30730. oldValue, err := m.oldValue(ctx)
  30731. if err != nil {
  30732. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  30733. }
  30734. return oldValue.Addtime, nil
  30735. }
  30736. // AddAddtime adds u to the "addtime" field.
  30737. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  30738. if m.addaddtime != nil {
  30739. *m.addaddtime += u
  30740. } else {
  30741. m.addaddtime = &u
  30742. }
  30743. }
  30744. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  30745. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  30746. v := m.addaddtime
  30747. if v == nil {
  30748. return
  30749. }
  30750. return *v, true
  30751. }
  30752. // ResetAddtime resets all changes to the "addtime" field.
  30753. func (m *UsageStatisticDayMutation) ResetAddtime() {
  30754. m.addtime = nil
  30755. m.addaddtime = nil
  30756. }
  30757. // SetType sets the "type" field.
  30758. func (m *UsageStatisticDayMutation) SetType(i int) {
  30759. m._type = &i
  30760. m.add_type = nil
  30761. }
  30762. // GetType returns the value of the "type" field in the mutation.
  30763. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  30764. v := m._type
  30765. if v == nil {
  30766. return
  30767. }
  30768. return *v, true
  30769. }
  30770. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  30771. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30773. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  30774. if !m.op.Is(OpUpdateOne) {
  30775. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30776. }
  30777. if m.id == nil || m.oldValue == nil {
  30778. return v, errors.New("OldType requires an ID field in the mutation")
  30779. }
  30780. oldValue, err := m.oldValue(ctx)
  30781. if err != nil {
  30782. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30783. }
  30784. return oldValue.Type, nil
  30785. }
  30786. // AddType adds i to the "type" field.
  30787. func (m *UsageStatisticDayMutation) AddType(i int) {
  30788. if m.add_type != nil {
  30789. *m.add_type += i
  30790. } else {
  30791. m.add_type = &i
  30792. }
  30793. }
  30794. // AddedType returns the value that was added to the "type" field in this mutation.
  30795. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  30796. v := m.add_type
  30797. if v == nil {
  30798. return
  30799. }
  30800. return *v, true
  30801. }
  30802. // ResetType resets all changes to the "type" field.
  30803. func (m *UsageStatisticDayMutation) ResetType() {
  30804. m._type = nil
  30805. m.add_type = nil
  30806. }
  30807. // SetBotID sets the "bot_id" field.
  30808. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  30809. m.bot_id = &s
  30810. }
  30811. // BotID returns the value of the "bot_id" field in the mutation.
  30812. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  30813. v := m.bot_id
  30814. if v == nil {
  30815. return
  30816. }
  30817. return *v, true
  30818. }
  30819. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  30820. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30822. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  30823. if !m.op.Is(OpUpdateOne) {
  30824. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30825. }
  30826. if m.id == nil || m.oldValue == nil {
  30827. return v, errors.New("OldBotID requires an ID field in the mutation")
  30828. }
  30829. oldValue, err := m.oldValue(ctx)
  30830. if err != nil {
  30831. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30832. }
  30833. return oldValue.BotID, nil
  30834. }
  30835. // ClearBotID clears the value of the "bot_id" field.
  30836. func (m *UsageStatisticDayMutation) ClearBotID() {
  30837. m.bot_id = nil
  30838. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  30839. }
  30840. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30841. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  30842. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  30843. return ok
  30844. }
  30845. // ResetBotID resets all changes to the "bot_id" field.
  30846. func (m *UsageStatisticDayMutation) ResetBotID() {
  30847. m.bot_id = nil
  30848. delete(m.clearedFields, usagestatisticday.FieldBotID)
  30849. }
  30850. // SetOrganizationID sets the "organization_id" field.
  30851. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  30852. m.organization_id = &u
  30853. m.addorganization_id = nil
  30854. }
  30855. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30856. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  30857. v := m.organization_id
  30858. if v == nil {
  30859. return
  30860. }
  30861. return *v, true
  30862. }
  30863. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  30864. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30866. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30867. if !m.op.Is(OpUpdateOne) {
  30868. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30869. }
  30870. if m.id == nil || m.oldValue == nil {
  30871. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30872. }
  30873. oldValue, err := m.oldValue(ctx)
  30874. if err != nil {
  30875. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30876. }
  30877. return oldValue.OrganizationID, nil
  30878. }
  30879. // AddOrganizationID adds u to the "organization_id" field.
  30880. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  30881. if m.addorganization_id != nil {
  30882. *m.addorganization_id += u
  30883. } else {
  30884. m.addorganization_id = &u
  30885. }
  30886. }
  30887. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30888. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  30889. v := m.addorganization_id
  30890. if v == nil {
  30891. return
  30892. }
  30893. return *v, true
  30894. }
  30895. // ClearOrganizationID clears the value of the "organization_id" field.
  30896. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  30897. m.organization_id = nil
  30898. m.addorganization_id = nil
  30899. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  30900. }
  30901. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30902. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  30903. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  30904. return ok
  30905. }
  30906. // ResetOrganizationID resets all changes to the "organization_id" field.
  30907. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  30908. m.organization_id = nil
  30909. m.addorganization_id = nil
  30910. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  30911. }
  30912. // SetAiResponse sets the "ai_response" field.
  30913. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  30914. m.ai_response = &u
  30915. m.addai_response = nil
  30916. }
  30917. // AiResponse returns the value of the "ai_response" field in the mutation.
  30918. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  30919. v := m.ai_response
  30920. if v == nil {
  30921. return
  30922. }
  30923. return *v, true
  30924. }
  30925. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  30926. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30928. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30929. if !m.op.Is(OpUpdateOne) {
  30930. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30931. }
  30932. if m.id == nil || m.oldValue == nil {
  30933. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30934. }
  30935. oldValue, err := m.oldValue(ctx)
  30936. if err != nil {
  30937. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30938. }
  30939. return oldValue.AiResponse, nil
  30940. }
  30941. // AddAiResponse adds u to the "ai_response" field.
  30942. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  30943. if m.addai_response != nil {
  30944. *m.addai_response += u
  30945. } else {
  30946. m.addai_response = &u
  30947. }
  30948. }
  30949. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30950. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  30951. v := m.addai_response
  30952. if v == nil {
  30953. return
  30954. }
  30955. return *v, true
  30956. }
  30957. // ResetAiResponse resets all changes to the "ai_response" field.
  30958. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  30959. m.ai_response = nil
  30960. m.addai_response = nil
  30961. }
  30962. // SetSopRun sets the "sop_run" field.
  30963. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  30964. m.sop_run = &u
  30965. m.addsop_run = nil
  30966. }
  30967. // SopRun returns the value of the "sop_run" field in the mutation.
  30968. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  30969. v := m.sop_run
  30970. if v == nil {
  30971. return
  30972. }
  30973. return *v, true
  30974. }
  30975. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  30976. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30978. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30979. if !m.op.Is(OpUpdateOne) {
  30980. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30981. }
  30982. if m.id == nil || m.oldValue == nil {
  30983. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30984. }
  30985. oldValue, err := m.oldValue(ctx)
  30986. if err != nil {
  30987. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30988. }
  30989. return oldValue.SopRun, nil
  30990. }
  30991. // AddSopRun adds u to the "sop_run" field.
  30992. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  30993. if m.addsop_run != nil {
  30994. *m.addsop_run += u
  30995. } else {
  30996. m.addsop_run = &u
  30997. }
  30998. }
  30999. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31000. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  31001. v := m.addsop_run
  31002. if v == nil {
  31003. return
  31004. }
  31005. return *v, true
  31006. }
  31007. // ResetSopRun resets all changes to the "sop_run" field.
  31008. func (m *UsageStatisticDayMutation) ResetSopRun() {
  31009. m.sop_run = nil
  31010. m.addsop_run = nil
  31011. }
  31012. // SetTotalFriend sets the "total_friend" field.
  31013. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  31014. m.total_friend = &u
  31015. m.addtotal_friend = nil
  31016. }
  31017. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31018. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  31019. v := m.total_friend
  31020. if v == nil {
  31021. return
  31022. }
  31023. return *v, true
  31024. }
  31025. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  31026. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31028. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31029. if !m.op.Is(OpUpdateOne) {
  31030. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31031. }
  31032. if m.id == nil || m.oldValue == nil {
  31033. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31034. }
  31035. oldValue, err := m.oldValue(ctx)
  31036. if err != nil {
  31037. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31038. }
  31039. return oldValue.TotalFriend, nil
  31040. }
  31041. // AddTotalFriend adds u to the "total_friend" field.
  31042. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  31043. if m.addtotal_friend != nil {
  31044. *m.addtotal_friend += u
  31045. } else {
  31046. m.addtotal_friend = &u
  31047. }
  31048. }
  31049. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31050. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  31051. v := m.addtotal_friend
  31052. if v == nil {
  31053. return
  31054. }
  31055. return *v, true
  31056. }
  31057. // ResetTotalFriend resets all changes to the "total_friend" field.
  31058. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  31059. m.total_friend = nil
  31060. m.addtotal_friend = nil
  31061. }
  31062. // SetTotalGroup sets the "total_group" field.
  31063. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  31064. m.total_group = &u
  31065. m.addtotal_group = nil
  31066. }
  31067. // TotalGroup returns the value of the "total_group" field in the mutation.
  31068. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  31069. v := m.total_group
  31070. if v == nil {
  31071. return
  31072. }
  31073. return *v, true
  31074. }
  31075. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  31076. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31078. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31079. if !m.op.Is(OpUpdateOne) {
  31080. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31081. }
  31082. if m.id == nil || m.oldValue == nil {
  31083. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31084. }
  31085. oldValue, err := m.oldValue(ctx)
  31086. if err != nil {
  31087. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31088. }
  31089. return oldValue.TotalGroup, nil
  31090. }
  31091. // AddTotalGroup adds u to the "total_group" field.
  31092. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  31093. if m.addtotal_group != nil {
  31094. *m.addtotal_group += u
  31095. } else {
  31096. m.addtotal_group = &u
  31097. }
  31098. }
  31099. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31100. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  31101. v := m.addtotal_group
  31102. if v == nil {
  31103. return
  31104. }
  31105. return *v, true
  31106. }
  31107. // ResetTotalGroup resets all changes to the "total_group" field.
  31108. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  31109. m.total_group = nil
  31110. m.addtotal_group = nil
  31111. }
  31112. // SetAccountBalance sets the "account_balance" field.
  31113. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  31114. m.account_balance = &u
  31115. m.addaccount_balance = nil
  31116. }
  31117. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31118. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  31119. v := m.account_balance
  31120. if v == nil {
  31121. return
  31122. }
  31123. return *v, true
  31124. }
  31125. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  31126. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31128. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31129. if !m.op.Is(OpUpdateOne) {
  31130. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31131. }
  31132. if m.id == nil || m.oldValue == nil {
  31133. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31134. }
  31135. oldValue, err := m.oldValue(ctx)
  31136. if err != nil {
  31137. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31138. }
  31139. return oldValue.AccountBalance, nil
  31140. }
  31141. // AddAccountBalance adds u to the "account_balance" field.
  31142. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  31143. if m.addaccount_balance != nil {
  31144. *m.addaccount_balance += u
  31145. } else {
  31146. m.addaccount_balance = &u
  31147. }
  31148. }
  31149. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31150. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  31151. v := m.addaccount_balance
  31152. if v == nil {
  31153. return
  31154. }
  31155. return *v, true
  31156. }
  31157. // ResetAccountBalance resets all changes to the "account_balance" field.
  31158. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  31159. m.account_balance = nil
  31160. m.addaccount_balance = nil
  31161. }
  31162. // SetConsumeToken sets the "consume_token" field.
  31163. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  31164. m.consume_token = &u
  31165. m.addconsume_token = nil
  31166. }
  31167. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31168. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  31169. v := m.consume_token
  31170. if v == nil {
  31171. return
  31172. }
  31173. return *v, true
  31174. }
  31175. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  31176. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31178. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31179. if !m.op.Is(OpUpdateOne) {
  31180. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31181. }
  31182. if m.id == nil || m.oldValue == nil {
  31183. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31184. }
  31185. oldValue, err := m.oldValue(ctx)
  31186. if err != nil {
  31187. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31188. }
  31189. return oldValue.ConsumeToken, nil
  31190. }
  31191. // AddConsumeToken adds u to the "consume_token" field.
  31192. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  31193. if m.addconsume_token != nil {
  31194. *m.addconsume_token += u
  31195. } else {
  31196. m.addconsume_token = &u
  31197. }
  31198. }
  31199. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31200. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  31201. v := m.addconsume_token
  31202. if v == nil {
  31203. return
  31204. }
  31205. return *v, true
  31206. }
  31207. // ResetConsumeToken resets all changes to the "consume_token" field.
  31208. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  31209. m.consume_token = nil
  31210. m.addconsume_token = nil
  31211. }
  31212. // SetActiveUser sets the "active_user" field.
  31213. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  31214. m.active_user = &u
  31215. m.addactive_user = nil
  31216. }
  31217. // ActiveUser returns the value of the "active_user" field in the mutation.
  31218. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  31219. v := m.active_user
  31220. if v == nil {
  31221. return
  31222. }
  31223. return *v, true
  31224. }
  31225. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  31226. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31228. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31229. if !m.op.Is(OpUpdateOne) {
  31230. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31231. }
  31232. if m.id == nil || m.oldValue == nil {
  31233. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31234. }
  31235. oldValue, err := m.oldValue(ctx)
  31236. if err != nil {
  31237. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31238. }
  31239. return oldValue.ActiveUser, nil
  31240. }
  31241. // AddActiveUser adds u to the "active_user" field.
  31242. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  31243. if m.addactive_user != nil {
  31244. *m.addactive_user += u
  31245. } else {
  31246. m.addactive_user = &u
  31247. }
  31248. }
  31249. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31250. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  31251. v := m.addactive_user
  31252. if v == nil {
  31253. return
  31254. }
  31255. return *v, true
  31256. }
  31257. // ResetActiveUser resets all changes to the "active_user" field.
  31258. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  31259. m.active_user = nil
  31260. m.addactive_user = nil
  31261. }
  31262. // SetNewUser sets the "new_user" field.
  31263. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  31264. m.new_user = &i
  31265. m.addnew_user = nil
  31266. }
  31267. // NewUser returns the value of the "new_user" field in the mutation.
  31268. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  31269. v := m.new_user
  31270. if v == nil {
  31271. return
  31272. }
  31273. return *v, true
  31274. }
  31275. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  31276. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31278. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31279. if !m.op.Is(OpUpdateOne) {
  31280. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31281. }
  31282. if m.id == nil || m.oldValue == nil {
  31283. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31284. }
  31285. oldValue, err := m.oldValue(ctx)
  31286. if err != nil {
  31287. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31288. }
  31289. return oldValue.NewUser, nil
  31290. }
  31291. // AddNewUser adds i to the "new_user" field.
  31292. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  31293. if m.addnew_user != nil {
  31294. *m.addnew_user += i
  31295. } else {
  31296. m.addnew_user = &i
  31297. }
  31298. }
  31299. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31300. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  31301. v := m.addnew_user
  31302. if v == nil {
  31303. return
  31304. }
  31305. return *v, true
  31306. }
  31307. // ResetNewUser resets all changes to the "new_user" field.
  31308. func (m *UsageStatisticDayMutation) ResetNewUser() {
  31309. m.new_user = nil
  31310. m.addnew_user = nil
  31311. }
  31312. // SetLabelDist sets the "label_dist" field.
  31313. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31314. m.label_dist = &ctd
  31315. m.appendlabel_dist = nil
  31316. }
  31317. // LabelDist returns the value of the "label_dist" field in the mutation.
  31318. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31319. v := m.label_dist
  31320. if v == nil {
  31321. return
  31322. }
  31323. return *v, true
  31324. }
  31325. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  31326. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31328. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31329. if !m.op.Is(OpUpdateOne) {
  31330. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31331. }
  31332. if m.id == nil || m.oldValue == nil {
  31333. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31334. }
  31335. oldValue, err := m.oldValue(ctx)
  31336. if err != nil {
  31337. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31338. }
  31339. return oldValue.LabelDist, nil
  31340. }
  31341. // AppendLabelDist adds ctd to the "label_dist" field.
  31342. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31343. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31344. }
  31345. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31346. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31347. if len(m.appendlabel_dist) == 0 {
  31348. return nil, false
  31349. }
  31350. return m.appendlabel_dist, true
  31351. }
  31352. // ResetLabelDist resets all changes to the "label_dist" field.
  31353. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  31354. m.label_dist = nil
  31355. m.appendlabel_dist = nil
  31356. }
  31357. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  31358. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  31359. m.predicates = append(m.predicates, ps...)
  31360. }
  31361. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  31362. // users can use type-assertion to append predicates that do not depend on any generated package.
  31363. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  31364. p := make([]predicate.UsageStatisticDay, len(ps))
  31365. for i := range ps {
  31366. p[i] = ps[i]
  31367. }
  31368. m.Where(p...)
  31369. }
  31370. // Op returns the operation name.
  31371. func (m *UsageStatisticDayMutation) Op() Op {
  31372. return m.op
  31373. }
  31374. // SetOp allows setting the mutation operation.
  31375. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  31376. m.op = op
  31377. }
  31378. // Type returns the node type of this mutation (UsageStatisticDay).
  31379. func (m *UsageStatisticDayMutation) Type() string {
  31380. return m.typ
  31381. }
  31382. // Fields returns all fields that were changed during this mutation. Note that in
  31383. // order to get all numeric fields that were incremented/decremented, call
  31384. // AddedFields().
  31385. func (m *UsageStatisticDayMutation) Fields() []string {
  31386. fields := make([]string, 0, 17)
  31387. if m.created_at != nil {
  31388. fields = append(fields, usagestatisticday.FieldCreatedAt)
  31389. }
  31390. if m.updated_at != nil {
  31391. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  31392. }
  31393. if m.status != nil {
  31394. fields = append(fields, usagestatisticday.FieldStatus)
  31395. }
  31396. if m.deleted_at != nil {
  31397. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31398. }
  31399. if m.addtime != nil {
  31400. fields = append(fields, usagestatisticday.FieldAddtime)
  31401. }
  31402. if m._type != nil {
  31403. fields = append(fields, usagestatisticday.FieldType)
  31404. }
  31405. if m.bot_id != nil {
  31406. fields = append(fields, usagestatisticday.FieldBotID)
  31407. }
  31408. if m.organization_id != nil {
  31409. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31410. }
  31411. if m.ai_response != nil {
  31412. fields = append(fields, usagestatisticday.FieldAiResponse)
  31413. }
  31414. if m.sop_run != nil {
  31415. fields = append(fields, usagestatisticday.FieldSopRun)
  31416. }
  31417. if m.total_friend != nil {
  31418. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31419. }
  31420. if m.total_group != nil {
  31421. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31422. }
  31423. if m.account_balance != nil {
  31424. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31425. }
  31426. if m.consume_token != nil {
  31427. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31428. }
  31429. if m.active_user != nil {
  31430. fields = append(fields, usagestatisticday.FieldActiveUser)
  31431. }
  31432. if m.new_user != nil {
  31433. fields = append(fields, usagestatisticday.FieldNewUser)
  31434. }
  31435. if m.label_dist != nil {
  31436. fields = append(fields, usagestatisticday.FieldLabelDist)
  31437. }
  31438. return fields
  31439. }
  31440. // Field returns the value of a field with the given name. The second boolean
  31441. // return value indicates that this field was not set, or was not defined in the
  31442. // schema.
  31443. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  31444. switch name {
  31445. case usagestatisticday.FieldCreatedAt:
  31446. return m.CreatedAt()
  31447. case usagestatisticday.FieldUpdatedAt:
  31448. return m.UpdatedAt()
  31449. case usagestatisticday.FieldStatus:
  31450. return m.Status()
  31451. case usagestatisticday.FieldDeletedAt:
  31452. return m.DeletedAt()
  31453. case usagestatisticday.FieldAddtime:
  31454. return m.Addtime()
  31455. case usagestatisticday.FieldType:
  31456. return m.GetType()
  31457. case usagestatisticday.FieldBotID:
  31458. return m.BotID()
  31459. case usagestatisticday.FieldOrganizationID:
  31460. return m.OrganizationID()
  31461. case usagestatisticday.FieldAiResponse:
  31462. return m.AiResponse()
  31463. case usagestatisticday.FieldSopRun:
  31464. return m.SopRun()
  31465. case usagestatisticday.FieldTotalFriend:
  31466. return m.TotalFriend()
  31467. case usagestatisticday.FieldTotalGroup:
  31468. return m.TotalGroup()
  31469. case usagestatisticday.FieldAccountBalance:
  31470. return m.AccountBalance()
  31471. case usagestatisticday.FieldConsumeToken:
  31472. return m.ConsumeToken()
  31473. case usagestatisticday.FieldActiveUser:
  31474. return m.ActiveUser()
  31475. case usagestatisticday.FieldNewUser:
  31476. return m.NewUser()
  31477. case usagestatisticday.FieldLabelDist:
  31478. return m.LabelDist()
  31479. }
  31480. return nil, false
  31481. }
  31482. // OldField returns the old value of the field from the database. An error is
  31483. // returned if the mutation operation is not UpdateOne, or the query to the
  31484. // database failed.
  31485. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31486. switch name {
  31487. case usagestatisticday.FieldCreatedAt:
  31488. return m.OldCreatedAt(ctx)
  31489. case usagestatisticday.FieldUpdatedAt:
  31490. return m.OldUpdatedAt(ctx)
  31491. case usagestatisticday.FieldStatus:
  31492. return m.OldStatus(ctx)
  31493. case usagestatisticday.FieldDeletedAt:
  31494. return m.OldDeletedAt(ctx)
  31495. case usagestatisticday.FieldAddtime:
  31496. return m.OldAddtime(ctx)
  31497. case usagestatisticday.FieldType:
  31498. return m.OldType(ctx)
  31499. case usagestatisticday.FieldBotID:
  31500. return m.OldBotID(ctx)
  31501. case usagestatisticday.FieldOrganizationID:
  31502. return m.OldOrganizationID(ctx)
  31503. case usagestatisticday.FieldAiResponse:
  31504. return m.OldAiResponse(ctx)
  31505. case usagestatisticday.FieldSopRun:
  31506. return m.OldSopRun(ctx)
  31507. case usagestatisticday.FieldTotalFriend:
  31508. return m.OldTotalFriend(ctx)
  31509. case usagestatisticday.FieldTotalGroup:
  31510. return m.OldTotalGroup(ctx)
  31511. case usagestatisticday.FieldAccountBalance:
  31512. return m.OldAccountBalance(ctx)
  31513. case usagestatisticday.FieldConsumeToken:
  31514. return m.OldConsumeToken(ctx)
  31515. case usagestatisticday.FieldActiveUser:
  31516. return m.OldActiveUser(ctx)
  31517. case usagestatisticday.FieldNewUser:
  31518. return m.OldNewUser(ctx)
  31519. case usagestatisticday.FieldLabelDist:
  31520. return m.OldLabelDist(ctx)
  31521. }
  31522. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31523. }
  31524. // SetField sets the value of a field with the given name. It returns an error if
  31525. // the field is not defined in the schema, or if the type mismatched the field
  31526. // type.
  31527. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  31528. switch name {
  31529. case usagestatisticday.FieldCreatedAt:
  31530. v, ok := value.(time.Time)
  31531. if !ok {
  31532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31533. }
  31534. m.SetCreatedAt(v)
  31535. return nil
  31536. case usagestatisticday.FieldUpdatedAt:
  31537. v, ok := value.(time.Time)
  31538. if !ok {
  31539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31540. }
  31541. m.SetUpdatedAt(v)
  31542. return nil
  31543. case usagestatisticday.FieldStatus:
  31544. v, ok := value.(uint8)
  31545. if !ok {
  31546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31547. }
  31548. m.SetStatus(v)
  31549. return nil
  31550. case usagestatisticday.FieldDeletedAt:
  31551. v, ok := value.(time.Time)
  31552. if !ok {
  31553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31554. }
  31555. m.SetDeletedAt(v)
  31556. return nil
  31557. case usagestatisticday.FieldAddtime:
  31558. v, ok := value.(uint64)
  31559. if !ok {
  31560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31561. }
  31562. m.SetAddtime(v)
  31563. return nil
  31564. case usagestatisticday.FieldType:
  31565. v, ok := value.(int)
  31566. if !ok {
  31567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31568. }
  31569. m.SetType(v)
  31570. return nil
  31571. case usagestatisticday.FieldBotID:
  31572. v, ok := value.(string)
  31573. if !ok {
  31574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31575. }
  31576. m.SetBotID(v)
  31577. return nil
  31578. case usagestatisticday.FieldOrganizationID:
  31579. v, ok := value.(uint64)
  31580. if !ok {
  31581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31582. }
  31583. m.SetOrganizationID(v)
  31584. return nil
  31585. case usagestatisticday.FieldAiResponse:
  31586. v, ok := value.(uint64)
  31587. if !ok {
  31588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31589. }
  31590. m.SetAiResponse(v)
  31591. return nil
  31592. case usagestatisticday.FieldSopRun:
  31593. v, ok := value.(uint64)
  31594. if !ok {
  31595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31596. }
  31597. m.SetSopRun(v)
  31598. return nil
  31599. case usagestatisticday.FieldTotalFriend:
  31600. v, ok := value.(uint64)
  31601. if !ok {
  31602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31603. }
  31604. m.SetTotalFriend(v)
  31605. return nil
  31606. case usagestatisticday.FieldTotalGroup:
  31607. v, ok := value.(uint64)
  31608. if !ok {
  31609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31610. }
  31611. m.SetTotalGroup(v)
  31612. return nil
  31613. case usagestatisticday.FieldAccountBalance:
  31614. v, ok := value.(uint64)
  31615. if !ok {
  31616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31617. }
  31618. m.SetAccountBalance(v)
  31619. return nil
  31620. case usagestatisticday.FieldConsumeToken:
  31621. v, ok := value.(uint64)
  31622. if !ok {
  31623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31624. }
  31625. m.SetConsumeToken(v)
  31626. return nil
  31627. case usagestatisticday.FieldActiveUser:
  31628. v, ok := value.(uint64)
  31629. if !ok {
  31630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31631. }
  31632. m.SetActiveUser(v)
  31633. return nil
  31634. case usagestatisticday.FieldNewUser:
  31635. v, ok := value.(int64)
  31636. if !ok {
  31637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31638. }
  31639. m.SetNewUser(v)
  31640. return nil
  31641. case usagestatisticday.FieldLabelDist:
  31642. v, ok := value.([]custom_types.LabelDist)
  31643. if !ok {
  31644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31645. }
  31646. m.SetLabelDist(v)
  31647. return nil
  31648. }
  31649. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31650. }
  31651. // AddedFields returns all numeric fields that were incremented/decremented during
  31652. // this mutation.
  31653. func (m *UsageStatisticDayMutation) AddedFields() []string {
  31654. var fields []string
  31655. if m.addstatus != nil {
  31656. fields = append(fields, usagestatisticday.FieldStatus)
  31657. }
  31658. if m.addaddtime != nil {
  31659. fields = append(fields, usagestatisticday.FieldAddtime)
  31660. }
  31661. if m.add_type != nil {
  31662. fields = append(fields, usagestatisticday.FieldType)
  31663. }
  31664. if m.addorganization_id != nil {
  31665. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31666. }
  31667. if m.addai_response != nil {
  31668. fields = append(fields, usagestatisticday.FieldAiResponse)
  31669. }
  31670. if m.addsop_run != nil {
  31671. fields = append(fields, usagestatisticday.FieldSopRun)
  31672. }
  31673. if m.addtotal_friend != nil {
  31674. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31675. }
  31676. if m.addtotal_group != nil {
  31677. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31678. }
  31679. if m.addaccount_balance != nil {
  31680. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31681. }
  31682. if m.addconsume_token != nil {
  31683. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31684. }
  31685. if m.addactive_user != nil {
  31686. fields = append(fields, usagestatisticday.FieldActiveUser)
  31687. }
  31688. if m.addnew_user != nil {
  31689. fields = append(fields, usagestatisticday.FieldNewUser)
  31690. }
  31691. return fields
  31692. }
  31693. // AddedField returns the numeric value that was incremented/decremented on a field
  31694. // with the given name. The second boolean return value indicates that this field
  31695. // was not set, or was not defined in the schema.
  31696. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  31697. switch name {
  31698. case usagestatisticday.FieldStatus:
  31699. return m.AddedStatus()
  31700. case usagestatisticday.FieldAddtime:
  31701. return m.AddedAddtime()
  31702. case usagestatisticday.FieldType:
  31703. return m.AddedType()
  31704. case usagestatisticday.FieldOrganizationID:
  31705. return m.AddedOrganizationID()
  31706. case usagestatisticday.FieldAiResponse:
  31707. return m.AddedAiResponse()
  31708. case usagestatisticday.FieldSopRun:
  31709. return m.AddedSopRun()
  31710. case usagestatisticday.FieldTotalFriend:
  31711. return m.AddedTotalFriend()
  31712. case usagestatisticday.FieldTotalGroup:
  31713. return m.AddedTotalGroup()
  31714. case usagestatisticday.FieldAccountBalance:
  31715. return m.AddedAccountBalance()
  31716. case usagestatisticday.FieldConsumeToken:
  31717. return m.AddedConsumeToken()
  31718. case usagestatisticday.FieldActiveUser:
  31719. return m.AddedActiveUser()
  31720. case usagestatisticday.FieldNewUser:
  31721. return m.AddedNewUser()
  31722. }
  31723. return nil, false
  31724. }
  31725. // AddField adds the value to the field with the given name. It returns an error if
  31726. // the field is not defined in the schema, or if the type mismatched the field
  31727. // type.
  31728. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  31729. switch name {
  31730. case usagestatisticday.FieldStatus:
  31731. v, ok := value.(int8)
  31732. if !ok {
  31733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31734. }
  31735. m.AddStatus(v)
  31736. return nil
  31737. case usagestatisticday.FieldAddtime:
  31738. v, ok := value.(int64)
  31739. if !ok {
  31740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31741. }
  31742. m.AddAddtime(v)
  31743. return nil
  31744. case usagestatisticday.FieldType:
  31745. v, ok := value.(int)
  31746. if !ok {
  31747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31748. }
  31749. m.AddType(v)
  31750. return nil
  31751. case usagestatisticday.FieldOrganizationID:
  31752. v, ok := value.(int64)
  31753. if !ok {
  31754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31755. }
  31756. m.AddOrganizationID(v)
  31757. return nil
  31758. case usagestatisticday.FieldAiResponse:
  31759. v, ok := value.(int64)
  31760. if !ok {
  31761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31762. }
  31763. m.AddAiResponse(v)
  31764. return nil
  31765. case usagestatisticday.FieldSopRun:
  31766. v, ok := value.(int64)
  31767. if !ok {
  31768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31769. }
  31770. m.AddSopRun(v)
  31771. return nil
  31772. case usagestatisticday.FieldTotalFriend:
  31773. v, ok := value.(int64)
  31774. if !ok {
  31775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31776. }
  31777. m.AddTotalFriend(v)
  31778. return nil
  31779. case usagestatisticday.FieldTotalGroup:
  31780. v, ok := value.(int64)
  31781. if !ok {
  31782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31783. }
  31784. m.AddTotalGroup(v)
  31785. return nil
  31786. case usagestatisticday.FieldAccountBalance:
  31787. v, ok := value.(int64)
  31788. if !ok {
  31789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31790. }
  31791. m.AddAccountBalance(v)
  31792. return nil
  31793. case usagestatisticday.FieldConsumeToken:
  31794. v, ok := value.(int64)
  31795. if !ok {
  31796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31797. }
  31798. m.AddConsumeToken(v)
  31799. return nil
  31800. case usagestatisticday.FieldActiveUser:
  31801. v, ok := value.(int64)
  31802. if !ok {
  31803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31804. }
  31805. m.AddActiveUser(v)
  31806. return nil
  31807. case usagestatisticday.FieldNewUser:
  31808. v, ok := value.(int64)
  31809. if !ok {
  31810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31811. }
  31812. m.AddNewUser(v)
  31813. return nil
  31814. }
  31815. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  31816. }
  31817. // ClearedFields returns all nullable fields that were cleared during this
  31818. // mutation.
  31819. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  31820. var fields []string
  31821. if m.FieldCleared(usagestatisticday.FieldStatus) {
  31822. fields = append(fields, usagestatisticday.FieldStatus)
  31823. }
  31824. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  31825. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31826. }
  31827. if m.FieldCleared(usagestatisticday.FieldBotID) {
  31828. fields = append(fields, usagestatisticday.FieldBotID)
  31829. }
  31830. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  31831. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31832. }
  31833. return fields
  31834. }
  31835. // FieldCleared returns a boolean indicating if a field with the given name was
  31836. // cleared in this mutation.
  31837. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  31838. _, ok := m.clearedFields[name]
  31839. return ok
  31840. }
  31841. // ClearField clears the value of the field with the given name. It returns an
  31842. // error if the field is not defined in the schema.
  31843. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  31844. switch name {
  31845. case usagestatisticday.FieldStatus:
  31846. m.ClearStatus()
  31847. return nil
  31848. case usagestatisticday.FieldDeletedAt:
  31849. m.ClearDeletedAt()
  31850. return nil
  31851. case usagestatisticday.FieldBotID:
  31852. m.ClearBotID()
  31853. return nil
  31854. case usagestatisticday.FieldOrganizationID:
  31855. m.ClearOrganizationID()
  31856. return nil
  31857. }
  31858. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  31859. }
  31860. // ResetField resets all changes in the mutation for the field with the given name.
  31861. // It returns an error if the field is not defined in the schema.
  31862. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  31863. switch name {
  31864. case usagestatisticday.FieldCreatedAt:
  31865. m.ResetCreatedAt()
  31866. return nil
  31867. case usagestatisticday.FieldUpdatedAt:
  31868. m.ResetUpdatedAt()
  31869. return nil
  31870. case usagestatisticday.FieldStatus:
  31871. m.ResetStatus()
  31872. return nil
  31873. case usagestatisticday.FieldDeletedAt:
  31874. m.ResetDeletedAt()
  31875. return nil
  31876. case usagestatisticday.FieldAddtime:
  31877. m.ResetAddtime()
  31878. return nil
  31879. case usagestatisticday.FieldType:
  31880. m.ResetType()
  31881. return nil
  31882. case usagestatisticday.FieldBotID:
  31883. m.ResetBotID()
  31884. return nil
  31885. case usagestatisticday.FieldOrganizationID:
  31886. m.ResetOrganizationID()
  31887. return nil
  31888. case usagestatisticday.FieldAiResponse:
  31889. m.ResetAiResponse()
  31890. return nil
  31891. case usagestatisticday.FieldSopRun:
  31892. m.ResetSopRun()
  31893. return nil
  31894. case usagestatisticday.FieldTotalFriend:
  31895. m.ResetTotalFriend()
  31896. return nil
  31897. case usagestatisticday.FieldTotalGroup:
  31898. m.ResetTotalGroup()
  31899. return nil
  31900. case usagestatisticday.FieldAccountBalance:
  31901. m.ResetAccountBalance()
  31902. return nil
  31903. case usagestatisticday.FieldConsumeToken:
  31904. m.ResetConsumeToken()
  31905. return nil
  31906. case usagestatisticday.FieldActiveUser:
  31907. m.ResetActiveUser()
  31908. return nil
  31909. case usagestatisticday.FieldNewUser:
  31910. m.ResetNewUser()
  31911. return nil
  31912. case usagestatisticday.FieldLabelDist:
  31913. m.ResetLabelDist()
  31914. return nil
  31915. }
  31916. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31917. }
  31918. // AddedEdges returns all edge names that were set/added in this mutation.
  31919. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  31920. edges := make([]string, 0, 0)
  31921. return edges
  31922. }
  31923. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31924. // name in this mutation.
  31925. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  31926. return nil
  31927. }
  31928. // RemovedEdges returns all edge names that were removed in this mutation.
  31929. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  31930. edges := make([]string, 0, 0)
  31931. return edges
  31932. }
  31933. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31934. // the given name in this mutation.
  31935. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  31936. return nil
  31937. }
  31938. // ClearedEdges returns all edge names that were cleared in this mutation.
  31939. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  31940. edges := make([]string, 0, 0)
  31941. return edges
  31942. }
  31943. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31944. // was cleared in this mutation.
  31945. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  31946. return false
  31947. }
  31948. // ClearEdge clears the value of the edge with the given name. It returns an error
  31949. // if that edge is not defined in the schema.
  31950. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  31951. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  31952. }
  31953. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31954. // It returns an error if the edge is not defined in the schema.
  31955. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  31956. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  31957. }
  31958. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  31959. type UsageStatisticHourMutation struct {
  31960. config
  31961. op Op
  31962. typ string
  31963. id *uint64
  31964. created_at *time.Time
  31965. updated_at *time.Time
  31966. status *uint8
  31967. addstatus *int8
  31968. deleted_at *time.Time
  31969. addtime *uint64
  31970. addaddtime *int64
  31971. _type *int
  31972. add_type *int
  31973. bot_id *string
  31974. organization_id *uint64
  31975. addorganization_id *int64
  31976. ai_response *uint64
  31977. addai_response *int64
  31978. sop_run *uint64
  31979. addsop_run *int64
  31980. total_friend *uint64
  31981. addtotal_friend *int64
  31982. total_group *uint64
  31983. addtotal_group *int64
  31984. account_balance *uint64
  31985. addaccount_balance *int64
  31986. consume_token *uint64
  31987. addconsume_token *int64
  31988. active_user *uint64
  31989. addactive_user *int64
  31990. new_user *int64
  31991. addnew_user *int64
  31992. label_dist *[]custom_types.LabelDist
  31993. appendlabel_dist []custom_types.LabelDist
  31994. clearedFields map[string]struct{}
  31995. done bool
  31996. oldValue func(context.Context) (*UsageStatisticHour, error)
  31997. predicates []predicate.UsageStatisticHour
  31998. }
  31999. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  32000. // usagestatistichourOption allows management of the mutation configuration using functional options.
  32001. type usagestatistichourOption func(*UsageStatisticHourMutation)
  32002. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  32003. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  32004. m := &UsageStatisticHourMutation{
  32005. config: c,
  32006. op: op,
  32007. typ: TypeUsageStatisticHour,
  32008. clearedFields: make(map[string]struct{}),
  32009. }
  32010. for _, opt := range opts {
  32011. opt(m)
  32012. }
  32013. return m
  32014. }
  32015. // withUsageStatisticHourID sets the ID field of the mutation.
  32016. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  32017. return func(m *UsageStatisticHourMutation) {
  32018. var (
  32019. err error
  32020. once sync.Once
  32021. value *UsageStatisticHour
  32022. )
  32023. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  32024. once.Do(func() {
  32025. if m.done {
  32026. err = errors.New("querying old values post mutation is not allowed")
  32027. } else {
  32028. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  32029. }
  32030. })
  32031. return value, err
  32032. }
  32033. m.id = &id
  32034. }
  32035. }
  32036. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  32037. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  32038. return func(m *UsageStatisticHourMutation) {
  32039. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  32040. return node, nil
  32041. }
  32042. m.id = &node.ID
  32043. }
  32044. }
  32045. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32046. // executed in a transaction (ent.Tx), a transactional client is returned.
  32047. func (m UsageStatisticHourMutation) Client() *Client {
  32048. client := &Client{config: m.config}
  32049. client.init()
  32050. return client
  32051. }
  32052. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32053. // it returns an error otherwise.
  32054. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  32055. if _, ok := m.driver.(*txDriver); !ok {
  32056. return nil, errors.New("ent: mutation is not running in a transaction")
  32057. }
  32058. tx := &Tx{config: m.config}
  32059. tx.init()
  32060. return tx, nil
  32061. }
  32062. // SetID sets the value of the id field. Note that this
  32063. // operation is only accepted on creation of UsageStatisticHour entities.
  32064. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  32065. m.id = &id
  32066. }
  32067. // ID returns the ID value in the mutation. Note that the ID is only available
  32068. // if it was provided to the builder or after it was returned from the database.
  32069. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  32070. if m.id == nil {
  32071. return
  32072. }
  32073. return *m.id, true
  32074. }
  32075. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32076. // That means, if the mutation is applied within a transaction with an isolation level such
  32077. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32078. // or updated by the mutation.
  32079. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  32080. switch {
  32081. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32082. id, exists := m.ID()
  32083. if exists {
  32084. return []uint64{id}, nil
  32085. }
  32086. fallthrough
  32087. case m.op.Is(OpUpdate | OpDelete):
  32088. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  32089. default:
  32090. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32091. }
  32092. }
  32093. // SetCreatedAt sets the "created_at" field.
  32094. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  32095. m.created_at = &t
  32096. }
  32097. // CreatedAt returns the value of the "created_at" field in the mutation.
  32098. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  32099. v := m.created_at
  32100. if v == nil {
  32101. return
  32102. }
  32103. return *v, true
  32104. }
  32105. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  32106. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32108. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32109. if !m.op.Is(OpUpdateOne) {
  32110. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32111. }
  32112. if m.id == nil || m.oldValue == nil {
  32113. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32114. }
  32115. oldValue, err := m.oldValue(ctx)
  32116. if err != nil {
  32117. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32118. }
  32119. return oldValue.CreatedAt, nil
  32120. }
  32121. // ResetCreatedAt resets all changes to the "created_at" field.
  32122. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  32123. m.created_at = nil
  32124. }
  32125. // SetUpdatedAt sets the "updated_at" field.
  32126. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  32127. m.updated_at = &t
  32128. }
  32129. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32130. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  32131. v := m.updated_at
  32132. if v == nil {
  32133. return
  32134. }
  32135. return *v, true
  32136. }
  32137. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  32138. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32140. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32141. if !m.op.Is(OpUpdateOne) {
  32142. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32143. }
  32144. if m.id == nil || m.oldValue == nil {
  32145. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32146. }
  32147. oldValue, err := m.oldValue(ctx)
  32148. if err != nil {
  32149. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32150. }
  32151. return oldValue.UpdatedAt, nil
  32152. }
  32153. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32154. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  32155. m.updated_at = nil
  32156. }
  32157. // SetStatus sets the "status" field.
  32158. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  32159. m.status = &u
  32160. m.addstatus = nil
  32161. }
  32162. // Status returns the value of the "status" field in the mutation.
  32163. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  32164. v := m.status
  32165. if v == nil {
  32166. return
  32167. }
  32168. return *v, true
  32169. }
  32170. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  32171. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32173. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32174. if !m.op.Is(OpUpdateOne) {
  32175. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32176. }
  32177. if m.id == nil || m.oldValue == nil {
  32178. return v, errors.New("OldStatus requires an ID field in the mutation")
  32179. }
  32180. oldValue, err := m.oldValue(ctx)
  32181. if err != nil {
  32182. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32183. }
  32184. return oldValue.Status, nil
  32185. }
  32186. // AddStatus adds u to the "status" field.
  32187. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  32188. if m.addstatus != nil {
  32189. *m.addstatus += u
  32190. } else {
  32191. m.addstatus = &u
  32192. }
  32193. }
  32194. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32195. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  32196. v := m.addstatus
  32197. if v == nil {
  32198. return
  32199. }
  32200. return *v, true
  32201. }
  32202. // ClearStatus clears the value of the "status" field.
  32203. func (m *UsageStatisticHourMutation) ClearStatus() {
  32204. m.status = nil
  32205. m.addstatus = nil
  32206. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  32207. }
  32208. // StatusCleared returns if the "status" field was cleared in this mutation.
  32209. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  32210. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  32211. return ok
  32212. }
  32213. // ResetStatus resets all changes to the "status" field.
  32214. func (m *UsageStatisticHourMutation) ResetStatus() {
  32215. m.status = nil
  32216. m.addstatus = nil
  32217. delete(m.clearedFields, usagestatistichour.FieldStatus)
  32218. }
  32219. // SetDeletedAt sets the "deleted_at" field.
  32220. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  32221. m.deleted_at = &t
  32222. }
  32223. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32224. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  32225. v := m.deleted_at
  32226. if v == nil {
  32227. return
  32228. }
  32229. return *v, true
  32230. }
  32231. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  32232. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32234. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32235. if !m.op.Is(OpUpdateOne) {
  32236. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32237. }
  32238. if m.id == nil || m.oldValue == nil {
  32239. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32240. }
  32241. oldValue, err := m.oldValue(ctx)
  32242. if err != nil {
  32243. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32244. }
  32245. return oldValue.DeletedAt, nil
  32246. }
  32247. // ClearDeletedAt clears the value of the "deleted_at" field.
  32248. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  32249. m.deleted_at = nil
  32250. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  32251. }
  32252. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32253. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  32254. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  32255. return ok
  32256. }
  32257. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32258. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  32259. m.deleted_at = nil
  32260. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  32261. }
  32262. // SetAddtime sets the "addtime" field.
  32263. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  32264. m.addtime = &u
  32265. m.addaddtime = nil
  32266. }
  32267. // Addtime returns the value of the "addtime" field in the mutation.
  32268. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  32269. v := m.addtime
  32270. if v == nil {
  32271. return
  32272. }
  32273. return *v, true
  32274. }
  32275. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  32276. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32278. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32279. if !m.op.Is(OpUpdateOne) {
  32280. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32281. }
  32282. if m.id == nil || m.oldValue == nil {
  32283. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32284. }
  32285. oldValue, err := m.oldValue(ctx)
  32286. if err != nil {
  32287. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32288. }
  32289. return oldValue.Addtime, nil
  32290. }
  32291. // AddAddtime adds u to the "addtime" field.
  32292. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  32293. if m.addaddtime != nil {
  32294. *m.addaddtime += u
  32295. } else {
  32296. m.addaddtime = &u
  32297. }
  32298. }
  32299. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32300. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  32301. v := m.addaddtime
  32302. if v == nil {
  32303. return
  32304. }
  32305. return *v, true
  32306. }
  32307. // ResetAddtime resets all changes to the "addtime" field.
  32308. func (m *UsageStatisticHourMutation) ResetAddtime() {
  32309. m.addtime = nil
  32310. m.addaddtime = nil
  32311. }
  32312. // SetType sets the "type" field.
  32313. func (m *UsageStatisticHourMutation) SetType(i int) {
  32314. m._type = &i
  32315. m.add_type = nil
  32316. }
  32317. // GetType returns the value of the "type" field in the mutation.
  32318. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  32319. v := m._type
  32320. if v == nil {
  32321. return
  32322. }
  32323. return *v, true
  32324. }
  32325. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  32326. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32328. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  32329. if !m.op.Is(OpUpdateOne) {
  32330. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32331. }
  32332. if m.id == nil || m.oldValue == nil {
  32333. return v, errors.New("OldType requires an ID field in the mutation")
  32334. }
  32335. oldValue, err := m.oldValue(ctx)
  32336. if err != nil {
  32337. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32338. }
  32339. return oldValue.Type, nil
  32340. }
  32341. // AddType adds i to the "type" field.
  32342. func (m *UsageStatisticHourMutation) AddType(i int) {
  32343. if m.add_type != nil {
  32344. *m.add_type += i
  32345. } else {
  32346. m.add_type = &i
  32347. }
  32348. }
  32349. // AddedType returns the value that was added to the "type" field in this mutation.
  32350. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  32351. v := m.add_type
  32352. if v == nil {
  32353. return
  32354. }
  32355. return *v, true
  32356. }
  32357. // ResetType resets all changes to the "type" field.
  32358. func (m *UsageStatisticHourMutation) ResetType() {
  32359. m._type = nil
  32360. m.add_type = nil
  32361. }
  32362. // SetBotID sets the "bot_id" field.
  32363. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  32364. m.bot_id = &s
  32365. }
  32366. // BotID returns the value of the "bot_id" field in the mutation.
  32367. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  32368. v := m.bot_id
  32369. if v == nil {
  32370. return
  32371. }
  32372. return *v, true
  32373. }
  32374. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  32375. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32377. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  32378. if !m.op.Is(OpUpdateOne) {
  32379. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32380. }
  32381. if m.id == nil || m.oldValue == nil {
  32382. return v, errors.New("OldBotID requires an ID field in the mutation")
  32383. }
  32384. oldValue, err := m.oldValue(ctx)
  32385. if err != nil {
  32386. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32387. }
  32388. return oldValue.BotID, nil
  32389. }
  32390. // ClearBotID clears the value of the "bot_id" field.
  32391. func (m *UsageStatisticHourMutation) ClearBotID() {
  32392. m.bot_id = nil
  32393. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  32394. }
  32395. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32396. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  32397. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  32398. return ok
  32399. }
  32400. // ResetBotID resets all changes to the "bot_id" field.
  32401. func (m *UsageStatisticHourMutation) ResetBotID() {
  32402. m.bot_id = nil
  32403. delete(m.clearedFields, usagestatistichour.FieldBotID)
  32404. }
  32405. // SetOrganizationID sets the "organization_id" field.
  32406. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  32407. m.organization_id = &u
  32408. m.addorganization_id = nil
  32409. }
  32410. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32411. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  32412. v := m.organization_id
  32413. if v == nil {
  32414. return
  32415. }
  32416. return *v, true
  32417. }
  32418. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  32419. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32421. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32422. if !m.op.Is(OpUpdateOne) {
  32423. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32424. }
  32425. if m.id == nil || m.oldValue == nil {
  32426. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32427. }
  32428. oldValue, err := m.oldValue(ctx)
  32429. if err != nil {
  32430. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32431. }
  32432. return oldValue.OrganizationID, nil
  32433. }
  32434. // AddOrganizationID adds u to the "organization_id" field.
  32435. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  32436. if m.addorganization_id != nil {
  32437. *m.addorganization_id += u
  32438. } else {
  32439. m.addorganization_id = &u
  32440. }
  32441. }
  32442. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32443. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  32444. v := m.addorganization_id
  32445. if v == nil {
  32446. return
  32447. }
  32448. return *v, true
  32449. }
  32450. // ClearOrganizationID clears the value of the "organization_id" field.
  32451. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  32452. m.organization_id = nil
  32453. m.addorganization_id = nil
  32454. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  32455. }
  32456. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32457. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  32458. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  32459. return ok
  32460. }
  32461. // ResetOrganizationID resets all changes to the "organization_id" field.
  32462. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  32463. m.organization_id = nil
  32464. m.addorganization_id = nil
  32465. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  32466. }
  32467. // SetAiResponse sets the "ai_response" field.
  32468. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  32469. m.ai_response = &u
  32470. m.addai_response = nil
  32471. }
  32472. // AiResponse returns the value of the "ai_response" field in the mutation.
  32473. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  32474. v := m.ai_response
  32475. if v == nil {
  32476. return
  32477. }
  32478. return *v, true
  32479. }
  32480. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  32481. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32483. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32484. if !m.op.Is(OpUpdateOne) {
  32485. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32486. }
  32487. if m.id == nil || m.oldValue == nil {
  32488. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32489. }
  32490. oldValue, err := m.oldValue(ctx)
  32491. if err != nil {
  32492. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32493. }
  32494. return oldValue.AiResponse, nil
  32495. }
  32496. // AddAiResponse adds u to the "ai_response" field.
  32497. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  32498. if m.addai_response != nil {
  32499. *m.addai_response += u
  32500. } else {
  32501. m.addai_response = &u
  32502. }
  32503. }
  32504. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32505. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  32506. v := m.addai_response
  32507. if v == nil {
  32508. return
  32509. }
  32510. return *v, true
  32511. }
  32512. // ResetAiResponse resets all changes to the "ai_response" field.
  32513. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  32514. m.ai_response = nil
  32515. m.addai_response = nil
  32516. }
  32517. // SetSopRun sets the "sop_run" field.
  32518. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  32519. m.sop_run = &u
  32520. m.addsop_run = nil
  32521. }
  32522. // SopRun returns the value of the "sop_run" field in the mutation.
  32523. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  32524. v := m.sop_run
  32525. if v == nil {
  32526. return
  32527. }
  32528. return *v, true
  32529. }
  32530. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  32531. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32533. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32534. if !m.op.Is(OpUpdateOne) {
  32535. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32536. }
  32537. if m.id == nil || m.oldValue == nil {
  32538. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32539. }
  32540. oldValue, err := m.oldValue(ctx)
  32541. if err != nil {
  32542. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32543. }
  32544. return oldValue.SopRun, nil
  32545. }
  32546. // AddSopRun adds u to the "sop_run" field.
  32547. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  32548. if m.addsop_run != nil {
  32549. *m.addsop_run += u
  32550. } else {
  32551. m.addsop_run = &u
  32552. }
  32553. }
  32554. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32555. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  32556. v := m.addsop_run
  32557. if v == nil {
  32558. return
  32559. }
  32560. return *v, true
  32561. }
  32562. // ResetSopRun resets all changes to the "sop_run" field.
  32563. func (m *UsageStatisticHourMutation) ResetSopRun() {
  32564. m.sop_run = nil
  32565. m.addsop_run = nil
  32566. }
  32567. // SetTotalFriend sets the "total_friend" field.
  32568. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  32569. m.total_friend = &u
  32570. m.addtotal_friend = nil
  32571. }
  32572. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32573. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  32574. v := m.total_friend
  32575. if v == nil {
  32576. return
  32577. }
  32578. return *v, true
  32579. }
  32580. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  32581. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32583. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32584. if !m.op.Is(OpUpdateOne) {
  32585. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32586. }
  32587. if m.id == nil || m.oldValue == nil {
  32588. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32589. }
  32590. oldValue, err := m.oldValue(ctx)
  32591. if err != nil {
  32592. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32593. }
  32594. return oldValue.TotalFriend, nil
  32595. }
  32596. // AddTotalFriend adds u to the "total_friend" field.
  32597. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  32598. if m.addtotal_friend != nil {
  32599. *m.addtotal_friend += u
  32600. } else {
  32601. m.addtotal_friend = &u
  32602. }
  32603. }
  32604. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32605. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  32606. v := m.addtotal_friend
  32607. if v == nil {
  32608. return
  32609. }
  32610. return *v, true
  32611. }
  32612. // ResetTotalFriend resets all changes to the "total_friend" field.
  32613. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  32614. m.total_friend = nil
  32615. m.addtotal_friend = nil
  32616. }
  32617. // SetTotalGroup sets the "total_group" field.
  32618. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  32619. m.total_group = &u
  32620. m.addtotal_group = nil
  32621. }
  32622. // TotalGroup returns the value of the "total_group" field in the mutation.
  32623. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  32624. v := m.total_group
  32625. if v == nil {
  32626. return
  32627. }
  32628. return *v, true
  32629. }
  32630. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  32631. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32633. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32634. if !m.op.Is(OpUpdateOne) {
  32635. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32636. }
  32637. if m.id == nil || m.oldValue == nil {
  32638. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32639. }
  32640. oldValue, err := m.oldValue(ctx)
  32641. if err != nil {
  32642. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32643. }
  32644. return oldValue.TotalGroup, nil
  32645. }
  32646. // AddTotalGroup adds u to the "total_group" field.
  32647. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  32648. if m.addtotal_group != nil {
  32649. *m.addtotal_group += u
  32650. } else {
  32651. m.addtotal_group = &u
  32652. }
  32653. }
  32654. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32655. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  32656. v := m.addtotal_group
  32657. if v == nil {
  32658. return
  32659. }
  32660. return *v, true
  32661. }
  32662. // ResetTotalGroup resets all changes to the "total_group" field.
  32663. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  32664. m.total_group = nil
  32665. m.addtotal_group = nil
  32666. }
  32667. // SetAccountBalance sets the "account_balance" field.
  32668. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  32669. m.account_balance = &u
  32670. m.addaccount_balance = nil
  32671. }
  32672. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32673. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  32674. v := m.account_balance
  32675. if v == nil {
  32676. return
  32677. }
  32678. return *v, true
  32679. }
  32680. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  32681. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32683. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32684. if !m.op.Is(OpUpdateOne) {
  32685. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32686. }
  32687. if m.id == nil || m.oldValue == nil {
  32688. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32689. }
  32690. oldValue, err := m.oldValue(ctx)
  32691. if err != nil {
  32692. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32693. }
  32694. return oldValue.AccountBalance, nil
  32695. }
  32696. // AddAccountBalance adds u to the "account_balance" field.
  32697. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  32698. if m.addaccount_balance != nil {
  32699. *m.addaccount_balance += u
  32700. } else {
  32701. m.addaccount_balance = &u
  32702. }
  32703. }
  32704. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32705. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  32706. v := m.addaccount_balance
  32707. if v == nil {
  32708. return
  32709. }
  32710. return *v, true
  32711. }
  32712. // ResetAccountBalance resets all changes to the "account_balance" field.
  32713. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  32714. m.account_balance = nil
  32715. m.addaccount_balance = nil
  32716. }
  32717. // SetConsumeToken sets the "consume_token" field.
  32718. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  32719. m.consume_token = &u
  32720. m.addconsume_token = nil
  32721. }
  32722. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32723. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  32724. v := m.consume_token
  32725. if v == nil {
  32726. return
  32727. }
  32728. return *v, true
  32729. }
  32730. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  32731. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32733. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32734. if !m.op.Is(OpUpdateOne) {
  32735. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32736. }
  32737. if m.id == nil || m.oldValue == nil {
  32738. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32739. }
  32740. oldValue, err := m.oldValue(ctx)
  32741. if err != nil {
  32742. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32743. }
  32744. return oldValue.ConsumeToken, nil
  32745. }
  32746. // AddConsumeToken adds u to the "consume_token" field.
  32747. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  32748. if m.addconsume_token != nil {
  32749. *m.addconsume_token += u
  32750. } else {
  32751. m.addconsume_token = &u
  32752. }
  32753. }
  32754. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  32755. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  32756. v := m.addconsume_token
  32757. if v == nil {
  32758. return
  32759. }
  32760. return *v, true
  32761. }
  32762. // ResetConsumeToken resets all changes to the "consume_token" field.
  32763. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  32764. m.consume_token = nil
  32765. m.addconsume_token = nil
  32766. }
  32767. // SetActiveUser sets the "active_user" field.
  32768. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  32769. m.active_user = &u
  32770. m.addactive_user = nil
  32771. }
  32772. // ActiveUser returns the value of the "active_user" field in the mutation.
  32773. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  32774. v := m.active_user
  32775. if v == nil {
  32776. return
  32777. }
  32778. return *v, true
  32779. }
  32780. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  32781. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32783. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32784. if !m.op.Is(OpUpdateOne) {
  32785. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32786. }
  32787. if m.id == nil || m.oldValue == nil {
  32788. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32789. }
  32790. oldValue, err := m.oldValue(ctx)
  32791. if err != nil {
  32792. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32793. }
  32794. return oldValue.ActiveUser, nil
  32795. }
  32796. // AddActiveUser adds u to the "active_user" field.
  32797. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  32798. if m.addactive_user != nil {
  32799. *m.addactive_user += u
  32800. } else {
  32801. m.addactive_user = &u
  32802. }
  32803. }
  32804. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32805. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  32806. v := m.addactive_user
  32807. if v == nil {
  32808. return
  32809. }
  32810. return *v, true
  32811. }
  32812. // ResetActiveUser resets all changes to the "active_user" field.
  32813. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  32814. m.active_user = nil
  32815. m.addactive_user = nil
  32816. }
  32817. // SetNewUser sets the "new_user" field.
  32818. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  32819. m.new_user = &i
  32820. m.addnew_user = nil
  32821. }
  32822. // NewUser returns the value of the "new_user" field in the mutation.
  32823. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  32824. v := m.new_user
  32825. if v == nil {
  32826. return
  32827. }
  32828. return *v, true
  32829. }
  32830. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  32831. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32833. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32834. if !m.op.Is(OpUpdateOne) {
  32835. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32836. }
  32837. if m.id == nil || m.oldValue == nil {
  32838. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32839. }
  32840. oldValue, err := m.oldValue(ctx)
  32841. if err != nil {
  32842. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32843. }
  32844. return oldValue.NewUser, nil
  32845. }
  32846. // AddNewUser adds i to the "new_user" field.
  32847. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  32848. if m.addnew_user != nil {
  32849. *m.addnew_user += i
  32850. } else {
  32851. m.addnew_user = &i
  32852. }
  32853. }
  32854. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32855. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  32856. v := m.addnew_user
  32857. if v == nil {
  32858. return
  32859. }
  32860. return *v, true
  32861. }
  32862. // ResetNewUser resets all changes to the "new_user" field.
  32863. func (m *UsageStatisticHourMutation) ResetNewUser() {
  32864. m.new_user = nil
  32865. m.addnew_user = nil
  32866. }
  32867. // SetLabelDist sets the "label_dist" field.
  32868. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32869. m.label_dist = &ctd
  32870. m.appendlabel_dist = nil
  32871. }
  32872. // LabelDist returns the value of the "label_dist" field in the mutation.
  32873. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32874. v := m.label_dist
  32875. if v == nil {
  32876. return
  32877. }
  32878. return *v, true
  32879. }
  32880. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  32881. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32883. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32884. if !m.op.Is(OpUpdateOne) {
  32885. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32886. }
  32887. if m.id == nil || m.oldValue == nil {
  32888. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32889. }
  32890. oldValue, err := m.oldValue(ctx)
  32891. if err != nil {
  32892. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32893. }
  32894. return oldValue.LabelDist, nil
  32895. }
  32896. // AppendLabelDist adds ctd to the "label_dist" field.
  32897. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32898. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32899. }
  32900. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32901. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32902. if len(m.appendlabel_dist) == 0 {
  32903. return nil, false
  32904. }
  32905. return m.appendlabel_dist, true
  32906. }
  32907. // ResetLabelDist resets all changes to the "label_dist" field.
  32908. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  32909. m.label_dist = nil
  32910. m.appendlabel_dist = nil
  32911. }
  32912. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  32913. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  32914. m.predicates = append(m.predicates, ps...)
  32915. }
  32916. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  32917. // users can use type-assertion to append predicates that do not depend on any generated package.
  32918. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  32919. p := make([]predicate.UsageStatisticHour, len(ps))
  32920. for i := range ps {
  32921. p[i] = ps[i]
  32922. }
  32923. m.Where(p...)
  32924. }
  32925. // Op returns the operation name.
  32926. func (m *UsageStatisticHourMutation) Op() Op {
  32927. return m.op
  32928. }
  32929. // SetOp allows setting the mutation operation.
  32930. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  32931. m.op = op
  32932. }
  32933. // Type returns the node type of this mutation (UsageStatisticHour).
  32934. func (m *UsageStatisticHourMutation) Type() string {
  32935. return m.typ
  32936. }
  32937. // Fields returns all fields that were changed during this mutation. Note that in
  32938. // order to get all numeric fields that were incremented/decremented, call
  32939. // AddedFields().
  32940. func (m *UsageStatisticHourMutation) Fields() []string {
  32941. fields := make([]string, 0, 17)
  32942. if m.created_at != nil {
  32943. fields = append(fields, usagestatistichour.FieldCreatedAt)
  32944. }
  32945. if m.updated_at != nil {
  32946. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  32947. }
  32948. if m.status != nil {
  32949. fields = append(fields, usagestatistichour.FieldStatus)
  32950. }
  32951. if m.deleted_at != nil {
  32952. fields = append(fields, usagestatistichour.FieldDeletedAt)
  32953. }
  32954. if m.addtime != nil {
  32955. fields = append(fields, usagestatistichour.FieldAddtime)
  32956. }
  32957. if m._type != nil {
  32958. fields = append(fields, usagestatistichour.FieldType)
  32959. }
  32960. if m.bot_id != nil {
  32961. fields = append(fields, usagestatistichour.FieldBotID)
  32962. }
  32963. if m.organization_id != nil {
  32964. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32965. }
  32966. if m.ai_response != nil {
  32967. fields = append(fields, usagestatistichour.FieldAiResponse)
  32968. }
  32969. if m.sop_run != nil {
  32970. fields = append(fields, usagestatistichour.FieldSopRun)
  32971. }
  32972. if m.total_friend != nil {
  32973. fields = append(fields, usagestatistichour.FieldTotalFriend)
  32974. }
  32975. if m.total_group != nil {
  32976. fields = append(fields, usagestatistichour.FieldTotalGroup)
  32977. }
  32978. if m.account_balance != nil {
  32979. fields = append(fields, usagestatistichour.FieldAccountBalance)
  32980. }
  32981. if m.consume_token != nil {
  32982. fields = append(fields, usagestatistichour.FieldConsumeToken)
  32983. }
  32984. if m.active_user != nil {
  32985. fields = append(fields, usagestatistichour.FieldActiveUser)
  32986. }
  32987. if m.new_user != nil {
  32988. fields = append(fields, usagestatistichour.FieldNewUser)
  32989. }
  32990. if m.label_dist != nil {
  32991. fields = append(fields, usagestatistichour.FieldLabelDist)
  32992. }
  32993. return fields
  32994. }
  32995. // Field returns the value of a field with the given name. The second boolean
  32996. // return value indicates that this field was not set, or was not defined in the
  32997. // schema.
  32998. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  32999. switch name {
  33000. case usagestatistichour.FieldCreatedAt:
  33001. return m.CreatedAt()
  33002. case usagestatistichour.FieldUpdatedAt:
  33003. return m.UpdatedAt()
  33004. case usagestatistichour.FieldStatus:
  33005. return m.Status()
  33006. case usagestatistichour.FieldDeletedAt:
  33007. return m.DeletedAt()
  33008. case usagestatistichour.FieldAddtime:
  33009. return m.Addtime()
  33010. case usagestatistichour.FieldType:
  33011. return m.GetType()
  33012. case usagestatistichour.FieldBotID:
  33013. return m.BotID()
  33014. case usagestatistichour.FieldOrganizationID:
  33015. return m.OrganizationID()
  33016. case usagestatistichour.FieldAiResponse:
  33017. return m.AiResponse()
  33018. case usagestatistichour.FieldSopRun:
  33019. return m.SopRun()
  33020. case usagestatistichour.FieldTotalFriend:
  33021. return m.TotalFriend()
  33022. case usagestatistichour.FieldTotalGroup:
  33023. return m.TotalGroup()
  33024. case usagestatistichour.FieldAccountBalance:
  33025. return m.AccountBalance()
  33026. case usagestatistichour.FieldConsumeToken:
  33027. return m.ConsumeToken()
  33028. case usagestatistichour.FieldActiveUser:
  33029. return m.ActiveUser()
  33030. case usagestatistichour.FieldNewUser:
  33031. return m.NewUser()
  33032. case usagestatistichour.FieldLabelDist:
  33033. return m.LabelDist()
  33034. }
  33035. return nil, false
  33036. }
  33037. // OldField returns the old value of the field from the database. An error is
  33038. // returned if the mutation operation is not UpdateOne, or the query to the
  33039. // database failed.
  33040. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33041. switch name {
  33042. case usagestatistichour.FieldCreatedAt:
  33043. return m.OldCreatedAt(ctx)
  33044. case usagestatistichour.FieldUpdatedAt:
  33045. return m.OldUpdatedAt(ctx)
  33046. case usagestatistichour.FieldStatus:
  33047. return m.OldStatus(ctx)
  33048. case usagestatistichour.FieldDeletedAt:
  33049. return m.OldDeletedAt(ctx)
  33050. case usagestatistichour.FieldAddtime:
  33051. return m.OldAddtime(ctx)
  33052. case usagestatistichour.FieldType:
  33053. return m.OldType(ctx)
  33054. case usagestatistichour.FieldBotID:
  33055. return m.OldBotID(ctx)
  33056. case usagestatistichour.FieldOrganizationID:
  33057. return m.OldOrganizationID(ctx)
  33058. case usagestatistichour.FieldAiResponse:
  33059. return m.OldAiResponse(ctx)
  33060. case usagestatistichour.FieldSopRun:
  33061. return m.OldSopRun(ctx)
  33062. case usagestatistichour.FieldTotalFriend:
  33063. return m.OldTotalFriend(ctx)
  33064. case usagestatistichour.FieldTotalGroup:
  33065. return m.OldTotalGroup(ctx)
  33066. case usagestatistichour.FieldAccountBalance:
  33067. return m.OldAccountBalance(ctx)
  33068. case usagestatistichour.FieldConsumeToken:
  33069. return m.OldConsumeToken(ctx)
  33070. case usagestatistichour.FieldActiveUser:
  33071. return m.OldActiveUser(ctx)
  33072. case usagestatistichour.FieldNewUser:
  33073. return m.OldNewUser(ctx)
  33074. case usagestatistichour.FieldLabelDist:
  33075. return m.OldLabelDist(ctx)
  33076. }
  33077. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33078. }
  33079. // SetField sets the value of a field with the given name. It returns an error if
  33080. // the field is not defined in the schema, or if the type mismatched the field
  33081. // type.
  33082. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  33083. switch name {
  33084. case usagestatistichour.FieldCreatedAt:
  33085. v, ok := value.(time.Time)
  33086. if !ok {
  33087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33088. }
  33089. m.SetCreatedAt(v)
  33090. return nil
  33091. case usagestatistichour.FieldUpdatedAt:
  33092. v, ok := value.(time.Time)
  33093. if !ok {
  33094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33095. }
  33096. m.SetUpdatedAt(v)
  33097. return nil
  33098. case usagestatistichour.FieldStatus:
  33099. v, ok := value.(uint8)
  33100. if !ok {
  33101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33102. }
  33103. m.SetStatus(v)
  33104. return nil
  33105. case usagestatistichour.FieldDeletedAt:
  33106. v, ok := value.(time.Time)
  33107. if !ok {
  33108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33109. }
  33110. m.SetDeletedAt(v)
  33111. return nil
  33112. case usagestatistichour.FieldAddtime:
  33113. v, ok := value.(uint64)
  33114. if !ok {
  33115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33116. }
  33117. m.SetAddtime(v)
  33118. return nil
  33119. case usagestatistichour.FieldType:
  33120. v, ok := value.(int)
  33121. if !ok {
  33122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33123. }
  33124. m.SetType(v)
  33125. return nil
  33126. case usagestatistichour.FieldBotID:
  33127. v, ok := value.(string)
  33128. if !ok {
  33129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33130. }
  33131. m.SetBotID(v)
  33132. return nil
  33133. case usagestatistichour.FieldOrganizationID:
  33134. v, ok := value.(uint64)
  33135. if !ok {
  33136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33137. }
  33138. m.SetOrganizationID(v)
  33139. return nil
  33140. case usagestatistichour.FieldAiResponse:
  33141. v, ok := value.(uint64)
  33142. if !ok {
  33143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33144. }
  33145. m.SetAiResponse(v)
  33146. return nil
  33147. case usagestatistichour.FieldSopRun:
  33148. v, ok := value.(uint64)
  33149. if !ok {
  33150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33151. }
  33152. m.SetSopRun(v)
  33153. return nil
  33154. case usagestatistichour.FieldTotalFriend:
  33155. v, ok := value.(uint64)
  33156. if !ok {
  33157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33158. }
  33159. m.SetTotalFriend(v)
  33160. return nil
  33161. case usagestatistichour.FieldTotalGroup:
  33162. v, ok := value.(uint64)
  33163. if !ok {
  33164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33165. }
  33166. m.SetTotalGroup(v)
  33167. return nil
  33168. case usagestatistichour.FieldAccountBalance:
  33169. v, ok := value.(uint64)
  33170. if !ok {
  33171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33172. }
  33173. m.SetAccountBalance(v)
  33174. return nil
  33175. case usagestatistichour.FieldConsumeToken:
  33176. v, ok := value.(uint64)
  33177. if !ok {
  33178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33179. }
  33180. m.SetConsumeToken(v)
  33181. return nil
  33182. case usagestatistichour.FieldActiveUser:
  33183. v, ok := value.(uint64)
  33184. if !ok {
  33185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33186. }
  33187. m.SetActiveUser(v)
  33188. return nil
  33189. case usagestatistichour.FieldNewUser:
  33190. v, ok := value.(int64)
  33191. if !ok {
  33192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33193. }
  33194. m.SetNewUser(v)
  33195. return nil
  33196. case usagestatistichour.FieldLabelDist:
  33197. v, ok := value.([]custom_types.LabelDist)
  33198. if !ok {
  33199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33200. }
  33201. m.SetLabelDist(v)
  33202. return nil
  33203. }
  33204. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33205. }
  33206. // AddedFields returns all numeric fields that were incremented/decremented during
  33207. // this mutation.
  33208. func (m *UsageStatisticHourMutation) AddedFields() []string {
  33209. var fields []string
  33210. if m.addstatus != nil {
  33211. fields = append(fields, usagestatistichour.FieldStatus)
  33212. }
  33213. if m.addaddtime != nil {
  33214. fields = append(fields, usagestatistichour.FieldAddtime)
  33215. }
  33216. if m.add_type != nil {
  33217. fields = append(fields, usagestatistichour.FieldType)
  33218. }
  33219. if m.addorganization_id != nil {
  33220. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33221. }
  33222. if m.addai_response != nil {
  33223. fields = append(fields, usagestatistichour.FieldAiResponse)
  33224. }
  33225. if m.addsop_run != nil {
  33226. fields = append(fields, usagestatistichour.FieldSopRun)
  33227. }
  33228. if m.addtotal_friend != nil {
  33229. fields = append(fields, usagestatistichour.FieldTotalFriend)
  33230. }
  33231. if m.addtotal_group != nil {
  33232. fields = append(fields, usagestatistichour.FieldTotalGroup)
  33233. }
  33234. if m.addaccount_balance != nil {
  33235. fields = append(fields, usagestatistichour.FieldAccountBalance)
  33236. }
  33237. if m.addconsume_token != nil {
  33238. fields = append(fields, usagestatistichour.FieldConsumeToken)
  33239. }
  33240. if m.addactive_user != nil {
  33241. fields = append(fields, usagestatistichour.FieldActiveUser)
  33242. }
  33243. if m.addnew_user != nil {
  33244. fields = append(fields, usagestatistichour.FieldNewUser)
  33245. }
  33246. return fields
  33247. }
  33248. // AddedField returns the numeric value that was incremented/decremented on a field
  33249. // with the given name. The second boolean return value indicates that this field
  33250. // was not set, or was not defined in the schema.
  33251. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  33252. switch name {
  33253. case usagestatistichour.FieldStatus:
  33254. return m.AddedStatus()
  33255. case usagestatistichour.FieldAddtime:
  33256. return m.AddedAddtime()
  33257. case usagestatistichour.FieldType:
  33258. return m.AddedType()
  33259. case usagestatistichour.FieldOrganizationID:
  33260. return m.AddedOrganizationID()
  33261. case usagestatistichour.FieldAiResponse:
  33262. return m.AddedAiResponse()
  33263. case usagestatistichour.FieldSopRun:
  33264. return m.AddedSopRun()
  33265. case usagestatistichour.FieldTotalFriend:
  33266. return m.AddedTotalFriend()
  33267. case usagestatistichour.FieldTotalGroup:
  33268. return m.AddedTotalGroup()
  33269. case usagestatistichour.FieldAccountBalance:
  33270. return m.AddedAccountBalance()
  33271. case usagestatistichour.FieldConsumeToken:
  33272. return m.AddedConsumeToken()
  33273. case usagestatistichour.FieldActiveUser:
  33274. return m.AddedActiveUser()
  33275. case usagestatistichour.FieldNewUser:
  33276. return m.AddedNewUser()
  33277. }
  33278. return nil, false
  33279. }
  33280. // AddField adds the value to the field with the given name. It returns an error if
  33281. // the field is not defined in the schema, or if the type mismatched the field
  33282. // type.
  33283. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  33284. switch name {
  33285. case usagestatistichour.FieldStatus:
  33286. v, ok := value.(int8)
  33287. if !ok {
  33288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33289. }
  33290. m.AddStatus(v)
  33291. return nil
  33292. case usagestatistichour.FieldAddtime:
  33293. v, ok := value.(int64)
  33294. if !ok {
  33295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33296. }
  33297. m.AddAddtime(v)
  33298. return nil
  33299. case usagestatistichour.FieldType:
  33300. v, ok := value.(int)
  33301. if !ok {
  33302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33303. }
  33304. m.AddType(v)
  33305. return nil
  33306. case usagestatistichour.FieldOrganizationID:
  33307. v, ok := value.(int64)
  33308. if !ok {
  33309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33310. }
  33311. m.AddOrganizationID(v)
  33312. return nil
  33313. case usagestatistichour.FieldAiResponse:
  33314. v, ok := value.(int64)
  33315. if !ok {
  33316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33317. }
  33318. m.AddAiResponse(v)
  33319. return nil
  33320. case usagestatistichour.FieldSopRun:
  33321. v, ok := value.(int64)
  33322. if !ok {
  33323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33324. }
  33325. m.AddSopRun(v)
  33326. return nil
  33327. case usagestatistichour.FieldTotalFriend:
  33328. v, ok := value.(int64)
  33329. if !ok {
  33330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33331. }
  33332. m.AddTotalFriend(v)
  33333. return nil
  33334. case usagestatistichour.FieldTotalGroup:
  33335. v, ok := value.(int64)
  33336. if !ok {
  33337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33338. }
  33339. m.AddTotalGroup(v)
  33340. return nil
  33341. case usagestatistichour.FieldAccountBalance:
  33342. v, ok := value.(int64)
  33343. if !ok {
  33344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33345. }
  33346. m.AddAccountBalance(v)
  33347. return nil
  33348. case usagestatistichour.FieldConsumeToken:
  33349. v, ok := value.(int64)
  33350. if !ok {
  33351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33352. }
  33353. m.AddConsumeToken(v)
  33354. return nil
  33355. case usagestatistichour.FieldActiveUser:
  33356. v, ok := value.(int64)
  33357. if !ok {
  33358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33359. }
  33360. m.AddActiveUser(v)
  33361. return nil
  33362. case usagestatistichour.FieldNewUser:
  33363. v, ok := value.(int64)
  33364. if !ok {
  33365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33366. }
  33367. m.AddNewUser(v)
  33368. return nil
  33369. }
  33370. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  33371. }
  33372. // ClearedFields returns all nullable fields that were cleared during this
  33373. // mutation.
  33374. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  33375. var fields []string
  33376. if m.FieldCleared(usagestatistichour.FieldStatus) {
  33377. fields = append(fields, usagestatistichour.FieldStatus)
  33378. }
  33379. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  33380. fields = append(fields, usagestatistichour.FieldDeletedAt)
  33381. }
  33382. if m.FieldCleared(usagestatistichour.FieldBotID) {
  33383. fields = append(fields, usagestatistichour.FieldBotID)
  33384. }
  33385. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  33386. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33387. }
  33388. return fields
  33389. }
  33390. // FieldCleared returns a boolean indicating if a field with the given name was
  33391. // cleared in this mutation.
  33392. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  33393. _, ok := m.clearedFields[name]
  33394. return ok
  33395. }
  33396. // ClearField clears the value of the field with the given name. It returns an
  33397. // error if the field is not defined in the schema.
  33398. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  33399. switch name {
  33400. case usagestatistichour.FieldStatus:
  33401. m.ClearStatus()
  33402. return nil
  33403. case usagestatistichour.FieldDeletedAt:
  33404. m.ClearDeletedAt()
  33405. return nil
  33406. case usagestatistichour.FieldBotID:
  33407. m.ClearBotID()
  33408. return nil
  33409. case usagestatistichour.FieldOrganizationID:
  33410. m.ClearOrganizationID()
  33411. return nil
  33412. }
  33413. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  33414. }
  33415. // ResetField resets all changes in the mutation for the field with the given name.
  33416. // It returns an error if the field is not defined in the schema.
  33417. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  33418. switch name {
  33419. case usagestatistichour.FieldCreatedAt:
  33420. m.ResetCreatedAt()
  33421. return nil
  33422. case usagestatistichour.FieldUpdatedAt:
  33423. m.ResetUpdatedAt()
  33424. return nil
  33425. case usagestatistichour.FieldStatus:
  33426. m.ResetStatus()
  33427. return nil
  33428. case usagestatistichour.FieldDeletedAt:
  33429. m.ResetDeletedAt()
  33430. return nil
  33431. case usagestatistichour.FieldAddtime:
  33432. m.ResetAddtime()
  33433. return nil
  33434. case usagestatistichour.FieldType:
  33435. m.ResetType()
  33436. return nil
  33437. case usagestatistichour.FieldBotID:
  33438. m.ResetBotID()
  33439. return nil
  33440. case usagestatistichour.FieldOrganizationID:
  33441. m.ResetOrganizationID()
  33442. return nil
  33443. case usagestatistichour.FieldAiResponse:
  33444. m.ResetAiResponse()
  33445. return nil
  33446. case usagestatistichour.FieldSopRun:
  33447. m.ResetSopRun()
  33448. return nil
  33449. case usagestatistichour.FieldTotalFriend:
  33450. m.ResetTotalFriend()
  33451. return nil
  33452. case usagestatistichour.FieldTotalGroup:
  33453. m.ResetTotalGroup()
  33454. return nil
  33455. case usagestatistichour.FieldAccountBalance:
  33456. m.ResetAccountBalance()
  33457. return nil
  33458. case usagestatistichour.FieldConsumeToken:
  33459. m.ResetConsumeToken()
  33460. return nil
  33461. case usagestatistichour.FieldActiveUser:
  33462. m.ResetActiveUser()
  33463. return nil
  33464. case usagestatistichour.FieldNewUser:
  33465. m.ResetNewUser()
  33466. return nil
  33467. case usagestatistichour.FieldLabelDist:
  33468. m.ResetLabelDist()
  33469. return nil
  33470. }
  33471. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33472. }
  33473. // AddedEdges returns all edge names that were set/added in this mutation.
  33474. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  33475. edges := make([]string, 0, 0)
  33476. return edges
  33477. }
  33478. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33479. // name in this mutation.
  33480. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  33481. return nil
  33482. }
  33483. // RemovedEdges returns all edge names that were removed in this mutation.
  33484. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  33485. edges := make([]string, 0, 0)
  33486. return edges
  33487. }
  33488. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33489. // the given name in this mutation.
  33490. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  33491. return nil
  33492. }
  33493. // ClearedEdges returns all edge names that were cleared in this mutation.
  33494. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  33495. edges := make([]string, 0, 0)
  33496. return edges
  33497. }
  33498. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33499. // was cleared in this mutation.
  33500. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  33501. return false
  33502. }
  33503. // ClearEdge clears the value of the edge with the given name. It returns an error
  33504. // if that edge is not defined in the schema.
  33505. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  33506. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  33507. }
  33508. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33509. // It returns an error if the edge is not defined in the schema.
  33510. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  33511. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  33512. }
  33513. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  33514. type UsageStatisticMonthMutation struct {
  33515. config
  33516. op Op
  33517. typ string
  33518. id *uint64
  33519. created_at *time.Time
  33520. updated_at *time.Time
  33521. status *uint8
  33522. addstatus *int8
  33523. deleted_at *time.Time
  33524. addtime *uint64
  33525. addaddtime *int64
  33526. _type *int
  33527. add_type *int
  33528. bot_id *string
  33529. organization_id *uint64
  33530. addorganization_id *int64
  33531. ai_response *uint64
  33532. addai_response *int64
  33533. sop_run *uint64
  33534. addsop_run *int64
  33535. total_friend *uint64
  33536. addtotal_friend *int64
  33537. total_group *uint64
  33538. addtotal_group *int64
  33539. account_balance *uint64
  33540. addaccount_balance *int64
  33541. consume_token *uint64
  33542. addconsume_token *int64
  33543. active_user *uint64
  33544. addactive_user *int64
  33545. new_user *int64
  33546. addnew_user *int64
  33547. label_dist *[]custom_types.LabelDist
  33548. appendlabel_dist []custom_types.LabelDist
  33549. clearedFields map[string]struct{}
  33550. done bool
  33551. oldValue func(context.Context) (*UsageStatisticMonth, error)
  33552. predicates []predicate.UsageStatisticMonth
  33553. }
  33554. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  33555. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  33556. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  33557. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  33558. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  33559. m := &UsageStatisticMonthMutation{
  33560. config: c,
  33561. op: op,
  33562. typ: TypeUsageStatisticMonth,
  33563. clearedFields: make(map[string]struct{}),
  33564. }
  33565. for _, opt := range opts {
  33566. opt(m)
  33567. }
  33568. return m
  33569. }
  33570. // withUsageStatisticMonthID sets the ID field of the mutation.
  33571. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  33572. return func(m *UsageStatisticMonthMutation) {
  33573. var (
  33574. err error
  33575. once sync.Once
  33576. value *UsageStatisticMonth
  33577. )
  33578. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  33579. once.Do(func() {
  33580. if m.done {
  33581. err = errors.New("querying old values post mutation is not allowed")
  33582. } else {
  33583. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  33584. }
  33585. })
  33586. return value, err
  33587. }
  33588. m.id = &id
  33589. }
  33590. }
  33591. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  33592. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  33593. return func(m *UsageStatisticMonthMutation) {
  33594. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  33595. return node, nil
  33596. }
  33597. m.id = &node.ID
  33598. }
  33599. }
  33600. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33601. // executed in a transaction (ent.Tx), a transactional client is returned.
  33602. func (m UsageStatisticMonthMutation) Client() *Client {
  33603. client := &Client{config: m.config}
  33604. client.init()
  33605. return client
  33606. }
  33607. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33608. // it returns an error otherwise.
  33609. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  33610. if _, ok := m.driver.(*txDriver); !ok {
  33611. return nil, errors.New("ent: mutation is not running in a transaction")
  33612. }
  33613. tx := &Tx{config: m.config}
  33614. tx.init()
  33615. return tx, nil
  33616. }
  33617. // SetID sets the value of the id field. Note that this
  33618. // operation is only accepted on creation of UsageStatisticMonth entities.
  33619. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  33620. m.id = &id
  33621. }
  33622. // ID returns the ID value in the mutation. Note that the ID is only available
  33623. // if it was provided to the builder or after it was returned from the database.
  33624. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  33625. if m.id == nil {
  33626. return
  33627. }
  33628. return *m.id, true
  33629. }
  33630. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33631. // That means, if the mutation is applied within a transaction with an isolation level such
  33632. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33633. // or updated by the mutation.
  33634. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  33635. switch {
  33636. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33637. id, exists := m.ID()
  33638. if exists {
  33639. return []uint64{id}, nil
  33640. }
  33641. fallthrough
  33642. case m.op.Is(OpUpdate | OpDelete):
  33643. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  33644. default:
  33645. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33646. }
  33647. }
  33648. // SetCreatedAt sets the "created_at" field.
  33649. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  33650. m.created_at = &t
  33651. }
  33652. // CreatedAt returns the value of the "created_at" field in the mutation.
  33653. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  33654. v := m.created_at
  33655. if v == nil {
  33656. return
  33657. }
  33658. return *v, true
  33659. }
  33660. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  33661. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33663. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33664. if !m.op.Is(OpUpdateOne) {
  33665. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33666. }
  33667. if m.id == nil || m.oldValue == nil {
  33668. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33669. }
  33670. oldValue, err := m.oldValue(ctx)
  33671. if err != nil {
  33672. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33673. }
  33674. return oldValue.CreatedAt, nil
  33675. }
  33676. // ResetCreatedAt resets all changes to the "created_at" field.
  33677. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  33678. m.created_at = nil
  33679. }
  33680. // SetUpdatedAt sets the "updated_at" field.
  33681. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  33682. m.updated_at = &t
  33683. }
  33684. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33685. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  33686. v := m.updated_at
  33687. if v == nil {
  33688. return
  33689. }
  33690. return *v, true
  33691. }
  33692. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  33693. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33695. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33696. if !m.op.Is(OpUpdateOne) {
  33697. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33698. }
  33699. if m.id == nil || m.oldValue == nil {
  33700. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33701. }
  33702. oldValue, err := m.oldValue(ctx)
  33703. if err != nil {
  33704. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33705. }
  33706. return oldValue.UpdatedAt, nil
  33707. }
  33708. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33709. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  33710. m.updated_at = nil
  33711. }
  33712. // SetStatus sets the "status" field.
  33713. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  33714. m.status = &u
  33715. m.addstatus = nil
  33716. }
  33717. // Status returns the value of the "status" field in the mutation.
  33718. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  33719. v := m.status
  33720. if v == nil {
  33721. return
  33722. }
  33723. return *v, true
  33724. }
  33725. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  33726. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33728. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33729. if !m.op.Is(OpUpdateOne) {
  33730. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33731. }
  33732. if m.id == nil || m.oldValue == nil {
  33733. return v, errors.New("OldStatus requires an ID field in the mutation")
  33734. }
  33735. oldValue, err := m.oldValue(ctx)
  33736. if err != nil {
  33737. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33738. }
  33739. return oldValue.Status, nil
  33740. }
  33741. // AddStatus adds u to the "status" field.
  33742. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  33743. if m.addstatus != nil {
  33744. *m.addstatus += u
  33745. } else {
  33746. m.addstatus = &u
  33747. }
  33748. }
  33749. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33750. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  33751. v := m.addstatus
  33752. if v == nil {
  33753. return
  33754. }
  33755. return *v, true
  33756. }
  33757. // ClearStatus clears the value of the "status" field.
  33758. func (m *UsageStatisticMonthMutation) ClearStatus() {
  33759. m.status = nil
  33760. m.addstatus = nil
  33761. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  33762. }
  33763. // StatusCleared returns if the "status" field was cleared in this mutation.
  33764. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  33765. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  33766. return ok
  33767. }
  33768. // ResetStatus resets all changes to the "status" field.
  33769. func (m *UsageStatisticMonthMutation) ResetStatus() {
  33770. m.status = nil
  33771. m.addstatus = nil
  33772. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  33773. }
  33774. // SetDeletedAt sets the "deleted_at" field.
  33775. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  33776. m.deleted_at = &t
  33777. }
  33778. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33779. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  33780. v := m.deleted_at
  33781. if v == nil {
  33782. return
  33783. }
  33784. return *v, true
  33785. }
  33786. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  33787. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33789. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33790. if !m.op.Is(OpUpdateOne) {
  33791. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33792. }
  33793. if m.id == nil || m.oldValue == nil {
  33794. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33795. }
  33796. oldValue, err := m.oldValue(ctx)
  33797. if err != nil {
  33798. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33799. }
  33800. return oldValue.DeletedAt, nil
  33801. }
  33802. // ClearDeletedAt clears the value of the "deleted_at" field.
  33803. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  33804. m.deleted_at = nil
  33805. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  33806. }
  33807. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33808. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  33809. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  33810. return ok
  33811. }
  33812. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33813. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  33814. m.deleted_at = nil
  33815. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  33816. }
  33817. // SetAddtime sets the "addtime" field.
  33818. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  33819. m.addtime = &u
  33820. m.addaddtime = nil
  33821. }
  33822. // Addtime returns the value of the "addtime" field in the mutation.
  33823. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  33824. v := m.addtime
  33825. if v == nil {
  33826. return
  33827. }
  33828. return *v, true
  33829. }
  33830. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  33831. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33833. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  33834. if !m.op.Is(OpUpdateOne) {
  33835. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  33836. }
  33837. if m.id == nil || m.oldValue == nil {
  33838. return v, errors.New("OldAddtime requires an ID field in the mutation")
  33839. }
  33840. oldValue, err := m.oldValue(ctx)
  33841. if err != nil {
  33842. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  33843. }
  33844. return oldValue.Addtime, nil
  33845. }
  33846. // AddAddtime adds u to the "addtime" field.
  33847. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  33848. if m.addaddtime != nil {
  33849. *m.addaddtime += u
  33850. } else {
  33851. m.addaddtime = &u
  33852. }
  33853. }
  33854. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  33855. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  33856. v := m.addaddtime
  33857. if v == nil {
  33858. return
  33859. }
  33860. return *v, true
  33861. }
  33862. // ResetAddtime resets all changes to the "addtime" field.
  33863. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  33864. m.addtime = nil
  33865. m.addaddtime = nil
  33866. }
  33867. // SetType sets the "type" field.
  33868. func (m *UsageStatisticMonthMutation) SetType(i int) {
  33869. m._type = &i
  33870. m.add_type = nil
  33871. }
  33872. // GetType returns the value of the "type" field in the mutation.
  33873. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  33874. v := m._type
  33875. if v == nil {
  33876. return
  33877. }
  33878. return *v, true
  33879. }
  33880. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  33881. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33883. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  33884. if !m.op.Is(OpUpdateOne) {
  33885. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33886. }
  33887. if m.id == nil || m.oldValue == nil {
  33888. return v, errors.New("OldType requires an ID field in the mutation")
  33889. }
  33890. oldValue, err := m.oldValue(ctx)
  33891. if err != nil {
  33892. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33893. }
  33894. return oldValue.Type, nil
  33895. }
  33896. // AddType adds i to the "type" field.
  33897. func (m *UsageStatisticMonthMutation) AddType(i int) {
  33898. if m.add_type != nil {
  33899. *m.add_type += i
  33900. } else {
  33901. m.add_type = &i
  33902. }
  33903. }
  33904. // AddedType returns the value that was added to the "type" field in this mutation.
  33905. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  33906. v := m.add_type
  33907. if v == nil {
  33908. return
  33909. }
  33910. return *v, true
  33911. }
  33912. // ResetType resets all changes to the "type" field.
  33913. func (m *UsageStatisticMonthMutation) ResetType() {
  33914. m._type = nil
  33915. m.add_type = nil
  33916. }
  33917. // SetBotID sets the "bot_id" field.
  33918. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  33919. m.bot_id = &s
  33920. }
  33921. // BotID returns the value of the "bot_id" field in the mutation.
  33922. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  33923. v := m.bot_id
  33924. if v == nil {
  33925. return
  33926. }
  33927. return *v, true
  33928. }
  33929. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  33930. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33932. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  33933. if !m.op.Is(OpUpdateOne) {
  33934. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33935. }
  33936. if m.id == nil || m.oldValue == nil {
  33937. return v, errors.New("OldBotID requires an ID field in the mutation")
  33938. }
  33939. oldValue, err := m.oldValue(ctx)
  33940. if err != nil {
  33941. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33942. }
  33943. return oldValue.BotID, nil
  33944. }
  33945. // ClearBotID clears the value of the "bot_id" field.
  33946. func (m *UsageStatisticMonthMutation) ClearBotID() {
  33947. m.bot_id = nil
  33948. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  33949. }
  33950. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  33951. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  33952. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  33953. return ok
  33954. }
  33955. // ResetBotID resets all changes to the "bot_id" field.
  33956. func (m *UsageStatisticMonthMutation) ResetBotID() {
  33957. m.bot_id = nil
  33958. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  33959. }
  33960. // SetOrganizationID sets the "organization_id" field.
  33961. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  33962. m.organization_id = &u
  33963. m.addorganization_id = nil
  33964. }
  33965. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33966. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  33967. v := m.organization_id
  33968. if v == nil {
  33969. return
  33970. }
  33971. return *v, true
  33972. }
  33973. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  33974. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33976. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33977. if !m.op.Is(OpUpdateOne) {
  33978. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33979. }
  33980. if m.id == nil || m.oldValue == nil {
  33981. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33982. }
  33983. oldValue, err := m.oldValue(ctx)
  33984. if err != nil {
  33985. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33986. }
  33987. return oldValue.OrganizationID, nil
  33988. }
  33989. // AddOrganizationID adds u to the "organization_id" field.
  33990. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  33991. if m.addorganization_id != nil {
  33992. *m.addorganization_id += u
  33993. } else {
  33994. m.addorganization_id = &u
  33995. }
  33996. }
  33997. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33998. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  33999. v := m.addorganization_id
  34000. if v == nil {
  34001. return
  34002. }
  34003. return *v, true
  34004. }
  34005. // ClearOrganizationID clears the value of the "organization_id" field.
  34006. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  34007. m.organization_id = nil
  34008. m.addorganization_id = nil
  34009. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  34010. }
  34011. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34012. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  34013. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  34014. return ok
  34015. }
  34016. // ResetOrganizationID resets all changes to the "organization_id" field.
  34017. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  34018. m.organization_id = nil
  34019. m.addorganization_id = nil
  34020. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  34021. }
  34022. // SetAiResponse sets the "ai_response" field.
  34023. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  34024. m.ai_response = &u
  34025. m.addai_response = nil
  34026. }
  34027. // AiResponse returns the value of the "ai_response" field in the mutation.
  34028. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  34029. v := m.ai_response
  34030. if v == nil {
  34031. return
  34032. }
  34033. return *v, true
  34034. }
  34035. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  34036. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34038. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  34039. if !m.op.Is(OpUpdateOne) {
  34040. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  34041. }
  34042. if m.id == nil || m.oldValue == nil {
  34043. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  34044. }
  34045. oldValue, err := m.oldValue(ctx)
  34046. if err != nil {
  34047. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  34048. }
  34049. return oldValue.AiResponse, nil
  34050. }
  34051. // AddAiResponse adds u to the "ai_response" field.
  34052. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  34053. if m.addai_response != nil {
  34054. *m.addai_response += u
  34055. } else {
  34056. m.addai_response = &u
  34057. }
  34058. }
  34059. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  34060. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  34061. v := m.addai_response
  34062. if v == nil {
  34063. return
  34064. }
  34065. return *v, true
  34066. }
  34067. // ResetAiResponse resets all changes to the "ai_response" field.
  34068. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  34069. m.ai_response = nil
  34070. m.addai_response = nil
  34071. }
  34072. // SetSopRun sets the "sop_run" field.
  34073. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  34074. m.sop_run = &u
  34075. m.addsop_run = nil
  34076. }
  34077. // SopRun returns the value of the "sop_run" field in the mutation.
  34078. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  34079. v := m.sop_run
  34080. if v == nil {
  34081. return
  34082. }
  34083. return *v, true
  34084. }
  34085. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  34086. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34088. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34089. if !m.op.Is(OpUpdateOne) {
  34090. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34091. }
  34092. if m.id == nil || m.oldValue == nil {
  34093. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34094. }
  34095. oldValue, err := m.oldValue(ctx)
  34096. if err != nil {
  34097. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34098. }
  34099. return oldValue.SopRun, nil
  34100. }
  34101. // AddSopRun adds u to the "sop_run" field.
  34102. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  34103. if m.addsop_run != nil {
  34104. *m.addsop_run += u
  34105. } else {
  34106. m.addsop_run = &u
  34107. }
  34108. }
  34109. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34110. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  34111. v := m.addsop_run
  34112. if v == nil {
  34113. return
  34114. }
  34115. return *v, true
  34116. }
  34117. // ResetSopRun resets all changes to the "sop_run" field.
  34118. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  34119. m.sop_run = nil
  34120. m.addsop_run = nil
  34121. }
  34122. // SetTotalFriend sets the "total_friend" field.
  34123. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  34124. m.total_friend = &u
  34125. m.addtotal_friend = nil
  34126. }
  34127. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34128. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  34129. v := m.total_friend
  34130. if v == nil {
  34131. return
  34132. }
  34133. return *v, true
  34134. }
  34135. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  34136. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34138. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34139. if !m.op.Is(OpUpdateOne) {
  34140. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34141. }
  34142. if m.id == nil || m.oldValue == nil {
  34143. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34144. }
  34145. oldValue, err := m.oldValue(ctx)
  34146. if err != nil {
  34147. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34148. }
  34149. return oldValue.TotalFriend, nil
  34150. }
  34151. // AddTotalFriend adds u to the "total_friend" field.
  34152. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  34153. if m.addtotal_friend != nil {
  34154. *m.addtotal_friend += u
  34155. } else {
  34156. m.addtotal_friend = &u
  34157. }
  34158. }
  34159. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34160. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  34161. v := m.addtotal_friend
  34162. if v == nil {
  34163. return
  34164. }
  34165. return *v, true
  34166. }
  34167. // ResetTotalFriend resets all changes to the "total_friend" field.
  34168. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  34169. m.total_friend = nil
  34170. m.addtotal_friend = nil
  34171. }
  34172. // SetTotalGroup sets the "total_group" field.
  34173. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  34174. m.total_group = &u
  34175. m.addtotal_group = nil
  34176. }
  34177. // TotalGroup returns the value of the "total_group" field in the mutation.
  34178. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  34179. v := m.total_group
  34180. if v == nil {
  34181. return
  34182. }
  34183. return *v, true
  34184. }
  34185. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  34186. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34188. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34189. if !m.op.Is(OpUpdateOne) {
  34190. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34191. }
  34192. if m.id == nil || m.oldValue == nil {
  34193. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34194. }
  34195. oldValue, err := m.oldValue(ctx)
  34196. if err != nil {
  34197. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34198. }
  34199. return oldValue.TotalGroup, nil
  34200. }
  34201. // AddTotalGroup adds u to the "total_group" field.
  34202. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  34203. if m.addtotal_group != nil {
  34204. *m.addtotal_group += u
  34205. } else {
  34206. m.addtotal_group = &u
  34207. }
  34208. }
  34209. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34210. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  34211. v := m.addtotal_group
  34212. if v == nil {
  34213. return
  34214. }
  34215. return *v, true
  34216. }
  34217. // ResetTotalGroup resets all changes to the "total_group" field.
  34218. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  34219. m.total_group = nil
  34220. m.addtotal_group = nil
  34221. }
  34222. // SetAccountBalance sets the "account_balance" field.
  34223. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  34224. m.account_balance = &u
  34225. m.addaccount_balance = nil
  34226. }
  34227. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34228. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  34229. v := m.account_balance
  34230. if v == nil {
  34231. return
  34232. }
  34233. return *v, true
  34234. }
  34235. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  34236. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34238. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34239. if !m.op.Is(OpUpdateOne) {
  34240. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34241. }
  34242. if m.id == nil || m.oldValue == nil {
  34243. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34244. }
  34245. oldValue, err := m.oldValue(ctx)
  34246. if err != nil {
  34247. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34248. }
  34249. return oldValue.AccountBalance, nil
  34250. }
  34251. // AddAccountBalance adds u to the "account_balance" field.
  34252. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  34253. if m.addaccount_balance != nil {
  34254. *m.addaccount_balance += u
  34255. } else {
  34256. m.addaccount_balance = &u
  34257. }
  34258. }
  34259. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34260. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  34261. v := m.addaccount_balance
  34262. if v == nil {
  34263. return
  34264. }
  34265. return *v, true
  34266. }
  34267. // ResetAccountBalance resets all changes to the "account_balance" field.
  34268. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  34269. m.account_balance = nil
  34270. m.addaccount_balance = nil
  34271. }
  34272. // SetConsumeToken sets the "consume_token" field.
  34273. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  34274. m.consume_token = &u
  34275. m.addconsume_token = nil
  34276. }
  34277. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34278. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  34279. v := m.consume_token
  34280. if v == nil {
  34281. return
  34282. }
  34283. return *v, true
  34284. }
  34285. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  34286. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34288. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34289. if !m.op.Is(OpUpdateOne) {
  34290. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34291. }
  34292. if m.id == nil || m.oldValue == nil {
  34293. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34294. }
  34295. oldValue, err := m.oldValue(ctx)
  34296. if err != nil {
  34297. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34298. }
  34299. return oldValue.ConsumeToken, nil
  34300. }
  34301. // AddConsumeToken adds u to the "consume_token" field.
  34302. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  34303. if m.addconsume_token != nil {
  34304. *m.addconsume_token += u
  34305. } else {
  34306. m.addconsume_token = &u
  34307. }
  34308. }
  34309. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34310. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  34311. v := m.addconsume_token
  34312. if v == nil {
  34313. return
  34314. }
  34315. return *v, true
  34316. }
  34317. // ResetConsumeToken resets all changes to the "consume_token" field.
  34318. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  34319. m.consume_token = nil
  34320. m.addconsume_token = nil
  34321. }
  34322. // SetActiveUser sets the "active_user" field.
  34323. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  34324. m.active_user = &u
  34325. m.addactive_user = nil
  34326. }
  34327. // ActiveUser returns the value of the "active_user" field in the mutation.
  34328. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  34329. v := m.active_user
  34330. if v == nil {
  34331. return
  34332. }
  34333. return *v, true
  34334. }
  34335. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  34336. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34338. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34339. if !m.op.Is(OpUpdateOne) {
  34340. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34341. }
  34342. if m.id == nil || m.oldValue == nil {
  34343. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34344. }
  34345. oldValue, err := m.oldValue(ctx)
  34346. if err != nil {
  34347. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34348. }
  34349. return oldValue.ActiveUser, nil
  34350. }
  34351. // AddActiveUser adds u to the "active_user" field.
  34352. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  34353. if m.addactive_user != nil {
  34354. *m.addactive_user += u
  34355. } else {
  34356. m.addactive_user = &u
  34357. }
  34358. }
  34359. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34360. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  34361. v := m.addactive_user
  34362. if v == nil {
  34363. return
  34364. }
  34365. return *v, true
  34366. }
  34367. // ResetActiveUser resets all changes to the "active_user" field.
  34368. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  34369. m.active_user = nil
  34370. m.addactive_user = nil
  34371. }
  34372. // SetNewUser sets the "new_user" field.
  34373. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  34374. m.new_user = &i
  34375. m.addnew_user = nil
  34376. }
  34377. // NewUser returns the value of the "new_user" field in the mutation.
  34378. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  34379. v := m.new_user
  34380. if v == nil {
  34381. return
  34382. }
  34383. return *v, true
  34384. }
  34385. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  34386. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34388. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34389. if !m.op.Is(OpUpdateOne) {
  34390. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34391. }
  34392. if m.id == nil || m.oldValue == nil {
  34393. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34394. }
  34395. oldValue, err := m.oldValue(ctx)
  34396. if err != nil {
  34397. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34398. }
  34399. return oldValue.NewUser, nil
  34400. }
  34401. // AddNewUser adds i to the "new_user" field.
  34402. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  34403. if m.addnew_user != nil {
  34404. *m.addnew_user += i
  34405. } else {
  34406. m.addnew_user = &i
  34407. }
  34408. }
  34409. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34410. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  34411. v := m.addnew_user
  34412. if v == nil {
  34413. return
  34414. }
  34415. return *v, true
  34416. }
  34417. // ResetNewUser resets all changes to the "new_user" field.
  34418. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  34419. m.new_user = nil
  34420. m.addnew_user = nil
  34421. }
  34422. // SetLabelDist sets the "label_dist" field.
  34423. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34424. m.label_dist = &ctd
  34425. m.appendlabel_dist = nil
  34426. }
  34427. // LabelDist returns the value of the "label_dist" field in the mutation.
  34428. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34429. v := m.label_dist
  34430. if v == nil {
  34431. return
  34432. }
  34433. return *v, true
  34434. }
  34435. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  34436. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34438. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34439. if !m.op.Is(OpUpdateOne) {
  34440. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34441. }
  34442. if m.id == nil || m.oldValue == nil {
  34443. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34444. }
  34445. oldValue, err := m.oldValue(ctx)
  34446. if err != nil {
  34447. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34448. }
  34449. return oldValue.LabelDist, nil
  34450. }
  34451. // AppendLabelDist adds ctd to the "label_dist" field.
  34452. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34453. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34454. }
  34455. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34456. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34457. if len(m.appendlabel_dist) == 0 {
  34458. return nil, false
  34459. }
  34460. return m.appendlabel_dist, true
  34461. }
  34462. // ResetLabelDist resets all changes to the "label_dist" field.
  34463. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  34464. m.label_dist = nil
  34465. m.appendlabel_dist = nil
  34466. }
  34467. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  34468. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  34469. m.predicates = append(m.predicates, ps...)
  34470. }
  34471. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  34472. // users can use type-assertion to append predicates that do not depend on any generated package.
  34473. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  34474. p := make([]predicate.UsageStatisticMonth, len(ps))
  34475. for i := range ps {
  34476. p[i] = ps[i]
  34477. }
  34478. m.Where(p...)
  34479. }
  34480. // Op returns the operation name.
  34481. func (m *UsageStatisticMonthMutation) Op() Op {
  34482. return m.op
  34483. }
  34484. // SetOp allows setting the mutation operation.
  34485. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  34486. m.op = op
  34487. }
  34488. // Type returns the node type of this mutation (UsageStatisticMonth).
  34489. func (m *UsageStatisticMonthMutation) Type() string {
  34490. return m.typ
  34491. }
  34492. // Fields returns all fields that were changed during this mutation. Note that in
  34493. // order to get all numeric fields that were incremented/decremented, call
  34494. // AddedFields().
  34495. func (m *UsageStatisticMonthMutation) Fields() []string {
  34496. fields := make([]string, 0, 17)
  34497. if m.created_at != nil {
  34498. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  34499. }
  34500. if m.updated_at != nil {
  34501. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  34502. }
  34503. if m.status != nil {
  34504. fields = append(fields, usagestatisticmonth.FieldStatus)
  34505. }
  34506. if m.deleted_at != nil {
  34507. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34508. }
  34509. if m.addtime != nil {
  34510. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34511. }
  34512. if m._type != nil {
  34513. fields = append(fields, usagestatisticmonth.FieldType)
  34514. }
  34515. if m.bot_id != nil {
  34516. fields = append(fields, usagestatisticmonth.FieldBotID)
  34517. }
  34518. if m.organization_id != nil {
  34519. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34520. }
  34521. if m.ai_response != nil {
  34522. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34523. }
  34524. if m.sop_run != nil {
  34525. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34526. }
  34527. if m.total_friend != nil {
  34528. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34529. }
  34530. if m.total_group != nil {
  34531. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34532. }
  34533. if m.account_balance != nil {
  34534. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34535. }
  34536. if m.consume_token != nil {
  34537. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34538. }
  34539. if m.active_user != nil {
  34540. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34541. }
  34542. if m.new_user != nil {
  34543. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34544. }
  34545. if m.label_dist != nil {
  34546. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  34547. }
  34548. return fields
  34549. }
  34550. // Field returns the value of a field with the given name. The second boolean
  34551. // return value indicates that this field was not set, or was not defined in the
  34552. // schema.
  34553. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  34554. switch name {
  34555. case usagestatisticmonth.FieldCreatedAt:
  34556. return m.CreatedAt()
  34557. case usagestatisticmonth.FieldUpdatedAt:
  34558. return m.UpdatedAt()
  34559. case usagestatisticmonth.FieldStatus:
  34560. return m.Status()
  34561. case usagestatisticmonth.FieldDeletedAt:
  34562. return m.DeletedAt()
  34563. case usagestatisticmonth.FieldAddtime:
  34564. return m.Addtime()
  34565. case usagestatisticmonth.FieldType:
  34566. return m.GetType()
  34567. case usagestatisticmonth.FieldBotID:
  34568. return m.BotID()
  34569. case usagestatisticmonth.FieldOrganizationID:
  34570. return m.OrganizationID()
  34571. case usagestatisticmonth.FieldAiResponse:
  34572. return m.AiResponse()
  34573. case usagestatisticmonth.FieldSopRun:
  34574. return m.SopRun()
  34575. case usagestatisticmonth.FieldTotalFriend:
  34576. return m.TotalFriend()
  34577. case usagestatisticmonth.FieldTotalGroup:
  34578. return m.TotalGroup()
  34579. case usagestatisticmonth.FieldAccountBalance:
  34580. return m.AccountBalance()
  34581. case usagestatisticmonth.FieldConsumeToken:
  34582. return m.ConsumeToken()
  34583. case usagestatisticmonth.FieldActiveUser:
  34584. return m.ActiveUser()
  34585. case usagestatisticmonth.FieldNewUser:
  34586. return m.NewUser()
  34587. case usagestatisticmonth.FieldLabelDist:
  34588. return m.LabelDist()
  34589. }
  34590. return nil, false
  34591. }
  34592. // OldField returns the old value of the field from the database. An error is
  34593. // returned if the mutation operation is not UpdateOne, or the query to the
  34594. // database failed.
  34595. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34596. switch name {
  34597. case usagestatisticmonth.FieldCreatedAt:
  34598. return m.OldCreatedAt(ctx)
  34599. case usagestatisticmonth.FieldUpdatedAt:
  34600. return m.OldUpdatedAt(ctx)
  34601. case usagestatisticmonth.FieldStatus:
  34602. return m.OldStatus(ctx)
  34603. case usagestatisticmonth.FieldDeletedAt:
  34604. return m.OldDeletedAt(ctx)
  34605. case usagestatisticmonth.FieldAddtime:
  34606. return m.OldAddtime(ctx)
  34607. case usagestatisticmonth.FieldType:
  34608. return m.OldType(ctx)
  34609. case usagestatisticmonth.FieldBotID:
  34610. return m.OldBotID(ctx)
  34611. case usagestatisticmonth.FieldOrganizationID:
  34612. return m.OldOrganizationID(ctx)
  34613. case usagestatisticmonth.FieldAiResponse:
  34614. return m.OldAiResponse(ctx)
  34615. case usagestatisticmonth.FieldSopRun:
  34616. return m.OldSopRun(ctx)
  34617. case usagestatisticmonth.FieldTotalFriend:
  34618. return m.OldTotalFriend(ctx)
  34619. case usagestatisticmonth.FieldTotalGroup:
  34620. return m.OldTotalGroup(ctx)
  34621. case usagestatisticmonth.FieldAccountBalance:
  34622. return m.OldAccountBalance(ctx)
  34623. case usagestatisticmonth.FieldConsumeToken:
  34624. return m.OldConsumeToken(ctx)
  34625. case usagestatisticmonth.FieldActiveUser:
  34626. return m.OldActiveUser(ctx)
  34627. case usagestatisticmonth.FieldNewUser:
  34628. return m.OldNewUser(ctx)
  34629. case usagestatisticmonth.FieldLabelDist:
  34630. return m.OldLabelDist(ctx)
  34631. }
  34632. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34633. }
  34634. // SetField sets the value of a field with the given name. It returns an error if
  34635. // the field is not defined in the schema, or if the type mismatched the field
  34636. // type.
  34637. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  34638. switch name {
  34639. case usagestatisticmonth.FieldCreatedAt:
  34640. v, ok := value.(time.Time)
  34641. if !ok {
  34642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34643. }
  34644. m.SetCreatedAt(v)
  34645. return nil
  34646. case usagestatisticmonth.FieldUpdatedAt:
  34647. v, ok := value.(time.Time)
  34648. if !ok {
  34649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34650. }
  34651. m.SetUpdatedAt(v)
  34652. return nil
  34653. case usagestatisticmonth.FieldStatus:
  34654. v, ok := value.(uint8)
  34655. if !ok {
  34656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34657. }
  34658. m.SetStatus(v)
  34659. return nil
  34660. case usagestatisticmonth.FieldDeletedAt:
  34661. v, ok := value.(time.Time)
  34662. if !ok {
  34663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34664. }
  34665. m.SetDeletedAt(v)
  34666. return nil
  34667. case usagestatisticmonth.FieldAddtime:
  34668. v, ok := value.(uint64)
  34669. if !ok {
  34670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34671. }
  34672. m.SetAddtime(v)
  34673. return nil
  34674. case usagestatisticmonth.FieldType:
  34675. v, ok := value.(int)
  34676. if !ok {
  34677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34678. }
  34679. m.SetType(v)
  34680. return nil
  34681. case usagestatisticmonth.FieldBotID:
  34682. v, ok := value.(string)
  34683. if !ok {
  34684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34685. }
  34686. m.SetBotID(v)
  34687. return nil
  34688. case usagestatisticmonth.FieldOrganizationID:
  34689. v, ok := value.(uint64)
  34690. if !ok {
  34691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34692. }
  34693. m.SetOrganizationID(v)
  34694. return nil
  34695. case usagestatisticmonth.FieldAiResponse:
  34696. v, ok := value.(uint64)
  34697. if !ok {
  34698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34699. }
  34700. m.SetAiResponse(v)
  34701. return nil
  34702. case usagestatisticmonth.FieldSopRun:
  34703. v, ok := value.(uint64)
  34704. if !ok {
  34705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34706. }
  34707. m.SetSopRun(v)
  34708. return nil
  34709. case usagestatisticmonth.FieldTotalFriend:
  34710. v, ok := value.(uint64)
  34711. if !ok {
  34712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34713. }
  34714. m.SetTotalFriend(v)
  34715. return nil
  34716. case usagestatisticmonth.FieldTotalGroup:
  34717. v, ok := value.(uint64)
  34718. if !ok {
  34719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34720. }
  34721. m.SetTotalGroup(v)
  34722. return nil
  34723. case usagestatisticmonth.FieldAccountBalance:
  34724. v, ok := value.(uint64)
  34725. if !ok {
  34726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34727. }
  34728. m.SetAccountBalance(v)
  34729. return nil
  34730. case usagestatisticmonth.FieldConsumeToken:
  34731. v, ok := value.(uint64)
  34732. if !ok {
  34733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34734. }
  34735. m.SetConsumeToken(v)
  34736. return nil
  34737. case usagestatisticmonth.FieldActiveUser:
  34738. v, ok := value.(uint64)
  34739. if !ok {
  34740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34741. }
  34742. m.SetActiveUser(v)
  34743. return nil
  34744. case usagestatisticmonth.FieldNewUser:
  34745. v, ok := value.(int64)
  34746. if !ok {
  34747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34748. }
  34749. m.SetNewUser(v)
  34750. return nil
  34751. case usagestatisticmonth.FieldLabelDist:
  34752. v, ok := value.([]custom_types.LabelDist)
  34753. if !ok {
  34754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34755. }
  34756. m.SetLabelDist(v)
  34757. return nil
  34758. }
  34759. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34760. }
  34761. // AddedFields returns all numeric fields that were incremented/decremented during
  34762. // this mutation.
  34763. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  34764. var fields []string
  34765. if m.addstatus != nil {
  34766. fields = append(fields, usagestatisticmonth.FieldStatus)
  34767. }
  34768. if m.addaddtime != nil {
  34769. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34770. }
  34771. if m.add_type != nil {
  34772. fields = append(fields, usagestatisticmonth.FieldType)
  34773. }
  34774. if m.addorganization_id != nil {
  34775. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34776. }
  34777. if m.addai_response != nil {
  34778. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34779. }
  34780. if m.addsop_run != nil {
  34781. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34782. }
  34783. if m.addtotal_friend != nil {
  34784. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34785. }
  34786. if m.addtotal_group != nil {
  34787. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34788. }
  34789. if m.addaccount_balance != nil {
  34790. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34791. }
  34792. if m.addconsume_token != nil {
  34793. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34794. }
  34795. if m.addactive_user != nil {
  34796. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34797. }
  34798. if m.addnew_user != nil {
  34799. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34800. }
  34801. return fields
  34802. }
  34803. // AddedField returns the numeric value that was incremented/decremented on a field
  34804. // with the given name. The second boolean return value indicates that this field
  34805. // was not set, or was not defined in the schema.
  34806. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  34807. switch name {
  34808. case usagestatisticmonth.FieldStatus:
  34809. return m.AddedStatus()
  34810. case usagestatisticmonth.FieldAddtime:
  34811. return m.AddedAddtime()
  34812. case usagestatisticmonth.FieldType:
  34813. return m.AddedType()
  34814. case usagestatisticmonth.FieldOrganizationID:
  34815. return m.AddedOrganizationID()
  34816. case usagestatisticmonth.FieldAiResponse:
  34817. return m.AddedAiResponse()
  34818. case usagestatisticmonth.FieldSopRun:
  34819. return m.AddedSopRun()
  34820. case usagestatisticmonth.FieldTotalFriend:
  34821. return m.AddedTotalFriend()
  34822. case usagestatisticmonth.FieldTotalGroup:
  34823. return m.AddedTotalGroup()
  34824. case usagestatisticmonth.FieldAccountBalance:
  34825. return m.AddedAccountBalance()
  34826. case usagestatisticmonth.FieldConsumeToken:
  34827. return m.AddedConsumeToken()
  34828. case usagestatisticmonth.FieldActiveUser:
  34829. return m.AddedActiveUser()
  34830. case usagestatisticmonth.FieldNewUser:
  34831. return m.AddedNewUser()
  34832. }
  34833. return nil, false
  34834. }
  34835. // AddField adds the value to the field with the given name. It returns an error if
  34836. // the field is not defined in the schema, or if the type mismatched the field
  34837. // type.
  34838. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  34839. switch name {
  34840. case usagestatisticmonth.FieldStatus:
  34841. v, ok := value.(int8)
  34842. if !ok {
  34843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34844. }
  34845. m.AddStatus(v)
  34846. return nil
  34847. case usagestatisticmonth.FieldAddtime:
  34848. v, ok := value.(int64)
  34849. if !ok {
  34850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34851. }
  34852. m.AddAddtime(v)
  34853. return nil
  34854. case usagestatisticmonth.FieldType:
  34855. v, ok := value.(int)
  34856. if !ok {
  34857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34858. }
  34859. m.AddType(v)
  34860. return nil
  34861. case usagestatisticmonth.FieldOrganizationID:
  34862. v, ok := value.(int64)
  34863. if !ok {
  34864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34865. }
  34866. m.AddOrganizationID(v)
  34867. return nil
  34868. case usagestatisticmonth.FieldAiResponse:
  34869. v, ok := value.(int64)
  34870. if !ok {
  34871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34872. }
  34873. m.AddAiResponse(v)
  34874. return nil
  34875. case usagestatisticmonth.FieldSopRun:
  34876. v, ok := value.(int64)
  34877. if !ok {
  34878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34879. }
  34880. m.AddSopRun(v)
  34881. return nil
  34882. case usagestatisticmonth.FieldTotalFriend:
  34883. v, ok := value.(int64)
  34884. if !ok {
  34885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34886. }
  34887. m.AddTotalFriend(v)
  34888. return nil
  34889. case usagestatisticmonth.FieldTotalGroup:
  34890. v, ok := value.(int64)
  34891. if !ok {
  34892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34893. }
  34894. m.AddTotalGroup(v)
  34895. return nil
  34896. case usagestatisticmonth.FieldAccountBalance:
  34897. v, ok := value.(int64)
  34898. if !ok {
  34899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34900. }
  34901. m.AddAccountBalance(v)
  34902. return nil
  34903. case usagestatisticmonth.FieldConsumeToken:
  34904. v, ok := value.(int64)
  34905. if !ok {
  34906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34907. }
  34908. m.AddConsumeToken(v)
  34909. return nil
  34910. case usagestatisticmonth.FieldActiveUser:
  34911. v, ok := value.(int64)
  34912. if !ok {
  34913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34914. }
  34915. m.AddActiveUser(v)
  34916. return nil
  34917. case usagestatisticmonth.FieldNewUser:
  34918. v, ok := value.(int64)
  34919. if !ok {
  34920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34921. }
  34922. m.AddNewUser(v)
  34923. return nil
  34924. }
  34925. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  34926. }
  34927. // ClearedFields returns all nullable fields that were cleared during this
  34928. // mutation.
  34929. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  34930. var fields []string
  34931. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  34932. fields = append(fields, usagestatisticmonth.FieldStatus)
  34933. }
  34934. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  34935. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34936. }
  34937. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  34938. fields = append(fields, usagestatisticmonth.FieldBotID)
  34939. }
  34940. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  34941. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34942. }
  34943. return fields
  34944. }
  34945. // FieldCleared returns a boolean indicating if a field with the given name was
  34946. // cleared in this mutation.
  34947. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  34948. _, ok := m.clearedFields[name]
  34949. return ok
  34950. }
  34951. // ClearField clears the value of the field with the given name. It returns an
  34952. // error if the field is not defined in the schema.
  34953. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  34954. switch name {
  34955. case usagestatisticmonth.FieldStatus:
  34956. m.ClearStatus()
  34957. return nil
  34958. case usagestatisticmonth.FieldDeletedAt:
  34959. m.ClearDeletedAt()
  34960. return nil
  34961. case usagestatisticmonth.FieldBotID:
  34962. m.ClearBotID()
  34963. return nil
  34964. case usagestatisticmonth.FieldOrganizationID:
  34965. m.ClearOrganizationID()
  34966. return nil
  34967. }
  34968. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  34969. }
  34970. // ResetField resets all changes in the mutation for the field with the given name.
  34971. // It returns an error if the field is not defined in the schema.
  34972. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  34973. switch name {
  34974. case usagestatisticmonth.FieldCreatedAt:
  34975. m.ResetCreatedAt()
  34976. return nil
  34977. case usagestatisticmonth.FieldUpdatedAt:
  34978. m.ResetUpdatedAt()
  34979. return nil
  34980. case usagestatisticmonth.FieldStatus:
  34981. m.ResetStatus()
  34982. return nil
  34983. case usagestatisticmonth.FieldDeletedAt:
  34984. m.ResetDeletedAt()
  34985. return nil
  34986. case usagestatisticmonth.FieldAddtime:
  34987. m.ResetAddtime()
  34988. return nil
  34989. case usagestatisticmonth.FieldType:
  34990. m.ResetType()
  34991. return nil
  34992. case usagestatisticmonth.FieldBotID:
  34993. m.ResetBotID()
  34994. return nil
  34995. case usagestatisticmonth.FieldOrganizationID:
  34996. m.ResetOrganizationID()
  34997. return nil
  34998. case usagestatisticmonth.FieldAiResponse:
  34999. m.ResetAiResponse()
  35000. return nil
  35001. case usagestatisticmonth.FieldSopRun:
  35002. m.ResetSopRun()
  35003. return nil
  35004. case usagestatisticmonth.FieldTotalFriend:
  35005. m.ResetTotalFriend()
  35006. return nil
  35007. case usagestatisticmonth.FieldTotalGroup:
  35008. m.ResetTotalGroup()
  35009. return nil
  35010. case usagestatisticmonth.FieldAccountBalance:
  35011. m.ResetAccountBalance()
  35012. return nil
  35013. case usagestatisticmonth.FieldConsumeToken:
  35014. m.ResetConsumeToken()
  35015. return nil
  35016. case usagestatisticmonth.FieldActiveUser:
  35017. m.ResetActiveUser()
  35018. return nil
  35019. case usagestatisticmonth.FieldNewUser:
  35020. m.ResetNewUser()
  35021. return nil
  35022. case usagestatisticmonth.FieldLabelDist:
  35023. m.ResetLabelDist()
  35024. return nil
  35025. }
  35026. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  35027. }
  35028. // AddedEdges returns all edge names that were set/added in this mutation.
  35029. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  35030. edges := make([]string, 0, 0)
  35031. return edges
  35032. }
  35033. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35034. // name in this mutation.
  35035. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  35036. return nil
  35037. }
  35038. // RemovedEdges returns all edge names that were removed in this mutation.
  35039. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  35040. edges := make([]string, 0, 0)
  35041. return edges
  35042. }
  35043. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35044. // the given name in this mutation.
  35045. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  35046. return nil
  35047. }
  35048. // ClearedEdges returns all edge names that were cleared in this mutation.
  35049. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  35050. edges := make([]string, 0, 0)
  35051. return edges
  35052. }
  35053. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35054. // was cleared in this mutation.
  35055. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  35056. return false
  35057. }
  35058. // ClearEdge clears the value of the edge with the given name. It returns an error
  35059. // if that edge is not defined in the schema.
  35060. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  35061. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  35062. }
  35063. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35064. // It returns an error if the edge is not defined in the schema.
  35065. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  35066. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  35067. }
  35068. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  35069. type UsageTotalMutation struct {
  35070. config
  35071. op Op
  35072. typ string
  35073. id *uint64
  35074. created_at *time.Time
  35075. updated_at *time.Time
  35076. status *uint8
  35077. addstatus *int8
  35078. _type *int
  35079. add_type *int
  35080. bot_id *string
  35081. total_tokens *uint64
  35082. addtotal_tokens *int64
  35083. start_index *uint64
  35084. addstart_index *int64
  35085. end_index *uint64
  35086. addend_index *int64
  35087. organization_id *uint64
  35088. addorganization_id *int64
  35089. clearedFields map[string]struct{}
  35090. done bool
  35091. oldValue func(context.Context) (*UsageTotal, error)
  35092. predicates []predicate.UsageTotal
  35093. }
  35094. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  35095. // usagetotalOption allows management of the mutation configuration using functional options.
  35096. type usagetotalOption func(*UsageTotalMutation)
  35097. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  35098. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  35099. m := &UsageTotalMutation{
  35100. config: c,
  35101. op: op,
  35102. typ: TypeUsageTotal,
  35103. clearedFields: make(map[string]struct{}),
  35104. }
  35105. for _, opt := range opts {
  35106. opt(m)
  35107. }
  35108. return m
  35109. }
  35110. // withUsageTotalID sets the ID field of the mutation.
  35111. func withUsageTotalID(id uint64) usagetotalOption {
  35112. return func(m *UsageTotalMutation) {
  35113. var (
  35114. err error
  35115. once sync.Once
  35116. value *UsageTotal
  35117. )
  35118. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  35119. once.Do(func() {
  35120. if m.done {
  35121. err = errors.New("querying old values post mutation is not allowed")
  35122. } else {
  35123. value, err = m.Client().UsageTotal.Get(ctx, id)
  35124. }
  35125. })
  35126. return value, err
  35127. }
  35128. m.id = &id
  35129. }
  35130. }
  35131. // withUsageTotal sets the old UsageTotal of the mutation.
  35132. func withUsageTotal(node *UsageTotal) usagetotalOption {
  35133. return func(m *UsageTotalMutation) {
  35134. m.oldValue = func(context.Context) (*UsageTotal, error) {
  35135. return node, nil
  35136. }
  35137. m.id = &node.ID
  35138. }
  35139. }
  35140. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35141. // executed in a transaction (ent.Tx), a transactional client is returned.
  35142. func (m UsageTotalMutation) Client() *Client {
  35143. client := &Client{config: m.config}
  35144. client.init()
  35145. return client
  35146. }
  35147. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35148. // it returns an error otherwise.
  35149. func (m UsageTotalMutation) Tx() (*Tx, error) {
  35150. if _, ok := m.driver.(*txDriver); !ok {
  35151. return nil, errors.New("ent: mutation is not running in a transaction")
  35152. }
  35153. tx := &Tx{config: m.config}
  35154. tx.init()
  35155. return tx, nil
  35156. }
  35157. // SetID sets the value of the id field. Note that this
  35158. // operation is only accepted on creation of UsageTotal entities.
  35159. func (m *UsageTotalMutation) SetID(id uint64) {
  35160. m.id = &id
  35161. }
  35162. // ID returns the ID value in the mutation. Note that the ID is only available
  35163. // if it was provided to the builder or after it was returned from the database.
  35164. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  35165. if m.id == nil {
  35166. return
  35167. }
  35168. return *m.id, true
  35169. }
  35170. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35171. // That means, if the mutation is applied within a transaction with an isolation level such
  35172. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35173. // or updated by the mutation.
  35174. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  35175. switch {
  35176. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35177. id, exists := m.ID()
  35178. if exists {
  35179. return []uint64{id}, nil
  35180. }
  35181. fallthrough
  35182. case m.op.Is(OpUpdate | OpDelete):
  35183. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  35184. default:
  35185. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35186. }
  35187. }
  35188. // SetCreatedAt sets the "created_at" field.
  35189. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  35190. m.created_at = &t
  35191. }
  35192. // CreatedAt returns the value of the "created_at" field in the mutation.
  35193. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  35194. v := m.created_at
  35195. if v == nil {
  35196. return
  35197. }
  35198. return *v, true
  35199. }
  35200. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  35201. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35203. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35204. if !m.op.Is(OpUpdateOne) {
  35205. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35206. }
  35207. if m.id == nil || m.oldValue == nil {
  35208. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35209. }
  35210. oldValue, err := m.oldValue(ctx)
  35211. if err != nil {
  35212. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35213. }
  35214. return oldValue.CreatedAt, nil
  35215. }
  35216. // ResetCreatedAt resets all changes to the "created_at" field.
  35217. func (m *UsageTotalMutation) ResetCreatedAt() {
  35218. m.created_at = nil
  35219. }
  35220. // SetUpdatedAt sets the "updated_at" field.
  35221. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  35222. m.updated_at = &t
  35223. }
  35224. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35225. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  35226. v := m.updated_at
  35227. if v == nil {
  35228. return
  35229. }
  35230. return *v, true
  35231. }
  35232. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  35233. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35235. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35236. if !m.op.Is(OpUpdateOne) {
  35237. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35238. }
  35239. if m.id == nil || m.oldValue == nil {
  35240. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35241. }
  35242. oldValue, err := m.oldValue(ctx)
  35243. if err != nil {
  35244. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35245. }
  35246. return oldValue.UpdatedAt, nil
  35247. }
  35248. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35249. func (m *UsageTotalMutation) ResetUpdatedAt() {
  35250. m.updated_at = nil
  35251. }
  35252. // SetStatus sets the "status" field.
  35253. func (m *UsageTotalMutation) SetStatus(u uint8) {
  35254. m.status = &u
  35255. m.addstatus = nil
  35256. }
  35257. // Status returns the value of the "status" field in the mutation.
  35258. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  35259. v := m.status
  35260. if v == nil {
  35261. return
  35262. }
  35263. return *v, true
  35264. }
  35265. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  35266. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35268. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35269. if !m.op.Is(OpUpdateOne) {
  35270. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35271. }
  35272. if m.id == nil || m.oldValue == nil {
  35273. return v, errors.New("OldStatus requires an ID field in the mutation")
  35274. }
  35275. oldValue, err := m.oldValue(ctx)
  35276. if err != nil {
  35277. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35278. }
  35279. return oldValue.Status, nil
  35280. }
  35281. // AddStatus adds u to the "status" field.
  35282. func (m *UsageTotalMutation) AddStatus(u int8) {
  35283. if m.addstatus != nil {
  35284. *m.addstatus += u
  35285. } else {
  35286. m.addstatus = &u
  35287. }
  35288. }
  35289. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35290. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  35291. v := m.addstatus
  35292. if v == nil {
  35293. return
  35294. }
  35295. return *v, true
  35296. }
  35297. // ClearStatus clears the value of the "status" field.
  35298. func (m *UsageTotalMutation) ClearStatus() {
  35299. m.status = nil
  35300. m.addstatus = nil
  35301. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  35302. }
  35303. // StatusCleared returns if the "status" field was cleared in this mutation.
  35304. func (m *UsageTotalMutation) StatusCleared() bool {
  35305. _, ok := m.clearedFields[usagetotal.FieldStatus]
  35306. return ok
  35307. }
  35308. // ResetStatus resets all changes to the "status" field.
  35309. func (m *UsageTotalMutation) ResetStatus() {
  35310. m.status = nil
  35311. m.addstatus = nil
  35312. delete(m.clearedFields, usagetotal.FieldStatus)
  35313. }
  35314. // SetType sets the "type" field.
  35315. func (m *UsageTotalMutation) SetType(i int) {
  35316. m._type = &i
  35317. m.add_type = nil
  35318. }
  35319. // GetType returns the value of the "type" field in the mutation.
  35320. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  35321. v := m._type
  35322. if v == nil {
  35323. return
  35324. }
  35325. return *v, true
  35326. }
  35327. // OldType returns the old "type" field's value of the UsageTotal entity.
  35328. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35330. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  35331. if !m.op.Is(OpUpdateOne) {
  35332. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35333. }
  35334. if m.id == nil || m.oldValue == nil {
  35335. return v, errors.New("OldType requires an ID field in the mutation")
  35336. }
  35337. oldValue, err := m.oldValue(ctx)
  35338. if err != nil {
  35339. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35340. }
  35341. return oldValue.Type, nil
  35342. }
  35343. // AddType adds i to the "type" field.
  35344. func (m *UsageTotalMutation) AddType(i int) {
  35345. if m.add_type != nil {
  35346. *m.add_type += i
  35347. } else {
  35348. m.add_type = &i
  35349. }
  35350. }
  35351. // AddedType returns the value that was added to the "type" field in this mutation.
  35352. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  35353. v := m.add_type
  35354. if v == nil {
  35355. return
  35356. }
  35357. return *v, true
  35358. }
  35359. // ClearType clears the value of the "type" field.
  35360. func (m *UsageTotalMutation) ClearType() {
  35361. m._type = nil
  35362. m.add_type = nil
  35363. m.clearedFields[usagetotal.FieldType] = struct{}{}
  35364. }
  35365. // TypeCleared returns if the "type" field was cleared in this mutation.
  35366. func (m *UsageTotalMutation) TypeCleared() bool {
  35367. _, ok := m.clearedFields[usagetotal.FieldType]
  35368. return ok
  35369. }
  35370. // ResetType resets all changes to the "type" field.
  35371. func (m *UsageTotalMutation) ResetType() {
  35372. m._type = nil
  35373. m.add_type = nil
  35374. delete(m.clearedFields, usagetotal.FieldType)
  35375. }
  35376. // SetBotID sets the "bot_id" field.
  35377. func (m *UsageTotalMutation) SetBotID(s string) {
  35378. m.bot_id = &s
  35379. }
  35380. // BotID returns the value of the "bot_id" field in the mutation.
  35381. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  35382. v := m.bot_id
  35383. if v == nil {
  35384. return
  35385. }
  35386. return *v, true
  35387. }
  35388. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  35389. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35391. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  35392. if !m.op.Is(OpUpdateOne) {
  35393. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35394. }
  35395. if m.id == nil || m.oldValue == nil {
  35396. return v, errors.New("OldBotID requires an ID field in the mutation")
  35397. }
  35398. oldValue, err := m.oldValue(ctx)
  35399. if err != nil {
  35400. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35401. }
  35402. return oldValue.BotID, nil
  35403. }
  35404. // ResetBotID resets all changes to the "bot_id" field.
  35405. func (m *UsageTotalMutation) ResetBotID() {
  35406. m.bot_id = nil
  35407. }
  35408. // SetTotalTokens sets the "total_tokens" field.
  35409. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  35410. m.total_tokens = &u
  35411. m.addtotal_tokens = nil
  35412. }
  35413. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  35414. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  35415. v := m.total_tokens
  35416. if v == nil {
  35417. return
  35418. }
  35419. return *v, true
  35420. }
  35421. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  35422. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35424. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  35425. if !m.op.Is(OpUpdateOne) {
  35426. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  35427. }
  35428. if m.id == nil || m.oldValue == nil {
  35429. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  35430. }
  35431. oldValue, err := m.oldValue(ctx)
  35432. if err != nil {
  35433. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  35434. }
  35435. return oldValue.TotalTokens, nil
  35436. }
  35437. // AddTotalTokens adds u to the "total_tokens" field.
  35438. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  35439. if m.addtotal_tokens != nil {
  35440. *m.addtotal_tokens += u
  35441. } else {
  35442. m.addtotal_tokens = &u
  35443. }
  35444. }
  35445. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  35446. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  35447. v := m.addtotal_tokens
  35448. if v == nil {
  35449. return
  35450. }
  35451. return *v, true
  35452. }
  35453. // ClearTotalTokens clears the value of the "total_tokens" field.
  35454. func (m *UsageTotalMutation) ClearTotalTokens() {
  35455. m.total_tokens = nil
  35456. m.addtotal_tokens = nil
  35457. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  35458. }
  35459. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  35460. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  35461. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  35462. return ok
  35463. }
  35464. // ResetTotalTokens resets all changes to the "total_tokens" field.
  35465. func (m *UsageTotalMutation) ResetTotalTokens() {
  35466. m.total_tokens = nil
  35467. m.addtotal_tokens = nil
  35468. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  35469. }
  35470. // SetStartIndex sets the "start_index" field.
  35471. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  35472. m.start_index = &u
  35473. m.addstart_index = nil
  35474. }
  35475. // StartIndex returns the value of the "start_index" field in the mutation.
  35476. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  35477. v := m.start_index
  35478. if v == nil {
  35479. return
  35480. }
  35481. return *v, true
  35482. }
  35483. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  35484. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35486. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  35487. if !m.op.Is(OpUpdateOne) {
  35488. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  35489. }
  35490. if m.id == nil || m.oldValue == nil {
  35491. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  35492. }
  35493. oldValue, err := m.oldValue(ctx)
  35494. if err != nil {
  35495. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  35496. }
  35497. return oldValue.StartIndex, nil
  35498. }
  35499. // AddStartIndex adds u to the "start_index" field.
  35500. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  35501. if m.addstart_index != nil {
  35502. *m.addstart_index += u
  35503. } else {
  35504. m.addstart_index = &u
  35505. }
  35506. }
  35507. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  35508. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  35509. v := m.addstart_index
  35510. if v == nil {
  35511. return
  35512. }
  35513. return *v, true
  35514. }
  35515. // ClearStartIndex clears the value of the "start_index" field.
  35516. func (m *UsageTotalMutation) ClearStartIndex() {
  35517. m.start_index = nil
  35518. m.addstart_index = nil
  35519. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  35520. }
  35521. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  35522. func (m *UsageTotalMutation) StartIndexCleared() bool {
  35523. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  35524. return ok
  35525. }
  35526. // ResetStartIndex resets all changes to the "start_index" field.
  35527. func (m *UsageTotalMutation) ResetStartIndex() {
  35528. m.start_index = nil
  35529. m.addstart_index = nil
  35530. delete(m.clearedFields, usagetotal.FieldStartIndex)
  35531. }
  35532. // SetEndIndex sets the "end_index" field.
  35533. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  35534. m.end_index = &u
  35535. m.addend_index = nil
  35536. }
  35537. // EndIndex returns the value of the "end_index" field in the mutation.
  35538. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  35539. v := m.end_index
  35540. if v == nil {
  35541. return
  35542. }
  35543. return *v, true
  35544. }
  35545. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  35546. // If the UsageTotal 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 *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  35549. if !m.op.Is(OpUpdateOne) {
  35550. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  35551. }
  35552. if m.id == nil || m.oldValue == nil {
  35553. return v, errors.New("OldEndIndex 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 OldEndIndex: %w", err)
  35558. }
  35559. return oldValue.EndIndex, nil
  35560. }
  35561. // AddEndIndex adds u to the "end_index" field.
  35562. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  35563. if m.addend_index != nil {
  35564. *m.addend_index += u
  35565. } else {
  35566. m.addend_index = &u
  35567. }
  35568. }
  35569. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  35570. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  35571. v := m.addend_index
  35572. if v == nil {
  35573. return
  35574. }
  35575. return *v, true
  35576. }
  35577. // ClearEndIndex clears the value of the "end_index" field.
  35578. func (m *UsageTotalMutation) ClearEndIndex() {
  35579. m.end_index = nil
  35580. m.addend_index = nil
  35581. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  35582. }
  35583. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  35584. func (m *UsageTotalMutation) EndIndexCleared() bool {
  35585. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  35586. return ok
  35587. }
  35588. // ResetEndIndex resets all changes to the "end_index" field.
  35589. func (m *UsageTotalMutation) ResetEndIndex() {
  35590. m.end_index = nil
  35591. m.addend_index = nil
  35592. delete(m.clearedFields, usagetotal.FieldEndIndex)
  35593. }
  35594. // SetOrganizationID sets the "organization_id" field.
  35595. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  35596. m.organization_id = &u
  35597. m.addorganization_id = nil
  35598. }
  35599. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35600. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  35601. v := m.organization_id
  35602. if v == nil {
  35603. return
  35604. }
  35605. return *v, true
  35606. }
  35607. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  35608. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35610. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35611. if !m.op.Is(OpUpdateOne) {
  35612. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35613. }
  35614. if m.id == nil || m.oldValue == nil {
  35615. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35616. }
  35617. oldValue, err := m.oldValue(ctx)
  35618. if err != nil {
  35619. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35620. }
  35621. return oldValue.OrganizationID, nil
  35622. }
  35623. // AddOrganizationID adds u to the "organization_id" field.
  35624. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  35625. if m.addorganization_id != nil {
  35626. *m.addorganization_id += u
  35627. } else {
  35628. m.addorganization_id = &u
  35629. }
  35630. }
  35631. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35632. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  35633. v := m.addorganization_id
  35634. if v == nil {
  35635. return
  35636. }
  35637. return *v, true
  35638. }
  35639. // ClearOrganizationID clears the value of the "organization_id" field.
  35640. func (m *UsageTotalMutation) ClearOrganizationID() {
  35641. m.organization_id = nil
  35642. m.addorganization_id = nil
  35643. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  35644. }
  35645. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35646. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  35647. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  35648. return ok
  35649. }
  35650. // ResetOrganizationID resets all changes to the "organization_id" field.
  35651. func (m *UsageTotalMutation) ResetOrganizationID() {
  35652. m.organization_id = nil
  35653. m.addorganization_id = nil
  35654. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  35655. }
  35656. // Where appends a list predicates to the UsageTotalMutation builder.
  35657. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  35658. m.predicates = append(m.predicates, ps...)
  35659. }
  35660. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  35661. // users can use type-assertion to append predicates that do not depend on any generated package.
  35662. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  35663. p := make([]predicate.UsageTotal, len(ps))
  35664. for i := range ps {
  35665. p[i] = ps[i]
  35666. }
  35667. m.Where(p...)
  35668. }
  35669. // Op returns the operation name.
  35670. func (m *UsageTotalMutation) Op() Op {
  35671. return m.op
  35672. }
  35673. // SetOp allows setting the mutation operation.
  35674. func (m *UsageTotalMutation) SetOp(op Op) {
  35675. m.op = op
  35676. }
  35677. // Type returns the node type of this mutation (UsageTotal).
  35678. func (m *UsageTotalMutation) Type() string {
  35679. return m.typ
  35680. }
  35681. // Fields returns all fields that were changed during this mutation. Note that in
  35682. // order to get all numeric fields that were incremented/decremented, call
  35683. // AddedFields().
  35684. func (m *UsageTotalMutation) Fields() []string {
  35685. fields := make([]string, 0, 9)
  35686. if m.created_at != nil {
  35687. fields = append(fields, usagetotal.FieldCreatedAt)
  35688. }
  35689. if m.updated_at != nil {
  35690. fields = append(fields, usagetotal.FieldUpdatedAt)
  35691. }
  35692. if m.status != nil {
  35693. fields = append(fields, usagetotal.FieldStatus)
  35694. }
  35695. if m._type != nil {
  35696. fields = append(fields, usagetotal.FieldType)
  35697. }
  35698. if m.bot_id != nil {
  35699. fields = append(fields, usagetotal.FieldBotID)
  35700. }
  35701. if m.total_tokens != nil {
  35702. fields = append(fields, usagetotal.FieldTotalTokens)
  35703. }
  35704. if m.start_index != nil {
  35705. fields = append(fields, usagetotal.FieldStartIndex)
  35706. }
  35707. if m.end_index != nil {
  35708. fields = append(fields, usagetotal.FieldEndIndex)
  35709. }
  35710. if m.organization_id != nil {
  35711. fields = append(fields, usagetotal.FieldOrganizationID)
  35712. }
  35713. return fields
  35714. }
  35715. // Field returns the value of a field with the given name. The second boolean
  35716. // return value indicates that this field was not set, or was not defined in the
  35717. // schema.
  35718. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  35719. switch name {
  35720. case usagetotal.FieldCreatedAt:
  35721. return m.CreatedAt()
  35722. case usagetotal.FieldUpdatedAt:
  35723. return m.UpdatedAt()
  35724. case usagetotal.FieldStatus:
  35725. return m.Status()
  35726. case usagetotal.FieldType:
  35727. return m.GetType()
  35728. case usagetotal.FieldBotID:
  35729. return m.BotID()
  35730. case usagetotal.FieldTotalTokens:
  35731. return m.TotalTokens()
  35732. case usagetotal.FieldStartIndex:
  35733. return m.StartIndex()
  35734. case usagetotal.FieldEndIndex:
  35735. return m.EndIndex()
  35736. case usagetotal.FieldOrganizationID:
  35737. return m.OrganizationID()
  35738. }
  35739. return nil, false
  35740. }
  35741. // OldField returns the old value of the field from the database. An error is
  35742. // returned if the mutation operation is not UpdateOne, or the query to the
  35743. // database failed.
  35744. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35745. switch name {
  35746. case usagetotal.FieldCreatedAt:
  35747. return m.OldCreatedAt(ctx)
  35748. case usagetotal.FieldUpdatedAt:
  35749. return m.OldUpdatedAt(ctx)
  35750. case usagetotal.FieldStatus:
  35751. return m.OldStatus(ctx)
  35752. case usagetotal.FieldType:
  35753. return m.OldType(ctx)
  35754. case usagetotal.FieldBotID:
  35755. return m.OldBotID(ctx)
  35756. case usagetotal.FieldTotalTokens:
  35757. return m.OldTotalTokens(ctx)
  35758. case usagetotal.FieldStartIndex:
  35759. return m.OldStartIndex(ctx)
  35760. case usagetotal.FieldEndIndex:
  35761. return m.OldEndIndex(ctx)
  35762. case usagetotal.FieldOrganizationID:
  35763. return m.OldOrganizationID(ctx)
  35764. }
  35765. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  35766. }
  35767. // SetField sets the value of a field with the given name. It returns an error if
  35768. // the field is not defined in the schema, or if the type mismatched the field
  35769. // type.
  35770. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  35771. switch name {
  35772. case usagetotal.FieldCreatedAt:
  35773. v, ok := value.(time.Time)
  35774. if !ok {
  35775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35776. }
  35777. m.SetCreatedAt(v)
  35778. return nil
  35779. case usagetotal.FieldUpdatedAt:
  35780. v, ok := value.(time.Time)
  35781. if !ok {
  35782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35783. }
  35784. m.SetUpdatedAt(v)
  35785. return nil
  35786. case usagetotal.FieldStatus:
  35787. v, ok := value.(uint8)
  35788. if !ok {
  35789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35790. }
  35791. m.SetStatus(v)
  35792. return nil
  35793. case usagetotal.FieldType:
  35794. v, ok := value.(int)
  35795. if !ok {
  35796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35797. }
  35798. m.SetType(v)
  35799. return nil
  35800. case usagetotal.FieldBotID:
  35801. v, ok := value.(string)
  35802. if !ok {
  35803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35804. }
  35805. m.SetBotID(v)
  35806. return nil
  35807. case usagetotal.FieldTotalTokens:
  35808. v, ok := value.(uint64)
  35809. if !ok {
  35810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35811. }
  35812. m.SetTotalTokens(v)
  35813. return nil
  35814. case usagetotal.FieldStartIndex:
  35815. v, ok := value.(uint64)
  35816. if !ok {
  35817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35818. }
  35819. m.SetStartIndex(v)
  35820. return nil
  35821. case usagetotal.FieldEndIndex:
  35822. v, ok := value.(uint64)
  35823. if !ok {
  35824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35825. }
  35826. m.SetEndIndex(v)
  35827. return nil
  35828. case usagetotal.FieldOrganizationID:
  35829. v, ok := value.(uint64)
  35830. if !ok {
  35831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35832. }
  35833. m.SetOrganizationID(v)
  35834. return nil
  35835. }
  35836. return fmt.Errorf("unknown UsageTotal field %s", name)
  35837. }
  35838. // AddedFields returns all numeric fields that were incremented/decremented during
  35839. // this mutation.
  35840. func (m *UsageTotalMutation) AddedFields() []string {
  35841. var fields []string
  35842. if m.addstatus != nil {
  35843. fields = append(fields, usagetotal.FieldStatus)
  35844. }
  35845. if m.add_type != nil {
  35846. fields = append(fields, usagetotal.FieldType)
  35847. }
  35848. if m.addtotal_tokens != nil {
  35849. fields = append(fields, usagetotal.FieldTotalTokens)
  35850. }
  35851. if m.addstart_index != nil {
  35852. fields = append(fields, usagetotal.FieldStartIndex)
  35853. }
  35854. if m.addend_index != nil {
  35855. fields = append(fields, usagetotal.FieldEndIndex)
  35856. }
  35857. if m.addorganization_id != nil {
  35858. fields = append(fields, usagetotal.FieldOrganizationID)
  35859. }
  35860. return fields
  35861. }
  35862. // AddedField returns the numeric value that was incremented/decremented on a field
  35863. // with the given name. The second boolean return value indicates that this field
  35864. // was not set, or was not defined in the schema.
  35865. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  35866. switch name {
  35867. case usagetotal.FieldStatus:
  35868. return m.AddedStatus()
  35869. case usagetotal.FieldType:
  35870. return m.AddedType()
  35871. case usagetotal.FieldTotalTokens:
  35872. return m.AddedTotalTokens()
  35873. case usagetotal.FieldStartIndex:
  35874. return m.AddedStartIndex()
  35875. case usagetotal.FieldEndIndex:
  35876. return m.AddedEndIndex()
  35877. case usagetotal.FieldOrganizationID:
  35878. return m.AddedOrganizationID()
  35879. }
  35880. return nil, false
  35881. }
  35882. // AddField adds the value to the field with the given name. It returns an error if
  35883. // the field is not defined in the schema, or if the type mismatched the field
  35884. // type.
  35885. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  35886. switch name {
  35887. case usagetotal.FieldStatus:
  35888. v, ok := value.(int8)
  35889. if !ok {
  35890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35891. }
  35892. m.AddStatus(v)
  35893. return nil
  35894. case usagetotal.FieldType:
  35895. v, ok := value.(int)
  35896. if !ok {
  35897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35898. }
  35899. m.AddType(v)
  35900. return nil
  35901. case usagetotal.FieldTotalTokens:
  35902. v, ok := value.(int64)
  35903. if !ok {
  35904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35905. }
  35906. m.AddTotalTokens(v)
  35907. return nil
  35908. case usagetotal.FieldStartIndex:
  35909. v, ok := value.(int64)
  35910. if !ok {
  35911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35912. }
  35913. m.AddStartIndex(v)
  35914. return nil
  35915. case usagetotal.FieldEndIndex:
  35916. v, ok := value.(int64)
  35917. if !ok {
  35918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35919. }
  35920. m.AddEndIndex(v)
  35921. return nil
  35922. case usagetotal.FieldOrganizationID:
  35923. v, ok := value.(int64)
  35924. if !ok {
  35925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35926. }
  35927. m.AddOrganizationID(v)
  35928. return nil
  35929. }
  35930. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  35931. }
  35932. // ClearedFields returns all nullable fields that were cleared during this
  35933. // mutation.
  35934. func (m *UsageTotalMutation) ClearedFields() []string {
  35935. var fields []string
  35936. if m.FieldCleared(usagetotal.FieldStatus) {
  35937. fields = append(fields, usagetotal.FieldStatus)
  35938. }
  35939. if m.FieldCleared(usagetotal.FieldType) {
  35940. fields = append(fields, usagetotal.FieldType)
  35941. }
  35942. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  35943. fields = append(fields, usagetotal.FieldTotalTokens)
  35944. }
  35945. if m.FieldCleared(usagetotal.FieldStartIndex) {
  35946. fields = append(fields, usagetotal.FieldStartIndex)
  35947. }
  35948. if m.FieldCleared(usagetotal.FieldEndIndex) {
  35949. fields = append(fields, usagetotal.FieldEndIndex)
  35950. }
  35951. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  35952. fields = append(fields, usagetotal.FieldOrganizationID)
  35953. }
  35954. return fields
  35955. }
  35956. // FieldCleared returns a boolean indicating if a field with the given name was
  35957. // cleared in this mutation.
  35958. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  35959. _, ok := m.clearedFields[name]
  35960. return ok
  35961. }
  35962. // ClearField clears the value of the field with the given name. It returns an
  35963. // error if the field is not defined in the schema.
  35964. func (m *UsageTotalMutation) ClearField(name string) error {
  35965. switch name {
  35966. case usagetotal.FieldStatus:
  35967. m.ClearStatus()
  35968. return nil
  35969. case usagetotal.FieldType:
  35970. m.ClearType()
  35971. return nil
  35972. case usagetotal.FieldTotalTokens:
  35973. m.ClearTotalTokens()
  35974. return nil
  35975. case usagetotal.FieldStartIndex:
  35976. m.ClearStartIndex()
  35977. return nil
  35978. case usagetotal.FieldEndIndex:
  35979. m.ClearEndIndex()
  35980. return nil
  35981. case usagetotal.FieldOrganizationID:
  35982. m.ClearOrganizationID()
  35983. return nil
  35984. }
  35985. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  35986. }
  35987. // ResetField resets all changes in the mutation for the field with the given name.
  35988. // It returns an error if the field is not defined in the schema.
  35989. func (m *UsageTotalMutation) ResetField(name string) error {
  35990. switch name {
  35991. case usagetotal.FieldCreatedAt:
  35992. m.ResetCreatedAt()
  35993. return nil
  35994. case usagetotal.FieldUpdatedAt:
  35995. m.ResetUpdatedAt()
  35996. return nil
  35997. case usagetotal.FieldStatus:
  35998. m.ResetStatus()
  35999. return nil
  36000. case usagetotal.FieldType:
  36001. m.ResetType()
  36002. return nil
  36003. case usagetotal.FieldBotID:
  36004. m.ResetBotID()
  36005. return nil
  36006. case usagetotal.FieldTotalTokens:
  36007. m.ResetTotalTokens()
  36008. return nil
  36009. case usagetotal.FieldStartIndex:
  36010. m.ResetStartIndex()
  36011. return nil
  36012. case usagetotal.FieldEndIndex:
  36013. m.ResetEndIndex()
  36014. return nil
  36015. case usagetotal.FieldOrganizationID:
  36016. m.ResetOrganizationID()
  36017. return nil
  36018. }
  36019. return fmt.Errorf("unknown UsageTotal field %s", name)
  36020. }
  36021. // AddedEdges returns all edge names that were set/added in this mutation.
  36022. func (m *UsageTotalMutation) AddedEdges() []string {
  36023. edges := make([]string, 0, 0)
  36024. return edges
  36025. }
  36026. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36027. // name in this mutation.
  36028. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  36029. return nil
  36030. }
  36031. // RemovedEdges returns all edge names that were removed in this mutation.
  36032. func (m *UsageTotalMutation) RemovedEdges() []string {
  36033. edges := make([]string, 0, 0)
  36034. return edges
  36035. }
  36036. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36037. // the given name in this mutation.
  36038. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  36039. return nil
  36040. }
  36041. // ClearedEdges returns all edge names that were cleared in this mutation.
  36042. func (m *UsageTotalMutation) ClearedEdges() []string {
  36043. edges := make([]string, 0, 0)
  36044. return edges
  36045. }
  36046. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36047. // was cleared in this mutation.
  36048. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  36049. return false
  36050. }
  36051. // ClearEdge clears the value of the edge with the given name. It returns an error
  36052. // if that edge is not defined in the schema.
  36053. func (m *UsageTotalMutation) ClearEdge(name string) error {
  36054. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  36055. }
  36056. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36057. // It returns an error if the edge is not defined in the schema.
  36058. func (m *UsageTotalMutation) ResetEdge(name string) error {
  36059. return fmt.Errorf("unknown UsageTotal edge %s", name)
  36060. }
  36061. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  36062. type WhatsappMutation struct {
  36063. config
  36064. op Op
  36065. typ string
  36066. id *uint64
  36067. created_at *time.Time
  36068. updated_at *time.Time
  36069. status *uint8
  36070. addstatus *int8
  36071. deleted_at *time.Time
  36072. wa_id *string
  36073. wa_name *string
  36074. callback *string
  36075. account *string
  36076. cc *string
  36077. phone *string
  36078. cc_phone *string
  36079. phone_name *string
  36080. phone_status *int8
  36081. addphone_status *int8
  36082. organization_id *uint64
  36083. addorganization_id *int64
  36084. api_base *string
  36085. api_key *string
  36086. allow_list *[]string
  36087. appendallow_list []string
  36088. group_allow_list *[]string
  36089. appendgroup_allow_list []string
  36090. block_list *[]string
  36091. appendblock_list []string
  36092. group_block_list *[]string
  36093. appendgroup_block_list []string
  36094. clearedFields map[string]struct{}
  36095. agent *uint64
  36096. clearedagent bool
  36097. done bool
  36098. oldValue func(context.Context) (*Whatsapp, error)
  36099. predicates []predicate.Whatsapp
  36100. }
  36101. var _ ent.Mutation = (*WhatsappMutation)(nil)
  36102. // whatsappOption allows management of the mutation configuration using functional options.
  36103. type whatsappOption func(*WhatsappMutation)
  36104. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  36105. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  36106. m := &WhatsappMutation{
  36107. config: c,
  36108. op: op,
  36109. typ: TypeWhatsapp,
  36110. clearedFields: make(map[string]struct{}),
  36111. }
  36112. for _, opt := range opts {
  36113. opt(m)
  36114. }
  36115. return m
  36116. }
  36117. // withWhatsappID sets the ID field of the mutation.
  36118. func withWhatsappID(id uint64) whatsappOption {
  36119. return func(m *WhatsappMutation) {
  36120. var (
  36121. err error
  36122. once sync.Once
  36123. value *Whatsapp
  36124. )
  36125. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  36126. once.Do(func() {
  36127. if m.done {
  36128. err = errors.New("querying old values post mutation is not allowed")
  36129. } else {
  36130. value, err = m.Client().Whatsapp.Get(ctx, id)
  36131. }
  36132. })
  36133. return value, err
  36134. }
  36135. m.id = &id
  36136. }
  36137. }
  36138. // withWhatsapp sets the old Whatsapp of the mutation.
  36139. func withWhatsapp(node *Whatsapp) whatsappOption {
  36140. return func(m *WhatsappMutation) {
  36141. m.oldValue = func(context.Context) (*Whatsapp, error) {
  36142. return node, nil
  36143. }
  36144. m.id = &node.ID
  36145. }
  36146. }
  36147. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36148. // executed in a transaction (ent.Tx), a transactional client is returned.
  36149. func (m WhatsappMutation) Client() *Client {
  36150. client := &Client{config: m.config}
  36151. client.init()
  36152. return client
  36153. }
  36154. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36155. // it returns an error otherwise.
  36156. func (m WhatsappMutation) Tx() (*Tx, error) {
  36157. if _, ok := m.driver.(*txDriver); !ok {
  36158. return nil, errors.New("ent: mutation is not running in a transaction")
  36159. }
  36160. tx := &Tx{config: m.config}
  36161. tx.init()
  36162. return tx, nil
  36163. }
  36164. // SetID sets the value of the id field. Note that this
  36165. // operation is only accepted on creation of Whatsapp entities.
  36166. func (m *WhatsappMutation) SetID(id uint64) {
  36167. m.id = &id
  36168. }
  36169. // ID returns the ID value in the mutation. Note that the ID is only available
  36170. // if it was provided to the builder or after it was returned from the database.
  36171. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  36172. if m.id == nil {
  36173. return
  36174. }
  36175. return *m.id, true
  36176. }
  36177. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36178. // That means, if the mutation is applied within a transaction with an isolation level such
  36179. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36180. // or updated by the mutation.
  36181. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  36182. switch {
  36183. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36184. id, exists := m.ID()
  36185. if exists {
  36186. return []uint64{id}, nil
  36187. }
  36188. fallthrough
  36189. case m.op.Is(OpUpdate | OpDelete):
  36190. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  36191. default:
  36192. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36193. }
  36194. }
  36195. // SetCreatedAt sets the "created_at" field.
  36196. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  36197. m.created_at = &t
  36198. }
  36199. // CreatedAt returns the value of the "created_at" field in the mutation.
  36200. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  36201. v := m.created_at
  36202. if v == nil {
  36203. return
  36204. }
  36205. return *v, true
  36206. }
  36207. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  36208. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36210. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36211. if !m.op.Is(OpUpdateOne) {
  36212. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36213. }
  36214. if m.id == nil || m.oldValue == nil {
  36215. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36216. }
  36217. oldValue, err := m.oldValue(ctx)
  36218. if err != nil {
  36219. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36220. }
  36221. return oldValue.CreatedAt, nil
  36222. }
  36223. // ResetCreatedAt resets all changes to the "created_at" field.
  36224. func (m *WhatsappMutation) ResetCreatedAt() {
  36225. m.created_at = nil
  36226. }
  36227. // SetUpdatedAt sets the "updated_at" field.
  36228. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  36229. m.updated_at = &t
  36230. }
  36231. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36232. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  36233. v := m.updated_at
  36234. if v == nil {
  36235. return
  36236. }
  36237. return *v, true
  36238. }
  36239. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  36240. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36242. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36243. if !m.op.Is(OpUpdateOne) {
  36244. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36245. }
  36246. if m.id == nil || m.oldValue == nil {
  36247. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36248. }
  36249. oldValue, err := m.oldValue(ctx)
  36250. if err != nil {
  36251. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36252. }
  36253. return oldValue.UpdatedAt, nil
  36254. }
  36255. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36256. func (m *WhatsappMutation) ResetUpdatedAt() {
  36257. m.updated_at = nil
  36258. }
  36259. // SetStatus sets the "status" field.
  36260. func (m *WhatsappMutation) SetStatus(u uint8) {
  36261. m.status = &u
  36262. m.addstatus = nil
  36263. }
  36264. // Status returns the value of the "status" field in the mutation.
  36265. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  36266. v := m.status
  36267. if v == nil {
  36268. return
  36269. }
  36270. return *v, true
  36271. }
  36272. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  36273. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36275. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36276. if !m.op.Is(OpUpdateOne) {
  36277. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36278. }
  36279. if m.id == nil || m.oldValue == nil {
  36280. return v, errors.New("OldStatus requires an ID field in the mutation")
  36281. }
  36282. oldValue, err := m.oldValue(ctx)
  36283. if err != nil {
  36284. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36285. }
  36286. return oldValue.Status, nil
  36287. }
  36288. // AddStatus adds u to the "status" field.
  36289. func (m *WhatsappMutation) AddStatus(u int8) {
  36290. if m.addstatus != nil {
  36291. *m.addstatus += u
  36292. } else {
  36293. m.addstatus = &u
  36294. }
  36295. }
  36296. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36297. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  36298. v := m.addstatus
  36299. if v == nil {
  36300. return
  36301. }
  36302. return *v, true
  36303. }
  36304. // ClearStatus clears the value of the "status" field.
  36305. func (m *WhatsappMutation) ClearStatus() {
  36306. m.status = nil
  36307. m.addstatus = nil
  36308. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  36309. }
  36310. // StatusCleared returns if the "status" field was cleared in this mutation.
  36311. func (m *WhatsappMutation) StatusCleared() bool {
  36312. _, ok := m.clearedFields[whatsapp.FieldStatus]
  36313. return ok
  36314. }
  36315. // ResetStatus resets all changes to the "status" field.
  36316. func (m *WhatsappMutation) ResetStatus() {
  36317. m.status = nil
  36318. m.addstatus = nil
  36319. delete(m.clearedFields, whatsapp.FieldStatus)
  36320. }
  36321. // SetDeletedAt sets the "deleted_at" field.
  36322. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  36323. m.deleted_at = &t
  36324. }
  36325. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36326. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  36327. v := m.deleted_at
  36328. if v == nil {
  36329. return
  36330. }
  36331. return *v, true
  36332. }
  36333. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  36334. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36336. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36337. if !m.op.Is(OpUpdateOne) {
  36338. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36339. }
  36340. if m.id == nil || m.oldValue == nil {
  36341. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36342. }
  36343. oldValue, err := m.oldValue(ctx)
  36344. if err != nil {
  36345. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36346. }
  36347. return oldValue.DeletedAt, nil
  36348. }
  36349. // ClearDeletedAt clears the value of the "deleted_at" field.
  36350. func (m *WhatsappMutation) ClearDeletedAt() {
  36351. m.deleted_at = nil
  36352. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  36353. }
  36354. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36355. func (m *WhatsappMutation) DeletedAtCleared() bool {
  36356. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  36357. return ok
  36358. }
  36359. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36360. func (m *WhatsappMutation) ResetDeletedAt() {
  36361. m.deleted_at = nil
  36362. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  36363. }
  36364. // SetWaID sets the "wa_id" field.
  36365. func (m *WhatsappMutation) SetWaID(s string) {
  36366. m.wa_id = &s
  36367. }
  36368. // WaID returns the value of the "wa_id" field in the mutation.
  36369. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  36370. v := m.wa_id
  36371. if v == nil {
  36372. return
  36373. }
  36374. return *v, true
  36375. }
  36376. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  36377. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36379. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  36380. if !m.op.Is(OpUpdateOne) {
  36381. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  36382. }
  36383. if m.id == nil || m.oldValue == nil {
  36384. return v, errors.New("OldWaID requires an ID field in the mutation")
  36385. }
  36386. oldValue, err := m.oldValue(ctx)
  36387. if err != nil {
  36388. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  36389. }
  36390. return oldValue.WaID, nil
  36391. }
  36392. // ClearWaID clears the value of the "wa_id" field.
  36393. func (m *WhatsappMutation) ClearWaID() {
  36394. m.wa_id = nil
  36395. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  36396. }
  36397. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  36398. func (m *WhatsappMutation) WaIDCleared() bool {
  36399. _, ok := m.clearedFields[whatsapp.FieldWaID]
  36400. return ok
  36401. }
  36402. // ResetWaID resets all changes to the "wa_id" field.
  36403. func (m *WhatsappMutation) ResetWaID() {
  36404. m.wa_id = nil
  36405. delete(m.clearedFields, whatsapp.FieldWaID)
  36406. }
  36407. // SetWaName sets the "wa_name" field.
  36408. func (m *WhatsappMutation) SetWaName(s string) {
  36409. m.wa_name = &s
  36410. }
  36411. // WaName returns the value of the "wa_name" field in the mutation.
  36412. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  36413. v := m.wa_name
  36414. if v == nil {
  36415. return
  36416. }
  36417. return *v, true
  36418. }
  36419. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  36420. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36422. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  36423. if !m.op.Is(OpUpdateOne) {
  36424. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  36425. }
  36426. if m.id == nil || m.oldValue == nil {
  36427. return v, errors.New("OldWaName requires an ID field in the mutation")
  36428. }
  36429. oldValue, err := m.oldValue(ctx)
  36430. if err != nil {
  36431. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  36432. }
  36433. return oldValue.WaName, nil
  36434. }
  36435. // ClearWaName clears the value of the "wa_name" field.
  36436. func (m *WhatsappMutation) ClearWaName() {
  36437. m.wa_name = nil
  36438. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  36439. }
  36440. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  36441. func (m *WhatsappMutation) WaNameCleared() bool {
  36442. _, ok := m.clearedFields[whatsapp.FieldWaName]
  36443. return ok
  36444. }
  36445. // ResetWaName resets all changes to the "wa_name" field.
  36446. func (m *WhatsappMutation) ResetWaName() {
  36447. m.wa_name = nil
  36448. delete(m.clearedFields, whatsapp.FieldWaName)
  36449. }
  36450. // SetCallback sets the "callback" field.
  36451. func (m *WhatsappMutation) SetCallback(s string) {
  36452. m.callback = &s
  36453. }
  36454. // Callback returns the value of the "callback" field in the mutation.
  36455. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  36456. v := m.callback
  36457. if v == nil {
  36458. return
  36459. }
  36460. return *v, true
  36461. }
  36462. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  36463. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36465. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  36466. if !m.op.Is(OpUpdateOne) {
  36467. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  36468. }
  36469. if m.id == nil || m.oldValue == nil {
  36470. return v, errors.New("OldCallback requires an ID field in the mutation")
  36471. }
  36472. oldValue, err := m.oldValue(ctx)
  36473. if err != nil {
  36474. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  36475. }
  36476. return oldValue.Callback, nil
  36477. }
  36478. // ClearCallback clears the value of the "callback" field.
  36479. func (m *WhatsappMutation) ClearCallback() {
  36480. m.callback = nil
  36481. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  36482. }
  36483. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  36484. func (m *WhatsappMutation) CallbackCleared() bool {
  36485. _, ok := m.clearedFields[whatsapp.FieldCallback]
  36486. return ok
  36487. }
  36488. // ResetCallback resets all changes to the "callback" field.
  36489. func (m *WhatsappMutation) ResetCallback() {
  36490. m.callback = nil
  36491. delete(m.clearedFields, whatsapp.FieldCallback)
  36492. }
  36493. // SetAgentID sets the "agent_id" field.
  36494. func (m *WhatsappMutation) SetAgentID(u uint64) {
  36495. m.agent = &u
  36496. }
  36497. // AgentID returns the value of the "agent_id" field in the mutation.
  36498. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  36499. v := m.agent
  36500. if v == nil {
  36501. return
  36502. }
  36503. return *v, true
  36504. }
  36505. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  36506. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36508. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  36509. if !m.op.Is(OpUpdateOne) {
  36510. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  36511. }
  36512. if m.id == nil || m.oldValue == nil {
  36513. return v, errors.New("OldAgentID requires an ID field in the mutation")
  36514. }
  36515. oldValue, err := m.oldValue(ctx)
  36516. if err != nil {
  36517. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  36518. }
  36519. return oldValue.AgentID, nil
  36520. }
  36521. // ResetAgentID resets all changes to the "agent_id" field.
  36522. func (m *WhatsappMutation) ResetAgentID() {
  36523. m.agent = nil
  36524. }
  36525. // SetAccount sets the "account" field.
  36526. func (m *WhatsappMutation) SetAccount(s string) {
  36527. m.account = &s
  36528. }
  36529. // Account returns the value of the "account" field in the mutation.
  36530. func (m *WhatsappMutation) Account() (r string, exists bool) {
  36531. v := m.account
  36532. if v == nil {
  36533. return
  36534. }
  36535. return *v, true
  36536. }
  36537. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  36538. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36540. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  36541. if !m.op.Is(OpUpdateOne) {
  36542. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  36543. }
  36544. if m.id == nil || m.oldValue == nil {
  36545. return v, errors.New("OldAccount requires an ID field in the mutation")
  36546. }
  36547. oldValue, err := m.oldValue(ctx)
  36548. if err != nil {
  36549. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  36550. }
  36551. return oldValue.Account, nil
  36552. }
  36553. // ClearAccount clears the value of the "account" field.
  36554. func (m *WhatsappMutation) ClearAccount() {
  36555. m.account = nil
  36556. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  36557. }
  36558. // AccountCleared returns if the "account" field was cleared in this mutation.
  36559. func (m *WhatsappMutation) AccountCleared() bool {
  36560. _, ok := m.clearedFields[whatsapp.FieldAccount]
  36561. return ok
  36562. }
  36563. // ResetAccount resets all changes to the "account" field.
  36564. func (m *WhatsappMutation) ResetAccount() {
  36565. m.account = nil
  36566. delete(m.clearedFields, whatsapp.FieldAccount)
  36567. }
  36568. // SetCc sets the "cc" field.
  36569. func (m *WhatsappMutation) SetCc(s string) {
  36570. m.cc = &s
  36571. }
  36572. // Cc returns the value of the "cc" field in the mutation.
  36573. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  36574. v := m.cc
  36575. if v == nil {
  36576. return
  36577. }
  36578. return *v, true
  36579. }
  36580. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  36581. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36583. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  36584. if !m.op.Is(OpUpdateOne) {
  36585. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  36586. }
  36587. if m.id == nil || m.oldValue == nil {
  36588. return v, errors.New("OldCc requires an ID field in the mutation")
  36589. }
  36590. oldValue, err := m.oldValue(ctx)
  36591. if err != nil {
  36592. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  36593. }
  36594. return oldValue.Cc, nil
  36595. }
  36596. // ResetCc resets all changes to the "cc" field.
  36597. func (m *WhatsappMutation) ResetCc() {
  36598. m.cc = nil
  36599. }
  36600. // SetPhone sets the "phone" field.
  36601. func (m *WhatsappMutation) SetPhone(s string) {
  36602. m.phone = &s
  36603. }
  36604. // Phone returns the value of the "phone" field in the mutation.
  36605. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  36606. v := m.phone
  36607. if v == nil {
  36608. return
  36609. }
  36610. return *v, true
  36611. }
  36612. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  36613. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36615. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  36616. if !m.op.Is(OpUpdateOne) {
  36617. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  36618. }
  36619. if m.id == nil || m.oldValue == nil {
  36620. return v, errors.New("OldPhone requires an ID field in the mutation")
  36621. }
  36622. oldValue, err := m.oldValue(ctx)
  36623. if err != nil {
  36624. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  36625. }
  36626. return oldValue.Phone, nil
  36627. }
  36628. // ResetPhone resets all changes to the "phone" field.
  36629. func (m *WhatsappMutation) ResetPhone() {
  36630. m.phone = nil
  36631. }
  36632. // SetCcPhone sets the "cc_phone" field.
  36633. func (m *WhatsappMutation) SetCcPhone(s string) {
  36634. m.cc_phone = &s
  36635. }
  36636. // CcPhone returns the value of the "cc_phone" field in the mutation.
  36637. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  36638. v := m.cc_phone
  36639. if v == nil {
  36640. return
  36641. }
  36642. return *v, true
  36643. }
  36644. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  36645. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36647. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  36648. if !m.op.Is(OpUpdateOne) {
  36649. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  36650. }
  36651. if m.id == nil || m.oldValue == nil {
  36652. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  36653. }
  36654. oldValue, err := m.oldValue(ctx)
  36655. if err != nil {
  36656. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  36657. }
  36658. return oldValue.CcPhone, nil
  36659. }
  36660. // ResetCcPhone resets all changes to the "cc_phone" field.
  36661. func (m *WhatsappMutation) ResetCcPhone() {
  36662. m.cc_phone = nil
  36663. }
  36664. // SetPhoneName sets the "phone_name" field.
  36665. func (m *WhatsappMutation) SetPhoneName(s string) {
  36666. m.phone_name = &s
  36667. }
  36668. // PhoneName returns the value of the "phone_name" field in the mutation.
  36669. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  36670. v := m.phone_name
  36671. if v == nil {
  36672. return
  36673. }
  36674. return *v, true
  36675. }
  36676. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  36677. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36679. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  36680. if !m.op.Is(OpUpdateOne) {
  36681. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  36682. }
  36683. if m.id == nil || m.oldValue == nil {
  36684. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  36685. }
  36686. oldValue, err := m.oldValue(ctx)
  36687. if err != nil {
  36688. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  36689. }
  36690. return oldValue.PhoneName, nil
  36691. }
  36692. // ResetPhoneName resets all changes to the "phone_name" field.
  36693. func (m *WhatsappMutation) ResetPhoneName() {
  36694. m.phone_name = nil
  36695. }
  36696. // SetPhoneStatus sets the "phone_status" field.
  36697. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  36698. m.phone_status = &i
  36699. m.addphone_status = nil
  36700. }
  36701. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  36702. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  36703. v := m.phone_status
  36704. if v == nil {
  36705. return
  36706. }
  36707. return *v, true
  36708. }
  36709. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  36710. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36712. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  36713. if !m.op.Is(OpUpdateOne) {
  36714. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  36715. }
  36716. if m.id == nil || m.oldValue == nil {
  36717. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  36718. }
  36719. oldValue, err := m.oldValue(ctx)
  36720. if err != nil {
  36721. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  36722. }
  36723. return oldValue.PhoneStatus, nil
  36724. }
  36725. // AddPhoneStatus adds i to the "phone_status" field.
  36726. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  36727. if m.addphone_status != nil {
  36728. *m.addphone_status += i
  36729. } else {
  36730. m.addphone_status = &i
  36731. }
  36732. }
  36733. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  36734. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  36735. v := m.addphone_status
  36736. if v == nil {
  36737. return
  36738. }
  36739. return *v, true
  36740. }
  36741. // ResetPhoneStatus resets all changes to the "phone_status" field.
  36742. func (m *WhatsappMutation) ResetPhoneStatus() {
  36743. m.phone_status = nil
  36744. m.addphone_status = nil
  36745. }
  36746. // SetOrganizationID sets the "organization_id" field.
  36747. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  36748. m.organization_id = &u
  36749. m.addorganization_id = nil
  36750. }
  36751. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36752. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  36753. v := m.organization_id
  36754. if v == nil {
  36755. return
  36756. }
  36757. return *v, true
  36758. }
  36759. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  36760. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36762. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36763. if !m.op.Is(OpUpdateOne) {
  36764. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36765. }
  36766. if m.id == nil || m.oldValue == nil {
  36767. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36768. }
  36769. oldValue, err := m.oldValue(ctx)
  36770. if err != nil {
  36771. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36772. }
  36773. return oldValue.OrganizationID, nil
  36774. }
  36775. // AddOrganizationID adds u to the "organization_id" field.
  36776. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  36777. if m.addorganization_id != nil {
  36778. *m.addorganization_id += u
  36779. } else {
  36780. m.addorganization_id = &u
  36781. }
  36782. }
  36783. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36784. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  36785. v := m.addorganization_id
  36786. if v == nil {
  36787. return
  36788. }
  36789. return *v, true
  36790. }
  36791. // ClearOrganizationID clears the value of the "organization_id" field.
  36792. func (m *WhatsappMutation) ClearOrganizationID() {
  36793. m.organization_id = nil
  36794. m.addorganization_id = nil
  36795. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  36796. }
  36797. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36798. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  36799. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  36800. return ok
  36801. }
  36802. // ResetOrganizationID resets all changes to the "organization_id" field.
  36803. func (m *WhatsappMutation) ResetOrganizationID() {
  36804. m.organization_id = nil
  36805. m.addorganization_id = nil
  36806. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  36807. }
  36808. // SetAPIBase sets the "api_base" field.
  36809. func (m *WhatsappMutation) SetAPIBase(s string) {
  36810. m.api_base = &s
  36811. }
  36812. // APIBase returns the value of the "api_base" field in the mutation.
  36813. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  36814. v := m.api_base
  36815. if v == nil {
  36816. return
  36817. }
  36818. return *v, true
  36819. }
  36820. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  36821. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36823. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  36824. if !m.op.Is(OpUpdateOne) {
  36825. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  36826. }
  36827. if m.id == nil || m.oldValue == nil {
  36828. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  36829. }
  36830. oldValue, err := m.oldValue(ctx)
  36831. if err != nil {
  36832. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  36833. }
  36834. return oldValue.APIBase, nil
  36835. }
  36836. // ClearAPIBase clears the value of the "api_base" field.
  36837. func (m *WhatsappMutation) ClearAPIBase() {
  36838. m.api_base = nil
  36839. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  36840. }
  36841. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  36842. func (m *WhatsappMutation) APIBaseCleared() bool {
  36843. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  36844. return ok
  36845. }
  36846. // ResetAPIBase resets all changes to the "api_base" field.
  36847. func (m *WhatsappMutation) ResetAPIBase() {
  36848. m.api_base = nil
  36849. delete(m.clearedFields, whatsapp.FieldAPIBase)
  36850. }
  36851. // SetAPIKey sets the "api_key" field.
  36852. func (m *WhatsappMutation) SetAPIKey(s string) {
  36853. m.api_key = &s
  36854. }
  36855. // APIKey returns the value of the "api_key" field in the mutation.
  36856. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  36857. v := m.api_key
  36858. if v == nil {
  36859. return
  36860. }
  36861. return *v, true
  36862. }
  36863. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  36864. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36866. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  36867. if !m.op.Is(OpUpdateOne) {
  36868. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  36869. }
  36870. if m.id == nil || m.oldValue == nil {
  36871. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  36872. }
  36873. oldValue, err := m.oldValue(ctx)
  36874. if err != nil {
  36875. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  36876. }
  36877. return oldValue.APIKey, nil
  36878. }
  36879. // ClearAPIKey clears the value of the "api_key" field.
  36880. func (m *WhatsappMutation) ClearAPIKey() {
  36881. m.api_key = nil
  36882. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  36883. }
  36884. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  36885. func (m *WhatsappMutation) APIKeyCleared() bool {
  36886. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  36887. return ok
  36888. }
  36889. // ResetAPIKey resets all changes to the "api_key" field.
  36890. func (m *WhatsappMutation) ResetAPIKey() {
  36891. m.api_key = nil
  36892. delete(m.clearedFields, whatsapp.FieldAPIKey)
  36893. }
  36894. // SetAllowList sets the "allow_list" field.
  36895. func (m *WhatsappMutation) SetAllowList(s []string) {
  36896. m.allow_list = &s
  36897. m.appendallow_list = nil
  36898. }
  36899. // AllowList returns the value of the "allow_list" field in the mutation.
  36900. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  36901. v := m.allow_list
  36902. if v == nil {
  36903. return
  36904. }
  36905. return *v, true
  36906. }
  36907. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  36908. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36910. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  36911. if !m.op.Is(OpUpdateOne) {
  36912. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  36913. }
  36914. if m.id == nil || m.oldValue == nil {
  36915. return v, errors.New("OldAllowList requires an ID field in the mutation")
  36916. }
  36917. oldValue, err := m.oldValue(ctx)
  36918. if err != nil {
  36919. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  36920. }
  36921. return oldValue.AllowList, nil
  36922. }
  36923. // AppendAllowList adds s to the "allow_list" field.
  36924. func (m *WhatsappMutation) AppendAllowList(s []string) {
  36925. m.appendallow_list = append(m.appendallow_list, s...)
  36926. }
  36927. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  36928. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  36929. if len(m.appendallow_list) == 0 {
  36930. return nil, false
  36931. }
  36932. return m.appendallow_list, true
  36933. }
  36934. // ClearAllowList clears the value of the "allow_list" field.
  36935. func (m *WhatsappMutation) ClearAllowList() {
  36936. m.allow_list = nil
  36937. m.appendallow_list = nil
  36938. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  36939. }
  36940. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  36941. func (m *WhatsappMutation) AllowListCleared() bool {
  36942. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  36943. return ok
  36944. }
  36945. // ResetAllowList resets all changes to the "allow_list" field.
  36946. func (m *WhatsappMutation) ResetAllowList() {
  36947. m.allow_list = nil
  36948. m.appendallow_list = nil
  36949. delete(m.clearedFields, whatsapp.FieldAllowList)
  36950. }
  36951. // SetGroupAllowList sets the "group_allow_list" field.
  36952. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  36953. m.group_allow_list = &s
  36954. m.appendgroup_allow_list = nil
  36955. }
  36956. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  36957. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  36958. v := m.group_allow_list
  36959. if v == nil {
  36960. return
  36961. }
  36962. return *v, true
  36963. }
  36964. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  36965. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36967. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  36968. if !m.op.Is(OpUpdateOne) {
  36969. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  36970. }
  36971. if m.id == nil || m.oldValue == nil {
  36972. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  36973. }
  36974. oldValue, err := m.oldValue(ctx)
  36975. if err != nil {
  36976. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  36977. }
  36978. return oldValue.GroupAllowList, nil
  36979. }
  36980. // AppendGroupAllowList adds s to the "group_allow_list" field.
  36981. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  36982. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  36983. }
  36984. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  36985. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  36986. if len(m.appendgroup_allow_list) == 0 {
  36987. return nil, false
  36988. }
  36989. return m.appendgroup_allow_list, true
  36990. }
  36991. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  36992. func (m *WhatsappMutation) ClearGroupAllowList() {
  36993. m.group_allow_list = nil
  36994. m.appendgroup_allow_list = nil
  36995. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  36996. }
  36997. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  36998. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  36999. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  37000. return ok
  37001. }
  37002. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  37003. func (m *WhatsappMutation) ResetGroupAllowList() {
  37004. m.group_allow_list = nil
  37005. m.appendgroup_allow_list = nil
  37006. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  37007. }
  37008. // SetBlockList sets the "block_list" field.
  37009. func (m *WhatsappMutation) SetBlockList(s []string) {
  37010. m.block_list = &s
  37011. m.appendblock_list = nil
  37012. }
  37013. // BlockList returns the value of the "block_list" field in the mutation.
  37014. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  37015. v := m.block_list
  37016. if v == nil {
  37017. return
  37018. }
  37019. return *v, true
  37020. }
  37021. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  37022. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37024. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  37025. if !m.op.Is(OpUpdateOne) {
  37026. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  37027. }
  37028. if m.id == nil || m.oldValue == nil {
  37029. return v, errors.New("OldBlockList requires an ID field in the mutation")
  37030. }
  37031. oldValue, err := m.oldValue(ctx)
  37032. if err != nil {
  37033. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  37034. }
  37035. return oldValue.BlockList, nil
  37036. }
  37037. // AppendBlockList adds s to the "block_list" field.
  37038. func (m *WhatsappMutation) AppendBlockList(s []string) {
  37039. m.appendblock_list = append(m.appendblock_list, s...)
  37040. }
  37041. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  37042. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  37043. if len(m.appendblock_list) == 0 {
  37044. return nil, false
  37045. }
  37046. return m.appendblock_list, true
  37047. }
  37048. // ClearBlockList clears the value of the "block_list" field.
  37049. func (m *WhatsappMutation) ClearBlockList() {
  37050. m.block_list = nil
  37051. m.appendblock_list = nil
  37052. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  37053. }
  37054. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  37055. func (m *WhatsappMutation) BlockListCleared() bool {
  37056. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  37057. return ok
  37058. }
  37059. // ResetBlockList resets all changes to the "block_list" field.
  37060. func (m *WhatsappMutation) ResetBlockList() {
  37061. m.block_list = nil
  37062. m.appendblock_list = nil
  37063. delete(m.clearedFields, whatsapp.FieldBlockList)
  37064. }
  37065. // SetGroupBlockList sets the "group_block_list" field.
  37066. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  37067. m.group_block_list = &s
  37068. m.appendgroup_block_list = nil
  37069. }
  37070. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  37071. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  37072. v := m.group_block_list
  37073. if v == nil {
  37074. return
  37075. }
  37076. return *v, true
  37077. }
  37078. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  37079. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37081. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  37082. if !m.op.Is(OpUpdateOne) {
  37083. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  37084. }
  37085. if m.id == nil || m.oldValue == nil {
  37086. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  37087. }
  37088. oldValue, err := m.oldValue(ctx)
  37089. if err != nil {
  37090. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  37091. }
  37092. return oldValue.GroupBlockList, nil
  37093. }
  37094. // AppendGroupBlockList adds s to the "group_block_list" field.
  37095. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  37096. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  37097. }
  37098. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  37099. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  37100. if len(m.appendgroup_block_list) == 0 {
  37101. return nil, false
  37102. }
  37103. return m.appendgroup_block_list, true
  37104. }
  37105. // ClearGroupBlockList clears the value of the "group_block_list" field.
  37106. func (m *WhatsappMutation) ClearGroupBlockList() {
  37107. m.group_block_list = nil
  37108. m.appendgroup_block_list = nil
  37109. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  37110. }
  37111. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  37112. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  37113. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  37114. return ok
  37115. }
  37116. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  37117. func (m *WhatsappMutation) ResetGroupBlockList() {
  37118. m.group_block_list = nil
  37119. m.appendgroup_block_list = nil
  37120. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  37121. }
  37122. // ClearAgent clears the "agent" edge to the Agent entity.
  37123. func (m *WhatsappMutation) ClearAgent() {
  37124. m.clearedagent = true
  37125. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  37126. }
  37127. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  37128. func (m *WhatsappMutation) AgentCleared() bool {
  37129. return m.clearedagent
  37130. }
  37131. // AgentIDs returns the "agent" edge IDs in the mutation.
  37132. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  37133. // AgentID instead. It exists only for internal usage by the builders.
  37134. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  37135. if id := m.agent; id != nil {
  37136. ids = append(ids, *id)
  37137. }
  37138. return
  37139. }
  37140. // ResetAgent resets all changes to the "agent" edge.
  37141. func (m *WhatsappMutation) ResetAgent() {
  37142. m.agent = nil
  37143. m.clearedagent = false
  37144. }
  37145. // Where appends a list predicates to the WhatsappMutation builder.
  37146. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  37147. m.predicates = append(m.predicates, ps...)
  37148. }
  37149. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  37150. // users can use type-assertion to append predicates that do not depend on any generated package.
  37151. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  37152. p := make([]predicate.Whatsapp, len(ps))
  37153. for i := range ps {
  37154. p[i] = ps[i]
  37155. }
  37156. m.Where(p...)
  37157. }
  37158. // Op returns the operation name.
  37159. func (m *WhatsappMutation) Op() Op {
  37160. return m.op
  37161. }
  37162. // SetOp allows setting the mutation operation.
  37163. func (m *WhatsappMutation) SetOp(op Op) {
  37164. m.op = op
  37165. }
  37166. // Type returns the node type of this mutation (Whatsapp).
  37167. func (m *WhatsappMutation) Type() string {
  37168. return m.typ
  37169. }
  37170. // Fields returns all fields that were changed during this mutation. Note that in
  37171. // order to get all numeric fields that were incremented/decremented, call
  37172. // AddedFields().
  37173. func (m *WhatsappMutation) Fields() []string {
  37174. fields := make([]string, 0, 21)
  37175. if m.created_at != nil {
  37176. fields = append(fields, whatsapp.FieldCreatedAt)
  37177. }
  37178. if m.updated_at != nil {
  37179. fields = append(fields, whatsapp.FieldUpdatedAt)
  37180. }
  37181. if m.status != nil {
  37182. fields = append(fields, whatsapp.FieldStatus)
  37183. }
  37184. if m.deleted_at != nil {
  37185. fields = append(fields, whatsapp.FieldDeletedAt)
  37186. }
  37187. if m.wa_id != nil {
  37188. fields = append(fields, whatsapp.FieldWaID)
  37189. }
  37190. if m.wa_name != nil {
  37191. fields = append(fields, whatsapp.FieldWaName)
  37192. }
  37193. if m.callback != nil {
  37194. fields = append(fields, whatsapp.FieldCallback)
  37195. }
  37196. if m.agent != nil {
  37197. fields = append(fields, whatsapp.FieldAgentID)
  37198. }
  37199. if m.account != nil {
  37200. fields = append(fields, whatsapp.FieldAccount)
  37201. }
  37202. if m.cc != nil {
  37203. fields = append(fields, whatsapp.FieldCc)
  37204. }
  37205. if m.phone != nil {
  37206. fields = append(fields, whatsapp.FieldPhone)
  37207. }
  37208. if m.cc_phone != nil {
  37209. fields = append(fields, whatsapp.FieldCcPhone)
  37210. }
  37211. if m.phone_name != nil {
  37212. fields = append(fields, whatsapp.FieldPhoneName)
  37213. }
  37214. if m.phone_status != nil {
  37215. fields = append(fields, whatsapp.FieldPhoneStatus)
  37216. }
  37217. if m.organization_id != nil {
  37218. fields = append(fields, whatsapp.FieldOrganizationID)
  37219. }
  37220. if m.api_base != nil {
  37221. fields = append(fields, whatsapp.FieldAPIBase)
  37222. }
  37223. if m.api_key != nil {
  37224. fields = append(fields, whatsapp.FieldAPIKey)
  37225. }
  37226. if m.allow_list != nil {
  37227. fields = append(fields, whatsapp.FieldAllowList)
  37228. }
  37229. if m.group_allow_list != nil {
  37230. fields = append(fields, whatsapp.FieldGroupAllowList)
  37231. }
  37232. if m.block_list != nil {
  37233. fields = append(fields, whatsapp.FieldBlockList)
  37234. }
  37235. if m.group_block_list != nil {
  37236. fields = append(fields, whatsapp.FieldGroupBlockList)
  37237. }
  37238. return fields
  37239. }
  37240. // Field returns the value of a field with the given name. The second boolean
  37241. // return value indicates that this field was not set, or was not defined in the
  37242. // schema.
  37243. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  37244. switch name {
  37245. case whatsapp.FieldCreatedAt:
  37246. return m.CreatedAt()
  37247. case whatsapp.FieldUpdatedAt:
  37248. return m.UpdatedAt()
  37249. case whatsapp.FieldStatus:
  37250. return m.Status()
  37251. case whatsapp.FieldDeletedAt:
  37252. return m.DeletedAt()
  37253. case whatsapp.FieldWaID:
  37254. return m.WaID()
  37255. case whatsapp.FieldWaName:
  37256. return m.WaName()
  37257. case whatsapp.FieldCallback:
  37258. return m.Callback()
  37259. case whatsapp.FieldAgentID:
  37260. return m.AgentID()
  37261. case whatsapp.FieldAccount:
  37262. return m.Account()
  37263. case whatsapp.FieldCc:
  37264. return m.Cc()
  37265. case whatsapp.FieldPhone:
  37266. return m.Phone()
  37267. case whatsapp.FieldCcPhone:
  37268. return m.CcPhone()
  37269. case whatsapp.FieldPhoneName:
  37270. return m.PhoneName()
  37271. case whatsapp.FieldPhoneStatus:
  37272. return m.PhoneStatus()
  37273. case whatsapp.FieldOrganizationID:
  37274. return m.OrganizationID()
  37275. case whatsapp.FieldAPIBase:
  37276. return m.APIBase()
  37277. case whatsapp.FieldAPIKey:
  37278. return m.APIKey()
  37279. case whatsapp.FieldAllowList:
  37280. return m.AllowList()
  37281. case whatsapp.FieldGroupAllowList:
  37282. return m.GroupAllowList()
  37283. case whatsapp.FieldBlockList:
  37284. return m.BlockList()
  37285. case whatsapp.FieldGroupBlockList:
  37286. return m.GroupBlockList()
  37287. }
  37288. return nil, false
  37289. }
  37290. // OldField returns the old value of the field from the database. An error is
  37291. // returned if the mutation operation is not UpdateOne, or the query to the
  37292. // database failed.
  37293. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37294. switch name {
  37295. case whatsapp.FieldCreatedAt:
  37296. return m.OldCreatedAt(ctx)
  37297. case whatsapp.FieldUpdatedAt:
  37298. return m.OldUpdatedAt(ctx)
  37299. case whatsapp.FieldStatus:
  37300. return m.OldStatus(ctx)
  37301. case whatsapp.FieldDeletedAt:
  37302. return m.OldDeletedAt(ctx)
  37303. case whatsapp.FieldWaID:
  37304. return m.OldWaID(ctx)
  37305. case whatsapp.FieldWaName:
  37306. return m.OldWaName(ctx)
  37307. case whatsapp.FieldCallback:
  37308. return m.OldCallback(ctx)
  37309. case whatsapp.FieldAgentID:
  37310. return m.OldAgentID(ctx)
  37311. case whatsapp.FieldAccount:
  37312. return m.OldAccount(ctx)
  37313. case whatsapp.FieldCc:
  37314. return m.OldCc(ctx)
  37315. case whatsapp.FieldPhone:
  37316. return m.OldPhone(ctx)
  37317. case whatsapp.FieldCcPhone:
  37318. return m.OldCcPhone(ctx)
  37319. case whatsapp.FieldPhoneName:
  37320. return m.OldPhoneName(ctx)
  37321. case whatsapp.FieldPhoneStatus:
  37322. return m.OldPhoneStatus(ctx)
  37323. case whatsapp.FieldOrganizationID:
  37324. return m.OldOrganizationID(ctx)
  37325. case whatsapp.FieldAPIBase:
  37326. return m.OldAPIBase(ctx)
  37327. case whatsapp.FieldAPIKey:
  37328. return m.OldAPIKey(ctx)
  37329. case whatsapp.FieldAllowList:
  37330. return m.OldAllowList(ctx)
  37331. case whatsapp.FieldGroupAllowList:
  37332. return m.OldGroupAllowList(ctx)
  37333. case whatsapp.FieldBlockList:
  37334. return m.OldBlockList(ctx)
  37335. case whatsapp.FieldGroupBlockList:
  37336. return m.OldGroupBlockList(ctx)
  37337. }
  37338. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  37339. }
  37340. // SetField sets the value of a field with the given name. It returns an error if
  37341. // the field is not defined in the schema, or if the type mismatched the field
  37342. // type.
  37343. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  37344. switch name {
  37345. case whatsapp.FieldCreatedAt:
  37346. v, ok := value.(time.Time)
  37347. if !ok {
  37348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37349. }
  37350. m.SetCreatedAt(v)
  37351. return nil
  37352. case whatsapp.FieldUpdatedAt:
  37353. v, ok := value.(time.Time)
  37354. if !ok {
  37355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37356. }
  37357. m.SetUpdatedAt(v)
  37358. return nil
  37359. case whatsapp.FieldStatus:
  37360. v, ok := value.(uint8)
  37361. if !ok {
  37362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37363. }
  37364. m.SetStatus(v)
  37365. return nil
  37366. case whatsapp.FieldDeletedAt:
  37367. v, ok := value.(time.Time)
  37368. if !ok {
  37369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37370. }
  37371. m.SetDeletedAt(v)
  37372. return nil
  37373. case whatsapp.FieldWaID:
  37374. v, ok := value.(string)
  37375. if !ok {
  37376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37377. }
  37378. m.SetWaID(v)
  37379. return nil
  37380. case whatsapp.FieldWaName:
  37381. v, ok := value.(string)
  37382. if !ok {
  37383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37384. }
  37385. m.SetWaName(v)
  37386. return nil
  37387. case whatsapp.FieldCallback:
  37388. v, ok := value.(string)
  37389. if !ok {
  37390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37391. }
  37392. m.SetCallback(v)
  37393. return nil
  37394. case whatsapp.FieldAgentID:
  37395. v, ok := value.(uint64)
  37396. if !ok {
  37397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37398. }
  37399. m.SetAgentID(v)
  37400. return nil
  37401. case whatsapp.FieldAccount:
  37402. v, ok := value.(string)
  37403. if !ok {
  37404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37405. }
  37406. m.SetAccount(v)
  37407. return nil
  37408. case whatsapp.FieldCc:
  37409. v, ok := value.(string)
  37410. if !ok {
  37411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37412. }
  37413. m.SetCc(v)
  37414. return nil
  37415. case whatsapp.FieldPhone:
  37416. v, ok := value.(string)
  37417. if !ok {
  37418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37419. }
  37420. m.SetPhone(v)
  37421. return nil
  37422. case whatsapp.FieldCcPhone:
  37423. v, ok := value.(string)
  37424. if !ok {
  37425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37426. }
  37427. m.SetCcPhone(v)
  37428. return nil
  37429. case whatsapp.FieldPhoneName:
  37430. v, ok := value.(string)
  37431. if !ok {
  37432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37433. }
  37434. m.SetPhoneName(v)
  37435. return nil
  37436. case whatsapp.FieldPhoneStatus:
  37437. v, ok := value.(int8)
  37438. if !ok {
  37439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37440. }
  37441. m.SetPhoneStatus(v)
  37442. return nil
  37443. case whatsapp.FieldOrganizationID:
  37444. v, ok := value.(uint64)
  37445. if !ok {
  37446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37447. }
  37448. m.SetOrganizationID(v)
  37449. return nil
  37450. case whatsapp.FieldAPIBase:
  37451. v, ok := value.(string)
  37452. if !ok {
  37453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37454. }
  37455. m.SetAPIBase(v)
  37456. return nil
  37457. case whatsapp.FieldAPIKey:
  37458. v, ok := value.(string)
  37459. if !ok {
  37460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37461. }
  37462. m.SetAPIKey(v)
  37463. return nil
  37464. case whatsapp.FieldAllowList:
  37465. v, ok := value.([]string)
  37466. if !ok {
  37467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37468. }
  37469. m.SetAllowList(v)
  37470. return nil
  37471. case whatsapp.FieldGroupAllowList:
  37472. v, ok := value.([]string)
  37473. if !ok {
  37474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37475. }
  37476. m.SetGroupAllowList(v)
  37477. return nil
  37478. case whatsapp.FieldBlockList:
  37479. v, ok := value.([]string)
  37480. if !ok {
  37481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37482. }
  37483. m.SetBlockList(v)
  37484. return nil
  37485. case whatsapp.FieldGroupBlockList:
  37486. v, ok := value.([]string)
  37487. if !ok {
  37488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37489. }
  37490. m.SetGroupBlockList(v)
  37491. return nil
  37492. }
  37493. return fmt.Errorf("unknown Whatsapp field %s", name)
  37494. }
  37495. // AddedFields returns all numeric fields that were incremented/decremented during
  37496. // this mutation.
  37497. func (m *WhatsappMutation) AddedFields() []string {
  37498. var fields []string
  37499. if m.addstatus != nil {
  37500. fields = append(fields, whatsapp.FieldStatus)
  37501. }
  37502. if m.addphone_status != nil {
  37503. fields = append(fields, whatsapp.FieldPhoneStatus)
  37504. }
  37505. if m.addorganization_id != nil {
  37506. fields = append(fields, whatsapp.FieldOrganizationID)
  37507. }
  37508. return fields
  37509. }
  37510. // AddedField returns the numeric value that was incremented/decremented on a field
  37511. // with the given name. The second boolean return value indicates that this field
  37512. // was not set, or was not defined in the schema.
  37513. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  37514. switch name {
  37515. case whatsapp.FieldStatus:
  37516. return m.AddedStatus()
  37517. case whatsapp.FieldPhoneStatus:
  37518. return m.AddedPhoneStatus()
  37519. case whatsapp.FieldOrganizationID:
  37520. return m.AddedOrganizationID()
  37521. }
  37522. return nil, false
  37523. }
  37524. // AddField adds the value to the field with the given name. It returns an error if
  37525. // the field is not defined in the schema, or if the type mismatched the field
  37526. // type.
  37527. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  37528. switch name {
  37529. case whatsapp.FieldStatus:
  37530. v, ok := value.(int8)
  37531. if !ok {
  37532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37533. }
  37534. m.AddStatus(v)
  37535. return nil
  37536. case whatsapp.FieldPhoneStatus:
  37537. v, ok := value.(int8)
  37538. if !ok {
  37539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37540. }
  37541. m.AddPhoneStatus(v)
  37542. return nil
  37543. case whatsapp.FieldOrganizationID:
  37544. v, ok := value.(int64)
  37545. if !ok {
  37546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37547. }
  37548. m.AddOrganizationID(v)
  37549. return nil
  37550. }
  37551. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  37552. }
  37553. // ClearedFields returns all nullable fields that were cleared during this
  37554. // mutation.
  37555. func (m *WhatsappMutation) ClearedFields() []string {
  37556. var fields []string
  37557. if m.FieldCleared(whatsapp.FieldStatus) {
  37558. fields = append(fields, whatsapp.FieldStatus)
  37559. }
  37560. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  37561. fields = append(fields, whatsapp.FieldDeletedAt)
  37562. }
  37563. if m.FieldCleared(whatsapp.FieldWaID) {
  37564. fields = append(fields, whatsapp.FieldWaID)
  37565. }
  37566. if m.FieldCleared(whatsapp.FieldWaName) {
  37567. fields = append(fields, whatsapp.FieldWaName)
  37568. }
  37569. if m.FieldCleared(whatsapp.FieldCallback) {
  37570. fields = append(fields, whatsapp.FieldCallback)
  37571. }
  37572. if m.FieldCleared(whatsapp.FieldAccount) {
  37573. fields = append(fields, whatsapp.FieldAccount)
  37574. }
  37575. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  37576. fields = append(fields, whatsapp.FieldOrganizationID)
  37577. }
  37578. if m.FieldCleared(whatsapp.FieldAPIBase) {
  37579. fields = append(fields, whatsapp.FieldAPIBase)
  37580. }
  37581. if m.FieldCleared(whatsapp.FieldAPIKey) {
  37582. fields = append(fields, whatsapp.FieldAPIKey)
  37583. }
  37584. if m.FieldCleared(whatsapp.FieldAllowList) {
  37585. fields = append(fields, whatsapp.FieldAllowList)
  37586. }
  37587. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  37588. fields = append(fields, whatsapp.FieldGroupAllowList)
  37589. }
  37590. if m.FieldCleared(whatsapp.FieldBlockList) {
  37591. fields = append(fields, whatsapp.FieldBlockList)
  37592. }
  37593. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  37594. fields = append(fields, whatsapp.FieldGroupBlockList)
  37595. }
  37596. return fields
  37597. }
  37598. // FieldCleared returns a boolean indicating if a field with the given name was
  37599. // cleared in this mutation.
  37600. func (m *WhatsappMutation) FieldCleared(name string) bool {
  37601. _, ok := m.clearedFields[name]
  37602. return ok
  37603. }
  37604. // ClearField clears the value of the field with the given name. It returns an
  37605. // error if the field is not defined in the schema.
  37606. func (m *WhatsappMutation) ClearField(name string) error {
  37607. switch name {
  37608. case whatsapp.FieldStatus:
  37609. m.ClearStatus()
  37610. return nil
  37611. case whatsapp.FieldDeletedAt:
  37612. m.ClearDeletedAt()
  37613. return nil
  37614. case whatsapp.FieldWaID:
  37615. m.ClearWaID()
  37616. return nil
  37617. case whatsapp.FieldWaName:
  37618. m.ClearWaName()
  37619. return nil
  37620. case whatsapp.FieldCallback:
  37621. m.ClearCallback()
  37622. return nil
  37623. case whatsapp.FieldAccount:
  37624. m.ClearAccount()
  37625. return nil
  37626. case whatsapp.FieldOrganizationID:
  37627. m.ClearOrganizationID()
  37628. return nil
  37629. case whatsapp.FieldAPIBase:
  37630. m.ClearAPIBase()
  37631. return nil
  37632. case whatsapp.FieldAPIKey:
  37633. m.ClearAPIKey()
  37634. return nil
  37635. case whatsapp.FieldAllowList:
  37636. m.ClearAllowList()
  37637. return nil
  37638. case whatsapp.FieldGroupAllowList:
  37639. m.ClearGroupAllowList()
  37640. return nil
  37641. case whatsapp.FieldBlockList:
  37642. m.ClearBlockList()
  37643. return nil
  37644. case whatsapp.FieldGroupBlockList:
  37645. m.ClearGroupBlockList()
  37646. return nil
  37647. }
  37648. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  37649. }
  37650. // ResetField resets all changes in the mutation for the field with the given name.
  37651. // It returns an error if the field is not defined in the schema.
  37652. func (m *WhatsappMutation) ResetField(name string) error {
  37653. switch name {
  37654. case whatsapp.FieldCreatedAt:
  37655. m.ResetCreatedAt()
  37656. return nil
  37657. case whatsapp.FieldUpdatedAt:
  37658. m.ResetUpdatedAt()
  37659. return nil
  37660. case whatsapp.FieldStatus:
  37661. m.ResetStatus()
  37662. return nil
  37663. case whatsapp.FieldDeletedAt:
  37664. m.ResetDeletedAt()
  37665. return nil
  37666. case whatsapp.FieldWaID:
  37667. m.ResetWaID()
  37668. return nil
  37669. case whatsapp.FieldWaName:
  37670. m.ResetWaName()
  37671. return nil
  37672. case whatsapp.FieldCallback:
  37673. m.ResetCallback()
  37674. return nil
  37675. case whatsapp.FieldAgentID:
  37676. m.ResetAgentID()
  37677. return nil
  37678. case whatsapp.FieldAccount:
  37679. m.ResetAccount()
  37680. return nil
  37681. case whatsapp.FieldCc:
  37682. m.ResetCc()
  37683. return nil
  37684. case whatsapp.FieldPhone:
  37685. m.ResetPhone()
  37686. return nil
  37687. case whatsapp.FieldCcPhone:
  37688. m.ResetCcPhone()
  37689. return nil
  37690. case whatsapp.FieldPhoneName:
  37691. m.ResetPhoneName()
  37692. return nil
  37693. case whatsapp.FieldPhoneStatus:
  37694. m.ResetPhoneStatus()
  37695. return nil
  37696. case whatsapp.FieldOrganizationID:
  37697. m.ResetOrganizationID()
  37698. return nil
  37699. case whatsapp.FieldAPIBase:
  37700. m.ResetAPIBase()
  37701. return nil
  37702. case whatsapp.FieldAPIKey:
  37703. m.ResetAPIKey()
  37704. return nil
  37705. case whatsapp.FieldAllowList:
  37706. m.ResetAllowList()
  37707. return nil
  37708. case whatsapp.FieldGroupAllowList:
  37709. m.ResetGroupAllowList()
  37710. return nil
  37711. case whatsapp.FieldBlockList:
  37712. m.ResetBlockList()
  37713. return nil
  37714. case whatsapp.FieldGroupBlockList:
  37715. m.ResetGroupBlockList()
  37716. return nil
  37717. }
  37718. return fmt.Errorf("unknown Whatsapp field %s", name)
  37719. }
  37720. // AddedEdges returns all edge names that were set/added in this mutation.
  37721. func (m *WhatsappMutation) AddedEdges() []string {
  37722. edges := make([]string, 0, 1)
  37723. if m.agent != nil {
  37724. edges = append(edges, whatsapp.EdgeAgent)
  37725. }
  37726. return edges
  37727. }
  37728. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37729. // name in this mutation.
  37730. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  37731. switch name {
  37732. case whatsapp.EdgeAgent:
  37733. if id := m.agent; id != nil {
  37734. return []ent.Value{*id}
  37735. }
  37736. }
  37737. return nil
  37738. }
  37739. // RemovedEdges returns all edge names that were removed in this mutation.
  37740. func (m *WhatsappMutation) RemovedEdges() []string {
  37741. edges := make([]string, 0, 1)
  37742. return edges
  37743. }
  37744. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37745. // the given name in this mutation.
  37746. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  37747. return nil
  37748. }
  37749. // ClearedEdges returns all edge names that were cleared in this mutation.
  37750. func (m *WhatsappMutation) ClearedEdges() []string {
  37751. edges := make([]string, 0, 1)
  37752. if m.clearedagent {
  37753. edges = append(edges, whatsapp.EdgeAgent)
  37754. }
  37755. return edges
  37756. }
  37757. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37758. // was cleared in this mutation.
  37759. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  37760. switch name {
  37761. case whatsapp.EdgeAgent:
  37762. return m.clearedagent
  37763. }
  37764. return false
  37765. }
  37766. // ClearEdge clears the value of the edge with the given name. It returns an error
  37767. // if that edge is not defined in the schema.
  37768. func (m *WhatsappMutation) ClearEdge(name string) error {
  37769. switch name {
  37770. case whatsapp.EdgeAgent:
  37771. m.ClearAgent()
  37772. return nil
  37773. }
  37774. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  37775. }
  37776. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37777. // It returns an error if the edge is not defined in the schema.
  37778. func (m *WhatsappMutation) ResetEdge(name string) error {
  37779. switch name {
  37780. case whatsapp.EdgeAgent:
  37781. m.ResetAgent()
  37782. return nil
  37783. }
  37784. return fmt.Errorf("unknown Whatsapp edge %s", name)
  37785. }
  37786. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  37787. type WhatsappChannelMutation struct {
  37788. config
  37789. op Op
  37790. typ string
  37791. id *uint64
  37792. created_at *time.Time
  37793. updated_at *time.Time
  37794. status *uint8
  37795. addstatus *int8
  37796. deleted_at *time.Time
  37797. ak *string
  37798. sk *string
  37799. wa_id *string
  37800. wa_name *string
  37801. waba_id *uint64
  37802. addwaba_id *int64
  37803. business_id *uint64
  37804. addbusiness_id *int64
  37805. organization_id *uint64
  37806. addorganization_id *int64
  37807. verify_account *string
  37808. clearedFields map[string]struct{}
  37809. done bool
  37810. oldValue func(context.Context) (*WhatsappChannel, error)
  37811. predicates []predicate.WhatsappChannel
  37812. }
  37813. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  37814. // whatsappchannelOption allows management of the mutation configuration using functional options.
  37815. type whatsappchannelOption func(*WhatsappChannelMutation)
  37816. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  37817. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  37818. m := &WhatsappChannelMutation{
  37819. config: c,
  37820. op: op,
  37821. typ: TypeWhatsappChannel,
  37822. clearedFields: make(map[string]struct{}),
  37823. }
  37824. for _, opt := range opts {
  37825. opt(m)
  37826. }
  37827. return m
  37828. }
  37829. // withWhatsappChannelID sets the ID field of the mutation.
  37830. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  37831. return func(m *WhatsappChannelMutation) {
  37832. var (
  37833. err error
  37834. once sync.Once
  37835. value *WhatsappChannel
  37836. )
  37837. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  37838. once.Do(func() {
  37839. if m.done {
  37840. err = errors.New("querying old values post mutation is not allowed")
  37841. } else {
  37842. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  37843. }
  37844. })
  37845. return value, err
  37846. }
  37847. m.id = &id
  37848. }
  37849. }
  37850. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  37851. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  37852. return func(m *WhatsappChannelMutation) {
  37853. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  37854. return node, nil
  37855. }
  37856. m.id = &node.ID
  37857. }
  37858. }
  37859. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37860. // executed in a transaction (ent.Tx), a transactional client is returned.
  37861. func (m WhatsappChannelMutation) Client() *Client {
  37862. client := &Client{config: m.config}
  37863. client.init()
  37864. return client
  37865. }
  37866. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37867. // it returns an error otherwise.
  37868. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  37869. if _, ok := m.driver.(*txDriver); !ok {
  37870. return nil, errors.New("ent: mutation is not running in a transaction")
  37871. }
  37872. tx := &Tx{config: m.config}
  37873. tx.init()
  37874. return tx, nil
  37875. }
  37876. // SetID sets the value of the id field. Note that this
  37877. // operation is only accepted on creation of WhatsappChannel entities.
  37878. func (m *WhatsappChannelMutation) SetID(id uint64) {
  37879. m.id = &id
  37880. }
  37881. // ID returns the ID value in the mutation. Note that the ID is only available
  37882. // if it was provided to the builder or after it was returned from the database.
  37883. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  37884. if m.id == nil {
  37885. return
  37886. }
  37887. return *m.id, true
  37888. }
  37889. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37890. // That means, if the mutation is applied within a transaction with an isolation level such
  37891. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37892. // or updated by the mutation.
  37893. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  37894. switch {
  37895. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37896. id, exists := m.ID()
  37897. if exists {
  37898. return []uint64{id}, nil
  37899. }
  37900. fallthrough
  37901. case m.op.Is(OpUpdate | OpDelete):
  37902. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  37903. default:
  37904. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37905. }
  37906. }
  37907. // SetCreatedAt sets the "created_at" field.
  37908. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  37909. m.created_at = &t
  37910. }
  37911. // CreatedAt returns the value of the "created_at" field in the mutation.
  37912. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  37913. v := m.created_at
  37914. if v == nil {
  37915. return
  37916. }
  37917. return *v, true
  37918. }
  37919. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  37920. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37922. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37923. if !m.op.Is(OpUpdateOne) {
  37924. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37925. }
  37926. if m.id == nil || m.oldValue == nil {
  37927. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37928. }
  37929. oldValue, err := m.oldValue(ctx)
  37930. if err != nil {
  37931. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37932. }
  37933. return oldValue.CreatedAt, nil
  37934. }
  37935. // ResetCreatedAt resets all changes to the "created_at" field.
  37936. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  37937. m.created_at = nil
  37938. }
  37939. // SetUpdatedAt sets the "updated_at" field.
  37940. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  37941. m.updated_at = &t
  37942. }
  37943. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37944. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  37945. v := m.updated_at
  37946. if v == nil {
  37947. return
  37948. }
  37949. return *v, true
  37950. }
  37951. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  37952. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37954. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37955. if !m.op.Is(OpUpdateOne) {
  37956. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37957. }
  37958. if m.id == nil || m.oldValue == nil {
  37959. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37960. }
  37961. oldValue, err := m.oldValue(ctx)
  37962. if err != nil {
  37963. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37964. }
  37965. return oldValue.UpdatedAt, nil
  37966. }
  37967. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37968. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  37969. m.updated_at = nil
  37970. }
  37971. // SetStatus sets the "status" field.
  37972. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  37973. m.status = &u
  37974. m.addstatus = nil
  37975. }
  37976. // Status returns the value of the "status" field in the mutation.
  37977. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  37978. v := m.status
  37979. if v == nil {
  37980. return
  37981. }
  37982. return *v, true
  37983. }
  37984. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  37985. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37987. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37988. if !m.op.Is(OpUpdateOne) {
  37989. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37990. }
  37991. if m.id == nil || m.oldValue == nil {
  37992. return v, errors.New("OldStatus requires an ID field in the mutation")
  37993. }
  37994. oldValue, err := m.oldValue(ctx)
  37995. if err != nil {
  37996. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37997. }
  37998. return oldValue.Status, nil
  37999. }
  38000. // AddStatus adds u to the "status" field.
  38001. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  38002. if m.addstatus != nil {
  38003. *m.addstatus += u
  38004. } else {
  38005. m.addstatus = &u
  38006. }
  38007. }
  38008. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38009. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  38010. v := m.addstatus
  38011. if v == nil {
  38012. return
  38013. }
  38014. return *v, true
  38015. }
  38016. // ClearStatus clears the value of the "status" field.
  38017. func (m *WhatsappChannelMutation) ClearStatus() {
  38018. m.status = nil
  38019. m.addstatus = nil
  38020. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  38021. }
  38022. // StatusCleared returns if the "status" field was cleared in this mutation.
  38023. func (m *WhatsappChannelMutation) StatusCleared() bool {
  38024. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  38025. return ok
  38026. }
  38027. // ResetStatus resets all changes to the "status" field.
  38028. func (m *WhatsappChannelMutation) ResetStatus() {
  38029. m.status = nil
  38030. m.addstatus = nil
  38031. delete(m.clearedFields, whatsappchannel.FieldStatus)
  38032. }
  38033. // SetDeletedAt sets the "deleted_at" field.
  38034. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  38035. m.deleted_at = &t
  38036. }
  38037. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38038. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  38039. v := m.deleted_at
  38040. if v == nil {
  38041. return
  38042. }
  38043. return *v, true
  38044. }
  38045. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  38046. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38048. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38049. if !m.op.Is(OpUpdateOne) {
  38050. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38051. }
  38052. if m.id == nil || m.oldValue == nil {
  38053. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38054. }
  38055. oldValue, err := m.oldValue(ctx)
  38056. if err != nil {
  38057. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38058. }
  38059. return oldValue.DeletedAt, nil
  38060. }
  38061. // ClearDeletedAt clears the value of the "deleted_at" field.
  38062. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  38063. m.deleted_at = nil
  38064. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  38065. }
  38066. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38067. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  38068. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  38069. return ok
  38070. }
  38071. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38072. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  38073. m.deleted_at = nil
  38074. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  38075. }
  38076. // SetAk sets the "ak" field.
  38077. func (m *WhatsappChannelMutation) SetAk(s string) {
  38078. m.ak = &s
  38079. }
  38080. // Ak returns the value of the "ak" field in the mutation.
  38081. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  38082. v := m.ak
  38083. if v == nil {
  38084. return
  38085. }
  38086. return *v, true
  38087. }
  38088. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  38089. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38091. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  38092. if !m.op.Is(OpUpdateOne) {
  38093. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  38094. }
  38095. if m.id == nil || m.oldValue == nil {
  38096. return v, errors.New("OldAk requires an ID field in the mutation")
  38097. }
  38098. oldValue, err := m.oldValue(ctx)
  38099. if err != nil {
  38100. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  38101. }
  38102. return oldValue.Ak, nil
  38103. }
  38104. // ClearAk clears the value of the "ak" field.
  38105. func (m *WhatsappChannelMutation) ClearAk() {
  38106. m.ak = nil
  38107. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  38108. }
  38109. // AkCleared returns if the "ak" field was cleared in this mutation.
  38110. func (m *WhatsappChannelMutation) AkCleared() bool {
  38111. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  38112. return ok
  38113. }
  38114. // ResetAk resets all changes to the "ak" field.
  38115. func (m *WhatsappChannelMutation) ResetAk() {
  38116. m.ak = nil
  38117. delete(m.clearedFields, whatsappchannel.FieldAk)
  38118. }
  38119. // SetSk sets the "sk" field.
  38120. func (m *WhatsappChannelMutation) SetSk(s string) {
  38121. m.sk = &s
  38122. }
  38123. // Sk returns the value of the "sk" field in the mutation.
  38124. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  38125. v := m.sk
  38126. if v == nil {
  38127. return
  38128. }
  38129. return *v, true
  38130. }
  38131. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  38132. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38134. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  38135. if !m.op.Is(OpUpdateOne) {
  38136. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  38137. }
  38138. if m.id == nil || m.oldValue == nil {
  38139. return v, errors.New("OldSk requires an ID field in the mutation")
  38140. }
  38141. oldValue, err := m.oldValue(ctx)
  38142. if err != nil {
  38143. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  38144. }
  38145. return oldValue.Sk, nil
  38146. }
  38147. // ResetSk resets all changes to the "sk" field.
  38148. func (m *WhatsappChannelMutation) ResetSk() {
  38149. m.sk = nil
  38150. }
  38151. // SetWaID sets the "wa_id" field.
  38152. func (m *WhatsappChannelMutation) SetWaID(s string) {
  38153. m.wa_id = &s
  38154. }
  38155. // WaID returns the value of the "wa_id" field in the mutation.
  38156. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  38157. v := m.wa_id
  38158. if v == nil {
  38159. return
  38160. }
  38161. return *v, true
  38162. }
  38163. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  38164. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38166. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  38167. if !m.op.Is(OpUpdateOne) {
  38168. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  38169. }
  38170. if m.id == nil || m.oldValue == nil {
  38171. return v, errors.New("OldWaID requires an ID field in the mutation")
  38172. }
  38173. oldValue, err := m.oldValue(ctx)
  38174. if err != nil {
  38175. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  38176. }
  38177. return oldValue.WaID, nil
  38178. }
  38179. // ClearWaID clears the value of the "wa_id" field.
  38180. func (m *WhatsappChannelMutation) ClearWaID() {
  38181. m.wa_id = nil
  38182. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  38183. }
  38184. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  38185. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  38186. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  38187. return ok
  38188. }
  38189. // ResetWaID resets all changes to the "wa_id" field.
  38190. func (m *WhatsappChannelMutation) ResetWaID() {
  38191. m.wa_id = nil
  38192. delete(m.clearedFields, whatsappchannel.FieldWaID)
  38193. }
  38194. // SetWaName sets the "wa_name" field.
  38195. func (m *WhatsappChannelMutation) SetWaName(s string) {
  38196. m.wa_name = &s
  38197. }
  38198. // WaName returns the value of the "wa_name" field in the mutation.
  38199. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  38200. v := m.wa_name
  38201. if v == nil {
  38202. return
  38203. }
  38204. return *v, true
  38205. }
  38206. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  38207. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38209. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  38210. if !m.op.Is(OpUpdateOne) {
  38211. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  38212. }
  38213. if m.id == nil || m.oldValue == nil {
  38214. return v, errors.New("OldWaName requires an ID field in the mutation")
  38215. }
  38216. oldValue, err := m.oldValue(ctx)
  38217. if err != nil {
  38218. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  38219. }
  38220. return oldValue.WaName, nil
  38221. }
  38222. // ClearWaName clears the value of the "wa_name" field.
  38223. func (m *WhatsappChannelMutation) ClearWaName() {
  38224. m.wa_name = nil
  38225. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  38226. }
  38227. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  38228. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  38229. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  38230. return ok
  38231. }
  38232. // ResetWaName resets all changes to the "wa_name" field.
  38233. func (m *WhatsappChannelMutation) ResetWaName() {
  38234. m.wa_name = nil
  38235. delete(m.clearedFields, whatsappchannel.FieldWaName)
  38236. }
  38237. // SetWabaID sets the "waba_id" field.
  38238. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  38239. m.waba_id = &u
  38240. m.addwaba_id = nil
  38241. }
  38242. // WabaID returns the value of the "waba_id" field in the mutation.
  38243. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  38244. v := m.waba_id
  38245. if v == nil {
  38246. return
  38247. }
  38248. return *v, true
  38249. }
  38250. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  38251. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38253. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  38254. if !m.op.Is(OpUpdateOne) {
  38255. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  38256. }
  38257. if m.id == nil || m.oldValue == nil {
  38258. return v, errors.New("OldWabaID requires an ID field in the mutation")
  38259. }
  38260. oldValue, err := m.oldValue(ctx)
  38261. if err != nil {
  38262. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  38263. }
  38264. return oldValue.WabaID, nil
  38265. }
  38266. // AddWabaID adds u to the "waba_id" field.
  38267. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  38268. if m.addwaba_id != nil {
  38269. *m.addwaba_id += u
  38270. } else {
  38271. m.addwaba_id = &u
  38272. }
  38273. }
  38274. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  38275. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  38276. v := m.addwaba_id
  38277. if v == nil {
  38278. return
  38279. }
  38280. return *v, true
  38281. }
  38282. // ResetWabaID resets all changes to the "waba_id" field.
  38283. func (m *WhatsappChannelMutation) ResetWabaID() {
  38284. m.waba_id = nil
  38285. m.addwaba_id = nil
  38286. }
  38287. // SetBusinessID sets the "business_id" field.
  38288. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  38289. m.business_id = &u
  38290. m.addbusiness_id = nil
  38291. }
  38292. // BusinessID returns the value of the "business_id" field in the mutation.
  38293. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  38294. v := m.business_id
  38295. if v == nil {
  38296. return
  38297. }
  38298. return *v, true
  38299. }
  38300. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  38301. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38303. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  38304. if !m.op.Is(OpUpdateOne) {
  38305. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  38306. }
  38307. if m.id == nil || m.oldValue == nil {
  38308. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  38309. }
  38310. oldValue, err := m.oldValue(ctx)
  38311. if err != nil {
  38312. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  38313. }
  38314. return oldValue.BusinessID, nil
  38315. }
  38316. // AddBusinessID adds u to the "business_id" field.
  38317. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  38318. if m.addbusiness_id != nil {
  38319. *m.addbusiness_id += u
  38320. } else {
  38321. m.addbusiness_id = &u
  38322. }
  38323. }
  38324. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  38325. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  38326. v := m.addbusiness_id
  38327. if v == nil {
  38328. return
  38329. }
  38330. return *v, true
  38331. }
  38332. // ResetBusinessID resets all changes to the "business_id" field.
  38333. func (m *WhatsappChannelMutation) ResetBusinessID() {
  38334. m.business_id = nil
  38335. m.addbusiness_id = nil
  38336. }
  38337. // SetOrganizationID sets the "organization_id" field.
  38338. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  38339. m.organization_id = &u
  38340. m.addorganization_id = nil
  38341. }
  38342. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38343. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  38344. v := m.organization_id
  38345. if v == nil {
  38346. return
  38347. }
  38348. return *v, true
  38349. }
  38350. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  38351. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38353. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38354. if !m.op.Is(OpUpdateOne) {
  38355. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38356. }
  38357. if m.id == nil || m.oldValue == nil {
  38358. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38359. }
  38360. oldValue, err := m.oldValue(ctx)
  38361. if err != nil {
  38362. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38363. }
  38364. return oldValue.OrganizationID, nil
  38365. }
  38366. // AddOrganizationID adds u to the "organization_id" field.
  38367. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  38368. if m.addorganization_id != nil {
  38369. *m.addorganization_id += u
  38370. } else {
  38371. m.addorganization_id = &u
  38372. }
  38373. }
  38374. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38375. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  38376. v := m.addorganization_id
  38377. if v == nil {
  38378. return
  38379. }
  38380. return *v, true
  38381. }
  38382. // ClearOrganizationID clears the value of the "organization_id" field.
  38383. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  38384. m.organization_id = nil
  38385. m.addorganization_id = nil
  38386. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  38387. }
  38388. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38389. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  38390. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  38391. return ok
  38392. }
  38393. // ResetOrganizationID resets all changes to the "organization_id" field.
  38394. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  38395. m.organization_id = nil
  38396. m.addorganization_id = nil
  38397. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  38398. }
  38399. // SetVerifyAccount sets the "verify_account" field.
  38400. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  38401. m.verify_account = &s
  38402. }
  38403. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  38404. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  38405. v := m.verify_account
  38406. if v == nil {
  38407. return
  38408. }
  38409. return *v, true
  38410. }
  38411. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  38412. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38414. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  38415. if !m.op.Is(OpUpdateOne) {
  38416. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  38417. }
  38418. if m.id == nil || m.oldValue == nil {
  38419. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  38420. }
  38421. oldValue, err := m.oldValue(ctx)
  38422. if err != nil {
  38423. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  38424. }
  38425. return oldValue.VerifyAccount, nil
  38426. }
  38427. // ResetVerifyAccount resets all changes to the "verify_account" field.
  38428. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  38429. m.verify_account = nil
  38430. }
  38431. // Where appends a list predicates to the WhatsappChannelMutation builder.
  38432. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  38433. m.predicates = append(m.predicates, ps...)
  38434. }
  38435. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  38436. // users can use type-assertion to append predicates that do not depend on any generated package.
  38437. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  38438. p := make([]predicate.WhatsappChannel, len(ps))
  38439. for i := range ps {
  38440. p[i] = ps[i]
  38441. }
  38442. m.Where(p...)
  38443. }
  38444. // Op returns the operation name.
  38445. func (m *WhatsappChannelMutation) Op() Op {
  38446. return m.op
  38447. }
  38448. // SetOp allows setting the mutation operation.
  38449. func (m *WhatsappChannelMutation) SetOp(op Op) {
  38450. m.op = op
  38451. }
  38452. // Type returns the node type of this mutation (WhatsappChannel).
  38453. func (m *WhatsappChannelMutation) Type() string {
  38454. return m.typ
  38455. }
  38456. // Fields returns all fields that were changed during this mutation. Note that in
  38457. // order to get all numeric fields that were incremented/decremented, call
  38458. // AddedFields().
  38459. func (m *WhatsappChannelMutation) Fields() []string {
  38460. fields := make([]string, 0, 12)
  38461. if m.created_at != nil {
  38462. fields = append(fields, whatsappchannel.FieldCreatedAt)
  38463. }
  38464. if m.updated_at != nil {
  38465. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  38466. }
  38467. if m.status != nil {
  38468. fields = append(fields, whatsappchannel.FieldStatus)
  38469. }
  38470. if m.deleted_at != nil {
  38471. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38472. }
  38473. if m.ak != nil {
  38474. fields = append(fields, whatsappchannel.FieldAk)
  38475. }
  38476. if m.sk != nil {
  38477. fields = append(fields, whatsappchannel.FieldSk)
  38478. }
  38479. if m.wa_id != nil {
  38480. fields = append(fields, whatsappchannel.FieldWaID)
  38481. }
  38482. if m.wa_name != nil {
  38483. fields = append(fields, whatsappchannel.FieldWaName)
  38484. }
  38485. if m.waba_id != nil {
  38486. fields = append(fields, whatsappchannel.FieldWabaID)
  38487. }
  38488. if m.business_id != nil {
  38489. fields = append(fields, whatsappchannel.FieldBusinessID)
  38490. }
  38491. if m.organization_id != nil {
  38492. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38493. }
  38494. if m.verify_account != nil {
  38495. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  38496. }
  38497. return fields
  38498. }
  38499. // Field returns the value of a field with the given name. The second boolean
  38500. // return value indicates that this field was not set, or was not defined in the
  38501. // schema.
  38502. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  38503. switch name {
  38504. case whatsappchannel.FieldCreatedAt:
  38505. return m.CreatedAt()
  38506. case whatsappchannel.FieldUpdatedAt:
  38507. return m.UpdatedAt()
  38508. case whatsappchannel.FieldStatus:
  38509. return m.Status()
  38510. case whatsappchannel.FieldDeletedAt:
  38511. return m.DeletedAt()
  38512. case whatsappchannel.FieldAk:
  38513. return m.Ak()
  38514. case whatsappchannel.FieldSk:
  38515. return m.Sk()
  38516. case whatsappchannel.FieldWaID:
  38517. return m.WaID()
  38518. case whatsappchannel.FieldWaName:
  38519. return m.WaName()
  38520. case whatsappchannel.FieldWabaID:
  38521. return m.WabaID()
  38522. case whatsappchannel.FieldBusinessID:
  38523. return m.BusinessID()
  38524. case whatsappchannel.FieldOrganizationID:
  38525. return m.OrganizationID()
  38526. case whatsappchannel.FieldVerifyAccount:
  38527. return m.VerifyAccount()
  38528. }
  38529. return nil, false
  38530. }
  38531. // OldField returns the old value of the field from the database. An error is
  38532. // returned if the mutation operation is not UpdateOne, or the query to the
  38533. // database failed.
  38534. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38535. switch name {
  38536. case whatsappchannel.FieldCreatedAt:
  38537. return m.OldCreatedAt(ctx)
  38538. case whatsappchannel.FieldUpdatedAt:
  38539. return m.OldUpdatedAt(ctx)
  38540. case whatsappchannel.FieldStatus:
  38541. return m.OldStatus(ctx)
  38542. case whatsappchannel.FieldDeletedAt:
  38543. return m.OldDeletedAt(ctx)
  38544. case whatsappchannel.FieldAk:
  38545. return m.OldAk(ctx)
  38546. case whatsappchannel.FieldSk:
  38547. return m.OldSk(ctx)
  38548. case whatsappchannel.FieldWaID:
  38549. return m.OldWaID(ctx)
  38550. case whatsappchannel.FieldWaName:
  38551. return m.OldWaName(ctx)
  38552. case whatsappchannel.FieldWabaID:
  38553. return m.OldWabaID(ctx)
  38554. case whatsappchannel.FieldBusinessID:
  38555. return m.OldBusinessID(ctx)
  38556. case whatsappchannel.FieldOrganizationID:
  38557. return m.OldOrganizationID(ctx)
  38558. case whatsappchannel.FieldVerifyAccount:
  38559. return m.OldVerifyAccount(ctx)
  38560. }
  38561. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  38562. }
  38563. // SetField sets the value of a field with the given name. It returns an error if
  38564. // the field is not defined in the schema, or if the type mismatched the field
  38565. // type.
  38566. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  38567. switch name {
  38568. case whatsappchannel.FieldCreatedAt:
  38569. v, ok := value.(time.Time)
  38570. if !ok {
  38571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38572. }
  38573. m.SetCreatedAt(v)
  38574. return nil
  38575. case whatsappchannel.FieldUpdatedAt:
  38576. v, ok := value.(time.Time)
  38577. if !ok {
  38578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38579. }
  38580. m.SetUpdatedAt(v)
  38581. return nil
  38582. case whatsappchannel.FieldStatus:
  38583. v, ok := value.(uint8)
  38584. if !ok {
  38585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38586. }
  38587. m.SetStatus(v)
  38588. return nil
  38589. case whatsappchannel.FieldDeletedAt:
  38590. v, ok := value.(time.Time)
  38591. if !ok {
  38592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38593. }
  38594. m.SetDeletedAt(v)
  38595. return nil
  38596. case whatsappchannel.FieldAk:
  38597. v, ok := value.(string)
  38598. if !ok {
  38599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38600. }
  38601. m.SetAk(v)
  38602. return nil
  38603. case whatsappchannel.FieldSk:
  38604. v, ok := value.(string)
  38605. if !ok {
  38606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38607. }
  38608. m.SetSk(v)
  38609. return nil
  38610. case whatsappchannel.FieldWaID:
  38611. v, ok := value.(string)
  38612. if !ok {
  38613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38614. }
  38615. m.SetWaID(v)
  38616. return nil
  38617. case whatsappchannel.FieldWaName:
  38618. v, ok := value.(string)
  38619. if !ok {
  38620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38621. }
  38622. m.SetWaName(v)
  38623. return nil
  38624. case whatsappchannel.FieldWabaID:
  38625. v, ok := value.(uint64)
  38626. if !ok {
  38627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38628. }
  38629. m.SetWabaID(v)
  38630. return nil
  38631. case whatsappchannel.FieldBusinessID:
  38632. v, ok := value.(uint64)
  38633. if !ok {
  38634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38635. }
  38636. m.SetBusinessID(v)
  38637. return nil
  38638. case whatsappchannel.FieldOrganizationID:
  38639. v, ok := value.(uint64)
  38640. if !ok {
  38641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38642. }
  38643. m.SetOrganizationID(v)
  38644. return nil
  38645. case whatsappchannel.FieldVerifyAccount:
  38646. v, ok := value.(string)
  38647. if !ok {
  38648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38649. }
  38650. m.SetVerifyAccount(v)
  38651. return nil
  38652. }
  38653. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38654. }
  38655. // AddedFields returns all numeric fields that were incremented/decremented during
  38656. // this mutation.
  38657. func (m *WhatsappChannelMutation) AddedFields() []string {
  38658. var fields []string
  38659. if m.addstatus != nil {
  38660. fields = append(fields, whatsappchannel.FieldStatus)
  38661. }
  38662. if m.addwaba_id != nil {
  38663. fields = append(fields, whatsappchannel.FieldWabaID)
  38664. }
  38665. if m.addbusiness_id != nil {
  38666. fields = append(fields, whatsappchannel.FieldBusinessID)
  38667. }
  38668. if m.addorganization_id != nil {
  38669. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38670. }
  38671. return fields
  38672. }
  38673. // AddedField returns the numeric value that was incremented/decremented on a field
  38674. // with the given name. The second boolean return value indicates that this field
  38675. // was not set, or was not defined in the schema.
  38676. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  38677. switch name {
  38678. case whatsappchannel.FieldStatus:
  38679. return m.AddedStatus()
  38680. case whatsappchannel.FieldWabaID:
  38681. return m.AddedWabaID()
  38682. case whatsappchannel.FieldBusinessID:
  38683. return m.AddedBusinessID()
  38684. case whatsappchannel.FieldOrganizationID:
  38685. return m.AddedOrganizationID()
  38686. }
  38687. return nil, false
  38688. }
  38689. // AddField adds the value to the field with the given name. It returns an error if
  38690. // the field is not defined in the schema, or if the type mismatched the field
  38691. // type.
  38692. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  38693. switch name {
  38694. case whatsappchannel.FieldStatus:
  38695. v, ok := value.(int8)
  38696. if !ok {
  38697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38698. }
  38699. m.AddStatus(v)
  38700. return nil
  38701. case whatsappchannel.FieldWabaID:
  38702. v, ok := value.(int64)
  38703. if !ok {
  38704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38705. }
  38706. m.AddWabaID(v)
  38707. return nil
  38708. case whatsappchannel.FieldBusinessID:
  38709. v, ok := value.(int64)
  38710. if !ok {
  38711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38712. }
  38713. m.AddBusinessID(v)
  38714. return nil
  38715. case whatsappchannel.FieldOrganizationID:
  38716. v, ok := value.(int64)
  38717. if !ok {
  38718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38719. }
  38720. m.AddOrganizationID(v)
  38721. return nil
  38722. }
  38723. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  38724. }
  38725. // ClearedFields returns all nullable fields that were cleared during this
  38726. // mutation.
  38727. func (m *WhatsappChannelMutation) ClearedFields() []string {
  38728. var fields []string
  38729. if m.FieldCleared(whatsappchannel.FieldStatus) {
  38730. fields = append(fields, whatsappchannel.FieldStatus)
  38731. }
  38732. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  38733. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38734. }
  38735. if m.FieldCleared(whatsappchannel.FieldAk) {
  38736. fields = append(fields, whatsappchannel.FieldAk)
  38737. }
  38738. if m.FieldCleared(whatsappchannel.FieldWaID) {
  38739. fields = append(fields, whatsappchannel.FieldWaID)
  38740. }
  38741. if m.FieldCleared(whatsappchannel.FieldWaName) {
  38742. fields = append(fields, whatsappchannel.FieldWaName)
  38743. }
  38744. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  38745. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38746. }
  38747. return fields
  38748. }
  38749. // FieldCleared returns a boolean indicating if a field with the given name was
  38750. // cleared in this mutation.
  38751. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  38752. _, ok := m.clearedFields[name]
  38753. return ok
  38754. }
  38755. // ClearField clears the value of the field with the given name. It returns an
  38756. // error if the field is not defined in the schema.
  38757. func (m *WhatsappChannelMutation) ClearField(name string) error {
  38758. switch name {
  38759. case whatsappchannel.FieldStatus:
  38760. m.ClearStatus()
  38761. return nil
  38762. case whatsappchannel.FieldDeletedAt:
  38763. m.ClearDeletedAt()
  38764. return nil
  38765. case whatsappchannel.FieldAk:
  38766. m.ClearAk()
  38767. return nil
  38768. case whatsappchannel.FieldWaID:
  38769. m.ClearWaID()
  38770. return nil
  38771. case whatsappchannel.FieldWaName:
  38772. m.ClearWaName()
  38773. return nil
  38774. case whatsappchannel.FieldOrganizationID:
  38775. m.ClearOrganizationID()
  38776. return nil
  38777. }
  38778. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  38779. }
  38780. // ResetField resets all changes in the mutation for the field with the given name.
  38781. // It returns an error if the field is not defined in the schema.
  38782. func (m *WhatsappChannelMutation) ResetField(name string) error {
  38783. switch name {
  38784. case whatsappchannel.FieldCreatedAt:
  38785. m.ResetCreatedAt()
  38786. return nil
  38787. case whatsappchannel.FieldUpdatedAt:
  38788. m.ResetUpdatedAt()
  38789. return nil
  38790. case whatsappchannel.FieldStatus:
  38791. m.ResetStatus()
  38792. return nil
  38793. case whatsappchannel.FieldDeletedAt:
  38794. m.ResetDeletedAt()
  38795. return nil
  38796. case whatsappchannel.FieldAk:
  38797. m.ResetAk()
  38798. return nil
  38799. case whatsappchannel.FieldSk:
  38800. m.ResetSk()
  38801. return nil
  38802. case whatsappchannel.FieldWaID:
  38803. m.ResetWaID()
  38804. return nil
  38805. case whatsappchannel.FieldWaName:
  38806. m.ResetWaName()
  38807. return nil
  38808. case whatsappchannel.FieldWabaID:
  38809. m.ResetWabaID()
  38810. return nil
  38811. case whatsappchannel.FieldBusinessID:
  38812. m.ResetBusinessID()
  38813. return nil
  38814. case whatsappchannel.FieldOrganizationID:
  38815. m.ResetOrganizationID()
  38816. return nil
  38817. case whatsappchannel.FieldVerifyAccount:
  38818. m.ResetVerifyAccount()
  38819. return nil
  38820. }
  38821. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38822. }
  38823. // AddedEdges returns all edge names that were set/added in this mutation.
  38824. func (m *WhatsappChannelMutation) AddedEdges() []string {
  38825. edges := make([]string, 0, 0)
  38826. return edges
  38827. }
  38828. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38829. // name in this mutation.
  38830. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  38831. return nil
  38832. }
  38833. // RemovedEdges returns all edge names that were removed in this mutation.
  38834. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  38835. edges := make([]string, 0, 0)
  38836. return edges
  38837. }
  38838. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38839. // the given name in this mutation.
  38840. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  38841. return nil
  38842. }
  38843. // ClearedEdges returns all edge names that were cleared in this mutation.
  38844. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  38845. edges := make([]string, 0, 0)
  38846. return edges
  38847. }
  38848. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38849. // was cleared in this mutation.
  38850. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  38851. return false
  38852. }
  38853. // ClearEdge clears the value of the edge with the given name. It returns an error
  38854. // if that edge is not defined in the schema.
  38855. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  38856. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  38857. }
  38858. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38859. // It returns an error if the edge is not defined in the schema.
  38860. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  38861. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  38862. }
  38863. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  38864. type WorkExperienceMutation struct {
  38865. config
  38866. op Op
  38867. typ string
  38868. id *uint64
  38869. created_at *time.Time
  38870. updated_at *time.Time
  38871. deleted_at *time.Time
  38872. start_date *time.Time
  38873. end_date *time.Time
  38874. company *string
  38875. experience *string
  38876. organization_id *uint64
  38877. addorganization_id *int64
  38878. clearedFields map[string]struct{}
  38879. employee *uint64
  38880. clearedemployee bool
  38881. done bool
  38882. oldValue func(context.Context) (*WorkExperience, error)
  38883. predicates []predicate.WorkExperience
  38884. }
  38885. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  38886. // workexperienceOption allows management of the mutation configuration using functional options.
  38887. type workexperienceOption func(*WorkExperienceMutation)
  38888. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  38889. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  38890. m := &WorkExperienceMutation{
  38891. config: c,
  38892. op: op,
  38893. typ: TypeWorkExperience,
  38894. clearedFields: make(map[string]struct{}),
  38895. }
  38896. for _, opt := range opts {
  38897. opt(m)
  38898. }
  38899. return m
  38900. }
  38901. // withWorkExperienceID sets the ID field of the mutation.
  38902. func withWorkExperienceID(id uint64) workexperienceOption {
  38903. return func(m *WorkExperienceMutation) {
  38904. var (
  38905. err error
  38906. once sync.Once
  38907. value *WorkExperience
  38908. )
  38909. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  38910. once.Do(func() {
  38911. if m.done {
  38912. err = errors.New("querying old values post mutation is not allowed")
  38913. } else {
  38914. value, err = m.Client().WorkExperience.Get(ctx, id)
  38915. }
  38916. })
  38917. return value, err
  38918. }
  38919. m.id = &id
  38920. }
  38921. }
  38922. // withWorkExperience sets the old WorkExperience of the mutation.
  38923. func withWorkExperience(node *WorkExperience) workexperienceOption {
  38924. return func(m *WorkExperienceMutation) {
  38925. m.oldValue = func(context.Context) (*WorkExperience, error) {
  38926. return node, nil
  38927. }
  38928. m.id = &node.ID
  38929. }
  38930. }
  38931. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38932. // executed in a transaction (ent.Tx), a transactional client is returned.
  38933. func (m WorkExperienceMutation) Client() *Client {
  38934. client := &Client{config: m.config}
  38935. client.init()
  38936. return client
  38937. }
  38938. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38939. // it returns an error otherwise.
  38940. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  38941. if _, ok := m.driver.(*txDriver); !ok {
  38942. return nil, errors.New("ent: mutation is not running in a transaction")
  38943. }
  38944. tx := &Tx{config: m.config}
  38945. tx.init()
  38946. return tx, nil
  38947. }
  38948. // SetID sets the value of the id field. Note that this
  38949. // operation is only accepted on creation of WorkExperience entities.
  38950. func (m *WorkExperienceMutation) SetID(id uint64) {
  38951. m.id = &id
  38952. }
  38953. // ID returns the ID value in the mutation. Note that the ID is only available
  38954. // if it was provided to the builder or after it was returned from the database.
  38955. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  38956. if m.id == nil {
  38957. return
  38958. }
  38959. return *m.id, true
  38960. }
  38961. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38962. // That means, if the mutation is applied within a transaction with an isolation level such
  38963. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38964. // or updated by the mutation.
  38965. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  38966. switch {
  38967. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38968. id, exists := m.ID()
  38969. if exists {
  38970. return []uint64{id}, nil
  38971. }
  38972. fallthrough
  38973. case m.op.Is(OpUpdate | OpDelete):
  38974. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  38975. default:
  38976. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38977. }
  38978. }
  38979. // SetCreatedAt sets the "created_at" field.
  38980. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  38981. m.created_at = &t
  38982. }
  38983. // CreatedAt returns the value of the "created_at" field in the mutation.
  38984. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  38985. v := m.created_at
  38986. if v == nil {
  38987. return
  38988. }
  38989. return *v, true
  38990. }
  38991. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  38992. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38994. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38995. if !m.op.Is(OpUpdateOne) {
  38996. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38997. }
  38998. if m.id == nil || m.oldValue == nil {
  38999. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39000. }
  39001. oldValue, err := m.oldValue(ctx)
  39002. if err != nil {
  39003. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39004. }
  39005. return oldValue.CreatedAt, nil
  39006. }
  39007. // ResetCreatedAt resets all changes to the "created_at" field.
  39008. func (m *WorkExperienceMutation) ResetCreatedAt() {
  39009. m.created_at = nil
  39010. }
  39011. // SetUpdatedAt sets the "updated_at" field.
  39012. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  39013. m.updated_at = &t
  39014. }
  39015. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39016. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  39017. v := m.updated_at
  39018. if v == nil {
  39019. return
  39020. }
  39021. return *v, true
  39022. }
  39023. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  39024. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39026. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39027. if !m.op.Is(OpUpdateOne) {
  39028. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39029. }
  39030. if m.id == nil || m.oldValue == nil {
  39031. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39032. }
  39033. oldValue, err := m.oldValue(ctx)
  39034. if err != nil {
  39035. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39036. }
  39037. return oldValue.UpdatedAt, nil
  39038. }
  39039. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39040. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  39041. m.updated_at = nil
  39042. }
  39043. // SetDeletedAt sets the "deleted_at" field.
  39044. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  39045. m.deleted_at = &t
  39046. }
  39047. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39048. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  39049. v := m.deleted_at
  39050. if v == nil {
  39051. return
  39052. }
  39053. return *v, true
  39054. }
  39055. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  39056. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39058. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39059. if !m.op.Is(OpUpdateOne) {
  39060. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39061. }
  39062. if m.id == nil || m.oldValue == nil {
  39063. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39064. }
  39065. oldValue, err := m.oldValue(ctx)
  39066. if err != nil {
  39067. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39068. }
  39069. return oldValue.DeletedAt, nil
  39070. }
  39071. // ClearDeletedAt clears the value of the "deleted_at" field.
  39072. func (m *WorkExperienceMutation) ClearDeletedAt() {
  39073. m.deleted_at = nil
  39074. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  39075. }
  39076. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39077. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  39078. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  39079. return ok
  39080. }
  39081. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39082. func (m *WorkExperienceMutation) ResetDeletedAt() {
  39083. m.deleted_at = nil
  39084. delete(m.clearedFields, workexperience.FieldDeletedAt)
  39085. }
  39086. // SetEmployeeID sets the "employee_id" field.
  39087. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  39088. m.employee = &u
  39089. }
  39090. // EmployeeID returns the value of the "employee_id" field in the mutation.
  39091. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  39092. v := m.employee
  39093. if v == nil {
  39094. return
  39095. }
  39096. return *v, true
  39097. }
  39098. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  39099. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39101. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  39102. if !m.op.Is(OpUpdateOne) {
  39103. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  39104. }
  39105. if m.id == nil || m.oldValue == nil {
  39106. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  39107. }
  39108. oldValue, err := m.oldValue(ctx)
  39109. if err != nil {
  39110. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  39111. }
  39112. return oldValue.EmployeeID, nil
  39113. }
  39114. // ResetEmployeeID resets all changes to the "employee_id" field.
  39115. func (m *WorkExperienceMutation) ResetEmployeeID() {
  39116. m.employee = nil
  39117. }
  39118. // SetStartDate sets the "start_date" field.
  39119. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  39120. m.start_date = &t
  39121. }
  39122. // StartDate returns the value of the "start_date" field in the mutation.
  39123. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  39124. v := m.start_date
  39125. if v == nil {
  39126. return
  39127. }
  39128. return *v, true
  39129. }
  39130. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  39131. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39133. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  39134. if !m.op.Is(OpUpdateOne) {
  39135. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  39136. }
  39137. if m.id == nil || m.oldValue == nil {
  39138. return v, errors.New("OldStartDate requires an ID field in the mutation")
  39139. }
  39140. oldValue, err := m.oldValue(ctx)
  39141. if err != nil {
  39142. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  39143. }
  39144. return oldValue.StartDate, nil
  39145. }
  39146. // ResetStartDate resets all changes to the "start_date" field.
  39147. func (m *WorkExperienceMutation) ResetStartDate() {
  39148. m.start_date = nil
  39149. }
  39150. // SetEndDate sets the "end_date" field.
  39151. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  39152. m.end_date = &t
  39153. }
  39154. // EndDate returns the value of the "end_date" field in the mutation.
  39155. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  39156. v := m.end_date
  39157. if v == nil {
  39158. return
  39159. }
  39160. return *v, true
  39161. }
  39162. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  39163. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39165. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  39166. if !m.op.Is(OpUpdateOne) {
  39167. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  39168. }
  39169. if m.id == nil || m.oldValue == nil {
  39170. return v, errors.New("OldEndDate requires an ID field in the mutation")
  39171. }
  39172. oldValue, err := m.oldValue(ctx)
  39173. if err != nil {
  39174. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  39175. }
  39176. return oldValue.EndDate, nil
  39177. }
  39178. // ResetEndDate resets all changes to the "end_date" field.
  39179. func (m *WorkExperienceMutation) ResetEndDate() {
  39180. m.end_date = nil
  39181. }
  39182. // SetCompany sets the "company" field.
  39183. func (m *WorkExperienceMutation) SetCompany(s string) {
  39184. m.company = &s
  39185. }
  39186. // Company returns the value of the "company" field in the mutation.
  39187. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  39188. v := m.company
  39189. if v == nil {
  39190. return
  39191. }
  39192. return *v, true
  39193. }
  39194. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  39195. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39197. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  39198. if !m.op.Is(OpUpdateOne) {
  39199. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39200. }
  39201. if m.id == nil || m.oldValue == nil {
  39202. return v, errors.New("OldCompany requires an ID field in the mutation")
  39203. }
  39204. oldValue, err := m.oldValue(ctx)
  39205. if err != nil {
  39206. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39207. }
  39208. return oldValue.Company, nil
  39209. }
  39210. // ResetCompany resets all changes to the "company" field.
  39211. func (m *WorkExperienceMutation) ResetCompany() {
  39212. m.company = nil
  39213. }
  39214. // SetExperience sets the "experience" field.
  39215. func (m *WorkExperienceMutation) SetExperience(s string) {
  39216. m.experience = &s
  39217. }
  39218. // Experience returns the value of the "experience" field in the mutation.
  39219. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  39220. v := m.experience
  39221. if v == nil {
  39222. return
  39223. }
  39224. return *v, true
  39225. }
  39226. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  39227. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39229. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  39230. if !m.op.Is(OpUpdateOne) {
  39231. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  39232. }
  39233. if m.id == nil || m.oldValue == nil {
  39234. return v, errors.New("OldExperience requires an ID field in the mutation")
  39235. }
  39236. oldValue, err := m.oldValue(ctx)
  39237. if err != nil {
  39238. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  39239. }
  39240. return oldValue.Experience, nil
  39241. }
  39242. // ResetExperience resets all changes to the "experience" field.
  39243. func (m *WorkExperienceMutation) ResetExperience() {
  39244. m.experience = nil
  39245. }
  39246. // SetOrganizationID sets the "organization_id" field.
  39247. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  39248. m.organization_id = &u
  39249. m.addorganization_id = nil
  39250. }
  39251. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39252. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  39253. v := m.organization_id
  39254. if v == nil {
  39255. return
  39256. }
  39257. return *v, true
  39258. }
  39259. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  39260. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39262. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39263. if !m.op.Is(OpUpdateOne) {
  39264. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39265. }
  39266. if m.id == nil || m.oldValue == nil {
  39267. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39268. }
  39269. oldValue, err := m.oldValue(ctx)
  39270. if err != nil {
  39271. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39272. }
  39273. return oldValue.OrganizationID, nil
  39274. }
  39275. // AddOrganizationID adds u to the "organization_id" field.
  39276. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  39277. if m.addorganization_id != nil {
  39278. *m.addorganization_id += u
  39279. } else {
  39280. m.addorganization_id = &u
  39281. }
  39282. }
  39283. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39284. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  39285. v := m.addorganization_id
  39286. if v == nil {
  39287. return
  39288. }
  39289. return *v, true
  39290. }
  39291. // ResetOrganizationID resets all changes to the "organization_id" field.
  39292. func (m *WorkExperienceMutation) ResetOrganizationID() {
  39293. m.organization_id = nil
  39294. m.addorganization_id = nil
  39295. }
  39296. // ClearEmployee clears the "employee" edge to the Employee entity.
  39297. func (m *WorkExperienceMutation) ClearEmployee() {
  39298. m.clearedemployee = true
  39299. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  39300. }
  39301. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  39302. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  39303. return m.clearedemployee
  39304. }
  39305. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  39306. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39307. // EmployeeID instead. It exists only for internal usage by the builders.
  39308. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  39309. if id := m.employee; id != nil {
  39310. ids = append(ids, *id)
  39311. }
  39312. return
  39313. }
  39314. // ResetEmployee resets all changes to the "employee" edge.
  39315. func (m *WorkExperienceMutation) ResetEmployee() {
  39316. m.employee = nil
  39317. m.clearedemployee = false
  39318. }
  39319. // Where appends a list predicates to the WorkExperienceMutation builder.
  39320. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  39321. m.predicates = append(m.predicates, ps...)
  39322. }
  39323. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  39324. // users can use type-assertion to append predicates that do not depend on any generated package.
  39325. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  39326. p := make([]predicate.WorkExperience, len(ps))
  39327. for i := range ps {
  39328. p[i] = ps[i]
  39329. }
  39330. m.Where(p...)
  39331. }
  39332. // Op returns the operation name.
  39333. func (m *WorkExperienceMutation) Op() Op {
  39334. return m.op
  39335. }
  39336. // SetOp allows setting the mutation operation.
  39337. func (m *WorkExperienceMutation) SetOp(op Op) {
  39338. m.op = op
  39339. }
  39340. // Type returns the node type of this mutation (WorkExperience).
  39341. func (m *WorkExperienceMutation) Type() string {
  39342. return m.typ
  39343. }
  39344. // Fields returns all fields that were changed during this mutation. Note that in
  39345. // order to get all numeric fields that were incremented/decremented, call
  39346. // AddedFields().
  39347. func (m *WorkExperienceMutation) Fields() []string {
  39348. fields := make([]string, 0, 9)
  39349. if m.created_at != nil {
  39350. fields = append(fields, workexperience.FieldCreatedAt)
  39351. }
  39352. if m.updated_at != nil {
  39353. fields = append(fields, workexperience.FieldUpdatedAt)
  39354. }
  39355. if m.deleted_at != nil {
  39356. fields = append(fields, workexperience.FieldDeletedAt)
  39357. }
  39358. if m.employee != nil {
  39359. fields = append(fields, workexperience.FieldEmployeeID)
  39360. }
  39361. if m.start_date != nil {
  39362. fields = append(fields, workexperience.FieldStartDate)
  39363. }
  39364. if m.end_date != nil {
  39365. fields = append(fields, workexperience.FieldEndDate)
  39366. }
  39367. if m.company != nil {
  39368. fields = append(fields, workexperience.FieldCompany)
  39369. }
  39370. if m.experience != nil {
  39371. fields = append(fields, workexperience.FieldExperience)
  39372. }
  39373. if m.organization_id != nil {
  39374. fields = append(fields, workexperience.FieldOrganizationID)
  39375. }
  39376. return fields
  39377. }
  39378. // Field returns the value of a field with the given name. The second boolean
  39379. // return value indicates that this field was not set, or was not defined in the
  39380. // schema.
  39381. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  39382. switch name {
  39383. case workexperience.FieldCreatedAt:
  39384. return m.CreatedAt()
  39385. case workexperience.FieldUpdatedAt:
  39386. return m.UpdatedAt()
  39387. case workexperience.FieldDeletedAt:
  39388. return m.DeletedAt()
  39389. case workexperience.FieldEmployeeID:
  39390. return m.EmployeeID()
  39391. case workexperience.FieldStartDate:
  39392. return m.StartDate()
  39393. case workexperience.FieldEndDate:
  39394. return m.EndDate()
  39395. case workexperience.FieldCompany:
  39396. return m.Company()
  39397. case workexperience.FieldExperience:
  39398. return m.Experience()
  39399. case workexperience.FieldOrganizationID:
  39400. return m.OrganizationID()
  39401. }
  39402. return nil, false
  39403. }
  39404. // OldField returns the old value of the field from the database. An error is
  39405. // returned if the mutation operation is not UpdateOne, or the query to the
  39406. // database failed.
  39407. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39408. switch name {
  39409. case workexperience.FieldCreatedAt:
  39410. return m.OldCreatedAt(ctx)
  39411. case workexperience.FieldUpdatedAt:
  39412. return m.OldUpdatedAt(ctx)
  39413. case workexperience.FieldDeletedAt:
  39414. return m.OldDeletedAt(ctx)
  39415. case workexperience.FieldEmployeeID:
  39416. return m.OldEmployeeID(ctx)
  39417. case workexperience.FieldStartDate:
  39418. return m.OldStartDate(ctx)
  39419. case workexperience.FieldEndDate:
  39420. return m.OldEndDate(ctx)
  39421. case workexperience.FieldCompany:
  39422. return m.OldCompany(ctx)
  39423. case workexperience.FieldExperience:
  39424. return m.OldExperience(ctx)
  39425. case workexperience.FieldOrganizationID:
  39426. return m.OldOrganizationID(ctx)
  39427. }
  39428. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  39429. }
  39430. // SetField sets the value of a field with the given name. It returns an error if
  39431. // the field is not defined in the schema, or if the type mismatched the field
  39432. // type.
  39433. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  39434. switch name {
  39435. case workexperience.FieldCreatedAt:
  39436. v, ok := value.(time.Time)
  39437. if !ok {
  39438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39439. }
  39440. m.SetCreatedAt(v)
  39441. return nil
  39442. case workexperience.FieldUpdatedAt:
  39443. v, ok := value.(time.Time)
  39444. if !ok {
  39445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39446. }
  39447. m.SetUpdatedAt(v)
  39448. return nil
  39449. case workexperience.FieldDeletedAt:
  39450. v, ok := value.(time.Time)
  39451. if !ok {
  39452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39453. }
  39454. m.SetDeletedAt(v)
  39455. return nil
  39456. case workexperience.FieldEmployeeID:
  39457. v, ok := value.(uint64)
  39458. if !ok {
  39459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39460. }
  39461. m.SetEmployeeID(v)
  39462. return nil
  39463. case workexperience.FieldStartDate:
  39464. v, ok := value.(time.Time)
  39465. if !ok {
  39466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39467. }
  39468. m.SetStartDate(v)
  39469. return nil
  39470. case workexperience.FieldEndDate:
  39471. v, ok := value.(time.Time)
  39472. if !ok {
  39473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39474. }
  39475. m.SetEndDate(v)
  39476. return nil
  39477. case workexperience.FieldCompany:
  39478. v, ok := value.(string)
  39479. if !ok {
  39480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39481. }
  39482. m.SetCompany(v)
  39483. return nil
  39484. case workexperience.FieldExperience:
  39485. v, ok := value.(string)
  39486. if !ok {
  39487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39488. }
  39489. m.SetExperience(v)
  39490. return nil
  39491. case workexperience.FieldOrganizationID:
  39492. v, ok := value.(uint64)
  39493. if !ok {
  39494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39495. }
  39496. m.SetOrganizationID(v)
  39497. return nil
  39498. }
  39499. return fmt.Errorf("unknown WorkExperience field %s", name)
  39500. }
  39501. // AddedFields returns all numeric fields that were incremented/decremented during
  39502. // this mutation.
  39503. func (m *WorkExperienceMutation) AddedFields() []string {
  39504. var fields []string
  39505. if m.addorganization_id != nil {
  39506. fields = append(fields, workexperience.FieldOrganizationID)
  39507. }
  39508. return fields
  39509. }
  39510. // AddedField returns the numeric value that was incremented/decremented on a field
  39511. // with the given name. The second boolean return value indicates that this field
  39512. // was not set, or was not defined in the schema.
  39513. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  39514. switch name {
  39515. case workexperience.FieldOrganizationID:
  39516. return m.AddedOrganizationID()
  39517. }
  39518. return nil, false
  39519. }
  39520. // AddField adds the value to the field with the given name. It returns an error if
  39521. // the field is not defined in the schema, or if the type mismatched the field
  39522. // type.
  39523. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  39524. switch name {
  39525. case workexperience.FieldOrganizationID:
  39526. v, ok := value.(int64)
  39527. if !ok {
  39528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39529. }
  39530. m.AddOrganizationID(v)
  39531. return nil
  39532. }
  39533. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  39534. }
  39535. // ClearedFields returns all nullable fields that were cleared during this
  39536. // mutation.
  39537. func (m *WorkExperienceMutation) ClearedFields() []string {
  39538. var fields []string
  39539. if m.FieldCleared(workexperience.FieldDeletedAt) {
  39540. fields = append(fields, workexperience.FieldDeletedAt)
  39541. }
  39542. return fields
  39543. }
  39544. // FieldCleared returns a boolean indicating if a field with the given name was
  39545. // cleared in this mutation.
  39546. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  39547. _, ok := m.clearedFields[name]
  39548. return ok
  39549. }
  39550. // ClearField clears the value of the field with the given name. It returns an
  39551. // error if the field is not defined in the schema.
  39552. func (m *WorkExperienceMutation) ClearField(name string) error {
  39553. switch name {
  39554. case workexperience.FieldDeletedAt:
  39555. m.ClearDeletedAt()
  39556. return nil
  39557. }
  39558. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  39559. }
  39560. // ResetField resets all changes in the mutation for the field with the given name.
  39561. // It returns an error if the field is not defined in the schema.
  39562. func (m *WorkExperienceMutation) ResetField(name string) error {
  39563. switch name {
  39564. case workexperience.FieldCreatedAt:
  39565. m.ResetCreatedAt()
  39566. return nil
  39567. case workexperience.FieldUpdatedAt:
  39568. m.ResetUpdatedAt()
  39569. return nil
  39570. case workexperience.FieldDeletedAt:
  39571. m.ResetDeletedAt()
  39572. return nil
  39573. case workexperience.FieldEmployeeID:
  39574. m.ResetEmployeeID()
  39575. return nil
  39576. case workexperience.FieldStartDate:
  39577. m.ResetStartDate()
  39578. return nil
  39579. case workexperience.FieldEndDate:
  39580. m.ResetEndDate()
  39581. return nil
  39582. case workexperience.FieldCompany:
  39583. m.ResetCompany()
  39584. return nil
  39585. case workexperience.FieldExperience:
  39586. m.ResetExperience()
  39587. return nil
  39588. case workexperience.FieldOrganizationID:
  39589. m.ResetOrganizationID()
  39590. return nil
  39591. }
  39592. return fmt.Errorf("unknown WorkExperience field %s", name)
  39593. }
  39594. // AddedEdges returns all edge names that were set/added in this mutation.
  39595. func (m *WorkExperienceMutation) AddedEdges() []string {
  39596. edges := make([]string, 0, 1)
  39597. if m.employee != nil {
  39598. edges = append(edges, workexperience.EdgeEmployee)
  39599. }
  39600. return edges
  39601. }
  39602. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39603. // name in this mutation.
  39604. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  39605. switch name {
  39606. case workexperience.EdgeEmployee:
  39607. if id := m.employee; id != nil {
  39608. return []ent.Value{*id}
  39609. }
  39610. }
  39611. return nil
  39612. }
  39613. // RemovedEdges returns all edge names that were removed in this mutation.
  39614. func (m *WorkExperienceMutation) RemovedEdges() []string {
  39615. edges := make([]string, 0, 1)
  39616. return edges
  39617. }
  39618. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39619. // the given name in this mutation.
  39620. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  39621. return nil
  39622. }
  39623. // ClearedEdges returns all edge names that were cleared in this mutation.
  39624. func (m *WorkExperienceMutation) ClearedEdges() []string {
  39625. edges := make([]string, 0, 1)
  39626. if m.clearedemployee {
  39627. edges = append(edges, workexperience.EdgeEmployee)
  39628. }
  39629. return edges
  39630. }
  39631. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39632. // was cleared in this mutation.
  39633. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  39634. switch name {
  39635. case workexperience.EdgeEmployee:
  39636. return m.clearedemployee
  39637. }
  39638. return false
  39639. }
  39640. // ClearEdge clears the value of the edge with the given name. It returns an error
  39641. // if that edge is not defined in the schema.
  39642. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  39643. switch name {
  39644. case workexperience.EdgeEmployee:
  39645. m.ClearEmployee()
  39646. return nil
  39647. }
  39648. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  39649. }
  39650. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39651. // It returns an error if the edge is not defined in the schema.
  39652. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  39653. switch name {
  39654. case workexperience.EdgeEmployee:
  39655. m.ResetEmployee()
  39656. return nil
  39657. }
  39658. return fmt.Errorf("unknown WorkExperience edge %s", name)
  39659. }
  39660. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  39661. type WpChatroomMutation struct {
  39662. config
  39663. op Op
  39664. typ string
  39665. id *uint64
  39666. created_at *time.Time
  39667. updated_at *time.Time
  39668. status *uint8
  39669. addstatus *int8
  39670. wx_wxid *string
  39671. chatroom_id *string
  39672. nickname *string
  39673. owner *string
  39674. avatar *string
  39675. member_list *[]string
  39676. appendmember_list []string
  39677. clearedFields map[string]struct{}
  39678. done bool
  39679. oldValue func(context.Context) (*WpChatroom, error)
  39680. predicates []predicate.WpChatroom
  39681. }
  39682. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  39683. // wpchatroomOption allows management of the mutation configuration using functional options.
  39684. type wpchatroomOption func(*WpChatroomMutation)
  39685. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  39686. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  39687. m := &WpChatroomMutation{
  39688. config: c,
  39689. op: op,
  39690. typ: TypeWpChatroom,
  39691. clearedFields: make(map[string]struct{}),
  39692. }
  39693. for _, opt := range opts {
  39694. opt(m)
  39695. }
  39696. return m
  39697. }
  39698. // withWpChatroomID sets the ID field of the mutation.
  39699. func withWpChatroomID(id uint64) wpchatroomOption {
  39700. return func(m *WpChatroomMutation) {
  39701. var (
  39702. err error
  39703. once sync.Once
  39704. value *WpChatroom
  39705. )
  39706. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  39707. once.Do(func() {
  39708. if m.done {
  39709. err = errors.New("querying old values post mutation is not allowed")
  39710. } else {
  39711. value, err = m.Client().WpChatroom.Get(ctx, id)
  39712. }
  39713. })
  39714. return value, err
  39715. }
  39716. m.id = &id
  39717. }
  39718. }
  39719. // withWpChatroom sets the old WpChatroom of the mutation.
  39720. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  39721. return func(m *WpChatroomMutation) {
  39722. m.oldValue = func(context.Context) (*WpChatroom, error) {
  39723. return node, nil
  39724. }
  39725. m.id = &node.ID
  39726. }
  39727. }
  39728. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39729. // executed in a transaction (ent.Tx), a transactional client is returned.
  39730. func (m WpChatroomMutation) Client() *Client {
  39731. client := &Client{config: m.config}
  39732. client.init()
  39733. return client
  39734. }
  39735. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39736. // it returns an error otherwise.
  39737. func (m WpChatroomMutation) Tx() (*Tx, error) {
  39738. if _, ok := m.driver.(*txDriver); !ok {
  39739. return nil, errors.New("ent: mutation is not running in a transaction")
  39740. }
  39741. tx := &Tx{config: m.config}
  39742. tx.init()
  39743. return tx, nil
  39744. }
  39745. // SetID sets the value of the id field. Note that this
  39746. // operation is only accepted on creation of WpChatroom entities.
  39747. func (m *WpChatroomMutation) SetID(id uint64) {
  39748. m.id = &id
  39749. }
  39750. // ID returns the ID value in the mutation. Note that the ID is only available
  39751. // if it was provided to the builder or after it was returned from the database.
  39752. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  39753. if m.id == nil {
  39754. return
  39755. }
  39756. return *m.id, true
  39757. }
  39758. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39759. // That means, if the mutation is applied within a transaction with an isolation level such
  39760. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39761. // or updated by the mutation.
  39762. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  39763. switch {
  39764. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39765. id, exists := m.ID()
  39766. if exists {
  39767. return []uint64{id}, nil
  39768. }
  39769. fallthrough
  39770. case m.op.Is(OpUpdate | OpDelete):
  39771. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  39772. default:
  39773. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39774. }
  39775. }
  39776. // SetCreatedAt sets the "created_at" field.
  39777. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  39778. m.created_at = &t
  39779. }
  39780. // CreatedAt returns the value of the "created_at" field in the mutation.
  39781. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  39782. v := m.created_at
  39783. if v == nil {
  39784. return
  39785. }
  39786. return *v, true
  39787. }
  39788. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  39789. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39791. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39792. if !m.op.Is(OpUpdateOne) {
  39793. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39794. }
  39795. if m.id == nil || m.oldValue == nil {
  39796. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39797. }
  39798. oldValue, err := m.oldValue(ctx)
  39799. if err != nil {
  39800. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39801. }
  39802. return oldValue.CreatedAt, nil
  39803. }
  39804. // ResetCreatedAt resets all changes to the "created_at" field.
  39805. func (m *WpChatroomMutation) ResetCreatedAt() {
  39806. m.created_at = nil
  39807. }
  39808. // SetUpdatedAt sets the "updated_at" field.
  39809. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  39810. m.updated_at = &t
  39811. }
  39812. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39813. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  39814. v := m.updated_at
  39815. if v == nil {
  39816. return
  39817. }
  39818. return *v, true
  39819. }
  39820. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  39821. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39823. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39824. if !m.op.Is(OpUpdateOne) {
  39825. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39826. }
  39827. if m.id == nil || m.oldValue == nil {
  39828. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39829. }
  39830. oldValue, err := m.oldValue(ctx)
  39831. if err != nil {
  39832. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39833. }
  39834. return oldValue.UpdatedAt, nil
  39835. }
  39836. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39837. func (m *WpChatroomMutation) ResetUpdatedAt() {
  39838. m.updated_at = nil
  39839. }
  39840. // SetStatus sets the "status" field.
  39841. func (m *WpChatroomMutation) SetStatus(u uint8) {
  39842. m.status = &u
  39843. m.addstatus = nil
  39844. }
  39845. // Status returns the value of the "status" field in the mutation.
  39846. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  39847. v := m.status
  39848. if v == nil {
  39849. return
  39850. }
  39851. return *v, true
  39852. }
  39853. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  39854. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39856. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39857. if !m.op.Is(OpUpdateOne) {
  39858. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39859. }
  39860. if m.id == nil || m.oldValue == nil {
  39861. return v, errors.New("OldStatus requires an ID field in the mutation")
  39862. }
  39863. oldValue, err := m.oldValue(ctx)
  39864. if err != nil {
  39865. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39866. }
  39867. return oldValue.Status, nil
  39868. }
  39869. // AddStatus adds u to the "status" field.
  39870. func (m *WpChatroomMutation) AddStatus(u int8) {
  39871. if m.addstatus != nil {
  39872. *m.addstatus += u
  39873. } else {
  39874. m.addstatus = &u
  39875. }
  39876. }
  39877. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39878. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  39879. v := m.addstatus
  39880. if v == nil {
  39881. return
  39882. }
  39883. return *v, true
  39884. }
  39885. // ClearStatus clears the value of the "status" field.
  39886. func (m *WpChatroomMutation) ClearStatus() {
  39887. m.status = nil
  39888. m.addstatus = nil
  39889. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  39890. }
  39891. // StatusCleared returns if the "status" field was cleared in this mutation.
  39892. func (m *WpChatroomMutation) StatusCleared() bool {
  39893. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  39894. return ok
  39895. }
  39896. // ResetStatus resets all changes to the "status" field.
  39897. func (m *WpChatroomMutation) ResetStatus() {
  39898. m.status = nil
  39899. m.addstatus = nil
  39900. delete(m.clearedFields, wpchatroom.FieldStatus)
  39901. }
  39902. // SetWxWxid sets the "wx_wxid" field.
  39903. func (m *WpChatroomMutation) SetWxWxid(s string) {
  39904. m.wx_wxid = &s
  39905. }
  39906. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  39907. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  39908. v := m.wx_wxid
  39909. if v == nil {
  39910. return
  39911. }
  39912. return *v, true
  39913. }
  39914. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  39915. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39917. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  39918. if !m.op.Is(OpUpdateOne) {
  39919. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  39920. }
  39921. if m.id == nil || m.oldValue == nil {
  39922. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  39923. }
  39924. oldValue, err := m.oldValue(ctx)
  39925. if err != nil {
  39926. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  39927. }
  39928. return oldValue.WxWxid, nil
  39929. }
  39930. // ResetWxWxid resets all changes to the "wx_wxid" field.
  39931. func (m *WpChatroomMutation) ResetWxWxid() {
  39932. m.wx_wxid = nil
  39933. }
  39934. // SetChatroomID sets the "chatroom_id" field.
  39935. func (m *WpChatroomMutation) SetChatroomID(s string) {
  39936. m.chatroom_id = &s
  39937. }
  39938. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  39939. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  39940. v := m.chatroom_id
  39941. if v == nil {
  39942. return
  39943. }
  39944. return *v, true
  39945. }
  39946. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  39947. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39949. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  39950. if !m.op.Is(OpUpdateOne) {
  39951. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  39952. }
  39953. if m.id == nil || m.oldValue == nil {
  39954. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  39955. }
  39956. oldValue, err := m.oldValue(ctx)
  39957. if err != nil {
  39958. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  39959. }
  39960. return oldValue.ChatroomID, nil
  39961. }
  39962. // ResetChatroomID resets all changes to the "chatroom_id" field.
  39963. func (m *WpChatroomMutation) ResetChatroomID() {
  39964. m.chatroom_id = nil
  39965. }
  39966. // SetNickname sets the "nickname" field.
  39967. func (m *WpChatroomMutation) SetNickname(s string) {
  39968. m.nickname = &s
  39969. }
  39970. // Nickname returns the value of the "nickname" field in the mutation.
  39971. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  39972. v := m.nickname
  39973. if v == nil {
  39974. return
  39975. }
  39976. return *v, true
  39977. }
  39978. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  39979. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39981. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  39982. if !m.op.Is(OpUpdateOne) {
  39983. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39984. }
  39985. if m.id == nil || m.oldValue == nil {
  39986. return v, errors.New("OldNickname requires an ID field in the mutation")
  39987. }
  39988. oldValue, err := m.oldValue(ctx)
  39989. if err != nil {
  39990. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39991. }
  39992. return oldValue.Nickname, nil
  39993. }
  39994. // ResetNickname resets all changes to the "nickname" field.
  39995. func (m *WpChatroomMutation) ResetNickname() {
  39996. m.nickname = nil
  39997. }
  39998. // SetOwner sets the "owner" field.
  39999. func (m *WpChatroomMutation) SetOwner(s string) {
  40000. m.owner = &s
  40001. }
  40002. // Owner returns the value of the "owner" field in the mutation.
  40003. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  40004. v := m.owner
  40005. if v == nil {
  40006. return
  40007. }
  40008. return *v, true
  40009. }
  40010. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  40011. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40013. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  40014. if !m.op.Is(OpUpdateOne) {
  40015. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  40016. }
  40017. if m.id == nil || m.oldValue == nil {
  40018. return v, errors.New("OldOwner requires an ID field in the mutation")
  40019. }
  40020. oldValue, err := m.oldValue(ctx)
  40021. if err != nil {
  40022. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  40023. }
  40024. return oldValue.Owner, nil
  40025. }
  40026. // ResetOwner resets all changes to the "owner" field.
  40027. func (m *WpChatroomMutation) ResetOwner() {
  40028. m.owner = nil
  40029. }
  40030. // SetAvatar sets the "avatar" field.
  40031. func (m *WpChatroomMutation) SetAvatar(s string) {
  40032. m.avatar = &s
  40033. }
  40034. // Avatar returns the value of the "avatar" field in the mutation.
  40035. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  40036. v := m.avatar
  40037. if v == nil {
  40038. return
  40039. }
  40040. return *v, true
  40041. }
  40042. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  40043. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40045. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40046. if !m.op.Is(OpUpdateOne) {
  40047. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40048. }
  40049. if m.id == nil || m.oldValue == nil {
  40050. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40051. }
  40052. oldValue, err := m.oldValue(ctx)
  40053. if err != nil {
  40054. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40055. }
  40056. return oldValue.Avatar, nil
  40057. }
  40058. // ResetAvatar resets all changes to the "avatar" field.
  40059. func (m *WpChatroomMutation) ResetAvatar() {
  40060. m.avatar = nil
  40061. }
  40062. // SetMemberList sets the "member_list" field.
  40063. func (m *WpChatroomMutation) SetMemberList(s []string) {
  40064. m.member_list = &s
  40065. m.appendmember_list = nil
  40066. }
  40067. // MemberList returns the value of the "member_list" field in the mutation.
  40068. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  40069. v := m.member_list
  40070. if v == nil {
  40071. return
  40072. }
  40073. return *v, true
  40074. }
  40075. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  40076. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40078. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  40079. if !m.op.Is(OpUpdateOne) {
  40080. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  40081. }
  40082. if m.id == nil || m.oldValue == nil {
  40083. return v, errors.New("OldMemberList requires an ID field in the mutation")
  40084. }
  40085. oldValue, err := m.oldValue(ctx)
  40086. if err != nil {
  40087. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  40088. }
  40089. return oldValue.MemberList, nil
  40090. }
  40091. // AppendMemberList adds s to the "member_list" field.
  40092. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  40093. m.appendmember_list = append(m.appendmember_list, s...)
  40094. }
  40095. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  40096. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  40097. if len(m.appendmember_list) == 0 {
  40098. return nil, false
  40099. }
  40100. return m.appendmember_list, true
  40101. }
  40102. // ResetMemberList resets all changes to the "member_list" field.
  40103. func (m *WpChatroomMutation) ResetMemberList() {
  40104. m.member_list = nil
  40105. m.appendmember_list = nil
  40106. }
  40107. // Where appends a list predicates to the WpChatroomMutation builder.
  40108. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  40109. m.predicates = append(m.predicates, ps...)
  40110. }
  40111. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  40112. // users can use type-assertion to append predicates that do not depend on any generated package.
  40113. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  40114. p := make([]predicate.WpChatroom, len(ps))
  40115. for i := range ps {
  40116. p[i] = ps[i]
  40117. }
  40118. m.Where(p...)
  40119. }
  40120. // Op returns the operation name.
  40121. func (m *WpChatroomMutation) Op() Op {
  40122. return m.op
  40123. }
  40124. // SetOp allows setting the mutation operation.
  40125. func (m *WpChatroomMutation) SetOp(op Op) {
  40126. m.op = op
  40127. }
  40128. // Type returns the node type of this mutation (WpChatroom).
  40129. func (m *WpChatroomMutation) Type() string {
  40130. return m.typ
  40131. }
  40132. // Fields returns all fields that were changed during this mutation. Note that in
  40133. // order to get all numeric fields that were incremented/decremented, call
  40134. // AddedFields().
  40135. func (m *WpChatroomMutation) Fields() []string {
  40136. fields := make([]string, 0, 9)
  40137. if m.created_at != nil {
  40138. fields = append(fields, wpchatroom.FieldCreatedAt)
  40139. }
  40140. if m.updated_at != nil {
  40141. fields = append(fields, wpchatroom.FieldUpdatedAt)
  40142. }
  40143. if m.status != nil {
  40144. fields = append(fields, wpchatroom.FieldStatus)
  40145. }
  40146. if m.wx_wxid != nil {
  40147. fields = append(fields, wpchatroom.FieldWxWxid)
  40148. }
  40149. if m.chatroom_id != nil {
  40150. fields = append(fields, wpchatroom.FieldChatroomID)
  40151. }
  40152. if m.nickname != nil {
  40153. fields = append(fields, wpchatroom.FieldNickname)
  40154. }
  40155. if m.owner != nil {
  40156. fields = append(fields, wpchatroom.FieldOwner)
  40157. }
  40158. if m.avatar != nil {
  40159. fields = append(fields, wpchatroom.FieldAvatar)
  40160. }
  40161. if m.member_list != nil {
  40162. fields = append(fields, wpchatroom.FieldMemberList)
  40163. }
  40164. return fields
  40165. }
  40166. // Field returns the value of a field with the given name. The second boolean
  40167. // return value indicates that this field was not set, or was not defined in the
  40168. // schema.
  40169. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  40170. switch name {
  40171. case wpchatroom.FieldCreatedAt:
  40172. return m.CreatedAt()
  40173. case wpchatroom.FieldUpdatedAt:
  40174. return m.UpdatedAt()
  40175. case wpchatroom.FieldStatus:
  40176. return m.Status()
  40177. case wpchatroom.FieldWxWxid:
  40178. return m.WxWxid()
  40179. case wpchatroom.FieldChatroomID:
  40180. return m.ChatroomID()
  40181. case wpchatroom.FieldNickname:
  40182. return m.Nickname()
  40183. case wpchatroom.FieldOwner:
  40184. return m.Owner()
  40185. case wpchatroom.FieldAvatar:
  40186. return m.Avatar()
  40187. case wpchatroom.FieldMemberList:
  40188. return m.MemberList()
  40189. }
  40190. return nil, false
  40191. }
  40192. // OldField returns the old value of the field from the database. An error is
  40193. // returned if the mutation operation is not UpdateOne, or the query to the
  40194. // database failed.
  40195. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40196. switch name {
  40197. case wpchatroom.FieldCreatedAt:
  40198. return m.OldCreatedAt(ctx)
  40199. case wpchatroom.FieldUpdatedAt:
  40200. return m.OldUpdatedAt(ctx)
  40201. case wpchatroom.FieldStatus:
  40202. return m.OldStatus(ctx)
  40203. case wpchatroom.FieldWxWxid:
  40204. return m.OldWxWxid(ctx)
  40205. case wpchatroom.FieldChatroomID:
  40206. return m.OldChatroomID(ctx)
  40207. case wpchatroom.FieldNickname:
  40208. return m.OldNickname(ctx)
  40209. case wpchatroom.FieldOwner:
  40210. return m.OldOwner(ctx)
  40211. case wpchatroom.FieldAvatar:
  40212. return m.OldAvatar(ctx)
  40213. case wpchatroom.FieldMemberList:
  40214. return m.OldMemberList(ctx)
  40215. }
  40216. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  40217. }
  40218. // SetField sets the value of a field with the given name. It returns an error if
  40219. // the field is not defined in the schema, or if the type mismatched the field
  40220. // type.
  40221. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  40222. switch name {
  40223. case wpchatroom.FieldCreatedAt:
  40224. v, ok := value.(time.Time)
  40225. if !ok {
  40226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40227. }
  40228. m.SetCreatedAt(v)
  40229. return nil
  40230. case wpchatroom.FieldUpdatedAt:
  40231. v, ok := value.(time.Time)
  40232. if !ok {
  40233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40234. }
  40235. m.SetUpdatedAt(v)
  40236. return nil
  40237. case wpchatroom.FieldStatus:
  40238. v, ok := value.(uint8)
  40239. if !ok {
  40240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40241. }
  40242. m.SetStatus(v)
  40243. return nil
  40244. case wpchatroom.FieldWxWxid:
  40245. v, ok := value.(string)
  40246. if !ok {
  40247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40248. }
  40249. m.SetWxWxid(v)
  40250. return nil
  40251. case wpchatroom.FieldChatroomID:
  40252. v, ok := value.(string)
  40253. if !ok {
  40254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40255. }
  40256. m.SetChatroomID(v)
  40257. return nil
  40258. case wpchatroom.FieldNickname:
  40259. v, ok := value.(string)
  40260. if !ok {
  40261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40262. }
  40263. m.SetNickname(v)
  40264. return nil
  40265. case wpchatroom.FieldOwner:
  40266. v, ok := value.(string)
  40267. if !ok {
  40268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40269. }
  40270. m.SetOwner(v)
  40271. return nil
  40272. case wpchatroom.FieldAvatar:
  40273. v, ok := value.(string)
  40274. if !ok {
  40275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40276. }
  40277. m.SetAvatar(v)
  40278. return nil
  40279. case wpchatroom.FieldMemberList:
  40280. v, ok := value.([]string)
  40281. if !ok {
  40282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40283. }
  40284. m.SetMemberList(v)
  40285. return nil
  40286. }
  40287. return fmt.Errorf("unknown WpChatroom field %s", name)
  40288. }
  40289. // AddedFields returns all numeric fields that were incremented/decremented during
  40290. // this mutation.
  40291. func (m *WpChatroomMutation) AddedFields() []string {
  40292. var fields []string
  40293. if m.addstatus != nil {
  40294. fields = append(fields, wpchatroom.FieldStatus)
  40295. }
  40296. return fields
  40297. }
  40298. // AddedField returns the numeric value that was incremented/decremented on a field
  40299. // with the given name. The second boolean return value indicates that this field
  40300. // was not set, or was not defined in the schema.
  40301. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  40302. switch name {
  40303. case wpchatroom.FieldStatus:
  40304. return m.AddedStatus()
  40305. }
  40306. return nil, false
  40307. }
  40308. // AddField adds the value to the field with the given name. It returns an error if
  40309. // the field is not defined in the schema, or if the type mismatched the field
  40310. // type.
  40311. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  40312. switch name {
  40313. case wpchatroom.FieldStatus:
  40314. v, ok := value.(int8)
  40315. if !ok {
  40316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40317. }
  40318. m.AddStatus(v)
  40319. return nil
  40320. }
  40321. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  40322. }
  40323. // ClearedFields returns all nullable fields that were cleared during this
  40324. // mutation.
  40325. func (m *WpChatroomMutation) ClearedFields() []string {
  40326. var fields []string
  40327. if m.FieldCleared(wpchatroom.FieldStatus) {
  40328. fields = append(fields, wpchatroom.FieldStatus)
  40329. }
  40330. return fields
  40331. }
  40332. // FieldCleared returns a boolean indicating if a field with the given name was
  40333. // cleared in this mutation.
  40334. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  40335. _, ok := m.clearedFields[name]
  40336. return ok
  40337. }
  40338. // ClearField clears the value of the field with the given name. It returns an
  40339. // error if the field is not defined in the schema.
  40340. func (m *WpChatroomMutation) ClearField(name string) error {
  40341. switch name {
  40342. case wpchatroom.FieldStatus:
  40343. m.ClearStatus()
  40344. return nil
  40345. }
  40346. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  40347. }
  40348. // ResetField resets all changes in the mutation for the field with the given name.
  40349. // It returns an error if the field is not defined in the schema.
  40350. func (m *WpChatroomMutation) ResetField(name string) error {
  40351. switch name {
  40352. case wpchatroom.FieldCreatedAt:
  40353. m.ResetCreatedAt()
  40354. return nil
  40355. case wpchatroom.FieldUpdatedAt:
  40356. m.ResetUpdatedAt()
  40357. return nil
  40358. case wpchatroom.FieldStatus:
  40359. m.ResetStatus()
  40360. return nil
  40361. case wpchatroom.FieldWxWxid:
  40362. m.ResetWxWxid()
  40363. return nil
  40364. case wpchatroom.FieldChatroomID:
  40365. m.ResetChatroomID()
  40366. return nil
  40367. case wpchatroom.FieldNickname:
  40368. m.ResetNickname()
  40369. return nil
  40370. case wpchatroom.FieldOwner:
  40371. m.ResetOwner()
  40372. return nil
  40373. case wpchatroom.FieldAvatar:
  40374. m.ResetAvatar()
  40375. return nil
  40376. case wpchatroom.FieldMemberList:
  40377. m.ResetMemberList()
  40378. return nil
  40379. }
  40380. return fmt.Errorf("unknown WpChatroom field %s", name)
  40381. }
  40382. // AddedEdges returns all edge names that were set/added in this mutation.
  40383. func (m *WpChatroomMutation) AddedEdges() []string {
  40384. edges := make([]string, 0, 0)
  40385. return edges
  40386. }
  40387. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40388. // name in this mutation.
  40389. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  40390. return nil
  40391. }
  40392. // RemovedEdges returns all edge names that were removed in this mutation.
  40393. func (m *WpChatroomMutation) RemovedEdges() []string {
  40394. edges := make([]string, 0, 0)
  40395. return edges
  40396. }
  40397. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40398. // the given name in this mutation.
  40399. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  40400. return nil
  40401. }
  40402. // ClearedEdges returns all edge names that were cleared in this mutation.
  40403. func (m *WpChatroomMutation) ClearedEdges() []string {
  40404. edges := make([]string, 0, 0)
  40405. return edges
  40406. }
  40407. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40408. // was cleared in this mutation.
  40409. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  40410. return false
  40411. }
  40412. // ClearEdge clears the value of the edge with the given name. It returns an error
  40413. // if that edge is not defined in the schema.
  40414. func (m *WpChatroomMutation) ClearEdge(name string) error {
  40415. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  40416. }
  40417. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40418. // It returns an error if the edge is not defined in the schema.
  40419. func (m *WpChatroomMutation) ResetEdge(name string) error {
  40420. return fmt.Errorf("unknown WpChatroom edge %s", name)
  40421. }
  40422. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  40423. type WpChatroomMemberMutation struct {
  40424. config
  40425. op Op
  40426. typ string
  40427. id *uint64
  40428. created_at *time.Time
  40429. updated_at *time.Time
  40430. status *uint8
  40431. addstatus *int8
  40432. wx_wxid *string
  40433. wxid *string
  40434. nickname *string
  40435. avatar *string
  40436. clearedFields map[string]struct{}
  40437. done bool
  40438. oldValue func(context.Context) (*WpChatroomMember, error)
  40439. predicates []predicate.WpChatroomMember
  40440. }
  40441. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  40442. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  40443. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  40444. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  40445. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  40446. m := &WpChatroomMemberMutation{
  40447. config: c,
  40448. op: op,
  40449. typ: TypeWpChatroomMember,
  40450. clearedFields: make(map[string]struct{}),
  40451. }
  40452. for _, opt := range opts {
  40453. opt(m)
  40454. }
  40455. return m
  40456. }
  40457. // withWpChatroomMemberID sets the ID field of the mutation.
  40458. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  40459. return func(m *WpChatroomMemberMutation) {
  40460. var (
  40461. err error
  40462. once sync.Once
  40463. value *WpChatroomMember
  40464. )
  40465. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  40466. once.Do(func() {
  40467. if m.done {
  40468. err = errors.New("querying old values post mutation is not allowed")
  40469. } else {
  40470. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  40471. }
  40472. })
  40473. return value, err
  40474. }
  40475. m.id = &id
  40476. }
  40477. }
  40478. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  40479. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  40480. return func(m *WpChatroomMemberMutation) {
  40481. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  40482. return node, nil
  40483. }
  40484. m.id = &node.ID
  40485. }
  40486. }
  40487. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40488. // executed in a transaction (ent.Tx), a transactional client is returned.
  40489. func (m WpChatroomMemberMutation) Client() *Client {
  40490. client := &Client{config: m.config}
  40491. client.init()
  40492. return client
  40493. }
  40494. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40495. // it returns an error otherwise.
  40496. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  40497. if _, ok := m.driver.(*txDriver); !ok {
  40498. return nil, errors.New("ent: mutation is not running in a transaction")
  40499. }
  40500. tx := &Tx{config: m.config}
  40501. tx.init()
  40502. return tx, nil
  40503. }
  40504. // SetID sets the value of the id field. Note that this
  40505. // operation is only accepted on creation of WpChatroomMember entities.
  40506. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  40507. m.id = &id
  40508. }
  40509. // ID returns the ID value in the mutation. Note that the ID is only available
  40510. // if it was provided to the builder or after it was returned from the database.
  40511. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  40512. if m.id == nil {
  40513. return
  40514. }
  40515. return *m.id, true
  40516. }
  40517. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40518. // That means, if the mutation is applied within a transaction with an isolation level such
  40519. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40520. // or updated by the mutation.
  40521. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  40522. switch {
  40523. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40524. id, exists := m.ID()
  40525. if exists {
  40526. return []uint64{id}, nil
  40527. }
  40528. fallthrough
  40529. case m.op.Is(OpUpdate | OpDelete):
  40530. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  40531. default:
  40532. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40533. }
  40534. }
  40535. // SetCreatedAt sets the "created_at" field.
  40536. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  40537. m.created_at = &t
  40538. }
  40539. // CreatedAt returns the value of the "created_at" field in the mutation.
  40540. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  40541. v := m.created_at
  40542. if v == nil {
  40543. return
  40544. }
  40545. return *v, true
  40546. }
  40547. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  40548. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40550. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40551. if !m.op.Is(OpUpdateOne) {
  40552. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40553. }
  40554. if m.id == nil || m.oldValue == nil {
  40555. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40556. }
  40557. oldValue, err := m.oldValue(ctx)
  40558. if err != nil {
  40559. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40560. }
  40561. return oldValue.CreatedAt, nil
  40562. }
  40563. // ResetCreatedAt resets all changes to the "created_at" field.
  40564. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  40565. m.created_at = nil
  40566. }
  40567. // SetUpdatedAt sets the "updated_at" field.
  40568. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  40569. m.updated_at = &t
  40570. }
  40571. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40572. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  40573. v := m.updated_at
  40574. if v == nil {
  40575. return
  40576. }
  40577. return *v, true
  40578. }
  40579. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  40580. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40582. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40583. if !m.op.Is(OpUpdateOne) {
  40584. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40585. }
  40586. if m.id == nil || m.oldValue == nil {
  40587. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40588. }
  40589. oldValue, err := m.oldValue(ctx)
  40590. if err != nil {
  40591. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40592. }
  40593. return oldValue.UpdatedAt, nil
  40594. }
  40595. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40596. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  40597. m.updated_at = nil
  40598. }
  40599. // SetStatus sets the "status" field.
  40600. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  40601. m.status = &u
  40602. m.addstatus = nil
  40603. }
  40604. // Status returns the value of the "status" field in the mutation.
  40605. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  40606. v := m.status
  40607. if v == nil {
  40608. return
  40609. }
  40610. return *v, true
  40611. }
  40612. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  40613. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40615. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40616. if !m.op.Is(OpUpdateOne) {
  40617. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40618. }
  40619. if m.id == nil || m.oldValue == nil {
  40620. return v, errors.New("OldStatus requires an ID field in the mutation")
  40621. }
  40622. oldValue, err := m.oldValue(ctx)
  40623. if err != nil {
  40624. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40625. }
  40626. return oldValue.Status, nil
  40627. }
  40628. // AddStatus adds u to the "status" field.
  40629. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  40630. if m.addstatus != nil {
  40631. *m.addstatus += u
  40632. } else {
  40633. m.addstatus = &u
  40634. }
  40635. }
  40636. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40637. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  40638. v := m.addstatus
  40639. if v == nil {
  40640. return
  40641. }
  40642. return *v, true
  40643. }
  40644. // ClearStatus clears the value of the "status" field.
  40645. func (m *WpChatroomMemberMutation) ClearStatus() {
  40646. m.status = nil
  40647. m.addstatus = nil
  40648. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  40649. }
  40650. // StatusCleared returns if the "status" field was cleared in this mutation.
  40651. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  40652. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  40653. return ok
  40654. }
  40655. // ResetStatus resets all changes to the "status" field.
  40656. func (m *WpChatroomMemberMutation) ResetStatus() {
  40657. m.status = nil
  40658. m.addstatus = nil
  40659. delete(m.clearedFields, wpchatroommember.FieldStatus)
  40660. }
  40661. // SetWxWxid sets the "wx_wxid" field.
  40662. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  40663. m.wx_wxid = &s
  40664. }
  40665. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  40666. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  40667. v := m.wx_wxid
  40668. if v == nil {
  40669. return
  40670. }
  40671. return *v, true
  40672. }
  40673. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  40674. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40676. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  40677. if !m.op.Is(OpUpdateOne) {
  40678. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  40679. }
  40680. if m.id == nil || m.oldValue == nil {
  40681. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  40682. }
  40683. oldValue, err := m.oldValue(ctx)
  40684. if err != nil {
  40685. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  40686. }
  40687. return oldValue.WxWxid, nil
  40688. }
  40689. // ResetWxWxid resets all changes to the "wx_wxid" field.
  40690. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  40691. m.wx_wxid = nil
  40692. }
  40693. // SetWxid sets the "wxid" field.
  40694. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  40695. m.wxid = &s
  40696. }
  40697. // Wxid returns the value of the "wxid" field in the mutation.
  40698. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  40699. v := m.wxid
  40700. if v == nil {
  40701. return
  40702. }
  40703. return *v, true
  40704. }
  40705. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  40706. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40708. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  40709. if !m.op.Is(OpUpdateOne) {
  40710. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40711. }
  40712. if m.id == nil || m.oldValue == nil {
  40713. return v, errors.New("OldWxid requires an ID field in the mutation")
  40714. }
  40715. oldValue, err := m.oldValue(ctx)
  40716. if err != nil {
  40717. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40718. }
  40719. return oldValue.Wxid, nil
  40720. }
  40721. // ResetWxid resets all changes to the "wxid" field.
  40722. func (m *WpChatroomMemberMutation) ResetWxid() {
  40723. m.wxid = nil
  40724. }
  40725. // SetNickname sets the "nickname" field.
  40726. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  40727. m.nickname = &s
  40728. }
  40729. // Nickname returns the value of the "nickname" field in the mutation.
  40730. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  40731. v := m.nickname
  40732. if v == nil {
  40733. return
  40734. }
  40735. return *v, true
  40736. }
  40737. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  40738. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40740. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  40741. if !m.op.Is(OpUpdateOne) {
  40742. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40743. }
  40744. if m.id == nil || m.oldValue == nil {
  40745. return v, errors.New("OldNickname requires an ID field in the mutation")
  40746. }
  40747. oldValue, err := m.oldValue(ctx)
  40748. if err != nil {
  40749. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40750. }
  40751. return oldValue.Nickname, nil
  40752. }
  40753. // ResetNickname resets all changes to the "nickname" field.
  40754. func (m *WpChatroomMemberMutation) ResetNickname() {
  40755. m.nickname = nil
  40756. }
  40757. // SetAvatar sets the "avatar" field.
  40758. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  40759. m.avatar = &s
  40760. }
  40761. // Avatar returns the value of the "avatar" field in the mutation.
  40762. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  40763. v := m.avatar
  40764. if v == nil {
  40765. return
  40766. }
  40767. return *v, true
  40768. }
  40769. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  40770. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40772. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40773. if !m.op.Is(OpUpdateOne) {
  40774. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40775. }
  40776. if m.id == nil || m.oldValue == nil {
  40777. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40778. }
  40779. oldValue, err := m.oldValue(ctx)
  40780. if err != nil {
  40781. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40782. }
  40783. return oldValue.Avatar, nil
  40784. }
  40785. // ResetAvatar resets all changes to the "avatar" field.
  40786. func (m *WpChatroomMemberMutation) ResetAvatar() {
  40787. m.avatar = nil
  40788. }
  40789. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  40790. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  40791. m.predicates = append(m.predicates, ps...)
  40792. }
  40793. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  40794. // users can use type-assertion to append predicates that do not depend on any generated package.
  40795. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  40796. p := make([]predicate.WpChatroomMember, len(ps))
  40797. for i := range ps {
  40798. p[i] = ps[i]
  40799. }
  40800. m.Where(p...)
  40801. }
  40802. // Op returns the operation name.
  40803. func (m *WpChatroomMemberMutation) Op() Op {
  40804. return m.op
  40805. }
  40806. // SetOp allows setting the mutation operation.
  40807. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  40808. m.op = op
  40809. }
  40810. // Type returns the node type of this mutation (WpChatroomMember).
  40811. func (m *WpChatroomMemberMutation) Type() string {
  40812. return m.typ
  40813. }
  40814. // Fields returns all fields that were changed during this mutation. Note that in
  40815. // order to get all numeric fields that were incremented/decremented, call
  40816. // AddedFields().
  40817. func (m *WpChatroomMemberMutation) Fields() []string {
  40818. fields := make([]string, 0, 7)
  40819. if m.created_at != nil {
  40820. fields = append(fields, wpchatroommember.FieldCreatedAt)
  40821. }
  40822. if m.updated_at != nil {
  40823. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  40824. }
  40825. if m.status != nil {
  40826. fields = append(fields, wpchatroommember.FieldStatus)
  40827. }
  40828. if m.wx_wxid != nil {
  40829. fields = append(fields, wpchatroommember.FieldWxWxid)
  40830. }
  40831. if m.wxid != nil {
  40832. fields = append(fields, wpchatroommember.FieldWxid)
  40833. }
  40834. if m.nickname != nil {
  40835. fields = append(fields, wpchatroommember.FieldNickname)
  40836. }
  40837. if m.avatar != nil {
  40838. fields = append(fields, wpchatroommember.FieldAvatar)
  40839. }
  40840. return fields
  40841. }
  40842. // Field returns the value of a field with the given name. The second boolean
  40843. // return value indicates that this field was not set, or was not defined in the
  40844. // schema.
  40845. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  40846. switch name {
  40847. case wpchatroommember.FieldCreatedAt:
  40848. return m.CreatedAt()
  40849. case wpchatroommember.FieldUpdatedAt:
  40850. return m.UpdatedAt()
  40851. case wpchatroommember.FieldStatus:
  40852. return m.Status()
  40853. case wpchatroommember.FieldWxWxid:
  40854. return m.WxWxid()
  40855. case wpchatroommember.FieldWxid:
  40856. return m.Wxid()
  40857. case wpchatroommember.FieldNickname:
  40858. return m.Nickname()
  40859. case wpchatroommember.FieldAvatar:
  40860. return m.Avatar()
  40861. }
  40862. return nil, false
  40863. }
  40864. // OldField returns the old value of the field from the database. An error is
  40865. // returned if the mutation operation is not UpdateOne, or the query to the
  40866. // database failed.
  40867. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40868. switch name {
  40869. case wpchatroommember.FieldCreatedAt:
  40870. return m.OldCreatedAt(ctx)
  40871. case wpchatroommember.FieldUpdatedAt:
  40872. return m.OldUpdatedAt(ctx)
  40873. case wpchatroommember.FieldStatus:
  40874. return m.OldStatus(ctx)
  40875. case wpchatroommember.FieldWxWxid:
  40876. return m.OldWxWxid(ctx)
  40877. case wpchatroommember.FieldWxid:
  40878. return m.OldWxid(ctx)
  40879. case wpchatroommember.FieldNickname:
  40880. return m.OldNickname(ctx)
  40881. case wpchatroommember.FieldAvatar:
  40882. return m.OldAvatar(ctx)
  40883. }
  40884. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  40885. }
  40886. // SetField sets the value of a field with the given name. It returns an error if
  40887. // the field is not defined in the schema, or if the type mismatched the field
  40888. // type.
  40889. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  40890. switch name {
  40891. case wpchatroommember.FieldCreatedAt:
  40892. v, ok := value.(time.Time)
  40893. if !ok {
  40894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40895. }
  40896. m.SetCreatedAt(v)
  40897. return nil
  40898. case wpchatroommember.FieldUpdatedAt:
  40899. v, ok := value.(time.Time)
  40900. if !ok {
  40901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40902. }
  40903. m.SetUpdatedAt(v)
  40904. return nil
  40905. case wpchatroommember.FieldStatus:
  40906. v, ok := value.(uint8)
  40907. if !ok {
  40908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40909. }
  40910. m.SetStatus(v)
  40911. return nil
  40912. case wpchatroommember.FieldWxWxid:
  40913. v, ok := value.(string)
  40914. if !ok {
  40915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40916. }
  40917. m.SetWxWxid(v)
  40918. return nil
  40919. case wpchatroommember.FieldWxid:
  40920. v, ok := value.(string)
  40921. if !ok {
  40922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40923. }
  40924. m.SetWxid(v)
  40925. return nil
  40926. case wpchatroommember.FieldNickname:
  40927. v, ok := value.(string)
  40928. if !ok {
  40929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40930. }
  40931. m.SetNickname(v)
  40932. return nil
  40933. case wpchatroommember.FieldAvatar:
  40934. v, ok := value.(string)
  40935. if !ok {
  40936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40937. }
  40938. m.SetAvatar(v)
  40939. return nil
  40940. }
  40941. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  40942. }
  40943. // AddedFields returns all numeric fields that were incremented/decremented during
  40944. // this mutation.
  40945. func (m *WpChatroomMemberMutation) AddedFields() []string {
  40946. var fields []string
  40947. if m.addstatus != nil {
  40948. fields = append(fields, wpchatroommember.FieldStatus)
  40949. }
  40950. return fields
  40951. }
  40952. // AddedField returns the numeric value that was incremented/decremented on a field
  40953. // with the given name. The second boolean return value indicates that this field
  40954. // was not set, or was not defined in the schema.
  40955. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  40956. switch name {
  40957. case wpchatroommember.FieldStatus:
  40958. return m.AddedStatus()
  40959. }
  40960. return nil, false
  40961. }
  40962. // AddField adds the value to the field with the given name. It returns an error if
  40963. // the field is not defined in the schema, or if the type mismatched the field
  40964. // type.
  40965. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  40966. switch name {
  40967. case wpchatroommember.FieldStatus:
  40968. v, ok := value.(int8)
  40969. if !ok {
  40970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40971. }
  40972. m.AddStatus(v)
  40973. return nil
  40974. }
  40975. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  40976. }
  40977. // ClearedFields returns all nullable fields that were cleared during this
  40978. // mutation.
  40979. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  40980. var fields []string
  40981. if m.FieldCleared(wpchatroommember.FieldStatus) {
  40982. fields = append(fields, wpchatroommember.FieldStatus)
  40983. }
  40984. return fields
  40985. }
  40986. // FieldCleared returns a boolean indicating if a field with the given name was
  40987. // cleared in this mutation.
  40988. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  40989. _, ok := m.clearedFields[name]
  40990. return ok
  40991. }
  40992. // ClearField clears the value of the field with the given name. It returns an
  40993. // error if the field is not defined in the schema.
  40994. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  40995. switch name {
  40996. case wpchatroommember.FieldStatus:
  40997. m.ClearStatus()
  40998. return nil
  40999. }
  41000. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  41001. }
  41002. // ResetField resets all changes in the mutation for the field with the given name.
  41003. // It returns an error if the field is not defined in the schema.
  41004. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  41005. switch name {
  41006. case wpchatroommember.FieldCreatedAt:
  41007. m.ResetCreatedAt()
  41008. return nil
  41009. case wpchatroommember.FieldUpdatedAt:
  41010. m.ResetUpdatedAt()
  41011. return nil
  41012. case wpchatroommember.FieldStatus:
  41013. m.ResetStatus()
  41014. return nil
  41015. case wpchatroommember.FieldWxWxid:
  41016. m.ResetWxWxid()
  41017. return nil
  41018. case wpchatroommember.FieldWxid:
  41019. m.ResetWxid()
  41020. return nil
  41021. case wpchatroommember.FieldNickname:
  41022. m.ResetNickname()
  41023. return nil
  41024. case wpchatroommember.FieldAvatar:
  41025. m.ResetAvatar()
  41026. return nil
  41027. }
  41028. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  41029. }
  41030. // AddedEdges returns all edge names that were set/added in this mutation.
  41031. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  41032. edges := make([]string, 0, 0)
  41033. return edges
  41034. }
  41035. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41036. // name in this mutation.
  41037. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  41038. return nil
  41039. }
  41040. // RemovedEdges returns all edge names that were removed in this mutation.
  41041. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  41042. edges := make([]string, 0, 0)
  41043. return edges
  41044. }
  41045. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41046. // the given name in this mutation.
  41047. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  41048. return nil
  41049. }
  41050. // ClearedEdges returns all edge names that were cleared in this mutation.
  41051. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  41052. edges := make([]string, 0, 0)
  41053. return edges
  41054. }
  41055. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41056. // was cleared in this mutation.
  41057. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  41058. return false
  41059. }
  41060. // ClearEdge clears the value of the edge with the given name. It returns an error
  41061. // if that edge is not defined in the schema.
  41062. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  41063. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  41064. }
  41065. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41066. // It returns an error if the edge is not defined in the schema.
  41067. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  41068. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  41069. }
  41070. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  41071. type WxMutation struct {
  41072. config
  41073. op Op
  41074. typ string
  41075. id *uint64
  41076. created_at *time.Time
  41077. updated_at *time.Time
  41078. status *uint8
  41079. addstatus *int8
  41080. deleted_at *time.Time
  41081. port *string
  41082. process_id *string
  41083. callback *string
  41084. wxid *string
  41085. account *string
  41086. nickname *string
  41087. tel *string
  41088. head_big *string
  41089. organization_id *uint64
  41090. addorganization_id *int64
  41091. api_base *string
  41092. api_key *string
  41093. allow_list *[]string
  41094. appendallow_list []string
  41095. group_allow_list *[]string
  41096. appendgroup_allow_list []string
  41097. block_list *[]string
  41098. appendblock_list []string
  41099. group_block_list *[]string
  41100. appendgroup_block_list []string
  41101. ctype *uint64
  41102. addctype *int64
  41103. clearedFields map[string]struct{}
  41104. server *uint64
  41105. clearedserver bool
  41106. agent *uint64
  41107. clearedagent bool
  41108. done bool
  41109. oldValue func(context.Context) (*Wx, error)
  41110. predicates []predicate.Wx
  41111. }
  41112. var _ ent.Mutation = (*WxMutation)(nil)
  41113. // wxOption allows management of the mutation configuration using functional options.
  41114. type wxOption func(*WxMutation)
  41115. // newWxMutation creates new mutation for the Wx entity.
  41116. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  41117. m := &WxMutation{
  41118. config: c,
  41119. op: op,
  41120. typ: TypeWx,
  41121. clearedFields: make(map[string]struct{}),
  41122. }
  41123. for _, opt := range opts {
  41124. opt(m)
  41125. }
  41126. return m
  41127. }
  41128. // withWxID sets the ID field of the mutation.
  41129. func withWxID(id uint64) wxOption {
  41130. return func(m *WxMutation) {
  41131. var (
  41132. err error
  41133. once sync.Once
  41134. value *Wx
  41135. )
  41136. m.oldValue = func(ctx context.Context) (*Wx, error) {
  41137. once.Do(func() {
  41138. if m.done {
  41139. err = errors.New("querying old values post mutation is not allowed")
  41140. } else {
  41141. value, err = m.Client().Wx.Get(ctx, id)
  41142. }
  41143. })
  41144. return value, err
  41145. }
  41146. m.id = &id
  41147. }
  41148. }
  41149. // withWx sets the old Wx of the mutation.
  41150. func withWx(node *Wx) wxOption {
  41151. return func(m *WxMutation) {
  41152. m.oldValue = func(context.Context) (*Wx, error) {
  41153. return node, nil
  41154. }
  41155. m.id = &node.ID
  41156. }
  41157. }
  41158. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41159. // executed in a transaction (ent.Tx), a transactional client is returned.
  41160. func (m WxMutation) Client() *Client {
  41161. client := &Client{config: m.config}
  41162. client.init()
  41163. return client
  41164. }
  41165. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41166. // it returns an error otherwise.
  41167. func (m WxMutation) Tx() (*Tx, error) {
  41168. if _, ok := m.driver.(*txDriver); !ok {
  41169. return nil, errors.New("ent: mutation is not running in a transaction")
  41170. }
  41171. tx := &Tx{config: m.config}
  41172. tx.init()
  41173. return tx, nil
  41174. }
  41175. // SetID sets the value of the id field. Note that this
  41176. // operation is only accepted on creation of Wx entities.
  41177. func (m *WxMutation) SetID(id uint64) {
  41178. m.id = &id
  41179. }
  41180. // ID returns the ID value in the mutation. Note that the ID is only available
  41181. // if it was provided to the builder or after it was returned from the database.
  41182. func (m *WxMutation) ID() (id uint64, exists bool) {
  41183. if m.id == nil {
  41184. return
  41185. }
  41186. return *m.id, true
  41187. }
  41188. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41189. // That means, if the mutation is applied within a transaction with an isolation level such
  41190. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41191. // or updated by the mutation.
  41192. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  41193. switch {
  41194. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41195. id, exists := m.ID()
  41196. if exists {
  41197. return []uint64{id}, nil
  41198. }
  41199. fallthrough
  41200. case m.op.Is(OpUpdate | OpDelete):
  41201. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  41202. default:
  41203. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41204. }
  41205. }
  41206. // SetCreatedAt sets the "created_at" field.
  41207. func (m *WxMutation) SetCreatedAt(t time.Time) {
  41208. m.created_at = &t
  41209. }
  41210. // CreatedAt returns the value of the "created_at" field in the mutation.
  41211. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  41212. v := m.created_at
  41213. if v == nil {
  41214. return
  41215. }
  41216. return *v, true
  41217. }
  41218. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  41219. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41221. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41222. if !m.op.Is(OpUpdateOne) {
  41223. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41224. }
  41225. if m.id == nil || m.oldValue == nil {
  41226. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41227. }
  41228. oldValue, err := m.oldValue(ctx)
  41229. if err != nil {
  41230. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41231. }
  41232. return oldValue.CreatedAt, nil
  41233. }
  41234. // ResetCreatedAt resets all changes to the "created_at" field.
  41235. func (m *WxMutation) ResetCreatedAt() {
  41236. m.created_at = nil
  41237. }
  41238. // SetUpdatedAt sets the "updated_at" field.
  41239. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  41240. m.updated_at = &t
  41241. }
  41242. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41243. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  41244. v := m.updated_at
  41245. if v == nil {
  41246. return
  41247. }
  41248. return *v, true
  41249. }
  41250. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  41251. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41253. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41254. if !m.op.Is(OpUpdateOne) {
  41255. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41256. }
  41257. if m.id == nil || m.oldValue == nil {
  41258. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41259. }
  41260. oldValue, err := m.oldValue(ctx)
  41261. if err != nil {
  41262. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41263. }
  41264. return oldValue.UpdatedAt, nil
  41265. }
  41266. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41267. func (m *WxMutation) ResetUpdatedAt() {
  41268. m.updated_at = nil
  41269. }
  41270. // SetStatus sets the "status" field.
  41271. func (m *WxMutation) SetStatus(u uint8) {
  41272. m.status = &u
  41273. m.addstatus = nil
  41274. }
  41275. // Status returns the value of the "status" field in the mutation.
  41276. func (m *WxMutation) Status() (r uint8, exists bool) {
  41277. v := m.status
  41278. if v == nil {
  41279. return
  41280. }
  41281. return *v, true
  41282. }
  41283. // OldStatus returns the old "status" field's value of the Wx entity.
  41284. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41286. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41287. if !m.op.Is(OpUpdateOne) {
  41288. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41289. }
  41290. if m.id == nil || m.oldValue == nil {
  41291. return v, errors.New("OldStatus requires an ID field in the mutation")
  41292. }
  41293. oldValue, err := m.oldValue(ctx)
  41294. if err != nil {
  41295. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41296. }
  41297. return oldValue.Status, nil
  41298. }
  41299. // AddStatus adds u to the "status" field.
  41300. func (m *WxMutation) AddStatus(u int8) {
  41301. if m.addstatus != nil {
  41302. *m.addstatus += u
  41303. } else {
  41304. m.addstatus = &u
  41305. }
  41306. }
  41307. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41308. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  41309. v := m.addstatus
  41310. if v == nil {
  41311. return
  41312. }
  41313. return *v, true
  41314. }
  41315. // ClearStatus clears the value of the "status" field.
  41316. func (m *WxMutation) ClearStatus() {
  41317. m.status = nil
  41318. m.addstatus = nil
  41319. m.clearedFields[wx.FieldStatus] = struct{}{}
  41320. }
  41321. // StatusCleared returns if the "status" field was cleared in this mutation.
  41322. func (m *WxMutation) StatusCleared() bool {
  41323. _, ok := m.clearedFields[wx.FieldStatus]
  41324. return ok
  41325. }
  41326. // ResetStatus resets all changes to the "status" field.
  41327. func (m *WxMutation) ResetStatus() {
  41328. m.status = nil
  41329. m.addstatus = nil
  41330. delete(m.clearedFields, wx.FieldStatus)
  41331. }
  41332. // SetDeletedAt sets the "deleted_at" field.
  41333. func (m *WxMutation) SetDeletedAt(t time.Time) {
  41334. m.deleted_at = &t
  41335. }
  41336. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41337. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  41338. v := m.deleted_at
  41339. if v == nil {
  41340. return
  41341. }
  41342. return *v, true
  41343. }
  41344. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  41345. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41347. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41348. if !m.op.Is(OpUpdateOne) {
  41349. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41350. }
  41351. if m.id == nil || m.oldValue == nil {
  41352. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41353. }
  41354. oldValue, err := m.oldValue(ctx)
  41355. if err != nil {
  41356. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41357. }
  41358. return oldValue.DeletedAt, nil
  41359. }
  41360. // ClearDeletedAt clears the value of the "deleted_at" field.
  41361. func (m *WxMutation) ClearDeletedAt() {
  41362. m.deleted_at = nil
  41363. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  41364. }
  41365. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41366. func (m *WxMutation) DeletedAtCleared() bool {
  41367. _, ok := m.clearedFields[wx.FieldDeletedAt]
  41368. return ok
  41369. }
  41370. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41371. func (m *WxMutation) ResetDeletedAt() {
  41372. m.deleted_at = nil
  41373. delete(m.clearedFields, wx.FieldDeletedAt)
  41374. }
  41375. // SetServerID sets the "server_id" field.
  41376. func (m *WxMutation) SetServerID(u uint64) {
  41377. m.server = &u
  41378. }
  41379. // ServerID returns the value of the "server_id" field in the mutation.
  41380. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  41381. v := m.server
  41382. if v == nil {
  41383. return
  41384. }
  41385. return *v, true
  41386. }
  41387. // OldServerID returns the old "server_id" field's value of the Wx entity.
  41388. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41390. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  41391. if !m.op.Is(OpUpdateOne) {
  41392. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  41393. }
  41394. if m.id == nil || m.oldValue == nil {
  41395. return v, errors.New("OldServerID requires an ID field in the mutation")
  41396. }
  41397. oldValue, err := m.oldValue(ctx)
  41398. if err != nil {
  41399. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  41400. }
  41401. return oldValue.ServerID, nil
  41402. }
  41403. // ClearServerID clears the value of the "server_id" field.
  41404. func (m *WxMutation) ClearServerID() {
  41405. m.server = nil
  41406. m.clearedFields[wx.FieldServerID] = struct{}{}
  41407. }
  41408. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  41409. func (m *WxMutation) ServerIDCleared() bool {
  41410. _, ok := m.clearedFields[wx.FieldServerID]
  41411. return ok
  41412. }
  41413. // ResetServerID resets all changes to the "server_id" field.
  41414. func (m *WxMutation) ResetServerID() {
  41415. m.server = nil
  41416. delete(m.clearedFields, wx.FieldServerID)
  41417. }
  41418. // SetPort sets the "port" field.
  41419. func (m *WxMutation) SetPort(s string) {
  41420. m.port = &s
  41421. }
  41422. // Port returns the value of the "port" field in the mutation.
  41423. func (m *WxMutation) Port() (r string, exists bool) {
  41424. v := m.port
  41425. if v == nil {
  41426. return
  41427. }
  41428. return *v, true
  41429. }
  41430. // OldPort returns the old "port" field's value of the Wx entity.
  41431. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41433. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  41434. if !m.op.Is(OpUpdateOne) {
  41435. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  41436. }
  41437. if m.id == nil || m.oldValue == nil {
  41438. return v, errors.New("OldPort requires an ID field in the mutation")
  41439. }
  41440. oldValue, err := m.oldValue(ctx)
  41441. if err != nil {
  41442. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  41443. }
  41444. return oldValue.Port, nil
  41445. }
  41446. // ResetPort resets all changes to the "port" field.
  41447. func (m *WxMutation) ResetPort() {
  41448. m.port = nil
  41449. }
  41450. // SetProcessID sets the "process_id" field.
  41451. func (m *WxMutation) SetProcessID(s string) {
  41452. m.process_id = &s
  41453. }
  41454. // ProcessID returns the value of the "process_id" field in the mutation.
  41455. func (m *WxMutation) ProcessID() (r string, exists bool) {
  41456. v := m.process_id
  41457. if v == nil {
  41458. return
  41459. }
  41460. return *v, true
  41461. }
  41462. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  41463. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41465. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  41466. if !m.op.Is(OpUpdateOne) {
  41467. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  41468. }
  41469. if m.id == nil || m.oldValue == nil {
  41470. return v, errors.New("OldProcessID requires an ID field in the mutation")
  41471. }
  41472. oldValue, err := m.oldValue(ctx)
  41473. if err != nil {
  41474. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  41475. }
  41476. return oldValue.ProcessID, nil
  41477. }
  41478. // ResetProcessID resets all changes to the "process_id" field.
  41479. func (m *WxMutation) ResetProcessID() {
  41480. m.process_id = nil
  41481. }
  41482. // SetCallback sets the "callback" field.
  41483. func (m *WxMutation) SetCallback(s string) {
  41484. m.callback = &s
  41485. }
  41486. // Callback returns the value of the "callback" field in the mutation.
  41487. func (m *WxMutation) Callback() (r string, exists bool) {
  41488. v := m.callback
  41489. if v == nil {
  41490. return
  41491. }
  41492. return *v, true
  41493. }
  41494. // OldCallback returns the old "callback" field's value of the Wx entity.
  41495. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41497. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  41498. if !m.op.Is(OpUpdateOne) {
  41499. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  41500. }
  41501. if m.id == nil || m.oldValue == nil {
  41502. return v, errors.New("OldCallback requires an ID field in the mutation")
  41503. }
  41504. oldValue, err := m.oldValue(ctx)
  41505. if err != nil {
  41506. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  41507. }
  41508. return oldValue.Callback, nil
  41509. }
  41510. // ResetCallback resets all changes to the "callback" field.
  41511. func (m *WxMutation) ResetCallback() {
  41512. m.callback = nil
  41513. }
  41514. // SetWxid sets the "wxid" field.
  41515. func (m *WxMutation) SetWxid(s string) {
  41516. m.wxid = &s
  41517. }
  41518. // Wxid returns the value of the "wxid" field in the mutation.
  41519. func (m *WxMutation) Wxid() (r string, exists bool) {
  41520. v := m.wxid
  41521. if v == nil {
  41522. return
  41523. }
  41524. return *v, true
  41525. }
  41526. // OldWxid returns the old "wxid" field's value of the Wx entity.
  41527. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41529. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  41530. if !m.op.Is(OpUpdateOne) {
  41531. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41532. }
  41533. if m.id == nil || m.oldValue == nil {
  41534. return v, errors.New("OldWxid requires an ID field in the mutation")
  41535. }
  41536. oldValue, err := m.oldValue(ctx)
  41537. if err != nil {
  41538. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41539. }
  41540. return oldValue.Wxid, nil
  41541. }
  41542. // ResetWxid resets all changes to the "wxid" field.
  41543. func (m *WxMutation) ResetWxid() {
  41544. m.wxid = nil
  41545. }
  41546. // SetAccount sets the "account" field.
  41547. func (m *WxMutation) SetAccount(s string) {
  41548. m.account = &s
  41549. }
  41550. // Account returns the value of the "account" field in the mutation.
  41551. func (m *WxMutation) Account() (r string, exists bool) {
  41552. v := m.account
  41553. if v == nil {
  41554. return
  41555. }
  41556. return *v, true
  41557. }
  41558. // OldAccount returns the old "account" field's value of the Wx entity.
  41559. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41561. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  41562. if !m.op.Is(OpUpdateOne) {
  41563. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41564. }
  41565. if m.id == nil || m.oldValue == nil {
  41566. return v, errors.New("OldAccount requires an ID field in the mutation")
  41567. }
  41568. oldValue, err := m.oldValue(ctx)
  41569. if err != nil {
  41570. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41571. }
  41572. return oldValue.Account, nil
  41573. }
  41574. // ResetAccount resets all changes to the "account" field.
  41575. func (m *WxMutation) ResetAccount() {
  41576. m.account = nil
  41577. }
  41578. // SetNickname sets the "nickname" field.
  41579. func (m *WxMutation) SetNickname(s string) {
  41580. m.nickname = &s
  41581. }
  41582. // Nickname returns the value of the "nickname" field in the mutation.
  41583. func (m *WxMutation) Nickname() (r string, exists bool) {
  41584. v := m.nickname
  41585. if v == nil {
  41586. return
  41587. }
  41588. return *v, true
  41589. }
  41590. // OldNickname returns the old "nickname" field's value of the Wx entity.
  41591. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41593. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  41594. if !m.op.Is(OpUpdateOne) {
  41595. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41596. }
  41597. if m.id == nil || m.oldValue == nil {
  41598. return v, errors.New("OldNickname requires an ID field in the mutation")
  41599. }
  41600. oldValue, err := m.oldValue(ctx)
  41601. if err != nil {
  41602. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41603. }
  41604. return oldValue.Nickname, nil
  41605. }
  41606. // ResetNickname resets all changes to the "nickname" field.
  41607. func (m *WxMutation) ResetNickname() {
  41608. m.nickname = nil
  41609. }
  41610. // SetTel sets the "tel" field.
  41611. func (m *WxMutation) SetTel(s string) {
  41612. m.tel = &s
  41613. }
  41614. // Tel returns the value of the "tel" field in the mutation.
  41615. func (m *WxMutation) Tel() (r string, exists bool) {
  41616. v := m.tel
  41617. if v == nil {
  41618. return
  41619. }
  41620. return *v, true
  41621. }
  41622. // OldTel returns the old "tel" field's value of the Wx entity.
  41623. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41625. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  41626. if !m.op.Is(OpUpdateOne) {
  41627. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  41628. }
  41629. if m.id == nil || m.oldValue == nil {
  41630. return v, errors.New("OldTel requires an ID field in the mutation")
  41631. }
  41632. oldValue, err := m.oldValue(ctx)
  41633. if err != nil {
  41634. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  41635. }
  41636. return oldValue.Tel, nil
  41637. }
  41638. // ResetTel resets all changes to the "tel" field.
  41639. func (m *WxMutation) ResetTel() {
  41640. m.tel = nil
  41641. }
  41642. // SetHeadBig sets the "head_big" field.
  41643. func (m *WxMutation) SetHeadBig(s string) {
  41644. m.head_big = &s
  41645. }
  41646. // HeadBig returns the value of the "head_big" field in the mutation.
  41647. func (m *WxMutation) HeadBig() (r string, exists bool) {
  41648. v := m.head_big
  41649. if v == nil {
  41650. return
  41651. }
  41652. return *v, true
  41653. }
  41654. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  41655. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41657. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  41658. if !m.op.Is(OpUpdateOne) {
  41659. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  41660. }
  41661. if m.id == nil || m.oldValue == nil {
  41662. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  41663. }
  41664. oldValue, err := m.oldValue(ctx)
  41665. if err != nil {
  41666. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  41667. }
  41668. return oldValue.HeadBig, nil
  41669. }
  41670. // ResetHeadBig resets all changes to the "head_big" field.
  41671. func (m *WxMutation) ResetHeadBig() {
  41672. m.head_big = nil
  41673. }
  41674. // SetOrganizationID sets the "organization_id" field.
  41675. func (m *WxMutation) SetOrganizationID(u uint64) {
  41676. m.organization_id = &u
  41677. m.addorganization_id = nil
  41678. }
  41679. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41680. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  41681. v := m.organization_id
  41682. if v == nil {
  41683. return
  41684. }
  41685. return *v, true
  41686. }
  41687. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  41688. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41690. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41691. if !m.op.Is(OpUpdateOne) {
  41692. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41693. }
  41694. if m.id == nil || m.oldValue == nil {
  41695. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41696. }
  41697. oldValue, err := m.oldValue(ctx)
  41698. if err != nil {
  41699. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41700. }
  41701. return oldValue.OrganizationID, nil
  41702. }
  41703. // AddOrganizationID adds u to the "organization_id" field.
  41704. func (m *WxMutation) AddOrganizationID(u int64) {
  41705. if m.addorganization_id != nil {
  41706. *m.addorganization_id += u
  41707. } else {
  41708. m.addorganization_id = &u
  41709. }
  41710. }
  41711. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41712. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  41713. v := m.addorganization_id
  41714. if v == nil {
  41715. return
  41716. }
  41717. return *v, true
  41718. }
  41719. // ClearOrganizationID clears the value of the "organization_id" field.
  41720. func (m *WxMutation) ClearOrganizationID() {
  41721. m.organization_id = nil
  41722. m.addorganization_id = nil
  41723. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  41724. }
  41725. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41726. func (m *WxMutation) OrganizationIDCleared() bool {
  41727. _, ok := m.clearedFields[wx.FieldOrganizationID]
  41728. return ok
  41729. }
  41730. // ResetOrganizationID resets all changes to the "organization_id" field.
  41731. func (m *WxMutation) ResetOrganizationID() {
  41732. m.organization_id = nil
  41733. m.addorganization_id = nil
  41734. delete(m.clearedFields, wx.FieldOrganizationID)
  41735. }
  41736. // SetAgentID sets the "agent_id" field.
  41737. func (m *WxMutation) SetAgentID(u uint64) {
  41738. m.agent = &u
  41739. }
  41740. // AgentID returns the value of the "agent_id" field in the mutation.
  41741. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  41742. v := m.agent
  41743. if v == nil {
  41744. return
  41745. }
  41746. return *v, true
  41747. }
  41748. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  41749. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41751. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  41752. if !m.op.Is(OpUpdateOne) {
  41753. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  41754. }
  41755. if m.id == nil || m.oldValue == nil {
  41756. return v, errors.New("OldAgentID requires an ID field in the mutation")
  41757. }
  41758. oldValue, err := m.oldValue(ctx)
  41759. if err != nil {
  41760. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  41761. }
  41762. return oldValue.AgentID, nil
  41763. }
  41764. // ResetAgentID resets all changes to the "agent_id" field.
  41765. func (m *WxMutation) ResetAgentID() {
  41766. m.agent = nil
  41767. }
  41768. // SetAPIBase sets the "api_base" field.
  41769. func (m *WxMutation) SetAPIBase(s string) {
  41770. m.api_base = &s
  41771. }
  41772. // APIBase returns the value of the "api_base" field in the mutation.
  41773. func (m *WxMutation) APIBase() (r string, exists bool) {
  41774. v := m.api_base
  41775. if v == nil {
  41776. return
  41777. }
  41778. return *v, true
  41779. }
  41780. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  41781. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41783. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  41784. if !m.op.Is(OpUpdateOne) {
  41785. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  41786. }
  41787. if m.id == nil || m.oldValue == nil {
  41788. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  41789. }
  41790. oldValue, err := m.oldValue(ctx)
  41791. if err != nil {
  41792. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  41793. }
  41794. return oldValue.APIBase, nil
  41795. }
  41796. // ClearAPIBase clears the value of the "api_base" field.
  41797. func (m *WxMutation) ClearAPIBase() {
  41798. m.api_base = nil
  41799. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  41800. }
  41801. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  41802. func (m *WxMutation) APIBaseCleared() bool {
  41803. _, ok := m.clearedFields[wx.FieldAPIBase]
  41804. return ok
  41805. }
  41806. // ResetAPIBase resets all changes to the "api_base" field.
  41807. func (m *WxMutation) ResetAPIBase() {
  41808. m.api_base = nil
  41809. delete(m.clearedFields, wx.FieldAPIBase)
  41810. }
  41811. // SetAPIKey sets the "api_key" field.
  41812. func (m *WxMutation) SetAPIKey(s string) {
  41813. m.api_key = &s
  41814. }
  41815. // APIKey returns the value of the "api_key" field in the mutation.
  41816. func (m *WxMutation) APIKey() (r string, exists bool) {
  41817. v := m.api_key
  41818. if v == nil {
  41819. return
  41820. }
  41821. return *v, true
  41822. }
  41823. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  41824. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41826. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  41827. if !m.op.Is(OpUpdateOne) {
  41828. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  41829. }
  41830. if m.id == nil || m.oldValue == nil {
  41831. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  41832. }
  41833. oldValue, err := m.oldValue(ctx)
  41834. if err != nil {
  41835. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  41836. }
  41837. return oldValue.APIKey, nil
  41838. }
  41839. // ClearAPIKey clears the value of the "api_key" field.
  41840. func (m *WxMutation) ClearAPIKey() {
  41841. m.api_key = nil
  41842. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  41843. }
  41844. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  41845. func (m *WxMutation) APIKeyCleared() bool {
  41846. _, ok := m.clearedFields[wx.FieldAPIKey]
  41847. return ok
  41848. }
  41849. // ResetAPIKey resets all changes to the "api_key" field.
  41850. func (m *WxMutation) ResetAPIKey() {
  41851. m.api_key = nil
  41852. delete(m.clearedFields, wx.FieldAPIKey)
  41853. }
  41854. // SetAllowList sets the "allow_list" field.
  41855. func (m *WxMutation) SetAllowList(s []string) {
  41856. m.allow_list = &s
  41857. m.appendallow_list = nil
  41858. }
  41859. // AllowList returns the value of the "allow_list" field in the mutation.
  41860. func (m *WxMutation) AllowList() (r []string, exists bool) {
  41861. v := m.allow_list
  41862. if v == nil {
  41863. return
  41864. }
  41865. return *v, true
  41866. }
  41867. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  41868. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41870. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  41871. if !m.op.Is(OpUpdateOne) {
  41872. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  41873. }
  41874. if m.id == nil || m.oldValue == nil {
  41875. return v, errors.New("OldAllowList requires an ID field in the mutation")
  41876. }
  41877. oldValue, err := m.oldValue(ctx)
  41878. if err != nil {
  41879. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  41880. }
  41881. return oldValue.AllowList, nil
  41882. }
  41883. // AppendAllowList adds s to the "allow_list" field.
  41884. func (m *WxMutation) AppendAllowList(s []string) {
  41885. m.appendallow_list = append(m.appendallow_list, s...)
  41886. }
  41887. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  41888. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  41889. if len(m.appendallow_list) == 0 {
  41890. return nil, false
  41891. }
  41892. return m.appendallow_list, true
  41893. }
  41894. // ResetAllowList resets all changes to the "allow_list" field.
  41895. func (m *WxMutation) ResetAllowList() {
  41896. m.allow_list = nil
  41897. m.appendallow_list = nil
  41898. }
  41899. // SetGroupAllowList sets the "group_allow_list" field.
  41900. func (m *WxMutation) SetGroupAllowList(s []string) {
  41901. m.group_allow_list = &s
  41902. m.appendgroup_allow_list = nil
  41903. }
  41904. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  41905. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  41906. v := m.group_allow_list
  41907. if v == nil {
  41908. return
  41909. }
  41910. return *v, true
  41911. }
  41912. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  41913. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41915. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  41916. if !m.op.Is(OpUpdateOne) {
  41917. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  41918. }
  41919. if m.id == nil || m.oldValue == nil {
  41920. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  41921. }
  41922. oldValue, err := m.oldValue(ctx)
  41923. if err != nil {
  41924. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  41925. }
  41926. return oldValue.GroupAllowList, nil
  41927. }
  41928. // AppendGroupAllowList adds s to the "group_allow_list" field.
  41929. func (m *WxMutation) AppendGroupAllowList(s []string) {
  41930. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  41931. }
  41932. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  41933. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  41934. if len(m.appendgroup_allow_list) == 0 {
  41935. return nil, false
  41936. }
  41937. return m.appendgroup_allow_list, true
  41938. }
  41939. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  41940. func (m *WxMutation) ResetGroupAllowList() {
  41941. m.group_allow_list = nil
  41942. m.appendgroup_allow_list = nil
  41943. }
  41944. // SetBlockList sets the "block_list" field.
  41945. func (m *WxMutation) SetBlockList(s []string) {
  41946. m.block_list = &s
  41947. m.appendblock_list = nil
  41948. }
  41949. // BlockList returns the value of the "block_list" field in the mutation.
  41950. func (m *WxMutation) BlockList() (r []string, exists bool) {
  41951. v := m.block_list
  41952. if v == nil {
  41953. return
  41954. }
  41955. return *v, true
  41956. }
  41957. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  41958. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41960. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  41961. if !m.op.Is(OpUpdateOne) {
  41962. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  41963. }
  41964. if m.id == nil || m.oldValue == nil {
  41965. return v, errors.New("OldBlockList requires an ID field in the mutation")
  41966. }
  41967. oldValue, err := m.oldValue(ctx)
  41968. if err != nil {
  41969. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  41970. }
  41971. return oldValue.BlockList, nil
  41972. }
  41973. // AppendBlockList adds s to the "block_list" field.
  41974. func (m *WxMutation) AppendBlockList(s []string) {
  41975. m.appendblock_list = append(m.appendblock_list, s...)
  41976. }
  41977. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  41978. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  41979. if len(m.appendblock_list) == 0 {
  41980. return nil, false
  41981. }
  41982. return m.appendblock_list, true
  41983. }
  41984. // ResetBlockList resets all changes to the "block_list" field.
  41985. func (m *WxMutation) ResetBlockList() {
  41986. m.block_list = nil
  41987. m.appendblock_list = nil
  41988. }
  41989. // SetGroupBlockList sets the "group_block_list" field.
  41990. func (m *WxMutation) SetGroupBlockList(s []string) {
  41991. m.group_block_list = &s
  41992. m.appendgroup_block_list = nil
  41993. }
  41994. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  41995. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  41996. v := m.group_block_list
  41997. if v == nil {
  41998. return
  41999. }
  42000. return *v, true
  42001. }
  42002. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  42003. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42005. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  42006. if !m.op.Is(OpUpdateOne) {
  42007. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  42008. }
  42009. if m.id == nil || m.oldValue == nil {
  42010. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  42011. }
  42012. oldValue, err := m.oldValue(ctx)
  42013. if err != nil {
  42014. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  42015. }
  42016. return oldValue.GroupBlockList, nil
  42017. }
  42018. // AppendGroupBlockList adds s to the "group_block_list" field.
  42019. func (m *WxMutation) AppendGroupBlockList(s []string) {
  42020. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  42021. }
  42022. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  42023. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  42024. if len(m.appendgroup_block_list) == 0 {
  42025. return nil, false
  42026. }
  42027. return m.appendgroup_block_list, true
  42028. }
  42029. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  42030. func (m *WxMutation) ResetGroupBlockList() {
  42031. m.group_block_list = nil
  42032. m.appendgroup_block_list = nil
  42033. }
  42034. // SetCtype sets the "ctype" field.
  42035. func (m *WxMutation) SetCtype(u uint64) {
  42036. m.ctype = &u
  42037. m.addctype = nil
  42038. }
  42039. // Ctype returns the value of the "ctype" field in the mutation.
  42040. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  42041. v := m.ctype
  42042. if v == nil {
  42043. return
  42044. }
  42045. return *v, true
  42046. }
  42047. // OldCtype returns the old "ctype" field's value of the Wx entity.
  42048. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42050. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  42051. if !m.op.Is(OpUpdateOne) {
  42052. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  42053. }
  42054. if m.id == nil || m.oldValue == nil {
  42055. return v, errors.New("OldCtype requires an ID field in the mutation")
  42056. }
  42057. oldValue, err := m.oldValue(ctx)
  42058. if err != nil {
  42059. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  42060. }
  42061. return oldValue.Ctype, nil
  42062. }
  42063. // AddCtype adds u to the "ctype" field.
  42064. func (m *WxMutation) AddCtype(u int64) {
  42065. if m.addctype != nil {
  42066. *m.addctype += u
  42067. } else {
  42068. m.addctype = &u
  42069. }
  42070. }
  42071. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  42072. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  42073. v := m.addctype
  42074. if v == nil {
  42075. return
  42076. }
  42077. return *v, true
  42078. }
  42079. // ClearCtype clears the value of the "ctype" field.
  42080. func (m *WxMutation) ClearCtype() {
  42081. m.ctype = nil
  42082. m.addctype = nil
  42083. m.clearedFields[wx.FieldCtype] = struct{}{}
  42084. }
  42085. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  42086. func (m *WxMutation) CtypeCleared() bool {
  42087. _, ok := m.clearedFields[wx.FieldCtype]
  42088. return ok
  42089. }
  42090. // ResetCtype resets all changes to the "ctype" field.
  42091. func (m *WxMutation) ResetCtype() {
  42092. m.ctype = nil
  42093. m.addctype = nil
  42094. delete(m.clearedFields, wx.FieldCtype)
  42095. }
  42096. // ClearServer clears the "server" edge to the Server entity.
  42097. func (m *WxMutation) ClearServer() {
  42098. m.clearedserver = true
  42099. m.clearedFields[wx.FieldServerID] = struct{}{}
  42100. }
  42101. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  42102. func (m *WxMutation) ServerCleared() bool {
  42103. return m.ServerIDCleared() || m.clearedserver
  42104. }
  42105. // ServerIDs returns the "server" edge IDs in the mutation.
  42106. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42107. // ServerID instead. It exists only for internal usage by the builders.
  42108. func (m *WxMutation) ServerIDs() (ids []uint64) {
  42109. if id := m.server; id != nil {
  42110. ids = append(ids, *id)
  42111. }
  42112. return
  42113. }
  42114. // ResetServer resets all changes to the "server" edge.
  42115. func (m *WxMutation) ResetServer() {
  42116. m.server = nil
  42117. m.clearedserver = false
  42118. }
  42119. // ClearAgent clears the "agent" edge to the Agent entity.
  42120. func (m *WxMutation) ClearAgent() {
  42121. m.clearedagent = true
  42122. m.clearedFields[wx.FieldAgentID] = struct{}{}
  42123. }
  42124. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  42125. func (m *WxMutation) AgentCleared() bool {
  42126. return m.clearedagent
  42127. }
  42128. // AgentIDs returns the "agent" edge IDs in the mutation.
  42129. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42130. // AgentID instead. It exists only for internal usage by the builders.
  42131. func (m *WxMutation) AgentIDs() (ids []uint64) {
  42132. if id := m.agent; id != nil {
  42133. ids = append(ids, *id)
  42134. }
  42135. return
  42136. }
  42137. // ResetAgent resets all changes to the "agent" edge.
  42138. func (m *WxMutation) ResetAgent() {
  42139. m.agent = nil
  42140. m.clearedagent = false
  42141. }
  42142. // Where appends a list predicates to the WxMutation builder.
  42143. func (m *WxMutation) Where(ps ...predicate.Wx) {
  42144. m.predicates = append(m.predicates, ps...)
  42145. }
  42146. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  42147. // users can use type-assertion to append predicates that do not depend on any generated package.
  42148. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  42149. p := make([]predicate.Wx, len(ps))
  42150. for i := range ps {
  42151. p[i] = ps[i]
  42152. }
  42153. m.Where(p...)
  42154. }
  42155. // Op returns the operation name.
  42156. func (m *WxMutation) Op() Op {
  42157. return m.op
  42158. }
  42159. // SetOp allows setting the mutation operation.
  42160. func (m *WxMutation) SetOp(op Op) {
  42161. m.op = op
  42162. }
  42163. // Type returns the node type of this mutation (Wx).
  42164. func (m *WxMutation) Type() string {
  42165. return m.typ
  42166. }
  42167. // Fields returns all fields that were changed during this mutation. Note that in
  42168. // order to get all numeric fields that were incremented/decremented, call
  42169. // AddedFields().
  42170. func (m *WxMutation) Fields() []string {
  42171. fields := make([]string, 0, 22)
  42172. if m.created_at != nil {
  42173. fields = append(fields, wx.FieldCreatedAt)
  42174. }
  42175. if m.updated_at != nil {
  42176. fields = append(fields, wx.FieldUpdatedAt)
  42177. }
  42178. if m.status != nil {
  42179. fields = append(fields, wx.FieldStatus)
  42180. }
  42181. if m.deleted_at != nil {
  42182. fields = append(fields, wx.FieldDeletedAt)
  42183. }
  42184. if m.server != nil {
  42185. fields = append(fields, wx.FieldServerID)
  42186. }
  42187. if m.port != nil {
  42188. fields = append(fields, wx.FieldPort)
  42189. }
  42190. if m.process_id != nil {
  42191. fields = append(fields, wx.FieldProcessID)
  42192. }
  42193. if m.callback != nil {
  42194. fields = append(fields, wx.FieldCallback)
  42195. }
  42196. if m.wxid != nil {
  42197. fields = append(fields, wx.FieldWxid)
  42198. }
  42199. if m.account != nil {
  42200. fields = append(fields, wx.FieldAccount)
  42201. }
  42202. if m.nickname != nil {
  42203. fields = append(fields, wx.FieldNickname)
  42204. }
  42205. if m.tel != nil {
  42206. fields = append(fields, wx.FieldTel)
  42207. }
  42208. if m.head_big != nil {
  42209. fields = append(fields, wx.FieldHeadBig)
  42210. }
  42211. if m.organization_id != nil {
  42212. fields = append(fields, wx.FieldOrganizationID)
  42213. }
  42214. if m.agent != nil {
  42215. fields = append(fields, wx.FieldAgentID)
  42216. }
  42217. if m.api_base != nil {
  42218. fields = append(fields, wx.FieldAPIBase)
  42219. }
  42220. if m.api_key != nil {
  42221. fields = append(fields, wx.FieldAPIKey)
  42222. }
  42223. if m.allow_list != nil {
  42224. fields = append(fields, wx.FieldAllowList)
  42225. }
  42226. if m.group_allow_list != nil {
  42227. fields = append(fields, wx.FieldGroupAllowList)
  42228. }
  42229. if m.block_list != nil {
  42230. fields = append(fields, wx.FieldBlockList)
  42231. }
  42232. if m.group_block_list != nil {
  42233. fields = append(fields, wx.FieldGroupBlockList)
  42234. }
  42235. if m.ctype != nil {
  42236. fields = append(fields, wx.FieldCtype)
  42237. }
  42238. return fields
  42239. }
  42240. // Field returns the value of a field with the given name. The second boolean
  42241. // return value indicates that this field was not set, or was not defined in the
  42242. // schema.
  42243. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  42244. switch name {
  42245. case wx.FieldCreatedAt:
  42246. return m.CreatedAt()
  42247. case wx.FieldUpdatedAt:
  42248. return m.UpdatedAt()
  42249. case wx.FieldStatus:
  42250. return m.Status()
  42251. case wx.FieldDeletedAt:
  42252. return m.DeletedAt()
  42253. case wx.FieldServerID:
  42254. return m.ServerID()
  42255. case wx.FieldPort:
  42256. return m.Port()
  42257. case wx.FieldProcessID:
  42258. return m.ProcessID()
  42259. case wx.FieldCallback:
  42260. return m.Callback()
  42261. case wx.FieldWxid:
  42262. return m.Wxid()
  42263. case wx.FieldAccount:
  42264. return m.Account()
  42265. case wx.FieldNickname:
  42266. return m.Nickname()
  42267. case wx.FieldTel:
  42268. return m.Tel()
  42269. case wx.FieldHeadBig:
  42270. return m.HeadBig()
  42271. case wx.FieldOrganizationID:
  42272. return m.OrganizationID()
  42273. case wx.FieldAgentID:
  42274. return m.AgentID()
  42275. case wx.FieldAPIBase:
  42276. return m.APIBase()
  42277. case wx.FieldAPIKey:
  42278. return m.APIKey()
  42279. case wx.FieldAllowList:
  42280. return m.AllowList()
  42281. case wx.FieldGroupAllowList:
  42282. return m.GroupAllowList()
  42283. case wx.FieldBlockList:
  42284. return m.BlockList()
  42285. case wx.FieldGroupBlockList:
  42286. return m.GroupBlockList()
  42287. case wx.FieldCtype:
  42288. return m.Ctype()
  42289. }
  42290. return nil, false
  42291. }
  42292. // OldField returns the old value of the field from the database. An error is
  42293. // returned if the mutation operation is not UpdateOne, or the query to the
  42294. // database failed.
  42295. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42296. switch name {
  42297. case wx.FieldCreatedAt:
  42298. return m.OldCreatedAt(ctx)
  42299. case wx.FieldUpdatedAt:
  42300. return m.OldUpdatedAt(ctx)
  42301. case wx.FieldStatus:
  42302. return m.OldStatus(ctx)
  42303. case wx.FieldDeletedAt:
  42304. return m.OldDeletedAt(ctx)
  42305. case wx.FieldServerID:
  42306. return m.OldServerID(ctx)
  42307. case wx.FieldPort:
  42308. return m.OldPort(ctx)
  42309. case wx.FieldProcessID:
  42310. return m.OldProcessID(ctx)
  42311. case wx.FieldCallback:
  42312. return m.OldCallback(ctx)
  42313. case wx.FieldWxid:
  42314. return m.OldWxid(ctx)
  42315. case wx.FieldAccount:
  42316. return m.OldAccount(ctx)
  42317. case wx.FieldNickname:
  42318. return m.OldNickname(ctx)
  42319. case wx.FieldTel:
  42320. return m.OldTel(ctx)
  42321. case wx.FieldHeadBig:
  42322. return m.OldHeadBig(ctx)
  42323. case wx.FieldOrganizationID:
  42324. return m.OldOrganizationID(ctx)
  42325. case wx.FieldAgentID:
  42326. return m.OldAgentID(ctx)
  42327. case wx.FieldAPIBase:
  42328. return m.OldAPIBase(ctx)
  42329. case wx.FieldAPIKey:
  42330. return m.OldAPIKey(ctx)
  42331. case wx.FieldAllowList:
  42332. return m.OldAllowList(ctx)
  42333. case wx.FieldGroupAllowList:
  42334. return m.OldGroupAllowList(ctx)
  42335. case wx.FieldBlockList:
  42336. return m.OldBlockList(ctx)
  42337. case wx.FieldGroupBlockList:
  42338. return m.OldGroupBlockList(ctx)
  42339. case wx.FieldCtype:
  42340. return m.OldCtype(ctx)
  42341. }
  42342. return nil, fmt.Errorf("unknown Wx field %s", name)
  42343. }
  42344. // SetField sets the value of a field with the given name. It returns an error if
  42345. // the field is not defined in the schema, or if the type mismatched the field
  42346. // type.
  42347. func (m *WxMutation) SetField(name string, value ent.Value) error {
  42348. switch name {
  42349. case wx.FieldCreatedAt:
  42350. v, ok := value.(time.Time)
  42351. if !ok {
  42352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42353. }
  42354. m.SetCreatedAt(v)
  42355. return nil
  42356. case wx.FieldUpdatedAt:
  42357. v, ok := value.(time.Time)
  42358. if !ok {
  42359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42360. }
  42361. m.SetUpdatedAt(v)
  42362. return nil
  42363. case wx.FieldStatus:
  42364. v, ok := value.(uint8)
  42365. if !ok {
  42366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42367. }
  42368. m.SetStatus(v)
  42369. return nil
  42370. case wx.FieldDeletedAt:
  42371. v, ok := value.(time.Time)
  42372. if !ok {
  42373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42374. }
  42375. m.SetDeletedAt(v)
  42376. return nil
  42377. case wx.FieldServerID:
  42378. v, ok := value.(uint64)
  42379. if !ok {
  42380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42381. }
  42382. m.SetServerID(v)
  42383. return nil
  42384. case wx.FieldPort:
  42385. v, ok := value.(string)
  42386. if !ok {
  42387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42388. }
  42389. m.SetPort(v)
  42390. return nil
  42391. case wx.FieldProcessID:
  42392. v, ok := value.(string)
  42393. if !ok {
  42394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42395. }
  42396. m.SetProcessID(v)
  42397. return nil
  42398. case wx.FieldCallback:
  42399. v, ok := value.(string)
  42400. if !ok {
  42401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42402. }
  42403. m.SetCallback(v)
  42404. return nil
  42405. case wx.FieldWxid:
  42406. v, ok := value.(string)
  42407. if !ok {
  42408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42409. }
  42410. m.SetWxid(v)
  42411. return nil
  42412. case wx.FieldAccount:
  42413. v, ok := value.(string)
  42414. if !ok {
  42415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42416. }
  42417. m.SetAccount(v)
  42418. return nil
  42419. case wx.FieldNickname:
  42420. v, ok := value.(string)
  42421. if !ok {
  42422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42423. }
  42424. m.SetNickname(v)
  42425. return nil
  42426. case wx.FieldTel:
  42427. v, ok := value.(string)
  42428. if !ok {
  42429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42430. }
  42431. m.SetTel(v)
  42432. return nil
  42433. case wx.FieldHeadBig:
  42434. v, ok := value.(string)
  42435. if !ok {
  42436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42437. }
  42438. m.SetHeadBig(v)
  42439. return nil
  42440. case wx.FieldOrganizationID:
  42441. v, ok := value.(uint64)
  42442. if !ok {
  42443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42444. }
  42445. m.SetOrganizationID(v)
  42446. return nil
  42447. case wx.FieldAgentID:
  42448. v, ok := value.(uint64)
  42449. if !ok {
  42450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42451. }
  42452. m.SetAgentID(v)
  42453. return nil
  42454. case wx.FieldAPIBase:
  42455. v, ok := value.(string)
  42456. if !ok {
  42457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42458. }
  42459. m.SetAPIBase(v)
  42460. return nil
  42461. case wx.FieldAPIKey:
  42462. v, ok := value.(string)
  42463. if !ok {
  42464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42465. }
  42466. m.SetAPIKey(v)
  42467. return nil
  42468. case wx.FieldAllowList:
  42469. v, ok := value.([]string)
  42470. if !ok {
  42471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42472. }
  42473. m.SetAllowList(v)
  42474. return nil
  42475. case wx.FieldGroupAllowList:
  42476. v, ok := value.([]string)
  42477. if !ok {
  42478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42479. }
  42480. m.SetGroupAllowList(v)
  42481. return nil
  42482. case wx.FieldBlockList:
  42483. v, ok := value.([]string)
  42484. if !ok {
  42485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42486. }
  42487. m.SetBlockList(v)
  42488. return nil
  42489. case wx.FieldGroupBlockList:
  42490. v, ok := value.([]string)
  42491. if !ok {
  42492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42493. }
  42494. m.SetGroupBlockList(v)
  42495. return nil
  42496. case wx.FieldCtype:
  42497. v, ok := value.(uint64)
  42498. if !ok {
  42499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42500. }
  42501. m.SetCtype(v)
  42502. return nil
  42503. }
  42504. return fmt.Errorf("unknown Wx field %s", name)
  42505. }
  42506. // AddedFields returns all numeric fields that were incremented/decremented during
  42507. // this mutation.
  42508. func (m *WxMutation) AddedFields() []string {
  42509. var fields []string
  42510. if m.addstatus != nil {
  42511. fields = append(fields, wx.FieldStatus)
  42512. }
  42513. if m.addorganization_id != nil {
  42514. fields = append(fields, wx.FieldOrganizationID)
  42515. }
  42516. if m.addctype != nil {
  42517. fields = append(fields, wx.FieldCtype)
  42518. }
  42519. return fields
  42520. }
  42521. // AddedField returns the numeric value that was incremented/decremented on a field
  42522. // with the given name. The second boolean return value indicates that this field
  42523. // was not set, or was not defined in the schema.
  42524. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  42525. switch name {
  42526. case wx.FieldStatus:
  42527. return m.AddedStatus()
  42528. case wx.FieldOrganizationID:
  42529. return m.AddedOrganizationID()
  42530. case wx.FieldCtype:
  42531. return m.AddedCtype()
  42532. }
  42533. return nil, false
  42534. }
  42535. // AddField adds the value to the field with the given name. It returns an error if
  42536. // the field is not defined in the schema, or if the type mismatched the field
  42537. // type.
  42538. func (m *WxMutation) AddField(name string, value ent.Value) error {
  42539. switch name {
  42540. case wx.FieldStatus:
  42541. v, ok := value.(int8)
  42542. if !ok {
  42543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42544. }
  42545. m.AddStatus(v)
  42546. return nil
  42547. case wx.FieldOrganizationID:
  42548. v, ok := value.(int64)
  42549. if !ok {
  42550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42551. }
  42552. m.AddOrganizationID(v)
  42553. return nil
  42554. case wx.FieldCtype:
  42555. v, ok := value.(int64)
  42556. if !ok {
  42557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42558. }
  42559. m.AddCtype(v)
  42560. return nil
  42561. }
  42562. return fmt.Errorf("unknown Wx numeric field %s", name)
  42563. }
  42564. // ClearedFields returns all nullable fields that were cleared during this
  42565. // mutation.
  42566. func (m *WxMutation) ClearedFields() []string {
  42567. var fields []string
  42568. if m.FieldCleared(wx.FieldStatus) {
  42569. fields = append(fields, wx.FieldStatus)
  42570. }
  42571. if m.FieldCleared(wx.FieldDeletedAt) {
  42572. fields = append(fields, wx.FieldDeletedAt)
  42573. }
  42574. if m.FieldCleared(wx.FieldServerID) {
  42575. fields = append(fields, wx.FieldServerID)
  42576. }
  42577. if m.FieldCleared(wx.FieldOrganizationID) {
  42578. fields = append(fields, wx.FieldOrganizationID)
  42579. }
  42580. if m.FieldCleared(wx.FieldAPIBase) {
  42581. fields = append(fields, wx.FieldAPIBase)
  42582. }
  42583. if m.FieldCleared(wx.FieldAPIKey) {
  42584. fields = append(fields, wx.FieldAPIKey)
  42585. }
  42586. if m.FieldCleared(wx.FieldCtype) {
  42587. fields = append(fields, wx.FieldCtype)
  42588. }
  42589. return fields
  42590. }
  42591. // FieldCleared returns a boolean indicating if a field with the given name was
  42592. // cleared in this mutation.
  42593. func (m *WxMutation) FieldCleared(name string) bool {
  42594. _, ok := m.clearedFields[name]
  42595. return ok
  42596. }
  42597. // ClearField clears the value of the field with the given name. It returns an
  42598. // error if the field is not defined in the schema.
  42599. func (m *WxMutation) ClearField(name string) error {
  42600. switch name {
  42601. case wx.FieldStatus:
  42602. m.ClearStatus()
  42603. return nil
  42604. case wx.FieldDeletedAt:
  42605. m.ClearDeletedAt()
  42606. return nil
  42607. case wx.FieldServerID:
  42608. m.ClearServerID()
  42609. return nil
  42610. case wx.FieldOrganizationID:
  42611. m.ClearOrganizationID()
  42612. return nil
  42613. case wx.FieldAPIBase:
  42614. m.ClearAPIBase()
  42615. return nil
  42616. case wx.FieldAPIKey:
  42617. m.ClearAPIKey()
  42618. return nil
  42619. case wx.FieldCtype:
  42620. m.ClearCtype()
  42621. return nil
  42622. }
  42623. return fmt.Errorf("unknown Wx nullable field %s", name)
  42624. }
  42625. // ResetField resets all changes in the mutation for the field with the given name.
  42626. // It returns an error if the field is not defined in the schema.
  42627. func (m *WxMutation) ResetField(name string) error {
  42628. switch name {
  42629. case wx.FieldCreatedAt:
  42630. m.ResetCreatedAt()
  42631. return nil
  42632. case wx.FieldUpdatedAt:
  42633. m.ResetUpdatedAt()
  42634. return nil
  42635. case wx.FieldStatus:
  42636. m.ResetStatus()
  42637. return nil
  42638. case wx.FieldDeletedAt:
  42639. m.ResetDeletedAt()
  42640. return nil
  42641. case wx.FieldServerID:
  42642. m.ResetServerID()
  42643. return nil
  42644. case wx.FieldPort:
  42645. m.ResetPort()
  42646. return nil
  42647. case wx.FieldProcessID:
  42648. m.ResetProcessID()
  42649. return nil
  42650. case wx.FieldCallback:
  42651. m.ResetCallback()
  42652. return nil
  42653. case wx.FieldWxid:
  42654. m.ResetWxid()
  42655. return nil
  42656. case wx.FieldAccount:
  42657. m.ResetAccount()
  42658. return nil
  42659. case wx.FieldNickname:
  42660. m.ResetNickname()
  42661. return nil
  42662. case wx.FieldTel:
  42663. m.ResetTel()
  42664. return nil
  42665. case wx.FieldHeadBig:
  42666. m.ResetHeadBig()
  42667. return nil
  42668. case wx.FieldOrganizationID:
  42669. m.ResetOrganizationID()
  42670. return nil
  42671. case wx.FieldAgentID:
  42672. m.ResetAgentID()
  42673. return nil
  42674. case wx.FieldAPIBase:
  42675. m.ResetAPIBase()
  42676. return nil
  42677. case wx.FieldAPIKey:
  42678. m.ResetAPIKey()
  42679. return nil
  42680. case wx.FieldAllowList:
  42681. m.ResetAllowList()
  42682. return nil
  42683. case wx.FieldGroupAllowList:
  42684. m.ResetGroupAllowList()
  42685. return nil
  42686. case wx.FieldBlockList:
  42687. m.ResetBlockList()
  42688. return nil
  42689. case wx.FieldGroupBlockList:
  42690. m.ResetGroupBlockList()
  42691. return nil
  42692. case wx.FieldCtype:
  42693. m.ResetCtype()
  42694. return nil
  42695. }
  42696. return fmt.Errorf("unknown Wx field %s", name)
  42697. }
  42698. // AddedEdges returns all edge names that were set/added in this mutation.
  42699. func (m *WxMutation) AddedEdges() []string {
  42700. edges := make([]string, 0, 2)
  42701. if m.server != nil {
  42702. edges = append(edges, wx.EdgeServer)
  42703. }
  42704. if m.agent != nil {
  42705. edges = append(edges, wx.EdgeAgent)
  42706. }
  42707. return edges
  42708. }
  42709. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42710. // name in this mutation.
  42711. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  42712. switch name {
  42713. case wx.EdgeServer:
  42714. if id := m.server; id != nil {
  42715. return []ent.Value{*id}
  42716. }
  42717. case wx.EdgeAgent:
  42718. if id := m.agent; id != nil {
  42719. return []ent.Value{*id}
  42720. }
  42721. }
  42722. return nil
  42723. }
  42724. // RemovedEdges returns all edge names that were removed in this mutation.
  42725. func (m *WxMutation) RemovedEdges() []string {
  42726. edges := make([]string, 0, 2)
  42727. return edges
  42728. }
  42729. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42730. // the given name in this mutation.
  42731. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  42732. return nil
  42733. }
  42734. // ClearedEdges returns all edge names that were cleared in this mutation.
  42735. func (m *WxMutation) ClearedEdges() []string {
  42736. edges := make([]string, 0, 2)
  42737. if m.clearedserver {
  42738. edges = append(edges, wx.EdgeServer)
  42739. }
  42740. if m.clearedagent {
  42741. edges = append(edges, wx.EdgeAgent)
  42742. }
  42743. return edges
  42744. }
  42745. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42746. // was cleared in this mutation.
  42747. func (m *WxMutation) EdgeCleared(name string) bool {
  42748. switch name {
  42749. case wx.EdgeServer:
  42750. return m.clearedserver
  42751. case wx.EdgeAgent:
  42752. return m.clearedagent
  42753. }
  42754. return false
  42755. }
  42756. // ClearEdge clears the value of the edge with the given name. It returns an error
  42757. // if that edge is not defined in the schema.
  42758. func (m *WxMutation) ClearEdge(name string) error {
  42759. switch name {
  42760. case wx.EdgeServer:
  42761. m.ClearServer()
  42762. return nil
  42763. case wx.EdgeAgent:
  42764. m.ClearAgent()
  42765. return nil
  42766. }
  42767. return fmt.Errorf("unknown Wx unique edge %s", name)
  42768. }
  42769. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42770. // It returns an error if the edge is not defined in the schema.
  42771. func (m *WxMutation) ResetEdge(name string) error {
  42772. switch name {
  42773. case wx.EdgeServer:
  42774. m.ResetServer()
  42775. return nil
  42776. case wx.EdgeAgent:
  42777. m.ResetAgent()
  42778. return nil
  42779. }
  42780. return fmt.Errorf("unknown Wx edge %s", name)
  42781. }
  42782. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  42783. type WxCardMutation struct {
  42784. config
  42785. op Op
  42786. typ string
  42787. id *uint64
  42788. created_at *time.Time
  42789. updated_at *time.Time
  42790. deleted_at *time.Time
  42791. user_id *uint64
  42792. adduser_id *int64
  42793. wx_user_id *uint64
  42794. addwx_user_id *int64
  42795. avatar *string
  42796. logo *string
  42797. name *string
  42798. company *string
  42799. address *string
  42800. phone *string
  42801. official_account *string
  42802. wechat_account *string
  42803. email *string
  42804. api_base *string
  42805. api_key *string
  42806. ai_info *string
  42807. intro *string
  42808. clearedFields map[string]struct{}
  42809. done bool
  42810. oldValue func(context.Context) (*WxCard, error)
  42811. predicates []predicate.WxCard
  42812. }
  42813. var _ ent.Mutation = (*WxCardMutation)(nil)
  42814. // wxcardOption allows management of the mutation configuration using functional options.
  42815. type wxcardOption func(*WxCardMutation)
  42816. // newWxCardMutation creates new mutation for the WxCard entity.
  42817. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  42818. m := &WxCardMutation{
  42819. config: c,
  42820. op: op,
  42821. typ: TypeWxCard,
  42822. clearedFields: make(map[string]struct{}),
  42823. }
  42824. for _, opt := range opts {
  42825. opt(m)
  42826. }
  42827. return m
  42828. }
  42829. // withWxCardID sets the ID field of the mutation.
  42830. func withWxCardID(id uint64) wxcardOption {
  42831. return func(m *WxCardMutation) {
  42832. var (
  42833. err error
  42834. once sync.Once
  42835. value *WxCard
  42836. )
  42837. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  42838. once.Do(func() {
  42839. if m.done {
  42840. err = errors.New("querying old values post mutation is not allowed")
  42841. } else {
  42842. value, err = m.Client().WxCard.Get(ctx, id)
  42843. }
  42844. })
  42845. return value, err
  42846. }
  42847. m.id = &id
  42848. }
  42849. }
  42850. // withWxCard sets the old WxCard of the mutation.
  42851. func withWxCard(node *WxCard) wxcardOption {
  42852. return func(m *WxCardMutation) {
  42853. m.oldValue = func(context.Context) (*WxCard, error) {
  42854. return node, nil
  42855. }
  42856. m.id = &node.ID
  42857. }
  42858. }
  42859. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42860. // executed in a transaction (ent.Tx), a transactional client is returned.
  42861. func (m WxCardMutation) Client() *Client {
  42862. client := &Client{config: m.config}
  42863. client.init()
  42864. return client
  42865. }
  42866. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42867. // it returns an error otherwise.
  42868. func (m WxCardMutation) Tx() (*Tx, error) {
  42869. if _, ok := m.driver.(*txDriver); !ok {
  42870. return nil, errors.New("ent: mutation is not running in a transaction")
  42871. }
  42872. tx := &Tx{config: m.config}
  42873. tx.init()
  42874. return tx, nil
  42875. }
  42876. // SetID sets the value of the id field. Note that this
  42877. // operation is only accepted on creation of WxCard entities.
  42878. func (m *WxCardMutation) SetID(id uint64) {
  42879. m.id = &id
  42880. }
  42881. // ID returns the ID value in the mutation. Note that the ID is only available
  42882. // if it was provided to the builder or after it was returned from the database.
  42883. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  42884. if m.id == nil {
  42885. return
  42886. }
  42887. return *m.id, true
  42888. }
  42889. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42890. // That means, if the mutation is applied within a transaction with an isolation level such
  42891. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42892. // or updated by the mutation.
  42893. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  42894. switch {
  42895. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42896. id, exists := m.ID()
  42897. if exists {
  42898. return []uint64{id}, nil
  42899. }
  42900. fallthrough
  42901. case m.op.Is(OpUpdate | OpDelete):
  42902. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  42903. default:
  42904. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42905. }
  42906. }
  42907. // SetCreatedAt sets the "created_at" field.
  42908. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  42909. m.created_at = &t
  42910. }
  42911. // CreatedAt returns the value of the "created_at" field in the mutation.
  42912. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  42913. v := m.created_at
  42914. if v == nil {
  42915. return
  42916. }
  42917. return *v, true
  42918. }
  42919. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  42920. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42922. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42923. if !m.op.Is(OpUpdateOne) {
  42924. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42925. }
  42926. if m.id == nil || m.oldValue == nil {
  42927. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42928. }
  42929. oldValue, err := m.oldValue(ctx)
  42930. if err != nil {
  42931. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42932. }
  42933. return oldValue.CreatedAt, nil
  42934. }
  42935. // ResetCreatedAt resets all changes to the "created_at" field.
  42936. func (m *WxCardMutation) ResetCreatedAt() {
  42937. m.created_at = nil
  42938. }
  42939. // SetUpdatedAt sets the "updated_at" field.
  42940. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  42941. m.updated_at = &t
  42942. }
  42943. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42944. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  42945. v := m.updated_at
  42946. if v == nil {
  42947. return
  42948. }
  42949. return *v, true
  42950. }
  42951. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  42952. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42954. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42955. if !m.op.Is(OpUpdateOne) {
  42956. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42957. }
  42958. if m.id == nil || m.oldValue == nil {
  42959. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42960. }
  42961. oldValue, err := m.oldValue(ctx)
  42962. if err != nil {
  42963. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42964. }
  42965. return oldValue.UpdatedAt, nil
  42966. }
  42967. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42968. func (m *WxCardMutation) ResetUpdatedAt() {
  42969. m.updated_at = nil
  42970. }
  42971. // SetDeletedAt sets the "deleted_at" field.
  42972. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  42973. m.deleted_at = &t
  42974. }
  42975. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42976. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  42977. v := m.deleted_at
  42978. if v == nil {
  42979. return
  42980. }
  42981. return *v, true
  42982. }
  42983. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  42984. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42986. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42987. if !m.op.Is(OpUpdateOne) {
  42988. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42989. }
  42990. if m.id == nil || m.oldValue == nil {
  42991. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42992. }
  42993. oldValue, err := m.oldValue(ctx)
  42994. if err != nil {
  42995. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42996. }
  42997. return oldValue.DeletedAt, nil
  42998. }
  42999. // ClearDeletedAt clears the value of the "deleted_at" field.
  43000. func (m *WxCardMutation) ClearDeletedAt() {
  43001. m.deleted_at = nil
  43002. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  43003. }
  43004. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43005. func (m *WxCardMutation) DeletedAtCleared() bool {
  43006. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  43007. return ok
  43008. }
  43009. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43010. func (m *WxCardMutation) ResetDeletedAt() {
  43011. m.deleted_at = nil
  43012. delete(m.clearedFields, wxcard.FieldDeletedAt)
  43013. }
  43014. // SetUserID sets the "user_id" field.
  43015. func (m *WxCardMutation) SetUserID(u uint64) {
  43016. m.user_id = &u
  43017. m.adduser_id = nil
  43018. }
  43019. // UserID returns the value of the "user_id" field in the mutation.
  43020. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  43021. v := m.user_id
  43022. if v == nil {
  43023. return
  43024. }
  43025. return *v, true
  43026. }
  43027. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  43028. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43030. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  43031. if !m.op.Is(OpUpdateOne) {
  43032. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  43033. }
  43034. if m.id == nil || m.oldValue == nil {
  43035. return v, errors.New("OldUserID requires an ID field in the mutation")
  43036. }
  43037. oldValue, err := m.oldValue(ctx)
  43038. if err != nil {
  43039. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  43040. }
  43041. return oldValue.UserID, nil
  43042. }
  43043. // AddUserID adds u to the "user_id" field.
  43044. func (m *WxCardMutation) AddUserID(u int64) {
  43045. if m.adduser_id != nil {
  43046. *m.adduser_id += u
  43047. } else {
  43048. m.adduser_id = &u
  43049. }
  43050. }
  43051. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  43052. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  43053. v := m.adduser_id
  43054. if v == nil {
  43055. return
  43056. }
  43057. return *v, true
  43058. }
  43059. // ClearUserID clears the value of the "user_id" field.
  43060. func (m *WxCardMutation) ClearUserID() {
  43061. m.user_id = nil
  43062. m.adduser_id = nil
  43063. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  43064. }
  43065. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  43066. func (m *WxCardMutation) UserIDCleared() bool {
  43067. _, ok := m.clearedFields[wxcard.FieldUserID]
  43068. return ok
  43069. }
  43070. // ResetUserID resets all changes to the "user_id" field.
  43071. func (m *WxCardMutation) ResetUserID() {
  43072. m.user_id = nil
  43073. m.adduser_id = nil
  43074. delete(m.clearedFields, wxcard.FieldUserID)
  43075. }
  43076. // SetWxUserID sets the "wx_user_id" field.
  43077. func (m *WxCardMutation) SetWxUserID(u uint64) {
  43078. m.wx_user_id = &u
  43079. m.addwx_user_id = nil
  43080. }
  43081. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  43082. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  43083. v := m.wx_user_id
  43084. if v == nil {
  43085. return
  43086. }
  43087. return *v, true
  43088. }
  43089. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  43090. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43092. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  43093. if !m.op.Is(OpUpdateOne) {
  43094. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  43095. }
  43096. if m.id == nil || m.oldValue == nil {
  43097. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  43098. }
  43099. oldValue, err := m.oldValue(ctx)
  43100. if err != nil {
  43101. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  43102. }
  43103. return oldValue.WxUserID, nil
  43104. }
  43105. // AddWxUserID adds u to the "wx_user_id" field.
  43106. func (m *WxCardMutation) AddWxUserID(u int64) {
  43107. if m.addwx_user_id != nil {
  43108. *m.addwx_user_id += u
  43109. } else {
  43110. m.addwx_user_id = &u
  43111. }
  43112. }
  43113. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  43114. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  43115. v := m.addwx_user_id
  43116. if v == nil {
  43117. return
  43118. }
  43119. return *v, true
  43120. }
  43121. // ClearWxUserID clears the value of the "wx_user_id" field.
  43122. func (m *WxCardMutation) ClearWxUserID() {
  43123. m.wx_user_id = nil
  43124. m.addwx_user_id = nil
  43125. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  43126. }
  43127. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  43128. func (m *WxCardMutation) WxUserIDCleared() bool {
  43129. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  43130. return ok
  43131. }
  43132. // ResetWxUserID resets all changes to the "wx_user_id" field.
  43133. func (m *WxCardMutation) ResetWxUserID() {
  43134. m.wx_user_id = nil
  43135. m.addwx_user_id = nil
  43136. delete(m.clearedFields, wxcard.FieldWxUserID)
  43137. }
  43138. // SetAvatar sets the "avatar" field.
  43139. func (m *WxCardMutation) SetAvatar(s string) {
  43140. m.avatar = &s
  43141. }
  43142. // Avatar returns the value of the "avatar" field in the mutation.
  43143. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  43144. v := m.avatar
  43145. if v == nil {
  43146. return
  43147. }
  43148. return *v, true
  43149. }
  43150. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  43151. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43153. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43154. if !m.op.Is(OpUpdateOne) {
  43155. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43156. }
  43157. if m.id == nil || m.oldValue == nil {
  43158. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43159. }
  43160. oldValue, err := m.oldValue(ctx)
  43161. if err != nil {
  43162. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43163. }
  43164. return oldValue.Avatar, nil
  43165. }
  43166. // ResetAvatar resets all changes to the "avatar" field.
  43167. func (m *WxCardMutation) ResetAvatar() {
  43168. m.avatar = nil
  43169. }
  43170. // SetLogo sets the "logo" field.
  43171. func (m *WxCardMutation) SetLogo(s string) {
  43172. m.logo = &s
  43173. }
  43174. // Logo returns the value of the "logo" field in the mutation.
  43175. func (m *WxCardMutation) Logo() (r string, exists bool) {
  43176. v := m.logo
  43177. if v == nil {
  43178. return
  43179. }
  43180. return *v, true
  43181. }
  43182. // OldLogo returns the old "logo" field's value of the WxCard entity.
  43183. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43185. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  43186. if !m.op.Is(OpUpdateOne) {
  43187. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  43188. }
  43189. if m.id == nil || m.oldValue == nil {
  43190. return v, errors.New("OldLogo requires an ID field in the mutation")
  43191. }
  43192. oldValue, err := m.oldValue(ctx)
  43193. if err != nil {
  43194. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  43195. }
  43196. return oldValue.Logo, nil
  43197. }
  43198. // ResetLogo resets all changes to the "logo" field.
  43199. func (m *WxCardMutation) ResetLogo() {
  43200. m.logo = nil
  43201. }
  43202. // SetName sets the "name" field.
  43203. func (m *WxCardMutation) SetName(s string) {
  43204. m.name = &s
  43205. }
  43206. // Name returns the value of the "name" field in the mutation.
  43207. func (m *WxCardMutation) Name() (r string, exists bool) {
  43208. v := m.name
  43209. if v == nil {
  43210. return
  43211. }
  43212. return *v, true
  43213. }
  43214. // OldName returns the old "name" field's value of the WxCard entity.
  43215. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43217. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  43218. if !m.op.Is(OpUpdateOne) {
  43219. return v, errors.New("OldName is only allowed on UpdateOne operations")
  43220. }
  43221. if m.id == nil || m.oldValue == nil {
  43222. return v, errors.New("OldName requires an ID field in the mutation")
  43223. }
  43224. oldValue, err := m.oldValue(ctx)
  43225. if err != nil {
  43226. return v, fmt.Errorf("querying old value for OldName: %w", err)
  43227. }
  43228. return oldValue.Name, nil
  43229. }
  43230. // ResetName resets all changes to the "name" field.
  43231. func (m *WxCardMutation) ResetName() {
  43232. m.name = nil
  43233. }
  43234. // SetCompany sets the "company" field.
  43235. func (m *WxCardMutation) SetCompany(s string) {
  43236. m.company = &s
  43237. }
  43238. // Company returns the value of the "company" field in the mutation.
  43239. func (m *WxCardMutation) Company() (r string, exists bool) {
  43240. v := m.company
  43241. if v == nil {
  43242. return
  43243. }
  43244. return *v, true
  43245. }
  43246. // OldCompany returns the old "company" field's value of the WxCard entity.
  43247. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43249. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  43250. if !m.op.Is(OpUpdateOne) {
  43251. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  43252. }
  43253. if m.id == nil || m.oldValue == nil {
  43254. return v, errors.New("OldCompany requires an ID field in the mutation")
  43255. }
  43256. oldValue, err := m.oldValue(ctx)
  43257. if err != nil {
  43258. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  43259. }
  43260. return oldValue.Company, nil
  43261. }
  43262. // ResetCompany resets all changes to the "company" field.
  43263. func (m *WxCardMutation) ResetCompany() {
  43264. m.company = nil
  43265. }
  43266. // SetAddress sets the "address" field.
  43267. func (m *WxCardMutation) SetAddress(s string) {
  43268. m.address = &s
  43269. }
  43270. // Address returns the value of the "address" field in the mutation.
  43271. func (m *WxCardMutation) Address() (r string, exists bool) {
  43272. v := m.address
  43273. if v == nil {
  43274. return
  43275. }
  43276. return *v, true
  43277. }
  43278. // OldAddress returns the old "address" field's value of the WxCard entity.
  43279. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43281. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  43282. if !m.op.Is(OpUpdateOne) {
  43283. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  43284. }
  43285. if m.id == nil || m.oldValue == nil {
  43286. return v, errors.New("OldAddress requires an ID field in the mutation")
  43287. }
  43288. oldValue, err := m.oldValue(ctx)
  43289. if err != nil {
  43290. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  43291. }
  43292. return oldValue.Address, nil
  43293. }
  43294. // ResetAddress resets all changes to the "address" field.
  43295. func (m *WxCardMutation) ResetAddress() {
  43296. m.address = nil
  43297. }
  43298. // SetPhone sets the "phone" field.
  43299. func (m *WxCardMutation) SetPhone(s string) {
  43300. m.phone = &s
  43301. }
  43302. // Phone returns the value of the "phone" field in the mutation.
  43303. func (m *WxCardMutation) Phone() (r string, exists bool) {
  43304. v := m.phone
  43305. if v == nil {
  43306. return
  43307. }
  43308. return *v, true
  43309. }
  43310. // OldPhone returns the old "phone" field's value of the WxCard entity.
  43311. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43313. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  43314. if !m.op.Is(OpUpdateOne) {
  43315. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43316. }
  43317. if m.id == nil || m.oldValue == nil {
  43318. return v, errors.New("OldPhone requires an ID field in the mutation")
  43319. }
  43320. oldValue, err := m.oldValue(ctx)
  43321. if err != nil {
  43322. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43323. }
  43324. return oldValue.Phone, nil
  43325. }
  43326. // ResetPhone resets all changes to the "phone" field.
  43327. func (m *WxCardMutation) ResetPhone() {
  43328. m.phone = nil
  43329. }
  43330. // SetOfficialAccount sets the "official_account" field.
  43331. func (m *WxCardMutation) SetOfficialAccount(s string) {
  43332. m.official_account = &s
  43333. }
  43334. // OfficialAccount returns the value of the "official_account" field in the mutation.
  43335. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  43336. v := m.official_account
  43337. if v == nil {
  43338. return
  43339. }
  43340. return *v, true
  43341. }
  43342. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  43343. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43345. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  43346. if !m.op.Is(OpUpdateOne) {
  43347. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  43348. }
  43349. if m.id == nil || m.oldValue == nil {
  43350. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  43351. }
  43352. oldValue, err := m.oldValue(ctx)
  43353. if err != nil {
  43354. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  43355. }
  43356. return oldValue.OfficialAccount, nil
  43357. }
  43358. // ResetOfficialAccount resets all changes to the "official_account" field.
  43359. func (m *WxCardMutation) ResetOfficialAccount() {
  43360. m.official_account = nil
  43361. }
  43362. // SetWechatAccount sets the "wechat_account" field.
  43363. func (m *WxCardMutation) SetWechatAccount(s string) {
  43364. m.wechat_account = &s
  43365. }
  43366. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  43367. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  43368. v := m.wechat_account
  43369. if v == nil {
  43370. return
  43371. }
  43372. return *v, true
  43373. }
  43374. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  43375. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43377. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  43378. if !m.op.Is(OpUpdateOne) {
  43379. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  43380. }
  43381. if m.id == nil || m.oldValue == nil {
  43382. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  43383. }
  43384. oldValue, err := m.oldValue(ctx)
  43385. if err != nil {
  43386. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  43387. }
  43388. return oldValue.WechatAccount, nil
  43389. }
  43390. // ResetWechatAccount resets all changes to the "wechat_account" field.
  43391. func (m *WxCardMutation) ResetWechatAccount() {
  43392. m.wechat_account = nil
  43393. }
  43394. // SetEmail sets the "email" field.
  43395. func (m *WxCardMutation) SetEmail(s string) {
  43396. m.email = &s
  43397. }
  43398. // Email returns the value of the "email" field in the mutation.
  43399. func (m *WxCardMutation) Email() (r string, exists bool) {
  43400. v := m.email
  43401. if v == nil {
  43402. return
  43403. }
  43404. return *v, true
  43405. }
  43406. // OldEmail returns the old "email" field's value of the WxCard entity.
  43407. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43409. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  43410. if !m.op.Is(OpUpdateOne) {
  43411. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  43412. }
  43413. if m.id == nil || m.oldValue == nil {
  43414. return v, errors.New("OldEmail requires an ID field in the mutation")
  43415. }
  43416. oldValue, err := m.oldValue(ctx)
  43417. if err != nil {
  43418. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  43419. }
  43420. return oldValue.Email, nil
  43421. }
  43422. // ClearEmail clears the value of the "email" field.
  43423. func (m *WxCardMutation) ClearEmail() {
  43424. m.email = nil
  43425. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  43426. }
  43427. // EmailCleared returns if the "email" field was cleared in this mutation.
  43428. func (m *WxCardMutation) EmailCleared() bool {
  43429. _, ok := m.clearedFields[wxcard.FieldEmail]
  43430. return ok
  43431. }
  43432. // ResetEmail resets all changes to the "email" field.
  43433. func (m *WxCardMutation) ResetEmail() {
  43434. m.email = nil
  43435. delete(m.clearedFields, wxcard.FieldEmail)
  43436. }
  43437. // SetAPIBase sets the "api_base" field.
  43438. func (m *WxCardMutation) SetAPIBase(s string) {
  43439. m.api_base = &s
  43440. }
  43441. // APIBase returns the value of the "api_base" field in the mutation.
  43442. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  43443. v := m.api_base
  43444. if v == nil {
  43445. return
  43446. }
  43447. return *v, true
  43448. }
  43449. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  43450. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43452. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  43453. if !m.op.Is(OpUpdateOne) {
  43454. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43455. }
  43456. if m.id == nil || m.oldValue == nil {
  43457. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  43458. }
  43459. oldValue, err := m.oldValue(ctx)
  43460. if err != nil {
  43461. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  43462. }
  43463. return oldValue.APIBase, nil
  43464. }
  43465. // ClearAPIBase clears the value of the "api_base" field.
  43466. func (m *WxCardMutation) ClearAPIBase() {
  43467. m.api_base = nil
  43468. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  43469. }
  43470. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43471. func (m *WxCardMutation) APIBaseCleared() bool {
  43472. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  43473. return ok
  43474. }
  43475. // ResetAPIBase resets all changes to the "api_base" field.
  43476. func (m *WxCardMutation) ResetAPIBase() {
  43477. m.api_base = nil
  43478. delete(m.clearedFields, wxcard.FieldAPIBase)
  43479. }
  43480. // SetAPIKey sets the "api_key" field.
  43481. func (m *WxCardMutation) SetAPIKey(s string) {
  43482. m.api_key = &s
  43483. }
  43484. // APIKey returns the value of the "api_key" field in the mutation.
  43485. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  43486. v := m.api_key
  43487. if v == nil {
  43488. return
  43489. }
  43490. return *v, true
  43491. }
  43492. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  43493. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43495. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43496. if !m.op.Is(OpUpdateOne) {
  43497. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43498. }
  43499. if m.id == nil || m.oldValue == nil {
  43500. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43501. }
  43502. oldValue, err := m.oldValue(ctx)
  43503. if err != nil {
  43504. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43505. }
  43506. return oldValue.APIKey, nil
  43507. }
  43508. // ClearAPIKey clears the value of the "api_key" field.
  43509. func (m *WxCardMutation) ClearAPIKey() {
  43510. m.api_key = nil
  43511. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  43512. }
  43513. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43514. func (m *WxCardMutation) APIKeyCleared() bool {
  43515. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  43516. return ok
  43517. }
  43518. // ResetAPIKey resets all changes to the "api_key" field.
  43519. func (m *WxCardMutation) ResetAPIKey() {
  43520. m.api_key = nil
  43521. delete(m.clearedFields, wxcard.FieldAPIKey)
  43522. }
  43523. // SetAiInfo sets the "ai_info" field.
  43524. func (m *WxCardMutation) SetAiInfo(s string) {
  43525. m.ai_info = &s
  43526. }
  43527. // AiInfo returns the value of the "ai_info" field in the mutation.
  43528. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  43529. v := m.ai_info
  43530. if v == nil {
  43531. return
  43532. }
  43533. return *v, true
  43534. }
  43535. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  43536. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43538. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  43539. if !m.op.Is(OpUpdateOne) {
  43540. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  43541. }
  43542. if m.id == nil || m.oldValue == nil {
  43543. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  43544. }
  43545. oldValue, err := m.oldValue(ctx)
  43546. if err != nil {
  43547. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  43548. }
  43549. return oldValue.AiInfo, nil
  43550. }
  43551. // ClearAiInfo clears the value of the "ai_info" field.
  43552. func (m *WxCardMutation) ClearAiInfo() {
  43553. m.ai_info = nil
  43554. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  43555. }
  43556. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  43557. func (m *WxCardMutation) AiInfoCleared() bool {
  43558. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  43559. return ok
  43560. }
  43561. // ResetAiInfo resets all changes to the "ai_info" field.
  43562. func (m *WxCardMutation) ResetAiInfo() {
  43563. m.ai_info = nil
  43564. delete(m.clearedFields, wxcard.FieldAiInfo)
  43565. }
  43566. // SetIntro sets the "intro" field.
  43567. func (m *WxCardMutation) SetIntro(s string) {
  43568. m.intro = &s
  43569. }
  43570. // Intro returns the value of the "intro" field in the mutation.
  43571. func (m *WxCardMutation) Intro() (r string, exists bool) {
  43572. v := m.intro
  43573. if v == nil {
  43574. return
  43575. }
  43576. return *v, true
  43577. }
  43578. // OldIntro returns the old "intro" field's value of the WxCard entity.
  43579. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43581. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  43582. if !m.op.Is(OpUpdateOne) {
  43583. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  43584. }
  43585. if m.id == nil || m.oldValue == nil {
  43586. return v, errors.New("OldIntro requires an ID field in the mutation")
  43587. }
  43588. oldValue, err := m.oldValue(ctx)
  43589. if err != nil {
  43590. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  43591. }
  43592. return oldValue.Intro, nil
  43593. }
  43594. // ClearIntro clears the value of the "intro" field.
  43595. func (m *WxCardMutation) ClearIntro() {
  43596. m.intro = nil
  43597. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  43598. }
  43599. // IntroCleared returns if the "intro" field was cleared in this mutation.
  43600. func (m *WxCardMutation) IntroCleared() bool {
  43601. _, ok := m.clearedFields[wxcard.FieldIntro]
  43602. return ok
  43603. }
  43604. // ResetIntro resets all changes to the "intro" field.
  43605. func (m *WxCardMutation) ResetIntro() {
  43606. m.intro = nil
  43607. delete(m.clearedFields, wxcard.FieldIntro)
  43608. }
  43609. // Where appends a list predicates to the WxCardMutation builder.
  43610. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  43611. m.predicates = append(m.predicates, ps...)
  43612. }
  43613. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  43614. // users can use type-assertion to append predicates that do not depend on any generated package.
  43615. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  43616. p := make([]predicate.WxCard, len(ps))
  43617. for i := range ps {
  43618. p[i] = ps[i]
  43619. }
  43620. m.Where(p...)
  43621. }
  43622. // Op returns the operation name.
  43623. func (m *WxCardMutation) Op() Op {
  43624. return m.op
  43625. }
  43626. // SetOp allows setting the mutation operation.
  43627. func (m *WxCardMutation) SetOp(op Op) {
  43628. m.op = op
  43629. }
  43630. // Type returns the node type of this mutation (WxCard).
  43631. func (m *WxCardMutation) Type() string {
  43632. return m.typ
  43633. }
  43634. // Fields returns all fields that were changed during this mutation. Note that in
  43635. // order to get all numeric fields that were incremented/decremented, call
  43636. // AddedFields().
  43637. func (m *WxCardMutation) Fields() []string {
  43638. fields := make([]string, 0, 18)
  43639. if m.created_at != nil {
  43640. fields = append(fields, wxcard.FieldCreatedAt)
  43641. }
  43642. if m.updated_at != nil {
  43643. fields = append(fields, wxcard.FieldUpdatedAt)
  43644. }
  43645. if m.deleted_at != nil {
  43646. fields = append(fields, wxcard.FieldDeletedAt)
  43647. }
  43648. if m.user_id != nil {
  43649. fields = append(fields, wxcard.FieldUserID)
  43650. }
  43651. if m.wx_user_id != nil {
  43652. fields = append(fields, wxcard.FieldWxUserID)
  43653. }
  43654. if m.avatar != nil {
  43655. fields = append(fields, wxcard.FieldAvatar)
  43656. }
  43657. if m.logo != nil {
  43658. fields = append(fields, wxcard.FieldLogo)
  43659. }
  43660. if m.name != nil {
  43661. fields = append(fields, wxcard.FieldName)
  43662. }
  43663. if m.company != nil {
  43664. fields = append(fields, wxcard.FieldCompany)
  43665. }
  43666. if m.address != nil {
  43667. fields = append(fields, wxcard.FieldAddress)
  43668. }
  43669. if m.phone != nil {
  43670. fields = append(fields, wxcard.FieldPhone)
  43671. }
  43672. if m.official_account != nil {
  43673. fields = append(fields, wxcard.FieldOfficialAccount)
  43674. }
  43675. if m.wechat_account != nil {
  43676. fields = append(fields, wxcard.FieldWechatAccount)
  43677. }
  43678. if m.email != nil {
  43679. fields = append(fields, wxcard.FieldEmail)
  43680. }
  43681. if m.api_base != nil {
  43682. fields = append(fields, wxcard.FieldAPIBase)
  43683. }
  43684. if m.api_key != nil {
  43685. fields = append(fields, wxcard.FieldAPIKey)
  43686. }
  43687. if m.ai_info != nil {
  43688. fields = append(fields, wxcard.FieldAiInfo)
  43689. }
  43690. if m.intro != nil {
  43691. fields = append(fields, wxcard.FieldIntro)
  43692. }
  43693. return fields
  43694. }
  43695. // Field returns the value of a field with the given name. The second boolean
  43696. // return value indicates that this field was not set, or was not defined in the
  43697. // schema.
  43698. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  43699. switch name {
  43700. case wxcard.FieldCreatedAt:
  43701. return m.CreatedAt()
  43702. case wxcard.FieldUpdatedAt:
  43703. return m.UpdatedAt()
  43704. case wxcard.FieldDeletedAt:
  43705. return m.DeletedAt()
  43706. case wxcard.FieldUserID:
  43707. return m.UserID()
  43708. case wxcard.FieldWxUserID:
  43709. return m.WxUserID()
  43710. case wxcard.FieldAvatar:
  43711. return m.Avatar()
  43712. case wxcard.FieldLogo:
  43713. return m.Logo()
  43714. case wxcard.FieldName:
  43715. return m.Name()
  43716. case wxcard.FieldCompany:
  43717. return m.Company()
  43718. case wxcard.FieldAddress:
  43719. return m.Address()
  43720. case wxcard.FieldPhone:
  43721. return m.Phone()
  43722. case wxcard.FieldOfficialAccount:
  43723. return m.OfficialAccount()
  43724. case wxcard.FieldWechatAccount:
  43725. return m.WechatAccount()
  43726. case wxcard.FieldEmail:
  43727. return m.Email()
  43728. case wxcard.FieldAPIBase:
  43729. return m.APIBase()
  43730. case wxcard.FieldAPIKey:
  43731. return m.APIKey()
  43732. case wxcard.FieldAiInfo:
  43733. return m.AiInfo()
  43734. case wxcard.FieldIntro:
  43735. return m.Intro()
  43736. }
  43737. return nil, false
  43738. }
  43739. // OldField returns the old value of the field from the database. An error is
  43740. // returned if the mutation operation is not UpdateOne, or the query to the
  43741. // database failed.
  43742. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43743. switch name {
  43744. case wxcard.FieldCreatedAt:
  43745. return m.OldCreatedAt(ctx)
  43746. case wxcard.FieldUpdatedAt:
  43747. return m.OldUpdatedAt(ctx)
  43748. case wxcard.FieldDeletedAt:
  43749. return m.OldDeletedAt(ctx)
  43750. case wxcard.FieldUserID:
  43751. return m.OldUserID(ctx)
  43752. case wxcard.FieldWxUserID:
  43753. return m.OldWxUserID(ctx)
  43754. case wxcard.FieldAvatar:
  43755. return m.OldAvatar(ctx)
  43756. case wxcard.FieldLogo:
  43757. return m.OldLogo(ctx)
  43758. case wxcard.FieldName:
  43759. return m.OldName(ctx)
  43760. case wxcard.FieldCompany:
  43761. return m.OldCompany(ctx)
  43762. case wxcard.FieldAddress:
  43763. return m.OldAddress(ctx)
  43764. case wxcard.FieldPhone:
  43765. return m.OldPhone(ctx)
  43766. case wxcard.FieldOfficialAccount:
  43767. return m.OldOfficialAccount(ctx)
  43768. case wxcard.FieldWechatAccount:
  43769. return m.OldWechatAccount(ctx)
  43770. case wxcard.FieldEmail:
  43771. return m.OldEmail(ctx)
  43772. case wxcard.FieldAPIBase:
  43773. return m.OldAPIBase(ctx)
  43774. case wxcard.FieldAPIKey:
  43775. return m.OldAPIKey(ctx)
  43776. case wxcard.FieldAiInfo:
  43777. return m.OldAiInfo(ctx)
  43778. case wxcard.FieldIntro:
  43779. return m.OldIntro(ctx)
  43780. }
  43781. return nil, fmt.Errorf("unknown WxCard field %s", name)
  43782. }
  43783. // SetField sets the value of a field with the given name. It returns an error if
  43784. // the field is not defined in the schema, or if the type mismatched the field
  43785. // type.
  43786. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  43787. switch name {
  43788. case wxcard.FieldCreatedAt:
  43789. v, ok := value.(time.Time)
  43790. if !ok {
  43791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43792. }
  43793. m.SetCreatedAt(v)
  43794. return nil
  43795. case wxcard.FieldUpdatedAt:
  43796. v, ok := value.(time.Time)
  43797. if !ok {
  43798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43799. }
  43800. m.SetUpdatedAt(v)
  43801. return nil
  43802. case wxcard.FieldDeletedAt:
  43803. v, ok := value.(time.Time)
  43804. if !ok {
  43805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43806. }
  43807. m.SetDeletedAt(v)
  43808. return nil
  43809. case wxcard.FieldUserID:
  43810. v, ok := value.(uint64)
  43811. if !ok {
  43812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43813. }
  43814. m.SetUserID(v)
  43815. return nil
  43816. case wxcard.FieldWxUserID:
  43817. v, ok := value.(uint64)
  43818. if !ok {
  43819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43820. }
  43821. m.SetWxUserID(v)
  43822. return nil
  43823. case wxcard.FieldAvatar:
  43824. v, ok := value.(string)
  43825. if !ok {
  43826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43827. }
  43828. m.SetAvatar(v)
  43829. return nil
  43830. case wxcard.FieldLogo:
  43831. v, ok := value.(string)
  43832. if !ok {
  43833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43834. }
  43835. m.SetLogo(v)
  43836. return nil
  43837. case wxcard.FieldName:
  43838. v, ok := value.(string)
  43839. if !ok {
  43840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43841. }
  43842. m.SetName(v)
  43843. return nil
  43844. case wxcard.FieldCompany:
  43845. v, ok := value.(string)
  43846. if !ok {
  43847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43848. }
  43849. m.SetCompany(v)
  43850. return nil
  43851. case wxcard.FieldAddress:
  43852. v, ok := value.(string)
  43853. if !ok {
  43854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43855. }
  43856. m.SetAddress(v)
  43857. return nil
  43858. case wxcard.FieldPhone:
  43859. v, ok := value.(string)
  43860. if !ok {
  43861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43862. }
  43863. m.SetPhone(v)
  43864. return nil
  43865. case wxcard.FieldOfficialAccount:
  43866. v, ok := value.(string)
  43867. if !ok {
  43868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43869. }
  43870. m.SetOfficialAccount(v)
  43871. return nil
  43872. case wxcard.FieldWechatAccount:
  43873. v, ok := value.(string)
  43874. if !ok {
  43875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43876. }
  43877. m.SetWechatAccount(v)
  43878. return nil
  43879. case wxcard.FieldEmail:
  43880. v, ok := value.(string)
  43881. if !ok {
  43882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43883. }
  43884. m.SetEmail(v)
  43885. return nil
  43886. case wxcard.FieldAPIBase:
  43887. v, ok := value.(string)
  43888. if !ok {
  43889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43890. }
  43891. m.SetAPIBase(v)
  43892. return nil
  43893. case wxcard.FieldAPIKey:
  43894. v, ok := value.(string)
  43895. if !ok {
  43896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43897. }
  43898. m.SetAPIKey(v)
  43899. return nil
  43900. case wxcard.FieldAiInfo:
  43901. v, ok := value.(string)
  43902. if !ok {
  43903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43904. }
  43905. m.SetAiInfo(v)
  43906. return nil
  43907. case wxcard.FieldIntro:
  43908. v, ok := value.(string)
  43909. if !ok {
  43910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43911. }
  43912. m.SetIntro(v)
  43913. return nil
  43914. }
  43915. return fmt.Errorf("unknown WxCard field %s", name)
  43916. }
  43917. // AddedFields returns all numeric fields that were incremented/decremented during
  43918. // this mutation.
  43919. func (m *WxCardMutation) AddedFields() []string {
  43920. var fields []string
  43921. if m.adduser_id != nil {
  43922. fields = append(fields, wxcard.FieldUserID)
  43923. }
  43924. if m.addwx_user_id != nil {
  43925. fields = append(fields, wxcard.FieldWxUserID)
  43926. }
  43927. return fields
  43928. }
  43929. // AddedField returns the numeric value that was incremented/decremented on a field
  43930. // with the given name. The second boolean return value indicates that this field
  43931. // was not set, or was not defined in the schema.
  43932. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  43933. switch name {
  43934. case wxcard.FieldUserID:
  43935. return m.AddedUserID()
  43936. case wxcard.FieldWxUserID:
  43937. return m.AddedWxUserID()
  43938. }
  43939. return nil, false
  43940. }
  43941. // AddField adds the value to the field with the given name. It returns an error if
  43942. // the field is not defined in the schema, or if the type mismatched the field
  43943. // type.
  43944. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  43945. switch name {
  43946. case wxcard.FieldUserID:
  43947. v, ok := value.(int64)
  43948. if !ok {
  43949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43950. }
  43951. m.AddUserID(v)
  43952. return nil
  43953. case wxcard.FieldWxUserID:
  43954. v, ok := value.(int64)
  43955. if !ok {
  43956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43957. }
  43958. m.AddWxUserID(v)
  43959. return nil
  43960. }
  43961. return fmt.Errorf("unknown WxCard numeric field %s", name)
  43962. }
  43963. // ClearedFields returns all nullable fields that were cleared during this
  43964. // mutation.
  43965. func (m *WxCardMutation) ClearedFields() []string {
  43966. var fields []string
  43967. if m.FieldCleared(wxcard.FieldDeletedAt) {
  43968. fields = append(fields, wxcard.FieldDeletedAt)
  43969. }
  43970. if m.FieldCleared(wxcard.FieldUserID) {
  43971. fields = append(fields, wxcard.FieldUserID)
  43972. }
  43973. if m.FieldCleared(wxcard.FieldWxUserID) {
  43974. fields = append(fields, wxcard.FieldWxUserID)
  43975. }
  43976. if m.FieldCleared(wxcard.FieldEmail) {
  43977. fields = append(fields, wxcard.FieldEmail)
  43978. }
  43979. if m.FieldCleared(wxcard.FieldAPIBase) {
  43980. fields = append(fields, wxcard.FieldAPIBase)
  43981. }
  43982. if m.FieldCleared(wxcard.FieldAPIKey) {
  43983. fields = append(fields, wxcard.FieldAPIKey)
  43984. }
  43985. if m.FieldCleared(wxcard.FieldAiInfo) {
  43986. fields = append(fields, wxcard.FieldAiInfo)
  43987. }
  43988. if m.FieldCleared(wxcard.FieldIntro) {
  43989. fields = append(fields, wxcard.FieldIntro)
  43990. }
  43991. return fields
  43992. }
  43993. // FieldCleared returns a boolean indicating if a field with the given name was
  43994. // cleared in this mutation.
  43995. func (m *WxCardMutation) FieldCleared(name string) bool {
  43996. _, ok := m.clearedFields[name]
  43997. return ok
  43998. }
  43999. // ClearField clears the value of the field with the given name. It returns an
  44000. // error if the field is not defined in the schema.
  44001. func (m *WxCardMutation) ClearField(name string) error {
  44002. switch name {
  44003. case wxcard.FieldDeletedAt:
  44004. m.ClearDeletedAt()
  44005. return nil
  44006. case wxcard.FieldUserID:
  44007. m.ClearUserID()
  44008. return nil
  44009. case wxcard.FieldWxUserID:
  44010. m.ClearWxUserID()
  44011. return nil
  44012. case wxcard.FieldEmail:
  44013. m.ClearEmail()
  44014. return nil
  44015. case wxcard.FieldAPIBase:
  44016. m.ClearAPIBase()
  44017. return nil
  44018. case wxcard.FieldAPIKey:
  44019. m.ClearAPIKey()
  44020. return nil
  44021. case wxcard.FieldAiInfo:
  44022. m.ClearAiInfo()
  44023. return nil
  44024. case wxcard.FieldIntro:
  44025. m.ClearIntro()
  44026. return nil
  44027. }
  44028. return fmt.Errorf("unknown WxCard nullable field %s", name)
  44029. }
  44030. // ResetField resets all changes in the mutation for the field with the given name.
  44031. // It returns an error if the field is not defined in the schema.
  44032. func (m *WxCardMutation) ResetField(name string) error {
  44033. switch name {
  44034. case wxcard.FieldCreatedAt:
  44035. m.ResetCreatedAt()
  44036. return nil
  44037. case wxcard.FieldUpdatedAt:
  44038. m.ResetUpdatedAt()
  44039. return nil
  44040. case wxcard.FieldDeletedAt:
  44041. m.ResetDeletedAt()
  44042. return nil
  44043. case wxcard.FieldUserID:
  44044. m.ResetUserID()
  44045. return nil
  44046. case wxcard.FieldWxUserID:
  44047. m.ResetWxUserID()
  44048. return nil
  44049. case wxcard.FieldAvatar:
  44050. m.ResetAvatar()
  44051. return nil
  44052. case wxcard.FieldLogo:
  44053. m.ResetLogo()
  44054. return nil
  44055. case wxcard.FieldName:
  44056. m.ResetName()
  44057. return nil
  44058. case wxcard.FieldCompany:
  44059. m.ResetCompany()
  44060. return nil
  44061. case wxcard.FieldAddress:
  44062. m.ResetAddress()
  44063. return nil
  44064. case wxcard.FieldPhone:
  44065. m.ResetPhone()
  44066. return nil
  44067. case wxcard.FieldOfficialAccount:
  44068. m.ResetOfficialAccount()
  44069. return nil
  44070. case wxcard.FieldWechatAccount:
  44071. m.ResetWechatAccount()
  44072. return nil
  44073. case wxcard.FieldEmail:
  44074. m.ResetEmail()
  44075. return nil
  44076. case wxcard.FieldAPIBase:
  44077. m.ResetAPIBase()
  44078. return nil
  44079. case wxcard.FieldAPIKey:
  44080. m.ResetAPIKey()
  44081. return nil
  44082. case wxcard.FieldAiInfo:
  44083. m.ResetAiInfo()
  44084. return nil
  44085. case wxcard.FieldIntro:
  44086. m.ResetIntro()
  44087. return nil
  44088. }
  44089. return fmt.Errorf("unknown WxCard field %s", name)
  44090. }
  44091. // AddedEdges returns all edge names that were set/added in this mutation.
  44092. func (m *WxCardMutation) AddedEdges() []string {
  44093. edges := make([]string, 0, 0)
  44094. return edges
  44095. }
  44096. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44097. // name in this mutation.
  44098. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  44099. return nil
  44100. }
  44101. // RemovedEdges returns all edge names that were removed in this mutation.
  44102. func (m *WxCardMutation) RemovedEdges() []string {
  44103. edges := make([]string, 0, 0)
  44104. return edges
  44105. }
  44106. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44107. // the given name in this mutation.
  44108. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  44109. return nil
  44110. }
  44111. // ClearedEdges returns all edge names that were cleared in this mutation.
  44112. func (m *WxCardMutation) ClearedEdges() []string {
  44113. edges := make([]string, 0, 0)
  44114. return edges
  44115. }
  44116. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44117. // was cleared in this mutation.
  44118. func (m *WxCardMutation) EdgeCleared(name string) bool {
  44119. return false
  44120. }
  44121. // ClearEdge clears the value of the edge with the given name. It returns an error
  44122. // if that edge is not defined in the schema.
  44123. func (m *WxCardMutation) ClearEdge(name string) error {
  44124. return fmt.Errorf("unknown WxCard unique edge %s", name)
  44125. }
  44126. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44127. // It returns an error if the edge is not defined in the schema.
  44128. func (m *WxCardMutation) ResetEdge(name string) error {
  44129. return fmt.Errorf("unknown WxCard edge %s", name)
  44130. }
  44131. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  44132. type WxCardUserMutation struct {
  44133. config
  44134. op Op
  44135. typ string
  44136. id *uint64
  44137. created_at *time.Time
  44138. updated_at *time.Time
  44139. deleted_at *time.Time
  44140. wxid *string
  44141. account *string
  44142. avatar *string
  44143. nickname *string
  44144. remark *string
  44145. phone *string
  44146. open_id *string
  44147. union_id *string
  44148. session_key *string
  44149. is_vip *int
  44150. addis_vip *int
  44151. clearedFields map[string]struct{}
  44152. done bool
  44153. oldValue func(context.Context) (*WxCardUser, error)
  44154. predicates []predicate.WxCardUser
  44155. }
  44156. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  44157. // wxcarduserOption allows management of the mutation configuration using functional options.
  44158. type wxcarduserOption func(*WxCardUserMutation)
  44159. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  44160. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  44161. m := &WxCardUserMutation{
  44162. config: c,
  44163. op: op,
  44164. typ: TypeWxCardUser,
  44165. clearedFields: make(map[string]struct{}),
  44166. }
  44167. for _, opt := range opts {
  44168. opt(m)
  44169. }
  44170. return m
  44171. }
  44172. // withWxCardUserID sets the ID field of the mutation.
  44173. func withWxCardUserID(id uint64) wxcarduserOption {
  44174. return func(m *WxCardUserMutation) {
  44175. var (
  44176. err error
  44177. once sync.Once
  44178. value *WxCardUser
  44179. )
  44180. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  44181. once.Do(func() {
  44182. if m.done {
  44183. err = errors.New("querying old values post mutation is not allowed")
  44184. } else {
  44185. value, err = m.Client().WxCardUser.Get(ctx, id)
  44186. }
  44187. })
  44188. return value, err
  44189. }
  44190. m.id = &id
  44191. }
  44192. }
  44193. // withWxCardUser sets the old WxCardUser of the mutation.
  44194. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  44195. return func(m *WxCardUserMutation) {
  44196. m.oldValue = func(context.Context) (*WxCardUser, error) {
  44197. return node, nil
  44198. }
  44199. m.id = &node.ID
  44200. }
  44201. }
  44202. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44203. // executed in a transaction (ent.Tx), a transactional client is returned.
  44204. func (m WxCardUserMutation) Client() *Client {
  44205. client := &Client{config: m.config}
  44206. client.init()
  44207. return client
  44208. }
  44209. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44210. // it returns an error otherwise.
  44211. func (m WxCardUserMutation) Tx() (*Tx, error) {
  44212. if _, ok := m.driver.(*txDriver); !ok {
  44213. return nil, errors.New("ent: mutation is not running in a transaction")
  44214. }
  44215. tx := &Tx{config: m.config}
  44216. tx.init()
  44217. return tx, nil
  44218. }
  44219. // SetID sets the value of the id field. Note that this
  44220. // operation is only accepted on creation of WxCardUser entities.
  44221. func (m *WxCardUserMutation) SetID(id uint64) {
  44222. m.id = &id
  44223. }
  44224. // ID returns the ID value in the mutation. Note that the ID is only available
  44225. // if it was provided to the builder or after it was returned from the database.
  44226. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  44227. if m.id == nil {
  44228. return
  44229. }
  44230. return *m.id, true
  44231. }
  44232. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44233. // That means, if the mutation is applied within a transaction with an isolation level such
  44234. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44235. // or updated by the mutation.
  44236. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  44237. switch {
  44238. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44239. id, exists := m.ID()
  44240. if exists {
  44241. return []uint64{id}, nil
  44242. }
  44243. fallthrough
  44244. case m.op.Is(OpUpdate | OpDelete):
  44245. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  44246. default:
  44247. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44248. }
  44249. }
  44250. // SetCreatedAt sets the "created_at" field.
  44251. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  44252. m.created_at = &t
  44253. }
  44254. // CreatedAt returns the value of the "created_at" field in the mutation.
  44255. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  44256. v := m.created_at
  44257. if v == nil {
  44258. return
  44259. }
  44260. return *v, true
  44261. }
  44262. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  44263. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44265. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44266. if !m.op.Is(OpUpdateOne) {
  44267. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44268. }
  44269. if m.id == nil || m.oldValue == nil {
  44270. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44271. }
  44272. oldValue, err := m.oldValue(ctx)
  44273. if err != nil {
  44274. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44275. }
  44276. return oldValue.CreatedAt, nil
  44277. }
  44278. // ResetCreatedAt resets all changes to the "created_at" field.
  44279. func (m *WxCardUserMutation) ResetCreatedAt() {
  44280. m.created_at = nil
  44281. }
  44282. // SetUpdatedAt sets the "updated_at" field.
  44283. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  44284. m.updated_at = &t
  44285. }
  44286. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44287. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  44288. v := m.updated_at
  44289. if v == nil {
  44290. return
  44291. }
  44292. return *v, true
  44293. }
  44294. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  44295. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44297. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44298. if !m.op.Is(OpUpdateOne) {
  44299. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44300. }
  44301. if m.id == nil || m.oldValue == nil {
  44302. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44303. }
  44304. oldValue, err := m.oldValue(ctx)
  44305. if err != nil {
  44306. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44307. }
  44308. return oldValue.UpdatedAt, nil
  44309. }
  44310. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44311. func (m *WxCardUserMutation) ResetUpdatedAt() {
  44312. m.updated_at = nil
  44313. }
  44314. // SetDeletedAt sets the "deleted_at" field.
  44315. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  44316. m.deleted_at = &t
  44317. }
  44318. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44319. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  44320. v := m.deleted_at
  44321. if v == nil {
  44322. return
  44323. }
  44324. return *v, true
  44325. }
  44326. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  44327. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44329. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44330. if !m.op.Is(OpUpdateOne) {
  44331. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44332. }
  44333. if m.id == nil || m.oldValue == nil {
  44334. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44335. }
  44336. oldValue, err := m.oldValue(ctx)
  44337. if err != nil {
  44338. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44339. }
  44340. return oldValue.DeletedAt, nil
  44341. }
  44342. // ClearDeletedAt clears the value of the "deleted_at" field.
  44343. func (m *WxCardUserMutation) ClearDeletedAt() {
  44344. m.deleted_at = nil
  44345. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  44346. }
  44347. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44348. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  44349. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  44350. return ok
  44351. }
  44352. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44353. func (m *WxCardUserMutation) ResetDeletedAt() {
  44354. m.deleted_at = nil
  44355. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  44356. }
  44357. // SetWxid sets the "wxid" field.
  44358. func (m *WxCardUserMutation) SetWxid(s string) {
  44359. m.wxid = &s
  44360. }
  44361. // Wxid returns the value of the "wxid" field in the mutation.
  44362. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  44363. v := m.wxid
  44364. if v == nil {
  44365. return
  44366. }
  44367. return *v, true
  44368. }
  44369. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  44370. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44372. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  44373. if !m.op.Is(OpUpdateOne) {
  44374. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  44375. }
  44376. if m.id == nil || m.oldValue == nil {
  44377. return v, errors.New("OldWxid requires an ID field in the mutation")
  44378. }
  44379. oldValue, err := m.oldValue(ctx)
  44380. if err != nil {
  44381. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  44382. }
  44383. return oldValue.Wxid, nil
  44384. }
  44385. // ResetWxid resets all changes to the "wxid" field.
  44386. func (m *WxCardUserMutation) ResetWxid() {
  44387. m.wxid = nil
  44388. }
  44389. // SetAccount sets the "account" field.
  44390. func (m *WxCardUserMutation) SetAccount(s string) {
  44391. m.account = &s
  44392. }
  44393. // Account returns the value of the "account" field in the mutation.
  44394. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  44395. v := m.account
  44396. if v == nil {
  44397. return
  44398. }
  44399. return *v, true
  44400. }
  44401. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  44402. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44404. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  44405. if !m.op.Is(OpUpdateOne) {
  44406. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  44407. }
  44408. if m.id == nil || m.oldValue == nil {
  44409. return v, errors.New("OldAccount requires an ID field in the mutation")
  44410. }
  44411. oldValue, err := m.oldValue(ctx)
  44412. if err != nil {
  44413. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  44414. }
  44415. return oldValue.Account, nil
  44416. }
  44417. // ResetAccount resets all changes to the "account" field.
  44418. func (m *WxCardUserMutation) ResetAccount() {
  44419. m.account = nil
  44420. }
  44421. // SetAvatar sets the "avatar" field.
  44422. func (m *WxCardUserMutation) SetAvatar(s string) {
  44423. m.avatar = &s
  44424. }
  44425. // Avatar returns the value of the "avatar" field in the mutation.
  44426. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  44427. v := m.avatar
  44428. if v == nil {
  44429. return
  44430. }
  44431. return *v, true
  44432. }
  44433. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  44434. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44436. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44437. if !m.op.Is(OpUpdateOne) {
  44438. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44439. }
  44440. if m.id == nil || m.oldValue == nil {
  44441. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44442. }
  44443. oldValue, err := m.oldValue(ctx)
  44444. if err != nil {
  44445. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44446. }
  44447. return oldValue.Avatar, nil
  44448. }
  44449. // ResetAvatar resets all changes to the "avatar" field.
  44450. func (m *WxCardUserMutation) ResetAvatar() {
  44451. m.avatar = nil
  44452. }
  44453. // SetNickname sets the "nickname" field.
  44454. func (m *WxCardUserMutation) SetNickname(s string) {
  44455. m.nickname = &s
  44456. }
  44457. // Nickname returns the value of the "nickname" field in the mutation.
  44458. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  44459. v := m.nickname
  44460. if v == nil {
  44461. return
  44462. }
  44463. return *v, true
  44464. }
  44465. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  44466. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44468. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  44469. if !m.op.Is(OpUpdateOne) {
  44470. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44471. }
  44472. if m.id == nil || m.oldValue == nil {
  44473. return v, errors.New("OldNickname requires an ID field in the mutation")
  44474. }
  44475. oldValue, err := m.oldValue(ctx)
  44476. if err != nil {
  44477. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44478. }
  44479. return oldValue.Nickname, nil
  44480. }
  44481. // ResetNickname resets all changes to the "nickname" field.
  44482. func (m *WxCardUserMutation) ResetNickname() {
  44483. m.nickname = nil
  44484. }
  44485. // SetRemark sets the "remark" field.
  44486. func (m *WxCardUserMutation) SetRemark(s string) {
  44487. m.remark = &s
  44488. }
  44489. // Remark returns the value of the "remark" field in the mutation.
  44490. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  44491. v := m.remark
  44492. if v == nil {
  44493. return
  44494. }
  44495. return *v, true
  44496. }
  44497. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  44498. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44500. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  44501. if !m.op.Is(OpUpdateOne) {
  44502. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  44503. }
  44504. if m.id == nil || m.oldValue == nil {
  44505. return v, errors.New("OldRemark requires an ID field in the mutation")
  44506. }
  44507. oldValue, err := m.oldValue(ctx)
  44508. if err != nil {
  44509. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  44510. }
  44511. return oldValue.Remark, nil
  44512. }
  44513. // ResetRemark resets all changes to the "remark" field.
  44514. func (m *WxCardUserMutation) ResetRemark() {
  44515. m.remark = nil
  44516. }
  44517. // SetPhone sets the "phone" field.
  44518. func (m *WxCardUserMutation) SetPhone(s string) {
  44519. m.phone = &s
  44520. }
  44521. // Phone returns the value of the "phone" field in the mutation.
  44522. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  44523. v := m.phone
  44524. if v == nil {
  44525. return
  44526. }
  44527. return *v, true
  44528. }
  44529. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  44530. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44532. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  44533. if !m.op.Is(OpUpdateOne) {
  44534. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  44535. }
  44536. if m.id == nil || m.oldValue == nil {
  44537. return v, errors.New("OldPhone requires an ID field in the mutation")
  44538. }
  44539. oldValue, err := m.oldValue(ctx)
  44540. if err != nil {
  44541. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  44542. }
  44543. return oldValue.Phone, nil
  44544. }
  44545. // ResetPhone resets all changes to the "phone" field.
  44546. func (m *WxCardUserMutation) ResetPhone() {
  44547. m.phone = nil
  44548. }
  44549. // SetOpenID sets the "open_id" field.
  44550. func (m *WxCardUserMutation) SetOpenID(s string) {
  44551. m.open_id = &s
  44552. }
  44553. // OpenID returns the value of the "open_id" field in the mutation.
  44554. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  44555. v := m.open_id
  44556. if v == nil {
  44557. return
  44558. }
  44559. return *v, true
  44560. }
  44561. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  44562. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44564. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  44565. if !m.op.Is(OpUpdateOne) {
  44566. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  44567. }
  44568. if m.id == nil || m.oldValue == nil {
  44569. return v, errors.New("OldOpenID requires an ID field in the mutation")
  44570. }
  44571. oldValue, err := m.oldValue(ctx)
  44572. if err != nil {
  44573. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  44574. }
  44575. return oldValue.OpenID, nil
  44576. }
  44577. // ResetOpenID resets all changes to the "open_id" field.
  44578. func (m *WxCardUserMutation) ResetOpenID() {
  44579. m.open_id = nil
  44580. }
  44581. // SetUnionID sets the "union_id" field.
  44582. func (m *WxCardUserMutation) SetUnionID(s string) {
  44583. m.union_id = &s
  44584. }
  44585. // UnionID returns the value of the "union_id" field in the mutation.
  44586. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  44587. v := m.union_id
  44588. if v == nil {
  44589. return
  44590. }
  44591. return *v, true
  44592. }
  44593. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  44594. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44596. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  44597. if !m.op.Is(OpUpdateOne) {
  44598. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  44599. }
  44600. if m.id == nil || m.oldValue == nil {
  44601. return v, errors.New("OldUnionID requires an ID field in the mutation")
  44602. }
  44603. oldValue, err := m.oldValue(ctx)
  44604. if err != nil {
  44605. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  44606. }
  44607. return oldValue.UnionID, nil
  44608. }
  44609. // ResetUnionID resets all changes to the "union_id" field.
  44610. func (m *WxCardUserMutation) ResetUnionID() {
  44611. m.union_id = nil
  44612. }
  44613. // SetSessionKey sets the "session_key" field.
  44614. func (m *WxCardUserMutation) SetSessionKey(s string) {
  44615. m.session_key = &s
  44616. }
  44617. // SessionKey returns the value of the "session_key" field in the mutation.
  44618. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  44619. v := m.session_key
  44620. if v == nil {
  44621. return
  44622. }
  44623. return *v, true
  44624. }
  44625. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  44626. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44628. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  44629. if !m.op.Is(OpUpdateOne) {
  44630. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  44631. }
  44632. if m.id == nil || m.oldValue == nil {
  44633. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  44634. }
  44635. oldValue, err := m.oldValue(ctx)
  44636. if err != nil {
  44637. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  44638. }
  44639. return oldValue.SessionKey, nil
  44640. }
  44641. // ResetSessionKey resets all changes to the "session_key" field.
  44642. func (m *WxCardUserMutation) ResetSessionKey() {
  44643. m.session_key = nil
  44644. }
  44645. // SetIsVip sets the "is_vip" field.
  44646. func (m *WxCardUserMutation) SetIsVip(i int) {
  44647. m.is_vip = &i
  44648. m.addis_vip = nil
  44649. }
  44650. // IsVip returns the value of the "is_vip" field in the mutation.
  44651. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  44652. v := m.is_vip
  44653. if v == nil {
  44654. return
  44655. }
  44656. return *v, true
  44657. }
  44658. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  44659. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44661. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  44662. if !m.op.Is(OpUpdateOne) {
  44663. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  44664. }
  44665. if m.id == nil || m.oldValue == nil {
  44666. return v, errors.New("OldIsVip requires an ID field in the mutation")
  44667. }
  44668. oldValue, err := m.oldValue(ctx)
  44669. if err != nil {
  44670. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  44671. }
  44672. return oldValue.IsVip, nil
  44673. }
  44674. // AddIsVip adds i to the "is_vip" field.
  44675. func (m *WxCardUserMutation) AddIsVip(i int) {
  44676. if m.addis_vip != nil {
  44677. *m.addis_vip += i
  44678. } else {
  44679. m.addis_vip = &i
  44680. }
  44681. }
  44682. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  44683. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  44684. v := m.addis_vip
  44685. if v == nil {
  44686. return
  44687. }
  44688. return *v, true
  44689. }
  44690. // ResetIsVip resets all changes to the "is_vip" field.
  44691. func (m *WxCardUserMutation) ResetIsVip() {
  44692. m.is_vip = nil
  44693. m.addis_vip = nil
  44694. }
  44695. // Where appends a list predicates to the WxCardUserMutation builder.
  44696. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  44697. m.predicates = append(m.predicates, ps...)
  44698. }
  44699. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  44700. // users can use type-assertion to append predicates that do not depend on any generated package.
  44701. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  44702. p := make([]predicate.WxCardUser, len(ps))
  44703. for i := range ps {
  44704. p[i] = ps[i]
  44705. }
  44706. m.Where(p...)
  44707. }
  44708. // Op returns the operation name.
  44709. func (m *WxCardUserMutation) Op() Op {
  44710. return m.op
  44711. }
  44712. // SetOp allows setting the mutation operation.
  44713. func (m *WxCardUserMutation) SetOp(op Op) {
  44714. m.op = op
  44715. }
  44716. // Type returns the node type of this mutation (WxCardUser).
  44717. func (m *WxCardUserMutation) Type() string {
  44718. return m.typ
  44719. }
  44720. // Fields returns all fields that were changed during this mutation. Note that in
  44721. // order to get all numeric fields that were incremented/decremented, call
  44722. // AddedFields().
  44723. func (m *WxCardUserMutation) Fields() []string {
  44724. fields := make([]string, 0, 13)
  44725. if m.created_at != nil {
  44726. fields = append(fields, wxcarduser.FieldCreatedAt)
  44727. }
  44728. if m.updated_at != nil {
  44729. fields = append(fields, wxcarduser.FieldUpdatedAt)
  44730. }
  44731. if m.deleted_at != nil {
  44732. fields = append(fields, wxcarduser.FieldDeletedAt)
  44733. }
  44734. if m.wxid != nil {
  44735. fields = append(fields, wxcarduser.FieldWxid)
  44736. }
  44737. if m.account != nil {
  44738. fields = append(fields, wxcarduser.FieldAccount)
  44739. }
  44740. if m.avatar != nil {
  44741. fields = append(fields, wxcarduser.FieldAvatar)
  44742. }
  44743. if m.nickname != nil {
  44744. fields = append(fields, wxcarduser.FieldNickname)
  44745. }
  44746. if m.remark != nil {
  44747. fields = append(fields, wxcarduser.FieldRemark)
  44748. }
  44749. if m.phone != nil {
  44750. fields = append(fields, wxcarduser.FieldPhone)
  44751. }
  44752. if m.open_id != nil {
  44753. fields = append(fields, wxcarduser.FieldOpenID)
  44754. }
  44755. if m.union_id != nil {
  44756. fields = append(fields, wxcarduser.FieldUnionID)
  44757. }
  44758. if m.session_key != nil {
  44759. fields = append(fields, wxcarduser.FieldSessionKey)
  44760. }
  44761. if m.is_vip != nil {
  44762. fields = append(fields, wxcarduser.FieldIsVip)
  44763. }
  44764. return fields
  44765. }
  44766. // Field returns the value of a field with the given name. The second boolean
  44767. // return value indicates that this field was not set, or was not defined in the
  44768. // schema.
  44769. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  44770. switch name {
  44771. case wxcarduser.FieldCreatedAt:
  44772. return m.CreatedAt()
  44773. case wxcarduser.FieldUpdatedAt:
  44774. return m.UpdatedAt()
  44775. case wxcarduser.FieldDeletedAt:
  44776. return m.DeletedAt()
  44777. case wxcarduser.FieldWxid:
  44778. return m.Wxid()
  44779. case wxcarduser.FieldAccount:
  44780. return m.Account()
  44781. case wxcarduser.FieldAvatar:
  44782. return m.Avatar()
  44783. case wxcarduser.FieldNickname:
  44784. return m.Nickname()
  44785. case wxcarduser.FieldRemark:
  44786. return m.Remark()
  44787. case wxcarduser.FieldPhone:
  44788. return m.Phone()
  44789. case wxcarduser.FieldOpenID:
  44790. return m.OpenID()
  44791. case wxcarduser.FieldUnionID:
  44792. return m.UnionID()
  44793. case wxcarduser.FieldSessionKey:
  44794. return m.SessionKey()
  44795. case wxcarduser.FieldIsVip:
  44796. return m.IsVip()
  44797. }
  44798. return nil, false
  44799. }
  44800. // OldField returns the old value of the field from the database. An error is
  44801. // returned if the mutation operation is not UpdateOne, or the query to the
  44802. // database failed.
  44803. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44804. switch name {
  44805. case wxcarduser.FieldCreatedAt:
  44806. return m.OldCreatedAt(ctx)
  44807. case wxcarduser.FieldUpdatedAt:
  44808. return m.OldUpdatedAt(ctx)
  44809. case wxcarduser.FieldDeletedAt:
  44810. return m.OldDeletedAt(ctx)
  44811. case wxcarduser.FieldWxid:
  44812. return m.OldWxid(ctx)
  44813. case wxcarduser.FieldAccount:
  44814. return m.OldAccount(ctx)
  44815. case wxcarduser.FieldAvatar:
  44816. return m.OldAvatar(ctx)
  44817. case wxcarduser.FieldNickname:
  44818. return m.OldNickname(ctx)
  44819. case wxcarduser.FieldRemark:
  44820. return m.OldRemark(ctx)
  44821. case wxcarduser.FieldPhone:
  44822. return m.OldPhone(ctx)
  44823. case wxcarduser.FieldOpenID:
  44824. return m.OldOpenID(ctx)
  44825. case wxcarduser.FieldUnionID:
  44826. return m.OldUnionID(ctx)
  44827. case wxcarduser.FieldSessionKey:
  44828. return m.OldSessionKey(ctx)
  44829. case wxcarduser.FieldIsVip:
  44830. return m.OldIsVip(ctx)
  44831. }
  44832. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  44833. }
  44834. // SetField sets the value of a field with the given name. It returns an error if
  44835. // the field is not defined in the schema, or if the type mismatched the field
  44836. // type.
  44837. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  44838. switch name {
  44839. case wxcarduser.FieldCreatedAt:
  44840. v, ok := value.(time.Time)
  44841. if !ok {
  44842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44843. }
  44844. m.SetCreatedAt(v)
  44845. return nil
  44846. case wxcarduser.FieldUpdatedAt:
  44847. v, ok := value.(time.Time)
  44848. if !ok {
  44849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44850. }
  44851. m.SetUpdatedAt(v)
  44852. return nil
  44853. case wxcarduser.FieldDeletedAt:
  44854. v, ok := value.(time.Time)
  44855. if !ok {
  44856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44857. }
  44858. m.SetDeletedAt(v)
  44859. return nil
  44860. case wxcarduser.FieldWxid:
  44861. v, ok := value.(string)
  44862. if !ok {
  44863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44864. }
  44865. m.SetWxid(v)
  44866. return nil
  44867. case wxcarduser.FieldAccount:
  44868. v, ok := value.(string)
  44869. if !ok {
  44870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44871. }
  44872. m.SetAccount(v)
  44873. return nil
  44874. case wxcarduser.FieldAvatar:
  44875. v, ok := value.(string)
  44876. if !ok {
  44877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44878. }
  44879. m.SetAvatar(v)
  44880. return nil
  44881. case wxcarduser.FieldNickname:
  44882. v, ok := value.(string)
  44883. if !ok {
  44884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44885. }
  44886. m.SetNickname(v)
  44887. return nil
  44888. case wxcarduser.FieldRemark:
  44889. v, ok := value.(string)
  44890. if !ok {
  44891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44892. }
  44893. m.SetRemark(v)
  44894. return nil
  44895. case wxcarduser.FieldPhone:
  44896. v, ok := value.(string)
  44897. if !ok {
  44898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44899. }
  44900. m.SetPhone(v)
  44901. return nil
  44902. case wxcarduser.FieldOpenID:
  44903. v, ok := value.(string)
  44904. if !ok {
  44905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44906. }
  44907. m.SetOpenID(v)
  44908. return nil
  44909. case wxcarduser.FieldUnionID:
  44910. v, ok := value.(string)
  44911. if !ok {
  44912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44913. }
  44914. m.SetUnionID(v)
  44915. return nil
  44916. case wxcarduser.FieldSessionKey:
  44917. v, ok := value.(string)
  44918. if !ok {
  44919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44920. }
  44921. m.SetSessionKey(v)
  44922. return nil
  44923. case wxcarduser.FieldIsVip:
  44924. v, ok := value.(int)
  44925. if !ok {
  44926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44927. }
  44928. m.SetIsVip(v)
  44929. return nil
  44930. }
  44931. return fmt.Errorf("unknown WxCardUser field %s", name)
  44932. }
  44933. // AddedFields returns all numeric fields that were incremented/decremented during
  44934. // this mutation.
  44935. func (m *WxCardUserMutation) AddedFields() []string {
  44936. var fields []string
  44937. if m.addis_vip != nil {
  44938. fields = append(fields, wxcarduser.FieldIsVip)
  44939. }
  44940. return fields
  44941. }
  44942. // AddedField returns the numeric value that was incremented/decremented on a field
  44943. // with the given name. The second boolean return value indicates that this field
  44944. // was not set, or was not defined in the schema.
  44945. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  44946. switch name {
  44947. case wxcarduser.FieldIsVip:
  44948. return m.AddedIsVip()
  44949. }
  44950. return nil, false
  44951. }
  44952. // AddField adds the value to the field with the given name. It returns an error if
  44953. // the field is not defined in the schema, or if the type mismatched the field
  44954. // type.
  44955. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  44956. switch name {
  44957. case wxcarduser.FieldIsVip:
  44958. v, ok := value.(int)
  44959. if !ok {
  44960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44961. }
  44962. m.AddIsVip(v)
  44963. return nil
  44964. }
  44965. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  44966. }
  44967. // ClearedFields returns all nullable fields that were cleared during this
  44968. // mutation.
  44969. func (m *WxCardUserMutation) ClearedFields() []string {
  44970. var fields []string
  44971. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  44972. fields = append(fields, wxcarduser.FieldDeletedAt)
  44973. }
  44974. return fields
  44975. }
  44976. // FieldCleared returns a boolean indicating if a field with the given name was
  44977. // cleared in this mutation.
  44978. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  44979. _, ok := m.clearedFields[name]
  44980. return ok
  44981. }
  44982. // ClearField clears the value of the field with the given name. It returns an
  44983. // error if the field is not defined in the schema.
  44984. func (m *WxCardUserMutation) ClearField(name string) error {
  44985. switch name {
  44986. case wxcarduser.FieldDeletedAt:
  44987. m.ClearDeletedAt()
  44988. return nil
  44989. }
  44990. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  44991. }
  44992. // ResetField resets all changes in the mutation for the field with the given name.
  44993. // It returns an error if the field is not defined in the schema.
  44994. func (m *WxCardUserMutation) ResetField(name string) error {
  44995. switch name {
  44996. case wxcarduser.FieldCreatedAt:
  44997. m.ResetCreatedAt()
  44998. return nil
  44999. case wxcarduser.FieldUpdatedAt:
  45000. m.ResetUpdatedAt()
  45001. return nil
  45002. case wxcarduser.FieldDeletedAt:
  45003. m.ResetDeletedAt()
  45004. return nil
  45005. case wxcarduser.FieldWxid:
  45006. m.ResetWxid()
  45007. return nil
  45008. case wxcarduser.FieldAccount:
  45009. m.ResetAccount()
  45010. return nil
  45011. case wxcarduser.FieldAvatar:
  45012. m.ResetAvatar()
  45013. return nil
  45014. case wxcarduser.FieldNickname:
  45015. m.ResetNickname()
  45016. return nil
  45017. case wxcarduser.FieldRemark:
  45018. m.ResetRemark()
  45019. return nil
  45020. case wxcarduser.FieldPhone:
  45021. m.ResetPhone()
  45022. return nil
  45023. case wxcarduser.FieldOpenID:
  45024. m.ResetOpenID()
  45025. return nil
  45026. case wxcarduser.FieldUnionID:
  45027. m.ResetUnionID()
  45028. return nil
  45029. case wxcarduser.FieldSessionKey:
  45030. m.ResetSessionKey()
  45031. return nil
  45032. case wxcarduser.FieldIsVip:
  45033. m.ResetIsVip()
  45034. return nil
  45035. }
  45036. return fmt.Errorf("unknown WxCardUser field %s", name)
  45037. }
  45038. // AddedEdges returns all edge names that were set/added in this mutation.
  45039. func (m *WxCardUserMutation) AddedEdges() []string {
  45040. edges := make([]string, 0, 0)
  45041. return edges
  45042. }
  45043. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45044. // name in this mutation.
  45045. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  45046. return nil
  45047. }
  45048. // RemovedEdges returns all edge names that were removed in this mutation.
  45049. func (m *WxCardUserMutation) RemovedEdges() []string {
  45050. edges := make([]string, 0, 0)
  45051. return edges
  45052. }
  45053. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45054. // the given name in this mutation.
  45055. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  45056. return nil
  45057. }
  45058. // ClearedEdges returns all edge names that were cleared in this mutation.
  45059. func (m *WxCardUserMutation) ClearedEdges() []string {
  45060. edges := make([]string, 0, 0)
  45061. return edges
  45062. }
  45063. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45064. // was cleared in this mutation.
  45065. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  45066. return false
  45067. }
  45068. // ClearEdge clears the value of the edge with the given name. It returns an error
  45069. // if that edge is not defined in the schema.
  45070. func (m *WxCardUserMutation) ClearEdge(name string) error {
  45071. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  45072. }
  45073. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45074. // It returns an error if the edge is not defined in the schema.
  45075. func (m *WxCardUserMutation) ResetEdge(name string) error {
  45076. return fmt.Errorf("unknown WxCardUser edge %s", name)
  45077. }
  45078. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  45079. type WxCardVisitMutation struct {
  45080. config
  45081. op Op
  45082. typ string
  45083. id *uint64
  45084. created_at *time.Time
  45085. updated_at *time.Time
  45086. deleted_at *time.Time
  45087. user_id *uint64
  45088. adduser_id *int64
  45089. bot_id *uint64
  45090. addbot_id *int64
  45091. bot_type *uint8
  45092. addbot_type *int8
  45093. clearedFields map[string]struct{}
  45094. done bool
  45095. oldValue func(context.Context) (*WxCardVisit, error)
  45096. predicates []predicate.WxCardVisit
  45097. }
  45098. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  45099. // wxcardvisitOption allows management of the mutation configuration using functional options.
  45100. type wxcardvisitOption func(*WxCardVisitMutation)
  45101. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  45102. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  45103. m := &WxCardVisitMutation{
  45104. config: c,
  45105. op: op,
  45106. typ: TypeWxCardVisit,
  45107. clearedFields: make(map[string]struct{}),
  45108. }
  45109. for _, opt := range opts {
  45110. opt(m)
  45111. }
  45112. return m
  45113. }
  45114. // withWxCardVisitID sets the ID field of the mutation.
  45115. func withWxCardVisitID(id uint64) wxcardvisitOption {
  45116. return func(m *WxCardVisitMutation) {
  45117. var (
  45118. err error
  45119. once sync.Once
  45120. value *WxCardVisit
  45121. )
  45122. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  45123. once.Do(func() {
  45124. if m.done {
  45125. err = errors.New("querying old values post mutation is not allowed")
  45126. } else {
  45127. value, err = m.Client().WxCardVisit.Get(ctx, id)
  45128. }
  45129. })
  45130. return value, err
  45131. }
  45132. m.id = &id
  45133. }
  45134. }
  45135. // withWxCardVisit sets the old WxCardVisit of the mutation.
  45136. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  45137. return func(m *WxCardVisitMutation) {
  45138. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  45139. return node, nil
  45140. }
  45141. m.id = &node.ID
  45142. }
  45143. }
  45144. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45145. // executed in a transaction (ent.Tx), a transactional client is returned.
  45146. func (m WxCardVisitMutation) Client() *Client {
  45147. client := &Client{config: m.config}
  45148. client.init()
  45149. return client
  45150. }
  45151. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45152. // it returns an error otherwise.
  45153. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  45154. if _, ok := m.driver.(*txDriver); !ok {
  45155. return nil, errors.New("ent: mutation is not running in a transaction")
  45156. }
  45157. tx := &Tx{config: m.config}
  45158. tx.init()
  45159. return tx, nil
  45160. }
  45161. // SetID sets the value of the id field. Note that this
  45162. // operation is only accepted on creation of WxCardVisit entities.
  45163. func (m *WxCardVisitMutation) SetID(id uint64) {
  45164. m.id = &id
  45165. }
  45166. // ID returns the ID value in the mutation. Note that the ID is only available
  45167. // if it was provided to the builder or after it was returned from the database.
  45168. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  45169. if m.id == nil {
  45170. return
  45171. }
  45172. return *m.id, true
  45173. }
  45174. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45175. // That means, if the mutation is applied within a transaction with an isolation level such
  45176. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45177. // or updated by the mutation.
  45178. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  45179. switch {
  45180. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45181. id, exists := m.ID()
  45182. if exists {
  45183. return []uint64{id}, nil
  45184. }
  45185. fallthrough
  45186. case m.op.Is(OpUpdate | OpDelete):
  45187. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  45188. default:
  45189. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45190. }
  45191. }
  45192. // SetCreatedAt sets the "created_at" field.
  45193. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  45194. m.created_at = &t
  45195. }
  45196. // CreatedAt returns the value of the "created_at" field in the mutation.
  45197. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  45198. v := m.created_at
  45199. if v == nil {
  45200. return
  45201. }
  45202. return *v, true
  45203. }
  45204. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  45205. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45207. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45208. if !m.op.Is(OpUpdateOne) {
  45209. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45210. }
  45211. if m.id == nil || m.oldValue == nil {
  45212. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45213. }
  45214. oldValue, err := m.oldValue(ctx)
  45215. if err != nil {
  45216. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45217. }
  45218. return oldValue.CreatedAt, nil
  45219. }
  45220. // ResetCreatedAt resets all changes to the "created_at" field.
  45221. func (m *WxCardVisitMutation) ResetCreatedAt() {
  45222. m.created_at = nil
  45223. }
  45224. // SetUpdatedAt sets the "updated_at" field.
  45225. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  45226. m.updated_at = &t
  45227. }
  45228. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45229. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  45230. v := m.updated_at
  45231. if v == nil {
  45232. return
  45233. }
  45234. return *v, true
  45235. }
  45236. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  45237. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45239. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45240. if !m.op.Is(OpUpdateOne) {
  45241. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45242. }
  45243. if m.id == nil || m.oldValue == nil {
  45244. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45245. }
  45246. oldValue, err := m.oldValue(ctx)
  45247. if err != nil {
  45248. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45249. }
  45250. return oldValue.UpdatedAt, nil
  45251. }
  45252. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45253. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  45254. m.updated_at = nil
  45255. }
  45256. // SetDeletedAt sets the "deleted_at" field.
  45257. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  45258. m.deleted_at = &t
  45259. }
  45260. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45261. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  45262. v := m.deleted_at
  45263. if v == nil {
  45264. return
  45265. }
  45266. return *v, true
  45267. }
  45268. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  45269. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45271. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45272. if !m.op.Is(OpUpdateOne) {
  45273. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45274. }
  45275. if m.id == nil || m.oldValue == nil {
  45276. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45277. }
  45278. oldValue, err := m.oldValue(ctx)
  45279. if err != nil {
  45280. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45281. }
  45282. return oldValue.DeletedAt, nil
  45283. }
  45284. // ClearDeletedAt clears the value of the "deleted_at" field.
  45285. func (m *WxCardVisitMutation) ClearDeletedAt() {
  45286. m.deleted_at = nil
  45287. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  45288. }
  45289. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45290. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  45291. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  45292. return ok
  45293. }
  45294. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45295. func (m *WxCardVisitMutation) ResetDeletedAt() {
  45296. m.deleted_at = nil
  45297. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  45298. }
  45299. // SetUserID sets the "user_id" field.
  45300. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  45301. m.user_id = &u
  45302. m.adduser_id = nil
  45303. }
  45304. // UserID returns the value of the "user_id" field in the mutation.
  45305. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  45306. v := m.user_id
  45307. if v == nil {
  45308. return
  45309. }
  45310. return *v, true
  45311. }
  45312. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  45313. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45315. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  45316. if !m.op.Is(OpUpdateOne) {
  45317. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  45318. }
  45319. if m.id == nil || m.oldValue == nil {
  45320. return v, errors.New("OldUserID requires an ID field in the mutation")
  45321. }
  45322. oldValue, err := m.oldValue(ctx)
  45323. if err != nil {
  45324. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  45325. }
  45326. return oldValue.UserID, nil
  45327. }
  45328. // AddUserID adds u to the "user_id" field.
  45329. func (m *WxCardVisitMutation) AddUserID(u int64) {
  45330. if m.adduser_id != nil {
  45331. *m.adduser_id += u
  45332. } else {
  45333. m.adduser_id = &u
  45334. }
  45335. }
  45336. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  45337. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  45338. v := m.adduser_id
  45339. if v == nil {
  45340. return
  45341. }
  45342. return *v, true
  45343. }
  45344. // ClearUserID clears the value of the "user_id" field.
  45345. func (m *WxCardVisitMutation) ClearUserID() {
  45346. m.user_id = nil
  45347. m.adduser_id = nil
  45348. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  45349. }
  45350. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  45351. func (m *WxCardVisitMutation) UserIDCleared() bool {
  45352. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  45353. return ok
  45354. }
  45355. // ResetUserID resets all changes to the "user_id" field.
  45356. func (m *WxCardVisitMutation) ResetUserID() {
  45357. m.user_id = nil
  45358. m.adduser_id = nil
  45359. delete(m.clearedFields, wxcardvisit.FieldUserID)
  45360. }
  45361. // SetBotID sets the "bot_id" field.
  45362. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  45363. m.bot_id = &u
  45364. m.addbot_id = nil
  45365. }
  45366. // BotID returns the value of the "bot_id" field in the mutation.
  45367. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  45368. v := m.bot_id
  45369. if v == nil {
  45370. return
  45371. }
  45372. return *v, true
  45373. }
  45374. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  45375. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45377. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  45378. if !m.op.Is(OpUpdateOne) {
  45379. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  45380. }
  45381. if m.id == nil || m.oldValue == nil {
  45382. return v, errors.New("OldBotID requires an ID field in the mutation")
  45383. }
  45384. oldValue, err := m.oldValue(ctx)
  45385. if err != nil {
  45386. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  45387. }
  45388. return oldValue.BotID, nil
  45389. }
  45390. // AddBotID adds u to the "bot_id" field.
  45391. func (m *WxCardVisitMutation) AddBotID(u int64) {
  45392. if m.addbot_id != nil {
  45393. *m.addbot_id += u
  45394. } else {
  45395. m.addbot_id = &u
  45396. }
  45397. }
  45398. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  45399. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  45400. v := m.addbot_id
  45401. if v == nil {
  45402. return
  45403. }
  45404. return *v, true
  45405. }
  45406. // ResetBotID resets all changes to the "bot_id" field.
  45407. func (m *WxCardVisitMutation) ResetBotID() {
  45408. m.bot_id = nil
  45409. m.addbot_id = nil
  45410. }
  45411. // SetBotType sets the "bot_type" field.
  45412. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  45413. m.bot_type = &u
  45414. m.addbot_type = nil
  45415. }
  45416. // BotType returns the value of the "bot_type" field in the mutation.
  45417. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  45418. v := m.bot_type
  45419. if v == nil {
  45420. return
  45421. }
  45422. return *v, true
  45423. }
  45424. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  45425. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45427. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  45428. if !m.op.Is(OpUpdateOne) {
  45429. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  45430. }
  45431. if m.id == nil || m.oldValue == nil {
  45432. return v, errors.New("OldBotType requires an ID field in the mutation")
  45433. }
  45434. oldValue, err := m.oldValue(ctx)
  45435. if err != nil {
  45436. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  45437. }
  45438. return oldValue.BotType, nil
  45439. }
  45440. // AddBotType adds u to the "bot_type" field.
  45441. func (m *WxCardVisitMutation) AddBotType(u int8) {
  45442. if m.addbot_type != nil {
  45443. *m.addbot_type += u
  45444. } else {
  45445. m.addbot_type = &u
  45446. }
  45447. }
  45448. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  45449. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  45450. v := m.addbot_type
  45451. if v == nil {
  45452. return
  45453. }
  45454. return *v, true
  45455. }
  45456. // ResetBotType resets all changes to the "bot_type" field.
  45457. func (m *WxCardVisitMutation) ResetBotType() {
  45458. m.bot_type = nil
  45459. m.addbot_type = nil
  45460. }
  45461. // Where appends a list predicates to the WxCardVisitMutation builder.
  45462. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  45463. m.predicates = append(m.predicates, ps...)
  45464. }
  45465. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  45466. // users can use type-assertion to append predicates that do not depend on any generated package.
  45467. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  45468. p := make([]predicate.WxCardVisit, len(ps))
  45469. for i := range ps {
  45470. p[i] = ps[i]
  45471. }
  45472. m.Where(p...)
  45473. }
  45474. // Op returns the operation name.
  45475. func (m *WxCardVisitMutation) Op() Op {
  45476. return m.op
  45477. }
  45478. // SetOp allows setting the mutation operation.
  45479. func (m *WxCardVisitMutation) SetOp(op Op) {
  45480. m.op = op
  45481. }
  45482. // Type returns the node type of this mutation (WxCardVisit).
  45483. func (m *WxCardVisitMutation) Type() string {
  45484. return m.typ
  45485. }
  45486. // Fields returns all fields that were changed during this mutation. Note that in
  45487. // order to get all numeric fields that were incremented/decremented, call
  45488. // AddedFields().
  45489. func (m *WxCardVisitMutation) Fields() []string {
  45490. fields := make([]string, 0, 6)
  45491. if m.created_at != nil {
  45492. fields = append(fields, wxcardvisit.FieldCreatedAt)
  45493. }
  45494. if m.updated_at != nil {
  45495. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  45496. }
  45497. if m.deleted_at != nil {
  45498. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45499. }
  45500. if m.user_id != nil {
  45501. fields = append(fields, wxcardvisit.FieldUserID)
  45502. }
  45503. if m.bot_id != nil {
  45504. fields = append(fields, wxcardvisit.FieldBotID)
  45505. }
  45506. if m.bot_type != nil {
  45507. fields = append(fields, wxcardvisit.FieldBotType)
  45508. }
  45509. return fields
  45510. }
  45511. // Field returns the value of a field with the given name. The second boolean
  45512. // return value indicates that this field was not set, or was not defined in the
  45513. // schema.
  45514. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  45515. switch name {
  45516. case wxcardvisit.FieldCreatedAt:
  45517. return m.CreatedAt()
  45518. case wxcardvisit.FieldUpdatedAt:
  45519. return m.UpdatedAt()
  45520. case wxcardvisit.FieldDeletedAt:
  45521. return m.DeletedAt()
  45522. case wxcardvisit.FieldUserID:
  45523. return m.UserID()
  45524. case wxcardvisit.FieldBotID:
  45525. return m.BotID()
  45526. case wxcardvisit.FieldBotType:
  45527. return m.BotType()
  45528. }
  45529. return nil, false
  45530. }
  45531. // OldField returns the old value of the field from the database. An error is
  45532. // returned if the mutation operation is not UpdateOne, or the query to the
  45533. // database failed.
  45534. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45535. switch name {
  45536. case wxcardvisit.FieldCreatedAt:
  45537. return m.OldCreatedAt(ctx)
  45538. case wxcardvisit.FieldUpdatedAt:
  45539. return m.OldUpdatedAt(ctx)
  45540. case wxcardvisit.FieldDeletedAt:
  45541. return m.OldDeletedAt(ctx)
  45542. case wxcardvisit.FieldUserID:
  45543. return m.OldUserID(ctx)
  45544. case wxcardvisit.FieldBotID:
  45545. return m.OldBotID(ctx)
  45546. case wxcardvisit.FieldBotType:
  45547. return m.OldBotType(ctx)
  45548. }
  45549. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  45550. }
  45551. // SetField sets the value of a field with the given name. It returns an error if
  45552. // the field is not defined in the schema, or if the type mismatched the field
  45553. // type.
  45554. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  45555. switch name {
  45556. case wxcardvisit.FieldCreatedAt:
  45557. v, ok := value.(time.Time)
  45558. if !ok {
  45559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45560. }
  45561. m.SetCreatedAt(v)
  45562. return nil
  45563. case wxcardvisit.FieldUpdatedAt:
  45564. v, ok := value.(time.Time)
  45565. if !ok {
  45566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45567. }
  45568. m.SetUpdatedAt(v)
  45569. return nil
  45570. case wxcardvisit.FieldDeletedAt:
  45571. v, ok := value.(time.Time)
  45572. if !ok {
  45573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45574. }
  45575. m.SetDeletedAt(v)
  45576. return nil
  45577. case wxcardvisit.FieldUserID:
  45578. v, ok := value.(uint64)
  45579. if !ok {
  45580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45581. }
  45582. m.SetUserID(v)
  45583. return nil
  45584. case wxcardvisit.FieldBotID:
  45585. v, ok := value.(uint64)
  45586. if !ok {
  45587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45588. }
  45589. m.SetBotID(v)
  45590. return nil
  45591. case wxcardvisit.FieldBotType:
  45592. v, ok := value.(uint8)
  45593. if !ok {
  45594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45595. }
  45596. m.SetBotType(v)
  45597. return nil
  45598. }
  45599. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45600. }
  45601. // AddedFields returns all numeric fields that were incremented/decremented during
  45602. // this mutation.
  45603. func (m *WxCardVisitMutation) AddedFields() []string {
  45604. var fields []string
  45605. if m.adduser_id != nil {
  45606. fields = append(fields, wxcardvisit.FieldUserID)
  45607. }
  45608. if m.addbot_id != nil {
  45609. fields = append(fields, wxcardvisit.FieldBotID)
  45610. }
  45611. if m.addbot_type != nil {
  45612. fields = append(fields, wxcardvisit.FieldBotType)
  45613. }
  45614. return fields
  45615. }
  45616. // AddedField returns the numeric value that was incremented/decremented on a field
  45617. // with the given name. The second boolean return value indicates that this field
  45618. // was not set, or was not defined in the schema.
  45619. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  45620. switch name {
  45621. case wxcardvisit.FieldUserID:
  45622. return m.AddedUserID()
  45623. case wxcardvisit.FieldBotID:
  45624. return m.AddedBotID()
  45625. case wxcardvisit.FieldBotType:
  45626. return m.AddedBotType()
  45627. }
  45628. return nil, false
  45629. }
  45630. // AddField adds the value to the field with the given name. It returns an error if
  45631. // the field is not defined in the schema, or if the type mismatched the field
  45632. // type.
  45633. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  45634. switch name {
  45635. case wxcardvisit.FieldUserID:
  45636. v, ok := value.(int64)
  45637. if !ok {
  45638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45639. }
  45640. m.AddUserID(v)
  45641. return nil
  45642. case wxcardvisit.FieldBotID:
  45643. v, ok := value.(int64)
  45644. if !ok {
  45645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45646. }
  45647. m.AddBotID(v)
  45648. return nil
  45649. case wxcardvisit.FieldBotType:
  45650. v, ok := value.(int8)
  45651. if !ok {
  45652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45653. }
  45654. m.AddBotType(v)
  45655. return nil
  45656. }
  45657. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  45658. }
  45659. // ClearedFields returns all nullable fields that were cleared during this
  45660. // mutation.
  45661. func (m *WxCardVisitMutation) ClearedFields() []string {
  45662. var fields []string
  45663. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  45664. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45665. }
  45666. if m.FieldCleared(wxcardvisit.FieldUserID) {
  45667. fields = append(fields, wxcardvisit.FieldUserID)
  45668. }
  45669. return fields
  45670. }
  45671. // FieldCleared returns a boolean indicating if a field with the given name was
  45672. // cleared in this mutation.
  45673. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  45674. _, ok := m.clearedFields[name]
  45675. return ok
  45676. }
  45677. // ClearField clears the value of the field with the given name. It returns an
  45678. // error if the field is not defined in the schema.
  45679. func (m *WxCardVisitMutation) ClearField(name string) error {
  45680. switch name {
  45681. case wxcardvisit.FieldDeletedAt:
  45682. m.ClearDeletedAt()
  45683. return nil
  45684. case wxcardvisit.FieldUserID:
  45685. m.ClearUserID()
  45686. return nil
  45687. }
  45688. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  45689. }
  45690. // ResetField resets all changes in the mutation for the field with the given name.
  45691. // It returns an error if the field is not defined in the schema.
  45692. func (m *WxCardVisitMutation) ResetField(name string) error {
  45693. switch name {
  45694. case wxcardvisit.FieldCreatedAt:
  45695. m.ResetCreatedAt()
  45696. return nil
  45697. case wxcardvisit.FieldUpdatedAt:
  45698. m.ResetUpdatedAt()
  45699. return nil
  45700. case wxcardvisit.FieldDeletedAt:
  45701. m.ResetDeletedAt()
  45702. return nil
  45703. case wxcardvisit.FieldUserID:
  45704. m.ResetUserID()
  45705. return nil
  45706. case wxcardvisit.FieldBotID:
  45707. m.ResetBotID()
  45708. return nil
  45709. case wxcardvisit.FieldBotType:
  45710. m.ResetBotType()
  45711. return nil
  45712. }
  45713. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45714. }
  45715. // AddedEdges returns all edge names that were set/added in this mutation.
  45716. func (m *WxCardVisitMutation) AddedEdges() []string {
  45717. edges := make([]string, 0, 0)
  45718. return edges
  45719. }
  45720. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45721. // name in this mutation.
  45722. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  45723. return nil
  45724. }
  45725. // RemovedEdges returns all edge names that were removed in this mutation.
  45726. func (m *WxCardVisitMutation) RemovedEdges() []string {
  45727. edges := make([]string, 0, 0)
  45728. return edges
  45729. }
  45730. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45731. // the given name in this mutation.
  45732. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  45733. return nil
  45734. }
  45735. // ClearedEdges returns all edge names that were cleared in this mutation.
  45736. func (m *WxCardVisitMutation) ClearedEdges() []string {
  45737. edges := make([]string, 0, 0)
  45738. return edges
  45739. }
  45740. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45741. // was cleared in this mutation.
  45742. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  45743. return false
  45744. }
  45745. // ClearEdge clears the value of the edge with the given name. It returns an error
  45746. // if that edge is not defined in the schema.
  45747. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  45748. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  45749. }
  45750. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45751. // It returns an error if the edge is not defined in the schema.
  45752. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  45753. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  45754. }
  45755. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  45756. type XunjiMutation struct {
  45757. config
  45758. op Op
  45759. typ string
  45760. id *uint64
  45761. created_at *time.Time
  45762. updated_at *time.Time
  45763. status *uint8
  45764. addstatus *int8
  45765. deleted_at *time.Time
  45766. app_key *string
  45767. app_secret *string
  45768. token *string
  45769. encoding_key *string
  45770. organization_id *uint64
  45771. addorganization_id *int64
  45772. clearedFields map[string]struct{}
  45773. done bool
  45774. oldValue func(context.Context) (*Xunji, error)
  45775. predicates []predicate.Xunji
  45776. }
  45777. var _ ent.Mutation = (*XunjiMutation)(nil)
  45778. // xunjiOption allows management of the mutation configuration using functional options.
  45779. type xunjiOption func(*XunjiMutation)
  45780. // newXunjiMutation creates new mutation for the Xunji entity.
  45781. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  45782. m := &XunjiMutation{
  45783. config: c,
  45784. op: op,
  45785. typ: TypeXunji,
  45786. clearedFields: make(map[string]struct{}),
  45787. }
  45788. for _, opt := range opts {
  45789. opt(m)
  45790. }
  45791. return m
  45792. }
  45793. // withXunjiID sets the ID field of the mutation.
  45794. func withXunjiID(id uint64) xunjiOption {
  45795. return func(m *XunjiMutation) {
  45796. var (
  45797. err error
  45798. once sync.Once
  45799. value *Xunji
  45800. )
  45801. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  45802. once.Do(func() {
  45803. if m.done {
  45804. err = errors.New("querying old values post mutation is not allowed")
  45805. } else {
  45806. value, err = m.Client().Xunji.Get(ctx, id)
  45807. }
  45808. })
  45809. return value, err
  45810. }
  45811. m.id = &id
  45812. }
  45813. }
  45814. // withXunji sets the old Xunji of the mutation.
  45815. func withXunji(node *Xunji) xunjiOption {
  45816. return func(m *XunjiMutation) {
  45817. m.oldValue = func(context.Context) (*Xunji, error) {
  45818. return node, nil
  45819. }
  45820. m.id = &node.ID
  45821. }
  45822. }
  45823. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45824. // executed in a transaction (ent.Tx), a transactional client is returned.
  45825. func (m XunjiMutation) Client() *Client {
  45826. client := &Client{config: m.config}
  45827. client.init()
  45828. return client
  45829. }
  45830. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45831. // it returns an error otherwise.
  45832. func (m XunjiMutation) Tx() (*Tx, error) {
  45833. if _, ok := m.driver.(*txDriver); !ok {
  45834. return nil, errors.New("ent: mutation is not running in a transaction")
  45835. }
  45836. tx := &Tx{config: m.config}
  45837. tx.init()
  45838. return tx, nil
  45839. }
  45840. // SetID sets the value of the id field. Note that this
  45841. // operation is only accepted on creation of Xunji entities.
  45842. func (m *XunjiMutation) SetID(id uint64) {
  45843. m.id = &id
  45844. }
  45845. // ID returns the ID value in the mutation. Note that the ID is only available
  45846. // if it was provided to the builder or after it was returned from the database.
  45847. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  45848. if m.id == nil {
  45849. return
  45850. }
  45851. return *m.id, true
  45852. }
  45853. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45854. // That means, if the mutation is applied within a transaction with an isolation level such
  45855. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45856. // or updated by the mutation.
  45857. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  45858. switch {
  45859. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45860. id, exists := m.ID()
  45861. if exists {
  45862. return []uint64{id}, nil
  45863. }
  45864. fallthrough
  45865. case m.op.Is(OpUpdate | OpDelete):
  45866. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  45867. default:
  45868. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45869. }
  45870. }
  45871. // SetCreatedAt sets the "created_at" field.
  45872. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  45873. m.created_at = &t
  45874. }
  45875. // CreatedAt returns the value of the "created_at" field in the mutation.
  45876. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  45877. v := m.created_at
  45878. if v == nil {
  45879. return
  45880. }
  45881. return *v, true
  45882. }
  45883. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  45884. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45886. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45887. if !m.op.Is(OpUpdateOne) {
  45888. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45889. }
  45890. if m.id == nil || m.oldValue == nil {
  45891. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45892. }
  45893. oldValue, err := m.oldValue(ctx)
  45894. if err != nil {
  45895. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45896. }
  45897. return oldValue.CreatedAt, nil
  45898. }
  45899. // ResetCreatedAt resets all changes to the "created_at" field.
  45900. func (m *XunjiMutation) ResetCreatedAt() {
  45901. m.created_at = nil
  45902. }
  45903. // SetUpdatedAt sets the "updated_at" field.
  45904. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  45905. m.updated_at = &t
  45906. }
  45907. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45908. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  45909. v := m.updated_at
  45910. if v == nil {
  45911. return
  45912. }
  45913. return *v, true
  45914. }
  45915. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  45916. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45918. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45919. if !m.op.Is(OpUpdateOne) {
  45920. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45921. }
  45922. if m.id == nil || m.oldValue == nil {
  45923. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45924. }
  45925. oldValue, err := m.oldValue(ctx)
  45926. if err != nil {
  45927. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45928. }
  45929. return oldValue.UpdatedAt, nil
  45930. }
  45931. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45932. func (m *XunjiMutation) ResetUpdatedAt() {
  45933. m.updated_at = nil
  45934. }
  45935. // SetStatus sets the "status" field.
  45936. func (m *XunjiMutation) SetStatus(u uint8) {
  45937. m.status = &u
  45938. m.addstatus = nil
  45939. }
  45940. // Status returns the value of the "status" field in the mutation.
  45941. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  45942. v := m.status
  45943. if v == nil {
  45944. return
  45945. }
  45946. return *v, true
  45947. }
  45948. // OldStatus returns the old "status" field's value of the Xunji entity.
  45949. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  45950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45951. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45952. if !m.op.Is(OpUpdateOne) {
  45953. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45954. }
  45955. if m.id == nil || m.oldValue == nil {
  45956. return v, errors.New("OldStatus requires an ID field in the mutation")
  45957. }
  45958. oldValue, err := m.oldValue(ctx)
  45959. if err != nil {
  45960. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45961. }
  45962. return oldValue.Status, nil
  45963. }
  45964. // AddStatus adds u to the "status" field.
  45965. func (m *XunjiMutation) AddStatus(u int8) {
  45966. if m.addstatus != nil {
  45967. *m.addstatus += u
  45968. } else {
  45969. m.addstatus = &u
  45970. }
  45971. }
  45972. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45973. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  45974. v := m.addstatus
  45975. if v == nil {
  45976. return
  45977. }
  45978. return *v, true
  45979. }
  45980. // ClearStatus clears the value of the "status" field.
  45981. func (m *XunjiMutation) ClearStatus() {
  45982. m.status = nil
  45983. m.addstatus = nil
  45984. m.clearedFields[xunji.FieldStatus] = struct{}{}
  45985. }
  45986. // StatusCleared returns if the "status" field was cleared in this mutation.
  45987. func (m *XunjiMutation) StatusCleared() bool {
  45988. _, ok := m.clearedFields[xunji.FieldStatus]
  45989. return ok
  45990. }
  45991. // ResetStatus resets all changes to the "status" field.
  45992. func (m *XunjiMutation) ResetStatus() {
  45993. m.status = nil
  45994. m.addstatus = nil
  45995. delete(m.clearedFields, xunji.FieldStatus)
  45996. }
  45997. // SetDeletedAt sets the "deleted_at" field.
  45998. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  45999. m.deleted_at = &t
  46000. }
  46001. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46002. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  46003. v := m.deleted_at
  46004. if v == nil {
  46005. return
  46006. }
  46007. return *v, true
  46008. }
  46009. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  46010. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46012. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46013. if !m.op.Is(OpUpdateOne) {
  46014. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46015. }
  46016. if m.id == nil || m.oldValue == nil {
  46017. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46018. }
  46019. oldValue, err := m.oldValue(ctx)
  46020. if err != nil {
  46021. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46022. }
  46023. return oldValue.DeletedAt, nil
  46024. }
  46025. // ClearDeletedAt clears the value of the "deleted_at" field.
  46026. func (m *XunjiMutation) ClearDeletedAt() {
  46027. m.deleted_at = nil
  46028. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  46029. }
  46030. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46031. func (m *XunjiMutation) DeletedAtCleared() bool {
  46032. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  46033. return ok
  46034. }
  46035. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46036. func (m *XunjiMutation) ResetDeletedAt() {
  46037. m.deleted_at = nil
  46038. delete(m.clearedFields, xunji.FieldDeletedAt)
  46039. }
  46040. // SetAppKey sets the "app_key" field.
  46041. func (m *XunjiMutation) SetAppKey(s string) {
  46042. m.app_key = &s
  46043. }
  46044. // AppKey returns the value of the "app_key" field in the mutation.
  46045. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  46046. v := m.app_key
  46047. if v == nil {
  46048. return
  46049. }
  46050. return *v, true
  46051. }
  46052. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  46053. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46055. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  46056. if !m.op.Is(OpUpdateOne) {
  46057. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  46058. }
  46059. if m.id == nil || m.oldValue == nil {
  46060. return v, errors.New("OldAppKey requires an ID field in the mutation")
  46061. }
  46062. oldValue, err := m.oldValue(ctx)
  46063. if err != nil {
  46064. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  46065. }
  46066. return oldValue.AppKey, nil
  46067. }
  46068. // ResetAppKey resets all changes to the "app_key" field.
  46069. func (m *XunjiMutation) ResetAppKey() {
  46070. m.app_key = nil
  46071. }
  46072. // SetAppSecret sets the "app_secret" field.
  46073. func (m *XunjiMutation) SetAppSecret(s string) {
  46074. m.app_secret = &s
  46075. }
  46076. // AppSecret returns the value of the "app_secret" field in the mutation.
  46077. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  46078. v := m.app_secret
  46079. if v == nil {
  46080. return
  46081. }
  46082. return *v, true
  46083. }
  46084. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  46085. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46087. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  46088. if !m.op.Is(OpUpdateOne) {
  46089. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  46090. }
  46091. if m.id == nil || m.oldValue == nil {
  46092. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  46093. }
  46094. oldValue, err := m.oldValue(ctx)
  46095. if err != nil {
  46096. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  46097. }
  46098. return oldValue.AppSecret, nil
  46099. }
  46100. // ResetAppSecret resets all changes to the "app_secret" field.
  46101. func (m *XunjiMutation) ResetAppSecret() {
  46102. m.app_secret = nil
  46103. }
  46104. // SetToken sets the "token" field.
  46105. func (m *XunjiMutation) SetToken(s string) {
  46106. m.token = &s
  46107. }
  46108. // Token returns the value of the "token" field in the mutation.
  46109. func (m *XunjiMutation) Token() (r string, exists bool) {
  46110. v := m.token
  46111. if v == nil {
  46112. return
  46113. }
  46114. return *v, true
  46115. }
  46116. // OldToken returns the old "token" field's value of the Xunji entity.
  46117. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46119. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  46120. if !m.op.Is(OpUpdateOne) {
  46121. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  46122. }
  46123. if m.id == nil || m.oldValue == nil {
  46124. return v, errors.New("OldToken requires an ID field in the mutation")
  46125. }
  46126. oldValue, err := m.oldValue(ctx)
  46127. if err != nil {
  46128. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  46129. }
  46130. return oldValue.Token, nil
  46131. }
  46132. // ResetToken resets all changes to the "token" field.
  46133. func (m *XunjiMutation) ResetToken() {
  46134. m.token = nil
  46135. }
  46136. // SetEncodingKey sets the "encoding_key" field.
  46137. func (m *XunjiMutation) SetEncodingKey(s string) {
  46138. m.encoding_key = &s
  46139. }
  46140. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  46141. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  46142. v := m.encoding_key
  46143. if v == nil {
  46144. return
  46145. }
  46146. return *v, true
  46147. }
  46148. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  46149. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46151. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  46152. if !m.op.Is(OpUpdateOne) {
  46153. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  46154. }
  46155. if m.id == nil || m.oldValue == nil {
  46156. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  46157. }
  46158. oldValue, err := m.oldValue(ctx)
  46159. if err != nil {
  46160. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  46161. }
  46162. return oldValue.EncodingKey, nil
  46163. }
  46164. // ResetEncodingKey resets all changes to the "encoding_key" field.
  46165. func (m *XunjiMutation) ResetEncodingKey() {
  46166. m.encoding_key = nil
  46167. }
  46168. // SetOrganizationID sets the "organization_id" field.
  46169. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  46170. m.organization_id = &u
  46171. m.addorganization_id = nil
  46172. }
  46173. // OrganizationID returns the value of the "organization_id" field in the mutation.
  46174. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  46175. v := m.organization_id
  46176. if v == nil {
  46177. return
  46178. }
  46179. return *v, true
  46180. }
  46181. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  46182. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46184. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  46185. if !m.op.Is(OpUpdateOne) {
  46186. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  46187. }
  46188. if m.id == nil || m.oldValue == nil {
  46189. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  46190. }
  46191. oldValue, err := m.oldValue(ctx)
  46192. if err != nil {
  46193. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  46194. }
  46195. return oldValue.OrganizationID, nil
  46196. }
  46197. // AddOrganizationID adds u to the "organization_id" field.
  46198. func (m *XunjiMutation) AddOrganizationID(u int64) {
  46199. if m.addorganization_id != nil {
  46200. *m.addorganization_id += u
  46201. } else {
  46202. m.addorganization_id = &u
  46203. }
  46204. }
  46205. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  46206. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  46207. v := m.addorganization_id
  46208. if v == nil {
  46209. return
  46210. }
  46211. return *v, true
  46212. }
  46213. // ResetOrganizationID resets all changes to the "organization_id" field.
  46214. func (m *XunjiMutation) ResetOrganizationID() {
  46215. m.organization_id = nil
  46216. m.addorganization_id = nil
  46217. }
  46218. // Where appends a list predicates to the XunjiMutation builder.
  46219. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  46220. m.predicates = append(m.predicates, ps...)
  46221. }
  46222. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  46223. // users can use type-assertion to append predicates that do not depend on any generated package.
  46224. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  46225. p := make([]predicate.Xunji, len(ps))
  46226. for i := range ps {
  46227. p[i] = ps[i]
  46228. }
  46229. m.Where(p...)
  46230. }
  46231. // Op returns the operation name.
  46232. func (m *XunjiMutation) Op() Op {
  46233. return m.op
  46234. }
  46235. // SetOp allows setting the mutation operation.
  46236. func (m *XunjiMutation) SetOp(op Op) {
  46237. m.op = op
  46238. }
  46239. // Type returns the node type of this mutation (Xunji).
  46240. func (m *XunjiMutation) Type() string {
  46241. return m.typ
  46242. }
  46243. // Fields returns all fields that were changed during this mutation. Note that in
  46244. // order to get all numeric fields that were incremented/decremented, call
  46245. // AddedFields().
  46246. func (m *XunjiMutation) Fields() []string {
  46247. fields := make([]string, 0, 9)
  46248. if m.created_at != nil {
  46249. fields = append(fields, xunji.FieldCreatedAt)
  46250. }
  46251. if m.updated_at != nil {
  46252. fields = append(fields, xunji.FieldUpdatedAt)
  46253. }
  46254. if m.status != nil {
  46255. fields = append(fields, xunji.FieldStatus)
  46256. }
  46257. if m.deleted_at != nil {
  46258. fields = append(fields, xunji.FieldDeletedAt)
  46259. }
  46260. if m.app_key != nil {
  46261. fields = append(fields, xunji.FieldAppKey)
  46262. }
  46263. if m.app_secret != nil {
  46264. fields = append(fields, xunji.FieldAppSecret)
  46265. }
  46266. if m.token != nil {
  46267. fields = append(fields, xunji.FieldToken)
  46268. }
  46269. if m.encoding_key != nil {
  46270. fields = append(fields, xunji.FieldEncodingKey)
  46271. }
  46272. if m.organization_id != nil {
  46273. fields = append(fields, xunji.FieldOrganizationID)
  46274. }
  46275. return fields
  46276. }
  46277. // Field returns the value of a field with the given name. The second boolean
  46278. // return value indicates that this field was not set, or was not defined in the
  46279. // schema.
  46280. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  46281. switch name {
  46282. case xunji.FieldCreatedAt:
  46283. return m.CreatedAt()
  46284. case xunji.FieldUpdatedAt:
  46285. return m.UpdatedAt()
  46286. case xunji.FieldStatus:
  46287. return m.Status()
  46288. case xunji.FieldDeletedAt:
  46289. return m.DeletedAt()
  46290. case xunji.FieldAppKey:
  46291. return m.AppKey()
  46292. case xunji.FieldAppSecret:
  46293. return m.AppSecret()
  46294. case xunji.FieldToken:
  46295. return m.Token()
  46296. case xunji.FieldEncodingKey:
  46297. return m.EncodingKey()
  46298. case xunji.FieldOrganizationID:
  46299. return m.OrganizationID()
  46300. }
  46301. return nil, false
  46302. }
  46303. // OldField returns the old value of the field from the database. An error is
  46304. // returned if the mutation operation is not UpdateOne, or the query to the
  46305. // database failed.
  46306. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46307. switch name {
  46308. case xunji.FieldCreatedAt:
  46309. return m.OldCreatedAt(ctx)
  46310. case xunji.FieldUpdatedAt:
  46311. return m.OldUpdatedAt(ctx)
  46312. case xunji.FieldStatus:
  46313. return m.OldStatus(ctx)
  46314. case xunji.FieldDeletedAt:
  46315. return m.OldDeletedAt(ctx)
  46316. case xunji.FieldAppKey:
  46317. return m.OldAppKey(ctx)
  46318. case xunji.FieldAppSecret:
  46319. return m.OldAppSecret(ctx)
  46320. case xunji.FieldToken:
  46321. return m.OldToken(ctx)
  46322. case xunji.FieldEncodingKey:
  46323. return m.OldEncodingKey(ctx)
  46324. case xunji.FieldOrganizationID:
  46325. return m.OldOrganizationID(ctx)
  46326. }
  46327. return nil, fmt.Errorf("unknown Xunji field %s", name)
  46328. }
  46329. // SetField sets the value of a field with the given name. It returns an error if
  46330. // the field is not defined in the schema, or if the type mismatched the field
  46331. // type.
  46332. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  46333. switch name {
  46334. case xunji.FieldCreatedAt:
  46335. v, ok := value.(time.Time)
  46336. if !ok {
  46337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46338. }
  46339. m.SetCreatedAt(v)
  46340. return nil
  46341. case xunji.FieldUpdatedAt:
  46342. v, ok := value.(time.Time)
  46343. if !ok {
  46344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46345. }
  46346. m.SetUpdatedAt(v)
  46347. return nil
  46348. case xunji.FieldStatus:
  46349. v, ok := value.(uint8)
  46350. if !ok {
  46351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46352. }
  46353. m.SetStatus(v)
  46354. return nil
  46355. case xunji.FieldDeletedAt:
  46356. v, ok := value.(time.Time)
  46357. if !ok {
  46358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46359. }
  46360. m.SetDeletedAt(v)
  46361. return nil
  46362. case xunji.FieldAppKey:
  46363. v, ok := value.(string)
  46364. if !ok {
  46365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46366. }
  46367. m.SetAppKey(v)
  46368. return nil
  46369. case xunji.FieldAppSecret:
  46370. v, ok := value.(string)
  46371. if !ok {
  46372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46373. }
  46374. m.SetAppSecret(v)
  46375. return nil
  46376. case xunji.FieldToken:
  46377. v, ok := value.(string)
  46378. if !ok {
  46379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46380. }
  46381. m.SetToken(v)
  46382. return nil
  46383. case xunji.FieldEncodingKey:
  46384. v, ok := value.(string)
  46385. if !ok {
  46386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46387. }
  46388. m.SetEncodingKey(v)
  46389. return nil
  46390. case xunji.FieldOrganizationID:
  46391. v, ok := value.(uint64)
  46392. if !ok {
  46393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46394. }
  46395. m.SetOrganizationID(v)
  46396. return nil
  46397. }
  46398. return fmt.Errorf("unknown Xunji field %s", name)
  46399. }
  46400. // AddedFields returns all numeric fields that were incremented/decremented during
  46401. // this mutation.
  46402. func (m *XunjiMutation) AddedFields() []string {
  46403. var fields []string
  46404. if m.addstatus != nil {
  46405. fields = append(fields, xunji.FieldStatus)
  46406. }
  46407. if m.addorganization_id != nil {
  46408. fields = append(fields, xunji.FieldOrganizationID)
  46409. }
  46410. return fields
  46411. }
  46412. // AddedField returns the numeric value that was incremented/decremented on a field
  46413. // with the given name. The second boolean return value indicates that this field
  46414. // was not set, or was not defined in the schema.
  46415. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  46416. switch name {
  46417. case xunji.FieldStatus:
  46418. return m.AddedStatus()
  46419. case xunji.FieldOrganizationID:
  46420. return m.AddedOrganizationID()
  46421. }
  46422. return nil, false
  46423. }
  46424. // AddField adds the value to the field with the given name. It returns an error if
  46425. // the field is not defined in the schema, or if the type mismatched the field
  46426. // type.
  46427. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  46428. switch name {
  46429. case xunji.FieldStatus:
  46430. v, ok := value.(int8)
  46431. if !ok {
  46432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46433. }
  46434. m.AddStatus(v)
  46435. return nil
  46436. case xunji.FieldOrganizationID:
  46437. v, ok := value.(int64)
  46438. if !ok {
  46439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46440. }
  46441. m.AddOrganizationID(v)
  46442. return nil
  46443. }
  46444. return fmt.Errorf("unknown Xunji numeric field %s", name)
  46445. }
  46446. // ClearedFields returns all nullable fields that were cleared during this
  46447. // mutation.
  46448. func (m *XunjiMutation) ClearedFields() []string {
  46449. var fields []string
  46450. if m.FieldCleared(xunji.FieldStatus) {
  46451. fields = append(fields, xunji.FieldStatus)
  46452. }
  46453. if m.FieldCleared(xunji.FieldDeletedAt) {
  46454. fields = append(fields, xunji.FieldDeletedAt)
  46455. }
  46456. return fields
  46457. }
  46458. // FieldCleared returns a boolean indicating if a field with the given name was
  46459. // cleared in this mutation.
  46460. func (m *XunjiMutation) FieldCleared(name string) bool {
  46461. _, ok := m.clearedFields[name]
  46462. return ok
  46463. }
  46464. // ClearField clears the value of the field with the given name. It returns an
  46465. // error if the field is not defined in the schema.
  46466. func (m *XunjiMutation) ClearField(name string) error {
  46467. switch name {
  46468. case xunji.FieldStatus:
  46469. m.ClearStatus()
  46470. return nil
  46471. case xunji.FieldDeletedAt:
  46472. m.ClearDeletedAt()
  46473. return nil
  46474. }
  46475. return fmt.Errorf("unknown Xunji nullable field %s", name)
  46476. }
  46477. // ResetField resets all changes in the mutation for the field with the given name.
  46478. // It returns an error if the field is not defined in the schema.
  46479. func (m *XunjiMutation) ResetField(name string) error {
  46480. switch name {
  46481. case xunji.FieldCreatedAt:
  46482. m.ResetCreatedAt()
  46483. return nil
  46484. case xunji.FieldUpdatedAt:
  46485. m.ResetUpdatedAt()
  46486. return nil
  46487. case xunji.FieldStatus:
  46488. m.ResetStatus()
  46489. return nil
  46490. case xunji.FieldDeletedAt:
  46491. m.ResetDeletedAt()
  46492. return nil
  46493. case xunji.FieldAppKey:
  46494. m.ResetAppKey()
  46495. return nil
  46496. case xunji.FieldAppSecret:
  46497. m.ResetAppSecret()
  46498. return nil
  46499. case xunji.FieldToken:
  46500. m.ResetToken()
  46501. return nil
  46502. case xunji.FieldEncodingKey:
  46503. m.ResetEncodingKey()
  46504. return nil
  46505. case xunji.FieldOrganizationID:
  46506. m.ResetOrganizationID()
  46507. return nil
  46508. }
  46509. return fmt.Errorf("unknown Xunji field %s", name)
  46510. }
  46511. // AddedEdges returns all edge names that were set/added in this mutation.
  46512. func (m *XunjiMutation) AddedEdges() []string {
  46513. edges := make([]string, 0, 0)
  46514. return edges
  46515. }
  46516. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46517. // name in this mutation.
  46518. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  46519. return nil
  46520. }
  46521. // RemovedEdges returns all edge names that were removed in this mutation.
  46522. func (m *XunjiMutation) RemovedEdges() []string {
  46523. edges := make([]string, 0, 0)
  46524. return edges
  46525. }
  46526. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46527. // the given name in this mutation.
  46528. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  46529. return nil
  46530. }
  46531. // ClearedEdges returns all edge names that were cleared in this mutation.
  46532. func (m *XunjiMutation) ClearedEdges() []string {
  46533. edges := make([]string, 0, 0)
  46534. return edges
  46535. }
  46536. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46537. // was cleared in this mutation.
  46538. func (m *XunjiMutation) EdgeCleared(name string) bool {
  46539. return false
  46540. }
  46541. // ClearEdge clears the value of the edge with the given name. It returns an error
  46542. // if that edge is not defined in the schema.
  46543. func (m *XunjiMutation) ClearEdge(name string) error {
  46544. return fmt.Errorf("unknown Xunji unique edge %s", name)
  46545. }
  46546. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46547. // It returns an error if the edge is not defined in the schema.
  46548. func (m *XunjiMutation) ResetEdge(name string) error {
  46549. return fmt.Errorf("unknown Xunji edge %s", name)
  46550. }
  46551. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  46552. type XunjiServiceMutation struct {
  46553. config
  46554. op Op
  46555. typ string
  46556. id *uint64
  46557. created_at *time.Time
  46558. updated_at *time.Time
  46559. status *uint8
  46560. addstatus *int8
  46561. deleted_at *time.Time
  46562. xunji_id *uint64
  46563. addxunji_id *int64
  46564. organization_id *uint64
  46565. addorganization_id *int64
  46566. wxid *string
  46567. api_base *string
  46568. api_key *string
  46569. clearedFields map[string]struct{}
  46570. agent *uint64
  46571. clearedagent bool
  46572. done bool
  46573. oldValue func(context.Context) (*XunjiService, error)
  46574. predicates []predicate.XunjiService
  46575. }
  46576. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  46577. // xunjiserviceOption allows management of the mutation configuration using functional options.
  46578. type xunjiserviceOption func(*XunjiServiceMutation)
  46579. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  46580. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  46581. m := &XunjiServiceMutation{
  46582. config: c,
  46583. op: op,
  46584. typ: TypeXunjiService,
  46585. clearedFields: make(map[string]struct{}),
  46586. }
  46587. for _, opt := range opts {
  46588. opt(m)
  46589. }
  46590. return m
  46591. }
  46592. // withXunjiServiceID sets the ID field of the mutation.
  46593. func withXunjiServiceID(id uint64) xunjiserviceOption {
  46594. return func(m *XunjiServiceMutation) {
  46595. var (
  46596. err error
  46597. once sync.Once
  46598. value *XunjiService
  46599. )
  46600. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  46601. once.Do(func() {
  46602. if m.done {
  46603. err = errors.New("querying old values post mutation is not allowed")
  46604. } else {
  46605. value, err = m.Client().XunjiService.Get(ctx, id)
  46606. }
  46607. })
  46608. return value, err
  46609. }
  46610. m.id = &id
  46611. }
  46612. }
  46613. // withXunjiService sets the old XunjiService of the mutation.
  46614. func withXunjiService(node *XunjiService) xunjiserviceOption {
  46615. return func(m *XunjiServiceMutation) {
  46616. m.oldValue = func(context.Context) (*XunjiService, error) {
  46617. return node, nil
  46618. }
  46619. m.id = &node.ID
  46620. }
  46621. }
  46622. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46623. // executed in a transaction (ent.Tx), a transactional client is returned.
  46624. func (m XunjiServiceMutation) Client() *Client {
  46625. client := &Client{config: m.config}
  46626. client.init()
  46627. return client
  46628. }
  46629. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46630. // it returns an error otherwise.
  46631. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  46632. if _, ok := m.driver.(*txDriver); !ok {
  46633. return nil, errors.New("ent: mutation is not running in a transaction")
  46634. }
  46635. tx := &Tx{config: m.config}
  46636. tx.init()
  46637. return tx, nil
  46638. }
  46639. // SetID sets the value of the id field. Note that this
  46640. // operation is only accepted on creation of XunjiService entities.
  46641. func (m *XunjiServiceMutation) SetID(id uint64) {
  46642. m.id = &id
  46643. }
  46644. // ID returns the ID value in the mutation. Note that the ID is only available
  46645. // if it was provided to the builder or after it was returned from the database.
  46646. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  46647. if m.id == nil {
  46648. return
  46649. }
  46650. return *m.id, true
  46651. }
  46652. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46653. // That means, if the mutation is applied within a transaction with an isolation level such
  46654. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46655. // or updated by the mutation.
  46656. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  46657. switch {
  46658. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46659. id, exists := m.ID()
  46660. if exists {
  46661. return []uint64{id}, nil
  46662. }
  46663. fallthrough
  46664. case m.op.Is(OpUpdate | OpDelete):
  46665. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  46666. default:
  46667. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46668. }
  46669. }
  46670. // SetCreatedAt sets the "created_at" field.
  46671. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  46672. m.created_at = &t
  46673. }
  46674. // CreatedAt returns the value of the "created_at" field in the mutation.
  46675. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  46676. v := m.created_at
  46677. if v == nil {
  46678. return
  46679. }
  46680. return *v, true
  46681. }
  46682. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  46683. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46685. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46686. if !m.op.Is(OpUpdateOne) {
  46687. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46688. }
  46689. if m.id == nil || m.oldValue == nil {
  46690. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46691. }
  46692. oldValue, err := m.oldValue(ctx)
  46693. if err != nil {
  46694. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46695. }
  46696. return oldValue.CreatedAt, nil
  46697. }
  46698. // ResetCreatedAt resets all changes to the "created_at" field.
  46699. func (m *XunjiServiceMutation) ResetCreatedAt() {
  46700. m.created_at = nil
  46701. }
  46702. // SetUpdatedAt sets the "updated_at" field.
  46703. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  46704. m.updated_at = &t
  46705. }
  46706. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46707. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  46708. v := m.updated_at
  46709. if v == nil {
  46710. return
  46711. }
  46712. return *v, true
  46713. }
  46714. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  46715. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46717. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46718. if !m.op.Is(OpUpdateOne) {
  46719. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46720. }
  46721. if m.id == nil || m.oldValue == nil {
  46722. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46723. }
  46724. oldValue, err := m.oldValue(ctx)
  46725. if err != nil {
  46726. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46727. }
  46728. return oldValue.UpdatedAt, nil
  46729. }
  46730. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46731. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  46732. m.updated_at = nil
  46733. }
  46734. // SetStatus sets the "status" field.
  46735. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  46736. m.status = &u
  46737. m.addstatus = nil
  46738. }
  46739. // Status returns the value of the "status" field in the mutation.
  46740. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  46741. v := m.status
  46742. if v == nil {
  46743. return
  46744. }
  46745. return *v, true
  46746. }
  46747. // OldStatus returns the old "status" field's value of the XunjiService entity.
  46748. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46750. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46751. if !m.op.Is(OpUpdateOne) {
  46752. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46753. }
  46754. if m.id == nil || m.oldValue == nil {
  46755. return v, errors.New("OldStatus requires an ID field in the mutation")
  46756. }
  46757. oldValue, err := m.oldValue(ctx)
  46758. if err != nil {
  46759. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46760. }
  46761. return oldValue.Status, nil
  46762. }
  46763. // AddStatus adds u to the "status" field.
  46764. func (m *XunjiServiceMutation) AddStatus(u int8) {
  46765. if m.addstatus != nil {
  46766. *m.addstatus += u
  46767. } else {
  46768. m.addstatus = &u
  46769. }
  46770. }
  46771. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46772. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  46773. v := m.addstatus
  46774. if v == nil {
  46775. return
  46776. }
  46777. return *v, true
  46778. }
  46779. // ClearStatus clears the value of the "status" field.
  46780. func (m *XunjiServiceMutation) ClearStatus() {
  46781. m.status = nil
  46782. m.addstatus = nil
  46783. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  46784. }
  46785. // StatusCleared returns if the "status" field was cleared in this mutation.
  46786. func (m *XunjiServiceMutation) StatusCleared() bool {
  46787. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  46788. return ok
  46789. }
  46790. // ResetStatus resets all changes to the "status" field.
  46791. func (m *XunjiServiceMutation) ResetStatus() {
  46792. m.status = nil
  46793. m.addstatus = nil
  46794. delete(m.clearedFields, xunjiservice.FieldStatus)
  46795. }
  46796. // SetDeletedAt sets the "deleted_at" field.
  46797. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  46798. m.deleted_at = &t
  46799. }
  46800. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46801. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  46802. v := m.deleted_at
  46803. if v == nil {
  46804. return
  46805. }
  46806. return *v, true
  46807. }
  46808. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  46809. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46811. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46812. if !m.op.Is(OpUpdateOne) {
  46813. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46814. }
  46815. if m.id == nil || m.oldValue == nil {
  46816. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46817. }
  46818. oldValue, err := m.oldValue(ctx)
  46819. if err != nil {
  46820. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46821. }
  46822. return oldValue.DeletedAt, nil
  46823. }
  46824. // ClearDeletedAt clears the value of the "deleted_at" field.
  46825. func (m *XunjiServiceMutation) ClearDeletedAt() {
  46826. m.deleted_at = nil
  46827. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  46828. }
  46829. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46830. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  46831. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  46832. return ok
  46833. }
  46834. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46835. func (m *XunjiServiceMutation) ResetDeletedAt() {
  46836. m.deleted_at = nil
  46837. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  46838. }
  46839. // SetXunjiID sets the "xunji_id" field.
  46840. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  46841. m.xunji_id = &u
  46842. m.addxunji_id = nil
  46843. }
  46844. // XunjiID returns the value of the "xunji_id" field in the mutation.
  46845. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  46846. v := m.xunji_id
  46847. if v == nil {
  46848. return
  46849. }
  46850. return *v, true
  46851. }
  46852. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  46853. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46855. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  46856. if !m.op.Is(OpUpdateOne) {
  46857. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  46858. }
  46859. if m.id == nil || m.oldValue == nil {
  46860. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  46861. }
  46862. oldValue, err := m.oldValue(ctx)
  46863. if err != nil {
  46864. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  46865. }
  46866. return oldValue.XunjiID, nil
  46867. }
  46868. // AddXunjiID adds u to the "xunji_id" field.
  46869. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  46870. if m.addxunji_id != nil {
  46871. *m.addxunji_id += u
  46872. } else {
  46873. m.addxunji_id = &u
  46874. }
  46875. }
  46876. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  46877. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  46878. v := m.addxunji_id
  46879. if v == nil {
  46880. return
  46881. }
  46882. return *v, true
  46883. }
  46884. // ResetXunjiID resets all changes to the "xunji_id" field.
  46885. func (m *XunjiServiceMutation) ResetXunjiID() {
  46886. m.xunji_id = nil
  46887. m.addxunji_id = nil
  46888. }
  46889. // SetAgentID sets the "agent_id" field.
  46890. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  46891. m.agent = &u
  46892. }
  46893. // AgentID returns the value of the "agent_id" field in the mutation.
  46894. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  46895. v := m.agent
  46896. if v == nil {
  46897. return
  46898. }
  46899. return *v, true
  46900. }
  46901. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  46902. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46904. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  46905. if !m.op.Is(OpUpdateOne) {
  46906. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  46907. }
  46908. if m.id == nil || m.oldValue == nil {
  46909. return v, errors.New("OldAgentID requires an ID field in the mutation")
  46910. }
  46911. oldValue, err := m.oldValue(ctx)
  46912. if err != nil {
  46913. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  46914. }
  46915. return oldValue.AgentID, nil
  46916. }
  46917. // ResetAgentID resets all changes to the "agent_id" field.
  46918. func (m *XunjiServiceMutation) ResetAgentID() {
  46919. m.agent = nil
  46920. }
  46921. // SetOrganizationID sets the "organization_id" field.
  46922. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  46923. m.organization_id = &u
  46924. m.addorganization_id = nil
  46925. }
  46926. // OrganizationID returns the value of the "organization_id" field in the mutation.
  46927. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  46928. v := m.organization_id
  46929. if v == nil {
  46930. return
  46931. }
  46932. return *v, true
  46933. }
  46934. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  46935. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46937. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  46938. if !m.op.Is(OpUpdateOne) {
  46939. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  46940. }
  46941. if m.id == nil || m.oldValue == nil {
  46942. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  46943. }
  46944. oldValue, err := m.oldValue(ctx)
  46945. if err != nil {
  46946. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  46947. }
  46948. return oldValue.OrganizationID, nil
  46949. }
  46950. // AddOrganizationID adds u to the "organization_id" field.
  46951. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  46952. if m.addorganization_id != nil {
  46953. *m.addorganization_id += u
  46954. } else {
  46955. m.addorganization_id = &u
  46956. }
  46957. }
  46958. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  46959. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  46960. v := m.addorganization_id
  46961. if v == nil {
  46962. return
  46963. }
  46964. return *v, true
  46965. }
  46966. // ResetOrganizationID resets all changes to the "organization_id" field.
  46967. func (m *XunjiServiceMutation) ResetOrganizationID() {
  46968. m.organization_id = nil
  46969. m.addorganization_id = nil
  46970. }
  46971. // SetWxid sets the "wxid" field.
  46972. func (m *XunjiServiceMutation) SetWxid(s string) {
  46973. m.wxid = &s
  46974. }
  46975. // Wxid returns the value of the "wxid" field in the mutation.
  46976. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  46977. v := m.wxid
  46978. if v == nil {
  46979. return
  46980. }
  46981. return *v, true
  46982. }
  46983. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  46984. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46986. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  46987. if !m.op.Is(OpUpdateOne) {
  46988. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46989. }
  46990. if m.id == nil || m.oldValue == nil {
  46991. return v, errors.New("OldWxid requires an ID field in the mutation")
  46992. }
  46993. oldValue, err := m.oldValue(ctx)
  46994. if err != nil {
  46995. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46996. }
  46997. return oldValue.Wxid, nil
  46998. }
  46999. // ResetWxid resets all changes to the "wxid" field.
  47000. func (m *XunjiServiceMutation) ResetWxid() {
  47001. m.wxid = nil
  47002. }
  47003. // SetAPIBase sets the "api_base" field.
  47004. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  47005. m.api_base = &s
  47006. }
  47007. // APIBase returns the value of the "api_base" field in the mutation.
  47008. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  47009. v := m.api_base
  47010. if v == nil {
  47011. return
  47012. }
  47013. return *v, true
  47014. }
  47015. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  47016. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47018. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47019. if !m.op.Is(OpUpdateOne) {
  47020. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47021. }
  47022. if m.id == nil || m.oldValue == nil {
  47023. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  47024. }
  47025. oldValue, err := m.oldValue(ctx)
  47026. if err != nil {
  47027. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  47028. }
  47029. return oldValue.APIBase, nil
  47030. }
  47031. // ClearAPIBase clears the value of the "api_base" field.
  47032. func (m *XunjiServiceMutation) ClearAPIBase() {
  47033. m.api_base = nil
  47034. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  47035. }
  47036. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  47037. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  47038. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  47039. return ok
  47040. }
  47041. // ResetAPIBase resets all changes to the "api_base" field.
  47042. func (m *XunjiServiceMutation) ResetAPIBase() {
  47043. m.api_base = nil
  47044. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  47045. }
  47046. // SetAPIKey sets the "api_key" field.
  47047. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  47048. m.api_key = &s
  47049. }
  47050. // APIKey returns the value of the "api_key" field in the mutation.
  47051. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  47052. v := m.api_key
  47053. if v == nil {
  47054. return
  47055. }
  47056. return *v, true
  47057. }
  47058. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  47059. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47061. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  47062. if !m.op.Is(OpUpdateOne) {
  47063. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  47064. }
  47065. if m.id == nil || m.oldValue == nil {
  47066. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  47067. }
  47068. oldValue, err := m.oldValue(ctx)
  47069. if err != nil {
  47070. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  47071. }
  47072. return oldValue.APIKey, nil
  47073. }
  47074. // ClearAPIKey clears the value of the "api_key" field.
  47075. func (m *XunjiServiceMutation) ClearAPIKey() {
  47076. m.api_key = nil
  47077. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  47078. }
  47079. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  47080. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  47081. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  47082. return ok
  47083. }
  47084. // ResetAPIKey resets all changes to the "api_key" field.
  47085. func (m *XunjiServiceMutation) ResetAPIKey() {
  47086. m.api_key = nil
  47087. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  47088. }
  47089. // ClearAgent clears the "agent" edge to the Agent entity.
  47090. func (m *XunjiServiceMutation) ClearAgent() {
  47091. m.clearedagent = true
  47092. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  47093. }
  47094. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  47095. func (m *XunjiServiceMutation) AgentCleared() bool {
  47096. return m.clearedagent
  47097. }
  47098. // AgentIDs returns the "agent" edge IDs in the mutation.
  47099. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47100. // AgentID instead. It exists only for internal usage by the builders.
  47101. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  47102. if id := m.agent; id != nil {
  47103. ids = append(ids, *id)
  47104. }
  47105. return
  47106. }
  47107. // ResetAgent resets all changes to the "agent" edge.
  47108. func (m *XunjiServiceMutation) ResetAgent() {
  47109. m.agent = nil
  47110. m.clearedagent = false
  47111. }
  47112. // Where appends a list predicates to the XunjiServiceMutation builder.
  47113. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  47114. m.predicates = append(m.predicates, ps...)
  47115. }
  47116. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  47117. // users can use type-assertion to append predicates that do not depend on any generated package.
  47118. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  47119. p := make([]predicate.XunjiService, len(ps))
  47120. for i := range ps {
  47121. p[i] = ps[i]
  47122. }
  47123. m.Where(p...)
  47124. }
  47125. // Op returns the operation name.
  47126. func (m *XunjiServiceMutation) Op() Op {
  47127. return m.op
  47128. }
  47129. // SetOp allows setting the mutation operation.
  47130. func (m *XunjiServiceMutation) SetOp(op Op) {
  47131. m.op = op
  47132. }
  47133. // Type returns the node type of this mutation (XunjiService).
  47134. func (m *XunjiServiceMutation) Type() string {
  47135. return m.typ
  47136. }
  47137. // Fields returns all fields that were changed during this mutation. Note that in
  47138. // order to get all numeric fields that were incremented/decremented, call
  47139. // AddedFields().
  47140. func (m *XunjiServiceMutation) Fields() []string {
  47141. fields := make([]string, 0, 10)
  47142. if m.created_at != nil {
  47143. fields = append(fields, xunjiservice.FieldCreatedAt)
  47144. }
  47145. if m.updated_at != nil {
  47146. fields = append(fields, xunjiservice.FieldUpdatedAt)
  47147. }
  47148. if m.status != nil {
  47149. fields = append(fields, xunjiservice.FieldStatus)
  47150. }
  47151. if m.deleted_at != nil {
  47152. fields = append(fields, xunjiservice.FieldDeletedAt)
  47153. }
  47154. if m.xunji_id != nil {
  47155. fields = append(fields, xunjiservice.FieldXunjiID)
  47156. }
  47157. if m.agent != nil {
  47158. fields = append(fields, xunjiservice.FieldAgentID)
  47159. }
  47160. if m.organization_id != nil {
  47161. fields = append(fields, xunjiservice.FieldOrganizationID)
  47162. }
  47163. if m.wxid != nil {
  47164. fields = append(fields, xunjiservice.FieldWxid)
  47165. }
  47166. if m.api_base != nil {
  47167. fields = append(fields, xunjiservice.FieldAPIBase)
  47168. }
  47169. if m.api_key != nil {
  47170. fields = append(fields, xunjiservice.FieldAPIKey)
  47171. }
  47172. return fields
  47173. }
  47174. // Field returns the value of a field with the given name. The second boolean
  47175. // return value indicates that this field was not set, or was not defined in the
  47176. // schema.
  47177. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  47178. switch name {
  47179. case xunjiservice.FieldCreatedAt:
  47180. return m.CreatedAt()
  47181. case xunjiservice.FieldUpdatedAt:
  47182. return m.UpdatedAt()
  47183. case xunjiservice.FieldStatus:
  47184. return m.Status()
  47185. case xunjiservice.FieldDeletedAt:
  47186. return m.DeletedAt()
  47187. case xunjiservice.FieldXunjiID:
  47188. return m.XunjiID()
  47189. case xunjiservice.FieldAgentID:
  47190. return m.AgentID()
  47191. case xunjiservice.FieldOrganizationID:
  47192. return m.OrganizationID()
  47193. case xunjiservice.FieldWxid:
  47194. return m.Wxid()
  47195. case xunjiservice.FieldAPIBase:
  47196. return m.APIBase()
  47197. case xunjiservice.FieldAPIKey:
  47198. return m.APIKey()
  47199. }
  47200. return nil, false
  47201. }
  47202. // OldField returns the old value of the field from the database. An error is
  47203. // returned if the mutation operation is not UpdateOne, or the query to the
  47204. // database failed.
  47205. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47206. switch name {
  47207. case xunjiservice.FieldCreatedAt:
  47208. return m.OldCreatedAt(ctx)
  47209. case xunjiservice.FieldUpdatedAt:
  47210. return m.OldUpdatedAt(ctx)
  47211. case xunjiservice.FieldStatus:
  47212. return m.OldStatus(ctx)
  47213. case xunjiservice.FieldDeletedAt:
  47214. return m.OldDeletedAt(ctx)
  47215. case xunjiservice.FieldXunjiID:
  47216. return m.OldXunjiID(ctx)
  47217. case xunjiservice.FieldAgentID:
  47218. return m.OldAgentID(ctx)
  47219. case xunjiservice.FieldOrganizationID:
  47220. return m.OldOrganizationID(ctx)
  47221. case xunjiservice.FieldWxid:
  47222. return m.OldWxid(ctx)
  47223. case xunjiservice.FieldAPIBase:
  47224. return m.OldAPIBase(ctx)
  47225. case xunjiservice.FieldAPIKey:
  47226. return m.OldAPIKey(ctx)
  47227. }
  47228. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  47229. }
  47230. // SetField sets the value of a field with the given name. It returns an error if
  47231. // the field is not defined in the schema, or if the type mismatched the field
  47232. // type.
  47233. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  47234. switch name {
  47235. case xunjiservice.FieldCreatedAt:
  47236. v, ok := value.(time.Time)
  47237. if !ok {
  47238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47239. }
  47240. m.SetCreatedAt(v)
  47241. return nil
  47242. case xunjiservice.FieldUpdatedAt:
  47243. v, ok := value.(time.Time)
  47244. if !ok {
  47245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47246. }
  47247. m.SetUpdatedAt(v)
  47248. return nil
  47249. case xunjiservice.FieldStatus:
  47250. v, ok := value.(uint8)
  47251. if !ok {
  47252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47253. }
  47254. m.SetStatus(v)
  47255. return nil
  47256. case xunjiservice.FieldDeletedAt:
  47257. v, ok := value.(time.Time)
  47258. if !ok {
  47259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47260. }
  47261. m.SetDeletedAt(v)
  47262. return nil
  47263. case xunjiservice.FieldXunjiID:
  47264. v, ok := value.(uint64)
  47265. if !ok {
  47266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47267. }
  47268. m.SetXunjiID(v)
  47269. return nil
  47270. case xunjiservice.FieldAgentID:
  47271. v, ok := value.(uint64)
  47272. if !ok {
  47273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47274. }
  47275. m.SetAgentID(v)
  47276. return nil
  47277. case xunjiservice.FieldOrganizationID:
  47278. v, ok := value.(uint64)
  47279. if !ok {
  47280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47281. }
  47282. m.SetOrganizationID(v)
  47283. return nil
  47284. case xunjiservice.FieldWxid:
  47285. v, ok := value.(string)
  47286. if !ok {
  47287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47288. }
  47289. m.SetWxid(v)
  47290. return nil
  47291. case xunjiservice.FieldAPIBase:
  47292. v, ok := value.(string)
  47293. if !ok {
  47294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47295. }
  47296. m.SetAPIBase(v)
  47297. return nil
  47298. case xunjiservice.FieldAPIKey:
  47299. v, ok := value.(string)
  47300. if !ok {
  47301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47302. }
  47303. m.SetAPIKey(v)
  47304. return nil
  47305. }
  47306. return fmt.Errorf("unknown XunjiService field %s", name)
  47307. }
  47308. // AddedFields returns all numeric fields that were incremented/decremented during
  47309. // this mutation.
  47310. func (m *XunjiServiceMutation) AddedFields() []string {
  47311. var fields []string
  47312. if m.addstatus != nil {
  47313. fields = append(fields, xunjiservice.FieldStatus)
  47314. }
  47315. if m.addxunji_id != nil {
  47316. fields = append(fields, xunjiservice.FieldXunjiID)
  47317. }
  47318. if m.addorganization_id != nil {
  47319. fields = append(fields, xunjiservice.FieldOrganizationID)
  47320. }
  47321. return fields
  47322. }
  47323. // AddedField returns the numeric value that was incremented/decremented on a field
  47324. // with the given name. The second boolean return value indicates that this field
  47325. // was not set, or was not defined in the schema.
  47326. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  47327. switch name {
  47328. case xunjiservice.FieldStatus:
  47329. return m.AddedStatus()
  47330. case xunjiservice.FieldXunjiID:
  47331. return m.AddedXunjiID()
  47332. case xunjiservice.FieldOrganizationID:
  47333. return m.AddedOrganizationID()
  47334. }
  47335. return nil, false
  47336. }
  47337. // AddField adds the value to the field with the given name. It returns an error if
  47338. // the field is not defined in the schema, or if the type mismatched the field
  47339. // type.
  47340. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  47341. switch name {
  47342. case xunjiservice.FieldStatus:
  47343. v, ok := value.(int8)
  47344. if !ok {
  47345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47346. }
  47347. m.AddStatus(v)
  47348. return nil
  47349. case xunjiservice.FieldXunjiID:
  47350. v, ok := value.(int64)
  47351. if !ok {
  47352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47353. }
  47354. m.AddXunjiID(v)
  47355. return nil
  47356. case xunjiservice.FieldOrganizationID:
  47357. v, ok := value.(int64)
  47358. if !ok {
  47359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47360. }
  47361. m.AddOrganizationID(v)
  47362. return nil
  47363. }
  47364. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  47365. }
  47366. // ClearedFields returns all nullable fields that were cleared during this
  47367. // mutation.
  47368. func (m *XunjiServiceMutation) ClearedFields() []string {
  47369. var fields []string
  47370. if m.FieldCleared(xunjiservice.FieldStatus) {
  47371. fields = append(fields, xunjiservice.FieldStatus)
  47372. }
  47373. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  47374. fields = append(fields, xunjiservice.FieldDeletedAt)
  47375. }
  47376. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  47377. fields = append(fields, xunjiservice.FieldAPIBase)
  47378. }
  47379. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  47380. fields = append(fields, xunjiservice.FieldAPIKey)
  47381. }
  47382. return fields
  47383. }
  47384. // FieldCleared returns a boolean indicating if a field with the given name was
  47385. // cleared in this mutation.
  47386. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  47387. _, ok := m.clearedFields[name]
  47388. return ok
  47389. }
  47390. // ClearField clears the value of the field with the given name. It returns an
  47391. // error if the field is not defined in the schema.
  47392. func (m *XunjiServiceMutation) ClearField(name string) error {
  47393. switch name {
  47394. case xunjiservice.FieldStatus:
  47395. m.ClearStatus()
  47396. return nil
  47397. case xunjiservice.FieldDeletedAt:
  47398. m.ClearDeletedAt()
  47399. return nil
  47400. case xunjiservice.FieldAPIBase:
  47401. m.ClearAPIBase()
  47402. return nil
  47403. case xunjiservice.FieldAPIKey:
  47404. m.ClearAPIKey()
  47405. return nil
  47406. }
  47407. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  47408. }
  47409. // ResetField resets all changes in the mutation for the field with the given name.
  47410. // It returns an error if the field is not defined in the schema.
  47411. func (m *XunjiServiceMutation) ResetField(name string) error {
  47412. switch name {
  47413. case xunjiservice.FieldCreatedAt:
  47414. m.ResetCreatedAt()
  47415. return nil
  47416. case xunjiservice.FieldUpdatedAt:
  47417. m.ResetUpdatedAt()
  47418. return nil
  47419. case xunjiservice.FieldStatus:
  47420. m.ResetStatus()
  47421. return nil
  47422. case xunjiservice.FieldDeletedAt:
  47423. m.ResetDeletedAt()
  47424. return nil
  47425. case xunjiservice.FieldXunjiID:
  47426. m.ResetXunjiID()
  47427. return nil
  47428. case xunjiservice.FieldAgentID:
  47429. m.ResetAgentID()
  47430. return nil
  47431. case xunjiservice.FieldOrganizationID:
  47432. m.ResetOrganizationID()
  47433. return nil
  47434. case xunjiservice.FieldWxid:
  47435. m.ResetWxid()
  47436. return nil
  47437. case xunjiservice.FieldAPIBase:
  47438. m.ResetAPIBase()
  47439. return nil
  47440. case xunjiservice.FieldAPIKey:
  47441. m.ResetAPIKey()
  47442. return nil
  47443. }
  47444. return fmt.Errorf("unknown XunjiService field %s", name)
  47445. }
  47446. // AddedEdges returns all edge names that were set/added in this mutation.
  47447. func (m *XunjiServiceMutation) AddedEdges() []string {
  47448. edges := make([]string, 0, 1)
  47449. if m.agent != nil {
  47450. edges = append(edges, xunjiservice.EdgeAgent)
  47451. }
  47452. return edges
  47453. }
  47454. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47455. // name in this mutation.
  47456. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  47457. switch name {
  47458. case xunjiservice.EdgeAgent:
  47459. if id := m.agent; id != nil {
  47460. return []ent.Value{*id}
  47461. }
  47462. }
  47463. return nil
  47464. }
  47465. // RemovedEdges returns all edge names that were removed in this mutation.
  47466. func (m *XunjiServiceMutation) RemovedEdges() []string {
  47467. edges := make([]string, 0, 1)
  47468. return edges
  47469. }
  47470. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47471. // the given name in this mutation.
  47472. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  47473. return nil
  47474. }
  47475. // ClearedEdges returns all edge names that were cleared in this mutation.
  47476. func (m *XunjiServiceMutation) ClearedEdges() []string {
  47477. edges := make([]string, 0, 1)
  47478. if m.clearedagent {
  47479. edges = append(edges, xunjiservice.EdgeAgent)
  47480. }
  47481. return edges
  47482. }
  47483. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47484. // was cleared in this mutation.
  47485. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  47486. switch name {
  47487. case xunjiservice.EdgeAgent:
  47488. return m.clearedagent
  47489. }
  47490. return false
  47491. }
  47492. // ClearEdge clears the value of the edge with the given name. It returns an error
  47493. // if that edge is not defined in the schema.
  47494. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  47495. switch name {
  47496. case xunjiservice.EdgeAgent:
  47497. m.ClearAgent()
  47498. return nil
  47499. }
  47500. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  47501. }
  47502. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47503. // It returns an error if the edge is not defined in the schema.
  47504. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  47505. switch name {
  47506. case xunjiservice.EdgeAgent:
  47507. m.ResetAgent()
  47508. return nil
  47509. }
  47510. return fmt.Errorf("unknown XunjiService edge %s", name)
  47511. }