mutation.go 1.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946
  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. "entgo.io/ent"
  53. "entgo.io/ent/dialect/sql"
  54. )
  55. const (
  56. // Operation types.
  57. OpCreate = ent.OpCreate
  58. OpDelete = ent.OpDelete
  59. OpDeleteOne = ent.OpDeleteOne
  60. OpUpdate = ent.OpUpdate
  61. OpUpdateOne = ent.OpUpdateOne
  62. // Node types.
  63. TypeAgent = "Agent"
  64. TypeAgentBase = "AgentBase"
  65. TypeAliyunAvatar = "AliyunAvatar"
  66. TypeAllocAgent = "AllocAgent"
  67. TypeApiKey = "ApiKey"
  68. TypeBatchMsg = "BatchMsg"
  69. TypeCategory = "Category"
  70. TypeChatRecords = "ChatRecords"
  71. TypeChatSession = "ChatSession"
  72. TypeContact = "Contact"
  73. TypeCreditBalance = "CreditBalance"
  74. TypeCreditUsage = "CreditUsage"
  75. TypeEmployee = "Employee"
  76. TypeEmployeeConfig = "EmployeeConfig"
  77. TypeLabel = "Label"
  78. TypeLabelRelationship = "LabelRelationship"
  79. TypeLabelTagging = "LabelTagging"
  80. TypeMessage = "Message"
  81. TypeMessageRecords = "MessageRecords"
  82. TypeMsg = "Msg"
  83. TypePayRecharge = "PayRecharge"
  84. TypeServer = "Server"
  85. TypeSopNode = "SopNode"
  86. TypeSopStage = "SopStage"
  87. TypeSopTask = "SopTask"
  88. TypeToken = "Token"
  89. TypeTutorial = "Tutorial"
  90. TypeUsageDetail = "UsageDetail"
  91. TypeUsageStatisticDay = "UsageStatisticDay"
  92. TypeUsageStatisticHour = "UsageStatisticHour"
  93. TypeUsageStatisticMonth = "UsageStatisticMonth"
  94. TypeUsageTotal = "UsageTotal"
  95. TypeWhatsapp = "Whatsapp"
  96. TypeWhatsappChannel = "WhatsappChannel"
  97. TypeWorkExperience = "WorkExperience"
  98. TypeWpChatroom = "WpChatroom"
  99. TypeWpChatroomMember = "WpChatroomMember"
  100. TypeWx = "Wx"
  101. TypeWxCard = "WxCard"
  102. TypeWxCardUser = "WxCardUser"
  103. TypeWxCardVisit = "WxCardVisit"
  104. )
  105. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  106. type AgentMutation struct {
  107. config
  108. op Op
  109. typ string
  110. id *uint64
  111. created_at *time.Time
  112. updated_at *time.Time
  113. deleted_at *time.Time
  114. name *string
  115. role *string
  116. status *int
  117. addstatus *int
  118. background *string
  119. examples *string
  120. organization_id *uint64
  121. addorganization_id *int64
  122. dataset_id *string
  123. collection_id *string
  124. clearedFields map[string]struct{}
  125. wx_agent map[uint64]struct{}
  126. removedwx_agent map[uint64]struct{}
  127. clearedwx_agent bool
  128. token_agent map[uint64]struct{}
  129. removedtoken_agent map[uint64]struct{}
  130. clearedtoken_agent bool
  131. wa_agent map[uint64]struct{}
  132. removedwa_agent map[uint64]struct{}
  133. clearedwa_agent bool
  134. key_agent map[uint64]struct{}
  135. removedkey_agent map[uint64]struct{}
  136. clearedkey_agent bool
  137. done bool
  138. oldValue func(context.Context) (*Agent, error)
  139. predicates []predicate.Agent
  140. }
  141. var _ ent.Mutation = (*AgentMutation)(nil)
  142. // agentOption allows management of the mutation configuration using functional options.
  143. type agentOption func(*AgentMutation)
  144. // newAgentMutation creates new mutation for the Agent entity.
  145. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  146. m := &AgentMutation{
  147. config: c,
  148. op: op,
  149. typ: TypeAgent,
  150. clearedFields: make(map[string]struct{}),
  151. }
  152. for _, opt := range opts {
  153. opt(m)
  154. }
  155. return m
  156. }
  157. // withAgentID sets the ID field of the mutation.
  158. func withAgentID(id uint64) agentOption {
  159. return func(m *AgentMutation) {
  160. var (
  161. err error
  162. once sync.Once
  163. value *Agent
  164. )
  165. m.oldValue = func(ctx context.Context) (*Agent, error) {
  166. once.Do(func() {
  167. if m.done {
  168. err = errors.New("querying old values post mutation is not allowed")
  169. } else {
  170. value, err = m.Client().Agent.Get(ctx, id)
  171. }
  172. })
  173. return value, err
  174. }
  175. m.id = &id
  176. }
  177. }
  178. // withAgent sets the old Agent of the mutation.
  179. func withAgent(node *Agent) agentOption {
  180. return func(m *AgentMutation) {
  181. m.oldValue = func(context.Context) (*Agent, error) {
  182. return node, nil
  183. }
  184. m.id = &node.ID
  185. }
  186. }
  187. // Client returns a new `ent.Client` from the mutation. If the mutation was
  188. // executed in a transaction (ent.Tx), a transactional client is returned.
  189. func (m AgentMutation) Client() *Client {
  190. client := &Client{config: m.config}
  191. client.init()
  192. return client
  193. }
  194. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  195. // it returns an error otherwise.
  196. func (m AgentMutation) Tx() (*Tx, error) {
  197. if _, ok := m.driver.(*txDriver); !ok {
  198. return nil, errors.New("ent: mutation is not running in a transaction")
  199. }
  200. tx := &Tx{config: m.config}
  201. tx.init()
  202. return tx, nil
  203. }
  204. // SetID sets the value of the id field. Note that this
  205. // operation is only accepted on creation of Agent entities.
  206. func (m *AgentMutation) SetID(id uint64) {
  207. m.id = &id
  208. }
  209. // ID returns the ID value in the mutation. Note that the ID is only available
  210. // if it was provided to the builder or after it was returned from the database.
  211. func (m *AgentMutation) ID() (id uint64, exists bool) {
  212. if m.id == nil {
  213. return
  214. }
  215. return *m.id, true
  216. }
  217. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  218. // That means, if the mutation is applied within a transaction with an isolation level such
  219. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  220. // or updated by the mutation.
  221. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  222. switch {
  223. case m.op.Is(OpUpdateOne | OpDeleteOne):
  224. id, exists := m.ID()
  225. if exists {
  226. return []uint64{id}, nil
  227. }
  228. fallthrough
  229. case m.op.Is(OpUpdate | OpDelete):
  230. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  231. default:
  232. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  233. }
  234. }
  235. // SetCreatedAt sets the "created_at" field.
  236. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  237. m.created_at = &t
  238. }
  239. // CreatedAt returns the value of the "created_at" field in the mutation.
  240. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  241. v := m.created_at
  242. if v == nil {
  243. return
  244. }
  245. return *v, true
  246. }
  247. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  248. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  250. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  251. if !m.op.Is(OpUpdateOne) {
  252. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  253. }
  254. if m.id == nil || m.oldValue == nil {
  255. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  256. }
  257. oldValue, err := m.oldValue(ctx)
  258. if err != nil {
  259. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  260. }
  261. return oldValue.CreatedAt, nil
  262. }
  263. // ResetCreatedAt resets all changes to the "created_at" field.
  264. func (m *AgentMutation) ResetCreatedAt() {
  265. m.created_at = nil
  266. }
  267. // SetUpdatedAt sets the "updated_at" field.
  268. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  269. m.updated_at = &t
  270. }
  271. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  272. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  273. v := m.updated_at
  274. if v == nil {
  275. return
  276. }
  277. return *v, true
  278. }
  279. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  280. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  282. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  283. if !m.op.Is(OpUpdateOne) {
  284. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  285. }
  286. if m.id == nil || m.oldValue == nil {
  287. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  288. }
  289. oldValue, err := m.oldValue(ctx)
  290. if err != nil {
  291. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  292. }
  293. return oldValue.UpdatedAt, nil
  294. }
  295. // ResetUpdatedAt resets all changes to the "updated_at" field.
  296. func (m *AgentMutation) ResetUpdatedAt() {
  297. m.updated_at = nil
  298. }
  299. // SetDeletedAt sets the "deleted_at" field.
  300. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  301. m.deleted_at = &t
  302. }
  303. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  304. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  305. v := m.deleted_at
  306. if v == nil {
  307. return
  308. }
  309. return *v, true
  310. }
  311. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  312. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  314. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  315. if !m.op.Is(OpUpdateOne) {
  316. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  317. }
  318. if m.id == nil || m.oldValue == nil {
  319. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  320. }
  321. oldValue, err := m.oldValue(ctx)
  322. if err != nil {
  323. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  324. }
  325. return oldValue.DeletedAt, nil
  326. }
  327. // ClearDeletedAt clears the value of the "deleted_at" field.
  328. func (m *AgentMutation) ClearDeletedAt() {
  329. m.deleted_at = nil
  330. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  331. }
  332. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  333. func (m *AgentMutation) DeletedAtCleared() bool {
  334. _, ok := m.clearedFields[agent.FieldDeletedAt]
  335. return ok
  336. }
  337. // ResetDeletedAt resets all changes to the "deleted_at" field.
  338. func (m *AgentMutation) ResetDeletedAt() {
  339. m.deleted_at = nil
  340. delete(m.clearedFields, agent.FieldDeletedAt)
  341. }
  342. // SetName sets the "name" field.
  343. func (m *AgentMutation) SetName(s string) {
  344. m.name = &s
  345. }
  346. // Name returns the value of the "name" field in the mutation.
  347. func (m *AgentMutation) Name() (r string, exists bool) {
  348. v := m.name
  349. if v == nil {
  350. return
  351. }
  352. return *v, true
  353. }
  354. // OldName returns the old "name" field's value of the Agent entity.
  355. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  357. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  358. if !m.op.Is(OpUpdateOne) {
  359. return v, errors.New("OldName is only allowed on UpdateOne operations")
  360. }
  361. if m.id == nil || m.oldValue == nil {
  362. return v, errors.New("OldName requires an ID field in the mutation")
  363. }
  364. oldValue, err := m.oldValue(ctx)
  365. if err != nil {
  366. return v, fmt.Errorf("querying old value for OldName: %w", err)
  367. }
  368. return oldValue.Name, nil
  369. }
  370. // ResetName resets all changes to the "name" field.
  371. func (m *AgentMutation) ResetName() {
  372. m.name = nil
  373. }
  374. // SetRole sets the "role" field.
  375. func (m *AgentMutation) SetRole(s string) {
  376. m.role = &s
  377. }
  378. // Role returns the value of the "role" field in the mutation.
  379. func (m *AgentMutation) Role() (r string, exists bool) {
  380. v := m.role
  381. if v == nil {
  382. return
  383. }
  384. return *v, true
  385. }
  386. // OldRole returns the old "role" field's value of the Agent entity.
  387. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  389. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  390. if !m.op.Is(OpUpdateOne) {
  391. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  392. }
  393. if m.id == nil || m.oldValue == nil {
  394. return v, errors.New("OldRole requires an ID field in the mutation")
  395. }
  396. oldValue, err := m.oldValue(ctx)
  397. if err != nil {
  398. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  399. }
  400. return oldValue.Role, nil
  401. }
  402. // ResetRole resets all changes to the "role" field.
  403. func (m *AgentMutation) ResetRole() {
  404. m.role = nil
  405. }
  406. // SetStatus sets the "status" field.
  407. func (m *AgentMutation) SetStatus(i int) {
  408. m.status = &i
  409. m.addstatus = nil
  410. }
  411. // Status returns the value of the "status" field in the mutation.
  412. func (m *AgentMutation) Status() (r int, exists bool) {
  413. v := m.status
  414. if v == nil {
  415. return
  416. }
  417. return *v, true
  418. }
  419. // OldStatus returns the old "status" field's value of the Agent entity.
  420. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  422. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  423. if !m.op.Is(OpUpdateOne) {
  424. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  425. }
  426. if m.id == nil || m.oldValue == nil {
  427. return v, errors.New("OldStatus requires an ID field in the mutation")
  428. }
  429. oldValue, err := m.oldValue(ctx)
  430. if err != nil {
  431. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  432. }
  433. return oldValue.Status, nil
  434. }
  435. // AddStatus adds i to the "status" field.
  436. func (m *AgentMutation) AddStatus(i int) {
  437. if m.addstatus != nil {
  438. *m.addstatus += i
  439. } else {
  440. m.addstatus = &i
  441. }
  442. }
  443. // AddedStatus returns the value that was added to the "status" field in this mutation.
  444. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  445. v := m.addstatus
  446. if v == nil {
  447. return
  448. }
  449. return *v, true
  450. }
  451. // ClearStatus clears the value of the "status" field.
  452. func (m *AgentMutation) ClearStatus() {
  453. m.status = nil
  454. m.addstatus = nil
  455. m.clearedFields[agent.FieldStatus] = struct{}{}
  456. }
  457. // StatusCleared returns if the "status" field was cleared in this mutation.
  458. func (m *AgentMutation) StatusCleared() bool {
  459. _, ok := m.clearedFields[agent.FieldStatus]
  460. return ok
  461. }
  462. // ResetStatus resets all changes to the "status" field.
  463. func (m *AgentMutation) ResetStatus() {
  464. m.status = nil
  465. m.addstatus = nil
  466. delete(m.clearedFields, agent.FieldStatus)
  467. }
  468. // SetBackground sets the "background" field.
  469. func (m *AgentMutation) SetBackground(s string) {
  470. m.background = &s
  471. }
  472. // Background returns the value of the "background" field in the mutation.
  473. func (m *AgentMutation) Background() (r string, exists bool) {
  474. v := m.background
  475. if v == nil {
  476. return
  477. }
  478. return *v, true
  479. }
  480. // OldBackground returns the old "background" field's value of the Agent entity.
  481. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  483. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  484. if !m.op.Is(OpUpdateOne) {
  485. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  486. }
  487. if m.id == nil || m.oldValue == nil {
  488. return v, errors.New("OldBackground requires an ID field in the mutation")
  489. }
  490. oldValue, err := m.oldValue(ctx)
  491. if err != nil {
  492. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  493. }
  494. return oldValue.Background, nil
  495. }
  496. // ClearBackground clears the value of the "background" field.
  497. func (m *AgentMutation) ClearBackground() {
  498. m.background = nil
  499. m.clearedFields[agent.FieldBackground] = struct{}{}
  500. }
  501. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  502. func (m *AgentMutation) BackgroundCleared() bool {
  503. _, ok := m.clearedFields[agent.FieldBackground]
  504. return ok
  505. }
  506. // ResetBackground resets all changes to the "background" field.
  507. func (m *AgentMutation) ResetBackground() {
  508. m.background = nil
  509. delete(m.clearedFields, agent.FieldBackground)
  510. }
  511. // SetExamples sets the "examples" field.
  512. func (m *AgentMutation) SetExamples(s string) {
  513. m.examples = &s
  514. }
  515. // Examples returns the value of the "examples" field in the mutation.
  516. func (m *AgentMutation) Examples() (r string, exists bool) {
  517. v := m.examples
  518. if v == nil {
  519. return
  520. }
  521. return *v, true
  522. }
  523. // OldExamples returns the old "examples" field's value of the Agent entity.
  524. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  526. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  527. if !m.op.Is(OpUpdateOne) {
  528. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  529. }
  530. if m.id == nil || m.oldValue == nil {
  531. return v, errors.New("OldExamples requires an ID field in the mutation")
  532. }
  533. oldValue, err := m.oldValue(ctx)
  534. if err != nil {
  535. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  536. }
  537. return oldValue.Examples, nil
  538. }
  539. // ClearExamples clears the value of the "examples" field.
  540. func (m *AgentMutation) ClearExamples() {
  541. m.examples = nil
  542. m.clearedFields[agent.FieldExamples] = struct{}{}
  543. }
  544. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  545. func (m *AgentMutation) ExamplesCleared() bool {
  546. _, ok := m.clearedFields[agent.FieldExamples]
  547. return ok
  548. }
  549. // ResetExamples resets all changes to the "examples" field.
  550. func (m *AgentMutation) ResetExamples() {
  551. m.examples = nil
  552. delete(m.clearedFields, agent.FieldExamples)
  553. }
  554. // SetOrganizationID sets the "organization_id" field.
  555. func (m *AgentMutation) SetOrganizationID(u uint64) {
  556. m.organization_id = &u
  557. m.addorganization_id = nil
  558. }
  559. // OrganizationID returns the value of the "organization_id" field in the mutation.
  560. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  561. v := m.organization_id
  562. if v == nil {
  563. return
  564. }
  565. return *v, true
  566. }
  567. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  568. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  570. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  571. if !m.op.Is(OpUpdateOne) {
  572. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  573. }
  574. if m.id == nil || m.oldValue == nil {
  575. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  576. }
  577. oldValue, err := m.oldValue(ctx)
  578. if err != nil {
  579. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  580. }
  581. return oldValue.OrganizationID, nil
  582. }
  583. // AddOrganizationID adds u to the "organization_id" field.
  584. func (m *AgentMutation) AddOrganizationID(u int64) {
  585. if m.addorganization_id != nil {
  586. *m.addorganization_id += u
  587. } else {
  588. m.addorganization_id = &u
  589. }
  590. }
  591. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  592. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  593. v := m.addorganization_id
  594. if v == nil {
  595. return
  596. }
  597. return *v, true
  598. }
  599. // ResetOrganizationID resets all changes to the "organization_id" field.
  600. func (m *AgentMutation) ResetOrganizationID() {
  601. m.organization_id = nil
  602. m.addorganization_id = nil
  603. }
  604. // SetDatasetID sets the "dataset_id" field.
  605. func (m *AgentMutation) SetDatasetID(s string) {
  606. m.dataset_id = &s
  607. }
  608. // DatasetID returns the value of the "dataset_id" field in the mutation.
  609. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  610. v := m.dataset_id
  611. if v == nil {
  612. return
  613. }
  614. return *v, true
  615. }
  616. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  617. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  619. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  620. if !m.op.Is(OpUpdateOne) {
  621. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  622. }
  623. if m.id == nil || m.oldValue == nil {
  624. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  625. }
  626. oldValue, err := m.oldValue(ctx)
  627. if err != nil {
  628. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  629. }
  630. return oldValue.DatasetID, nil
  631. }
  632. // ResetDatasetID resets all changes to the "dataset_id" field.
  633. func (m *AgentMutation) ResetDatasetID() {
  634. m.dataset_id = nil
  635. }
  636. // SetCollectionID sets the "collection_id" field.
  637. func (m *AgentMutation) SetCollectionID(s string) {
  638. m.collection_id = &s
  639. }
  640. // CollectionID returns the value of the "collection_id" field in the mutation.
  641. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  642. v := m.collection_id
  643. if v == nil {
  644. return
  645. }
  646. return *v, true
  647. }
  648. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  649. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  651. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  652. if !m.op.Is(OpUpdateOne) {
  653. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  654. }
  655. if m.id == nil || m.oldValue == nil {
  656. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  657. }
  658. oldValue, err := m.oldValue(ctx)
  659. if err != nil {
  660. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  661. }
  662. return oldValue.CollectionID, nil
  663. }
  664. // ResetCollectionID resets all changes to the "collection_id" field.
  665. func (m *AgentMutation) ResetCollectionID() {
  666. m.collection_id = nil
  667. }
  668. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  669. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  670. if m.wx_agent == nil {
  671. m.wx_agent = make(map[uint64]struct{})
  672. }
  673. for i := range ids {
  674. m.wx_agent[ids[i]] = struct{}{}
  675. }
  676. }
  677. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  678. func (m *AgentMutation) ClearWxAgent() {
  679. m.clearedwx_agent = true
  680. }
  681. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  682. func (m *AgentMutation) WxAgentCleared() bool {
  683. return m.clearedwx_agent
  684. }
  685. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  686. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  687. if m.removedwx_agent == nil {
  688. m.removedwx_agent = make(map[uint64]struct{})
  689. }
  690. for i := range ids {
  691. delete(m.wx_agent, ids[i])
  692. m.removedwx_agent[ids[i]] = struct{}{}
  693. }
  694. }
  695. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  696. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  697. for id := range m.removedwx_agent {
  698. ids = append(ids, id)
  699. }
  700. return
  701. }
  702. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  703. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  704. for id := range m.wx_agent {
  705. ids = append(ids, id)
  706. }
  707. return
  708. }
  709. // ResetWxAgent resets all changes to the "wx_agent" edge.
  710. func (m *AgentMutation) ResetWxAgent() {
  711. m.wx_agent = nil
  712. m.clearedwx_agent = false
  713. m.removedwx_agent = nil
  714. }
  715. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  716. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  717. if m.token_agent == nil {
  718. m.token_agent = make(map[uint64]struct{})
  719. }
  720. for i := range ids {
  721. m.token_agent[ids[i]] = struct{}{}
  722. }
  723. }
  724. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  725. func (m *AgentMutation) ClearTokenAgent() {
  726. m.clearedtoken_agent = true
  727. }
  728. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  729. func (m *AgentMutation) TokenAgentCleared() bool {
  730. return m.clearedtoken_agent
  731. }
  732. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  733. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  734. if m.removedtoken_agent == nil {
  735. m.removedtoken_agent = make(map[uint64]struct{})
  736. }
  737. for i := range ids {
  738. delete(m.token_agent, ids[i])
  739. m.removedtoken_agent[ids[i]] = struct{}{}
  740. }
  741. }
  742. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  743. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  744. for id := range m.removedtoken_agent {
  745. ids = append(ids, id)
  746. }
  747. return
  748. }
  749. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  750. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  751. for id := range m.token_agent {
  752. ids = append(ids, id)
  753. }
  754. return
  755. }
  756. // ResetTokenAgent resets all changes to the "token_agent" edge.
  757. func (m *AgentMutation) ResetTokenAgent() {
  758. m.token_agent = nil
  759. m.clearedtoken_agent = false
  760. m.removedtoken_agent = nil
  761. }
  762. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  763. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  764. if m.wa_agent == nil {
  765. m.wa_agent = make(map[uint64]struct{})
  766. }
  767. for i := range ids {
  768. m.wa_agent[ids[i]] = struct{}{}
  769. }
  770. }
  771. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  772. func (m *AgentMutation) ClearWaAgent() {
  773. m.clearedwa_agent = true
  774. }
  775. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  776. func (m *AgentMutation) WaAgentCleared() bool {
  777. return m.clearedwa_agent
  778. }
  779. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  780. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  781. if m.removedwa_agent == nil {
  782. m.removedwa_agent = make(map[uint64]struct{})
  783. }
  784. for i := range ids {
  785. delete(m.wa_agent, ids[i])
  786. m.removedwa_agent[ids[i]] = struct{}{}
  787. }
  788. }
  789. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  790. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  791. for id := range m.removedwa_agent {
  792. ids = append(ids, id)
  793. }
  794. return
  795. }
  796. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  797. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  798. for id := range m.wa_agent {
  799. ids = append(ids, id)
  800. }
  801. return
  802. }
  803. // ResetWaAgent resets all changes to the "wa_agent" edge.
  804. func (m *AgentMutation) ResetWaAgent() {
  805. m.wa_agent = nil
  806. m.clearedwa_agent = false
  807. m.removedwa_agent = nil
  808. }
  809. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  810. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  811. if m.key_agent == nil {
  812. m.key_agent = make(map[uint64]struct{})
  813. }
  814. for i := range ids {
  815. m.key_agent[ids[i]] = struct{}{}
  816. }
  817. }
  818. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  819. func (m *AgentMutation) ClearKeyAgent() {
  820. m.clearedkey_agent = true
  821. }
  822. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  823. func (m *AgentMutation) KeyAgentCleared() bool {
  824. return m.clearedkey_agent
  825. }
  826. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  827. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  828. if m.removedkey_agent == nil {
  829. m.removedkey_agent = make(map[uint64]struct{})
  830. }
  831. for i := range ids {
  832. delete(m.key_agent, ids[i])
  833. m.removedkey_agent[ids[i]] = struct{}{}
  834. }
  835. }
  836. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  837. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  838. for id := range m.removedkey_agent {
  839. ids = append(ids, id)
  840. }
  841. return
  842. }
  843. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  844. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  845. for id := range m.key_agent {
  846. ids = append(ids, id)
  847. }
  848. return
  849. }
  850. // ResetKeyAgent resets all changes to the "key_agent" edge.
  851. func (m *AgentMutation) ResetKeyAgent() {
  852. m.key_agent = nil
  853. m.clearedkey_agent = false
  854. m.removedkey_agent = nil
  855. }
  856. // Where appends a list predicates to the AgentMutation builder.
  857. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  858. m.predicates = append(m.predicates, ps...)
  859. }
  860. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  861. // users can use type-assertion to append predicates that do not depend on any generated package.
  862. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  863. p := make([]predicate.Agent, len(ps))
  864. for i := range ps {
  865. p[i] = ps[i]
  866. }
  867. m.Where(p...)
  868. }
  869. // Op returns the operation name.
  870. func (m *AgentMutation) Op() Op {
  871. return m.op
  872. }
  873. // SetOp allows setting the mutation operation.
  874. func (m *AgentMutation) SetOp(op Op) {
  875. m.op = op
  876. }
  877. // Type returns the node type of this mutation (Agent).
  878. func (m *AgentMutation) Type() string {
  879. return m.typ
  880. }
  881. // Fields returns all fields that were changed during this mutation. Note that in
  882. // order to get all numeric fields that were incremented/decremented, call
  883. // AddedFields().
  884. func (m *AgentMutation) Fields() []string {
  885. fields := make([]string, 0, 11)
  886. if m.created_at != nil {
  887. fields = append(fields, agent.FieldCreatedAt)
  888. }
  889. if m.updated_at != nil {
  890. fields = append(fields, agent.FieldUpdatedAt)
  891. }
  892. if m.deleted_at != nil {
  893. fields = append(fields, agent.FieldDeletedAt)
  894. }
  895. if m.name != nil {
  896. fields = append(fields, agent.FieldName)
  897. }
  898. if m.role != nil {
  899. fields = append(fields, agent.FieldRole)
  900. }
  901. if m.status != nil {
  902. fields = append(fields, agent.FieldStatus)
  903. }
  904. if m.background != nil {
  905. fields = append(fields, agent.FieldBackground)
  906. }
  907. if m.examples != nil {
  908. fields = append(fields, agent.FieldExamples)
  909. }
  910. if m.organization_id != nil {
  911. fields = append(fields, agent.FieldOrganizationID)
  912. }
  913. if m.dataset_id != nil {
  914. fields = append(fields, agent.FieldDatasetID)
  915. }
  916. if m.collection_id != nil {
  917. fields = append(fields, agent.FieldCollectionID)
  918. }
  919. return fields
  920. }
  921. // Field returns the value of a field with the given name. The second boolean
  922. // return value indicates that this field was not set, or was not defined in the
  923. // schema.
  924. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  925. switch name {
  926. case agent.FieldCreatedAt:
  927. return m.CreatedAt()
  928. case agent.FieldUpdatedAt:
  929. return m.UpdatedAt()
  930. case agent.FieldDeletedAt:
  931. return m.DeletedAt()
  932. case agent.FieldName:
  933. return m.Name()
  934. case agent.FieldRole:
  935. return m.Role()
  936. case agent.FieldStatus:
  937. return m.Status()
  938. case agent.FieldBackground:
  939. return m.Background()
  940. case agent.FieldExamples:
  941. return m.Examples()
  942. case agent.FieldOrganizationID:
  943. return m.OrganizationID()
  944. case agent.FieldDatasetID:
  945. return m.DatasetID()
  946. case agent.FieldCollectionID:
  947. return m.CollectionID()
  948. }
  949. return nil, false
  950. }
  951. // OldField returns the old value of the field from the database. An error is
  952. // returned if the mutation operation is not UpdateOne, or the query to the
  953. // database failed.
  954. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  955. switch name {
  956. case agent.FieldCreatedAt:
  957. return m.OldCreatedAt(ctx)
  958. case agent.FieldUpdatedAt:
  959. return m.OldUpdatedAt(ctx)
  960. case agent.FieldDeletedAt:
  961. return m.OldDeletedAt(ctx)
  962. case agent.FieldName:
  963. return m.OldName(ctx)
  964. case agent.FieldRole:
  965. return m.OldRole(ctx)
  966. case agent.FieldStatus:
  967. return m.OldStatus(ctx)
  968. case agent.FieldBackground:
  969. return m.OldBackground(ctx)
  970. case agent.FieldExamples:
  971. return m.OldExamples(ctx)
  972. case agent.FieldOrganizationID:
  973. return m.OldOrganizationID(ctx)
  974. case agent.FieldDatasetID:
  975. return m.OldDatasetID(ctx)
  976. case agent.FieldCollectionID:
  977. return m.OldCollectionID(ctx)
  978. }
  979. return nil, fmt.Errorf("unknown Agent field %s", name)
  980. }
  981. // SetField sets the value of a field with the given name. It returns an error if
  982. // the field is not defined in the schema, or if the type mismatched the field
  983. // type.
  984. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  985. switch name {
  986. case agent.FieldCreatedAt:
  987. v, ok := value.(time.Time)
  988. if !ok {
  989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  990. }
  991. m.SetCreatedAt(v)
  992. return nil
  993. case agent.FieldUpdatedAt:
  994. v, ok := value.(time.Time)
  995. if !ok {
  996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  997. }
  998. m.SetUpdatedAt(v)
  999. return nil
  1000. case agent.FieldDeletedAt:
  1001. v, ok := value.(time.Time)
  1002. if !ok {
  1003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1004. }
  1005. m.SetDeletedAt(v)
  1006. return nil
  1007. case agent.FieldName:
  1008. v, ok := value.(string)
  1009. if !ok {
  1010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1011. }
  1012. m.SetName(v)
  1013. return nil
  1014. case agent.FieldRole:
  1015. v, ok := value.(string)
  1016. if !ok {
  1017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1018. }
  1019. m.SetRole(v)
  1020. return nil
  1021. case agent.FieldStatus:
  1022. v, ok := value.(int)
  1023. if !ok {
  1024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1025. }
  1026. m.SetStatus(v)
  1027. return nil
  1028. case agent.FieldBackground:
  1029. v, ok := value.(string)
  1030. if !ok {
  1031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1032. }
  1033. m.SetBackground(v)
  1034. return nil
  1035. case agent.FieldExamples:
  1036. v, ok := value.(string)
  1037. if !ok {
  1038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1039. }
  1040. m.SetExamples(v)
  1041. return nil
  1042. case agent.FieldOrganizationID:
  1043. v, ok := value.(uint64)
  1044. if !ok {
  1045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1046. }
  1047. m.SetOrganizationID(v)
  1048. return nil
  1049. case agent.FieldDatasetID:
  1050. v, ok := value.(string)
  1051. if !ok {
  1052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1053. }
  1054. m.SetDatasetID(v)
  1055. return nil
  1056. case agent.FieldCollectionID:
  1057. v, ok := value.(string)
  1058. if !ok {
  1059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1060. }
  1061. m.SetCollectionID(v)
  1062. return nil
  1063. }
  1064. return fmt.Errorf("unknown Agent field %s", name)
  1065. }
  1066. // AddedFields returns all numeric fields that were incremented/decremented during
  1067. // this mutation.
  1068. func (m *AgentMutation) AddedFields() []string {
  1069. var fields []string
  1070. if m.addstatus != nil {
  1071. fields = append(fields, agent.FieldStatus)
  1072. }
  1073. if m.addorganization_id != nil {
  1074. fields = append(fields, agent.FieldOrganizationID)
  1075. }
  1076. return fields
  1077. }
  1078. // AddedField returns the numeric value that was incremented/decremented on a field
  1079. // with the given name. The second boolean return value indicates that this field
  1080. // was not set, or was not defined in the schema.
  1081. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1082. switch name {
  1083. case agent.FieldStatus:
  1084. return m.AddedStatus()
  1085. case agent.FieldOrganizationID:
  1086. return m.AddedOrganizationID()
  1087. }
  1088. return nil, false
  1089. }
  1090. // AddField adds the value to the field with the given name. It returns an error if
  1091. // the field is not defined in the schema, or if the type mismatched the field
  1092. // type.
  1093. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1094. switch name {
  1095. case agent.FieldStatus:
  1096. v, ok := value.(int)
  1097. if !ok {
  1098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1099. }
  1100. m.AddStatus(v)
  1101. return nil
  1102. case agent.FieldOrganizationID:
  1103. v, ok := value.(int64)
  1104. if !ok {
  1105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1106. }
  1107. m.AddOrganizationID(v)
  1108. return nil
  1109. }
  1110. return fmt.Errorf("unknown Agent numeric field %s", name)
  1111. }
  1112. // ClearedFields returns all nullable fields that were cleared during this
  1113. // mutation.
  1114. func (m *AgentMutation) ClearedFields() []string {
  1115. var fields []string
  1116. if m.FieldCleared(agent.FieldDeletedAt) {
  1117. fields = append(fields, agent.FieldDeletedAt)
  1118. }
  1119. if m.FieldCleared(agent.FieldStatus) {
  1120. fields = append(fields, agent.FieldStatus)
  1121. }
  1122. if m.FieldCleared(agent.FieldBackground) {
  1123. fields = append(fields, agent.FieldBackground)
  1124. }
  1125. if m.FieldCleared(agent.FieldExamples) {
  1126. fields = append(fields, agent.FieldExamples)
  1127. }
  1128. return fields
  1129. }
  1130. // FieldCleared returns a boolean indicating if a field with the given name was
  1131. // cleared in this mutation.
  1132. func (m *AgentMutation) FieldCleared(name string) bool {
  1133. _, ok := m.clearedFields[name]
  1134. return ok
  1135. }
  1136. // ClearField clears the value of the field with the given name. It returns an
  1137. // error if the field is not defined in the schema.
  1138. func (m *AgentMutation) ClearField(name string) error {
  1139. switch name {
  1140. case agent.FieldDeletedAt:
  1141. m.ClearDeletedAt()
  1142. return nil
  1143. case agent.FieldStatus:
  1144. m.ClearStatus()
  1145. return nil
  1146. case agent.FieldBackground:
  1147. m.ClearBackground()
  1148. return nil
  1149. case agent.FieldExamples:
  1150. m.ClearExamples()
  1151. return nil
  1152. }
  1153. return fmt.Errorf("unknown Agent nullable field %s", name)
  1154. }
  1155. // ResetField resets all changes in the mutation for the field with the given name.
  1156. // It returns an error if the field is not defined in the schema.
  1157. func (m *AgentMutation) ResetField(name string) error {
  1158. switch name {
  1159. case agent.FieldCreatedAt:
  1160. m.ResetCreatedAt()
  1161. return nil
  1162. case agent.FieldUpdatedAt:
  1163. m.ResetUpdatedAt()
  1164. return nil
  1165. case agent.FieldDeletedAt:
  1166. m.ResetDeletedAt()
  1167. return nil
  1168. case agent.FieldName:
  1169. m.ResetName()
  1170. return nil
  1171. case agent.FieldRole:
  1172. m.ResetRole()
  1173. return nil
  1174. case agent.FieldStatus:
  1175. m.ResetStatus()
  1176. return nil
  1177. case agent.FieldBackground:
  1178. m.ResetBackground()
  1179. return nil
  1180. case agent.FieldExamples:
  1181. m.ResetExamples()
  1182. return nil
  1183. case agent.FieldOrganizationID:
  1184. m.ResetOrganizationID()
  1185. return nil
  1186. case agent.FieldDatasetID:
  1187. m.ResetDatasetID()
  1188. return nil
  1189. case agent.FieldCollectionID:
  1190. m.ResetCollectionID()
  1191. return nil
  1192. }
  1193. return fmt.Errorf("unknown Agent field %s", name)
  1194. }
  1195. // AddedEdges returns all edge names that were set/added in this mutation.
  1196. func (m *AgentMutation) AddedEdges() []string {
  1197. edges := make([]string, 0, 4)
  1198. if m.wx_agent != nil {
  1199. edges = append(edges, agent.EdgeWxAgent)
  1200. }
  1201. if m.token_agent != nil {
  1202. edges = append(edges, agent.EdgeTokenAgent)
  1203. }
  1204. if m.wa_agent != nil {
  1205. edges = append(edges, agent.EdgeWaAgent)
  1206. }
  1207. if m.key_agent != nil {
  1208. edges = append(edges, agent.EdgeKeyAgent)
  1209. }
  1210. return edges
  1211. }
  1212. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1213. // name in this mutation.
  1214. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1215. switch name {
  1216. case agent.EdgeWxAgent:
  1217. ids := make([]ent.Value, 0, len(m.wx_agent))
  1218. for id := range m.wx_agent {
  1219. ids = append(ids, id)
  1220. }
  1221. return ids
  1222. case agent.EdgeTokenAgent:
  1223. ids := make([]ent.Value, 0, len(m.token_agent))
  1224. for id := range m.token_agent {
  1225. ids = append(ids, id)
  1226. }
  1227. return ids
  1228. case agent.EdgeWaAgent:
  1229. ids := make([]ent.Value, 0, len(m.wa_agent))
  1230. for id := range m.wa_agent {
  1231. ids = append(ids, id)
  1232. }
  1233. return ids
  1234. case agent.EdgeKeyAgent:
  1235. ids := make([]ent.Value, 0, len(m.key_agent))
  1236. for id := range m.key_agent {
  1237. ids = append(ids, id)
  1238. }
  1239. return ids
  1240. }
  1241. return nil
  1242. }
  1243. // RemovedEdges returns all edge names that were removed in this mutation.
  1244. func (m *AgentMutation) RemovedEdges() []string {
  1245. edges := make([]string, 0, 4)
  1246. if m.removedwx_agent != nil {
  1247. edges = append(edges, agent.EdgeWxAgent)
  1248. }
  1249. if m.removedtoken_agent != nil {
  1250. edges = append(edges, agent.EdgeTokenAgent)
  1251. }
  1252. if m.removedwa_agent != nil {
  1253. edges = append(edges, agent.EdgeWaAgent)
  1254. }
  1255. if m.removedkey_agent != nil {
  1256. edges = append(edges, agent.EdgeKeyAgent)
  1257. }
  1258. return edges
  1259. }
  1260. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1261. // the given name in this mutation.
  1262. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1263. switch name {
  1264. case agent.EdgeWxAgent:
  1265. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1266. for id := range m.removedwx_agent {
  1267. ids = append(ids, id)
  1268. }
  1269. return ids
  1270. case agent.EdgeTokenAgent:
  1271. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1272. for id := range m.removedtoken_agent {
  1273. ids = append(ids, id)
  1274. }
  1275. return ids
  1276. case agent.EdgeWaAgent:
  1277. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1278. for id := range m.removedwa_agent {
  1279. ids = append(ids, id)
  1280. }
  1281. return ids
  1282. case agent.EdgeKeyAgent:
  1283. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1284. for id := range m.removedkey_agent {
  1285. ids = append(ids, id)
  1286. }
  1287. return ids
  1288. }
  1289. return nil
  1290. }
  1291. // ClearedEdges returns all edge names that were cleared in this mutation.
  1292. func (m *AgentMutation) ClearedEdges() []string {
  1293. edges := make([]string, 0, 4)
  1294. if m.clearedwx_agent {
  1295. edges = append(edges, agent.EdgeWxAgent)
  1296. }
  1297. if m.clearedtoken_agent {
  1298. edges = append(edges, agent.EdgeTokenAgent)
  1299. }
  1300. if m.clearedwa_agent {
  1301. edges = append(edges, agent.EdgeWaAgent)
  1302. }
  1303. if m.clearedkey_agent {
  1304. edges = append(edges, agent.EdgeKeyAgent)
  1305. }
  1306. return edges
  1307. }
  1308. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1309. // was cleared in this mutation.
  1310. func (m *AgentMutation) EdgeCleared(name string) bool {
  1311. switch name {
  1312. case agent.EdgeWxAgent:
  1313. return m.clearedwx_agent
  1314. case agent.EdgeTokenAgent:
  1315. return m.clearedtoken_agent
  1316. case agent.EdgeWaAgent:
  1317. return m.clearedwa_agent
  1318. case agent.EdgeKeyAgent:
  1319. return m.clearedkey_agent
  1320. }
  1321. return false
  1322. }
  1323. // ClearEdge clears the value of the edge with the given name. It returns an error
  1324. // if that edge is not defined in the schema.
  1325. func (m *AgentMutation) ClearEdge(name string) error {
  1326. switch name {
  1327. }
  1328. return fmt.Errorf("unknown Agent unique edge %s", name)
  1329. }
  1330. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1331. // It returns an error if the edge is not defined in the schema.
  1332. func (m *AgentMutation) ResetEdge(name string) error {
  1333. switch name {
  1334. case agent.EdgeWxAgent:
  1335. m.ResetWxAgent()
  1336. return nil
  1337. case agent.EdgeTokenAgent:
  1338. m.ResetTokenAgent()
  1339. return nil
  1340. case agent.EdgeWaAgent:
  1341. m.ResetWaAgent()
  1342. return nil
  1343. case agent.EdgeKeyAgent:
  1344. m.ResetKeyAgent()
  1345. return nil
  1346. }
  1347. return fmt.Errorf("unknown Agent edge %s", name)
  1348. }
  1349. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1350. type AgentBaseMutation struct {
  1351. config
  1352. op Op
  1353. typ string
  1354. id *string
  1355. q *string
  1356. a *string
  1357. chunk_index *uint64
  1358. addchunk_index *int64
  1359. indexes *[]string
  1360. appendindexes []string
  1361. dataset_id *string
  1362. collection_id *string
  1363. source_name *string
  1364. can_write *[]bool
  1365. appendcan_write []bool
  1366. is_owner *[]bool
  1367. appendis_owner []bool
  1368. clearedFields map[string]struct{}
  1369. wx_agent map[uint64]struct{}
  1370. removedwx_agent map[uint64]struct{}
  1371. clearedwx_agent bool
  1372. done bool
  1373. oldValue func(context.Context) (*AgentBase, error)
  1374. predicates []predicate.AgentBase
  1375. }
  1376. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1377. // agentbaseOption allows management of the mutation configuration using functional options.
  1378. type agentbaseOption func(*AgentBaseMutation)
  1379. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1380. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1381. m := &AgentBaseMutation{
  1382. config: c,
  1383. op: op,
  1384. typ: TypeAgentBase,
  1385. clearedFields: make(map[string]struct{}),
  1386. }
  1387. for _, opt := range opts {
  1388. opt(m)
  1389. }
  1390. return m
  1391. }
  1392. // withAgentBaseID sets the ID field of the mutation.
  1393. func withAgentBaseID(id string) agentbaseOption {
  1394. return func(m *AgentBaseMutation) {
  1395. var (
  1396. err error
  1397. once sync.Once
  1398. value *AgentBase
  1399. )
  1400. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1401. once.Do(func() {
  1402. if m.done {
  1403. err = errors.New("querying old values post mutation is not allowed")
  1404. } else {
  1405. value, err = m.Client().AgentBase.Get(ctx, id)
  1406. }
  1407. })
  1408. return value, err
  1409. }
  1410. m.id = &id
  1411. }
  1412. }
  1413. // withAgentBase sets the old AgentBase of the mutation.
  1414. func withAgentBase(node *AgentBase) agentbaseOption {
  1415. return func(m *AgentBaseMutation) {
  1416. m.oldValue = func(context.Context) (*AgentBase, error) {
  1417. return node, nil
  1418. }
  1419. m.id = &node.ID
  1420. }
  1421. }
  1422. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1423. // executed in a transaction (ent.Tx), a transactional client is returned.
  1424. func (m AgentBaseMutation) Client() *Client {
  1425. client := &Client{config: m.config}
  1426. client.init()
  1427. return client
  1428. }
  1429. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1430. // it returns an error otherwise.
  1431. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1432. if _, ok := m.driver.(*txDriver); !ok {
  1433. return nil, errors.New("ent: mutation is not running in a transaction")
  1434. }
  1435. tx := &Tx{config: m.config}
  1436. tx.init()
  1437. return tx, nil
  1438. }
  1439. // SetID sets the value of the id field. Note that this
  1440. // operation is only accepted on creation of AgentBase entities.
  1441. func (m *AgentBaseMutation) SetID(id string) {
  1442. m.id = &id
  1443. }
  1444. // ID returns the ID value in the mutation. Note that the ID is only available
  1445. // if it was provided to the builder or after it was returned from the database.
  1446. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1447. if m.id == nil {
  1448. return
  1449. }
  1450. return *m.id, true
  1451. }
  1452. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1453. // That means, if the mutation is applied within a transaction with an isolation level such
  1454. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1455. // or updated by the mutation.
  1456. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1457. switch {
  1458. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1459. id, exists := m.ID()
  1460. if exists {
  1461. return []string{id}, nil
  1462. }
  1463. fallthrough
  1464. case m.op.Is(OpUpdate | OpDelete):
  1465. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1466. default:
  1467. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1468. }
  1469. }
  1470. // SetQ sets the "q" field.
  1471. func (m *AgentBaseMutation) SetQ(s string) {
  1472. m.q = &s
  1473. }
  1474. // Q returns the value of the "q" field in the mutation.
  1475. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1476. v := m.q
  1477. if v == nil {
  1478. return
  1479. }
  1480. return *v, true
  1481. }
  1482. // OldQ returns the old "q" field's value of the AgentBase entity.
  1483. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1485. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1486. if !m.op.Is(OpUpdateOne) {
  1487. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1488. }
  1489. if m.id == nil || m.oldValue == nil {
  1490. return v, errors.New("OldQ requires an ID field in the mutation")
  1491. }
  1492. oldValue, err := m.oldValue(ctx)
  1493. if err != nil {
  1494. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1495. }
  1496. return oldValue.Q, nil
  1497. }
  1498. // ClearQ clears the value of the "q" field.
  1499. func (m *AgentBaseMutation) ClearQ() {
  1500. m.q = nil
  1501. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1502. }
  1503. // QCleared returns if the "q" field was cleared in this mutation.
  1504. func (m *AgentBaseMutation) QCleared() bool {
  1505. _, ok := m.clearedFields[agentbase.FieldQ]
  1506. return ok
  1507. }
  1508. // ResetQ resets all changes to the "q" field.
  1509. func (m *AgentBaseMutation) ResetQ() {
  1510. m.q = nil
  1511. delete(m.clearedFields, agentbase.FieldQ)
  1512. }
  1513. // SetA sets the "a" field.
  1514. func (m *AgentBaseMutation) SetA(s string) {
  1515. m.a = &s
  1516. }
  1517. // A returns the value of the "a" field in the mutation.
  1518. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1519. v := m.a
  1520. if v == nil {
  1521. return
  1522. }
  1523. return *v, true
  1524. }
  1525. // OldA returns the old "a" field's value of the AgentBase entity.
  1526. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1528. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1529. if !m.op.Is(OpUpdateOne) {
  1530. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1531. }
  1532. if m.id == nil || m.oldValue == nil {
  1533. return v, errors.New("OldA requires an ID field in the mutation")
  1534. }
  1535. oldValue, err := m.oldValue(ctx)
  1536. if err != nil {
  1537. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1538. }
  1539. return oldValue.A, nil
  1540. }
  1541. // ClearA clears the value of the "a" field.
  1542. func (m *AgentBaseMutation) ClearA() {
  1543. m.a = nil
  1544. m.clearedFields[agentbase.FieldA] = struct{}{}
  1545. }
  1546. // ACleared returns if the "a" field was cleared in this mutation.
  1547. func (m *AgentBaseMutation) ACleared() bool {
  1548. _, ok := m.clearedFields[agentbase.FieldA]
  1549. return ok
  1550. }
  1551. // ResetA resets all changes to the "a" field.
  1552. func (m *AgentBaseMutation) ResetA() {
  1553. m.a = nil
  1554. delete(m.clearedFields, agentbase.FieldA)
  1555. }
  1556. // SetChunkIndex sets the "chunk_index" field.
  1557. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1558. m.chunk_index = &u
  1559. m.addchunk_index = nil
  1560. }
  1561. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1562. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1563. v := m.chunk_index
  1564. if v == nil {
  1565. return
  1566. }
  1567. return *v, true
  1568. }
  1569. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1570. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1572. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1573. if !m.op.Is(OpUpdateOne) {
  1574. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1575. }
  1576. if m.id == nil || m.oldValue == nil {
  1577. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1578. }
  1579. oldValue, err := m.oldValue(ctx)
  1580. if err != nil {
  1581. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1582. }
  1583. return oldValue.ChunkIndex, nil
  1584. }
  1585. // AddChunkIndex adds u to the "chunk_index" field.
  1586. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1587. if m.addchunk_index != nil {
  1588. *m.addchunk_index += u
  1589. } else {
  1590. m.addchunk_index = &u
  1591. }
  1592. }
  1593. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1594. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1595. v := m.addchunk_index
  1596. if v == nil {
  1597. return
  1598. }
  1599. return *v, true
  1600. }
  1601. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1602. func (m *AgentBaseMutation) ResetChunkIndex() {
  1603. m.chunk_index = nil
  1604. m.addchunk_index = nil
  1605. }
  1606. // SetIndexes sets the "indexes" field.
  1607. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1608. m.indexes = &s
  1609. m.appendindexes = nil
  1610. }
  1611. // Indexes returns the value of the "indexes" field in the mutation.
  1612. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1613. v := m.indexes
  1614. if v == nil {
  1615. return
  1616. }
  1617. return *v, true
  1618. }
  1619. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1620. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1622. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1623. if !m.op.Is(OpUpdateOne) {
  1624. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1625. }
  1626. if m.id == nil || m.oldValue == nil {
  1627. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1628. }
  1629. oldValue, err := m.oldValue(ctx)
  1630. if err != nil {
  1631. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1632. }
  1633. return oldValue.Indexes, nil
  1634. }
  1635. // AppendIndexes adds s to the "indexes" field.
  1636. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1637. m.appendindexes = append(m.appendindexes, s...)
  1638. }
  1639. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1640. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1641. if len(m.appendindexes) == 0 {
  1642. return nil, false
  1643. }
  1644. return m.appendindexes, true
  1645. }
  1646. // ClearIndexes clears the value of the "indexes" field.
  1647. func (m *AgentBaseMutation) ClearIndexes() {
  1648. m.indexes = nil
  1649. m.appendindexes = nil
  1650. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1651. }
  1652. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1653. func (m *AgentBaseMutation) IndexesCleared() bool {
  1654. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1655. return ok
  1656. }
  1657. // ResetIndexes resets all changes to the "indexes" field.
  1658. func (m *AgentBaseMutation) ResetIndexes() {
  1659. m.indexes = nil
  1660. m.appendindexes = nil
  1661. delete(m.clearedFields, agentbase.FieldIndexes)
  1662. }
  1663. // SetDatasetID sets the "dataset_id" field.
  1664. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1665. m.dataset_id = &s
  1666. }
  1667. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1668. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1669. v := m.dataset_id
  1670. if v == nil {
  1671. return
  1672. }
  1673. return *v, true
  1674. }
  1675. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1676. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1678. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1679. if !m.op.Is(OpUpdateOne) {
  1680. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1681. }
  1682. if m.id == nil || m.oldValue == nil {
  1683. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1684. }
  1685. oldValue, err := m.oldValue(ctx)
  1686. if err != nil {
  1687. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1688. }
  1689. return oldValue.DatasetID, nil
  1690. }
  1691. // ClearDatasetID clears the value of the "dataset_id" field.
  1692. func (m *AgentBaseMutation) ClearDatasetID() {
  1693. m.dataset_id = nil
  1694. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1695. }
  1696. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1697. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1698. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1699. return ok
  1700. }
  1701. // ResetDatasetID resets all changes to the "dataset_id" field.
  1702. func (m *AgentBaseMutation) ResetDatasetID() {
  1703. m.dataset_id = nil
  1704. delete(m.clearedFields, agentbase.FieldDatasetID)
  1705. }
  1706. // SetCollectionID sets the "collection_id" field.
  1707. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1708. m.collection_id = &s
  1709. }
  1710. // CollectionID returns the value of the "collection_id" field in the mutation.
  1711. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1712. v := m.collection_id
  1713. if v == nil {
  1714. return
  1715. }
  1716. return *v, true
  1717. }
  1718. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1719. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1721. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1722. if !m.op.Is(OpUpdateOne) {
  1723. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1724. }
  1725. if m.id == nil || m.oldValue == nil {
  1726. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1727. }
  1728. oldValue, err := m.oldValue(ctx)
  1729. if err != nil {
  1730. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1731. }
  1732. return oldValue.CollectionID, nil
  1733. }
  1734. // ClearCollectionID clears the value of the "collection_id" field.
  1735. func (m *AgentBaseMutation) ClearCollectionID() {
  1736. m.collection_id = nil
  1737. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1738. }
  1739. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1740. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1741. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1742. return ok
  1743. }
  1744. // ResetCollectionID resets all changes to the "collection_id" field.
  1745. func (m *AgentBaseMutation) ResetCollectionID() {
  1746. m.collection_id = nil
  1747. delete(m.clearedFields, agentbase.FieldCollectionID)
  1748. }
  1749. // SetSourceName sets the "source_name" field.
  1750. func (m *AgentBaseMutation) SetSourceName(s string) {
  1751. m.source_name = &s
  1752. }
  1753. // SourceName returns the value of the "source_name" field in the mutation.
  1754. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1755. v := m.source_name
  1756. if v == nil {
  1757. return
  1758. }
  1759. return *v, true
  1760. }
  1761. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1762. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1764. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1765. if !m.op.Is(OpUpdateOne) {
  1766. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1767. }
  1768. if m.id == nil || m.oldValue == nil {
  1769. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1770. }
  1771. oldValue, err := m.oldValue(ctx)
  1772. if err != nil {
  1773. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1774. }
  1775. return oldValue.SourceName, nil
  1776. }
  1777. // ClearSourceName clears the value of the "source_name" field.
  1778. func (m *AgentBaseMutation) ClearSourceName() {
  1779. m.source_name = nil
  1780. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1781. }
  1782. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1783. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1784. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1785. return ok
  1786. }
  1787. // ResetSourceName resets all changes to the "source_name" field.
  1788. func (m *AgentBaseMutation) ResetSourceName() {
  1789. m.source_name = nil
  1790. delete(m.clearedFields, agentbase.FieldSourceName)
  1791. }
  1792. // SetCanWrite sets the "can_write" field.
  1793. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1794. m.can_write = &b
  1795. m.appendcan_write = nil
  1796. }
  1797. // CanWrite returns the value of the "can_write" field in the mutation.
  1798. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1799. v := m.can_write
  1800. if v == nil {
  1801. return
  1802. }
  1803. return *v, true
  1804. }
  1805. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1806. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1808. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1809. if !m.op.Is(OpUpdateOne) {
  1810. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1811. }
  1812. if m.id == nil || m.oldValue == nil {
  1813. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1814. }
  1815. oldValue, err := m.oldValue(ctx)
  1816. if err != nil {
  1817. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1818. }
  1819. return oldValue.CanWrite, nil
  1820. }
  1821. // AppendCanWrite adds b to the "can_write" field.
  1822. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1823. m.appendcan_write = append(m.appendcan_write, b...)
  1824. }
  1825. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1826. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1827. if len(m.appendcan_write) == 0 {
  1828. return nil, false
  1829. }
  1830. return m.appendcan_write, true
  1831. }
  1832. // ClearCanWrite clears the value of the "can_write" field.
  1833. func (m *AgentBaseMutation) ClearCanWrite() {
  1834. m.can_write = nil
  1835. m.appendcan_write = nil
  1836. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1837. }
  1838. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1839. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1840. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1841. return ok
  1842. }
  1843. // ResetCanWrite resets all changes to the "can_write" field.
  1844. func (m *AgentBaseMutation) ResetCanWrite() {
  1845. m.can_write = nil
  1846. m.appendcan_write = nil
  1847. delete(m.clearedFields, agentbase.FieldCanWrite)
  1848. }
  1849. // SetIsOwner sets the "is_owner" field.
  1850. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1851. m.is_owner = &b
  1852. m.appendis_owner = nil
  1853. }
  1854. // IsOwner returns the value of the "is_owner" field in the mutation.
  1855. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1856. v := m.is_owner
  1857. if v == nil {
  1858. return
  1859. }
  1860. return *v, true
  1861. }
  1862. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1863. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1865. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1866. if !m.op.Is(OpUpdateOne) {
  1867. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1868. }
  1869. if m.id == nil || m.oldValue == nil {
  1870. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1871. }
  1872. oldValue, err := m.oldValue(ctx)
  1873. if err != nil {
  1874. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1875. }
  1876. return oldValue.IsOwner, nil
  1877. }
  1878. // AppendIsOwner adds b to the "is_owner" field.
  1879. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1880. m.appendis_owner = append(m.appendis_owner, b...)
  1881. }
  1882. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1883. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1884. if len(m.appendis_owner) == 0 {
  1885. return nil, false
  1886. }
  1887. return m.appendis_owner, true
  1888. }
  1889. // ClearIsOwner clears the value of the "is_owner" field.
  1890. func (m *AgentBaseMutation) ClearIsOwner() {
  1891. m.is_owner = nil
  1892. m.appendis_owner = nil
  1893. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1894. }
  1895. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1896. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1897. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1898. return ok
  1899. }
  1900. // ResetIsOwner resets all changes to the "is_owner" field.
  1901. func (m *AgentBaseMutation) ResetIsOwner() {
  1902. m.is_owner = nil
  1903. m.appendis_owner = nil
  1904. delete(m.clearedFields, agentbase.FieldIsOwner)
  1905. }
  1906. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1907. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1908. if m.wx_agent == nil {
  1909. m.wx_agent = make(map[uint64]struct{})
  1910. }
  1911. for i := range ids {
  1912. m.wx_agent[ids[i]] = struct{}{}
  1913. }
  1914. }
  1915. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1916. func (m *AgentBaseMutation) ClearWxAgent() {
  1917. m.clearedwx_agent = true
  1918. }
  1919. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1920. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1921. return m.clearedwx_agent
  1922. }
  1923. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1924. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1925. if m.removedwx_agent == nil {
  1926. m.removedwx_agent = make(map[uint64]struct{})
  1927. }
  1928. for i := range ids {
  1929. delete(m.wx_agent, ids[i])
  1930. m.removedwx_agent[ids[i]] = struct{}{}
  1931. }
  1932. }
  1933. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1934. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1935. for id := range m.removedwx_agent {
  1936. ids = append(ids, id)
  1937. }
  1938. return
  1939. }
  1940. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1941. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1942. for id := range m.wx_agent {
  1943. ids = append(ids, id)
  1944. }
  1945. return
  1946. }
  1947. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1948. func (m *AgentBaseMutation) ResetWxAgent() {
  1949. m.wx_agent = nil
  1950. m.clearedwx_agent = false
  1951. m.removedwx_agent = nil
  1952. }
  1953. // Where appends a list predicates to the AgentBaseMutation builder.
  1954. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1955. m.predicates = append(m.predicates, ps...)
  1956. }
  1957. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1958. // users can use type-assertion to append predicates that do not depend on any generated package.
  1959. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1960. p := make([]predicate.AgentBase, len(ps))
  1961. for i := range ps {
  1962. p[i] = ps[i]
  1963. }
  1964. m.Where(p...)
  1965. }
  1966. // Op returns the operation name.
  1967. func (m *AgentBaseMutation) Op() Op {
  1968. return m.op
  1969. }
  1970. // SetOp allows setting the mutation operation.
  1971. func (m *AgentBaseMutation) SetOp(op Op) {
  1972. m.op = op
  1973. }
  1974. // Type returns the node type of this mutation (AgentBase).
  1975. func (m *AgentBaseMutation) Type() string {
  1976. return m.typ
  1977. }
  1978. // Fields returns all fields that were changed during this mutation. Note that in
  1979. // order to get all numeric fields that were incremented/decremented, call
  1980. // AddedFields().
  1981. func (m *AgentBaseMutation) Fields() []string {
  1982. fields := make([]string, 0, 9)
  1983. if m.q != nil {
  1984. fields = append(fields, agentbase.FieldQ)
  1985. }
  1986. if m.a != nil {
  1987. fields = append(fields, agentbase.FieldA)
  1988. }
  1989. if m.chunk_index != nil {
  1990. fields = append(fields, agentbase.FieldChunkIndex)
  1991. }
  1992. if m.indexes != nil {
  1993. fields = append(fields, agentbase.FieldIndexes)
  1994. }
  1995. if m.dataset_id != nil {
  1996. fields = append(fields, agentbase.FieldDatasetID)
  1997. }
  1998. if m.collection_id != nil {
  1999. fields = append(fields, agentbase.FieldCollectionID)
  2000. }
  2001. if m.source_name != nil {
  2002. fields = append(fields, agentbase.FieldSourceName)
  2003. }
  2004. if m.can_write != nil {
  2005. fields = append(fields, agentbase.FieldCanWrite)
  2006. }
  2007. if m.is_owner != nil {
  2008. fields = append(fields, agentbase.FieldIsOwner)
  2009. }
  2010. return fields
  2011. }
  2012. // Field returns the value of a field with the given name. The second boolean
  2013. // return value indicates that this field was not set, or was not defined in the
  2014. // schema.
  2015. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2016. switch name {
  2017. case agentbase.FieldQ:
  2018. return m.Q()
  2019. case agentbase.FieldA:
  2020. return m.A()
  2021. case agentbase.FieldChunkIndex:
  2022. return m.ChunkIndex()
  2023. case agentbase.FieldIndexes:
  2024. return m.Indexes()
  2025. case agentbase.FieldDatasetID:
  2026. return m.DatasetID()
  2027. case agentbase.FieldCollectionID:
  2028. return m.CollectionID()
  2029. case agentbase.FieldSourceName:
  2030. return m.SourceName()
  2031. case agentbase.FieldCanWrite:
  2032. return m.CanWrite()
  2033. case agentbase.FieldIsOwner:
  2034. return m.IsOwner()
  2035. }
  2036. return nil, false
  2037. }
  2038. // OldField returns the old value of the field from the database. An error is
  2039. // returned if the mutation operation is not UpdateOne, or the query to the
  2040. // database failed.
  2041. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2042. switch name {
  2043. case agentbase.FieldQ:
  2044. return m.OldQ(ctx)
  2045. case agentbase.FieldA:
  2046. return m.OldA(ctx)
  2047. case agentbase.FieldChunkIndex:
  2048. return m.OldChunkIndex(ctx)
  2049. case agentbase.FieldIndexes:
  2050. return m.OldIndexes(ctx)
  2051. case agentbase.FieldDatasetID:
  2052. return m.OldDatasetID(ctx)
  2053. case agentbase.FieldCollectionID:
  2054. return m.OldCollectionID(ctx)
  2055. case agentbase.FieldSourceName:
  2056. return m.OldSourceName(ctx)
  2057. case agentbase.FieldCanWrite:
  2058. return m.OldCanWrite(ctx)
  2059. case agentbase.FieldIsOwner:
  2060. return m.OldIsOwner(ctx)
  2061. }
  2062. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2063. }
  2064. // SetField sets the value of a field with the given name. It returns an error if
  2065. // the field is not defined in the schema, or if the type mismatched the field
  2066. // type.
  2067. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2068. switch name {
  2069. case agentbase.FieldQ:
  2070. v, ok := value.(string)
  2071. if !ok {
  2072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2073. }
  2074. m.SetQ(v)
  2075. return nil
  2076. case agentbase.FieldA:
  2077. v, ok := value.(string)
  2078. if !ok {
  2079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2080. }
  2081. m.SetA(v)
  2082. return nil
  2083. case agentbase.FieldChunkIndex:
  2084. v, ok := value.(uint64)
  2085. if !ok {
  2086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2087. }
  2088. m.SetChunkIndex(v)
  2089. return nil
  2090. case agentbase.FieldIndexes:
  2091. v, ok := value.([]string)
  2092. if !ok {
  2093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2094. }
  2095. m.SetIndexes(v)
  2096. return nil
  2097. case agentbase.FieldDatasetID:
  2098. v, ok := value.(string)
  2099. if !ok {
  2100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2101. }
  2102. m.SetDatasetID(v)
  2103. return nil
  2104. case agentbase.FieldCollectionID:
  2105. v, ok := value.(string)
  2106. if !ok {
  2107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2108. }
  2109. m.SetCollectionID(v)
  2110. return nil
  2111. case agentbase.FieldSourceName:
  2112. v, ok := value.(string)
  2113. if !ok {
  2114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2115. }
  2116. m.SetSourceName(v)
  2117. return nil
  2118. case agentbase.FieldCanWrite:
  2119. v, ok := value.([]bool)
  2120. if !ok {
  2121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2122. }
  2123. m.SetCanWrite(v)
  2124. return nil
  2125. case agentbase.FieldIsOwner:
  2126. v, ok := value.([]bool)
  2127. if !ok {
  2128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2129. }
  2130. m.SetIsOwner(v)
  2131. return nil
  2132. }
  2133. return fmt.Errorf("unknown AgentBase field %s", name)
  2134. }
  2135. // AddedFields returns all numeric fields that were incremented/decremented during
  2136. // this mutation.
  2137. func (m *AgentBaseMutation) AddedFields() []string {
  2138. var fields []string
  2139. if m.addchunk_index != nil {
  2140. fields = append(fields, agentbase.FieldChunkIndex)
  2141. }
  2142. return fields
  2143. }
  2144. // AddedField returns the numeric value that was incremented/decremented on a field
  2145. // with the given name. The second boolean return value indicates that this field
  2146. // was not set, or was not defined in the schema.
  2147. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2148. switch name {
  2149. case agentbase.FieldChunkIndex:
  2150. return m.AddedChunkIndex()
  2151. }
  2152. return nil, false
  2153. }
  2154. // AddField adds the value to the field with the given name. It returns an error if
  2155. // the field is not defined in the schema, or if the type mismatched the field
  2156. // type.
  2157. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2158. switch name {
  2159. case agentbase.FieldChunkIndex:
  2160. v, ok := value.(int64)
  2161. if !ok {
  2162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2163. }
  2164. m.AddChunkIndex(v)
  2165. return nil
  2166. }
  2167. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2168. }
  2169. // ClearedFields returns all nullable fields that were cleared during this
  2170. // mutation.
  2171. func (m *AgentBaseMutation) ClearedFields() []string {
  2172. var fields []string
  2173. if m.FieldCleared(agentbase.FieldQ) {
  2174. fields = append(fields, agentbase.FieldQ)
  2175. }
  2176. if m.FieldCleared(agentbase.FieldA) {
  2177. fields = append(fields, agentbase.FieldA)
  2178. }
  2179. if m.FieldCleared(agentbase.FieldIndexes) {
  2180. fields = append(fields, agentbase.FieldIndexes)
  2181. }
  2182. if m.FieldCleared(agentbase.FieldDatasetID) {
  2183. fields = append(fields, agentbase.FieldDatasetID)
  2184. }
  2185. if m.FieldCleared(agentbase.FieldCollectionID) {
  2186. fields = append(fields, agentbase.FieldCollectionID)
  2187. }
  2188. if m.FieldCleared(agentbase.FieldSourceName) {
  2189. fields = append(fields, agentbase.FieldSourceName)
  2190. }
  2191. if m.FieldCleared(agentbase.FieldCanWrite) {
  2192. fields = append(fields, agentbase.FieldCanWrite)
  2193. }
  2194. if m.FieldCleared(agentbase.FieldIsOwner) {
  2195. fields = append(fields, agentbase.FieldIsOwner)
  2196. }
  2197. return fields
  2198. }
  2199. // FieldCleared returns a boolean indicating if a field with the given name was
  2200. // cleared in this mutation.
  2201. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2202. _, ok := m.clearedFields[name]
  2203. return ok
  2204. }
  2205. // ClearField clears the value of the field with the given name. It returns an
  2206. // error if the field is not defined in the schema.
  2207. func (m *AgentBaseMutation) ClearField(name string) error {
  2208. switch name {
  2209. case agentbase.FieldQ:
  2210. m.ClearQ()
  2211. return nil
  2212. case agentbase.FieldA:
  2213. m.ClearA()
  2214. return nil
  2215. case agentbase.FieldIndexes:
  2216. m.ClearIndexes()
  2217. return nil
  2218. case agentbase.FieldDatasetID:
  2219. m.ClearDatasetID()
  2220. return nil
  2221. case agentbase.FieldCollectionID:
  2222. m.ClearCollectionID()
  2223. return nil
  2224. case agentbase.FieldSourceName:
  2225. m.ClearSourceName()
  2226. return nil
  2227. case agentbase.FieldCanWrite:
  2228. m.ClearCanWrite()
  2229. return nil
  2230. case agentbase.FieldIsOwner:
  2231. m.ClearIsOwner()
  2232. return nil
  2233. }
  2234. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2235. }
  2236. // ResetField resets all changes in the mutation for the field with the given name.
  2237. // It returns an error if the field is not defined in the schema.
  2238. func (m *AgentBaseMutation) ResetField(name string) error {
  2239. switch name {
  2240. case agentbase.FieldQ:
  2241. m.ResetQ()
  2242. return nil
  2243. case agentbase.FieldA:
  2244. m.ResetA()
  2245. return nil
  2246. case agentbase.FieldChunkIndex:
  2247. m.ResetChunkIndex()
  2248. return nil
  2249. case agentbase.FieldIndexes:
  2250. m.ResetIndexes()
  2251. return nil
  2252. case agentbase.FieldDatasetID:
  2253. m.ResetDatasetID()
  2254. return nil
  2255. case agentbase.FieldCollectionID:
  2256. m.ResetCollectionID()
  2257. return nil
  2258. case agentbase.FieldSourceName:
  2259. m.ResetSourceName()
  2260. return nil
  2261. case agentbase.FieldCanWrite:
  2262. m.ResetCanWrite()
  2263. return nil
  2264. case agentbase.FieldIsOwner:
  2265. m.ResetIsOwner()
  2266. return nil
  2267. }
  2268. return fmt.Errorf("unknown AgentBase field %s", name)
  2269. }
  2270. // AddedEdges returns all edge names that were set/added in this mutation.
  2271. func (m *AgentBaseMutation) AddedEdges() []string {
  2272. edges := make([]string, 0, 1)
  2273. if m.wx_agent != nil {
  2274. edges = append(edges, agentbase.EdgeWxAgent)
  2275. }
  2276. return edges
  2277. }
  2278. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2279. // name in this mutation.
  2280. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2281. switch name {
  2282. case agentbase.EdgeWxAgent:
  2283. ids := make([]ent.Value, 0, len(m.wx_agent))
  2284. for id := range m.wx_agent {
  2285. ids = append(ids, id)
  2286. }
  2287. return ids
  2288. }
  2289. return nil
  2290. }
  2291. // RemovedEdges returns all edge names that were removed in this mutation.
  2292. func (m *AgentBaseMutation) RemovedEdges() []string {
  2293. edges := make([]string, 0, 1)
  2294. if m.removedwx_agent != nil {
  2295. edges = append(edges, agentbase.EdgeWxAgent)
  2296. }
  2297. return edges
  2298. }
  2299. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2300. // the given name in this mutation.
  2301. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2302. switch name {
  2303. case agentbase.EdgeWxAgent:
  2304. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2305. for id := range m.removedwx_agent {
  2306. ids = append(ids, id)
  2307. }
  2308. return ids
  2309. }
  2310. return nil
  2311. }
  2312. // ClearedEdges returns all edge names that were cleared in this mutation.
  2313. func (m *AgentBaseMutation) ClearedEdges() []string {
  2314. edges := make([]string, 0, 1)
  2315. if m.clearedwx_agent {
  2316. edges = append(edges, agentbase.EdgeWxAgent)
  2317. }
  2318. return edges
  2319. }
  2320. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2321. // was cleared in this mutation.
  2322. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2323. switch name {
  2324. case agentbase.EdgeWxAgent:
  2325. return m.clearedwx_agent
  2326. }
  2327. return false
  2328. }
  2329. // ClearEdge clears the value of the edge with the given name. It returns an error
  2330. // if that edge is not defined in the schema.
  2331. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2332. switch name {
  2333. }
  2334. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2335. }
  2336. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2337. // It returns an error if the edge is not defined in the schema.
  2338. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2339. switch name {
  2340. case agentbase.EdgeWxAgent:
  2341. m.ResetWxAgent()
  2342. return nil
  2343. }
  2344. return fmt.Errorf("unknown AgentBase edge %s", name)
  2345. }
  2346. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2347. type AliyunAvatarMutation struct {
  2348. config
  2349. op Op
  2350. typ string
  2351. id *uint64
  2352. created_at *time.Time
  2353. updated_at *time.Time
  2354. deleted_at *time.Time
  2355. user_id *uint64
  2356. adduser_id *int64
  2357. biz_id *string
  2358. access_key_id *string
  2359. access_key_secret *string
  2360. app_id *string
  2361. tenant_id *uint64
  2362. addtenant_id *int64
  2363. response *string
  2364. token *string
  2365. session_id *string
  2366. clearedFields map[string]struct{}
  2367. done bool
  2368. oldValue func(context.Context) (*AliyunAvatar, error)
  2369. predicates []predicate.AliyunAvatar
  2370. }
  2371. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2372. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2373. type aliyunavatarOption func(*AliyunAvatarMutation)
  2374. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2375. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2376. m := &AliyunAvatarMutation{
  2377. config: c,
  2378. op: op,
  2379. typ: TypeAliyunAvatar,
  2380. clearedFields: make(map[string]struct{}),
  2381. }
  2382. for _, opt := range opts {
  2383. opt(m)
  2384. }
  2385. return m
  2386. }
  2387. // withAliyunAvatarID sets the ID field of the mutation.
  2388. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2389. return func(m *AliyunAvatarMutation) {
  2390. var (
  2391. err error
  2392. once sync.Once
  2393. value *AliyunAvatar
  2394. )
  2395. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2396. once.Do(func() {
  2397. if m.done {
  2398. err = errors.New("querying old values post mutation is not allowed")
  2399. } else {
  2400. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2401. }
  2402. })
  2403. return value, err
  2404. }
  2405. m.id = &id
  2406. }
  2407. }
  2408. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2409. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2410. return func(m *AliyunAvatarMutation) {
  2411. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2412. return node, nil
  2413. }
  2414. m.id = &node.ID
  2415. }
  2416. }
  2417. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2418. // executed in a transaction (ent.Tx), a transactional client is returned.
  2419. func (m AliyunAvatarMutation) Client() *Client {
  2420. client := &Client{config: m.config}
  2421. client.init()
  2422. return client
  2423. }
  2424. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2425. // it returns an error otherwise.
  2426. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2427. if _, ok := m.driver.(*txDriver); !ok {
  2428. return nil, errors.New("ent: mutation is not running in a transaction")
  2429. }
  2430. tx := &Tx{config: m.config}
  2431. tx.init()
  2432. return tx, nil
  2433. }
  2434. // SetID sets the value of the id field. Note that this
  2435. // operation is only accepted on creation of AliyunAvatar entities.
  2436. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2437. m.id = &id
  2438. }
  2439. // ID returns the ID value in the mutation. Note that the ID is only available
  2440. // if it was provided to the builder or after it was returned from the database.
  2441. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2442. if m.id == nil {
  2443. return
  2444. }
  2445. return *m.id, true
  2446. }
  2447. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2448. // That means, if the mutation is applied within a transaction with an isolation level such
  2449. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2450. // or updated by the mutation.
  2451. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2452. switch {
  2453. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2454. id, exists := m.ID()
  2455. if exists {
  2456. return []uint64{id}, nil
  2457. }
  2458. fallthrough
  2459. case m.op.Is(OpUpdate | OpDelete):
  2460. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2461. default:
  2462. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2463. }
  2464. }
  2465. // SetCreatedAt sets the "created_at" field.
  2466. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2467. m.created_at = &t
  2468. }
  2469. // CreatedAt returns the value of the "created_at" field in the mutation.
  2470. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2471. v := m.created_at
  2472. if v == nil {
  2473. return
  2474. }
  2475. return *v, true
  2476. }
  2477. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2478. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2480. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2481. if !m.op.Is(OpUpdateOne) {
  2482. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2483. }
  2484. if m.id == nil || m.oldValue == nil {
  2485. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2486. }
  2487. oldValue, err := m.oldValue(ctx)
  2488. if err != nil {
  2489. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2490. }
  2491. return oldValue.CreatedAt, nil
  2492. }
  2493. // ResetCreatedAt resets all changes to the "created_at" field.
  2494. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2495. m.created_at = nil
  2496. }
  2497. // SetUpdatedAt sets the "updated_at" field.
  2498. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2499. m.updated_at = &t
  2500. }
  2501. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2502. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2503. v := m.updated_at
  2504. if v == nil {
  2505. return
  2506. }
  2507. return *v, true
  2508. }
  2509. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2510. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2512. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2513. if !m.op.Is(OpUpdateOne) {
  2514. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2515. }
  2516. if m.id == nil || m.oldValue == nil {
  2517. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2518. }
  2519. oldValue, err := m.oldValue(ctx)
  2520. if err != nil {
  2521. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2522. }
  2523. return oldValue.UpdatedAt, nil
  2524. }
  2525. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2526. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2527. m.updated_at = nil
  2528. }
  2529. // SetDeletedAt sets the "deleted_at" field.
  2530. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2531. m.deleted_at = &t
  2532. }
  2533. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2534. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2535. v := m.deleted_at
  2536. if v == nil {
  2537. return
  2538. }
  2539. return *v, true
  2540. }
  2541. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2542. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2544. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2545. if !m.op.Is(OpUpdateOne) {
  2546. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2547. }
  2548. if m.id == nil || m.oldValue == nil {
  2549. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2550. }
  2551. oldValue, err := m.oldValue(ctx)
  2552. if err != nil {
  2553. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2554. }
  2555. return oldValue.DeletedAt, nil
  2556. }
  2557. // ClearDeletedAt clears the value of the "deleted_at" field.
  2558. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2559. m.deleted_at = nil
  2560. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2561. }
  2562. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2563. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2564. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2565. return ok
  2566. }
  2567. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2568. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2569. m.deleted_at = nil
  2570. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2571. }
  2572. // SetUserID sets the "user_id" field.
  2573. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2574. m.user_id = &u
  2575. m.adduser_id = nil
  2576. }
  2577. // UserID returns the value of the "user_id" field in the mutation.
  2578. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2579. v := m.user_id
  2580. if v == nil {
  2581. return
  2582. }
  2583. return *v, true
  2584. }
  2585. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2586. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2588. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2589. if !m.op.Is(OpUpdateOne) {
  2590. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2591. }
  2592. if m.id == nil || m.oldValue == nil {
  2593. return v, errors.New("OldUserID requires an ID field in the mutation")
  2594. }
  2595. oldValue, err := m.oldValue(ctx)
  2596. if err != nil {
  2597. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2598. }
  2599. return oldValue.UserID, nil
  2600. }
  2601. // AddUserID adds u to the "user_id" field.
  2602. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2603. if m.adduser_id != nil {
  2604. *m.adduser_id += u
  2605. } else {
  2606. m.adduser_id = &u
  2607. }
  2608. }
  2609. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2610. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2611. v := m.adduser_id
  2612. if v == nil {
  2613. return
  2614. }
  2615. return *v, true
  2616. }
  2617. // ResetUserID resets all changes to the "user_id" field.
  2618. func (m *AliyunAvatarMutation) ResetUserID() {
  2619. m.user_id = nil
  2620. m.adduser_id = nil
  2621. }
  2622. // SetBizID sets the "biz_id" field.
  2623. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2624. m.biz_id = &s
  2625. }
  2626. // BizID returns the value of the "biz_id" field in the mutation.
  2627. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2628. v := m.biz_id
  2629. if v == nil {
  2630. return
  2631. }
  2632. return *v, true
  2633. }
  2634. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2635. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2637. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2638. if !m.op.Is(OpUpdateOne) {
  2639. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2640. }
  2641. if m.id == nil || m.oldValue == nil {
  2642. return v, errors.New("OldBizID requires an ID field in the mutation")
  2643. }
  2644. oldValue, err := m.oldValue(ctx)
  2645. if err != nil {
  2646. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2647. }
  2648. return oldValue.BizID, nil
  2649. }
  2650. // ResetBizID resets all changes to the "biz_id" field.
  2651. func (m *AliyunAvatarMutation) ResetBizID() {
  2652. m.biz_id = nil
  2653. }
  2654. // SetAccessKeyID sets the "access_key_id" field.
  2655. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2656. m.access_key_id = &s
  2657. }
  2658. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2659. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2660. v := m.access_key_id
  2661. if v == nil {
  2662. return
  2663. }
  2664. return *v, true
  2665. }
  2666. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2667. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2669. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2670. if !m.op.Is(OpUpdateOne) {
  2671. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2672. }
  2673. if m.id == nil || m.oldValue == nil {
  2674. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2675. }
  2676. oldValue, err := m.oldValue(ctx)
  2677. if err != nil {
  2678. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2679. }
  2680. return oldValue.AccessKeyID, nil
  2681. }
  2682. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2683. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2684. m.access_key_id = nil
  2685. }
  2686. // SetAccessKeySecret sets the "access_key_secret" field.
  2687. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2688. m.access_key_secret = &s
  2689. }
  2690. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2691. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2692. v := m.access_key_secret
  2693. if v == nil {
  2694. return
  2695. }
  2696. return *v, true
  2697. }
  2698. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2699. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2701. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2702. if !m.op.Is(OpUpdateOne) {
  2703. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2704. }
  2705. if m.id == nil || m.oldValue == nil {
  2706. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2707. }
  2708. oldValue, err := m.oldValue(ctx)
  2709. if err != nil {
  2710. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2711. }
  2712. return oldValue.AccessKeySecret, nil
  2713. }
  2714. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2715. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2716. m.access_key_secret = nil
  2717. }
  2718. // SetAppID sets the "app_id" field.
  2719. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2720. m.app_id = &s
  2721. }
  2722. // AppID returns the value of the "app_id" field in the mutation.
  2723. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2724. v := m.app_id
  2725. if v == nil {
  2726. return
  2727. }
  2728. return *v, true
  2729. }
  2730. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2731. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2733. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2734. if !m.op.Is(OpUpdateOne) {
  2735. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2736. }
  2737. if m.id == nil || m.oldValue == nil {
  2738. return v, errors.New("OldAppID requires an ID field in the mutation")
  2739. }
  2740. oldValue, err := m.oldValue(ctx)
  2741. if err != nil {
  2742. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2743. }
  2744. return oldValue.AppID, nil
  2745. }
  2746. // ClearAppID clears the value of the "app_id" field.
  2747. func (m *AliyunAvatarMutation) ClearAppID() {
  2748. m.app_id = nil
  2749. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2750. }
  2751. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2752. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2753. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2754. return ok
  2755. }
  2756. // ResetAppID resets all changes to the "app_id" field.
  2757. func (m *AliyunAvatarMutation) ResetAppID() {
  2758. m.app_id = nil
  2759. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2760. }
  2761. // SetTenantID sets the "tenant_id" field.
  2762. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2763. m.tenant_id = &u
  2764. m.addtenant_id = nil
  2765. }
  2766. // TenantID returns the value of the "tenant_id" field in the mutation.
  2767. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2768. v := m.tenant_id
  2769. if v == nil {
  2770. return
  2771. }
  2772. return *v, true
  2773. }
  2774. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2775. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2777. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2778. if !m.op.Is(OpUpdateOne) {
  2779. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2780. }
  2781. if m.id == nil || m.oldValue == nil {
  2782. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2783. }
  2784. oldValue, err := m.oldValue(ctx)
  2785. if err != nil {
  2786. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2787. }
  2788. return oldValue.TenantID, nil
  2789. }
  2790. // AddTenantID adds u to the "tenant_id" field.
  2791. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2792. if m.addtenant_id != nil {
  2793. *m.addtenant_id += u
  2794. } else {
  2795. m.addtenant_id = &u
  2796. }
  2797. }
  2798. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2799. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2800. v := m.addtenant_id
  2801. if v == nil {
  2802. return
  2803. }
  2804. return *v, true
  2805. }
  2806. // ResetTenantID resets all changes to the "tenant_id" field.
  2807. func (m *AliyunAvatarMutation) ResetTenantID() {
  2808. m.tenant_id = nil
  2809. m.addtenant_id = nil
  2810. }
  2811. // SetResponse sets the "response" field.
  2812. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2813. m.response = &s
  2814. }
  2815. // Response returns the value of the "response" field in the mutation.
  2816. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2817. v := m.response
  2818. if v == nil {
  2819. return
  2820. }
  2821. return *v, true
  2822. }
  2823. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2824. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2826. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2827. if !m.op.Is(OpUpdateOne) {
  2828. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2829. }
  2830. if m.id == nil || m.oldValue == nil {
  2831. return v, errors.New("OldResponse requires an ID field in the mutation")
  2832. }
  2833. oldValue, err := m.oldValue(ctx)
  2834. if err != nil {
  2835. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2836. }
  2837. return oldValue.Response, nil
  2838. }
  2839. // ResetResponse resets all changes to the "response" field.
  2840. func (m *AliyunAvatarMutation) ResetResponse() {
  2841. m.response = nil
  2842. }
  2843. // SetToken sets the "token" field.
  2844. func (m *AliyunAvatarMutation) SetToken(s string) {
  2845. m.token = &s
  2846. }
  2847. // Token returns the value of the "token" field in the mutation.
  2848. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2849. v := m.token
  2850. if v == nil {
  2851. return
  2852. }
  2853. return *v, true
  2854. }
  2855. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2856. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2858. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2859. if !m.op.Is(OpUpdateOne) {
  2860. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2861. }
  2862. if m.id == nil || m.oldValue == nil {
  2863. return v, errors.New("OldToken requires an ID field in the mutation")
  2864. }
  2865. oldValue, err := m.oldValue(ctx)
  2866. if err != nil {
  2867. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2868. }
  2869. return oldValue.Token, nil
  2870. }
  2871. // ResetToken resets all changes to the "token" field.
  2872. func (m *AliyunAvatarMutation) ResetToken() {
  2873. m.token = nil
  2874. }
  2875. // SetSessionID sets the "session_id" field.
  2876. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2877. m.session_id = &s
  2878. }
  2879. // SessionID returns the value of the "session_id" field in the mutation.
  2880. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2881. v := m.session_id
  2882. if v == nil {
  2883. return
  2884. }
  2885. return *v, true
  2886. }
  2887. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2888. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2890. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2891. if !m.op.Is(OpUpdateOne) {
  2892. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2893. }
  2894. if m.id == nil || m.oldValue == nil {
  2895. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2896. }
  2897. oldValue, err := m.oldValue(ctx)
  2898. if err != nil {
  2899. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2900. }
  2901. return oldValue.SessionID, nil
  2902. }
  2903. // ResetSessionID resets all changes to the "session_id" field.
  2904. func (m *AliyunAvatarMutation) ResetSessionID() {
  2905. m.session_id = nil
  2906. }
  2907. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2908. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2909. m.predicates = append(m.predicates, ps...)
  2910. }
  2911. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2912. // users can use type-assertion to append predicates that do not depend on any generated package.
  2913. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2914. p := make([]predicate.AliyunAvatar, len(ps))
  2915. for i := range ps {
  2916. p[i] = ps[i]
  2917. }
  2918. m.Where(p...)
  2919. }
  2920. // Op returns the operation name.
  2921. func (m *AliyunAvatarMutation) Op() Op {
  2922. return m.op
  2923. }
  2924. // SetOp allows setting the mutation operation.
  2925. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2926. m.op = op
  2927. }
  2928. // Type returns the node type of this mutation (AliyunAvatar).
  2929. func (m *AliyunAvatarMutation) Type() string {
  2930. return m.typ
  2931. }
  2932. // Fields returns all fields that were changed during this mutation. Note that in
  2933. // order to get all numeric fields that were incremented/decremented, call
  2934. // AddedFields().
  2935. func (m *AliyunAvatarMutation) Fields() []string {
  2936. fields := make([]string, 0, 12)
  2937. if m.created_at != nil {
  2938. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2939. }
  2940. if m.updated_at != nil {
  2941. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2942. }
  2943. if m.deleted_at != nil {
  2944. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2945. }
  2946. if m.user_id != nil {
  2947. fields = append(fields, aliyunavatar.FieldUserID)
  2948. }
  2949. if m.biz_id != nil {
  2950. fields = append(fields, aliyunavatar.FieldBizID)
  2951. }
  2952. if m.access_key_id != nil {
  2953. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2954. }
  2955. if m.access_key_secret != nil {
  2956. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2957. }
  2958. if m.app_id != nil {
  2959. fields = append(fields, aliyunavatar.FieldAppID)
  2960. }
  2961. if m.tenant_id != nil {
  2962. fields = append(fields, aliyunavatar.FieldTenantID)
  2963. }
  2964. if m.response != nil {
  2965. fields = append(fields, aliyunavatar.FieldResponse)
  2966. }
  2967. if m.token != nil {
  2968. fields = append(fields, aliyunavatar.FieldToken)
  2969. }
  2970. if m.session_id != nil {
  2971. fields = append(fields, aliyunavatar.FieldSessionID)
  2972. }
  2973. return fields
  2974. }
  2975. // Field returns the value of a field with the given name. The second boolean
  2976. // return value indicates that this field was not set, or was not defined in the
  2977. // schema.
  2978. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2979. switch name {
  2980. case aliyunavatar.FieldCreatedAt:
  2981. return m.CreatedAt()
  2982. case aliyunavatar.FieldUpdatedAt:
  2983. return m.UpdatedAt()
  2984. case aliyunavatar.FieldDeletedAt:
  2985. return m.DeletedAt()
  2986. case aliyunavatar.FieldUserID:
  2987. return m.UserID()
  2988. case aliyunavatar.FieldBizID:
  2989. return m.BizID()
  2990. case aliyunavatar.FieldAccessKeyID:
  2991. return m.AccessKeyID()
  2992. case aliyunavatar.FieldAccessKeySecret:
  2993. return m.AccessKeySecret()
  2994. case aliyunavatar.FieldAppID:
  2995. return m.AppID()
  2996. case aliyunavatar.FieldTenantID:
  2997. return m.TenantID()
  2998. case aliyunavatar.FieldResponse:
  2999. return m.Response()
  3000. case aliyunavatar.FieldToken:
  3001. return m.Token()
  3002. case aliyunavatar.FieldSessionID:
  3003. return m.SessionID()
  3004. }
  3005. return nil, false
  3006. }
  3007. // OldField returns the old value of the field from the database. An error is
  3008. // returned if the mutation operation is not UpdateOne, or the query to the
  3009. // database failed.
  3010. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3011. switch name {
  3012. case aliyunavatar.FieldCreatedAt:
  3013. return m.OldCreatedAt(ctx)
  3014. case aliyunavatar.FieldUpdatedAt:
  3015. return m.OldUpdatedAt(ctx)
  3016. case aliyunavatar.FieldDeletedAt:
  3017. return m.OldDeletedAt(ctx)
  3018. case aliyunavatar.FieldUserID:
  3019. return m.OldUserID(ctx)
  3020. case aliyunavatar.FieldBizID:
  3021. return m.OldBizID(ctx)
  3022. case aliyunavatar.FieldAccessKeyID:
  3023. return m.OldAccessKeyID(ctx)
  3024. case aliyunavatar.FieldAccessKeySecret:
  3025. return m.OldAccessKeySecret(ctx)
  3026. case aliyunavatar.FieldAppID:
  3027. return m.OldAppID(ctx)
  3028. case aliyunavatar.FieldTenantID:
  3029. return m.OldTenantID(ctx)
  3030. case aliyunavatar.FieldResponse:
  3031. return m.OldResponse(ctx)
  3032. case aliyunavatar.FieldToken:
  3033. return m.OldToken(ctx)
  3034. case aliyunavatar.FieldSessionID:
  3035. return m.OldSessionID(ctx)
  3036. }
  3037. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3038. }
  3039. // SetField sets the value of a field with the given name. It returns an error if
  3040. // the field is not defined in the schema, or if the type mismatched the field
  3041. // type.
  3042. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3043. switch name {
  3044. case aliyunavatar.FieldCreatedAt:
  3045. v, ok := value.(time.Time)
  3046. if !ok {
  3047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3048. }
  3049. m.SetCreatedAt(v)
  3050. return nil
  3051. case aliyunavatar.FieldUpdatedAt:
  3052. v, ok := value.(time.Time)
  3053. if !ok {
  3054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3055. }
  3056. m.SetUpdatedAt(v)
  3057. return nil
  3058. case aliyunavatar.FieldDeletedAt:
  3059. v, ok := value.(time.Time)
  3060. if !ok {
  3061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3062. }
  3063. m.SetDeletedAt(v)
  3064. return nil
  3065. case aliyunavatar.FieldUserID:
  3066. v, ok := value.(uint64)
  3067. if !ok {
  3068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3069. }
  3070. m.SetUserID(v)
  3071. return nil
  3072. case aliyunavatar.FieldBizID:
  3073. v, ok := value.(string)
  3074. if !ok {
  3075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3076. }
  3077. m.SetBizID(v)
  3078. return nil
  3079. case aliyunavatar.FieldAccessKeyID:
  3080. v, ok := value.(string)
  3081. if !ok {
  3082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3083. }
  3084. m.SetAccessKeyID(v)
  3085. return nil
  3086. case aliyunavatar.FieldAccessKeySecret:
  3087. v, ok := value.(string)
  3088. if !ok {
  3089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3090. }
  3091. m.SetAccessKeySecret(v)
  3092. return nil
  3093. case aliyunavatar.FieldAppID:
  3094. v, ok := value.(string)
  3095. if !ok {
  3096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3097. }
  3098. m.SetAppID(v)
  3099. return nil
  3100. case aliyunavatar.FieldTenantID:
  3101. v, ok := value.(uint64)
  3102. if !ok {
  3103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3104. }
  3105. m.SetTenantID(v)
  3106. return nil
  3107. case aliyunavatar.FieldResponse:
  3108. v, ok := value.(string)
  3109. if !ok {
  3110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3111. }
  3112. m.SetResponse(v)
  3113. return nil
  3114. case aliyunavatar.FieldToken:
  3115. v, ok := value.(string)
  3116. if !ok {
  3117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3118. }
  3119. m.SetToken(v)
  3120. return nil
  3121. case aliyunavatar.FieldSessionID:
  3122. v, ok := value.(string)
  3123. if !ok {
  3124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3125. }
  3126. m.SetSessionID(v)
  3127. return nil
  3128. }
  3129. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3130. }
  3131. // AddedFields returns all numeric fields that were incremented/decremented during
  3132. // this mutation.
  3133. func (m *AliyunAvatarMutation) AddedFields() []string {
  3134. var fields []string
  3135. if m.adduser_id != nil {
  3136. fields = append(fields, aliyunavatar.FieldUserID)
  3137. }
  3138. if m.addtenant_id != nil {
  3139. fields = append(fields, aliyunavatar.FieldTenantID)
  3140. }
  3141. return fields
  3142. }
  3143. // AddedField returns the numeric value that was incremented/decremented on a field
  3144. // with the given name. The second boolean return value indicates that this field
  3145. // was not set, or was not defined in the schema.
  3146. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3147. switch name {
  3148. case aliyunavatar.FieldUserID:
  3149. return m.AddedUserID()
  3150. case aliyunavatar.FieldTenantID:
  3151. return m.AddedTenantID()
  3152. }
  3153. return nil, false
  3154. }
  3155. // AddField adds the value to the field with the given name. It returns an error if
  3156. // the field is not defined in the schema, or if the type mismatched the field
  3157. // type.
  3158. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3159. switch name {
  3160. case aliyunavatar.FieldUserID:
  3161. v, ok := value.(int64)
  3162. if !ok {
  3163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3164. }
  3165. m.AddUserID(v)
  3166. return nil
  3167. case aliyunavatar.FieldTenantID:
  3168. v, ok := value.(int64)
  3169. if !ok {
  3170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3171. }
  3172. m.AddTenantID(v)
  3173. return nil
  3174. }
  3175. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3176. }
  3177. // ClearedFields returns all nullable fields that were cleared during this
  3178. // mutation.
  3179. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3180. var fields []string
  3181. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3182. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3183. }
  3184. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3185. fields = append(fields, aliyunavatar.FieldAppID)
  3186. }
  3187. return fields
  3188. }
  3189. // FieldCleared returns a boolean indicating if a field with the given name was
  3190. // cleared in this mutation.
  3191. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3192. _, ok := m.clearedFields[name]
  3193. return ok
  3194. }
  3195. // ClearField clears the value of the field with the given name. It returns an
  3196. // error if the field is not defined in the schema.
  3197. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3198. switch name {
  3199. case aliyunavatar.FieldDeletedAt:
  3200. m.ClearDeletedAt()
  3201. return nil
  3202. case aliyunavatar.FieldAppID:
  3203. m.ClearAppID()
  3204. return nil
  3205. }
  3206. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3207. }
  3208. // ResetField resets all changes in the mutation for the field with the given name.
  3209. // It returns an error if the field is not defined in the schema.
  3210. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3211. switch name {
  3212. case aliyunavatar.FieldCreatedAt:
  3213. m.ResetCreatedAt()
  3214. return nil
  3215. case aliyunavatar.FieldUpdatedAt:
  3216. m.ResetUpdatedAt()
  3217. return nil
  3218. case aliyunavatar.FieldDeletedAt:
  3219. m.ResetDeletedAt()
  3220. return nil
  3221. case aliyunavatar.FieldUserID:
  3222. m.ResetUserID()
  3223. return nil
  3224. case aliyunavatar.FieldBizID:
  3225. m.ResetBizID()
  3226. return nil
  3227. case aliyunavatar.FieldAccessKeyID:
  3228. m.ResetAccessKeyID()
  3229. return nil
  3230. case aliyunavatar.FieldAccessKeySecret:
  3231. m.ResetAccessKeySecret()
  3232. return nil
  3233. case aliyunavatar.FieldAppID:
  3234. m.ResetAppID()
  3235. return nil
  3236. case aliyunavatar.FieldTenantID:
  3237. m.ResetTenantID()
  3238. return nil
  3239. case aliyunavatar.FieldResponse:
  3240. m.ResetResponse()
  3241. return nil
  3242. case aliyunavatar.FieldToken:
  3243. m.ResetToken()
  3244. return nil
  3245. case aliyunavatar.FieldSessionID:
  3246. m.ResetSessionID()
  3247. return nil
  3248. }
  3249. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3250. }
  3251. // AddedEdges returns all edge names that were set/added in this mutation.
  3252. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3253. edges := make([]string, 0, 0)
  3254. return edges
  3255. }
  3256. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3257. // name in this mutation.
  3258. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3259. return nil
  3260. }
  3261. // RemovedEdges returns all edge names that were removed in this mutation.
  3262. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3263. edges := make([]string, 0, 0)
  3264. return edges
  3265. }
  3266. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3267. // the given name in this mutation.
  3268. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3269. return nil
  3270. }
  3271. // ClearedEdges returns all edge names that were cleared in this mutation.
  3272. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3273. edges := make([]string, 0, 0)
  3274. return edges
  3275. }
  3276. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3277. // was cleared in this mutation.
  3278. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3279. return false
  3280. }
  3281. // ClearEdge clears the value of the edge with the given name. It returns an error
  3282. // if that edge is not defined in the schema.
  3283. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3284. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3285. }
  3286. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3287. // It returns an error if the edge is not defined in the schema.
  3288. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3289. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3290. }
  3291. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3292. type AllocAgentMutation struct {
  3293. config
  3294. op Op
  3295. typ string
  3296. id *uint64
  3297. created_at *time.Time
  3298. updated_at *time.Time
  3299. deleted_at *time.Time
  3300. user_id *string
  3301. organization_id *uint64
  3302. addorganization_id *int64
  3303. agents *[]uint64
  3304. appendagents []uint64
  3305. status *int
  3306. addstatus *int
  3307. clearedFields map[string]struct{}
  3308. done bool
  3309. oldValue func(context.Context) (*AllocAgent, error)
  3310. predicates []predicate.AllocAgent
  3311. }
  3312. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3313. // allocagentOption allows management of the mutation configuration using functional options.
  3314. type allocagentOption func(*AllocAgentMutation)
  3315. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3316. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3317. m := &AllocAgentMutation{
  3318. config: c,
  3319. op: op,
  3320. typ: TypeAllocAgent,
  3321. clearedFields: make(map[string]struct{}),
  3322. }
  3323. for _, opt := range opts {
  3324. opt(m)
  3325. }
  3326. return m
  3327. }
  3328. // withAllocAgentID sets the ID field of the mutation.
  3329. func withAllocAgentID(id uint64) allocagentOption {
  3330. return func(m *AllocAgentMutation) {
  3331. var (
  3332. err error
  3333. once sync.Once
  3334. value *AllocAgent
  3335. )
  3336. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3337. once.Do(func() {
  3338. if m.done {
  3339. err = errors.New("querying old values post mutation is not allowed")
  3340. } else {
  3341. value, err = m.Client().AllocAgent.Get(ctx, id)
  3342. }
  3343. })
  3344. return value, err
  3345. }
  3346. m.id = &id
  3347. }
  3348. }
  3349. // withAllocAgent sets the old AllocAgent of the mutation.
  3350. func withAllocAgent(node *AllocAgent) allocagentOption {
  3351. return func(m *AllocAgentMutation) {
  3352. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3353. return node, nil
  3354. }
  3355. m.id = &node.ID
  3356. }
  3357. }
  3358. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3359. // executed in a transaction (ent.Tx), a transactional client is returned.
  3360. func (m AllocAgentMutation) Client() *Client {
  3361. client := &Client{config: m.config}
  3362. client.init()
  3363. return client
  3364. }
  3365. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3366. // it returns an error otherwise.
  3367. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3368. if _, ok := m.driver.(*txDriver); !ok {
  3369. return nil, errors.New("ent: mutation is not running in a transaction")
  3370. }
  3371. tx := &Tx{config: m.config}
  3372. tx.init()
  3373. return tx, nil
  3374. }
  3375. // SetID sets the value of the id field. Note that this
  3376. // operation is only accepted on creation of AllocAgent entities.
  3377. func (m *AllocAgentMutation) SetID(id uint64) {
  3378. m.id = &id
  3379. }
  3380. // ID returns the ID value in the mutation. Note that the ID is only available
  3381. // if it was provided to the builder or after it was returned from the database.
  3382. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3383. if m.id == nil {
  3384. return
  3385. }
  3386. return *m.id, true
  3387. }
  3388. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3389. // That means, if the mutation is applied within a transaction with an isolation level such
  3390. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3391. // or updated by the mutation.
  3392. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3393. switch {
  3394. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3395. id, exists := m.ID()
  3396. if exists {
  3397. return []uint64{id}, nil
  3398. }
  3399. fallthrough
  3400. case m.op.Is(OpUpdate | OpDelete):
  3401. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3402. default:
  3403. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3404. }
  3405. }
  3406. // SetCreatedAt sets the "created_at" field.
  3407. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3408. m.created_at = &t
  3409. }
  3410. // CreatedAt returns the value of the "created_at" field in the mutation.
  3411. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3412. v := m.created_at
  3413. if v == nil {
  3414. return
  3415. }
  3416. return *v, true
  3417. }
  3418. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3419. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3421. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3422. if !m.op.Is(OpUpdateOne) {
  3423. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3424. }
  3425. if m.id == nil || m.oldValue == nil {
  3426. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3427. }
  3428. oldValue, err := m.oldValue(ctx)
  3429. if err != nil {
  3430. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3431. }
  3432. return oldValue.CreatedAt, nil
  3433. }
  3434. // ResetCreatedAt resets all changes to the "created_at" field.
  3435. func (m *AllocAgentMutation) ResetCreatedAt() {
  3436. m.created_at = nil
  3437. }
  3438. // SetUpdatedAt sets the "updated_at" field.
  3439. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3440. m.updated_at = &t
  3441. }
  3442. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3443. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3444. v := m.updated_at
  3445. if v == nil {
  3446. return
  3447. }
  3448. return *v, true
  3449. }
  3450. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3451. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3453. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3454. if !m.op.Is(OpUpdateOne) {
  3455. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3456. }
  3457. if m.id == nil || m.oldValue == nil {
  3458. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3459. }
  3460. oldValue, err := m.oldValue(ctx)
  3461. if err != nil {
  3462. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3463. }
  3464. return oldValue.UpdatedAt, nil
  3465. }
  3466. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3467. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3468. m.updated_at = nil
  3469. }
  3470. // SetDeletedAt sets the "deleted_at" field.
  3471. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3472. m.deleted_at = &t
  3473. }
  3474. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3475. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3476. v := m.deleted_at
  3477. if v == nil {
  3478. return
  3479. }
  3480. return *v, true
  3481. }
  3482. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3483. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3485. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3486. if !m.op.Is(OpUpdateOne) {
  3487. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3488. }
  3489. if m.id == nil || m.oldValue == nil {
  3490. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3491. }
  3492. oldValue, err := m.oldValue(ctx)
  3493. if err != nil {
  3494. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3495. }
  3496. return oldValue.DeletedAt, nil
  3497. }
  3498. // ClearDeletedAt clears the value of the "deleted_at" field.
  3499. func (m *AllocAgentMutation) ClearDeletedAt() {
  3500. m.deleted_at = nil
  3501. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3502. }
  3503. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3504. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3505. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3506. return ok
  3507. }
  3508. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3509. func (m *AllocAgentMutation) ResetDeletedAt() {
  3510. m.deleted_at = nil
  3511. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3512. }
  3513. // SetUserID sets the "user_id" field.
  3514. func (m *AllocAgentMutation) SetUserID(s string) {
  3515. m.user_id = &s
  3516. }
  3517. // UserID returns the value of the "user_id" field in the mutation.
  3518. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3519. v := m.user_id
  3520. if v == nil {
  3521. return
  3522. }
  3523. return *v, true
  3524. }
  3525. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3526. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3528. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3529. if !m.op.Is(OpUpdateOne) {
  3530. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3531. }
  3532. if m.id == nil || m.oldValue == nil {
  3533. return v, errors.New("OldUserID requires an ID field in the mutation")
  3534. }
  3535. oldValue, err := m.oldValue(ctx)
  3536. if err != nil {
  3537. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3538. }
  3539. return oldValue.UserID, nil
  3540. }
  3541. // ClearUserID clears the value of the "user_id" field.
  3542. func (m *AllocAgentMutation) ClearUserID() {
  3543. m.user_id = nil
  3544. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3545. }
  3546. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3547. func (m *AllocAgentMutation) UserIDCleared() bool {
  3548. _, ok := m.clearedFields[allocagent.FieldUserID]
  3549. return ok
  3550. }
  3551. // ResetUserID resets all changes to the "user_id" field.
  3552. func (m *AllocAgentMutation) ResetUserID() {
  3553. m.user_id = nil
  3554. delete(m.clearedFields, allocagent.FieldUserID)
  3555. }
  3556. // SetOrganizationID sets the "organization_id" field.
  3557. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3558. m.organization_id = &u
  3559. m.addorganization_id = nil
  3560. }
  3561. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3562. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3563. v := m.organization_id
  3564. if v == nil {
  3565. return
  3566. }
  3567. return *v, true
  3568. }
  3569. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3570. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3572. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3573. if !m.op.Is(OpUpdateOne) {
  3574. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3575. }
  3576. if m.id == nil || m.oldValue == nil {
  3577. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3578. }
  3579. oldValue, err := m.oldValue(ctx)
  3580. if err != nil {
  3581. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3582. }
  3583. return oldValue.OrganizationID, nil
  3584. }
  3585. // AddOrganizationID adds u to the "organization_id" field.
  3586. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3587. if m.addorganization_id != nil {
  3588. *m.addorganization_id += u
  3589. } else {
  3590. m.addorganization_id = &u
  3591. }
  3592. }
  3593. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3594. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3595. v := m.addorganization_id
  3596. if v == nil {
  3597. return
  3598. }
  3599. return *v, true
  3600. }
  3601. // ClearOrganizationID clears the value of the "organization_id" field.
  3602. func (m *AllocAgentMutation) ClearOrganizationID() {
  3603. m.organization_id = nil
  3604. m.addorganization_id = nil
  3605. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3606. }
  3607. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3608. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3609. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3610. return ok
  3611. }
  3612. // ResetOrganizationID resets all changes to the "organization_id" field.
  3613. func (m *AllocAgentMutation) ResetOrganizationID() {
  3614. m.organization_id = nil
  3615. m.addorganization_id = nil
  3616. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3617. }
  3618. // SetAgents sets the "agents" field.
  3619. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3620. m.agents = &u
  3621. m.appendagents = nil
  3622. }
  3623. // Agents returns the value of the "agents" field in the mutation.
  3624. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3625. v := m.agents
  3626. if v == nil {
  3627. return
  3628. }
  3629. return *v, true
  3630. }
  3631. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3632. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3634. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3635. if !m.op.Is(OpUpdateOne) {
  3636. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3637. }
  3638. if m.id == nil || m.oldValue == nil {
  3639. return v, errors.New("OldAgents requires an ID field in the mutation")
  3640. }
  3641. oldValue, err := m.oldValue(ctx)
  3642. if err != nil {
  3643. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3644. }
  3645. return oldValue.Agents, nil
  3646. }
  3647. // AppendAgents adds u to the "agents" field.
  3648. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3649. m.appendagents = append(m.appendagents, u...)
  3650. }
  3651. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3652. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3653. if len(m.appendagents) == 0 {
  3654. return nil, false
  3655. }
  3656. return m.appendagents, true
  3657. }
  3658. // ResetAgents resets all changes to the "agents" field.
  3659. func (m *AllocAgentMutation) ResetAgents() {
  3660. m.agents = nil
  3661. m.appendagents = nil
  3662. }
  3663. // SetStatus sets the "status" field.
  3664. func (m *AllocAgentMutation) SetStatus(i int) {
  3665. m.status = &i
  3666. m.addstatus = nil
  3667. }
  3668. // Status returns the value of the "status" field in the mutation.
  3669. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3670. v := m.status
  3671. if v == nil {
  3672. return
  3673. }
  3674. return *v, true
  3675. }
  3676. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3677. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3679. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3680. if !m.op.Is(OpUpdateOne) {
  3681. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3682. }
  3683. if m.id == nil || m.oldValue == nil {
  3684. return v, errors.New("OldStatus requires an ID field in the mutation")
  3685. }
  3686. oldValue, err := m.oldValue(ctx)
  3687. if err != nil {
  3688. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3689. }
  3690. return oldValue.Status, nil
  3691. }
  3692. // AddStatus adds i to the "status" field.
  3693. func (m *AllocAgentMutation) AddStatus(i int) {
  3694. if m.addstatus != nil {
  3695. *m.addstatus += i
  3696. } else {
  3697. m.addstatus = &i
  3698. }
  3699. }
  3700. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3701. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3702. v := m.addstatus
  3703. if v == nil {
  3704. return
  3705. }
  3706. return *v, true
  3707. }
  3708. // ClearStatus clears the value of the "status" field.
  3709. func (m *AllocAgentMutation) ClearStatus() {
  3710. m.status = nil
  3711. m.addstatus = nil
  3712. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3713. }
  3714. // StatusCleared returns if the "status" field was cleared in this mutation.
  3715. func (m *AllocAgentMutation) StatusCleared() bool {
  3716. _, ok := m.clearedFields[allocagent.FieldStatus]
  3717. return ok
  3718. }
  3719. // ResetStatus resets all changes to the "status" field.
  3720. func (m *AllocAgentMutation) ResetStatus() {
  3721. m.status = nil
  3722. m.addstatus = nil
  3723. delete(m.clearedFields, allocagent.FieldStatus)
  3724. }
  3725. // Where appends a list predicates to the AllocAgentMutation builder.
  3726. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3727. m.predicates = append(m.predicates, ps...)
  3728. }
  3729. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3730. // users can use type-assertion to append predicates that do not depend on any generated package.
  3731. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3732. p := make([]predicate.AllocAgent, len(ps))
  3733. for i := range ps {
  3734. p[i] = ps[i]
  3735. }
  3736. m.Where(p...)
  3737. }
  3738. // Op returns the operation name.
  3739. func (m *AllocAgentMutation) Op() Op {
  3740. return m.op
  3741. }
  3742. // SetOp allows setting the mutation operation.
  3743. func (m *AllocAgentMutation) SetOp(op Op) {
  3744. m.op = op
  3745. }
  3746. // Type returns the node type of this mutation (AllocAgent).
  3747. func (m *AllocAgentMutation) Type() string {
  3748. return m.typ
  3749. }
  3750. // Fields returns all fields that were changed during this mutation. Note that in
  3751. // order to get all numeric fields that were incremented/decremented, call
  3752. // AddedFields().
  3753. func (m *AllocAgentMutation) Fields() []string {
  3754. fields := make([]string, 0, 7)
  3755. if m.created_at != nil {
  3756. fields = append(fields, allocagent.FieldCreatedAt)
  3757. }
  3758. if m.updated_at != nil {
  3759. fields = append(fields, allocagent.FieldUpdatedAt)
  3760. }
  3761. if m.deleted_at != nil {
  3762. fields = append(fields, allocagent.FieldDeletedAt)
  3763. }
  3764. if m.user_id != nil {
  3765. fields = append(fields, allocagent.FieldUserID)
  3766. }
  3767. if m.organization_id != nil {
  3768. fields = append(fields, allocagent.FieldOrganizationID)
  3769. }
  3770. if m.agents != nil {
  3771. fields = append(fields, allocagent.FieldAgents)
  3772. }
  3773. if m.status != nil {
  3774. fields = append(fields, allocagent.FieldStatus)
  3775. }
  3776. return fields
  3777. }
  3778. // Field returns the value of a field with the given name. The second boolean
  3779. // return value indicates that this field was not set, or was not defined in the
  3780. // schema.
  3781. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3782. switch name {
  3783. case allocagent.FieldCreatedAt:
  3784. return m.CreatedAt()
  3785. case allocagent.FieldUpdatedAt:
  3786. return m.UpdatedAt()
  3787. case allocagent.FieldDeletedAt:
  3788. return m.DeletedAt()
  3789. case allocagent.FieldUserID:
  3790. return m.UserID()
  3791. case allocagent.FieldOrganizationID:
  3792. return m.OrganizationID()
  3793. case allocagent.FieldAgents:
  3794. return m.Agents()
  3795. case allocagent.FieldStatus:
  3796. return m.Status()
  3797. }
  3798. return nil, false
  3799. }
  3800. // OldField returns the old value of the field from the database. An error is
  3801. // returned if the mutation operation is not UpdateOne, or the query to the
  3802. // database failed.
  3803. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3804. switch name {
  3805. case allocagent.FieldCreatedAt:
  3806. return m.OldCreatedAt(ctx)
  3807. case allocagent.FieldUpdatedAt:
  3808. return m.OldUpdatedAt(ctx)
  3809. case allocagent.FieldDeletedAt:
  3810. return m.OldDeletedAt(ctx)
  3811. case allocagent.FieldUserID:
  3812. return m.OldUserID(ctx)
  3813. case allocagent.FieldOrganizationID:
  3814. return m.OldOrganizationID(ctx)
  3815. case allocagent.FieldAgents:
  3816. return m.OldAgents(ctx)
  3817. case allocagent.FieldStatus:
  3818. return m.OldStatus(ctx)
  3819. }
  3820. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3821. }
  3822. // SetField sets the value of a field with the given name. It returns an error if
  3823. // the field is not defined in the schema, or if the type mismatched the field
  3824. // type.
  3825. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3826. switch name {
  3827. case allocagent.FieldCreatedAt:
  3828. v, ok := value.(time.Time)
  3829. if !ok {
  3830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3831. }
  3832. m.SetCreatedAt(v)
  3833. return nil
  3834. case allocagent.FieldUpdatedAt:
  3835. v, ok := value.(time.Time)
  3836. if !ok {
  3837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3838. }
  3839. m.SetUpdatedAt(v)
  3840. return nil
  3841. case allocagent.FieldDeletedAt:
  3842. v, ok := value.(time.Time)
  3843. if !ok {
  3844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3845. }
  3846. m.SetDeletedAt(v)
  3847. return nil
  3848. case allocagent.FieldUserID:
  3849. v, ok := value.(string)
  3850. if !ok {
  3851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3852. }
  3853. m.SetUserID(v)
  3854. return nil
  3855. case allocagent.FieldOrganizationID:
  3856. v, ok := value.(uint64)
  3857. if !ok {
  3858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3859. }
  3860. m.SetOrganizationID(v)
  3861. return nil
  3862. case allocagent.FieldAgents:
  3863. v, ok := value.([]uint64)
  3864. if !ok {
  3865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3866. }
  3867. m.SetAgents(v)
  3868. return nil
  3869. case allocagent.FieldStatus:
  3870. v, ok := value.(int)
  3871. if !ok {
  3872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3873. }
  3874. m.SetStatus(v)
  3875. return nil
  3876. }
  3877. return fmt.Errorf("unknown AllocAgent field %s", name)
  3878. }
  3879. // AddedFields returns all numeric fields that were incremented/decremented during
  3880. // this mutation.
  3881. func (m *AllocAgentMutation) AddedFields() []string {
  3882. var fields []string
  3883. if m.addorganization_id != nil {
  3884. fields = append(fields, allocagent.FieldOrganizationID)
  3885. }
  3886. if m.addstatus != nil {
  3887. fields = append(fields, allocagent.FieldStatus)
  3888. }
  3889. return fields
  3890. }
  3891. // AddedField returns the numeric value that was incremented/decremented on a field
  3892. // with the given name. The second boolean return value indicates that this field
  3893. // was not set, or was not defined in the schema.
  3894. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3895. switch name {
  3896. case allocagent.FieldOrganizationID:
  3897. return m.AddedOrganizationID()
  3898. case allocagent.FieldStatus:
  3899. return m.AddedStatus()
  3900. }
  3901. return nil, false
  3902. }
  3903. // AddField adds the value to the field with the given name. It returns an error if
  3904. // the field is not defined in the schema, or if the type mismatched the field
  3905. // type.
  3906. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3907. switch name {
  3908. case allocagent.FieldOrganizationID:
  3909. v, ok := value.(int64)
  3910. if !ok {
  3911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3912. }
  3913. m.AddOrganizationID(v)
  3914. return nil
  3915. case allocagent.FieldStatus:
  3916. v, ok := value.(int)
  3917. if !ok {
  3918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3919. }
  3920. m.AddStatus(v)
  3921. return nil
  3922. }
  3923. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3924. }
  3925. // ClearedFields returns all nullable fields that were cleared during this
  3926. // mutation.
  3927. func (m *AllocAgentMutation) ClearedFields() []string {
  3928. var fields []string
  3929. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3930. fields = append(fields, allocagent.FieldDeletedAt)
  3931. }
  3932. if m.FieldCleared(allocagent.FieldUserID) {
  3933. fields = append(fields, allocagent.FieldUserID)
  3934. }
  3935. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3936. fields = append(fields, allocagent.FieldOrganizationID)
  3937. }
  3938. if m.FieldCleared(allocagent.FieldStatus) {
  3939. fields = append(fields, allocagent.FieldStatus)
  3940. }
  3941. return fields
  3942. }
  3943. // FieldCleared returns a boolean indicating if a field with the given name was
  3944. // cleared in this mutation.
  3945. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3946. _, ok := m.clearedFields[name]
  3947. return ok
  3948. }
  3949. // ClearField clears the value of the field with the given name. It returns an
  3950. // error if the field is not defined in the schema.
  3951. func (m *AllocAgentMutation) ClearField(name string) error {
  3952. switch name {
  3953. case allocagent.FieldDeletedAt:
  3954. m.ClearDeletedAt()
  3955. return nil
  3956. case allocagent.FieldUserID:
  3957. m.ClearUserID()
  3958. return nil
  3959. case allocagent.FieldOrganizationID:
  3960. m.ClearOrganizationID()
  3961. return nil
  3962. case allocagent.FieldStatus:
  3963. m.ClearStatus()
  3964. return nil
  3965. }
  3966. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3967. }
  3968. // ResetField resets all changes in the mutation for the field with the given name.
  3969. // It returns an error if the field is not defined in the schema.
  3970. func (m *AllocAgentMutation) ResetField(name string) error {
  3971. switch name {
  3972. case allocagent.FieldCreatedAt:
  3973. m.ResetCreatedAt()
  3974. return nil
  3975. case allocagent.FieldUpdatedAt:
  3976. m.ResetUpdatedAt()
  3977. return nil
  3978. case allocagent.FieldDeletedAt:
  3979. m.ResetDeletedAt()
  3980. return nil
  3981. case allocagent.FieldUserID:
  3982. m.ResetUserID()
  3983. return nil
  3984. case allocagent.FieldOrganizationID:
  3985. m.ResetOrganizationID()
  3986. return nil
  3987. case allocagent.FieldAgents:
  3988. m.ResetAgents()
  3989. return nil
  3990. case allocagent.FieldStatus:
  3991. m.ResetStatus()
  3992. return nil
  3993. }
  3994. return fmt.Errorf("unknown AllocAgent field %s", name)
  3995. }
  3996. // AddedEdges returns all edge names that were set/added in this mutation.
  3997. func (m *AllocAgentMutation) AddedEdges() []string {
  3998. edges := make([]string, 0, 0)
  3999. return edges
  4000. }
  4001. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4002. // name in this mutation.
  4003. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4004. return nil
  4005. }
  4006. // RemovedEdges returns all edge names that were removed in this mutation.
  4007. func (m *AllocAgentMutation) RemovedEdges() []string {
  4008. edges := make([]string, 0, 0)
  4009. return edges
  4010. }
  4011. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4012. // the given name in this mutation.
  4013. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4014. return nil
  4015. }
  4016. // ClearedEdges returns all edge names that were cleared in this mutation.
  4017. func (m *AllocAgentMutation) ClearedEdges() []string {
  4018. edges := make([]string, 0, 0)
  4019. return edges
  4020. }
  4021. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4022. // was cleared in this mutation.
  4023. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4024. return false
  4025. }
  4026. // ClearEdge clears the value of the edge with the given name. It returns an error
  4027. // if that edge is not defined in the schema.
  4028. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4029. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4030. }
  4031. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4032. // It returns an error if the edge is not defined in the schema.
  4033. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4034. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4035. }
  4036. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4037. type ApiKeyMutation struct {
  4038. config
  4039. op Op
  4040. typ string
  4041. id *uint64
  4042. created_at *time.Time
  4043. updated_at *time.Time
  4044. deleted_at *time.Time
  4045. title *string
  4046. key *string
  4047. organization_id *uint64
  4048. addorganization_id *int64
  4049. custom_agent_base *string
  4050. custom_agent_key *string
  4051. openai_base *string
  4052. openai_key *string
  4053. clearedFields map[string]struct{}
  4054. agent *uint64
  4055. clearedagent bool
  4056. done bool
  4057. oldValue func(context.Context) (*ApiKey, error)
  4058. predicates []predicate.ApiKey
  4059. }
  4060. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4061. // apikeyOption allows management of the mutation configuration using functional options.
  4062. type apikeyOption func(*ApiKeyMutation)
  4063. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4064. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4065. m := &ApiKeyMutation{
  4066. config: c,
  4067. op: op,
  4068. typ: TypeApiKey,
  4069. clearedFields: make(map[string]struct{}),
  4070. }
  4071. for _, opt := range opts {
  4072. opt(m)
  4073. }
  4074. return m
  4075. }
  4076. // withApiKeyID sets the ID field of the mutation.
  4077. func withApiKeyID(id uint64) apikeyOption {
  4078. return func(m *ApiKeyMutation) {
  4079. var (
  4080. err error
  4081. once sync.Once
  4082. value *ApiKey
  4083. )
  4084. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4085. once.Do(func() {
  4086. if m.done {
  4087. err = errors.New("querying old values post mutation is not allowed")
  4088. } else {
  4089. value, err = m.Client().ApiKey.Get(ctx, id)
  4090. }
  4091. })
  4092. return value, err
  4093. }
  4094. m.id = &id
  4095. }
  4096. }
  4097. // withApiKey sets the old ApiKey of the mutation.
  4098. func withApiKey(node *ApiKey) apikeyOption {
  4099. return func(m *ApiKeyMutation) {
  4100. m.oldValue = func(context.Context) (*ApiKey, error) {
  4101. return node, nil
  4102. }
  4103. m.id = &node.ID
  4104. }
  4105. }
  4106. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4107. // executed in a transaction (ent.Tx), a transactional client is returned.
  4108. func (m ApiKeyMutation) Client() *Client {
  4109. client := &Client{config: m.config}
  4110. client.init()
  4111. return client
  4112. }
  4113. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4114. // it returns an error otherwise.
  4115. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4116. if _, ok := m.driver.(*txDriver); !ok {
  4117. return nil, errors.New("ent: mutation is not running in a transaction")
  4118. }
  4119. tx := &Tx{config: m.config}
  4120. tx.init()
  4121. return tx, nil
  4122. }
  4123. // SetID sets the value of the id field. Note that this
  4124. // operation is only accepted on creation of ApiKey entities.
  4125. func (m *ApiKeyMutation) SetID(id uint64) {
  4126. m.id = &id
  4127. }
  4128. // ID returns the ID value in the mutation. Note that the ID is only available
  4129. // if it was provided to the builder or after it was returned from the database.
  4130. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4131. if m.id == nil {
  4132. return
  4133. }
  4134. return *m.id, true
  4135. }
  4136. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4137. // That means, if the mutation is applied within a transaction with an isolation level such
  4138. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4139. // or updated by the mutation.
  4140. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4141. switch {
  4142. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4143. id, exists := m.ID()
  4144. if exists {
  4145. return []uint64{id}, nil
  4146. }
  4147. fallthrough
  4148. case m.op.Is(OpUpdate | OpDelete):
  4149. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4150. default:
  4151. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4152. }
  4153. }
  4154. // SetCreatedAt sets the "created_at" field.
  4155. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4156. m.created_at = &t
  4157. }
  4158. // CreatedAt returns the value of the "created_at" field in the mutation.
  4159. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4160. v := m.created_at
  4161. if v == nil {
  4162. return
  4163. }
  4164. return *v, true
  4165. }
  4166. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4167. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4169. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4170. if !m.op.Is(OpUpdateOne) {
  4171. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4172. }
  4173. if m.id == nil || m.oldValue == nil {
  4174. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4175. }
  4176. oldValue, err := m.oldValue(ctx)
  4177. if err != nil {
  4178. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4179. }
  4180. return oldValue.CreatedAt, nil
  4181. }
  4182. // ResetCreatedAt resets all changes to the "created_at" field.
  4183. func (m *ApiKeyMutation) ResetCreatedAt() {
  4184. m.created_at = nil
  4185. }
  4186. // SetUpdatedAt sets the "updated_at" field.
  4187. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4188. m.updated_at = &t
  4189. }
  4190. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4191. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4192. v := m.updated_at
  4193. if v == nil {
  4194. return
  4195. }
  4196. return *v, true
  4197. }
  4198. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4199. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4201. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4202. if !m.op.Is(OpUpdateOne) {
  4203. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4204. }
  4205. if m.id == nil || m.oldValue == nil {
  4206. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4207. }
  4208. oldValue, err := m.oldValue(ctx)
  4209. if err != nil {
  4210. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4211. }
  4212. return oldValue.UpdatedAt, nil
  4213. }
  4214. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4215. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4216. m.updated_at = nil
  4217. }
  4218. // SetDeletedAt sets the "deleted_at" field.
  4219. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4220. m.deleted_at = &t
  4221. }
  4222. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4223. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4224. v := m.deleted_at
  4225. if v == nil {
  4226. return
  4227. }
  4228. return *v, true
  4229. }
  4230. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4231. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4233. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4234. if !m.op.Is(OpUpdateOne) {
  4235. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4236. }
  4237. if m.id == nil || m.oldValue == nil {
  4238. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4239. }
  4240. oldValue, err := m.oldValue(ctx)
  4241. if err != nil {
  4242. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4243. }
  4244. return oldValue.DeletedAt, nil
  4245. }
  4246. // ClearDeletedAt clears the value of the "deleted_at" field.
  4247. func (m *ApiKeyMutation) ClearDeletedAt() {
  4248. m.deleted_at = nil
  4249. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4250. }
  4251. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4252. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4253. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4254. return ok
  4255. }
  4256. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4257. func (m *ApiKeyMutation) ResetDeletedAt() {
  4258. m.deleted_at = nil
  4259. delete(m.clearedFields, apikey.FieldDeletedAt)
  4260. }
  4261. // SetTitle sets the "title" field.
  4262. func (m *ApiKeyMutation) SetTitle(s string) {
  4263. m.title = &s
  4264. }
  4265. // Title returns the value of the "title" field in the mutation.
  4266. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4267. v := m.title
  4268. if v == nil {
  4269. return
  4270. }
  4271. return *v, true
  4272. }
  4273. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4274. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4276. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4277. if !m.op.Is(OpUpdateOne) {
  4278. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4279. }
  4280. if m.id == nil || m.oldValue == nil {
  4281. return v, errors.New("OldTitle requires an ID field in the mutation")
  4282. }
  4283. oldValue, err := m.oldValue(ctx)
  4284. if err != nil {
  4285. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4286. }
  4287. return oldValue.Title, nil
  4288. }
  4289. // ClearTitle clears the value of the "title" field.
  4290. func (m *ApiKeyMutation) ClearTitle() {
  4291. m.title = nil
  4292. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4293. }
  4294. // TitleCleared returns if the "title" field was cleared in this mutation.
  4295. func (m *ApiKeyMutation) TitleCleared() bool {
  4296. _, ok := m.clearedFields[apikey.FieldTitle]
  4297. return ok
  4298. }
  4299. // ResetTitle resets all changes to the "title" field.
  4300. func (m *ApiKeyMutation) ResetTitle() {
  4301. m.title = nil
  4302. delete(m.clearedFields, apikey.FieldTitle)
  4303. }
  4304. // SetKey sets the "key" field.
  4305. func (m *ApiKeyMutation) SetKey(s string) {
  4306. m.key = &s
  4307. }
  4308. // Key returns the value of the "key" field in the mutation.
  4309. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4310. v := m.key
  4311. if v == nil {
  4312. return
  4313. }
  4314. return *v, true
  4315. }
  4316. // OldKey returns the old "key" field's value of the ApiKey entity.
  4317. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4319. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4320. if !m.op.Is(OpUpdateOne) {
  4321. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4322. }
  4323. if m.id == nil || m.oldValue == nil {
  4324. return v, errors.New("OldKey requires an ID field in the mutation")
  4325. }
  4326. oldValue, err := m.oldValue(ctx)
  4327. if err != nil {
  4328. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4329. }
  4330. return oldValue.Key, nil
  4331. }
  4332. // ClearKey clears the value of the "key" field.
  4333. func (m *ApiKeyMutation) ClearKey() {
  4334. m.key = nil
  4335. m.clearedFields[apikey.FieldKey] = struct{}{}
  4336. }
  4337. // KeyCleared returns if the "key" field was cleared in this mutation.
  4338. func (m *ApiKeyMutation) KeyCleared() bool {
  4339. _, ok := m.clearedFields[apikey.FieldKey]
  4340. return ok
  4341. }
  4342. // ResetKey resets all changes to the "key" field.
  4343. func (m *ApiKeyMutation) ResetKey() {
  4344. m.key = nil
  4345. delete(m.clearedFields, apikey.FieldKey)
  4346. }
  4347. // SetOrganizationID sets the "organization_id" field.
  4348. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4349. m.organization_id = &u
  4350. m.addorganization_id = nil
  4351. }
  4352. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4353. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4354. v := m.organization_id
  4355. if v == nil {
  4356. return
  4357. }
  4358. return *v, true
  4359. }
  4360. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4361. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4363. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4364. if !m.op.Is(OpUpdateOne) {
  4365. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4366. }
  4367. if m.id == nil || m.oldValue == nil {
  4368. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4369. }
  4370. oldValue, err := m.oldValue(ctx)
  4371. if err != nil {
  4372. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4373. }
  4374. return oldValue.OrganizationID, nil
  4375. }
  4376. // AddOrganizationID adds u to the "organization_id" field.
  4377. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4378. if m.addorganization_id != nil {
  4379. *m.addorganization_id += u
  4380. } else {
  4381. m.addorganization_id = &u
  4382. }
  4383. }
  4384. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4385. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4386. v := m.addorganization_id
  4387. if v == nil {
  4388. return
  4389. }
  4390. return *v, true
  4391. }
  4392. // ResetOrganizationID resets all changes to the "organization_id" field.
  4393. func (m *ApiKeyMutation) ResetOrganizationID() {
  4394. m.organization_id = nil
  4395. m.addorganization_id = nil
  4396. }
  4397. // SetAgentID sets the "agent_id" field.
  4398. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4399. m.agent = &u
  4400. }
  4401. // AgentID returns the value of the "agent_id" field in the mutation.
  4402. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4403. v := m.agent
  4404. if v == nil {
  4405. return
  4406. }
  4407. return *v, true
  4408. }
  4409. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4410. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4412. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4413. if !m.op.Is(OpUpdateOne) {
  4414. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4415. }
  4416. if m.id == nil || m.oldValue == nil {
  4417. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4418. }
  4419. oldValue, err := m.oldValue(ctx)
  4420. if err != nil {
  4421. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4422. }
  4423. return oldValue.AgentID, nil
  4424. }
  4425. // ResetAgentID resets all changes to the "agent_id" field.
  4426. func (m *ApiKeyMutation) ResetAgentID() {
  4427. m.agent = nil
  4428. }
  4429. // SetCustomAgentBase sets the "custom_agent_base" field.
  4430. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4431. m.custom_agent_base = &s
  4432. }
  4433. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4434. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4435. v := m.custom_agent_base
  4436. if v == nil {
  4437. return
  4438. }
  4439. return *v, true
  4440. }
  4441. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4442. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4444. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4445. if !m.op.Is(OpUpdateOne) {
  4446. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4447. }
  4448. if m.id == nil || m.oldValue == nil {
  4449. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4450. }
  4451. oldValue, err := m.oldValue(ctx)
  4452. if err != nil {
  4453. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4454. }
  4455. return oldValue.CustomAgentBase, nil
  4456. }
  4457. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4458. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4459. m.custom_agent_base = nil
  4460. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4461. }
  4462. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4463. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4464. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4465. return ok
  4466. }
  4467. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4468. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4469. m.custom_agent_base = nil
  4470. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4471. }
  4472. // SetCustomAgentKey sets the "custom_agent_key" field.
  4473. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4474. m.custom_agent_key = &s
  4475. }
  4476. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4477. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4478. v := m.custom_agent_key
  4479. if v == nil {
  4480. return
  4481. }
  4482. return *v, true
  4483. }
  4484. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4485. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4487. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4488. if !m.op.Is(OpUpdateOne) {
  4489. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4490. }
  4491. if m.id == nil || m.oldValue == nil {
  4492. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4493. }
  4494. oldValue, err := m.oldValue(ctx)
  4495. if err != nil {
  4496. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4497. }
  4498. return oldValue.CustomAgentKey, nil
  4499. }
  4500. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4501. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4502. m.custom_agent_key = nil
  4503. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4504. }
  4505. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4506. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4507. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4508. return ok
  4509. }
  4510. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4511. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4512. m.custom_agent_key = nil
  4513. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4514. }
  4515. // SetOpenaiBase sets the "openai_base" field.
  4516. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4517. m.openai_base = &s
  4518. }
  4519. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4520. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4521. v := m.openai_base
  4522. if v == nil {
  4523. return
  4524. }
  4525. return *v, true
  4526. }
  4527. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4528. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4530. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4531. if !m.op.Is(OpUpdateOne) {
  4532. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4533. }
  4534. if m.id == nil || m.oldValue == nil {
  4535. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4536. }
  4537. oldValue, err := m.oldValue(ctx)
  4538. if err != nil {
  4539. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4540. }
  4541. return oldValue.OpenaiBase, nil
  4542. }
  4543. // ClearOpenaiBase clears the value of the "openai_base" field.
  4544. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4545. m.openai_base = nil
  4546. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4547. }
  4548. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4549. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4550. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4551. return ok
  4552. }
  4553. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4554. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4555. m.openai_base = nil
  4556. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4557. }
  4558. // SetOpenaiKey sets the "openai_key" field.
  4559. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4560. m.openai_key = &s
  4561. }
  4562. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4563. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4564. v := m.openai_key
  4565. if v == nil {
  4566. return
  4567. }
  4568. return *v, true
  4569. }
  4570. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4571. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4573. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4574. if !m.op.Is(OpUpdateOne) {
  4575. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4576. }
  4577. if m.id == nil || m.oldValue == nil {
  4578. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4579. }
  4580. oldValue, err := m.oldValue(ctx)
  4581. if err != nil {
  4582. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4583. }
  4584. return oldValue.OpenaiKey, nil
  4585. }
  4586. // ClearOpenaiKey clears the value of the "openai_key" field.
  4587. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4588. m.openai_key = nil
  4589. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4590. }
  4591. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4592. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4593. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4594. return ok
  4595. }
  4596. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4597. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4598. m.openai_key = nil
  4599. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4600. }
  4601. // ClearAgent clears the "agent" edge to the Agent entity.
  4602. func (m *ApiKeyMutation) ClearAgent() {
  4603. m.clearedagent = true
  4604. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4605. }
  4606. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4607. func (m *ApiKeyMutation) AgentCleared() bool {
  4608. return m.clearedagent
  4609. }
  4610. // AgentIDs returns the "agent" edge IDs in the mutation.
  4611. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4612. // AgentID instead. It exists only for internal usage by the builders.
  4613. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4614. if id := m.agent; id != nil {
  4615. ids = append(ids, *id)
  4616. }
  4617. return
  4618. }
  4619. // ResetAgent resets all changes to the "agent" edge.
  4620. func (m *ApiKeyMutation) ResetAgent() {
  4621. m.agent = nil
  4622. m.clearedagent = false
  4623. }
  4624. // Where appends a list predicates to the ApiKeyMutation builder.
  4625. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4626. m.predicates = append(m.predicates, ps...)
  4627. }
  4628. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4629. // users can use type-assertion to append predicates that do not depend on any generated package.
  4630. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4631. p := make([]predicate.ApiKey, len(ps))
  4632. for i := range ps {
  4633. p[i] = ps[i]
  4634. }
  4635. m.Where(p...)
  4636. }
  4637. // Op returns the operation name.
  4638. func (m *ApiKeyMutation) Op() Op {
  4639. return m.op
  4640. }
  4641. // SetOp allows setting the mutation operation.
  4642. func (m *ApiKeyMutation) SetOp(op Op) {
  4643. m.op = op
  4644. }
  4645. // Type returns the node type of this mutation (ApiKey).
  4646. func (m *ApiKeyMutation) Type() string {
  4647. return m.typ
  4648. }
  4649. // Fields returns all fields that were changed during this mutation. Note that in
  4650. // order to get all numeric fields that were incremented/decremented, call
  4651. // AddedFields().
  4652. func (m *ApiKeyMutation) Fields() []string {
  4653. fields := make([]string, 0, 11)
  4654. if m.created_at != nil {
  4655. fields = append(fields, apikey.FieldCreatedAt)
  4656. }
  4657. if m.updated_at != nil {
  4658. fields = append(fields, apikey.FieldUpdatedAt)
  4659. }
  4660. if m.deleted_at != nil {
  4661. fields = append(fields, apikey.FieldDeletedAt)
  4662. }
  4663. if m.title != nil {
  4664. fields = append(fields, apikey.FieldTitle)
  4665. }
  4666. if m.key != nil {
  4667. fields = append(fields, apikey.FieldKey)
  4668. }
  4669. if m.organization_id != nil {
  4670. fields = append(fields, apikey.FieldOrganizationID)
  4671. }
  4672. if m.agent != nil {
  4673. fields = append(fields, apikey.FieldAgentID)
  4674. }
  4675. if m.custom_agent_base != nil {
  4676. fields = append(fields, apikey.FieldCustomAgentBase)
  4677. }
  4678. if m.custom_agent_key != nil {
  4679. fields = append(fields, apikey.FieldCustomAgentKey)
  4680. }
  4681. if m.openai_base != nil {
  4682. fields = append(fields, apikey.FieldOpenaiBase)
  4683. }
  4684. if m.openai_key != nil {
  4685. fields = append(fields, apikey.FieldOpenaiKey)
  4686. }
  4687. return fields
  4688. }
  4689. // Field returns the value of a field with the given name. The second boolean
  4690. // return value indicates that this field was not set, or was not defined in the
  4691. // schema.
  4692. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  4693. switch name {
  4694. case apikey.FieldCreatedAt:
  4695. return m.CreatedAt()
  4696. case apikey.FieldUpdatedAt:
  4697. return m.UpdatedAt()
  4698. case apikey.FieldDeletedAt:
  4699. return m.DeletedAt()
  4700. case apikey.FieldTitle:
  4701. return m.Title()
  4702. case apikey.FieldKey:
  4703. return m.Key()
  4704. case apikey.FieldOrganizationID:
  4705. return m.OrganizationID()
  4706. case apikey.FieldAgentID:
  4707. return m.AgentID()
  4708. case apikey.FieldCustomAgentBase:
  4709. return m.CustomAgentBase()
  4710. case apikey.FieldCustomAgentKey:
  4711. return m.CustomAgentKey()
  4712. case apikey.FieldOpenaiBase:
  4713. return m.OpenaiBase()
  4714. case apikey.FieldOpenaiKey:
  4715. return m.OpenaiKey()
  4716. }
  4717. return nil, false
  4718. }
  4719. // OldField returns the old value of the field from the database. An error is
  4720. // returned if the mutation operation is not UpdateOne, or the query to the
  4721. // database failed.
  4722. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4723. switch name {
  4724. case apikey.FieldCreatedAt:
  4725. return m.OldCreatedAt(ctx)
  4726. case apikey.FieldUpdatedAt:
  4727. return m.OldUpdatedAt(ctx)
  4728. case apikey.FieldDeletedAt:
  4729. return m.OldDeletedAt(ctx)
  4730. case apikey.FieldTitle:
  4731. return m.OldTitle(ctx)
  4732. case apikey.FieldKey:
  4733. return m.OldKey(ctx)
  4734. case apikey.FieldOrganizationID:
  4735. return m.OldOrganizationID(ctx)
  4736. case apikey.FieldAgentID:
  4737. return m.OldAgentID(ctx)
  4738. case apikey.FieldCustomAgentBase:
  4739. return m.OldCustomAgentBase(ctx)
  4740. case apikey.FieldCustomAgentKey:
  4741. return m.OldCustomAgentKey(ctx)
  4742. case apikey.FieldOpenaiBase:
  4743. return m.OldOpenaiBase(ctx)
  4744. case apikey.FieldOpenaiKey:
  4745. return m.OldOpenaiKey(ctx)
  4746. }
  4747. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  4748. }
  4749. // SetField sets the value of a field with the given name. It returns an error if
  4750. // the field is not defined in the schema, or if the type mismatched the field
  4751. // type.
  4752. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  4753. switch name {
  4754. case apikey.FieldCreatedAt:
  4755. v, ok := value.(time.Time)
  4756. if !ok {
  4757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4758. }
  4759. m.SetCreatedAt(v)
  4760. return nil
  4761. case apikey.FieldUpdatedAt:
  4762. v, ok := value.(time.Time)
  4763. if !ok {
  4764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4765. }
  4766. m.SetUpdatedAt(v)
  4767. return nil
  4768. case apikey.FieldDeletedAt:
  4769. v, ok := value.(time.Time)
  4770. if !ok {
  4771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4772. }
  4773. m.SetDeletedAt(v)
  4774. return nil
  4775. case apikey.FieldTitle:
  4776. v, ok := value.(string)
  4777. if !ok {
  4778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4779. }
  4780. m.SetTitle(v)
  4781. return nil
  4782. case apikey.FieldKey:
  4783. v, ok := value.(string)
  4784. if !ok {
  4785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4786. }
  4787. m.SetKey(v)
  4788. return nil
  4789. case apikey.FieldOrganizationID:
  4790. v, ok := value.(uint64)
  4791. if !ok {
  4792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4793. }
  4794. m.SetOrganizationID(v)
  4795. return nil
  4796. case apikey.FieldAgentID:
  4797. v, ok := value.(uint64)
  4798. if !ok {
  4799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4800. }
  4801. m.SetAgentID(v)
  4802. return nil
  4803. case apikey.FieldCustomAgentBase:
  4804. v, ok := value.(string)
  4805. if !ok {
  4806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4807. }
  4808. m.SetCustomAgentBase(v)
  4809. return nil
  4810. case apikey.FieldCustomAgentKey:
  4811. v, ok := value.(string)
  4812. if !ok {
  4813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4814. }
  4815. m.SetCustomAgentKey(v)
  4816. return nil
  4817. case apikey.FieldOpenaiBase:
  4818. v, ok := value.(string)
  4819. if !ok {
  4820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4821. }
  4822. m.SetOpenaiBase(v)
  4823. return nil
  4824. case apikey.FieldOpenaiKey:
  4825. v, ok := value.(string)
  4826. if !ok {
  4827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4828. }
  4829. m.SetOpenaiKey(v)
  4830. return nil
  4831. }
  4832. return fmt.Errorf("unknown ApiKey field %s", name)
  4833. }
  4834. // AddedFields returns all numeric fields that were incremented/decremented during
  4835. // this mutation.
  4836. func (m *ApiKeyMutation) AddedFields() []string {
  4837. var fields []string
  4838. if m.addorganization_id != nil {
  4839. fields = append(fields, apikey.FieldOrganizationID)
  4840. }
  4841. return fields
  4842. }
  4843. // AddedField returns the numeric value that was incremented/decremented on a field
  4844. // with the given name. The second boolean return value indicates that this field
  4845. // was not set, or was not defined in the schema.
  4846. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  4847. switch name {
  4848. case apikey.FieldOrganizationID:
  4849. return m.AddedOrganizationID()
  4850. }
  4851. return nil, false
  4852. }
  4853. // AddField adds the value to the field with the given name. It returns an error if
  4854. // the field is not defined in the schema, or if the type mismatched the field
  4855. // type.
  4856. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  4857. switch name {
  4858. case apikey.FieldOrganizationID:
  4859. v, ok := value.(int64)
  4860. if !ok {
  4861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4862. }
  4863. m.AddOrganizationID(v)
  4864. return nil
  4865. }
  4866. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  4867. }
  4868. // ClearedFields returns all nullable fields that were cleared during this
  4869. // mutation.
  4870. func (m *ApiKeyMutation) ClearedFields() []string {
  4871. var fields []string
  4872. if m.FieldCleared(apikey.FieldDeletedAt) {
  4873. fields = append(fields, apikey.FieldDeletedAt)
  4874. }
  4875. if m.FieldCleared(apikey.FieldTitle) {
  4876. fields = append(fields, apikey.FieldTitle)
  4877. }
  4878. if m.FieldCleared(apikey.FieldKey) {
  4879. fields = append(fields, apikey.FieldKey)
  4880. }
  4881. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  4882. fields = append(fields, apikey.FieldCustomAgentBase)
  4883. }
  4884. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  4885. fields = append(fields, apikey.FieldCustomAgentKey)
  4886. }
  4887. if m.FieldCleared(apikey.FieldOpenaiBase) {
  4888. fields = append(fields, apikey.FieldOpenaiBase)
  4889. }
  4890. if m.FieldCleared(apikey.FieldOpenaiKey) {
  4891. fields = append(fields, apikey.FieldOpenaiKey)
  4892. }
  4893. return fields
  4894. }
  4895. // FieldCleared returns a boolean indicating if a field with the given name was
  4896. // cleared in this mutation.
  4897. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  4898. _, ok := m.clearedFields[name]
  4899. return ok
  4900. }
  4901. // ClearField clears the value of the field with the given name. It returns an
  4902. // error if the field is not defined in the schema.
  4903. func (m *ApiKeyMutation) ClearField(name string) error {
  4904. switch name {
  4905. case apikey.FieldDeletedAt:
  4906. m.ClearDeletedAt()
  4907. return nil
  4908. case apikey.FieldTitle:
  4909. m.ClearTitle()
  4910. return nil
  4911. case apikey.FieldKey:
  4912. m.ClearKey()
  4913. return nil
  4914. case apikey.FieldCustomAgentBase:
  4915. m.ClearCustomAgentBase()
  4916. return nil
  4917. case apikey.FieldCustomAgentKey:
  4918. m.ClearCustomAgentKey()
  4919. return nil
  4920. case apikey.FieldOpenaiBase:
  4921. m.ClearOpenaiBase()
  4922. return nil
  4923. case apikey.FieldOpenaiKey:
  4924. m.ClearOpenaiKey()
  4925. return nil
  4926. }
  4927. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  4928. }
  4929. // ResetField resets all changes in the mutation for the field with the given name.
  4930. // It returns an error if the field is not defined in the schema.
  4931. func (m *ApiKeyMutation) ResetField(name string) error {
  4932. switch name {
  4933. case apikey.FieldCreatedAt:
  4934. m.ResetCreatedAt()
  4935. return nil
  4936. case apikey.FieldUpdatedAt:
  4937. m.ResetUpdatedAt()
  4938. return nil
  4939. case apikey.FieldDeletedAt:
  4940. m.ResetDeletedAt()
  4941. return nil
  4942. case apikey.FieldTitle:
  4943. m.ResetTitle()
  4944. return nil
  4945. case apikey.FieldKey:
  4946. m.ResetKey()
  4947. return nil
  4948. case apikey.FieldOrganizationID:
  4949. m.ResetOrganizationID()
  4950. return nil
  4951. case apikey.FieldAgentID:
  4952. m.ResetAgentID()
  4953. return nil
  4954. case apikey.FieldCustomAgentBase:
  4955. m.ResetCustomAgentBase()
  4956. return nil
  4957. case apikey.FieldCustomAgentKey:
  4958. m.ResetCustomAgentKey()
  4959. return nil
  4960. case apikey.FieldOpenaiBase:
  4961. m.ResetOpenaiBase()
  4962. return nil
  4963. case apikey.FieldOpenaiKey:
  4964. m.ResetOpenaiKey()
  4965. return nil
  4966. }
  4967. return fmt.Errorf("unknown ApiKey field %s", name)
  4968. }
  4969. // AddedEdges returns all edge names that were set/added in this mutation.
  4970. func (m *ApiKeyMutation) AddedEdges() []string {
  4971. edges := make([]string, 0, 1)
  4972. if m.agent != nil {
  4973. edges = append(edges, apikey.EdgeAgent)
  4974. }
  4975. return edges
  4976. }
  4977. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4978. // name in this mutation.
  4979. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  4980. switch name {
  4981. case apikey.EdgeAgent:
  4982. if id := m.agent; id != nil {
  4983. return []ent.Value{*id}
  4984. }
  4985. }
  4986. return nil
  4987. }
  4988. // RemovedEdges returns all edge names that were removed in this mutation.
  4989. func (m *ApiKeyMutation) RemovedEdges() []string {
  4990. edges := make([]string, 0, 1)
  4991. return edges
  4992. }
  4993. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4994. // the given name in this mutation.
  4995. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  4996. return nil
  4997. }
  4998. // ClearedEdges returns all edge names that were cleared in this mutation.
  4999. func (m *ApiKeyMutation) ClearedEdges() []string {
  5000. edges := make([]string, 0, 1)
  5001. if m.clearedagent {
  5002. edges = append(edges, apikey.EdgeAgent)
  5003. }
  5004. return edges
  5005. }
  5006. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5007. // was cleared in this mutation.
  5008. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5009. switch name {
  5010. case apikey.EdgeAgent:
  5011. return m.clearedagent
  5012. }
  5013. return false
  5014. }
  5015. // ClearEdge clears the value of the edge with the given name. It returns an error
  5016. // if that edge is not defined in the schema.
  5017. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5018. switch name {
  5019. case apikey.EdgeAgent:
  5020. m.ClearAgent()
  5021. return nil
  5022. }
  5023. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5024. }
  5025. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5026. // It returns an error if the edge is not defined in the schema.
  5027. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5028. switch name {
  5029. case apikey.EdgeAgent:
  5030. m.ResetAgent()
  5031. return nil
  5032. }
  5033. return fmt.Errorf("unknown ApiKey edge %s", name)
  5034. }
  5035. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5036. type BatchMsgMutation struct {
  5037. config
  5038. op Op
  5039. typ string
  5040. id *uint64
  5041. created_at *time.Time
  5042. updated_at *time.Time
  5043. deleted_at *time.Time
  5044. status *uint8
  5045. addstatus *int8
  5046. batch_no *string
  5047. task_name *string
  5048. fromwxid *string
  5049. msg *string
  5050. tag *string
  5051. tagids *string
  5052. total *int32
  5053. addtotal *int32
  5054. success *int32
  5055. addsuccess *int32
  5056. fail *int32
  5057. addfail *int32
  5058. start_time *time.Time
  5059. stop_time *time.Time
  5060. send_time *time.Time
  5061. _type *int32
  5062. add_type *int32
  5063. organization_id *uint64
  5064. addorganization_id *int64
  5065. ctype *uint64
  5066. addctype *int64
  5067. cc *string
  5068. phone *string
  5069. template_name *string
  5070. template_code *string
  5071. lang *string
  5072. clearedFields map[string]struct{}
  5073. done bool
  5074. oldValue func(context.Context) (*BatchMsg, error)
  5075. predicates []predicate.BatchMsg
  5076. }
  5077. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5078. // batchmsgOption allows management of the mutation configuration using functional options.
  5079. type batchmsgOption func(*BatchMsgMutation)
  5080. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5081. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5082. m := &BatchMsgMutation{
  5083. config: c,
  5084. op: op,
  5085. typ: TypeBatchMsg,
  5086. clearedFields: make(map[string]struct{}),
  5087. }
  5088. for _, opt := range opts {
  5089. opt(m)
  5090. }
  5091. return m
  5092. }
  5093. // withBatchMsgID sets the ID field of the mutation.
  5094. func withBatchMsgID(id uint64) batchmsgOption {
  5095. return func(m *BatchMsgMutation) {
  5096. var (
  5097. err error
  5098. once sync.Once
  5099. value *BatchMsg
  5100. )
  5101. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5102. once.Do(func() {
  5103. if m.done {
  5104. err = errors.New("querying old values post mutation is not allowed")
  5105. } else {
  5106. value, err = m.Client().BatchMsg.Get(ctx, id)
  5107. }
  5108. })
  5109. return value, err
  5110. }
  5111. m.id = &id
  5112. }
  5113. }
  5114. // withBatchMsg sets the old BatchMsg of the mutation.
  5115. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5116. return func(m *BatchMsgMutation) {
  5117. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5118. return node, nil
  5119. }
  5120. m.id = &node.ID
  5121. }
  5122. }
  5123. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5124. // executed in a transaction (ent.Tx), a transactional client is returned.
  5125. func (m BatchMsgMutation) Client() *Client {
  5126. client := &Client{config: m.config}
  5127. client.init()
  5128. return client
  5129. }
  5130. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5131. // it returns an error otherwise.
  5132. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5133. if _, ok := m.driver.(*txDriver); !ok {
  5134. return nil, errors.New("ent: mutation is not running in a transaction")
  5135. }
  5136. tx := &Tx{config: m.config}
  5137. tx.init()
  5138. return tx, nil
  5139. }
  5140. // SetID sets the value of the id field. Note that this
  5141. // operation is only accepted on creation of BatchMsg entities.
  5142. func (m *BatchMsgMutation) SetID(id uint64) {
  5143. m.id = &id
  5144. }
  5145. // ID returns the ID value in the mutation. Note that the ID is only available
  5146. // if it was provided to the builder or after it was returned from the database.
  5147. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5148. if m.id == nil {
  5149. return
  5150. }
  5151. return *m.id, true
  5152. }
  5153. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5154. // That means, if the mutation is applied within a transaction with an isolation level such
  5155. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5156. // or updated by the mutation.
  5157. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5158. switch {
  5159. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5160. id, exists := m.ID()
  5161. if exists {
  5162. return []uint64{id}, nil
  5163. }
  5164. fallthrough
  5165. case m.op.Is(OpUpdate | OpDelete):
  5166. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5167. default:
  5168. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5169. }
  5170. }
  5171. // SetCreatedAt sets the "created_at" field.
  5172. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5173. m.created_at = &t
  5174. }
  5175. // CreatedAt returns the value of the "created_at" field in the mutation.
  5176. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5177. v := m.created_at
  5178. if v == nil {
  5179. return
  5180. }
  5181. return *v, true
  5182. }
  5183. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5184. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5186. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5187. if !m.op.Is(OpUpdateOne) {
  5188. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5189. }
  5190. if m.id == nil || m.oldValue == nil {
  5191. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5192. }
  5193. oldValue, err := m.oldValue(ctx)
  5194. if err != nil {
  5195. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5196. }
  5197. return oldValue.CreatedAt, nil
  5198. }
  5199. // ResetCreatedAt resets all changes to the "created_at" field.
  5200. func (m *BatchMsgMutation) ResetCreatedAt() {
  5201. m.created_at = nil
  5202. }
  5203. // SetUpdatedAt sets the "updated_at" field.
  5204. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5205. m.updated_at = &t
  5206. }
  5207. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5208. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5209. v := m.updated_at
  5210. if v == nil {
  5211. return
  5212. }
  5213. return *v, true
  5214. }
  5215. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5216. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5218. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5219. if !m.op.Is(OpUpdateOne) {
  5220. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5221. }
  5222. if m.id == nil || m.oldValue == nil {
  5223. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5224. }
  5225. oldValue, err := m.oldValue(ctx)
  5226. if err != nil {
  5227. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5228. }
  5229. return oldValue.UpdatedAt, nil
  5230. }
  5231. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5232. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5233. m.updated_at = nil
  5234. }
  5235. // SetDeletedAt sets the "deleted_at" field.
  5236. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5237. m.deleted_at = &t
  5238. }
  5239. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5240. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5241. v := m.deleted_at
  5242. if v == nil {
  5243. return
  5244. }
  5245. return *v, true
  5246. }
  5247. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5248. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5250. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5251. if !m.op.Is(OpUpdateOne) {
  5252. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5253. }
  5254. if m.id == nil || m.oldValue == nil {
  5255. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5256. }
  5257. oldValue, err := m.oldValue(ctx)
  5258. if err != nil {
  5259. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5260. }
  5261. return oldValue.DeletedAt, nil
  5262. }
  5263. // ClearDeletedAt clears the value of the "deleted_at" field.
  5264. func (m *BatchMsgMutation) ClearDeletedAt() {
  5265. m.deleted_at = nil
  5266. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5267. }
  5268. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5269. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5270. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5271. return ok
  5272. }
  5273. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5274. func (m *BatchMsgMutation) ResetDeletedAt() {
  5275. m.deleted_at = nil
  5276. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5277. }
  5278. // SetStatus sets the "status" field.
  5279. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5280. m.status = &u
  5281. m.addstatus = nil
  5282. }
  5283. // Status returns the value of the "status" field in the mutation.
  5284. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5285. v := m.status
  5286. if v == nil {
  5287. return
  5288. }
  5289. return *v, true
  5290. }
  5291. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5292. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5294. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5295. if !m.op.Is(OpUpdateOne) {
  5296. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5297. }
  5298. if m.id == nil || m.oldValue == nil {
  5299. return v, errors.New("OldStatus requires an ID field in the mutation")
  5300. }
  5301. oldValue, err := m.oldValue(ctx)
  5302. if err != nil {
  5303. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5304. }
  5305. return oldValue.Status, nil
  5306. }
  5307. // AddStatus adds u to the "status" field.
  5308. func (m *BatchMsgMutation) AddStatus(u int8) {
  5309. if m.addstatus != nil {
  5310. *m.addstatus += u
  5311. } else {
  5312. m.addstatus = &u
  5313. }
  5314. }
  5315. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5316. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5317. v := m.addstatus
  5318. if v == nil {
  5319. return
  5320. }
  5321. return *v, true
  5322. }
  5323. // ClearStatus clears the value of the "status" field.
  5324. func (m *BatchMsgMutation) ClearStatus() {
  5325. m.status = nil
  5326. m.addstatus = nil
  5327. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5328. }
  5329. // StatusCleared returns if the "status" field was cleared in this mutation.
  5330. func (m *BatchMsgMutation) StatusCleared() bool {
  5331. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5332. return ok
  5333. }
  5334. // ResetStatus resets all changes to the "status" field.
  5335. func (m *BatchMsgMutation) ResetStatus() {
  5336. m.status = nil
  5337. m.addstatus = nil
  5338. delete(m.clearedFields, batchmsg.FieldStatus)
  5339. }
  5340. // SetBatchNo sets the "batch_no" field.
  5341. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5342. m.batch_no = &s
  5343. }
  5344. // BatchNo returns the value of the "batch_no" field in the mutation.
  5345. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5346. v := m.batch_no
  5347. if v == nil {
  5348. return
  5349. }
  5350. return *v, true
  5351. }
  5352. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5353. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5355. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5356. if !m.op.Is(OpUpdateOne) {
  5357. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5358. }
  5359. if m.id == nil || m.oldValue == nil {
  5360. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5361. }
  5362. oldValue, err := m.oldValue(ctx)
  5363. if err != nil {
  5364. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5365. }
  5366. return oldValue.BatchNo, nil
  5367. }
  5368. // ClearBatchNo clears the value of the "batch_no" field.
  5369. func (m *BatchMsgMutation) ClearBatchNo() {
  5370. m.batch_no = nil
  5371. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5372. }
  5373. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5374. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5375. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5376. return ok
  5377. }
  5378. // ResetBatchNo resets all changes to the "batch_no" field.
  5379. func (m *BatchMsgMutation) ResetBatchNo() {
  5380. m.batch_no = nil
  5381. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5382. }
  5383. // SetTaskName sets the "task_name" field.
  5384. func (m *BatchMsgMutation) SetTaskName(s string) {
  5385. m.task_name = &s
  5386. }
  5387. // TaskName returns the value of the "task_name" field in the mutation.
  5388. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5389. v := m.task_name
  5390. if v == nil {
  5391. return
  5392. }
  5393. return *v, true
  5394. }
  5395. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5396. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5398. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5399. if !m.op.Is(OpUpdateOne) {
  5400. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5401. }
  5402. if m.id == nil || m.oldValue == nil {
  5403. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5404. }
  5405. oldValue, err := m.oldValue(ctx)
  5406. if err != nil {
  5407. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5408. }
  5409. return oldValue.TaskName, nil
  5410. }
  5411. // ClearTaskName clears the value of the "task_name" field.
  5412. func (m *BatchMsgMutation) ClearTaskName() {
  5413. m.task_name = nil
  5414. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5415. }
  5416. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5417. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5418. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5419. return ok
  5420. }
  5421. // ResetTaskName resets all changes to the "task_name" field.
  5422. func (m *BatchMsgMutation) ResetTaskName() {
  5423. m.task_name = nil
  5424. delete(m.clearedFields, batchmsg.FieldTaskName)
  5425. }
  5426. // SetFromwxid sets the "fromwxid" field.
  5427. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5428. m.fromwxid = &s
  5429. }
  5430. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5431. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5432. v := m.fromwxid
  5433. if v == nil {
  5434. return
  5435. }
  5436. return *v, true
  5437. }
  5438. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5439. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5441. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5442. if !m.op.Is(OpUpdateOne) {
  5443. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5444. }
  5445. if m.id == nil || m.oldValue == nil {
  5446. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5447. }
  5448. oldValue, err := m.oldValue(ctx)
  5449. if err != nil {
  5450. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5451. }
  5452. return oldValue.Fromwxid, nil
  5453. }
  5454. // ClearFromwxid clears the value of the "fromwxid" field.
  5455. func (m *BatchMsgMutation) ClearFromwxid() {
  5456. m.fromwxid = nil
  5457. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5458. }
  5459. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5460. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5461. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5462. return ok
  5463. }
  5464. // ResetFromwxid resets all changes to the "fromwxid" field.
  5465. func (m *BatchMsgMutation) ResetFromwxid() {
  5466. m.fromwxid = nil
  5467. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5468. }
  5469. // SetMsg sets the "msg" field.
  5470. func (m *BatchMsgMutation) SetMsg(s string) {
  5471. m.msg = &s
  5472. }
  5473. // Msg returns the value of the "msg" field in the mutation.
  5474. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5475. v := m.msg
  5476. if v == nil {
  5477. return
  5478. }
  5479. return *v, true
  5480. }
  5481. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5482. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5484. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5485. if !m.op.Is(OpUpdateOne) {
  5486. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5487. }
  5488. if m.id == nil || m.oldValue == nil {
  5489. return v, errors.New("OldMsg requires an ID field in the mutation")
  5490. }
  5491. oldValue, err := m.oldValue(ctx)
  5492. if err != nil {
  5493. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5494. }
  5495. return oldValue.Msg, nil
  5496. }
  5497. // ClearMsg clears the value of the "msg" field.
  5498. func (m *BatchMsgMutation) ClearMsg() {
  5499. m.msg = nil
  5500. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5501. }
  5502. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5503. func (m *BatchMsgMutation) MsgCleared() bool {
  5504. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5505. return ok
  5506. }
  5507. // ResetMsg resets all changes to the "msg" field.
  5508. func (m *BatchMsgMutation) ResetMsg() {
  5509. m.msg = nil
  5510. delete(m.clearedFields, batchmsg.FieldMsg)
  5511. }
  5512. // SetTag sets the "tag" field.
  5513. func (m *BatchMsgMutation) SetTag(s string) {
  5514. m.tag = &s
  5515. }
  5516. // Tag returns the value of the "tag" field in the mutation.
  5517. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5518. v := m.tag
  5519. if v == nil {
  5520. return
  5521. }
  5522. return *v, true
  5523. }
  5524. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5525. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5527. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5528. if !m.op.Is(OpUpdateOne) {
  5529. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5530. }
  5531. if m.id == nil || m.oldValue == nil {
  5532. return v, errors.New("OldTag requires an ID field in the mutation")
  5533. }
  5534. oldValue, err := m.oldValue(ctx)
  5535. if err != nil {
  5536. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5537. }
  5538. return oldValue.Tag, nil
  5539. }
  5540. // ClearTag clears the value of the "tag" field.
  5541. func (m *BatchMsgMutation) ClearTag() {
  5542. m.tag = nil
  5543. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5544. }
  5545. // TagCleared returns if the "tag" field was cleared in this mutation.
  5546. func (m *BatchMsgMutation) TagCleared() bool {
  5547. _, ok := m.clearedFields[batchmsg.FieldTag]
  5548. return ok
  5549. }
  5550. // ResetTag resets all changes to the "tag" field.
  5551. func (m *BatchMsgMutation) ResetTag() {
  5552. m.tag = nil
  5553. delete(m.clearedFields, batchmsg.FieldTag)
  5554. }
  5555. // SetTagids sets the "tagids" field.
  5556. func (m *BatchMsgMutation) SetTagids(s string) {
  5557. m.tagids = &s
  5558. }
  5559. // Tagids returns the value of the "tagids" field in the mutation.
  5560. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5561. v := m.tagids
  5562. if v == nil {
  5563. return
  5564. }
  5565. return *v, true
  5566. }
  5567. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5568. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5570. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5571. if !m.op.Is(OpUpdateOne) {
  5572. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5573. }
  5574. if m.id == nil || m.oldValue == nil {
  5575. return v, errors.New("OldTagids requires an ID field in the mutation")
  5576. }
  5577. oldValue, err := m.oldValue(ctx)
  5578. if err != nil {
  5579. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5580. }
  5581. return oldValue.Tagids, nil
  5582. }
  5583. // ClearTagids clears the value of the "tagids" field.
  5584. func (m *BatchMsgMutation) ClearTagids() {
  5585. m.tagids = nil
  5586. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5587. }
  5588. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5589. func (m *BatchMsgMutation) TagidsCleared() bool {
  5590. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5591. return ok
  5592. }
  5593. // ResetTagids resets all changes to the "tagids" field.
  5594. func (m *BatchMsgMutation) ResetTagids() {
  5595. m.tagids = nil
  5596. delete(m.clearedFields, batchmsg.FieldTagids)
  5597. }
  5598. // SetTotal sets the "total" field.
  5599. func (m *BatchMsgMutation) SetTotal(i int32) {
  5600. m.total = &i
  5601. m.addtotal = nil
  5602. }
  5603. // Total returns the value of the "total" field in the mutation.
  5604. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5605. v := m.total
  5606. if v == nil {
  5607. return
  5608. }
  5609. return *v, true
  5610. }
  5611. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5612. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5614. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5615. if !m.op.Is(OpUpdateOne) {
  5616. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5617. }
  5618. if m.id == nil || m.oldValue == nil {
  5619. return v, errors.New("OldTotal requires an ID field in the mutation")
  5620. }
  5621. oldValue, err := m.oldValue(ctx)
  5622. if err != nil {
  5623. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5624. }
  5625. return oldValue.Total, nil
  5626. }
  5627. // AddTotal adds i to the "total" field.
  5628. func (m *BatchMsgMutation) AddTotal(i int32) {
  5629. if m.addtotal != nil {
  5630. *m.addtotal += i
  5631. } else {
  5632. m.addtotal = &i
  5633. }
  5634. }
  5635. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5636. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5637. v := m.addtotal
  5638. if v == nil {
  5639. return
  5640. }
  5641. return *v, true
  5642. }
  5643. // ClearTotal clears the value of the "total" field.
  5644. func (m *BatchMsgMutation) ClearTotal() {
  5645. m.total = nil
  5646. m.addtotal = nil
  5647. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5648. }
  5649. // TotalCleared returns if the "total" field was cleared in this mutation.
  5650. func (m *BatchMsgMutation) TotalCleared() bool {
  5651. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5652. return ok
  5653. }
  5654. // ResetTotal resets all changes to the "total" field.
  5655. func (m *BatchMsgMutation) ResetTotal() {
  5656. m.total = nil
  5657. m.addtotal = nil
  5658. delete(m.clearedFields, batchmsg.FieldTotal)
  5659. }
  5660. // SetSuccess sets the "success" field.
  5661. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5662. m.success = &i
  5663. m.addsuccess = nil
  5664. }
  5665. // Success returns the value of the "success" field in the mutation.
  5666. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5667. v := m.success
  5668. if v == nil {
  5669. return
  5670. }
  5671. return *v, true
  5672. }
  5673. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5674. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5676. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  5677. if !m.op.Is(OpUpdateOne) {
  5678. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  5679. }
  5680. if m.id == nil || m.oldValue == nil {
  5681. return v, errors.New("OldSuccess requires an ID field in the mutation")
  5682. }
  5683. oldValue, err := m.oldValue(ctx)
  5684. if err != nil {
  5685. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  5686. }
  5687. return oldValue.Success, nil
  5688. }
  5689. // AddSuccess adds i to the "success" field.
  5690. func (m *BatchMsgMutation) AddSuccess(i int32) {
  5691. if m.addsuccess != nil {
  5692. *m.addsuccess += i
  5693. } else {
  5694. m.addsuccess = &i
  5695. }
  5696. }
  5697. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  5698. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  5699. v := m.addsuccess
  5700. if v == nil {
  5701. return
  5702. }
  5703. return *v, true
  5704. }
  5705. // ClearSuccess clears the value of the "success" field.
  5706. func (m *BatchMsgMutation) ClearSuccess() {
  5707. m.success = nil
  5708. m.addsuccess = nil
  5709. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  5710. }
  5711. // SuccessCleared returns if the "success" field was cleared in this mutation.
  5712. func (m *BatchMsgMutation) SuccessCleared() bool {
  5713. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  5714. return ok
  5715. }
  5716. // ResetSuccess resets all changes to the "success" field.
  5717. func (m *BatchMsgMutation) ResetSuccess() {
  5718. m.success = nil
  5719. m.addsuccess = nil
  5720. delete(m.clearedFields, batchmsg.FieldSuccess)
  5721. }
  5722. // SetFail sets the "fail" field.
  5723. func (m *BatchMsgMutation) SetFail(i int32) {
  5724. m.fail = &i
  5725. m.addfail = nil
  5726. }
  5727. // Fail returns the value of the "fail" field in the mutation.
  5728. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  5729. v := m.fail
  5730. if v == nil {
  5731. return
  5732. }
  5733. return *v, true
  5734. }
  5735. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  5736. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5738. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  5739. if !m.op.Is(OpUpdateOne) {
  5740. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  5741. }
  5742. if m.id == nil || m.oldValue == nil {
  5743. return v, errors.New("OldFail requires an ID field in the mutation")
  5744. }
  5745. oldValue, err := m.oldValue(ctx)
  5746. if err != nil {
  5747. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  5748. }
  5749. return oldValue.Fail, nil
  5750. }
  5751. // AddFail adds i to the "fail" field.
  5752. func (m *BatchMsgMutation) AddFail(i int32) {
  5753. if m.addfail != nil {
  5754. *m.addfail += i
  5755. } else {
  5756. m.addfail = &i
  5757. }
  5758. }
  5759. // AddedFail returns the value that was added to the "fail" field in this mutation.
  5760. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  5761. v := m.addfail
  5762. if v == nil {
  5763. return
  5764. }
  5765. return *v, true
  5766. }
  5767. // ClearFail clears the value of the "fail" field.
  5768. func (m *BatchMsgMutation) ClearFail() {
  5769. m.fail = nil
  5770. m.addfail = nil
  5771. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  5772. }
  5773. // FailCleared returns if the "fail" field was cleared in this mutation.
  5774. func (m *BatchMsgMutation) FailCleared() bool {
  5775. _, ok := m.clearedFields[batchmsg.FieldFail]
  5776. return ok
  5777. }
  5778. // ResetFail resets all changes to the "fail" field.
  5779. func (m *BatchMsgMutation) ResetFail() {
  5780. m.fail = nil
  5781. m.addfail = nil
  5782. delete(m.clearedFields, batchmsg.FieldFail)
  5783. }
  5784. // SetStartTime sets the "start_time" field.
  5785. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  5786. m.start_time = &t
  5787. }
  5788. // StartTime returns the value of the "start_time" field in the mutation.
  5789. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  5790. v := m.start_time
  5791. if v == nil {
  5792. return
  5793. }
  5794. return *v, true
  5795. }
  5796. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  5797. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5799. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  5800. if !m.op.Is(OpUpdateOne) {
  5801. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  5802. }
  5803. if m.id == nil || m.oldValue == nil {
  5804. return v, errors.New("OldStartTime requires an ID field in the mutation")
  5805. }
  5806. oldValue, err := m.oldValue(ctx)
  5807. if err != nil {
  5808. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  5809. }
  5810. return oldValue.StartTime, nil
  5811. }
  5812. // ClearStartTime clears the value of the "start_time" field.
  5813. func (m *BatchMsgMutation) ClearStartTime() {
  5814. m.start_time = nil
  5815. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  5816. }
  5817. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  5818. func (m *BatchMsgMutation) StartTimeCleared() bool {
  5819. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  5820. return ok
  5821. }
  5822. // ResetStartTime resets all changes to the "start_time" field.
  5823. func (m *BatchMsgMutation) ResetStartTime() {
  5824. m.start_time = nil
  5825. delete(m.clearedFields, batchmsg.FieldStartTime)
  5826. }
  5827. // SetStopTime sets the "stop_time" field.
  5828. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  5829. m.stop_time = &t
  5830. }
  5831. // StopTime returns the value of the "stop_time" field in the mutation.
  5832. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  5833. v := m.stop_time
  5834. if v == nil {
  5835. return
  5836. }
  5837. return *v, true
  5838. }
  5839. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  5840. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5842. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  5843. if !m.op.Is(OpUpdateOne) {
  5844. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  5845. }
  5846. if m.id == nil || m.oldValue == nil {
  5847. return v, errors.New("OldStopTime requires an ID field in the mutation")
  5848. }
  5849. oldValue, err := m.oldValue(ctx)
  5850. if err != nil {
  5851. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  5852. }
  5853. return oldValue.StopTime, nil
  5854. }
  5855. // ClearStopTime clears the value of the "stop_time" field.
  5856. func (m *BatchMsgMutation) ClearStopTime() {
  5857. m.stop_time = nil
  5858. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  5859. }
  5860. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  5861. func (m *BatchMsgMutation) StopTimeCleared() bool {
  5862. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  5863. return ok
  5864. }
  5865. // ResetStopTime resets all changes to the "stop_time" field.
  5866. func (m *BatchMsgMutation) ResetStopTime() {
  5867. m.stop_time = nil
  5868. delete(m.clearedFields, batchmsg.FieldStopTime)
  5869. }
  5870. // SetSendTime sets the "send_time" field.
  5871. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  5872. m.send_time = &t
  5873. }
  5874. // SendTime returns the value of the "send_time" field in the mutation.
  5875. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  5876. v := m.send_time
  5877. if v == nil {
  5878. return
  5879. }
  5880. return *v, true
  5881. }
  5882. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  5883. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5885. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  5886. if !m.op.Is(OpUpdateOne) {
  5887. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  5888. }
  5889. if m.id == nil || m.oldValue == nil {
  5890. return v, errors.New("OldSendTime requires an ID field in the mutation")
  5891. }
  5892. oldValue, err := m.oldValue(ctx)
  5893. if err != nil {
  5894. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  5895. }
  5896. return oldValue.SendTime, nil
  5897. }
  5898. // ClearSendTime clears the value of the "send_time" field.
  5899. func (m *BatchMsgMutation) ClearSendTime() {
  5900. m.send_time = nil
  5901. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  5902. }
  5903. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  5904. func (m *BatchMsgMutation) SendTimeCleared() bool {
  5905. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  5906. return ok
  5907. }
  5908. // ResetSendTime resets all changes to the "send_time" field.
  5909. func (m *BatchMsgMutation) ResetSendTime() {
  5910. m.send_time = nil
  5911. delete(m.clearedFields, batchmsg.FieldSendTime)
  5912. }
  5913. // SetType sets the "type" field.
  5914. func (m *BatchMsgMutation) SetType(i int32) {
  5915. m._type = &i
  5916. m.add_type = nil
  5917. }
  5918. // GetType returns the value of the "type" field in the mutation.
  5919. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  5920. v := m._type
  5921. if v == nil {
  5922. return
  5923. }
  5924. return *v, true
  5925. }
  5926. // OldType returns the old "type" field's value of the BatchMsg entity.
  5927. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5929. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  5930. if !m.op.Is(OpUpdateOne) {
  5931. return v, errors.New("OldType is only allowed on UpdateOne operations")
  5932. }
  5933. if m.id == nil || m.oldValue == nil {
  5934. return v, errors.New("OldType requires an ID field in the mutation")
  5935. }
  5936. oldValue, err := m.oldValue(ctx)
  5937. if err != nil {
  5938. return v, fmt.Errorf("querying old value for OldType: %w", err)
  5939. }
  5940. return oldValue.Type, nil
  5941. }
  5942. // AddType adds i to the "type" field.
  5943. func (m *BatchMsgMutation) AddType(i int32) {
  5944. if m.add_type != nil {
  5945. *m.add_type += i
  5946. } else {
  5947. m.add_type = &i
  5948. }
  5949. }
  5950. // AddedType returns the value that was added to the "type" field in this mutation.
  5951. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  5952. v := m.add_type
  5953. if v == nil {
  5954. return
  5955. }
  5956. return *v, true
  5957. }
  5958. // ClearType clears the value of the "type" field.
  5959. func (m *BatchMsgMutation) ClearType() {
  5960. m._type = nil
  5961. m.add_type = nil
  5962. m.clearedFields[batchmsg.FieldType] = struct{}{}
  5963. }
  5964. // TypeCleared returns if the "type" field was cleared in this mutation.
  5965. func (m *BatchMsgMutation) TypeCleared() bool {
  5966. _, ok := m.clearedFields[batchmsg.FieldType]
  5967. return ok
  5968. }
  5969. // ResetType resets all changes to the "type" field.
  5970. func (m *BatchMsgMutation) ResetType() {
  5971. m._type = nil
  5972. m.add_type = nil
  5973. delete(m.clearedFields, batchmsg.FieldType)
  5974. }
  5975. // SetOrganizationID sets the "organization_id" field.
  5976. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  5977. m.organization_id = &u
  5978. m.addorganization_id = nil
  5979. }
  5980. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5981. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  5982. v := m.organization_id
  5983. if v == nil {
  5984. return
  5985. }
  5986. return *v, true
  5987. }
  5988. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  5989. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5991. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5992. if !m.op.Is(OpUpdateOne) {
  5993. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5994. }
  5995. if m.id == nil || m.oldValue == nil {
  5996. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5997. }
  5998. oldValue, err := m.oldValue(ctx)
  5999. if err != nil {
  6000. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6001. }
  6002. return oldValue.OrganizationID, nil
  6003. }
  6004. // AddOrganizationID adds u to the "organization_id" field.
  6005. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6006. if m.addorganization_id != nil {
  6007. *m.addorganization_id += u
  6008. } else {
  6009. m.addorganization_id = &u
  6010. }
  6011. }
  6012. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6013. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6014. v := m.addorganization_id
  6015. if v == nil {
  6016. return
  6017. }
  6018. return *v, true
  6019. }
  6020. // ResetOrganizationID resets all changes to the "organization_id" field.
  6021. func (m *BatchMsgMutation) ResetOrganizationID() {
  6022. m.organization_id = nil
  6023. m.addorganization_id = nil
  6024. }
  6025. // SetCtype sets the "ctype" field.
  6026. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6027. m.ctype = &u
  6028. m.addctype = nil
  6029. }
  6030. // Ctype returns the value of the "ctype" field in the mutation.
  6031. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6032. v := m.ctype
  6033. if v == nil {
  6034. return
  6035. }
  6036. return *v, true
  6037. }
  6038. // OldCtype returns the old "ctype" 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) OldCtype(ctx context.Context) (v uint64, err error) {
  6042. if !m.op.Is(OpUpdateOne) {
  6043. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6044. }
  6045. if m.id == nil || m.oldValue == nil {
  6046. return v, errors.New("OldCtype 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 OldCtype: %w", err)
  6051. }
  6052. return oldValue.Ctype, nil
  6053. }
  6054. // AddCtype adds u to the "ctype" field.
  6055. func (m *BatchMsgMutation) AddCtype(u int64) {
  6056. if m.addctype != nil {
  6057. *m.addctype += u
  6058. } else {
  6059. m.addctype = &u
  6060. }
  6061. }
  6062. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6063. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6064. v := m.addctype
  6065. if v == nil {
  6066. return
  6067. }
  6068. return *v, true
  6069. }
  6070. // ResetCtype resets all changes to the "ctype" field.
  6071. func (m *BatchMsgMutation) ResetCtype() {
  6072. m.ctype = nil
  6073. m.addctype = nil
  6074. }
  6075. // SetCc sets the "cc" field.
  6076. func (m *BatchMsgMutation) SetCc(s string) {
  6077. m.cc = &s
  6078. }
  6079. // Cc returns the value of the "cc" field in the mutation.
  6080. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6081. v := m.cc
  6082. if v == nil {
  6083. return
  6084. }
  6085. return *v, true
  6086. }
  6087. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6088. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6090. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6091. if !m.op.Is(OpUpdateOne) {
  6092. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6093. }
  6094. if m.id == nil || m.oldValue == nil {
  6095. return v, errors.New("OldCc requires an ID field in the mutation")
  6096. }
  6097. oldValue, err := m.oldValue(ctx)
  6098. if err != nil {
  6099. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6100. }
  6101. return oldValue.Cc, nil
  6102. }
  6103. // ClearCc clears the value of the "cc" field.
  6104. func (m *BatchMsgMutation) ClearCc() {
  6105. m.cc = nil
  6106. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6107. }
  6108. // CcCleared returns if the "cc" field was cleared in this mutation.
  6109. func (m *BatchMsgMutation) CcCleared() bool {
  6110. _, ok := m.clearedFields[batchmsg.FieldCc]
  6111. return ok
  6112. }
  6113. // ResetCc resets all changes to the "cc" field.
  6114. func (m *BatchMsgMutation) ResetCc() {
  6115. m.cc = nil
  6116. delete(m.clearedFields, batchmsg.FieldCc)
  6117. }
  6118. // SetPhone sets the "phone" field.
  6119. func (m *BatchMsgMutation) SetPhone(s string) {
  6120. m.phone = &s
  6121. }
  6122. // Phone returns the value of the "phone" field in the mutation.
  6123. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6124. v := m.phone
  6125. if v == nil {
  6126. return
  6127. }
  6128. return *v, true
  6129. }
  6130. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6131. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6133. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6134. if !m.op.Is(OpUpdateOne) {
  6135. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6136. }
  6137. if m.id == nil || m.oldValue == nil {
  6138. return v, errors.New("OldPhone requires an ID field in the mutation")
  6139. }
  6140. oldValue, err := m.oldValue(ctx)
  6141. if err != nil {
  6142. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6143. }
  6144. return oldValue.Phone, nil
  6145. }
  6146. // ClearPhone clears the value of the "phone" field.
  6147. func (m *BatchMsgMutation) ClearPhone() {
  6148. m.phone = nil
  6149. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6150. }
  6151. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6152. func (m *BatchMsgMutation) PhoneCleared() bool {
  6153. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6154. return ok
  6155. }
  6156. // ResetPhone resets all changes to the "phone" field.
  6157. func (m *BatchMsgMutation) ResetPhone() {
  6158. m.phone = nil
  6159. delete(m.clearedFields, batchmsg.FieldPhone)
  6160. }
  6161. // SetTemplateName sets the "template_name" field.
  6162. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6163. m.template_name = &s
  6164. }
  6165. // TemplateName returns the value of the "template_name" field in the mutation.
  6166. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6167. v := m.template_name
  6168. if v == nil {
  6169. return
  6170. }
  6171. return *v, true
  6172. }
  6173. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6174. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6176. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6177. if !m.op.Is(OpUpdateOne) {
  6178. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6179. }
  6180. if m.id == nil || m.oldValue == nil {
  6181. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6182. }
  6183. oldValue, err := m.oldValue(ctx)
  6184. if err != nil {
  6185. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6186. }
  6187. return oldValue.TemplateName, nil
  6188. }
  6189. // ClearTemplateName clears the value of the "template_name" field.
  6190. func (m *BatchMsgMutation) ClearTemplateName() {
  6191. m.template_name = nil
  6192. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6193. }
  6194. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6195. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6196. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6197. return ok
  6198. }
  6199. // ResetTemplateName resets all changes to the "template_name" field.
  6200. func (m *BatchMsgMutation) ResetTemplateName() {
  6201. m.template_name = nil
  6202. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6203. }
  6204. // SetTemplateCode sets the "template_code" field.
  6205. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6206. m.template_code = &s
  6207. }
  6208. // TemplateCode returns the value of the "template_code" field in the mutation.
  6209. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6210. v := m.template_code
  6211. if v == nil {
  6212. return
  6213. }
  6214. return *v, true
  6215. }
  6216. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6217. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6219. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6220. if !m.op.Is(OpUpdateOne) {
  6221. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6222. }
  6223. if m.id == nil || m.oldValue == nil {
  6224. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6225. }
  6226. oldValue, err := m.oldValue(ctx)
  6227. if err != nil {
  6228. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6229. }
  6230. return oldValue.TemplateCode, nil
  6231. }
  6232. // ClearTemplateCode clears the value of the "template_code" field.
  6233. func (m *BatchMsgMutation) ClearTemplateCode() {
  6234. m.template_code = nil
  6235. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6236. }
  6237. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6238. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6239. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6240. return ok
  6241. }
  6242. // ResetTemplateCode resets all changes to the "template_code" field.
  6243. func (m *BatchMsgMutation) ResetTemplateCode() {
  6244. m.template_code = nil
  6245. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6246. }
  6247. // SetLang sets the "lang" field.
  6248. func (m *BatchMsgMutation) SetLang(s string) {
  6249. m.lang = &s
  6250. }
  6251. // Lang returns the value of the "lang" field in the mutation.
  6252. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6253. v := m.lang
  6254. if v == nil {
  6255. return
  6256. }
  6257. return *v, true
  6258. }
  6259. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6260. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6262. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6263. if !m.op.Is(OpUpdateOne) {
  6264. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6265. }
  6266. if m.id == nil || m.oldValue == nil {
  6267. return v, errors.New("OldLang requires an ID field in the mutation")
  6268. }
  6269. oldValue, err := m.oldValue(ctx)
  6270. if err != nil {
  6271. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6272. }
  6273. return oldValue.Lang, nil
  6274. }
  6275. // ClearLang clears the value of the "lang" field.
  6276. func (m *BatchMsgMutation) ClearLang() {
  6277. m.lang = nil
  6278. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6279. }
  6280. // LangCleared returns if the "lang" field was cleared in this mutation.
  6281. func (m *BatchMsgMutation) LangCleared() bool {
  6282. _, ok := m.clearedFields[batchmsg.FieldLang]
  6283. return ok
  6284. }
  6285. // ResetLang resets all changes to the "lang" field.
  6286. func (m *BatchMsgMutation) ResetLang() {
  6287. m.lang = nil
  6288. delete(m.clearedFields, batchmsg.FieldLang)
  6289. }
  6290. // Where appends a list predicates to the BatchMsgMutation builder.
  6291. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6292. m.predicates = append(m.predicates, ps...)
  6293. }
  6294. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6295. // users can use type-assertion to append predicates that do not depend on any generated package.
  6296. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6297. p := make([]predicate.BatchMsg, len(ps))
  6298. for i := range ps {
  6299. p[i] = ps[i]
  6300. }
  6301. m.Where(p...)
  6302. }
  6303. // Op returns the operation name.
  6304. func (m *BatchMsgMutation) Op() Op {
  6305. return m.op
  6306. }
  6307. // SetOp allows setting the mutation operation.
  6308. func (m *BatchMsgMutation) SetOp(op Op) {
  6309. m.op = op
  6310. }
  6311. // Type returns the node type of this mutation (BatchMsg).
  6312. func (m *BatchMsgMutation) Type() string {
  6313. return m.typ
  6314. }
  6315. // Fields returns all fields that were changed during this mutation. Note that in
  6316. // order to get all numeric fields that were incremented/decremented, call
  6317. // AddedFields().
  6318. func (m *BatchMsgMutation) Fields() []string {
  6319. fields := make([]string, 0, 24)
  6320. if m.created_at != nil {
  6321. fields = append(fields, batchmsg.FieldCreatedAt)
  6322. }
  6323. if m.updated_at != nil {
  6324. fields = append(fields, batchmsg.FieldUpdatedAt)
  6325. }
  6326. if m.deleted_at != nil {
  6327. fields = append(fields, batchmsg.FieldDeletedAt)
  6328. }
  6329. if m.status != nil {
  6330. fields = append(fields, batchmsg.FieldStatus)
  6331. }
  6332. if m.batch_no != nil {
  6333. fields = append(fields, batchmsg.FieldBatchNo)
  6334. }
  6335. if m.task_name != nil {
  6336. fields = append(fields, batchmsg.FieldTaskName)
  6337. }
  6338. if m.fromwxid != nil {
  6339. fields = append(fields, batchmsg.FieldFromwxid)
  6340. }
  6341. if m.msg != nil {
  6342. fields = append(fields, batchmsg.FieldMsg)
  6343. }
  6344. if m.tag != nil {
  6345. fields = append(fields, batchmsg.FieldTag)
  6346. }
  6347. if m.tagids != nil {
  6348. fields = append(fields, batchmsg.FieldTagids)
  6349. }
  6350. if m.total != nil {
  6351. fields = append(fields, batchmsg.FieldTotal)
  6352. }
  6353. if m.success != nil {
  6354. fields = append(fields, batchmsg.FieldSuccess)
  6355. }
  6356. if m.fail != nil {
  6357. fields = append(fields, batchmsg.FieldFail)
  6358. }
  6359. if m.start_time != nil {
  6360. fields = append(fields, batchmsg.FieldStartTime)
  6361. }
  6362. if m.stop_time != nil {
  6363. fields = append(fields, batchmsg.FieldStopTime)
  6364. }
  6365. if m.send_time != nil {
  6366. fields = append(fields, batchmsg.FieldSendTime)
  6367. }
  6368. if m._type != nil {
  6369. fields = append(fields, batchmsg.FieldType)
  6370. }
  6371. if m.organization_id != nil {
  6372. fields = append(fields, batchmsg.FieldOrganizationID)
  6373. }
  6374. if m.ctype != nil {
  6375. fields = append(fields, batchmsg.FieldCtype)
  6376. }
  6377. if m.cc != nil {
  6378. fields = append(fields, batchmsg.FieldCc)
  6379. }
  6380. if m.phone != nil {
  6381. fields = append(fields, batchmsg.FieldPhone)
  6382. }
  6383. if m.template_name != nil {
  6384. fields = append(fields, batchmsg.FieldTemplateName)
  6385. }
  6386. if m.template_code != nil {
  6387. fields = append(fields, batchmsg.FieldTemplateCode)
  6388. }
  6389. if m.lang != nil {
  6390. fields = append(fields, batchmsg.FieldLang)
  6391. }
  6392. return fields
  6393. }
  6394. // Field returns the value of a field with the given name. The second boolean
  6395. // return value indicates that this field was not set, or was not defined in the
  6396. // schema.
  6397. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6398. switch name {
  6399. case batchmsg.FieldCreatedAt:
  6400. return m.CreatedAt()
  6401. case batchmsg.FieldUpdatedAt:
  6402. return m.UpdatedAt()
  6403. case batchmsg.FieldDeletedAt:
  6404. return m.DeletedAt()
  6405. case batchmsg.FieldStatus:
  6406. return m.Status()
  6407. case batchmsg.FieldBatchNo:
  6408. return m.BatchNo()
  6409. case batchmsg.FieldTaskName:
  6410. return m.TaskName()
  6411. case batchmsg.FieldFromwxid:
  6412. return m.Fromwxid()
  6413. case batchmsg.FieldMsg:
  6414. return m.Msg()
  6415. case batchmsg.FieldTag:
  6416. return m.Tag()
  6417. case batchmsg.FieldTagids:
  6418. return m.Tagids()
  6419. case batchmsg.FieldTotal:
  6420. return m.Total()
  6421. case batchmsg.FieldSuccess:
  6422. return m.Success()
  6423. case batchmsg.FieldFail:
  6424. return m.Fail()
  6425. case batchmsg.FieldStartTime:
  6426. return m.StartTime()
  6427. case batchmsg.FieldStopTime:
  6428. return m.StopTime()
  6429. case batchmsg.FieldSendTime:
  6430. return m.SendTime()
  6431. case batchmsg.FieldType:
  6432. return m.GetType()
  6433. case batchmsg.FieldOrganizationID:
  6434. return m.OrganizationID()
  6435. case batchmsg.FieldCtype:
  6436. return m.Ctype()
  6437. case batchmsg.FieldCc:
  6438. return m.Cc()
  6439. case batchmsg.FieldPhone:
  6440. return m.Phone()
  6441. case batchmsg.FieldTemplateName:
  6442. return m.TemplateName()
  6443. case batchmsg.FieldTemplateCode:
  6444. return m.TemplateCode()
  6445. case batchmsg.FieldLang:
  6446. return m.Lang()
  6447. }
  6448. return nil, false
  6449. }
  6450. // OldField returns the old value of the field from the database. An error is
  6451. // returned if the mutation operation is not UpdateOne, or the query to the
  6452. // database failed.
  6453. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6454. switch name {
  6455. case batchmsg.FieldCreatedAt:
  6456. return m.OldCreatedAt(ctx)
  6457. case batchmsg.FieldUpdatedAt:
  6458. return m.OldUpdatedAt(ctx)
  6459. case batchmsg.FieldDeletedAt:
  6460. return m.OldDeletedAt(ctx)
  6461. case batchmsg.FieldStatus:
  6462. return m.OldStatus(ctx)
  6463. case batchmsg.FieldBatchNo:
  6464. return m.OldBatchNo(ctx)
  6465. case batchmsg.FieldTaskName:
  6466. return m.OldTaskName(ctx)
  6467. case batchmsg.FieldFromwxid:
  6468. return m.OldFromwxid(ctx)
  6469. case batchmsg.FieldMsg:
  6470. return m.OldMsg(ctx)
  6471. case batchmsg.FieldTag:
  6472. return m.OldTag(ctx)
  6473. case batchmsg.FieldTagids:
  6474. return m.OldTagids(ctx)
  6475. case batchmsg.FieldTotal:
  6476. return m.OldTotal(ctx)
  6477. case batchmsg.FieldSuccess:
  6478. return m.OldSuccess(ctx)
  6479. case batchmsg.FieldFail:
  6480. return m.OldFail(ctx)
  6481. case batchmsg.FieldStartTime:
  6482. return m.OldStartTime(ctx)
  6483. case batchmsg.FieldStopTime:
  6484. return m.OldStopTime(ctx)
  6485. case batchmsg.FieldSendTime:
  6486. return m.OldSendTime(ctx)
  6487. case batchmsg.FieldType:
  6488. return m.OldType(ctx)
  6489. case batchmsg.FieldOrganizationID:
  6490. return m.OldOrganizationID(ctx)
  6491. case batchmsg.FieldCtype:
  6492. return m.OldCtype(ctx)
  6493. case batchmsg.FieldCc:
  6494. return m.OldCc(ctx)
  6495. case batchmsg.FieldPhone:
  6496. return m.OldPhone(ctx)
  6497. case batchmsg.FieldTemplateName:
  6498. return m.OldTemplateName(ctx)
  6499. case batchmsg.FieldTemplateCode:
  6500. return m.OldTemplateCode(ctx)
  6501. case batchmsg.FieldLang:
  6502. return m.OldLang(ctx)
  6503. }
  6504. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6505. }
  6506. // SetField sets the value of a field with the given name. It returns an error if
  6507. // the field is not defined in the schema, or if the type mismatched the field
  6508. // type.
  6509. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6510. switch name {
  6511. case batchmsg.FieldCreatedAt:
  6512. v, ok := value.(time.Time)
  6513. if !ok {
  6514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6515. }
  6516. m.SetCreatedAt(v)
  6517. return nil
  6518. case batchmsg.FieldUpdatedAt:
  6519. v, ok := value.(time.Time)
  6520. if !ok {
  6521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6522. }
  6523. m.SetUpdatedAt(v)
  6524. return nil
  6525. case batchmsg.FieldDeletedAt:
  6526. v, ok := value.(time.Time)
  6527. if !ok {
  6528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6529. }
  6530. m.SetDeletedAt(v)
  6531. return nil
  6532. case batchmsg.FieldStatus:
  6533. v, ok := value.(uint8)
  6534. if !ok {
  6535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6536. }
  6537. m.SetStatus(v)
  6538. return nil
  6539. case batchmsg.FieldBatchNo:
  6540. v, ok := value.(string)
  6541. if !ok {
  6542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6543. }
  6544. m.SetBatchNo(v)
  6545. return nil
  6546. case batchmsg.FieldTaskName:
  6547. v, ok := value.(string)
  6548. if !ok {
  6549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6550. }
  6551. m.SetTaskName(v)
  6552. return nil
  6553. case batchmsg.FieldFromwxid:
  6554. v, ok := value.(string)
  6555. if !ok {
  6556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6557. }
  6558. m.SetFromwxid(v)
  6559. return nil
  6560. case batchmsg.FieldMsg:
  6561. v, ok := value.(string)
  6562. if !ok {
  6563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6564. }
  6565. m.SetMsg(v)
  6566. return nil
  6567. case batchmsg.FieldTag:
  6568. v, ok := value.(string)
  6569. if !ok {
  6570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6571. }
  6572. m.SetTag(v)
  6573. return nil
  6574. case batchmsg.FieldTagids:
  6575. v, ok := value.(string)
  6576. if !ok {
  6577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6578. }
  6579. m.SetTagids(v)
  6580. return nil
  6581. case batchmsg.FieldTotal:
  6582. v, ok := value.(int32)
  6583. if !ok {
  6584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6585. }
  6586. m.SetTotal(v)
  6587. return nil
  6588. case batchmsg.FieldSuccess:
  6589. v, ok := value.(int32)
  6590. if !ok {
  6591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6592. }
  6593. m.SetSuccess(v)
  6594. return nil
  6595. case batchmsg.FieldFail:
  6596. v, ok := value.(int32)
  6597. if !ok {
  6598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6599. }
  6600. m.SetFail(v)
  6601. return nil
  6602. case batchmsg.FieldStartTime:
  6603. v, ok := value.(time.Time)
  6604. if !ok {
  6605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6606. }
  6607. m.SetStartTime(v)
  6608. return nil
  6609. case batchmsg.FieldStopTime:
  6610. v, ok := value.(time.Time)
  6611. if !ok {
  6612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6613. }
  6614. m.SetStopTime(v)
  6615. return nil
  6616. case batchmsg.FieldSendTime:
  6617. v, ok := value.(time.Time)
  6618. if !ok {
  6619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6620. }
  6621. m.SetSendTime(v)
  6622. return nil
  6623. case batchmsg.FieldType:
  6624. v, ok := value.(int32)
  6625. if !ok {
  6626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6627. }
  6628. m.SetType(v)
  6629. return nil
  6630. case batchmsg.FieldOrganizationID:
  6631. v, ok := value.(uint64)
  6632. if !ok {
  6633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6634. }
  6635. m.SetOrganizationID(v)
  6636. return nil
  6637. case batchmsg.FieldCtype:
  6638. v, ok := value.(uint64)
  6639. if !ok {
  6640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6641. }
  6642. m.SetCtype(v)
  6643. return nil
  6644. case batchmsg.FieldCc:
  6645. v, ok := value.(string)
  6646. if !ok {
  6647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6648. }
  6649. m.SetCc(v)
  6650. return nil
  6651. case batchmsg.FieldPhone:
  6652. v, ok := value.(string)
  6653. if !ok {
  6654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6655. }
  6656. m.SetPhone(v)
  6657. return nil
  6658. case batchmsg.FieldTemplateName:
  6659. v, ok := value.(string)
  6660. if !ok {
  6661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6662. }
  6663. m.SetTemplateName(v)
  6664. return nil
  6665. case batchmsg.FieldTemplateCode:
  6666. v, ok := value.(string)
  6667. if !ok {
  6668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6669. }
  6670. m.SetTemplateCode(v)
  6671. return nil
  6672. case batchmsg.FieldLang:
  6673. v, ok := value.(string)
  6674. if !ok {
  6675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6676. }
  6677. m.SetLang(v)
  6678. return nil
  6679. }
  6680. return fmt.Errorf("unknown BatchMsg field %s", name)
  6681. }
  6682. // AddedFields returns all numeric fields that were incremented/decremented during
  6683. // this mutation.
  6684. func (m *BatchMsgMutation) AddedFields() []string {
  6685. var fields []string
  6686. if m.addstatus != nil {
  6687. fields = append(fields, batchmsg.FieldStatus)
  6688. }
  6689. if m.addtotal != nil {
  6690. fields = append(fields, batchmsg.FieldTotal)
  6691. }
  6692. if m.addsuccess != nil {
  6693. fields = append(fields, batchmsg.FieldSuccess)
  6694. }
  6695. if m.addfail != nil {
  6696. fields = append(fields, batchmsg.FieldFail)
  6697. }
  6698. if m.add_type != nil {
  6699. fields = append(fields, batchmsg.FieldType)
  6700. }
  6701. if m.addorganization_id != nil {
  6702. fields = append(fields, batchmsg.FieldOrganizationID)
  6703. }
  6704. if m.addctype != nil {
  6705. fields = append(fields, batchmsg.FieldCtype)
  6706. }
  6707. return fields
  6708. }
  6709. // AddedField returns the numeric value that was incremented/decremented on a field
  6710. // with the given name. The second boolean return value indicates that this field
  6711. // was not set, or was not defined in the schema.
  6712. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  6713. switch name {
  6714. case batchmsg.FieldStatus:
  6715. return m.AddedStatus()
  6716. case batchmsg.FieldTotal:
  6717. return m.AddedTotal()
  6718. case batchmsg.FieldSuccess:
  6719. return m.AddedSuccess()
  6720. case batchmsg.FieldFail:
  6721. return m.AddedFail()
  6722. case batchmsg.FieldType:
  6723. return m.AddedType()
  6724. case batchmsg.FieldOrganizationID:
  6725. return m.AddedOrganizationID()
  6726. case batchmsg.FieldCtype:
  6727. return m.AddedCtype()
  6728. }
  6729. return nil, false
  6730. }
  6731. // AddField adds the value to the field with the given name. It returns an error if
  6732. // the field is not defined in the schema, or if the type mismatched the field
  6733. // type.
  6734. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  6735. switch name {
  6736. case batchmsg.FieldStatus:
  6737. v, ok := value.(int8)
  6738. if !ok {
  6739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6740. }
  6741. m.AddStatus(v)
  6742. return nil
  6743. case batchmsg.FieldTotal:
  6744. v, ok := value.(int32)
  6745. if !ok {
  6746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6747. }
  6748. m.AddTotal(v)
  6749. return nil
  6750. case batchmsg.FieldSuccess:
  6751. v, ok := value.(int32)
  6752. if !ok {
  6753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6754. }
  6755. m.AddSuccess(v)
  6756. return nil
  6757. case batchmsg.FieldFail:
  6758. v, ok := value.(int32)
  6759. if !ok {
  6760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6761. }
  6762. m.AddFail(v)
  6763. return nil
  6764. case batchmsg.FieldType:
  6765. v, ok := value.(int32)
  6766. if !ok {
  6767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6768. }
  6769. m.AddType(v)
  6770. return nil
  6771. case batchmsg.FieldOrganizationID:
  6772. v, ok := value.(int64)
  6773. if !ok {
  6774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6775. }
  6776. m.AddOrganizationID(v)
  6777. return nil
  6778. case batchmsg.FieldCtype:
  6779. v, ok := value.(int64)
  6780. if !ok {
  6781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6782. }
  6783. m.AddCtype(v)
  6784. return nil
  6785. }
  6786. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  6787. }
  6788. // ClearedFields returns all nullable fields that were cleared during this
  6789. // mutation.
  6790. func (m *BatchMsgMutation) ClearedFields() []string {
  6791. var fields []string
  6792. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  6793. fields = append(fields, batchmsg.FieldDeletedAt)
  6794. }
  6795. if m.FieldCleared(batchmsg.FieldStatus) {
  6796. fields = append(fields, batchmsg.FieldStatus)
  6797. }
  6798. if m.FieldCleared(batchmsg.FieldBatchNo) {
  6799. fields = append(fields, batchmsg.FieldBatchNo)
  6800. }
  6801. if m.FieldCleared(batchmsg.FieldTaskName) {
  6802. fields = append(fields, batchmsg.FieldTaskName)
  6803. }
  6804. if m.FieldCleared(batchmsg.FieldFromwxid) {
  6805. fields = append(fields, batchmsg.FieldFromwxid)
  6806. }
  6807. if m.FieldCleared(batchmsg.FieldMsg) {
  6808. fields = append(fields, batchmsg.FieldMsg)
  6809. }
  6810. if m.FieldCleared(batchmsg.FieldTag) {
  6811. fields = append(fields, batchmsg.FieldTag)
  6812. }
  6813. if m.FieldCleared(batchmsg.FieldTagids) {
  6814. fields = append(fields, batchmsg.FieldTagids)
  6815. }
  6816. if m.FieldCleared(batchmsg.FieldTotal) {
  6817. fields = append(fields, batchmsg.FieldTotal)
  6818. }
  6819. if m.FieldCleared(batchmsg.FieldSuccess) {
  6820. fields = append(fields, batchmsg.FieldSuccess)
  6821. }
  6822. if m.FieldCleared(batchmsg.FieldFail) {
  6823. fields = append(fields, batchmsg.FieldFail)
  6824. }
  6825. if m.FieldCleared(batchmsg.FieldStartTime) {
  6826. fields = append(fields, batchmsg.FieldStartTime)
  6827. }
  6828. if m.FieldCleared(batchmsg.FieldStopTime) {
  6829. fields = append(fields, batchmsg.FieldStopTime)
  6830. }
  6831. if m.FieldCleared(batchmsg.FieldSendTime) {
  6832. fields = append(fields, batchmsg.FieldSendTime)
  6833. }
  6834. if m.FieldCleared(batchmsg.FieldType) {
  6835. fields = append(fields, batchmsg.FieldType)
  6836. }
  6837. if m.FieldCleared(batchmsg.FieldCc) {
  6838. fields = append(fields, batchmsg.FieldCc)
  6839. }
  6840. if m.FieldCleared(batchmsg.FieldPhone) {
  6841. fields = append(fields, batchmsg.FieldPhone)
  6842. }
  6843. if m.FieldCleared(batchmsg.FieldTemplateName) {
  6844. fields = append(fields, batchmsg.FieldTemplateName)
  6845. }
  6846. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  6847. fields = append(fields, batchmsg.FieldTemplateCode)
  6848. }
  6849. if m.FieldCleared(batchmsg.FieldLang) {
  6850. fields = append(fields, batchmsg.FieldLang)
  6851. }
  6852. return fields
  6853. }
  6854. // FieldCleared returns a boolean indicating if a field with the given name was
  6855. // cleared in this mutation.
  6856. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  6857. _, ok := m.clearedFields[name]
  6858. return ok
  6859. }
  6860. // ClearField clears the value of the field with the given name. It returns an
  6861. // error if the field is not defined in the schema.
  6862. func (m *BatchMsgMutation) ClearField(name string) error {
  6863. switch name {
  6864. case batchmsg.FieldDeletedAt:
  6865. m.ClearDeletedAt()
  6866. return nil
  6867. case batchmsg.FieldStatus:
  6868. m.ClearStatus()
  6869. return nil
  6870. case batchmsg.FieldBatchNo:
  6871. m.ClearBatchNo()
  6872. return nil
  6873. case batchmsg.FieldTaskName:
  6874. m.ClearTaskName()
  6875. return nil
  6876. case batchmsg.FieldFromwxid:
  6877. m.ClearFromwxid()
  6878. return nil
  6879. case batchmsg.FieldMsg:
  6880. m.ClearMsg()
  6881. return nil
  6882. case batchmsg.FieldTag:
  6883. m.ClearTag()
  6884. return nil
  6885. case batchmsg.FieldTagids:
  6886. m.ClearTagids()
  6887. return nil
  6888. case batchmsg.FieldTotal:
  6889. m.ClearTotal()
  6890. return nil
  6891. case batchmsg.FieldSuccess:
  6892. m.ClearSuccess()
  6893. return nil
  6894. case batchmsg.FieldFail:
  6895. m.ClearFail()
  6896. return nil
  6897. case batchmsg.FieldStartTime:
  6898. m.ClearStartTime()
  6899. return nil
  6900. case batchmsg.FieldStopTime:
  6901. m.ClearStopTime()
  6902. return nil
  6903. case batchmsg.FieldSendTime:
  6904. m.ClearSendTime()
  6905. return nil
  6906. case batchmsg.FieldType:
  6907. m.ClearType()
  6908. return nil
  6909. case batchmsg.FieldCc:
  6910. m.ClearCc()
  6911. return nil
  6912. case batchmsg.FieldPhone:
  6913. m.ClearPhone()
  6914. return nil
  6915. case batchmsg.FieldTemplateName:
  6916. m.ClearTemplateName()
  6917. return nil
  6918. case batchmsg.FieldTemplateCode:
  6919. m.ClearTemplateCode()
  6920. return nil
  6921. case batchmsg.FieldLang:
  6922. m.ClearLang()
  6923. return nil
  6924. }
  6925. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  6926. }
  6927. // ResetField resets all changes in the mutation for the field with the given name.
  6928. // It returns an error if the field is not defined in the schema.
  6929. func (m *BatchMsgMutation) ResetField(name string) error {
  6930. switch name {
  6931. case batchmsg.FieldCreatedAt:
  6932. m.ResetCreatedAt()
  6933. return nil
  6934. case batchmsg.FieldUpdatedAt:
  6935. m.ResetUpdatedAt()
  6936. return nil
  6937. case batchmsg.FieldDeletedAt:
  6938. m.ResetDeletedAt()
  6939. return nil
  6940. case batchmsg.FieldStatus:
  6941. m.ResetStatus()
  6942. return nil
  6943. case batchmsg.FieldBatchNo:
  6944. m.ResetBatchNo()
  6945. return nil
  6946. case batchmsg.FieldTaskName:
  6947. m.ResetTaskName()
  6948. return nil
  6949. case batchmsg.FieldFromwxid:
  6950. m.ResetFromwxid()
  6951. return nil
  6952. case batchmsg.FieldMsg:
  6953. m.ResetMsg()
  6954. return nil
  6955. case batchmsg.FieldTag:
  6956. m.ResetTag()
  6957. return nil
  6958. case batchmsg.FieldTagids:
  6959. m.ResetTagids()
  6960. return nil
  6961. case batchmsg.FieldTotal:
  6962. m.ResetTotal()
  6963. return nil
  6964. case batchmsg.FieldSuccess:
  6965. m.ResetSuccess()
  6966. return nil
  6967. case batchmsg.FieldFail:
  6968. m.ResetFail()
  6969. return nil
  6970. case batchmsg.FieldStartTime:
  6971. m.ResetStartTime()
  6972. return nil
  6973. case batchmsg.FieldStopTime:
  6974. m.ResetStopTime()
  6975. return nil
  6976. case batchmsg.FieldSendTime:
  6977. m.ResetSendTime()
  6978. return nil
  6979. case batchmsg.FieldType:
  6980. m.ResetType()
  6981. return nil
  6982. case batchmsg.FieldOrganizationID:
  6983. m.ResetOrganizationID()
  6984. return nil
  6985. case batchmsg.FieldCtype:
  6986. m.ResetCtype()
  6987. return nil
  6988. case batchmsg.FieldCc:
  6989. m.ResetCc()
  6990. return nil
  6991. case batchmsg.FieldPhone:
  6992. m.ResetPhone()
  6993. return nil
  6994. case batchmsg.FieldTemplateName:
  6995. m.ResetTemplateName()
  6996. return nil
  6997. case batchmsg.FieldTemplateCode:
  6998. m.ResetTemplateCode()
  6999. return nil
  7000. case batchmsg.FieldLang:
  7001. m.ResetLang()
  7002. return nil
  7003. }
  7004. return fmt.Errorf("unknown BatchMsg field %s", name)
  7005. }
  7006. // AddedEdges returns all edge names that were set/added in this mutation.
  7007. func (m *BatchMsgMutation) AddedEdges() []string {
  7008. edges := make([]string, 0, 0)
  7009. return edges
  7010. }
  7011. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7012. // name in this mutation.
  7013. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7014. return nil
  7015. }
  7016. // RemovedEdges returns all edge names that were removed in this mutation.
  7017. func (m *BatchMsgMutation) RemovedEdges() []string {
  7018. edges := make([]string, 0, 0)
  7019. return edges
  7020. }
  7021. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7022. // the given name in this mutation.
  7023. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7024. return nil
  7025. }
  7026. // ClearedEdges returns all edge names that were cleared in this mutation.
  7027. func (m *BatchMsgMutation) ClearedEdges() []string {
  7028. edges := make([]string, 0, 0)
  7029. return edges
  7030. }
  7031. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7032. // was cleared in this mutation.
  7033. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7034. return false
  7035. }
  7036. // ClearEdge clears the value of the edge with the given name. It returns an error
  7037. // if that edge is not defined in the schema.
  7038. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7039. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7040. }
  7041. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7042. // It returns an error if the edge is not defined in the schema.
  7043. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7044. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7045. }
  7046. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7047. type CategoryMutation struct {
  7048. config
  7049. op Op
  7050. typ string
  7051. id *uint64
  7052. created_at *time.Time
  7053. updated_at *time.Time
  7054. deleted_at *time.Time
  7055. name *string
  7056. organization_id *uint64
  7057. addorganization_id *int64
  7058. clearedFields map[string]struct{}
  7059. done bool
  7060. oldValue func(context.Context) (*Category, error)
  7061. predicates []predicate.Category
  7062. }
  7063. var _ ent.Mutation = (*CategoryMutation)(nil)
  7064. // categoryOption allows management of the mutation configuration using functional options.
  7065. type categoryOption func(*CategoryMutation)
  7066. // newCategoryMutation creates new mutation for the Category entity.
  7067. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7068. m := &CategoryMutation{
  7069. config: c,
  7070. op: op,
  7071. typ: TypeCategory,
  7072. clearedFields: make(map[string]struct{}),
  7073. }
  7074. for _, opt := range opts {
  7075. opt(m)
  7076. }
  7077. return m
  7078. }
  7079. // withCategoryID sets the ID field of the mutation.
  7080. func withCategoryID(id uint64) categoryOption {
  7081. return func(m *CategoryMutation) {
  7082. var (
  7083. err error
  7084. once sync.Once
  7085. value *Category
  7086. )
  7087. m.oldValue = func(ctx context.Context) (*Category, error) {
  7088. once.Do(func() {
  7089. if m.done {
  7090. err = errors.New("querying old values post mutation is not allowed")
  7091. } else {
  7092. value, err = m.Client().Category.Get(ctx, id)
  7093. }
  7094. })
  7095. return value, err
  7096. }
  7097. m.id = &id
  7098. }
  7099. }
  7100. // withCategory sets the old Category of the mutation.
  7101. func withCategory(node *Category) categoryOption {
  7102. return func(m *CategoryMutation) {
  7103. m.oldValue = func(context.Context) (*Category, error) {
  7104. return node, nil
  7105. }
  7106. m.id = &node.ID
  7107. }
  7108. }
  7109. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7110. // executed in a transaction (ent.Tx), a transactional client is returned.
  7111. func (m CategoryMutation) Client() *Client {
  7112. client := &Client{config: m.config}
  7113. client.init()
  7114. return client
  7115. }
  7116. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7117. // it returns an error otherwise.
  7118. func (m CategoryMutation) Tx() (*Tx, error) {
  7119. if _, ok := m.driver.(*txDriver); !ok {
  7120. return nil, errors.New("ent: mutation is not running in a transaction")
  7121. }
  7122. tx := &Tx{config: m.config}
  7123. tx.init()
  7124. return tx, nil
  7125. }
  7126. // SetID sets the value of the id field. Note that this
  7127. // operation is only accepted on creation of Category entities.
  7128. func (m *CategoryMutation) SetID(id uint64) {
  7129. m.id = &id
  7130. }
  7131. // ID returns the ID value in the mutation. Note that the ID is only available
  7132. // if it was provided to the builder or after it was returned from the database.
  7133. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7134. if m.id == nil {
  7135. return
  7136. }
  7137. return *m.id, true
  7138. }
  7139. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7140. // That means, if the mutation is applied within a transaction with an isolation level such
  7141. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7142. // or updated by the mutation.
  7143. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7144. switch {
  7145. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7146. id, exists := m.ID()
  7147. if exists {
  7148. return []uint64{id}, nil
  7149. }
  7150. fallthrough
  7151. case m.op.Is(OpUpdate | OpDelete):
  7152. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7153. default:
  7154. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7155. }
  7156. }
  7157. // SetCreatedAt sets the "created_at" field.
  7158. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7159. m.created_at = &t
  7160. }
  7161. // CreatedAt returns the value of the "created_at" field in the mutation.
  7162. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7163. v := m.created_at
  7164. if v == nil {
  7165. return
  7166. }
  7167. return *v, true
  7168. }
  7169. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7170. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7172. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7173. if !m.op.Is(OpUpdateOne) {
  7174. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7175. }
  7176. if m.id == nil || m.oldValue == nil {
  7177. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7178. }
  7179. oldValue, err := m.oldValue(ctx)
  7180. if err != nil {
  7181. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7182. }
  7183. return oldValue.CreatedAt, nil
  7184. }
  7185. // ResetCreatedAt resets all changes to the "created_at" field.
  7186. func (m *CategoryMutation) ResetCreatedAt() {
  7187. m.created_at = nil
  7188. }
  7189. // SetUpdatedAt sets the "updated_at" field.
  7190. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7191. m.updated_at = &t
  7192. }
  7193. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7194. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7195. v := m.updated_at
  7196. if v == nil {
  7197. return
  7198. }
  7199. return *v, true
  7200. }
  7201. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7202. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7204. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7205. if !m.op.Is(OpUpdateOne) {
  7206. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7207. }
  7208. if m.id == nil || m.oldValue == nil {
  7209. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7210. }
  7211. oldValue, err := m.oldValue(ctx)
  7212. if err != nil {
  7213. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7214. }
  7215. return oldValue.UpdatedAt, nil
  7216. }
  7217. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7218. func (m *CategoryMutation) ResetUpdatedAt() {
  7219. m.updated_at = nil
  7220. }
  7221. // SetDeletedAt sets the "deleted_at" field.
  7222. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7223. m.deleted_at = &t
  7224. }
  7225. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7226. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7227. v := m.deleted_at
  7228. if v == nil {
  7229. return
  7230. }
  7231. return *v, true
  7232. }
  7233. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7234. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7236. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7237. if !m.op.Is(OpUpdateOne) {
  7238. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7239. }
  7240. if m.id == nil || m.oldValue == nil {
  7241. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7242. }
  7243. oldValue, err := m.oldValue(ctx)
  7244. if err != nil {
  7245. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7246. }
  7247. return oldValue.DeletedAt, nil
  7248. }
  7249. // ClearDeletedAt clears the value of the "deleted_at" field.
  7250. func (m *CategoryMutation) ClearDeletedAt() {
  7251. m.deleted_at = nil
  7252. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7253. }
  7254. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7255. func (m *CategoryMutation) DeletedAtCleared() bool {
  7256. _, ok := m.clearedFields[category.FieldDeletedAt]
  7257. return ok
  7258. }
  7259. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7260. func (m *CategoryMutation) ResetDeletedAt() {
  7261. m.deleted_at = nil
  7262. delete(m.clearedFields, category.FieldDeletedAt)
  7263. }
  7264. // SetName sets the "name" field.
  7265. func (m *CategoryMutation) SetName(s string) {
  7266. m.name = &s
  7267. }
  7268. // Name returns the value of the "name" field in the mutation.
  7269. func (m *CategoryMutation) Name() (r string, exists bool) {
  7270. v := m.name
  7271. if v == nil {
  7272. return
  7273. }
  7274. return *v, true
  7275. }
  7276. // OldName returns the old "name" field's value of the Category entity.
  7277. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7279. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7280. if !m.op.Is(OpUpdateOne) {
  7281. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7282. }
  7283. if m.id == nil || m.oldValue == nil {
  7284. return v, errors.New("OldName requires an ID field in the mutation")
  7285. }
  7286. oldValue, err := m.oldValue(ctx)
  7287. if err != nil {
  7288. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7289. }
  7290. return oldValue.Name, nil
  7291. }
  7292. // ResetName resets all changes to the "name" field.
  7293. func (m *CategoryMutation) ResetName() {
  7294. m.name = nil
  7295. }
  7296. // SetOrganizationID sets the "organization_id" field.
  7297. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7298. m.organization_id = &u
  7299. m.addorganization_id = nil
  7300. }
  7301. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7302. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7303. v := m.organization_id
  7304. if v == nil {
  7305. return
  7306. }
  7307. return *v, true
  7308. }
  7309. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7310. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7312. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7313. if !m.op.Is(OpUpdateOne) {
  7314. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7315. }
  7316. if m.id == nil || m.oldValue == nil {
  7317. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7318. }
  7319. oldValue, err := m.oldValue(ctx)
  7320. if err != nil {
  7321. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7322. }
  7323. return oldValue.OrganizationID, nil
  7324. }
  7325. // AddOrganizationID adds u to the "organization_id" field.
  7326. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7327. if m.addorganization_id != nil {
  7328. *m.addorganization_id += u
  7329. } else {
  7330. m.addorganization_id = &u
  7331. }
  7332. }
  7333. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7334. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7335. v := m.addorganization_id
  7336. if v == nil {
  7337. return
  7338. }
  7339. return *v, true
  7340. }
  7341. // ResetOrganizationID resets all changes to the "organization_id" field.
  7342. func (m *CategoryMutation) ResetOrganizationID() {
  7343. m.organization_id = nil
  7344. m.addorganization_id = nil
  7345. }
  7346. // Where appends a list predicates to the CategoryMutation builder.
  7347. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7348. m.predicates = append(m.predicates, ps...)
  7349. }
  7350. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7351. // users can use type-assertion to append predicates that do not depend on any generated package.
  7352. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7353. p := make([]predicate.Category, len(ps))
  7354. for i := range ps {
  7355. p[i] = ps[i]
  7356. }
  7357. m.Where(p...)
  7358. }
  7359. // Op returns the operation name.
  7360. func (m *CategoryMutation) Op() Op {
  7361. return m.op
  7362. }
  7363. // SetOp allows setting the mutation operation.
  7364. func (m *CategoryMutation) SetOp(op Op) {
  7365. m.op = op
  7366. }
  7367. // Type returns the node type of this mutation (Category).
  7368. func (m *CategoryMutation) Type() string {
  7369. return m.typ
  7370. }
  7371. // Fields returns all fields that were changed during this mutation. Note that in
  7372. // order to get all numeric fields that were incremented/decremented, call
  7373. // AddedFields().
  7374. func (m *CategoryMutation) Fields() []string {
  7375. fields := make([]string, 0, 5)
  7376. if m.created_at != nil {
  7377. fields = append(fields, category.FieldCreatedAt)
  7378. }
  7379. if m.updated_at != nil {
  7380. fields = append(fields, category.FieldUpdatedAt)
  7381. }
  7382. if m.deleted_at != nil {
  7383. fields = append(fields, category.FieldDeletedAt)
  7384. }
  7385. if m.name != nil {
  7386. fields = append(fields, category.FieldName)
  7387. }
  7388. if m.organization_id != nil {
  7389. fields = append(fields, category.FieldOrganizationID)
  7390. }
  7391. return fields
  7392. }
  7393. // Field returns the value of a field with the given name. The second boolean
  7394. // return value indicates that this field was not set, or was not defined in the
  7395. // schema.
  7396. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7397. switch name {
  7398. case category.FieldCreatedAt:
  7399. return m.CreatedAt()
  7400. case category.FieldUpdatedAt:
  7401. return m.UpdatedAt()
  7402. case category.FieldDeletedAt:
  7403. return m.DeletedAt()
  7404. case category.FieldName:
  7405. return m.Name()
  7406. case category.FieldOrganizationID:
  7407. return m.OrganizationID()
  7408. }
  7409. return nil, false
  7410. }
  7411. // OldField returns the old value of the field from the database. An error is
  7412. // returned if the mutation operation is not UpdateOne, or the query to the
  7413. // database failed.
  7414. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7415. switch name {
  7416. case category.FieldCreatedAt:
  7417. return m.OldCreatedAt(ctx)
  7418. case category.FieldUpdatedAt:
  7419. return m.OldUpdatedAt(ctx)
  7420. case category.FieldDeletedAt:
  7421. return m.OldDeletedAt(ctx)
  7422. case category.FieldName:
  7423. return m.OldName(ctx)
  7424. case category.FieldOrganizationID:
  7425. return m.OldOrganizationID(ctx)
  7426. }
  7427. return nil, fmt.Errorf("unknown Category field %s", name)
  7428. }
  7429. // SetField sets the value of a field with the given name. It returns an error if
  7430. // the field is not defined in the schema, or if the type mismatched the field
  7431. // type.
  7432. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7433. switch name {
  7434. case category.FieldCreatedAt:
  7435. v, ok := value.(time.Time)
  7436. if !ok {
  7437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7438. }
  7439. m.SetCreatedAt(v)
  7440. return nil
  7441. case category.FieldUpdatedAt:
  7442. v, ok := value.(time.Time)
  7443. if !ok {
  7444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7445. }
  7446. m.SetUpdatedAt(v)
  7447. return nil
  7448. case category.FieldDeletedAt:
  7449. v, ok := value.(time.Time)
  7450. if !ok {
  7451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7452. }
  7453. m.SetDeletedAt(v)
  7454. return nil
  7455. case category.FieldName:
  7456. v, ok := value.(string)
  7457. if !ok {
  7458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7459. }
  7460. m.SetName(v)
  7461. return nil
  7462. case category.FieldOrganizationID:
  7463. v, ok := value.(uint64)
  7464. if !ok {
  7465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7466. }
  7467. m.SetOrganizationID(v)
  7468. return nil
  7469. }
  7470. return fmt.Errorf("unknown Category field %s", name)
  7471. }
  7472. // AddedFields returns all numeric fields that were incremented/decremented during
  7473. // this mutation.
  7474. func (m *CategoryMutation) AddedFields() []string {
  7475. var fields []string
  7476. if m.addorganization_id != nil {
  7477. fields = append(fields, category.FieldOrganizationID)
  7478. }
  7479. return fields
  7480. }
  7481. // AddedField returns the numeric value that was incremented/decremented on a field
  7482. // with the given name. The second boolean return value indicates that this field
  7483. // was not set, or was not defined in the schema.
  7484. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7485. switch name {
  7486. case category.FieldOrganizationID:
  7487. return m.AddedOrganizationID()
  7488. }
  7489. return nil, false
  7490. }
  7491. // AddField adds the value to the field with the given name. It returns an error if
  7492. // the field is not defined in the schema, or if the type mismatched the field
  7493. // type.
  7494. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7495. switch name {
  7496. case category.FieldOrganizationID:
  7497. v, ok := value.(int64)
  7498. if !ok {
  7499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7500. }
  7501. m.AddOrganizationID(v)
  7502. return nil
  7503. }
  7504. return fmt.Errorf("unknown Category numeric field %s", name)
  7505. }
  7506. // ClearedFields returns all nullable fields that were cleared during this
  7507. // mutation.
  7508. func (m *CategoryMutation) ClearedFields() []string {
  7509. var fields []string
  7510. if m.FieldCleared(category.FieldDeletedAt) {
  7511. fields = append(fields, category.FieldDeletedAt)
  7512. }
  7513. return fields
  7514. }
  7515. // FieldCleared returns a boolean indicating if a field with the given name was
  7516. // cleared in this mutation.
  7517. func (m *CategoryMutation) FieldCleared(name string) bool {
  7518. _, ok := m.clearedFields[name]
  7519. return ok
  7520. }
  7521. // ClearField clears the value of the field with the given name. It returns an
  7522. // error if the field is not defined in the schema.
  7523. func (m *CategoryMutation) ClearField(name string) error {
  7524. switch name {
  7525. case category.FieldDeletedAt:
  7526. m.ClearDeletedAt()
  7527. return nil
  7528. }
  7529. return fmt.Errorf("unknown Category nullable field %s", name)
  7530. }
  7531. // ResetField resets all changes in the mutation for the field with the given name.
  7532. // It returns an error if the field is not defined in the schema.
  7533. func (m *CategoryMutation) ResetField(name string) error {
  7534. switch name {
  7535. case category.FieldCreatedAt:
  7536. m.ResetCreatedAt()
  7537. return nil
  7538. case category.FieldUpdatedAt:
  7539. m.ResetUpdatedAt()
  7540. return nil
  7541. case category.FieldDeletedAt:
  7542. m.ResetDeletedAt()
  7543. return nil
  7544. case category.FieldName:
  7545. m.ResetName()
  7546. return nil
  7547. case category.FieldOrganizationID:
  7548. m.ResetOrganizationID()
  7549. return nil
  7550. }
  7551. return fmt.Errorf("unknown Category field %s", name)
  7552. }
  7553. // AddedEdges returns all edge names that were set/added in this mutation.
  7554. func (m *CategoryMutation) AddedEdges() []string {
  7555. edges := make([]string, 0, 0)
  7556. return edges
  7557. }
  7558. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7559. // name in this mutation.
  7560. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7561. return nil
  7562. }
  7563. // RemovedEdges returns all edge names that were removed in this mutation.
  7564. func (m *CategoryMutation) RemovedEdges() []string {
  7565. edges := make([]string, 0, 0)
  7566. return edges
  7567. }
  7568. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7569. // the given name in this mutation.
  7570. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7571. return nil
  7572. }
  7573. // ClearedEdges returns all edge names that were cleared in this mutation.
  7574. func (m *CategoryMutation) ClearedEdges() []string {
  7575. edges := make([]string, 0, 0)
  7576. return edges
  7577. }
  7578. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7579. // was cleared in this mutation.
  7580. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7581. return false
  7582. }
  7583. // ClearEdge clears the value of the edge with the given name. It returns an error
  7584. // if that edge is not defined in the schema.
  7585. func (m *CategoryMutation) ClearEdge(name string) error {
  7586. return fmt.Errorf("unknown Category unique edge %s", name)
  7587. }
  7588. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7589. // It returns an error if the edge is not defined in the schema.
  7590. func (m *CategoryMutation) ResetEdge(name string) error {
  7591. return fmt.Errorf("unknown Category edge %s", name)
  7592. }
  7593. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7594. type ChatRecordsMutation struct {
  7595. config
  7596. op Op
  7597. typ string
  7598. id *uint64
  7599. created_at *time.Time
  7600. updated_at *time.Time
  7601. deleted_at *time.Time
  7602. content *string
  7603. content_type *uint8
  7604. addcontent_type *int8
  7605. session_id *uint64
  7606. addsession_id *int64
  7607. user_id *uint64
  7608. adduser_id *int64
  7609. bot_id *uint64
  7610. addbot_id *int64
  7611. bot_type *uint8
  7612. addbot_type *int8
  7613. clearedFields map[string]struct{}
  7614. done bool
  7615. oldValue func(context.Context) (*ChatRecords, error)
  7616. predicates []predicate.ChatRecords
  7617. }
  7618. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7619. // chatrecordsOption allows management of the mutation configuration using functional options.
  7620. type chatrecordsOption func(*ChatRecordsMutation)
  7621. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7622. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7623. m := &ChatRecordsMutation{
  7624. config: c,
  7625. op: op,
  7626. typ: TypeChatRecords,
  7627. clearedFields: make(map[string]struct{}),
  7628. }
  7629. for _, opt := range opts {
  7630. opt(m)
  7631. }
  7632. return m
  7633. }
  7634. // withChatRecordsID sets the ID field of the mutation.
  7635. func withChatRecordsID(id uint64) chatrecordsOption {
  7636. return func(m *ChatRecordsMutation) {
  7637. var (
  7638. err error
  7639. once sync.Once
  7640. value *ChatRecords
  7641. )
  7642. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7643. once.Do(func() {
  7644. if m.done {
  7645. err = errors.New("querying old values post mutation is not allowed")
  7646. } else {
  7647. value, err = m.Client().ChatRecords.Get(ctx, id)
  7648. }
  7649. })
  7650. return value, err
  7651. }
  7652. m.id = &id
  7653. }
  7654. }
  7655. // withChatRecords sets the old ChatRecords of the mutation.
  7656. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7657. return func(m *ChatRecordsMutation) {
  7658. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7659. return node, nil
  7660. }
  7661. m.id = &node.ID
  7662. }
  7663. }
  7664. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7665. // executed in a transaction (ent.Tx), a transactional client is returned.
  7666. func (m ChatRecordsMutation) Client() *Client {
  7667. client := &Client{config: m.config}
  7668. client.init()
  7669. return client
  7670. }
  7671. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7672. // it returns an error otherwise.
  7673. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7674. if _, ok := m.driver.(*txDriver); !ok {
  7675. return nil, errors.New("ent: mutation is not running in a transaction")
  7676. }
  7677. tx := &Tx{config: m.config}
  7678. tx.init()
  7679. return tx, nil
  7680. }
  7681. // SetID sets the value of the id field. Note that this
  7682. // operation is only accepted on creation of ChatRecords entities.
  7683. func (m *ChatRecordsMutation) SetID(id uint64) {
  7684. m.id = &id
  7685. }
  7686. // ID returns the ID value in the mutation. Note that the ID is only available
  7687. // if it was provided to the builder or after it was returned from the database.
  7688. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  7689. if m.id == nil {
  7690. return
  7691. }
  7692. return *m.id, true
  7693. }
  7694. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7695. // That means, if the mutation is applied within a transaction with an isolation level such
  7696. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7697. // or updated by the mutation.
  7698. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7699. switch {
  7700. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7701. id, exists := m.ID()
  7702. if exists {
  7703. return []uint64{id}, nil
  7704. }
  7705. fallthrough
  7706. case m.op.Is(OpUpdate | OpDelete):
  7707. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  7708. default:
  7709. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7710. }
  7711. }
  7712. // SetCreatedAt sets the "created_at" field.
  7713. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  7714. m.created_at = &t
  7715. }
  7716. // CreatedAt returns the value of the "created_at" field in the mutation.
  7717. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7718. v := m.created_at
  7719. if v == nil {
  7720. return
  7721. }
  7722. return *v, true
  7723. }
  7724. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  7725. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7727. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7728. if !m.op.Is(OpUpdateOne) {
  7729. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7730. }
  7731. if m.id == nil || m.oldValue == nil {
  7732. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7733. }
  7734. oldValue, err := m.oldValue(ctx)
  7735. if err != nil {
  7736. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7737. }
  7738. return oldValue.CreatedAt, nil
  7739. }
  7740. // ResetCreatedAt resets all changes to the "created_at" field.
  7741. func (m *ChatRecordsMutation) ResetCreatedAt() {
  7742. m.created_at = nil
  7743. }
  7744. // SetUpdatedAt sets the "updated_at" field.
  7745. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  7746. m.updated_at = &t
  7747. }
  7748. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7749. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7750. v := m.updated_at
  7751. if v == nil {
  7752. return
  7753. }
  7754. return *v, true
  7755. }
  7756. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  7757. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7759. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7760. if !m.op.Is(OpUpdateOne) {
  7761. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7762. }
  7763. if m.id == nil || m.oldValue == nil {
  7764. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7765. }
  7766. oldValue, err := m.oldValue(ctx)
  7767. if err != nil {
  7768. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7769. }
  7770. return oldValue.UpdatedAt, nil
  7771. }
  7772. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7773. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  7774. m.updated_at = nil
  7775. }
  7776. // SetDeletedAt sets the "deleted_at" field.
  7777. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  7778. m.deleted_at = &t
  7779. }
  7780. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7781. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  7782. v := m.deleted_at
  7783. if v == nil {
  7784. return
  7785. }
  7786. return *v, true
  7787. }
  7788. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  7789. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7791. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7792. if !m.op.Is(OpUpdateOne) {
  7793. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7794. }
  7795. if m.id == nil || m.oldValue == nil {
  7796. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7797. }
  7798. oldValue, err := m.oldValue(ctx)
  7799. if err != nil {
  7800. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7801. }
  7802. return oldValue.DeletedAt, nil
  7803. }
  7804. // ClearDeletedAt clears the value of the "deleted_at" field.
  7805. func (m *ChatRecordsMutation) ClearDeletedAt() {
  7806. m.deleted_at = nil
  7807. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  7808. }
  7809. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7810. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  7811. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  7812. return ok
  7813. }
  7814. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7815. func (m *ChatRecordsMutation) ResetDeletedAt() {
  7816. m.deleted_at = nil
  7817. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  7818. }
  7819. // SetContent sets the "content" field.
  7820. func (m *ChatRecordsMutation) SetContent(s string) {
  7821. m.content = &s
  7822. }
  7823. // Content returns the value of the "content" field in the mutation.
  7824. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  7825. v := m.content
  7826. if v == nil {
  7827. return
  7828. }
  7829. return *v, true
  7830. }
  7831. // OldContent returns the old "content" field's value of the ChatRecords entity.
  7832. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7834. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  7835. if !m.op.Is(OpUpdateOne) {
  7836. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7837. }
  7838. if m.id == nil || m.oldValue == nil {
  7839. return v, errors.New("OldContent requires an ID field in the mutation")
  7840. }
  7841. oldValue, err := m.oldValue(ctx)
  7842. if err != nil {
  7843. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  7844. }
  7845. return oldValue.Content, nil
  7846. }
  7847. // ResetContent resets all changes to the "content" field.
  7848. func (m *ChatRecordsMutation) ResetContent() {
  7849. m.content = nil
  7850. }
  7851. // SetContentType sets the "content_type" field.
  7852. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  7853. m.content_type = &u
  7854. m.addcontent_type = nil
  7855. }
  7856. // ContentType returns the value of the "content_type" field in the mutation.
  7857. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  7858. v := m.content_type
  7859. if v == nil {
  7860. return
  7861. }
  7862. return *v, true
  7863. }
  7864. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  7865. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7867. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  7868. if !m.op.Is(OpUpdateOne) {
  7869. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  7870. }
  7871. if m.id == nil || m.oldValue == nil {
  7872. return v, errors.New("OldContentType requires an ID field in the mutation")
  7873. }
  7874. oldValue, err := m.oldValue(ctx)
  7875. if err != nil {
  7876. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  7877. }
  7878. return oldValue.ContentType, nil
  7879. }
  7880. // AddContentType adds u to the "content_type" field.
  7881. func (m *ChatRecordsMutation) AddContentType(u int8) {
  7882. if m.addcontent_type != nil {
  7883. *m.addcontent_type += u
  7884. } else {
  7885. m.addcontent_type = &u
  7886. }
  7887. }
  7888. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  7889. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  7890. v := m.addcontent_type
  7891. if v == nil {
  7892. return
  7893. }
  7894. return *v, true
  7895. }
  7896. // ResetContentType resets all changes to the "content_type" field.
  7897. func (m *ChatRecordsMutation) ResetContentType() {
  7898. m.content_type = nil
  7899. m.addcontent_type = nil
  7900. }
  7901. // SetSessionID sets the "session_id" field.
  7902. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  7903. m.session_id = &u
  7904. m.addsession_id = nil
  7905. }
  7906. // SessionID returns the value of the "session_id" field in the mutation.
  7907. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  7908. v := m.session_id
  7909. if v == nil {
  7910. return
  7911. }
  7912. return *v, true
  7913. }
  7914. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  7915. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7917. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  7918. if !m.op.Is(OpUpdateOne) {
  7919. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  7920. }
  7921. if m.id == nil || m.oldValue == nil {
  7922. return v, errors.New("OldSessionID requires an ID field in the mutation")
  7923. }
  7924. oldValue, err := m.oldValue(ctx)
  7925. if err != nil {
  7926. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  7927. }
  7928. return oldValue.SessionID, nil
  7929. }
  7930. // AddSessionID adds u to the "session_id" field.
  7931. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  7932. if m.addsession_id != nil {
  7933. *m.addsession_id += u
  7934. } else {
  7935. m.addsession_id = &u
  7936. }
  7937. }
  7938. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  7939. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  7940. v := m.addsession_id
  7941. if v == nil {
  7942. return
  7943. }
  7944. return *v, true
  7945. }
  7946. // ResetSessionID resets all changes to the "session_id" field.
  7947. func (m *ChatRecordsMutation) ResetSessionID() {
  7948. m.session_id = nil
  7949. m.addsession_id = nil
  7950. }
  7951. // SetUserID sets the "user_id" field.
  7952. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  7953. m.user_id = &u
  7954. m.adduser_id = nil
  7955. }
  7956. // UserID returns the value of the "user_id" field in the mutation.
  7957. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  7958. v := m.user_id
  7959. if v == nil {
  7960. return
  7961. }
  7962. return *v, true
  7963. }
  7964. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  7965. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7967. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7968. if !m.op.Is(OpUpdateOne) {
  7969. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7970. }
  7971. if m.id == nil || m.oldValue == nil {
  7972. return v, errors.New("OldUserID requires an ID field in the mutation")
  7973. }
  7974. oldValue, err := m.oldValue(ctx)
  7975. if err != nil {
  7976. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7977. }
  7978. return oldValue.UserID, nil
  7979. }
  7980. // AddUserID adds u to the "user_id" field.
  7981. func (m *ChatRecordsMutation) AddUserID(u int64) {
  7982. if m.adduser_id != nil {
  7983. *m.adduser_id += u
  7984. } else {
  7985. m.adduser_id = &u
  7986. }
  7987. }
  7988. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7989. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  7990. v := m.adduser_id
  7991. if v == nil {
  7992. return
  7993. }
  7994. return *v, true
  7995. }
  7996. // ResetUserID resets all changes to the "user_id" field.
  7997. func (m *ChatRecordsMutation) ResetUserID() {
  7998. m.user_id = nil
  7999. m.adduser_id = nil
  8000. }
  8001. // SetBotID sets the "bot_id" field.
  8002. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8003. m.bot_id = &u
  8004. m.addbot_id = nil
  8005. }
  8006. // BotID returns the value of the "bot_id" field in the mutation.
  8007. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8008. v := m.bot_id
  8009. if v == nil {
  8010. return
  8011. }
  8012. return *v, true
  8013. }
  8014. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8015. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8017. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8018. if !m.op.Is(OpUpdateOne) {
  8019. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8020. }
  8021. if m.id == nil || m.oldValue == nil {
  8022. return v, errors.New("OldBotID requires an ID field in the mutation")
  8023. }
  8024. oldValue, err := m.oldValue(ctx)
  8025. if err != nil {
  8026. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8027. }
  8028. return oldValue.BotID, nil
  8029. }
  8030. // AddBotID adds u to the "bot_id" field.
  8031. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8032. if m.addbot_id != nil {
  8033. *m.addbot_id += u
  8034. } else {
  8035. m.addbot_id = &u
  8036. }
  8037. }
  8038. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8039. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8040. v := m.addbot_id
  8041. if v == nil {
  8042. return
  8043. }
  8044. return *v, true
  8045. }
  8046. // ResetBotID resets all changes to the "bot_id" field.
  8047. func (m *ChatRecordsMutation) ResetBotID() {
  8048. m.bot_id = nil
  8049. m.addbot_id = nil
  8050. }
  8051. // SetBotType sets the "bot_type" field.
  8052. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8053. m.bot_type = &u
  8054. m.addbot_type = nil
  8055. }
  8056. // BotType returns the value of the "bot_type" field in the mutation.
  8057. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8058. v := m.bot_type
  8059. if v == nil {
  8060. return
  8061. }
  8062. return *v, true
  8063. }
  8064. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8065. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8067. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8068. if !m.op.Is(OpUpdateOne) {
  8069. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8070. }
  8071. if m.id == nil || m.oldValue == nil {
  8072. return v, errors.New("OldBotType requires an ID field in the mutation")
  8073. }
  8074. oldValue, err := m.oldValue(ctx)
  8075. if err != nil {
  8076. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8077. }
  8078. return oldValue.BotType, nil
  8079. }
  8080. // AddBotType adds u to the "bot_type" field.
  8081. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8082. if m.addbot_type != nil {
  8083. *m.addbot_type += u
  8084. } else {
  8085. m.addbot_type = &u
  8086. }
  8087. }
  8088. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8089. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8090. v := m.addbot_type
  8091. if v == nil {
  8092. return
  8093. }
  8094. return *v, true
  8095. }
  8096. // ResetBotType resets all changes to the "bot_type" field.
  8097. func (m *ChatRecordsMutation) ResetBotType() {
  8098. m.bot_type = nil
  8099. m.addbot_type = nil
  8100. }
  8101. // Where appends a list predicates to the ChatRecordsMutation builder.
  8102. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8103. m.predicates = append(m.predicates, ps...)
  8104. }
  8105. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8106. // users can use type-assertion to append predicates that do not depend on any generated package.
  8107. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8108. p := make([]predicate.ChatRecords, len(ps))
  8109. for i := range ps {
  8110. p[i] = ps[i]
  8111. }
  8112. m.Where(p...)
  8113. }
  8114. // Op returns the operation name.
  8115. func (m *ChatRecordsMutation) Op() Op {
  8116. return m.op
  8117. }
  8118. // SetOp allows setting the mutation operation.
  8119. func (m *ChatRecordsMutation) SetOp(op Op) {
  8120. m.op = op
  8121. }
  8122. // Type returns the node type of this mutation (ChatRecords).
  8123. func (m *ChatRecordsMutation) Type() string {
  8124. return m.typ
  8125. }
  8126. // Fields returns all fields that were changed during this mutation. Note that in
  8127. // order to get all numeric fields that were incremented/decremented, call
  8128. // AddedFields().
  8129. func (m *ChatRecordsMutation) Fields() []string {
  8130. fields := make([]string, 0, 9)
  8131. if m.created_at != nil {
  8132. fields = append(fields, chatrecords.FieldCreatedAt)
  8133. }
  8134. if m.updated_at != nil {
  8135. fields = append(fields, chatrecords.FieldUpdatedAt)
  8136. }
  8137. if m.deleted_at != nil {
  8138. fields = append(fields, chatrecords.FieldDeletedAt)
  8139. }
  8140. if m.content != nil {
  8141. fields = append(fields, chatrecords.FieldContent)
  8142. }
  8143. if m.content_type != nil {
  8144. fields = append(fields, chatrecords.FieldContentType)
  8145. }
  8146. if m.session_id != nil {
  8147. fields = append(fields, chatrecords.FieldSessionID)
  8148. }
  8149. if m.user_id != nil {
  8150. fields = append(fields, chatrecords.FieldUserID)
  8151. }
  8152. if m.bot_id != nil {
  8153. fields = append(fields, chatrecords.FieldBotID)
  8154. }
  8155. if m.bot_type != nil {
  8156. fields = append(fields, chatrecords.FieldBotType)
  8157. }
  8158. return fields
  8159. }
  8160. // Field returns the value of a field with the given name. The second boolean
  8161. // return value indicates that this field was not set, or was not defined in the
  8162. // schema.
  8163. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8164. switch name {
  8165. case chatrecords.FieldCreatedAt:
  8166. return m.CreatedAt()
  8167. case chatrecords.FieldUpdatedAt:
  8168. return m.UpdatedAt()
  8169. case chatrecords.FieldDeletedAt:
  8170. return m.DeletedAt()
  8171. case chatrecords.FieldContent:
  8172. return m.Content()
  8173. case chatrecords.FieldContentType:
  8174. return m.ContentType()
  8175. case chatrecords.FieldSessionID:
  8176. return m.SessionID()
  8177. case chatrecords.FieldUserID:
  8178. return m.UserID()
  8179. case chatrecords.FieldBotID:
  8180. return m.BotID()
  8181. case chatrecords.FieldBotType:
  8182. return m.BotType()
  8183. }
  8184. return nil, false
  8185. }
  8186. // OldField returns the old value of the field from the database. An error is
  8187. // returned if the mutation operation is not UpdateOne, or the query to the
  8188. // database failed.
  8189. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8190. switch name {
  8191. case chatrecords.FieldCreatedAt:
  8192. return m.OldCreatedAt(ctx)
  8193. case chatrecords.FieldUpdatedAt:
  8194. return m.OldUpdatedAt(ctx)
  8195. case chatrecords.FieldDeletedAt:
  8196. return m.OldDeletedAt(ctx)
  8197. case chatrecords.FieldContent:
  8198. return m.OldContent(ctx)
  8199. case chatrecords.FieldContentType:
  8200. return m.OldContentType(ctx)
  8201. case chatrecords.FieldSessionID:
  8202. return m.OldSessionID(ctx)
  8203. case chatrecords.FieldUserID:
  8204. return m.OldUserID(ctx)
  8205. case chatrecords.FieldBotID:
  8206. return m.OldBotID(ctx)
  8207. case chatrecords.FieldBotType:
  8208. return m.OldBotType(ctx)
  8209. }
  8210. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8211. }
  8212. // SetField sets the value of a field with the given name. It returns an error if
  8213. // the field is not defined in the schema, or if the type mismatched the field
  8214. // type.
  8215. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8216. switch name {
  8217. case chatrecords.FieldCreatedAt:
  8218. v, ok := value.(time.Time)
  8219. if !ok {
  8220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8221. }
  8222. m.SetCreatedAt(v)
  8223. return nil
  8224. case chatrecords.FieldUpdatedAt:
  8225. v, ok := value.(time.Time)
  8226. if !ok {
  8227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8228. }
  8229. m.SetUpdatedAt(v)
  8230. return nil
  8231. case chatrecords.FieldDeletedAt:
  8232. v, ok := value.(time.Time)
  8233. if !ok {
  8234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8235. }
  8236. m.SetDeletedAt(v)
  8237. return nil
  8238. case chatrecords.FieldContent:
  8239. v, ok := value.(string)
  8240. if !ok {
  8241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8242. }
  8243. m.SetContent(v)
  8244. return nil
  8245. case chatrecords.FieldContentType:
  8246. v, ok := value.(uint8)
  8247. if !ok {
  8248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8249. }
  8250. m.SetContentType(v)
  8251. return nil
  8252. case chatrecords.FieldSessionID:
  8253. v, ok := value.(uint64)
  8254. if !ok {
  8255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8256. }
  8257. m.SetSessionID(v)
  8258. return nil
  8259. case chatrecords.FieldUserID:
  8260. v, ok := value.(uint64)
  8261. if !ok {
  8262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8263. }
  8264. m.SetUserID(v)
  8265. return nil
  8266. case chatrecords.FieldBotID:
  8267. v, ok := value.(uint64)
  8268. if !ok {
  8269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8270. }
  8271. m.SetBotID(v)
  8272. return nil
  8273. case chatrecords.FieldBotType:
  8274. v, ok := value.(uint8)
  8275. if !ok {
  8276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8277. }
  8278. m.SetBotType(v)
  8279. return nil
  8280. }
  8281. return fmt.Errorf("unknown ChatRecords field %s", name)
  8282. }
  8283. // AddedFields returns all numeric fields that were incremented/decremented during
  8284. // this mutation.
  8285. func (m *ChatRecordsMutation) AddedFields() []string {
  8286. var fields []string
  8287. if m.addcontent_type != nil {
  8288. fields = append(fields, chatrecords.FieldContentType)
  8289. }
  8290. if m.addsession_id != nil {
  8291. fields = append(fields, chatrecords.FieldSessionID)
  8292. }
  8293. if m.adduser_id != nil {
  8294. fields = append(fields, chatrecords.FieldUserID)
  8295. }
  8296. if m.addbot_id != nil {
  8297. fields = append(fields, chatrecords.FieldBotID)
  8298. }
  8299. if m.addbot_type != nil {
  8300. fields = append(fields, chatrecords.FieldBotType)
  8301. }
  8302. return fields
  8303. }
  8304. // AddedField returns the numeric value that was incremented/decremented on a field
  8305. // with the given name. The second boolean return value indicates that this field
  8306. // was not set, or was not defined in the schema.
  8307. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8308. switch name {
  8309. case chatrecords.FieldContentType:
  8310. return m.AddedContentType()
  8311. case chatrecords.FieldSessionID:
  8312. return m.AddedSessionID()
  8313. case chatrecords.FieldUserID:
  8314. return m.AddedUserID()
  8315. case chatrecords.FieldBotID:
  8316. return m.AddedBotID()
  8317. case chatrecords.FieldBotType:
  8318. return m.AddedBotType()
  8319. }
  8320. return nil, false
  8321. }
  8322. // AddField adds the value to the field with the given name. It returns an error if
  8323. // the field is not defined in the schema, or if the type mismatched the field
  8324. // type.
  8325. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8326. switch name {
  8327. case chatrecords.FieldContentType:
  8328. v, ok := value.(int8)
  8329. if !ok {
  8330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8331. }
  8332. m.AddContentType(v)
  8333. return nil
  8334. case chatrecords.FieldSessionID:
  8335. v, ok := value.(int64)
  8336. if !ok {
  8337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8338. }
  8339. m.AddSessionID(v)
  8340. return nil
  8341. case chatrecords.FieldUserID:
  8342. v, ok := value.(int64)
  8343. if !ok {
  8344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8345. }
  8346. m.AddUserID(v)
  8347. return nil
  8348. case chatrecords.FieldBotID:
  8349. v, ok := value.(int64)
  8350. if !ok {
  8351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8352. }
  8353. m.AddBotID(v)
  8354. return nil
  8355. case chatrecords.FieldBotType:
  8356. v, ok := value.(int8)
  8357. if !ok {
  8358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8359. }
  8360. m.AddBotType(v)
  8361. return nil
  8362. }
  8363. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8364. }
  8365. // ClearedFields returns all nullable fields that were cleared during this
  8366. // mutation.
  8367. func (m *ChatRecordsMutation) ClearedFields() []string {
  8368. var fields []string
  8369. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8370. fields = append(fields, chatrecords.FieldDeletedAt)
  8371. }
  8372. return fields
  8373. }
  8374. // FieldCleared returns a boolean indicating if a field with the given name was
  8375. // cleared in this mutation.
  8376. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8377. _, ok := m.clearedFields[name]
  8378. return ok
  8379. }
  8380. // ClearField clears the value of the field with the given name. It returns an
  8381. // error if the field is not defined in the schema.
  8382. func (m *ChatRecordsMutation) ClearField(name string) error {
  8383. switch name {
  8384. case chatrecords.FieldDeletedAt:
  8385. m.ClearDeletedAt()
  8386. return nil
  8387. }
  8388. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8389. }
  8390. // ResetField resets all changes in the mutation for the field with the given name.
  8391. // It returns an error if the field is not defined in the schema.
  8392. func (m *ChatRecordsMutation) ResetField(name string) error {
  8393. switch name {
  8394. case chatrecords.FieldCreatedAt:
  8395. m.ResetCreatedAt()
  8396. return nil
  8397. case chatrecords.FieldUpdatedAt:
  8398. m.ResetUpdatedAt()
  8399. return nil
  8400. case chatrecords.FieldDeletedAt:
  8401. m.ResetDeletedAt()
  8402. return nil
  8403. case chatrecords.FieldContent:
  8404. m.ResetContent()
  8405. return nil
  8406. case chatrecords.FieldContentType:
  8407. m.ResetContentType()
  8408. return nil
  8409. case chatrecords.FieldSessionID:
  8410. m.ResetSessionID()
  8411. return nil
  8412. case chatrecords.FieldUserID:
  8413. m.ResetUserID()
  8414. return nil
  8415. case chatrecords.FieldBotID:
  8416. m.ResetBotID()
  8417. return nil
  8418. case chatrecords.FieldBotType:
  8419. m.ResetBotType()
  8420. return nil
  8421. }
  8422. return fmt.Errorf("unknown ChatRecords field %s", name)
  8423. }
  8424. // AddedEdges returns all edge names that were set/added in this mutation.
  8425. func (m *ChatRecordsMutation) AddedEdges() []string {
  8426. edges := make([]string, 0, 0)
  8427. return edges
  8428. }
  8429. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8430. // name in this mutation.
  8431. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8432. return nil
  8433. }
  8434. // RemovedEdges returns all edge names that were removed in this mutation.
  8435. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8436. edges := make([]string, 0, 0)
  8437. return edges
  8438. }
  8439. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8440. // the given name in this mutation.
  8441. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8442. return nil
  8443. }
  8444. // ClearedEdges returns all edge names that were cleared in this mutation.
  8445. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8446. edges := make([]string, 0, 0)
  8447. return edges
  8448. }
  8449. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8450. // was cleared in this mutation.
  8451. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8452. return false
  8453. }
  8454. // ClearEdge clears the value of the edge with the given name. It returns an error
  8455. // if that edge is not defined in the schema.
  8456. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8457. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8458. }
  8459. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8460. // It returns an error if the edge is not defined in the schema.
  8461. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8462. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8463. }
  8464. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8465. type ChatSessionMutation struct {
  8466. config
  8467. op Op
  8468. typ string
  8469. id *uint64
  8470. created_at *time.Time
  8471. updated_at *time.Time
  8472. deleted_at *time.Time
  8473. name *string
  8474. user_id *uint64
  8475. adduser_id *int64
  8476. bot_id *uint64
  8477. addbot_id *int64
  8478. bot_type *uint8
  8479. addbot_type *int8
  8480. clearedFields map[string]struct{}
  8481. done bool
  8482. oldValue func(context.Context) (*ChatSession, error)
  8483. predicates []predicate.ChatSession
  8484. }
  8485. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8486. // chatsessionOption allows management of the mutation configuration using functional options.
  8487. type chatsessionOption func(*ChatSessionMutation)
  8488. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8489. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8490. m := &ChatSessionMutation{
  8491. config: c,
  8492. op: op,
  8493. typ: TypeChatSession,
  8494. clearedFields: make(map[string]struct{}),
  8495. }
  8496. for _, opt := range opts {
  8497. opt(m)
  8498. }
  8499. return m
  8500. }
  8501. // withChatSessionID sets the ID field of the mutation.
  8502. func withChatSessionID(id uint64) chatsessionOption {
  8503. return func(m *ChatSessionMutation) {
  8504. var (
  8505. err error
  8506. once sync.Once
  8507. value *ChatSession
  8508. )
  8509. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8510. once.Do(func() {
  8511. if m.done {
  8512. err = errors.New("querying old values post mutation is not allowed")
  8513. } else {
  8514. value, err = m.Client().ChatSession.Get(ctx, id)
  8515. }
  8516. })
  8517. return value, err
  8518. }
  8519. m.id = &id
  8520. }
  8521. }
  8522. // withChatSession sets the old ChatSession of the mutation.
  8523. func withChatSession(node *ChatSession) chatsessionOption {
  8524. return func(m *ChatSessionMutation) {
  8525. m.oldValue = func(context.Context) (*ChatSession, error) {
  8526. return node, nil
  8527. }
  8528. m.id = &node.ID
  8529. }
  8530. }
  8531. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8532. // executed in a transaction (ent.Tx), a transactional client is returned.
  8533. func (m ChatSessionMutation) Client() *Client {
  8534. client := &Client{config: m.config}
  8535. client.init()
  8536. return client
  8537. }
  8538. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8539. // it returns an error otherwise.
  8540. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8541. if _, ok := m.driver.(*txDriver); !ok {
  8542. return nil, errors.New("ent: mutation is not running in a transaction")
  8543. }
  8544. tx := &Tx{config: m.config}
  8545. tx.init()
  8546. return tx, nil
  8547. }
  8548. // SetID sets the value of the id field. Note that this
  8549. // operation is only accepted on creation of ChatSession entities.
  8550. func (m *ChatSessionMutation) SetID(id uint64) {
  8551. m.id = &id
  8552. }
  8553. // ID returns the ID value in the mutation. Note that the ID is only available
  8554. // if it was provided to the builder or after it was returned from the database.
  8555. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8556. if m.id == nil {
  8557. return
  8558. }
  8559. return *m.id, true
  8560. }
  8561. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8562. // That means, if the mutation is applied within a transaction with an isolation level such
  8563. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8564. // or updated by the mutation.
  8565. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8566. switch {
  8567. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8568. id, exists := m.ID()
  8569. if exists {
  8570. return []uint64{id}, nil
  8571. }
  8572. fallthrough
  8573. case m.op.Is(OpUpdate | OpDelete):
  8574. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8575. default:
  8576. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8577. }
  8578. }
  8579. // SetCreatedAt sets the "created_at" field.
  8580. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8581. m.created_at = &t
  8582. }
  8583. // CreatedAt returns the value of the "created_at" field in the mutation.
  8584. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8585. v := m.created_at
  8586. if v == nil {
  8587. return
  8588. }
  8589. return *v, true
  8590. }
  8591. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8592. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8594. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8595. if !m.op.Is(OpUpdateOne) {
  8596. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8597. }
  8598. if m.id == nil || m.oldValue == nil {
  8599. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8600. }
  8601. oldValue, err := m.oldValue(ctx)
  8602. if err != nil {
  8603. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8604. }
  8605. return oldValue.CreatedAt, nil
  8606. }
  8607. // ResetCreatedAt resets all changes to the "created_at" field.
  8608. func (m *ChatSessionMutation) ResetCreatedAt() {
  8609. m.created_at = nil
  8610. }
  8611. // SetUpdatedAt sets the "updated_at" field.
  8612. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8613. m.updated_at = &t
  8614. }
  8615. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8616. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8617. v := m.updated_at
  8618. if v == nil {
  8619. return
  8620. }
  8621. return *v, true
  8622. }
  8623. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8624. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8626. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8627. if !m.op.Is(OpUpdateOne) {
  8628. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8629. }
  8630. if m.id == nil || m.oldValue == nil {
  8631. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8632. }
  8633. oldValue, err := m.oldValue(ctx)
  8634. if err != nil {
  8635. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8636. }
  8637. return oldValue.UpdatedAt, nil
  8638. }
  8639. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8640. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8641. m.updated_at = nil
  8642. }
  8643. // SetDeletedAt sets the "deleted_at" field.
  8644. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8645. m.deleted_at = &t
  8646. }
  8647. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8648. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8649. v := m.deleted_at
  8650. if v == nil {
  8651. return
  8652. }
  8653. return *v, true
  8654. }
  8655. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8656. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8658. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8659. if !m.op.Is(OpUpdateOne) {
  8660. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8661. }
  8662. if m.id == nil || m.oldValue == nil {
  8663. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8664. }
  8665. oldValue, err := m.oldValue(ctx)
  8666. if err != nil {
  8667. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8668. }
  8669. return oldValue.DeletedAt, nil
  8670. }
  8671. // ClearDeletedAt clears the value of the "deleted_at" field.
  8672. func (m *ChatSessionMutation) ClearDeletedAt() {
  8673. m.deleted_at = nil
  8674. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8675. }
  8676. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8677. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  8678. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  8679. return ok
  8680. }
  8681. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8682. func (m *ChatSessionMutation) ResetDeletedAt() {
  8683. m.deleted_at = nil
  8684. delete(m.clearedFields, chatsession.FieldDeletedAt)
  8685. }
  8686. // SetName sets the "name" field.
  8687. func (m *ChatSessionMutation) SetName(s string) {
  8688. m.name = &s
  8689. }
  8690. // Name returns the value of the "name" field in the mutation.
  8691. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  8692. v := m.name
  8693. if v == nil {
  8694. return
  8695. }
  8696. return *v, true
  8697. }
  8698. // OldName returns the old "name" field's value of the ChatSession entity.
  8699. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8701. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  8702. if !m.op.Is(OpUpdateOne) {
  8703. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8704. }
  8705. if m.id == nil || m.oldValue == nil {
  8706. return v, errors.New("OldName requires an ID field in the mutation")
  8707. }
  8708. oldValue, err := m.oldValue(ctx)
  8709. if err != nil {
  8710. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8711. }
  8712. return oldValue.Name, nil
  8713. }
  8714. // ResetName resets all changes to the "name" field.
  8715. func (m *ChatSessionMutation) ResetName() {
  8716. m.name = nil
  8717. }
  8718. // SetUserID sets the "user_id" field.
  8719. func (m *ChatSessionMutation) SetUserID(u uint64) {
  8720. m.user_id = &u
  8721. m.adduser_id = nil
  8722. }
  8723. // UserID returns the value of the "user_id" field in the mutation.
  8724. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  8725. v := m.user_id
  8726. if v == nil {
  8727. return
  8728. }
  8729. return *v, true
  8730. }
  8731. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  8732. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8734. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8735. if !m.op.Is(OpUpdateOne) {
  8736. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8737. }
  8738. if m.id == nil || m.oldValue == nil {
  8739. return v, errors.New("OldUserID requires an ID field in the mutation")
  8740. }
  8741. oldValue, err := m.oldValue(ctx)
  8742. if err != nil {
  8743. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8744. }
  8745. return oldValue.UserID, nil
  8746. }
  8747. // AddUserID adds u to the "user_id" field.
  8748. func (m *ChatSessionMutation) AddUserID(u int64) {
  8749. if m.adduser_id != nil {
  8750. *m.adduser_id += u
  8751. } else {
  8752. m.adduser_id = &u
  8753. }
  8754. }
  8755. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8756. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  8757. v := m.adduser_id
  8758. if v == nil {
  8759. return
  8760. }
  8761. return *v, true
  8762. }
  8763. // ResetUserID resets all changes to the "user_id" field.
  8764. func (m *ChatSessionMutation) ResetUserID() {
  8765. m.user_id = nil
  8766. m.adduser_id = nil
  8767. }
  8768. // SetBotID sets the "bot_id" field.
  8769. func (m *ChatSessionMutation) SetBotID(u uint64) {
  8770. m.bot_id = &u
  8771. m.addbot_id = nil
  8772. }
  8773. // BotID returns the value of the "bot_id" field in the mutation.
  8774. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  8775. v := m.bot_id
  8776. if v == nil {
  8777. return
  8778. }
  8779. return *v, true
  8780. }
  8781. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  8782. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8784. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8785. if !m.op.Is(OpUpdateOne) {
  8786. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8787. }
  8788. if m.id == nil || m.oldValue == nil {
  8789. return v, errors.New("OldBotID requires an ID field in the mutation")
  8790. }
  8791. oldValue, err := m.oldValue(ctx)
  8792. if err != nil {
  8793. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8794. }
  8795. return oldValue.BotID, nil
  8796. }
  8797. // AddBotID adds u to the "bot_id" field.
  8798. func (m *ChatSessionMutation) AddBotID(u int64) {
  8799. if m.addbot_id != nil {
  8800. *m.addbot_id += u
  8801. } else {
  8802. m.addbot_id = &u
  8803. }
  8804. }
  8805. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8806. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  8807. v := m.addbot_id
  8808. if v == nil {
  8809. return
  8810. }
  8811. return *v, true
  8812. }
  8813. // ResetBotID resets all changes to the "bot_id" field.
  8814. func (m *ChatSessionMutation) ResetBotID() {
  8815. m.bot_id = nil
  8816. m.addbot_id = nil
  8817. }
  8818. // SetBotType sets the "bot_type" field.
  8819. func (m *ChatSessionMutation) SetBotType(u uint8) {
  8820. m.bot_type = &u
  8821. m.addbot_type = nil
  8822. }
  8823. // BotType returns the value of the "bot_type" field in the mutation.
  8824. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  8825. v := m.bot_type
  8826. if v == nil {
  8827. return
  8828. }
  8829. return *v, true
  8830. }
  8831. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  8832. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8834. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8835. if !m.op.Is(OpUpdateOne) {
  8836. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8837. }
  8838. if m.id == nil || m.oldValue == nil {
  8839. return v, errors.New("OldBotType requires an ID field in the mutation")
  8840. }
  8841. oldValue, err := m.oldValue(ctx)
  8842. if err != nil {
  8843. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8844. }
  8845. return oldValue.BotType, nil
  8846. }
  8847. // AddBotType adds u to the "bot_type" field.
  8848. func (m *ChatSessionMutation) AddBotType(u int8) {
  8849. if m.addbot_type != nil {
  8850. *m.addbot_type += u
  8851. } else {
  8852. m.addbot_type = &u
  8853. }
  8854. }
  8855. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8856. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  8857. v := m.addbot_type
  8858. if v == nil {
  8859. return
  8860. }
  8861. return *v, true
  8862. }
  8863. // ResetBotType resets all changes to the "bot_type" field.
  8864. func (m *ChatSessionMutation) ResetBotType() {
  8865. m.bot_type = nil
  8866. m.addbot_type = nil
  8867. }
  8868. // Where appends a list predicates to the ChatSessionMutation builder.
  8869. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  8870. m.predicates = append(m.predicates, ps...)
  8871. }
  8872. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  8873. // users can use type-assertion to append predicates that do not depend on any generated package.
  8874. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  8875. p := make([]predicate.ChatSession, len(ps))
  8876. for i := range ps {
  8877. p[i] = ps[i]
  8878. }
  8879. m.Where(p...)
  8880. }
  8881. // Op returns the operation name.
  8882. func (m *ChatSessionMutation) Op() Op {
  8883. return m.op
  8884. }
  8885. // SetOp allows setting the mutation operation.
  8886. func (m *ChatSessionMutation) SetOp(op Op) {
  8887. m.op = op
  8888. }
  8889. // Type returns the node type of this mutation (ChatSession).
  8890. func (m *ChatSessionMutation) Type() string {
  8891. return m.typ
  8892. }
  8893. // Fields returns all fields that were changed during this mutation. Note that in
  8894. // order to get all numeric fields that were incremented/decremented, call
  8895. // AddedFields().
  8896. func (m *ChatSessionMutation) Fields() []string {
  8897. fields := make([]string, 0, 7)
  8898. if m.created_at != nil {
  8899. fields = append(fields, chatsession.FieldCreatedAt)
  8900. }
  8901. if m.updated_at != nil {
  8902. fields = append(fields, chatsession.FieldUpdatedAt)
  8903. }
  8904. if m.deleted_at != nil {
  8905. fields = append(fields, chatsession.FieldDeletedAt)
  8906. }
  8907. if m.name != nil {
  8908. fields = append(fields, chatsession.FieldName)
  8909. }
  8910. if m.user_id != nil {
  8911. fields = append(fields, chatsession.FieldUserID)
  8912. }
  8913. if m.bot_id != nil {
  8914. fields = append(fields, chatsession.FieldBotID)
  8915. }
  8916. if m.bot_type != nil {
  8917. fields = append(fields, chatsession.FieldBotType)
  8918. }
  8919. return fields
  8920. }
  8921. // Field returns the value of a field with the given name. The second boolean
  8922. // return value indicates that this field was not set, or was not defined in the
  8923. // schema.
  8924. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  8925. switch name {
  8926. case chatsession.FieldCreatedAt:
  8927. return m.CreatedAt()
  8928. case chatsession.FieldUpdatedAt:
  8929. return m.UpdatedAt()
  8930. case chatsession.FieldDeletedAt:
  8931. return m.DeletedAt()
  8932. case chatsession.FieldName:
  8933. return m.Name()
  8934. case chatsession.FieldUserID:
  8935. return m.UserID()
  8936. case chatsession.FieldBotID:
  8937. return m.BotID()
  8938. case chatsession.FieldBotType:
  8939. return m.BotType()
  8940. }
  8941. return nil, false
  8942. }
  8943. // OldField returns the old value of the field from the database. An error is
  8944. // returned if the mutation operation is not UpdateOne, or the query to the
  8945. // database failed.
  8946. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8947. switch name {
  8948. case chatsession.FieldCreatedAt:
  8949. return m.OldCreatedAt(ctx)
  8950. case chatsession.FieldUpdatedAt:
  8951. return m.OldUpdatedAt(ctx)
  8952. case chatsession.FieldDeletedAt:
  8953. return m.OldDeletedAt(ctx)
  8954. case chatsession.FieldName:
  8955. return m.OldName(ctx)
  8956. case chatsession.FieldUserID:
  8957. return m.OldUserID(ctx)
  8958. case chatsession.FieldBotID:
  8959. return m.OldBotID(ctx)
  8960. case chatsession.FieldBotType:
  8961. return m.OldBotType(ctx)
  8962. }
  8963. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  8964. }
  8965. // SetField sets the value of a field with the given name. It returns an error if
  8966. // the field is not defined in the schema, or if the type mismatched the field
  8967. // type.
  8968. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  8969. switch name {
  8970. case chatsession.FieldCreatedAt:
  8971. v, ok := value.(time.Time)
  8972. if !ok {
  8973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8974. }
  8975. m.SetCreatedAt(v)
  8976. return nil
  8977. case chatsession.FieldUpdatedAt:
  8978. v, ok := value.(time.Time)
  8979. if !ok {
  8980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8981. }
  8982. m.SetUpdatedAt(v)
  8983. return nil
  8984. case chatsession.FieldDeletedAt:
  8985. v, ok := value.(time.Time)
  8986. if !ok {
  8987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8988. }
  8989. m.SetDeletedAt(v)
  8990. return nil
  8991. case chatsession.FieldName:
  8992. v, ok := value.(string)
  8993. if !ok {
  8994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8995. }
  8996. m.SetName(v)
  8997. return nil
  8998. case chatsession.FieldUserID:
  8999. v, ok := value.(uint64)
  9000. if !ok {
  9001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9002. }
  9003. m.SetUserID(v)
  9004. return nil
  9005. case chatsession.FieldBotID:
  9006. v, ok := value.(uint64)
  9007. if !ok {
  9008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9009. }
  9010. m.SetBotID(v)
  9011. return nil
  9012. case chatsession.FieldBotType:
  9013. v, ok := value.(uint8)
  9014. if !ok {
  9015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9016. }
  9017. m.SetBotType(v)
  9018. return nil
  9019. }
  9020. return fmt.Errorf("unknown ChatSession field %s", name)
  9021. }
  9022. // AddedFields returns all numeric fields that were incremented/decremented during
  9023. // this mutation.
  9024. func (m *ChatSessionMutation) AddedFields() []string {
  9025. var fields []string
  9026. if m.adduser_id != nil {
  9027. fields = append(fields, chatsession.FieldUserID)
  9028. }
  9029. if m.addbot_id != nil {
  9030. fields = append(fields, chatsession.FieldBotID)
  9031. }
  9032. if m.addbot_type != nil {
  9033. fields = append(fields, chatsession.FieldBotType)
  9034. }
  9035. return fields
  9036. }
  9037. // AddedField returns the numeric value that was incremented/decremented on a field
  9038. // with the given name. The second boolean return value indicates that this field
  9039. // was not set, or was not defined in the schema.
  9040. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9041. switch name {
  9042. case chatsession.FieldUserID:
  9043. return m.AddedUserID()
  9044. case chatsession.FieldBotID:
  9045. return m.AddedBotID()
  9046. case chatsession.FieldBotType:
  9047. return m.AddedBotType()
  9048. }
  9049. return nil, false
  9050. }
  9051. // AddField adds the value to the field with the given name. It returns an error if
  9052. // the field is not defined in the schema, or if the type mismatched the field
  9053. // type.
  9054. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9055. switch name {
  9056. case chatsession.FieldUserID:
  9057. v, ok := value.(int64)
  9058. if !ok {
  9059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9060. }
  9061. m.AddUserID(v)
  9062. return nil
  9063. case chatsession.FieldBotID:
  9064. v, ok := value.(int64)
  9065. if !ok {
  9066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9067. }
  9068. m.AddBotID(v)
  9069. return nil
  9070. case chatsession.FieldBotType:
  9071. v, ok := value.(int8)
  9072. if !ok {
  9073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9074. }
  9075. m.AddBotType(v)
  9076. return nil
  9077. }
  9078. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9079. }
  9080. // ClearedFields returns all nullable fields that were cleared during this
  9081. // mutation.
  9082. func (m *ChatSessionMutation) ClearedFields() []string {
  9083. var fields []string
  9084. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9085. fields = append(fields, chatsession.FieldDeletedAt)
  9086. }
  9087. return fields
  9088. }
  9089. // FieldCleared returns a boolean indicating if a field with the given name was
  9090. // cleared in this mutation.
  9091. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9092. _, ok := m.clearedFields[name]
  9093. return ok
  9094. }
  9095. // ClearField clears the value of the field with the given name. It returns an
  9096. // error if the field is not defined in the schema.
  9097. func (m *ChatSessionMutation) ClearField(name string) error {
  9098. switch name {
  9099. case chatsession.FieldDeletedAt:
  9100. m.ClearDeletedAt()
  9101. return nil
  9102. }
  9103. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9104. }
  9105. // ResetField resets all changes in the mutation for the field with the given name.
  9106. // It returns an error if the field is not defined in the schema.
  9107. func (m *ChatSessionMutation) ResetField(name string) error {
  9108. switch name {
  9109. case chatsession.FieldCreatedAt:
  9110. m.ResetCreatedAt()
  9111. return nil
  9112. case chatsession.FieldUpdatedAt:
  9113. m.ResetUpdatedAt()
  9114. return nil
  9115. case chatsession.FieldDeletedAt:
  9116. m.ResetDeletedAt()
  9117. return nil
  9118. case chatsession.FieldName:
  9119. m.ResetName()
  9120. return nil
  9121. case chatsession.FieldUserID:
  9122. m.ResetUserID()
  9123. return nil
  9124. case chatsession.FieldBotID:
  9125. m.ResetBotID()
  9126. return nil
  9127. case chatsession.FieldBotType:
  9128. m.ResetBotType()
  9129. return nil
  9130. }
  9131. return fmt.Errorf("unknown ChatSession field %s", name)
  9132. }
  9133. // AddedEdges returns all edge names that were set/added in this mutation.
  9134. func (m *ChatSessionMutation) AddedEdges() []string {
  9135. edges := make([]string, 0, 0)
  9136. return edges
  9137. }
  9138. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9139. // name in this mutation.
  9140. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9141. return nil
  9142. }
  9143. // RemovedEdges returns all edge names that were removed in this mutation.
  9144. func (m *ChatSessionMutation) RemovedEdges() []string {
  9145. edges := make([]string, 0, 0)
  9146. return edges
  9147. }
  9148. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9149. // the given name in this mutation.
  9150. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9151. return nil
  9152. }
  9153. // ClearedEdges returns all edge names that were cleared in this mutation.
  9154. func (m *ChatSessionMutation) ClearedEdges() []string {
  9155. edges := make([]string, 0, 0)
  9156. return edges
  9157. }
  9158. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9159. // was cleared in this mutation.
  9160. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9161. return false
  9162. }
  9163. // ClearEdge clears the value of the edge with the given name. It returns an error
  9164. // if that edge is not defined in the schema.
  9165. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9166. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9167. }
  9168. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9169. // It returns an error if the edge is not defined in the schema.
  9170. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9171. return fmt.Errorf("unknown ChatSession edge %s", name)
  9172. }
  9173. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  9174. type ContactMutation struct {
  9175. config
  9176. op Op
  9177. typ string
  9178. id *uint64
  9179. created_at *time.Time
  9180. updated_at *time.Time
  9181. status *uint8
  9182. addstatus *int8
  9183. deleted_at *time.Time
  9184. wx_wxid *string
  9185. _type *int
  9186. add_type *int
  9187. wxid *string
  9188. account *string
  9189. nickname *string
  9190. markname *string
  9191. headimg *string
  9192. sex *int
  9193. addsex *int
  9194. starrole *string
  9195. dontseeit *int
  9196. adddontseeit *int
  9197. dontseeme *int
  9198. adddontseeme *int
  9199. lag *string
  9200. gid *string
  9201. gname *string
  9202. v3 *string
  9203. organization_id *uint64
  9204. addorganization_id *int64
  9205. ctype *uint64
  9206. addctype *int64
  9207. cage *int
  9208. addcage *int
  9209. cname *string
  9210. carea *string
  9211. cbirthday *string
  9212. cbirtharea *string
  9213. cidcard_no *string
  9214. ctitle *string
  9215. cc *string
  9216. phone *string
  9217. clearedFields map[string]struct{}
  9218. contact_relationships map[uint64]struct{}
  9219. removedcontact_relationships map[uint64]struct{}
  9220. clearedcontact_relationships bool
  9221. contact_messages map[uint64]struct{}
  9222. removedcontact_messages map[uint64]struct{}
  9223. clearedcontact_messages bool
  9224. done bool
  9225. oldValue func(context.Context) (*Contact, error)
  9226. predicates []predicate.Contact
  9227. }
  9228. var _ ent.Mutation = (*ContactMutation)(nil)
  9229. // contactOption allows management of the mutation configuration using functional options.
  9230. type contactOption func(*ContactMutation)
  9231. // newContactMutation creates new mutation for the Contact entity.
  9232. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  9233. m := &ContactMutation{
  9234. config: c,
  9235. op: op,
  9236. typ: TypeContact,
  9237. clearedFields: make(map[string]struct{}),
  9238. }
  9239. for _, opt := range opts {
  9240. opt(m)
  9241. }
  9242. return m
  9243. }
  9244. // withContactID sets the ID field of the mutation.
  9245. func withContactID(id uint64) contactOption {
  9246. return func(m *ContactMutation) {
  9247. var (
  9248. err error
  9249. once sync.Once
  9250. value *Contact
  9251. )
  9252. m.oldValue = func(ctx context.Context) (*Contact, error) {
  9253. once.Do(func() {
  9254. if m.done {
  9255. err = errors.New("querying old values post mutation is not allowed")
  9256. } else {
  9257. value, err = m.Client().Contact.Get(ctx, id)
  9258. }
  9259. })
  9260. return value, err
  9261. }
  9262. m.id = &id
  9263. }
  9264. }
  9265. // withContact sets the old Contact of the mutation.
  9266. func withContact(node *Contact) contactOption {
  9267. return func(m *ContactMutation) {
  9268. m.oldValue = func(context.Context) (*Contact, error) {
  9269. return node, nil
  9270. }
  9271. m.id = &node.ID
  9272. }
  9273. }
  9274. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9275. // executed in a transaction (ent.Tx), a transactional client is returned.
  9276. func (m ContactMutation) Client() *Client {
  9277. client := &Client{config: m.config}
  9278. client.init()
  9279. return client
  9280. }
  9281. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9282. // it returns an error otherwise.
  9283. func (m ContactMutation) Tx() (*Tx, error) {
  9284. if _, ok := m.driver.(*txDriver); !ok {
  9285. return nil, errors.New("ent: mutation is not running in a transaction")
  9286. }
  9287. tx := &Tx{config: m.config}
  9288. tx.init()
  9289. return tx, nil
  9290. }
  9291. // SetID sets the value of the id field. Note that this
  9292. // operation is only accepted on creation of Contact entities.
  9293. func (m *ContactMutation) SetID(id uint64) {
  9294. m.id = &id
  9295. }
  9296. // ID returns the ID value in the mutation. Note that the ID is only available
  9297. // if it was provided to the builder or after it was returned from the database.
  9298. func (m *ContactMutation) ID() (id uint64, exists bool) {
  9299. if m.id == nil {
  9300. return
  9301. }
  9302. return *m.id, true
  9303. }
  9304. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9305. // That means, if the mutation is applied within a transaction with an isolation level such
  9306. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9307. // or updated by the mutation.
  9308. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  9309. switch {
  9310. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9311. id, exists := m.ID()
  9312. if exists {
  9313. return []uint64{id}, nil
  9314. }
  9315. fallthrough
  9316. case m.op.Is(OpUpdate | OpDelete):
  9317. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  9318. default:
  9319. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9320. }
  9321. }
  9322. // SetCreatedAt sets the "created_at" field.
  9323. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  9324. m.created_at = &t
  9325. }
  9326. // CreatedAt returns the value of the "created_at" field in the mutation.
  9327. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  9328. v := m.created_at
  9329. if v == nil {
  9330. return
  9331. }
  9332. return *v, true
  9333. }
  9334. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  9335. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9337. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9338. if !m.op.Is(OpUpdateOne) {
  9339. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9340. }
  9341. if m.id == nil || m.oldValue == nil {
  9342. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9343. }
  9344. oldValue, err := m.oldValue(ctx)
  9345. if err != nil {
  9346. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9347. }
  9348. return oldValue.CreatedAt, nil
  9349. }
  9350. // ResetCreatedAt resets all changes to the "created_at" field.
  9351. func (m *ContactMutation) ResetCreatedAt() {
  9352. m.created_at = nil
  9353. }
  9354. // SetUpdatedAt sets the "updated_at" field.
  9355. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  9356. m.updated_at = &t
  9357. }
  9358. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9359. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  9360. v := m.updated_at
  9361. if v == nil {
  9362. return
  9363. }
  9364. return *v, true
  9365. }
  9366. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  9367. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9369. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9370. if !m.op.Is(OpUpdateOne) {
  9371. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9372. }
  9373. if m.id == nil || m.oldValue == nil {
  9374. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9375. }
  9376. oldValue, err := m.oldValue(ctx)
  9377. if err != nil {
  9378. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9379. }
  9380. return oldValue.UpdatedAt, nil
  9381. }
  9382. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9383. func (m *ContactMutation) ResetUpdatedAt() {
  9384. m.updated_at = nil
  9385. }
  9386. // SetStatus sets the "status" field.
  9387. func (m *ContactMutation) SetStatus(u uint8) {
  9388. m.status = &u
  9389. m.addstatus = nil
  9390. }
  9391. // Status returns the value of the "status" field in the mutation.
  9392. func (m *ContactMutation) Status() (r uint8, exists bool) {
  9393. v := m.status
  9394. if v == nil {
  9395. return
  9396. }
  9397. return *v, true
  9398. }
  9399. // OldStatus returns the old "status" field's value of the Contact entity.
  9400. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9402. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9403. if !m.op.Is(OpUpdateOne) {
  9404. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9405. }
  9406. if m.id == nil || m.oldValue == nil {
  9407. return v, errors.New("OldStatus requires an ID field in the mutation")
  9408. }
  9409. oldValue, err := m.oldValue(ctx)
  9410. if err != nil {
  9411. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9412. }
  9413. return oldValue.Status, nil
  9414. }
  9415. // AddStatus adds u to the "status" field.
  9416. func (m *ContactMutation) AddStatus(u int8) {
  9417. if m.addstatus != nil {
  9418. *m.addstatus += u
  9419. } else {
  9420. m.addstatus = &u
  9421. }
  9422. }
  9423. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9424. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  9425. v := m.addstatus
  9426. if v == nil {
  9427. return
  9428. }
  9429. return *v, true
  9430. }
  9431. // ClearStatus clears the value of the "status" field.
  9432. func (m *ContactMutation) ClearStatus() {
  9433. m.status = nil
  9434. m.addstatus = nil
  9435. m.clearedFields[contact.FieldStatus] = struct{}{}
  9436. }
  9437. // StatusCleared returns if the "status" field was cleared in this mutation.
  9438. func (m *ContactMutation) StatusCleared() bool {
  9439. _, ok := m.clearedFields[contact.FieldStatus]
  9440. return ok
  9441. }
  9442. // ResetStatus resets all changes to the "status" field.
  9443. func (m *ContactMutation) ResetStatus() {
  9444. m.status = nil
  9445. m.addstatus = nil
  9446. delete(m.clearedFields, contact.FieldStatus)
  9447. }
  9448. // SetDeletedAt sets the "deleted_at" field.
  9449. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  9450. m.deleted_at = &t
  9451. }
  9452. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9453. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  9454. v := m.deleted_at
  9455. if v == nil {
  9456. return
  9457. }
  9458. return *v, true
  9459. }
  9460. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  9461. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9463. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9464. if !m.op.Is(OpUpdateOne) {
  9465. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9466. }
  9467. if m.id == nil || m.oldValue == nil {
  9468. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9469. }
  9470. oldValue, err := m.oldValue(ctx)
  9471. if err != nil {
  9472. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9473. }
  9474. return oldValue.DeletedAt, nil
  9475. }
  9476. // ClearDeletedAt clears the value of the "deleted_at" field.
  9477. func (m *ContactMutation) ClearDeletedAt() {
  9478. m.deleted_at = nil
  9479. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  9480. }
  9481. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9482. func (m *ContactMutation) DeletedAtCleared() bool {
  9483. _, ok := m.clearedFields[contact.FieldDeletedAt]
  9484. return ok
  9485. }
  9486. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9487. func (m *ContactMutation) ResetDeletedAt() {
  9488. m.deleted_at = nil
  9489. delete(m.clearedFields, contact.FieldDeletedAt)
  9490. }
  9491. // SetWxWxid sets the "wx_wxid" field.
  9492. func (m *ContactMutation) SetWxWxid(s string) {
  9493. m.wx_wxid = &s
  9494. }
  9495. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  9496. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  9497. v := m.wx_wxid
  9498. if v == nil {
  9499. return
  9500. }
  9501. return *v, true
  9502. }
  9503. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  9504. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9506. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  9507. if !m.op.Is(OpUpdateOne) {
  9508. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  9509. }
  9510. if m.id == nil || m.oldValue == nil {
  9511. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  9512. }
  9513. oldValue, err := m.oldValue(ctx)
  9514. if err != nil {
  9515. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9516. }
  9517. return oldValue.WxWxid, nil
  9518. }
  9519. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9520. func (m *ContactMutation) ResetWxWxid() {
  9521. m.wx_wxid = nil
  9522. }
  9523. // SetType sets the "type" field.
  9524. func (m *ContactMutation) SetType(i int) {
  9525. m._type = &i
  9526. m.add_type = nil
  9527. }
  9528. // GetType returns the value of the "type" field in the mutation.
  9529. func (m *ContactMutation) GetType() (r int, exists bool) {
  9530. v := m._type
  9531. if v == nil {
  9532. return
  9533. }
  9534. return *v, true
  9535. }
  9536. // OldType returns the old "type" field's value of the Contact entity.
  9537. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9539. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  9540. if !m.op.Is(OpUpdateOne) {
  9541. return v, errors.New("OldType is only allowed on UpdateOne operations")
  9542. }
  9543. if m.id == nil || m.oldValue == nil {
  9544. return v, errors.New("OldType requires an ID field in the mutation")
  9545. }
  9546. oldValue, err := m.oldValue(ctx)
  9547. if err != nil {
  9548. return v, fmt.Errorf("querying old value for OldType: %w", err)
  9549. }
  9550. return oldValue.Type, nil
  9551. }
  9552. // AddType adds i to the "type" field.
  9553. func (m *ContactMutation) AddType(i int) {
  9554. if m.add_type != nil {
  9555. *m.add_type += i
  9556. } else {
  9557. m.add_type = &i
  9558. }
  9559. }
  9560. // AddedType returns the value that was added to the "type" field in this mutation.
  9561. func (m *ContactMutation) AddedType() (r int, exists bool) {
  9562. v := m.add_type
  9563. if v == nil {
  9564. return
  9565. }
  9566. return *v, true
  9567. }
  9568. // ClearType clears the value of the "type" field.
  9569. func (m *ContactMutation) ClearType() {
  9570. m._type = nil
  9571. m.add_type = nil
  9572. m.clearedFields[contact.FieldType] = struct{}{}
  9573. }
  9574. // TypeCleared returns if the "type" field was cleared in this mutation.
  9575. func (m *ContactMutation) TypeCleared() bool {
  9576. _, ok := m.clearedFields[contact.FieldType]
  9577. return ok
  9578. }
  9579. // ResetType resets all changes to the "type" field.
  9580. func (m *ContactMutation) ResetType() {
  9581. m._type = nil
  9582. m.add_type = nil
  9583. delete(m.clearedFields, contact.FieldType)
  9584. }
  9585. // SetWxid sets the "wxid" field.
  9586. func (m *ContactMutation) SetWxid(s string) {
  9587. m.wxid = &s
  9588. }
  9589. // Wxid returns the value of the "wxid" field in the mutation.
  9590. func (m *ContactMutation) Wxid() (r string, exists bool) {
  9591. v := m.wxid
  9592. if v == nil {
  9593. return
  9594. }
  9595. return *v, true
  9596. }
  9597. // OldWxid returns the old "wxid" field's value of the Contact entity.
  9598. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9600. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  9601. if !m.op.Is(OpUpdateOne) {
  9602. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9603. }
  9604. if m.id == nil || m.oldValue == nil {
  9605. return v, errors.New("OldWxid requires an ID field in the mutation")
  9606. }
  9607. oldValue, err := m.oldValue(ctx)
  9608. if err != nil {
  9609. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9610. }
  9611. return oldValue.Wxid, nil
  9612. }
  9613. // ResetWxid resets all changes to the "wxid" field.
  9614. func (m *ContactMutation) ResetWxid() {
  9615. m.wxid = nil
  9616. }
  9617. // SetAccount sets the "account" field.
  9618. func (m *ContactMutation) SetAccount(s string) {
  9619. m.account = &s
  9620. }
  9621. // Account returns the value of the "account" field in the mutation.
  9622. func (m *ContactMutation) Account() (r string, exists bool) {
  9623. v := m.account
  9624. if v == nil {
  9625. return
  9626. }
  9627. return *v, true
  9628. }
  9629. // OldAccount returns the old "account" field's value of the Contact entity.
  9630. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9632. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  9633. if !m.op.Is(OpUpdateOne) {
  9634. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  9635. }
  9636. if m.id == nil || m.oldValue == nil {
  9637. return v, errors.New("OldAccount requires an ID field in the mutation")
  9638. }
  9639. oldValue, err := m.oldValue(ctx)
  9640. if err != nil {
  9641. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  9642. }
  9643. return oldValue.Account, nil
  9644. }
  9645. // ResetAccount resets all changes to the "account" field.
  9646. func (m *ContactMutation) ResetAccount() {
  9647. m.account = nil
  9648. }
  9649. // SetNickname sets the "nickname" field.
  9650. func (m *ContactMutation) SetNickname(s string) {
  9651. m.nickname = &s
  9652. }
  9653. // Nickname returns the value of the "nickname" field in the mutation.
  9654. func (m *ContactMutation) Nickname() (r string, exists bool) {
  9655. v := m.nickname
  9656. if v == nil {
  9657. return
  9658. }
  9659. return *v, true
  9660. }
  9661. // OldNickname returns the old "nickname" field's value of the Contact entity.
  9662. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9664. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  9665. if !m.op.Is(OpUpdateOne) {
  9666. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  9667. }
  9668. if m.id == nil || m.oldValue == nil {
  9669. return v, errors.New("OldNickname requires an ID field in the mutation")
  9670. }
  9671. oldValue, err := m.oldValue(ctx)
  9672. if err != nil {
  9673. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  9674. }
  9675. return oldValue.Nickname, nil
  9676. }
  9677. // ResetNickname resets all changes to the "nickname" field.
  9678. func (m *ContactMutation) ResetNickname() {
  9679. m.nickname = nil
  9680. }
  9681. // SetMarkname sets the "markname" field.
  9682. func (m *ContactMutation) SetMarkname(s string) {
  9683. m.markname = &s
  9684. }
  9685. // Markname returns the value of the "markname" field in the mutation.
  9686. func (m *ContactMutation) Markname() (r string, exists bool) {
  9687. v := m.markname
  9688. if v == nil {
  9689. return
  9690. }
  9691. return *v, true
  9692. }
  9693. // OldMarkname returns the old "markname" field's value of the Contact entity.
  9694. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9696. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  9697. if !m.op.Is(OpUpdateOne) {
  9698. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  9699. }
  9700. if m.id == nil || m.oldValue == nil {
  9701. return v, errors.New("OldMarkname requires an ID field in the mutation")
  9702. }
  9703. oldValue, err := m.oldValue(ctx)
  9704. if err != nil {
  9705. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  9706. }
  9707. return oldValue.Markname, nil
  9708. }
  9709. // ResetMarkname resets all changes to the "markname" field.
  9710. func (m *ContactMutation) ResetMarkname() {
  9711. m.markname = nil
  9712. }
  9713. // SetHeadimg sets the "headimg" field.
  9714. func (m *ContactMutation) SetHeadimg(s string) {
  9715. m.headimg = &s
  9716. }
  9717. // Headimg returns the value of the "headimg" field in the mutation.
  9718. func (m *ContactMutation) Headimg() (r string, exists bool) {
  9719. v := m.headimg
  9720. if v == nil {
  9721. return
  9722. }
  9723. return *v, true
  9724. }
  9725. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  9726. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9728. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  9729. if !m.op.Is(OpUpdateOne) {
  9730. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  9731. }
  9732. if m.id == nil || m.oldValue == nil {
  9733. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  9734. }
  9735. oldValue, err := m.oldValue(ctx)
  9736. if err != nil {
  9737. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  9738. }
  9739. return oldValue.Headimg, nil
  9740. }
  9741. // ResetHeadimg resets all changes to the "headimg" field.
  9742. func (m *ContactMutation) ResetHeadimg() {
  9743. m.headimg = nil
  9744. }
  9745. // SetSex sets the "sex" field.
  9746. func (m *ContactMutation) SetSex(i int) {
  9747. m.sex = &i
  9748. m.addsex = nil
  9749. }
  9750. // Sex returns the value of the "sex" field in the mutation.
  9751. func (m *ContactMutation) Sex() (r int, exists bool) {
  9752. v := m.sex
  9753. if v == nil {
  9754. return
  9755. }
  9756. return *v, true
  9757. }
  9758. // OldSex returns the old "sex" field's value of the Contact entity.
  9759. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9761. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  9762. if !m.op.Is(OpUpdateOne) {
  9763. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  9764. }
  9765. if m.id == nil || m.oldValue == nil {
  9766. return v, errors.New("OldSex requires an ID field in the mutation")
  9767. }
  9768. oldValue, err := m.oldValue(ctx)
  9769. if err != nil {
  9770. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  9771. }
  9772. return oldValue.Sex, nil
  9773. }
  9774. // AddSex adds i to the "sex" field.
  9775. func (m *ContactMutation) AddSex(i int) {
  9776. if m.addsex != nil {
  9777. *m.addsex += i
  9778. } else {
  9779. m.addsex = &i
  9780. }
  9781. }
  9782. // AddedSex returns the value that was added to the "sex" field in this mutation.
  9783. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  9784. v := m.addsex
  9785. if v == nil {
  9786. return
  9787. }
  9788. return *v, true
  9789. }
  9790. // ResetSex resets all changes to the "sex" field.
  9791. func (m *ContactMutation) ResetSex() {
  9792. m.sex = nil
  9793. m.addsex = nil
  9794. }
  9795. // SetStarrole sets the "starrole" field.
  9796. func (m *ContactMutation) SetStarrole(s string) {
  9797. m.starrole = &s
  9798. }
  9799. // Starrole returns the value of the "starrole" field in the mutation.
  9800. func (m *ContactMutation) Starrole() (r string, exists bool) {
  9801. v := m.starrole
  9802. if v == nil {
  9803. return
  9804. }
  9805. return *v, true
  9806. }
  9807. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  9808. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9810. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  9811. if !m.op.Is(OpUpdateOne) {
  9812. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  9813. }
  9814. if m.id == nil || m.oldValue == nil {
  9815. return v, errors.New("OldStarrole requires an ID field in the mutation")
  9816. }
  9817. oldValue, err := m.oldValue(ctx)
  9818. if err != nil {
  9819. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  9820. }
  9821. return oldValue.Starrole, nil
  9822. }
  9823. // ResetStarrole resets all changes to the "starrole" field.
  9824. func (m *ContactMutation) ResetStarrole() {
  9825. m.starrole = nil
  9826. }
  9827. // SetDontseeit sets the "dontseeit" field.
  9828. func (m *ContactMutation) SetDontseeit(i int) {
  9829. m.dontseeit = &i
  9830. m.adddontseeit = nil
  9831. }
  9832. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  9833. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  9834. v := m.dontseeit
  9835. if v == nil {
  9836. return
  9837. }
  9838. return *v, true
  9839. }
  9840. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  9841. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9843. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  9844. if !m.op.Is(OpUpdateOne) {
  9845. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  9846. }
  9847. if m.id == nil || m.oldValue == nil {
  9848. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  9849. }
  9850. oldValue, err := m.oldValue(ctx)
  9851. if err != nil {
  9852. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  9853. }
  9854. return oldValue.Dontseeit, nil
  9855. }
  9856. // AddDontseeit adds i to the "dontseeit" field.
  9857. func (m *ContactMutation) AddDontseeit(i int) {
  9858. if m.adddontseeit != nil {
  9859. *m.adddontseeit += i
  9860. } else {
  9861. m.adddontseeit = &i
  9862. }
  9863. }
  9864. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  9865. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  9866. v := m.adddontseeit
  9867. if v == nil {
  9868. return
  9869. }
  9870. return *v, true
  9871. }
  9872. // ResetDontseeit resets all changes to the "dontseeit" field.
  9873. func (m *ContactMutation) ResetDontseeit() {
  9874. m.dontseeit = nil
  9875. m.adddontseeit = nil
  9876. }
  9877. // SetDontseeme sets the "dontseeme" field.
  9878. func (m *ContactMutation) SetDontseeme(i int) {
  9879. m.dontseeme = &i
  9880. m.adddontseeme = nil
  9881. }
  9882. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  9883. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  9884. v := m.dontseeme
  9885. if v == nil {
  9886. return
  9887. }
  9888. return *v, true
  9889. }
  9890. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  9891. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9893. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  9894. if !m.op.Is(OpUpdateOne) {
  9895. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  9896. }
  9897. if m.id == nil || m.oldValue == nil {
  9898. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  9899. }
  9900. oldValue, err := m.oldValue(ctx)
  9901. if err != nil {
  9902. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  9903. }
  9904. return oldValue.Dontseeme, nil
  9905. }
  9906. // AddDontseeme adds i to the "dontseeme" field.
  9907. func (m *ContactMutation) AddDontseeme(i int) {
  9908. if m.adddontseeme != nil {
  9909. *m.adddontseeme += i
  9910. } else {
  9911. m.adddontseeme = &i
  9912. }
  9913. }
  9914. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  9915. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  9916. v := m.adddontseeme
  9917. if v == nil {
  9918. return
  9919. }
  9920. return *v, true
  9921. }
  9922. // ResetDontseeme resets all changes to the "dontseeme" field.
  9923. func (m *ContactMutation) ResetDontseeme() {
  9924. m.dontseeme = nil
  9925. m.adddontseeme = nil
  9926. }
  9927. // SetLag sets the "lag" field.
  9928. func (m *ContactMutation) SetLag(s string) {
  9929. m.lag = &s
  9930. }
  9931. // Lag returns the value of the "lag" field in the mutation.
  9932. func (m *ContactMutation) Lag() (r string, exists bool) {
  9933. v := m.lag
  9934. if v == nil {
  9935. return
  9936. }
  9937. return *v, true
  9938. }
  9939. // OldLag returns the old "lag" field's value of the Contact entity.
  9940. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9942. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  9943. if !m.op.Is(OpUpdateOne) {
  9944. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  9945. }
  9946. if m.id == nil || m.oldValue == nil {
  9947. return v, errors.New("OldLag requires an ID field in the mutation")
  9948. }
  9949. oldValue, err := m.oldValue(ctx)
  9950. if err != nil {
  9951. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  9952. }
  9953. return oldValue.Lag, nil
  9954. }
  9955. // ResetLag resets all changes to the "lag" field.
  9956. func (m *ContactMutation) ResetLag() {
  9957. m.lag = nil
  9958. }
  9959. // SetGid sets the "gid" field.
  9960. func (m *ContactMutation) SetGid(s string) {
  9961. m.gid = &s
  9962. }
  9963. // Gid returns the value of the "gid" field in the mutation.
  9964. func (m *ContactMutation) Gid() (r string, exists bool) {
  9965. v := m.gid
  9966. if v == nil {
  9967. return
  9968. }
  9969. return *v, true
  9970. }
  9971. // OldGid returns the old "gid" field's value of the Contact entity.
  9972. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9974. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  9975. if !m.op.Is(OpUpdateOne) {
  9976. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  9977. }
  9978. if m.id == nil || m.oldValue == nil {
  9979. return v, errors.New("OldGid requires an ID field in the mutation")
  9980. }
  9981. oldValue, err := m.oldValue(ctx)
  9982. if err != nil {
  9983. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  9984. }
  9985. return oldValue.Gid, nil
  9986. }
  9987. // ResetGid resets all changes to the "gid" field.
  9988. func (m *ContactMutation) ResetGid() {
  9989. m.gid = nil
  9990. }
  9991. // SetGname sets the "gname" field.
  9992. func (m *ContactMutation) SetGname(s string) {
  9993. m.gname = &s
  9994. }
  9995. // Gname returns the value of the "gname" field in the mutation.
  9996. func (m *ContactMutation) Gname() (r string, exists bool) {
  9997. v := m.gname
  9998. if v == nil {
  9999. return
  10000. }
  10001. return *v, true
  10002. }
  10003. // OldGname returns the old "gname" field's value of the Contact entity.
  10004. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10006. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  10007. if !m.op.Is(OpUpdateOne) {
  10008. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  10009. }
  10010. if m.id == nil || m.oldValue == nil {
  10011. return v, errors.New("OldGname requires an ID field in the mutation")
  10012. }
  10013. oldValue, err := m.oldValue(ctx)
  10014. if err != nil {
  10015. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  10016. }
  10017. return oldValue.Gname, nil
  10018. }
  10019. // ResetGname resets all changes to the "gname" field.
  10020. func (m *ContactMutation) ResetGname() {
  10021. m.gname = nil
  10022. }
  10023. // SetV3 sets the "v3" field.
  10024. func (m *ContactMutation) SetV3(s string) {
  10025. m.v3 = &s
  10026. }
  10027. // V3 returns the value of the "v3" field in the mutation.
  10028. func (m *ContactMutation) V3() (r string, exists bool) {
  10029. v := m.v3
  10030. if v == nil {
  10031. return
  10032. }
  10033. return *v, true
  10034. }
  10035. // OldV3 returns the old "v3" field's value of the Contact entity.
  10036. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10038. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  10039. if !m.op.Is(OpUpdateOne) {
  10040. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  10041. }
  10042. if m.id == nil || m.oldValue == nil {
  10043. return v, errors.New("OldV3 requires an ID field in the mutation")
  10044. }
  10045. oldValue, err := m.oldValue(ctx)
  10046. if err != nil {
  10047. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  10048. }
  10049. return oldValue.V3, nil
  10050. }
  10051. // ResetV3 resets all changes to the "v3" field.
  10052. func (m *ContactMutation) ResetV3() {
  10053. m.v3 = nil
  10054. }
  10055. // SetOrganizationID sets the "organization_id" field.
  10056. func (m *ContactMutation) SetOrganizationID(u uint64) {
  10057. m.organization_id = &u
  10058. m.addorganization_id = nil
  10059. }
  10060. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10061. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  10062. v := m.organization_id
  10063. if v == nil {
  10064. return
  10065. }
  10066. return *v, true
  10067. }
  10068. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  10069. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10071. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10072. if !m.op.Is(OpUpdateOne) {
  10073. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10074. }
  10075. if m.id == nil || m.oldValue == nil {
  10076. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10077. }
  10078. oldValue, err := m.oldValue(ctx)
  10079. if err != nil {
  10080. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10081. }
  10082. return oldValue.OrganizationID, nil
  10083. }
  10084. // AddOrganizationID adds u to the "organization_id" field.
  10085. func (m *ContactMutation) AddOrganizationID(u int64) {
  10086. if m.addorganization_id != nil {
  10087. *m.addorganization_id += u
  10088. } else {
  10089. m.addorganization_id = &u
  10090. }
  10091. }
  10092. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10093. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  10094. v := m.addorganization_id
  10095. if v == nil {
  10096. return
  10097. }
  10098. return *v, true
  10099. }
  10100. // ClearOrganizationID clears the value of the "organization_id" field.
  10101. func (m *ContactMutation) ClearOrganizationID() {
  10102. m.organization_id = nil
  10103. m.addorganization_id = nil
  10104. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  10105. }
  10106. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10107. func (m *ContactMutation) OrganizationIDCleared() bool {
  10108. _, ok := m.clearedFields[contact.FieldOrganizationID]
  10109. return ok
  10110. }
  10111. // ResetOrganizationID resets all changes to the "organization_id" field.
  10112. func (m *ContactMutation) ResetOrganizationID() {
  10113. m.organization_id = nil
  10114. m.addorganization_id = nil
  10115. delete(m.clearedFields, contact.FieldOrganizationID)
  10116. }
  10117. // SetCtype sets the "ctype" field.
  10118. func (m *ContactMutation) SetCtype(u uint64) {
  10119. m.ctype = &u
  10120. m.addctype = nil
  10121. }
  10122. // Ctype returns the value of the "ctype" field in the mutation.
  10123. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  10124. v := m.ctype
  10125. if v == nil {
  10126. return
  10127. }
  10128. return *v, true
  10129. }
  10130. // OldCtype returns the old "ctype" field's value of the Contact entity.
  10131. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10133. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  10134. if !m.op.Is(OpUpdateOne) {
  10135. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  10136. }
  10137. if m.id == nil || m.oldValue == nil {
  10138. return v, errors.New("OldCtype requires an ID field in the mutation")
  10139. }
  10140. oldValue, err := m.oldValue(ctx)
  10141. if err != nil {
  10142. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  10143. }
  10144. return oldValue.Ctype, nil
  10145. }
  10146. // AddCtype adds u to the "ctype" field.
  10147. func (m *ContactMutation) AddCtype(u int64) {
  10148. if m.addctype != nil {
  10149. *m.addctype += u
  10150. } else {
  10151. m.addctype = &u
  10152. }
  10153. }
  10154. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  10155. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  10156. v := m.addctype
  10157. if v == nil {
  10158. return
  10159. }
  10160. return *v, true
  10161. }
  10162. // ResetCtype resets all changes to the "ctype" field.
  10163. func (m *ContactMutation) ResetCtype() {
  10164. m.ctype = nil
  10165. m.addctype = nil
  10166. }
  10167. // SetCage sets the "cage" field.
  10168. func (m *ContactMutation) SetCage(i int) {
  10169. m.cage = &i
  10170. m.addcage = nil
  10171. }
  10172. // Cage returns the value of the "cage" field in the mutation.
  10173. func (m *ContactMutation) Cage() (r int, exists bool) {
  10174. v := m.cage
  10175. if v == nil {
  10176. return
  10177. }
  10178. return *v, true
  10179. }
  10180. // OldCage returns the old "cage" field's value of the Contact entity.
  10181. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10183. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  10184. if !m.op.Is(OpUpdateOne) {
  10185. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  10186. }
  10187. if m.id == nil || m.oldValue == nil {
  10188. return v, errors.New("OldCage requires an ID field in the mutation")
  10189. }
  10190. oldValue, err := m.oldValue(ctx)
  10191. if err != nil {
  10192. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  10193. }
  10194. return oldValue.Cage, nil
  10195. }
  10196. // AddCage adds i to the "cage" field.
  10197. func (m *ContactMutation) AddCage(i int) {
  10198. if m.addcage != nil {
  10199. *m.addcage += i
  10200. } else {
  10201. m.addcage = &i
  10202. }
  10203. }
  10204. // AddedCage returns the value that was added to the "cage" field in this mutation.
  10205. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  10206. v := m.addcage
  10207. if v == nil {
  10208. return
  10209. }
  10210. return *v, true
  10211. }
  10212. // ResetCage resets all changes to the "cage" field.
  10213. func (m *ContactMutation) ResetCage() {
  10214. m.cage = nil
  10215. m.addcage = nil
  10216. }
  10217. // SetCname sets the "cname" field.
  10218. func (m *ContactMutation) SetCname(s string) {
  10219. m.cname = &s
  10220. }
  10221. // Cname returns the value of the "cname" field in the mutation.
  10222. func (m *ContactMutation) Cname() (r string, exists bool) {
  10223. v := m.cname
  10224. if v == nil {
  10225. return
  10226. }
  10227. return *v, true
  10228. }
  10229. // OldCname returns the old "cname" field's value of the Contact entity.
  10230. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10232. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  10233. if !m.op.Is(OpUpdateOne) {
  10234. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  10235. }
  10236. if m.id == nil || m.oldValue == nil {
  10237. return v, errors.New("OldCname requires an ID field in the mutation")
  10238. }
  10239. oldValue, err := m.oldValue(ctx)
  10240. if err != nil {
  10241. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  10242. }
  10243. return oldValue.Cname, nil
  10244. }
  10245. // ResetCname resets all changes to the "cname" field.
  10246. func (m *ContactMutation) ResetCname() {
  10247. m.cname = nil
  10248. }
  10249. // SetCarea sets the "carea" field.
  10250. func (m *ContactMutation) SetCarea(s string) {
  10251. m.carea = &s
  10252. }
  10253. // Carea returns the value of the "carea" field in the mutation.
  10254. func (m *ContactMutation) Carea() (r string, exists bool) {
  10255. v := m.carea
  10256. if v == nil {
  10257. return
  10258. }
  10259. return *v, true
  10260. }
  10261. // OldCarea returns the old "carea" field's value of the Contact entity.
  10262. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10264. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  10265. if !m.op.Is(OpUpdateOne) {
  10266. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  10267. }
  10268. if m.id == nil || m.oldValue == nil {
  10269. return v, errors.New("OldCarea requires an ID field in the mutation")
  10270. }
  10271. oldValue, err := m.oldValue(ctx)
  10272. if err != nil {
  10273. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  10274. }
  10275. return oldValue.Carea, nil
  10276. }
  10277. // ResetCarea resets all changes to the "carea" field.
  10278. func (m *ContactMutation) ResetCarea() {
  10279. m.carea = nil
  10280. }
  10281. // SetCbirthday sets the "cbirthday" field.
  10282. func (m *ContactMutation) SetCbirthday(s string) {
  10283. m.cbirthday = &s
  10284. }
  10285. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  10286. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  10287. v := m.cbirthday
  10288. if v == nil {
  10289. return
  10290. }
  10291. return *v, true
  10292. }
  10293. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  10294. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10296. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  10297. if !m.op.Is(OpUpdateOne) {
  10298. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  10299. }
  10300. if m.id == nil || m.oldValue == nil {
  10301. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  10302. }
  10303. oldValue, err := m.oldValue(ctx)
  10304. if err != nil {
  10305. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  10306. }
  10307. return oldValue.Cbirthday, nil
  10308. }
  10309. // ResetCbirthday resets all changes to the "cbirthday" field.
  10310. func (m *ContactMutation) ResetCbirthday() {
  10311. m.cbirthday = nil
  10312. }
  10313. // SetCbirtharea sets the "cbirtharea" field.
  10314. func (m *ContactMutation) SetCbirtharea(s string) {
  10315. m.cbirtharea = &s
  10316. }
  10317. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  10318. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  10319. v := m.cbirtharea
  10320. if v == nil {
  10321. return
  10322. }
  10323. return *v, true
  10324. }
  10325. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  10326. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10328. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  10329. if !m.op.Is(OpUpdateOne) {
  10330. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  10331. }
  10332. if m.id == nil || m.oldValue == nil {
  10333. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  10334. }
  10335. oldValue, err := m.oldValue(ctx)
  10336. if err != nil {
  10337. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  10338. }
  10339. return oldValue.Cbirtharea, nil
  10340. }
  10341. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  10342. func (m *ContactMutation) ResetCbirtharea() {
  10343. m.cbirtharea = nil
  10344. }
  10345. // SetCidcardNo sets the "cidcard_no" field.
  10346. func (m *ContactMutation) SetCidcardNo(s string) {
  10347. m.cidcard_no = &s
  10348. }
  10349. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  10350. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  10351. v := m.cidcard_no
  10352. if v == nil {
  10353. return
  10354. }
  10355. return *v, true
  10356. }
  10357. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  10358. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10360. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  10361. if !m.op.Is(OpUpdateOne) {
  10362. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  10363. }
  10364. if m.id == nil || m.oldValue == nil {
  10365. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  10366. }
  10367. oldValue, err := m.oldValue(ctx)
  10368. if err != nil {
  10369. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  10370. }
  10371. return oldValue.CidcardNo, nil
  10372. }
  10373. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  10374. func (m *ContactMutation) ResetCidcardNo() {
  10375. m.cidcard_no = nil
  10376. }
  10377. // SetCtitle sets the "ctitle" field.
  10378. func (m *ContactMutation) SetCtitle(s string) {
  10379. m.ctitle = &s
  10380. }
  10381. // Ctitle returns the value of the "ctitle" field in the mutation.
  10382. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  10383. v := m.ctitle
  10384. if v == nil {
  10385. return
  10386. }
  10387. return *v, true
  10388. }
  10389. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  10390. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10392. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  10393. if !m.op.Is(OpUpdateOne) {
  10394. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  10395. }
  10396. if m.id == nil || m.oldValue == nil {
  10397. return v, errors.New("OldCtitle requires an ID field in the mutation")
  10398. }
  10399. oldValue, err := m.oldValue(ctx)
  10400. if err != nil {
  10401. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  10402. }
  10403. return oldValue.Ctitle, nil
  10404. }
  10405. // ResetCtitle resets all changes to the "ctitle" field.
  10406. func (m *ContactMutation) ResetCtitle() {
  10407. m.ctitle = nil
  10408. }
  10409. // SetCc sets the "cc" field.
  10410. func (m *ContactMutation) SetCc(s string) {
  10411. m.cc = &s
  10412. }
  10413. // Cc returns the value of the "cc" field in the mutation.
  10414. func (m *ContactMutation) Cc() (r string, exists bool) {
  10415. v := m.cc
  10416. if v == nil {
  10417. return
  10418. }
  10419. return *v, true
  10420. }
  10421. // OldCc returns the old "cc" field's value of the Contact entity.
  10422. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10424. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  10425. if !m.op.Is(OpUpdateOne) {
  10426. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  10427. }
  10428. if m.id == nil || m.oldValue == nil {
  10429. return v, errors.New("OldCc requires an ID field in the mutation")
  10430. }
  10431. oldValue, err := m.oldValue(ctx)
  10432. if err != nil {
  10433. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  10434. }
  10435. return oldValue.Cc, nil
  10436. }
  10437. // ResetCc resets all changes to the "cc" field.
  10438. func (m *ContactMutation) ResetCc() {
  10439. m.cc = nil
  10440. }
  10441. // SetPhone sets the "phone" field.
  10442. func (m *ContactMutation) SetPhone(s string) {
  10443. m.phone = &s
  10444. }
  10445. // Phone returns the value of the "phone" field in the mutation.
  10446. func (m *ContactMutation) Phone() (r string, exists bool) {
  10447. v := m.phone
  10448. if v == nil {
  10449. return
  10450. }
  10451. return *v, true
  10452. }
  10453. // OldPhone returns the old "phone" field's value of the Contact entity.
  10454. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10456. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  10457. if !m.op.Is(OpUpdateOne) {
  10458. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  10459. }
  10460. if m.id == nil || m.oldValue == nil {
  10461. return v, errors.New("OldPhone requires an ID field in the mutation")
  10462. }
  10463. oldValue, err := m.oldValue(ctx)
  10464. if err != nil {
  10465. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  10466. }
  10467. return oldValue.Phone, nil
  10468. }
  10469. // ResetPhone resets all changes to the "phone" field.
  10470. func (m *ContactMutation) ResetPhone() {
  10471. m.phone = nil
  10472. }
  10473. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  10474. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  10475. if m.contact_relationships == nil {
  10476. m.contact_relationships = make(map[uint64]struct{})
  10477. }
  10478. for i := range ids {
  10479. m.contact_relationships[ids[i]] = struct{}{}
  10480. }
  10481. }
  10482. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  10483. func (m *ContactMutation) ClearContactRelationships() {
  10484. m.clearedcontact_relationships = true
  10485. }
  10486. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  10487. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  10488. return m.clearedcontact_relationships
  10489. }
  10490. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  10491. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  10492. if m.removedcontact_relationships == nil {
  10493. m.removedcontact_relationships = make(map[uint64]struct{})
  10494. }
  10495. for i := range ids {
  10496. delete(m.contact_relationships, ids[i])
  10497. m.removedcontact_relationships[ids[i]] = struct{}{}
  10498. }
  10499. }
  10500. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  10501. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  10502. for id := range m.removedcontact_relationships {
  10503. ids = append(ids, id)
  10504. }
  10505. return
  10506. }
  10507. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  10508. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  10509. for id := range m.contact_relationships {
  10510. ids = append(ids, id)
  10511. }
  10512. return
  10513. }
  10514. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  10515. func (m *ContactMutation) ResetContactRelationships() {
  10516. m.contact_relationships = nil
  10517. m.clearedcontact_relationships = false
  10518. m.removedcontact_relationships = nil
  10519. }
  10520. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  10521. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  10522. if m.contact_messages == nil {
  10523. m.contact_messages = make(map[uint64]struct{})
  10524. }
  10525. for i := range ids {
  10526. m.contact_messages[ids[i]] = struct{}{}
  10527. }
  10528. }
  10529. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  10530. func (m *ContactMutation) ClearContactMessages() {
  10531. m.clearedcontact_messages = true
  10532. }
  10533. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  10534. func (m *ContactMutation) ContactMessagesCleared() bool {
  10535. return m.clearedcontact_messages
  10536. }
  10537. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  10538. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  10539. if m.removedcontact_messages == nil {
  10540. m.removedcontact_messages = make(map[uint64]struct{})
  10541. }
  10542. for i := range ids {
  10543. delete(m.contact_messages, ids[i])
  10544. m.removedcontact_messages[ids[i]] = struct{}{}
  10545. }
  10546. }
  10547. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  10548. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  10549. for id := range m.removedcontact_messages {
  10550. ids = append(ids, id)
  10551. }
  10552. return
  10553. }
  10554. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  10555. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  10556. for id := range m.contact_messages {
  10557. ids = append(ids, id)
  10558. }
  10559. return
  10560. }
  10561. // ResetContactMessages resets all changes to the "contact_messages" edge.
  10562. func (m *ContactMutation) ResetContactMessages() {
  10563. m.contact_messages = nil
  10564. m.clearedcontact_messages = false
  10565. m.removedcontact_messages = nil
  10566. }
  10567. // Where appends a list predicates to the ContactMutation builder.
  10568. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  10569. m.predicates = append(m.predicates, ps...)
  10570. }
  10571. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  10572. // users can use type-assertion to append predicates that do not depend on any generated package.
  10573. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  10574. p := make([]predicate.Contact, len(ps))
  10575. for i := range ps {
  10576. p[i] = ps[i]
  10577. }
  10578. m.Where(p...)
  10579. }
  10580. // Op returns the operation name.
  10581. func (m *ContactMutation) Op() Op {
  10582. return m.op
  10583. }
  10584. // SetOp allows setting the mutation operation.
  10585. func (m *ContactMutation) SetOp(op Op) {
  10586. m.op = op
  10587. }
  10588. // Type returns the node type of this mutation (Contact).
  10589. func (m *ContactMutation) Type() string {
  10590. return m.typ
  10591. }
  10592. // Fields returns all fields that were changed during this mutation. Note that in
  10593. // order to get all numeric fields that were incremented/decremented, call
  10594. // AddedFields().
  10595. func (m *ContactMutation) Fields() []string {
  10596. fields := make([]string, 0, 30)
  10597. if m.created_at != nil {
  10598. fields = append(fields, contact.FieldCreatedAt)
  10599. }
  10600. if m.updated_at != nil {
  10601. fields = append(fields, contact.FieldUpdatedAt)
  10602. }
  10603. if m.status != nil {
  10604. fields = append(fields, contact.FieldStatus)
  10605. }
  10606. if m.deleted_at != nil {
  10607. fields = append(fields, contact.FieldDeletedAt)
  10608. }
  10609. if m.wx_wxid != nil {
  10610. fields = append(fields, contact.FieldWxWxid)
  10611. }
  10612. if m._type != nil {
  10613. fields = append(fields, contact.FieldType)
  10614. }
  10615. if m.wxid != nil {
  10616. fields = append(fields, contact.FieldWxid)
  10617. }
  10618. if m.account != nil {
  10619. fields = append(fields, contact.FieldAccount)
  10620. }
  10621. if m.nickname != nil {
  10622. fields = append(fields, contact.FieldNickname)
  10623. }
  10624. if m.markname != nil {
  10625. fields = append(fields, contact.FieldMarkname)
  10626. }
  10627. if m.headimg != nil {
  10628. fields = append(fields, contact.FieldHeadimg)
  10629. }
  10630. if m.sex != nil {
  10631. fields = append(fields, contact.FieldSex)
  10632. }
  10633. if m.starrole != nil {
  10634. fields = append(fields, contact.FieldStarrole)
  10635. }
  10636. if m.dontseeit != nil {
  10637. fields = append(fields, contact.FieldDontseeit)
  10638. }
  10639. if m.dontseeme != nil {
  10640. fields = append(fields, contact.FieldDontseeme)
  10641. }
  10642. if m.lag != nil {
  10643. fields = append(fields, contact.FieldLag)
  10644. }
  10645. if m.gid != nil {
  10646. fields = append(fields, contact.FieldGid)
  10647. }
  10648. if m.gname != nil {
  10649. fields = append(fields, contact.FieldGname)
  10650. }
  10651. if m.v3 != nil {
  10652. fields = append(fields, contact.FieldV3)
  10653. }
  10654. if m.organization_id != nil {
  10655. fields = append(fields, contact.FieldOrganizationID)
  10656. }
  10657. if m.ctype != nil {
  10658. fields = append(fields, contact.FieldCtype)
  10659. }
  10660. if m.cage != nil {
  10661. fields = append(fields, contact.FieldCage)
  10662. }
  10663. if m.cname != nil {
  10664. fields = append(fields, contact.FieldCname)
  10665. }
  10666. if m.carea != nil {
  10667. fields = append(fields, contact.FieldCarea)
  10668. }
  10669. if m.cbirthday != nil {
  10670. fields = append(fields, contact.FieldCbirthday)
  10671. }
  10672. if m.cbirtharea != nil {
  10673. fields = append(fields, contact.FieldCbirtharea)
  10674. }
  10675. if m.cidcard_no != nil {
  10676. fields = append(fields, contact.FieldCidcardNo)
  10677. }
  10678. if m.ctitle != nil {
  10679. fields = append(fields, contact.FieldCtitle)
  10680. }
  10681. if m.cc != nil {
  10682. fields = append(fields, contact.FieldCc)
  10683. }
  10684. if m.phone != nil {
  10685. fields = append(fields, contact.FieldPhone)
  10686. }
  10687. return fields
  10688. }
  10689. // Field returns the value of a field with the given name. The second boolean
  10690. // return value indicates that this field was not set, or was not defined in the
  10691. // schema.
  10692. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  10693. switch name {
  10694. case contact.FieldCreatedAt:
  10695. return m.CreatedAt()
  10696. case contact.FieldUpdatedAt:
  10697. return m.UpdatedAt()
  10698. case contact.FieldStatus:
  10699. return m.Status()
  10700. case contact.FieldDeletedAt:
  10701. return m.DeletedAt()
  10702. case contact.FieldWxWxid:
  10703. return m.WxWxid()
  10704. case contact.FieldType:
  10705. return m.GetType()
  10706. case contact.FieldWxid:
  10707. return m.Wxid()
  10708. case contact.FieldAccount:
  10709. return m.Account()
  10710. case contact.FieldNickname:
  10711. return m.Nickname()
  10712. case contact.FieldMarkname:
  10713. return m.Markname()
  10714. case contact.FieldHeadimg:
  10715. return m.Headimg()
  10716. case contact.FieldSex:
  10717. return m.Sex()
  10718. case contact.FieldStarrole:
  10719. return m.Starrole()
  10720. case contact.FieldDontseeit:
  10721. return m.Dontseeit()
  10722. case contact.FieldDontseeme:
  10723. return m.Dontseeme()
  10724. case contact.FieldLag:
  10725. return m.Lag()
  10726. case contact.FieldGid:
  10727. return m.Gid()
  10728. case contact.FieldGname:
  10729. return m.Gname()
  10730. case contact.FieldV3:
  10731. return m.V3()
  10732. case contact.FieldOrganizationID:
  10733. return m.OrganizationID()
  10734. case contact.FieldCtype:
  10735. return m.Ctype()
  10736. case contact.FieldCage:
  10737. return m.Cage()
  10738. case contact.FieldCname:
  10739. return m.Cname()
  10740. case contact.FieldCarea:
  10741. return m.Carea()
  10742. case contact.FieldCbirthday:
  10743. return m.Cbirthday()
  10744. case contact.FieldCbirtharea:
  10745. return m.Cbirtharea()
  10746. case contact.FieldCidcardNo:
  10747. return m.CidcardNo()
  10748. case contact.FieldCtitle:
  10749. return m.Ctitle()
  10750. case contact.FieldCc:
  10751. return m.Cc()
  10752. case contact.FieldPhone:
  10753. return m.Phone()
  10754. }
  10755. return nil, false
  10756. }
  10757. // OldField returns the old value of the field from the database. An error is
  10758. // returned if the mutation operation is not UpdateOne, or the query to the
  10759. // database failed.
  10760. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10761. switch name {
  10762. case contact.FieldCreatedAt:
  10763. return m.OldCreatedAt(ctx)
  10764. case contact.FieldUpdatedAt:
  10765. return m.OldUpdatedAt(ctx)
  10766. case contact.FieldStatus:
  10767. return m.OldStatus(ctx)
  10768. case contact.FieldDeletedAt:
  10769. return m.OldDeletedAt(ctx)
  10770. case contact.FieldWxWxid:
  10771. return m.OldWxWxid(ctx)
  10772. case contact.FieldType:
  10773. return m.OldType(ctx)
  10774. case contact.FieldWxid:
  10775. return m.OldWxid(ctx)
  10776. case contact.FieldAccount:
  10777. return m.OldAccount(ctx)
  10778. case contact.FieldNickname:
  10779. return m.OldNickname(ctx)
  10780. case contact.FieldMarkname:
  10781. return m.OldMarkname(ctx)
  10782. case contact.FieldHeadimg:
  10783. return m.OldHeadimg(ctx)
  10784. case contact.FieldSex:
  10785. return m.OldSex(ctx)
  10786. case contact.FieldStarrole:
  10787. return m.OldStarrole(ctx)
  10788. case contact.FieldDontseeit:
  10789. return m.OldDontseeit(ctx)
  10790. case contact.FieldDontseeme:
  10791. return m.OldDontseeme(ctx)
  10792. case contact.FieldLag:
  10793. return m.OldLag(ctx)
  10794. case contact.FieldGid:
  10795. return m.OldGid(ctx)
  10796. case contact.FieldGname:
  10797. return m.OldGname(ctx)
  10798. case contact.FieldV3:
  10799. return m.OldV3(ctx)
  10800. case contact.FieldOrganizationID:
  10801. return m.OldOrganizationID(ctx)
  10802. case contact.FieldCtype:
  10803. return m.OldCtype(ctx)
  10804. case contact.FieldCage:
  10805. return m.OldCage(ctx)
  10806. case contact.FieldCname:
  10807. return m.OldCname(ctx)
  10808. case contact.FieldCarea:
  10809. return m.OldCarea(ctx)
  10810. case contact.FieldCbirthday:
  10811. return m.OldCbirthday(ctx)
  10812. case contact.FieldCbirtharea:
  10813. return m.OldCbirtharea(ctx)
  10814. case contact.FieldCidcardNo:
  10815. return m.OldCidcardNo(ctx)
  10816. case contact.FieldCtitle:
  10817. return m.OldCtitle(ctx)
  10818. case contact.FieldCc:
  10819. return m.OldCc(ctx)
  10820. case contact.FieldPhone:
  10821. return m.OldPhone(ctx)
  10822. }
  10823. return nil, fmt.Errorf("unknown Contact field %s", name)
  10824. }
  10825. // SetField sets the value of a field with the given name. It returns an error if
  10826. // the field is not defined in the schema, or if the type mismatched the field
  10827. // type.
  10828. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  10829. switch name {
  10830. case contact.FieldCreatedAt:
  10831. v, ok := value.(time.Time)
  10832. if !ok {
  10833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10834. }
  10835. m.SetCreatedAt(v)
  10836. return nil
  10837. case contact.FieldUpdatedAt:
  10838. v, ok := value.(time.Time)
  10839. if !ok {
  10840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10841. }
  10842. m.SetUpdatedAt(v)
  10843. return nil
  10844. case contact.FieldStatus:
  10845. v, ok := value.(uint8)
  10846. if !ok {
  10847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10848. }
  10849. m.SetStatus(v)
  10850. return nil
  10851. case contact.FieldDeletedAt:
  10852. v, ok := value.(time.Time)
  10853. if !ok {
  10854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10855. }
  10856. m.SetDeletedAt(v)
  10857. return nil
  10858. case contact.FieldWxWxid:
  10859. v, ok := value.(string)
  10860. if !ok {
  10861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10862. }
  10863. m.SetWxWxid(v)
  10864. return nil
  10865. case contact.FieldType:
  10866. v, ok := value.(int)
  10867. if !ok {
  10868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10869. }
  10870. m.SetType(v)
  10871. return nil
  10872. case contact.FieldWxid:
  10873. v, ok := value.(string)
  10874. if !ok {
  10875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10876. }
  10877. m.SetWxid(v)
  10878. return nil
  10879. case contact.FieldAccount:
  10880. v, ok := value.(string)
  10881. if !ok {
  10882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10883. }
  10884. m.SetAccount(v)
  10885. return nil
  10886. case contact.FieldNickname:
  10887. v, ok := value.(string)
  10888. if !ok {
  10889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10890. }
  10891. m.SetNickname(v)
  10892. return nil
  10893. case contact.FieldMarkname:
  10894. v, ok := value.(string)
  10895. if !ok {
  10896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10897. }
  10898. m.SetMarkname(v)
  10899. return nil
  10900. case contact.FieldHeadimg:
  10901. v, ok := value.(string)
  10902. if !ok {
  10903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10904. }
  10905. m.SetHeadimg(v)
  10906. return nil
  10907. case contact.FieldSex:
  10908. v, ok := value.(int)
  10909. if !ok {
  10910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10911. }
  10912. m.SetSex(v)
  10913. return nil
  10914. case contact.FieldStarrole:
  10915. v, ok := value.(string)
  10916. if !ok {
  10917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10918. }
  10919. m.SetStarrole(v)
  10920. return nil
  10921. case contact.FieldDontseeit:
  10922. v, ok := value.(int)
  10923. if !ok {
  10924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10925. }
  10926. m.SetDontseeit(v)
  10927. return nil
  10928. case contact.FieldDontseeme:
  10929. v, ok := value.(int)
  10930. if !ok {
  10931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10932. }
  10933. m.SetDontseeme(v)
  10934. return nil
  10935. case contact.FieldLag:
  10936. v, ok := value.(string)
  10937. if !ok {
  10938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10939. }
  10940. m.SetLag(v)
  10941. return nil
  10942. case contact.FieldGid:
  10943. v, ok := value.(string)
  10944. if !ok {
  10945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10946. }
  10947. m.SetGid(v)
  10948. return nil
  10949. case contact.FieldGname:
  10950. v, ok := value.(string)
  10951. if !ok {
  10952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10953. }
  10954. m.SetGname(v)
  10955. return nil
  10956. case contact.FieldV3:
  10957. v, ok := value.(string)
  10958. if !ok {
  10959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10960. }
  10961. m.SetV3(v)
  10962. return nil
  10963. case contact.FieldOrganizationID:
  10964. v, ok := value.(uint64)
  10965. if !ok {
  10966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10967. }
  10968. m.SetOrganizationID(v)
  10969. return nil
  10970. case contact.FieldCtype:
  10971. v, ok := value.(uint64)
  10972. if !ok {
  10973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10974. }
  10975. m.SetCtype(v)
  10976. return nil
  10977. case contact.FieldCage:
  10978. v, ok := value.(int)
  10979. if !ok {
  10980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10981. }
  10982. m.SetCage(v)
  10983. return nil
  10984. case contact.FieldCname:
  10985. v, ok := value.(string)
  10986. if !ok {
  10987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10988. }
  10989. m.SetCname(v)
  10990. return nil
  10991. case contact.FieldCarea:
  10992. v, ok := value.(string)
  10993. if !ok {
  10994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10995. }
  10996. m.SetCarea(v)
  10997. return nil
  10998. case contact.FieldCbirthday:
  10999. v, ok := value.(string)
  11000. if !ok {
  11001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11002. }
  11003. m.SetCbirthday(v)
  11004. return nil
  11005. case contact.FieldCbirtharea:
  11006. v, ok := value.(string)
  11007. if !ok {
  11008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11009. }
  11010. m.SetCbirtharea(v)
  11011. return nil
  11012. case contact.FieldCidcardNo:
  11013. v, ok := value.(string)
  11014. if !ok {
  11015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11016. }
  11017. m.SetCidcardNo(v)
  11018. return nil
  11019. case contact.FieldCtitle:
  11020. v, ok := value.(string)
  11021. if !ok {
  11022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11023. }
  11024. m.SetCtitle(v)
  11025. return nil
  11026. case contact.FieldCc:
  11027. v, ok := value.(string)
  11028. if !ok {
  11029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11030. }
  11031. m.SetCc(v)
  11032. return nil
  11033. case contact.FieldPhone:
  11034. v, ok := value.(string)
  11035. if !ok {
  11036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11037. }
  11038. m.SetPhone(v)
  11039. return nil
  11040. }
  11041. return fmt.Errorf("unknown Contact field %s", name)
  11042. }
  11043. // AddedFields returns all numeric fields that were incremented/decremented during
  11044. // this mutation.
  11045. func (m *ContactMutation) AddedFields() []string {
  11046. var fields []string
  11047. if m.addstatus != nil {
  11048. fields = append(fields, contact.FieldStatus)
  11049. }
  11050. if m.add_type != nil {
  11051. fields = append(fields, contact.FieldType)
  11052. }
  11053. if m.addsex != nil {
  11054. fields = append(fields, contact.FieldSex)
  11055. }
  11056. if m.adddontseeit != nil {
  11057. fields = append(fields, contact.FieldDontseeit)
  11058. }
  11059. if m.adddontseeme != nil {
  11060. fields = append(fields, contact.FieldDontseeme)
  11061. }
  11062. if m.addorganization_id != nil {
  11063. fields = append(fields, contact.FieldOrganizationID)
  11064. }
  11065. if m.addctype != nil {
  11066. fields = append(fields, contact.FieldCtype)
  11067. }
  11068. if m.addcage != nil {
  11069. fields = append(fields, contact.FieldCage)
  11070. }
  11071. return fields
  11072. }
  11073. // AddedField returns the numeric value that was incremented/decremented on a field
  11074. // with the given name. The second boolean return value indicates that this field
  11075. // was not set, or was not defined in the schema.
  11076. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  11077. switch name {
  11078. case contact.FieldStatus:
  11079. return m.AddedStatus()
  11080. case contact.FieldType:
  11081. return m.AddedType()
  11082. case contact.FieldSex:
  11083. return m.AddedSex()
  11084. case contact.FieldDontseeit:
  11085. return m.AddedDontseeit()
  11086. case contact.FieldDontseeme:
  11087. return m.AddedDontseeme()
  11088. case contact.FieldOrganizationID:
  11089. return m.AddedOrganizationID()
  11090. case contact.FieldCtype:
  11091. return m.AddedCtype()
  11092. case contact.FieldCage:
  11093. return m.AddedCage()
  11094. }
  11095. return nil, false
  11096. }
  11097. // AddField adds the value to the field with the given name. It returns an error if
  11098. // the field is not defined in the schema, or if the type mismatched the field
  11099. // type.
  11100. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  11101. switch name {
  11102. case contact.FieldStatus:
  11103. v, ok := value.(int8)
  11104. if !ok {
  11105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11106. }
  11107. m.AddStatus(v)
  11108. return nil
  11109. case contact.FieldType:
  11110. v, ok := value.(int)
  11111. if !ok {
  11112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11113. }
  11114. m.AddType(v)
  11115. return nil
  11116. case contact.FieldSex:
  11117. v, ok := value.(int)
  11118. if !ok {
  11119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11120. }
  11121. m.AddSex(v)
  11122. return nil
  11123. case contact.FieldDontseeit:
  11124. v, ok := value.(int)
  11125. if !ok {
  11126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11127. }
  11128. m.AddDontseeit(v)
  11129. return nil
  11130. case contact.FieldDontseeme:
  11131. v, ok := value.(int)
  11132. if !ok {
  11133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11134. }
  11135. m.AddDontseeme(v)
  11136. return nil
  11137. case contact.FieldOrganizationID:
  11138. v, ok := value.(int64)
  11139. if !ok {
  11140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11141. }
  11142. m.AddOrganizationID(v)
  11143. return nil
  11144. case contact.FieldCtype:
  11145. v, ok := value.(int64)
  11146. if !ok {
  11147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11148. }
  11149. m.AddCtype(v)
  11150. return nil
  11151. case contact.FieldCage:
  11152. v, ok := value.(int)
  11153. if !ok {
  11154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11155. }
  11156. m.AddCage(v)
  11157. return nil
  11158. }
  11159. return fmt.Errorf("unknown Contact numeric field %s", name)
  11160. }
  11161. // ClearedFields returns all nullable fields that were cleared during this
  11162. // mutation.
  11163. func (m *ContactMutation) ClearedFields() []string {
  11164. var fields []string
  11165. if m.FieldCleared(contact.FieldStatus) {
  11166. fields = append(fields, contact.FieldStatus)
  11167. }
  11168. if m.FieldCleared(contact.FieldDeletedAt) {
  11169. fields = append(fields, contact.FieldDeletedAt)
  11170. }
  11171. if m.FieldCleared(contact.FieldType) {
  11172. fields = append(fields, contact.FieldType)
  11173. }
  11174. if m.FieldCleared(contact.FieldOrganizationID) {
  11175. fields = append(fields, contact.FieldOrganizationID)
  11176. }
  11177. return fields
  11178. }
  11179. // FieldCleared returns a boolean indicating if a field with the given name was
  11180. // cleared in this mutation.
  11181. func (m *ContactMutation) FieldCleared(name string) bool {
  11182. _, ok := m.clearedFields[name]
  11183. return ok
  11184. }
  11185. // ClearField clears the value of the field with the given name. It returns an
  11186. // error if the field is not defined in the schema.
  11187. func (m *ContactMutation) ClearField(name string) error {
  11188. switch name {
  11189. case contact.FieldStatus:
  11190. m.ClearStatus()
  11191. return nil
  11192. case contact.FieldDeletedAt:
  11193. m.ClearDeletedAt()
  11194. return nil
  11195. case contact.FieldType:
  11196. m.ClearType()
  11197. return nil
  11198. case contact.FieldOrganizationID:
  11199. m.ClearOrganizationID()
  11200. return nil
  11201. }
  11202. return fmt.Errorf("unknown Contact nullable field %s", name)
  11203. }
  11204. // ResetField resets all changes in the mutation for the field with the given name.
  11205. // It returns an error if the field is not defined in the schema.
  11206. func (m *ContactMutation) ResetField(name string) error {
  11207. switch name {
  11208. case contact.FieldCreatedAt:
  11209. m.ResetCreatedAt()
  11210. return nil
  11211. case contact.FieldUpdatedAt:
  11212. m.ResetUpdatedAt()
  11213. return nil
  11214. case contact.FieldStatus:
  11215. m.ResetStatus()
  11216. return nil
  11217. case contact.FieldDeletedAt:
  11218. m.ResetDeletedAt()
  11219. return nil
  11220. case contact.FieldWxWxid:
  11221. m.ResetWxWxid()
  11222. return nil
  11223. case contact.FieldType:
  11224. m.ResetType()
  11225. return nil
  11226. case contact.FieldWxid:
  11227. m.ResetWxid()
  11228. return nil
  11229. case contact.FieldAccount:
  11230. m.ResetAccount()
  11231. return nil
  11232. case contact.FieldNickname:
  11233. m.ResetNickname()
  11234. return nil
  11235. case contact.FieldMarkname:
  11236. m.ResetMarkname()
  11237. return nil
  11238. case contact.FieldHeadimg:
  11239. m.ResetHeadimg()
  11240. return nil
  11241. case contact.FieldSex:
  11242. m.ResetSex()
  11243. return nil
  11244. case contact.FieldStarrole:
  11245. m.ResetStarrole()
  11246. return nil
  11247. case contact.FieldDontseeit:
  11248. m.ResetDontseeit()
  11249. return nil
  11250. case contact.FieldDontseeme:
  11251. m.ResetDontseeme()
  11252. return nil
  11253. case contact.FieldLag:
  11254. m.ResetLag()
  11255. return nil
  11256. case contact.FieldGid:
  11257. m.ResetGid()
  11258. return nil
  11259. case contact.FieldGname:
  11260. m.ResetGname()
  11261. return nil
  11262. case contact.FieldV3:
  11263. m.ResetV3()
  11264. return nil
  11265. case contact.FieldOrganizationID:
  11266. m.ResetOrganizationID()
  11267. return nil
  11268. case contact.FieldCtype:
  11269. m.ResetCtype()
  11270. return nil
  11271. case contact.FieldCage:
  11272. m.ResetCage()
  11273. return nil
  11274. case contact.FieldCname:
  11275. m.ResetCname()
  11276. return nil
  11277. case contact.FieldCarea:
  11278. m.ResetCarea()
  11279. return nil
  11280. case contact.FieldCbirthday:
  11281. m.ResetCbirthday()
  11282. return nil
  11283. case contact.FieldCbirtharea:
  11284. m.ResetCbirtharea()
  11285. return nil
  11286. case contact.FieldCidcardNo:
  11287. m.ResetCidcardNo()
  11288. return nil
  11289. case contact.FieldCtitle:
  11290. m.ResetCtitle()
  11291. return nil
  11292. case contact.FieldCc:
  11293. m.ResetCc()
  11294. return nil
  11295. case contact.FieldPhone:
  11296. m.ResetPhone()
  11297. return nil
  11298. }
  11299. return fmt.Errorf("unknown Contact field %s", name)
  11300. }
  11301. // AddedEdges returns all edge names that were set/added in this mutation.
  11302. func (m *ContactMutation) AddedEdges() []string {
  11303. edges := make([]string, 0, 2)
  11304. if m.contact_relationships != nil {
  11305. edges = append(edges, contact.EdgeContactRelationships)
  11306. }
  11307. if m.contact_messages != nil {
  11308. edges = append(edges, contact.EdgeContactMessages)
  11309. }
  11310. return edges
  11311. }
  11312. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11313. // name in this mutation.
  11314. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  11315. switch name {
  11316. case contact.EdgeContactRelationships:
  11317. ids := make([]ent.Value, 0, len(m.contact_relationships))
  11318. for id := range m.contact_relationships {
  11319. ids = append(ids, id)
  11320. }
  11321. return ids
  11322. case contact.EdgeContactMessages:
  11323. ids := make([]ent.Value, 0, len(m.contact_messages))
  11324. for id := range m.contact_messages {
  11325. ids = append(ids, id)
  11326. }
  11327. return ids
  11328. }
  11329. return nil
  11330. }
  11331. // RemovedEdges returns all edge names that were removed in this mutation.
  11332. func (m *ContactMutation) RemovedEdges() []string {
  11333. edges := make([]string, 0, 2)
  11334. if m.removedcontact_relationships != nil {
  11335. edges = append(edges, contact.EdgeContactRelationships)
  11336. }
  11337. if m.removedcontact_messages != nil {
  11338. edges = append(edges, contact.EdgeContactMessages)
  11339. }
  11340. return edges
  11341. }
  11342. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11343. // the given name in this mutation.
  11344. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  11345. switch name {
  11346. case contact.EdgeContactRelationships:
  11347. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  11348. for id := range m.removedcontact_relationships {
  11349. ids = append(ids, id)
  11350. }
  11351. return ids
  11352. case contact.EdgeContactMessages:
  11353. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  11354. for id := range m.removedcontact_messages {
  11355. ids = append(ids, id)
  11356. }
  11357. return ids
  11358. }
  11359. return nil
  11360. }
  11361. // ClearedEdges returns all edge names that were cleared in this mutation.
  11362. func (m *ContactMutation) ClearedEdges() []string {
  11363. edges := make([]string, 0, 2)
  11364. if m.clearedcontact_relationships {
  11365. edges = append(edges, contact.EdgeContactRelationships)
  11366. }
  11367. if m.clearedcontact_messages {
  11368. edges = append(edges, contact.EdgeContactMessages)
  11369. }
  11370. return edges
  11371. }
  11372. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11373. // was cleared in this mutation.
  11374. func (m *ContactMutation) EdgeCleared(name string) bool {
  11375. switch name {
  11376. case contact.EdgeContactRelationships:
  11377. return m.clearedcontact_relationships
  11378. case contact.EdgeContactMessages:
  11379. return m.clearedcontact_messages
  11380. }
  11381. return false
  11382. }
  11383. // ClearEdge clears the value of the edge with the given name. It returns an error
  11384. // if that edge is not defined in the schema.
  11385. func (m *ContactMutation) ClearEdge(name string) error {
  11386. switch name {
  11387. }
  11388. return fmt.Errorf("unknown Contact unique edge %s", name)
  11389. }
  11390. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11391. // It returns an error if the edge is not defined in the schema.
  11392. func (m *ContactMutation) ResetEdge(name string) error {
  11393. switch name {
  11394. case contact.EdgeContactRelationships:
  11395. m.ResetContactRelationships()
  11396. return nil
  11397. case contact.EdgeContactMessages:
  11398. m.ResetContactMessages()
  11399. return nil
  11400. }
  11401. return fmt.Errorf("unknown Contact edge %s", name)
  11402. }
  11403. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  11404. type CreditBalanceMutation struct {
  11405. config
  11406. op Op
  11407. typ string
  11408. id *uint64
  11409. created_at *time.Time
  11410. updated_at *time.Time
  11411. deleted_at *time.Time
  11412. user_id *string
  11413. balance *float32
  11414. addbalance *float32
  11415. status *int
  11416. addstatus *int
  11417. organization_id *uint64
  11418. addorganization_id *int64
  11419. clearedFields map[string]struct{}
  11420. done bool
  11421. oldValue func(context.Context) (*CreditBalance, error)
  11422. predicates []predicate.CreditBalance
  11423. }
  11424. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  11425. // creditbalanceOption allows management of the mutation configuration using functional options.
  11426. type creditbalanceOption func(*CreditBalanceMutation)
  11427. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  11428. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  11429. m := &CreditBalanceMutation{
  11430. config: c,
  11431. op: op,
  11432. typ: TypeCreditBalance,
  11433. clearedFields: make(map[string]struct{}),
  11434. }
  11435. for _, opt := range opts {
  11436. opt(m)
  11437. }
  11438. return m
  11439. }
  11440. // withCreditBalanceID sets the ID field of the mutation.
  11441. func withCreditBalanceID(id uint64) creditbalanceOption {
  11442. return func(m *CreditBalanceMutation) {
  11443. var (
  11444. err error
  11445. once sync.Once
  11446. value *CreditBalance
  11447. )
  11448. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  11449. once.Do(func() {
  11450. if m.done {
  11451. err = errors.New("querying old values post mutation is not allowed")
  11452. } else {
  11453. value, err = m.Client().CreditBalance.Get(ctx, id)
  11454. }
  11455. })
  11456. return value, err
  11457. }
  11458. m.id = &id
  11459. }
  11460. }
  11461. // withCreditBalance sets the old CreditBalance of the mutation.
  11462. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  11463. return func(m *CreditBalanceMutation) {
  11464. m.oldValue = func(context.Context) (*CreditBalance, error) {
  11465. return node, nil
  11466. }
  11467. m.id = &node.ID
  11468. }
  11469. }
  11470. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11471. // executed in a transaction (ent.Tx), a transactional client is returned.
  11472. func (m CreditBalanceMutation) Client() *Client {
  11473. client := &Client{config: m.config}
  11474. client.init()
  11475. return client
  11476. }
  11477. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11478. // it returns an error otherwise.
  11479. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  11480. if _, ok := m.driver.(*txDriver); !ok {
  11481. return nil, errors.New("ent: mutation is not running in a transaction")
  11482. }
  11483. tx := &Tx{config: m.config}
  11484. tx.init()
  11485. return tx, nil
  11486. }
  11487. // SetID sets the value of the id field. Note that this
  11488. // operation is only accepted on creation of CreditBalance entities.
  11489. func (m *CreditBalanceMutation) SetID(id uint64) {
  11490. m.id = &id
  11491. }
  11492. // ID returns the ID value in the mutation. Note that the ID is only available
  11493. // if it was provided to the builder or after it was returned from the database.
  11494. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  11495. if m.id == nil {
  11496. return
  11497. }
  11498. return *m.id, true
  11499. }
  11500. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11501. // That means, if the mutation is applied within a transaction with an isolation level such
  11502. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11503. // or updated by the mutation.
  11504. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  11505. switch {
  11506. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11507. id, exists := m.ID()
  11508. if exists {
  11509. return []uint64{id}, nil
  11510. }
  11511. fallthrough
  11512. case m.op.Is(OpUpdate | OpDelete):
  11513. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  11514. default:
  11515. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11516. }
  11517. }
  11518. // SetCreatedAt sets the "created_at" field.
  11519. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  11520. m.created_at = &t
  11521. }
  11522. // CreatedAt returns the value of the "created_at" field in the mutation.
  11523. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  11524. v := m.created_at
  11525. if v == nil {
  11526. return
  11527. }
  11528. return *v, true
  11529. }
  11530. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  11531. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11533. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11534. if !m.op.Is(OpUpdateOne) {
  11535. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11536. }
  11537. if m.id == nil || m.oldValue == nil {
  11538. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11539. }
  11540. oldValue, err := m.oldValue(ctx)
  11541. if err != nil {
  11542. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11543. }
  11544. return oldValue.CreatedAt, nil
  11545. }
  11546. // ResetCreatedAt resets all changes to the "created_at" field.
  11547. func (m *CreditBalanceMutation) ResetCreatedAt() {
  11548. m.created_at = nil
  11549. }
  11550. // SetUpdatedAt sets the "updated_at" field.
  11551. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  11552. m.updated_at = &t
  11553. }
  11554. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11555. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  11556. v := m.updated_at
  11557. if v == nil {
  11558. return
  11559. }
  11560. return *v, true
  11561. }
  11562. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  11563. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11565. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11566. if !m.op.Is(OpUpdateOne) {
  11567. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11568. }
  11569. if m.id == nil || m.oldValue == nil {
  11570. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11571. }
  11572. oldValue, err := m.oldValue(ctx)
  11573. if err != nil {
  11574. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11575. }
  11576. return oldValue.UpdatedAt, nil
  11577. }
  11578. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11579. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  11580. m.updated_at = nil
  11581. }
  11582. // SetDeletedAt sets the "deleted_at" field.
  11583. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  11584. m.deleted_at = &t
  11585. }
  11586. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11587. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  11588. v := m.deleted_at
  11589. if v == nil {
  11590. return
  11591. }
  11592. return *v, true
  11593. }
  11594. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  11595. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11597. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11598. if !m.op.Is(OpUpdateOne) {
  11599. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11600. }
  11601. if m.id == nil || m.oldValue == nil {
  11602. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11603. }
  11604. oldValue, err := m.oldValue(ctx)
  11605. if err != nil {
  11606. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11607. }
  11608. return oldValue.DeletedAt, nil
  11609. }
  11610. // ClearDeletedAt clears the value of the "deleted_at" field.
  11611. func (m *CreditBalanceMutation) ClearDeletedAt() {
  11612. m.deleted_at = nil
  11613. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  11614. }
  11615. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11616. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  11617. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  11618. return ok
  11619. }
  11620. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11621. func (m *CreditBalanceMutation) ResetDeletedAt() {
  11622. m.deleted_at = nil
  11623. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  11624. }
  11625. // SetUserID sets the "user_id" field.
  11626. func (m *CreditBalanceMutation) SetUserID(s string) {
  11627. m.user_id = &s
  11628. }
  11629. // UserID returns the value of the "user_id" field in the mutation.
  11630. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  11631. v := m.user_id
  11632. if v == nil {
  11633. return
  11634. }
  11635. return *v, true
  11636. }
  11637. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  11638. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11640. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  11641. if !m.op.Is(OpUpdateOne) {
  11642. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11643. }
  11644. if m.id == nil || m.oldValue == nil {
  11645. return v, errors.New("OldUserID requires an ID field in the mutation")
  11646. }
  11647. oldValue, err := m.oldValue(ctx)
  11648. if err != nil {
  11649. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11650. }
  11651. return oldValue.UserID, nil
  11652. }
  11653. // ClearUserID clears the value of the "user_id" field.
  11654. func (m *CreditBalanceMutation) ClearUserID() {
  11655. m.user_id = nil
  11656. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  11657. }
  11658. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11659. func (m *CreditBalanceMutation) UserIDCleared() bool {
  11660. _, ok := m.clearedFields[creditbalance.FieldUserID]
  11661. return ok
  11662. }
  11663. // ResetUserID resets all changes to the "user_id" field.
  11664. func (m *CreditBalanceMutation) ResetUserID() {
  11665. m.user_id = nil
  11666. delete(m.clearedFields, creditbalance.FieldUserID)
  11667. }
  11668. // SetBalance sets the "balance" field.
  11669. func (m *CreditBalanceMutation) SetBalance(f float32) {
  11670. m.balance = &f
  11671. m.addbalance = nil
  11672. }
  11673. // Balance returns the value of the "balance" field in the mutation.
  11674. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  11675. v := m.balance
  11676. if v == nil {
  11677. return
  11678. }
  11679. return *v, true
  11680. }
  11681. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  11682. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11684. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  11685. if !m.op.Is(OpUpdateOne) {
  11686. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  11687. }
  11688. if m.id == nil || m.oldValue == nil {
  11689. return v, errors.New("OldBalance requires an ID field in the mutation")
  11690. }
  11691. oldValue, err := m.oldValue(ctx)
  11692. if err != nil {
  11693. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  11694. }
  11695. return oldValue.Balance, nil
  11696. }
  11697. // AddBalance adds f to the "balance" field.
  11698. func (m *CreditBalanceMutation) AddBalance(f float32) {
  11699. if m.addbalance != nil {
  11700. *m.addbalance += f
  11701. } else {
  11702. m.addbalance = &f
  11703. }
  11704. }
  11705. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  11706. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  11707. v := m.addbalance
  11708. if v == nil {
  11709. return
  11710. }
  11711. return *v, true
  11712. }
  11713. // ResetBalance resets all changes to the "balance" field.
  11714. func (m *CreditBalanceMutation) ResetBalance() {
  11715. m.balance = nil
  11716. m.addbalance = nil
  11717. }
  11718. // SetStatus sets the "status" field.
  11719. func (m *CreditBalanceMutation) SetStatus(i int) {
  11720. m.status = &i
  11721. m.addstatus = nil
  11722. }
  11723. // Status returns the value of the "status" field in the mutation.
  11724. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  11725. v := m.status
  11726. if v == nil {
  11727. return
  11728. }
  11729. return *v, true
  11730. }
  11731. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  11732. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11734. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  11735. if !m.op.Is(OpUpdateOne) {
  11736. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11737. }
  11738. if m.id == nil || m.oldValue == nil {
  11739. return v, errors.New("OldStatus requires an ID field in the mutation")
  11740. }
  11741. oldValue, err := m.oldValue(ctx)
  11742. if err != nil {
  11743. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11744. }
  11745. return oldValue.Status, nil
  11746. }
  11747. // AddStatus adds i to the "status" field.
  11748. func (m *CreditBalanceMutation) AddStatus(i int) {
  11749. if m.addstatus != nil {
  11750. *m.addstatus += i
  11751. } else {
  11752. m.addstatus = &i
  11753. }
  11754. }
  11755. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11756. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  11757. v := m.addstatus
  11758. if v == nil {
  11759. return
  11760. }
  11761. return *v, true
  11762. }
  11763. // ClearStatus clears the value of the "status" field.
  11764. func (m *CreditBalanceMutation) ClearStatus() {
  11765. m.status = nil
  11766. m.addstatus = nil
  11767. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  11768. }
  11769. // StatusCleared returns if the "status" field was cleared in this mutation.
  11770. func (m *CreditBalanceMutation) StatusCleared() bool {
  11771. _, ok := m.clearedFields[creditbalance.FieldStatus]
  11772. return ok
  11773. }
  11774. // ResetStatus resets all changes to the "status" field.
  11775. func (m *CreditBalanceMutation) ResetStatus() {
  11776. m.status = nil
  11777. m.addstatus = nil
  11778. delete(m.clearedFields, creditbalance.FieldStatus)
  11779. }
  11780. // SetOrganizationID sets the "organization_id" field.
  11781. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  11782. m.organization_id = &u
  11783. m.addorganization_id = nil
  11784. }
  11785. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11786. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  11787. v := m.organization_id
  11788. if v == nil {
  11789. return
  11790. }
  11791. return *v, true
  11792. }
  11793. // OldOrganizationID returns the old "organization_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) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11797. if !m.op.Is(OpUpdateOne) {
  11798. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11799. }
  11800. if m.id == nil || m.oldValue == nil {
  11801. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  11806. }
  11807. return oldValue.OrganizationID, nil
  11808. }
  11809. // AddOrganizationID adds u to the "organization_id" field.
  11810. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  11811. if m.addorganization_id != nil {
  11812. *m.addorganization_id += u
  11813. } else {
  11814. m.addorganization_id = &u
  11815. }
  11816. }
  11817. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11818. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  11819. v := m.addorganization_id
  11820. if v == nil {
  11821. return
  11822. }
  11823. return *v, true
  11824. }
  11825. // ClearOrganizationID clears the value of the "organization_id" field.
  11826. func (m *CreditBalanceMutation) ClearOrganizationID() {
  11827. m.organization_id = nil
  11828. m.addorganization_id = nil
  11829. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  11830. }
  11831. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11832. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  11833. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  11834. return ok
  11835. }
  11836. // ResetOrganizationID resets all changes to the "organization_id" field.
  11837. func (m *CreditBalanceMutation) ResetOrganizationID() {
  11838. m.organization_id = nil
  11839. m.addorganization_id = nil
  11840. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  11841. }
  11842. // Where appends a list predicates to the CreditBalanceMutation builder.
  11843. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  11844. m.predicates = append(m.predicates, ps...)
  11845. }
  11846. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  11847. // users can use type-assertion to append predicates that do not depend on any generated package.
  11848. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  11849. p := make([]predicate.CreditBalance, len(ps))
  11850. for i := range ps {
  11851. p[i] = ps[i]
  11852. }
  11853. m.Where(p...)
  11854. }
  11855. // Op returns the operation name.
  11856. func (m *CreditBalanceMutation) Op() Op {
  11857. return m.op
  11858. }
  11859. // SetOp allows setting the mutation operation.
  11860. func (m *CreditBalanceMutation) SetOp(op Op) {
  11861. m.op = op
  11862. }
  11863. // Type returns the node type of this mutation (CreditBalance).
  11864. func (m *CreditBalanceMutation) Type() string {
  11865. return m.typ
  11866. }
  11867. // Fields returns all fields that were changed during this mutation. Note that in
  11868. // order to get all numeric fields that were incremented/decremented, call
  11869. // AddedFields().
  11870. func (m *CreditBalanceMutation) Fields() []string {
  11871. fields := make([]string, 0, 7)
  11872. if m.created_at != nil {
  11873. fields = append(fields, creditbalance.FieldCreatedAt)
  11874. }
  11875. if m.updated_at != nil {
  11876. fields = append(fields, creditbalance.FieldUpdatedAt)
  11877. }
  11878. if m.deleted_at != nil {
  11879. fields = append(fields, creditbalance.FieldDeletedAt)
  11880. }
  11881. if m.user_id != nil {
  11882. fields = append(fields, creditbalance.FieldUserID)
  11883. }
  11884. if m.balance != nil {
  11885. fields = append(fields, creditbalance.FieldBalance)
  11886. }
  11887. if m.status != nil {
  11888. fields = append(fields, creditbalance.FieldStatus)
  11889. }
  11890. if m.organization_id != nil {
  11891. fields = append(fields, creditbalance.FieldOrganizationID)
  11892. }
  11893. return fields
  11894. }
  11895. // Field returns the value of a field with the given name. The second boolean
  11896. // return value indicates that this field was not set, or was not defined in the
  11897. // schema.
  11898. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  11899. switch name {
  11900. case creditbalance.FieldCreatedAt:
  11901. return m.CreatedAt()
  11902. case creditbalance.FieldUpdatedAt:
  11903. return m.UpdatedAt()
  11904. case creditbalance.FieldDeletedAt:
  11905. return m.DeletedAt()
  11906. case creditbalance.FieldUserID:
  11907. return m.UserID()
  11908. case creditbalance.FieldBalance:
  11909. return m.Balance()
  11910. case creditbalance.FieldStatus:
  11911. return m.Status()
  11912. case creditbalance.FieldOrganizationID:
  11913. return m.OrganizationID()
  11914. }
  11915. return nil, false
  11916. }
  11917. // OldField returns the old value of the field from the database. An error is
  11918. // returned if the mutation operation is not UpdateOne, or the query to the
  11919. // database failed.
  11920. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11921. switch name {
  11922. case creditbalance.FieldCreatedAt:
  11923. return m.OldCreatedAt(ctx)
  11924. case creditbalance.FieldUpdatedAt:
  11925. return m.OldUpdatedAt(ctx)
  11926. case creditbalance.FieldDeletedAt:
  11927. return m.OldDeletedAt(ctx)
  11928. case creditbalance.FieldUserID:
  11929. return m.OldUserID(ctx)
  11930. case creditbalance.FieldBalance:
  11931. return m.OldBalance(ctx)
  11932. case creditbalance.FieldStatus:
  11933. return m.OldStatus(ctx)
  11934. case creditbalance.FieldOrganizationID:
  11935. return m.OldOrganizationID(ctx)
  11936. }
  11937. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  11938. }
  11939. // SetField sets the value of a field with the given name. It returns an error if
  11940. // the field is not defined in the schema, or if the type mismatched the field
  11941. // type.
  11942. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  11943. switch name {
  11944. case creditbalance.FieldCreatedAt:
  11945. v, ok := value.(time.Time)
  11946. if !ok {
  11947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11948. }
  11949. m.SetCreatedAt(v)
  11950. return nil
  11951. case creditbalance.FieldUpdatedAt:
  11952. v, ok := value.(time.Time)
  11953. if !ok {
  11954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11955. }
  11956. m.SetUpdatedAt(v)
  11957. return nil
  11958. case creditbalance.FieldDeletedAt:
  11959. v, ok := value.(time.Time)
  11960. if !ok {
  11961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11962. }
  11963. m.SetDeletedAt(v)
  11964. return nil
  11965. case creditbalance.FieldUserID:
  11966. v, ok := value.(string)
  11967. if !ok {
  11968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11969. }
  11970. m.SetUserID(v)
  11971. return nil
  11972. case creditbalance.FieldBalance:
  11973. v, ok := value.(float32)
  11974. if !ok {
  11975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11976. }
  11977. m.SetBalance(v)
  11978. return nil
  11979. case creditbalance.FieldStatus:
  11980. v, ok := value.(int)
  11981. if !ok {
  11982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11983. }
  11984. m.SetStatus(v)
  11985. return nil
  11986. case creditbalance.FieldOrganizationID:
  11987. v, ok := value.(uint64)
  11988. if !ok {
  11989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11990. }
  11991. m.SetOrganizationID(v)
  11992. return nil
  11993. }
  11994. return fmt.Errorf("unknown CreditBalance field %s", name)
  11995. }
  11996. // AddedFields returns all numeric fields that were incremented/decremented during
  11997. // this mutation.
  11998. func (m *CreditBalanceMutation) AddedFields() []string {
  11999. var fields []string
  12000. if m.addbalance != nil {
  12001. fields = append(fields, creditbalance.FieldBalance)
  12002. }
  12003. if m.addstatus != nil {
  12004. fields = append(fields, creditbalance.FieldStatus)
  12005. }
  12006. if m.addorganization_id != nil {
  12007. fields = append(fields, creditbalance.FieldOrganizationID)
  12008. }
  12009. return fields
  12010. }
  12011. // AddedField returns the numeric value that was incremented/decremented on a field
  12012. // with the given name. The second boolean return value indicates that this field
  12013. // was not set, or was not defined in the schema.
  12014. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  12015. switch name {
  12016. case creditbalance.FieldBalance:
  12017. return m.AddedBalance()
  12018. case creditbalance.FieldStatus:
  12019. return m.AddedStatus()
  12020. case creditbalance.FieldOrganizationID:
  12021. return m.AddedOrganizationID()
  12022. }
  12023. return nil, false
  12024. }
  12025. // AddField adds the value to the field with the given name. It returns an error if
  12026. // the field is not defined in the schema, or if the type mismatched the field
  12027. // type.
  12028. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  12029. switch name {
  12030. case creditbalance.FieldBalance:
  12031. v, ok := value.(float32)
  12032. if !ok {
  12033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12034. }
  12035. m.AddBalance(v)
  12036. return nil
  12037. case creditbalance.FieldStatus:
  12038. v, ok := value.(int)
  12039. if !ok {
  12040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12041. }
  12042. m.AddStatus(v)
  12043. return nil
  12044. case creditbalance.FieldOrganizationID:
  12045. v, ok := value.(int64)
  12046. if !ok {
  12047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12048. }
  12049. m.AddOrganizationID(v)
  12050. return nil
  12051. }
  12052. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  12053. }
  12054. // ClearedFields returns all nullable fields that were cleared during this
  12055. // mutation.
  12056. func (m *CreditBalanceMutation) ClearedFields() []string {
  12057. var fields []string
  12058. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  12059. fields = append(fields, creditbalance.FieldDeletedAt)
  12060. }
  12061. if m.FieldCleared(creditbalance.FieldUserID) {
  12062. fields = append(fields, creditbalance.FieldUserID)
  12063. }
  12064. if m.FieldCleared(creditbalance.FieldStatus) {
  12065. fields = append(fields, creditbalance.FieldStatus)
  12066. }
  12067. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  12068. fields = append(fields, creditbalance.FieldOrganizationID)
  12069. }
  12070. return fields
  12071. }
  12072. // FieldCleared returns a boolean indicating if a field with the given name was
  12073. // cleared in this mutation.
  12074. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  12075. _, ok := m.clearedFields[name]
  12076. return ok
  12077. }
  12078. // ClearField clears the value of the field with the given name. It returns an
  12079. // error if the field is not defined in the schema.
  12080. func (m *CreditBalanceMutation) ClearField(name string) error {
  12081. switch name {
  12082. case creditbalance.FieldDeletedAt:
  12083. m.ClearDeletedAt()
  12084. return nil
  12085. case creditbalance.FieldUserID:
  12086. m.ClearUserID()
  12087. return nil
  12088. case creditbalance.FieldStatus:
  12089. m.ClearStatus()
  12090. return nil
  12091. case creditbalance.FieldOrganizationID:
  12092. m.ClearOrganizationID()
  12093. return nil
  12094. }
  12095. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  12096. }
  12097. // ResetField resets all changes in the mutation for the field with the given name.
  12098. // It returns an error if the field is not defined in the schema.
  12099. func (m *CreditBalanceMutation) ResetField(name string) error {
  12100. switch name {
  12101. case creditbalance.FieldCreatedAt:
  12102. m.ResetCreatedAt()
  12103. return nil
  12104. case creditbalance.FieldUpdatedAt:
  12105. m.ResetUpdatedAt()
  12106. return nil
  12107. case creditbalance.FieldDeletedAt:
  12108. m.ResetDeletedAt()
  12109. return nil
  12110. case creditbalance.FieldUserID:
  12111. m.ResetUserID()
  12112. return nil
  12113. case creditbalance.FieldBalance:
  12114. m.ResetBalance()
  12115. return nil
  12116. case creditbalance.FieldStatus:
  12117. m.ResetStatus()
  12118. return nil
  12119. case creditbalance.FieldOrganizationID:
  12120. m.ResetOrganizationID()
  12121. return nil
  12122. }
  12123. return fmt.Errorf("unknown CreditBalance field %s", name)
  12124. }
  12125. // AddedEdges returns all edge names that were set/added in this mutation.
  12126. func (m *CreditBalanceMutation) AddedEdges() []string {
  12127. edges := make([]string, 0, 0)
  12128. return edges
  12129. }
  12130. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12131. // name in this mutation.
  12132. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  12133. return nil
  12134. }
  12135. // RemovedEdges returns all edge names that were removed in this mutation.
  12136. func (m *CreditBalanceMutation) RemovedEdges() []string {
  12137. edges := make([]string, 0, 0)
  12138. return edges
  12139. }
  12140. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12141. // the given name in this mutation.
  12142. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  12143. return nil
  12144. }
  12145. // ClearedEdges returns all edge names that were cleared in this mutation.
  12146. func (m *CreditBalanceMutation) ClearedEdges() []string {
  12147. edges := make([]string, 0, 0)
  12148. return edges
  12149. }
  12150. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12151. // was cleared in this mutation.
  12152. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  12153. return false
  12154. }
  12155. // ClearEdge clears the value of the edge with the given name. It returns an error
  12156. // if that edge is not defined in the schema.
  12157. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  12158. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  12159. }
  12160. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12161. // It returns an error if the edge is not defined in the schema.
  12162. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  12163. return fmt.Errorf("unknown CreditBalance edge %s", name)
  12164. }
  12165. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  12166. type CreditUsageMutation struct {
  12167. config
  12168. op Op
  12169. typ string
  12170. id *uint64
  12171. created_at *time.Time
  12172. updated_at *time.Time
  12173. deleted_at *time.Time
  12174. user_id *string
  12175. number *float32
  12176. addnumber *float32
  12177. status *int
  12178. addstatus *int
  12179. ntype *int
  12180. addntype *int
  12181. table *string
  12182. organization_id *uint64
  12183. addorganization_id *int64
  12184. nid *uint64
  12185. addnid *int64
  12186. reason *string
  12187. operator *string
  12188. clearedFields map[string]struct{}
  12189. done bool
  12190. oldValue func(context.Context) (*CreditUsage, error)
  12191. predicates []predicate.CreditUsage
  12192. }
  12193. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  12194. // creditusageOption allows management of the mutation configuration using functional options.
  12195. type creditusageOption func(*CreditUsageMutation)
  12196. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  12197. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  12198. m := &CreditUsageMutation{
  12199. config: c,
  12200. op: op,
  12201. typ: TypeCreditUsage,
  12202. clearedFields: make(map[string]struct{}),
  12203. }
  12204. for _, opt := range opts {
  12205. opt(m)
  12206. }
  12207. return m
  12208. }
  12209. // withCreditUsageID sets the ID field of the mutation.
  12210. func withCreditUsageID(id uint64) creditusageOption {
  12211. return func(m *CreditUsageMutation) {
  12212. var (
  12213. err error
  12214. once sync.Once
  12215. value *CreditUsage
  12216. )
  12217. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  12218. once.Do(func() {
  12219. if m.done {
  12220. err = errors.New("querying old values post mutation is not allowed")
  12221. } else {
  12222. value, err = m.Client().CreditUsage.Get(ctx, id)
  12223. }
  12224. })
  12225. return value, err
  12226. }
  12227. m.id = &id
  12228. }
  12229. }
  12230. // withCreditUsage sets the old CreditUsage of the mutation.
  12231. func withCreditUsage(node *CreditUsage) creditusageOption {
  12232. return func(m *CreditUsageMutation) {
  12233. m.oldValue = func(context.Context) (*CreditUsage, error) {
  12234. return node, nil
  12235. }
  12236. m.id = &node.ID
  12237. }
  12238. }
  12239. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12240. // executed in a transaction (ent.Tx), a transactional client is returned.
  12241. func (m CreditUsageMutation) Client() *Client {
  12242. client := &Client{config: m.config}
  12243. client.init()
  12244. return client
  12245. }
  12246. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12247. // it returns an error otherwise.
  12248. func (m CreditUsageMutation) Tx() (*Tx, error) {
  12249. if _, ok := m.driver.(*txDriver); !ok {
  12250. return nil, errors.New("ent: mutation is not running in a transaction")
  12251. }
  12252. tx := &Tx{config: m.config}
  12253. tx.init()
  12254. return tx, nil
  12255. }
  12256. // SetID sets the value of the id field. Note that this
  12257. // operation is only accepted on creation of CreditUsage entities.
  12258. func (m *CreditUsageMutation) SetID(id uint64) {
  12259. m.id = &id
  12260. }
  12261. // ID returns the ID value in the mutation. Note that the ID is only available
  12262. // if it was provided to the builder or after it was returned from the database.
  12263. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  12264. if m.id == nil {
  12265. return
  12266. }
  12267. return *m.id, true
  12268. }
  12269. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12270. // That means, if the mutation is applied within a transaction with an isolation level such
  12271. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12272. // or updated by the mutation.
  12273. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  12274. switch {
  12275. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12276. id, exists := m.ID()
  12277. if exists {
  12278. return []uint64{id}, nil
  12279. }
  12280. fallthrough
  12281. case m.op.Is(OpUpdate | OpDelete):
  12282. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  12283. default:
  12284. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12285. }
  12286. }
  12287. // SetCreatedAt sets the "created_at" field.
  12288. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  12289. m.created_at = &t
  12290. }
  12291. // CreatedAt returns the value of the "created_at" field in the mutation.
  12292. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  12293. v := m.created_at
  12294. if v == nil {
  12295. return
  12296. }
  12297. return *v, true
  12298. }
  12299. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  12300. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12302. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12303. if !m.op.Is(OpUpdateOne) {
  12304. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12305. }
  12306. if m.id == nil || m.oldValue == nil {
  12307. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12308. }
  12309. oldValue, err := m.oldValue(ctx)
  12310. if err != nil {
  12311. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12312. }
  12313. return oldValue.CreatedAt, nil
  12314. }
  12315. // ResetCreatedAt resets all changes to the "created_at" field.
  12316. func (m *CreditUsageMutation) ResetCreatedAt() {
  12317. m.created_at = nil
  12318. }
  12319. // SetUpdatedAt sets the "updated_at" field.
  12320. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  12321. m.updated_at = &t
  12322. }
  12323. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12324. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  12325. v := m.updated_at
  12326. if v == nil {
  12327. return
  12328. }
  12329. return *v, true
  12330. }
  12331. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  12332. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12334. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12335. if !m.op.Is(OpUpdateOne) {
  12336. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12337. }
  12338. if m.id == nil || m.oldValue == nil {
  12339. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12340. }
  12341. oldValue, err := m.oldValue(ctx)
  12342. if err != nil {
  12343. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12344. }
  12345. return oldValue.UpdatedAt, nil
  12346. }
  12347. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12348. func (m *CreditUsageMutation) ResetUpdatedAt() {
  12349. m.updated_at = nil
  12350. }
  12351. // SetDeletedAt sets the "deleted_at" field.
  12352. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  12353. m.deleted_at = &t
  12354. }
  12355. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12356. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  12357. v := m.deleted_at
  12358. if v == nil {
  12359. return
  12360. }
  12361. return *v, true
  12362. }
  12363. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  12364. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12366. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12367. if !m.op.Is(OpUpdateOne) {
  12368. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12369. }
  12370. if m.id == nil || m.oldValue == nil {
  12371. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12372. }
  12373. oldValue, err := m.oldValue(ctx)
  12374. if err != nil {
  12375. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12376. }
  12377. return oldValue.DeletedAt, nil
  12378. }
  12379. // ClearDeletedAt clears the value of the "deleted_at" field.
  12380. func (m *CreditUsageMutation) ClearDeletedAt() {
  12381. m.deleted_at = nil
  12382. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  12383. }
  12384. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12385. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  12386. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  12387. return ok
  12388. }
  12389. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12390. func (m *CreditUsageMutation) ResetDeletedAt() {
  12391. m.deleted_at = nil
  12392. delete(m.clearedFields, creditusage.FieldDeletedAt)
  12393. }
  12394. // SetUserID sets the "user_id" field.
  12395. func (m *CreditUsageMutation) SetUserID(s string) {
  12396. m.user_id = &s
  12397. }
  12398. // UserID returns the value of the "user_id" field in the mutation.
  12399. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  12400. v := m.user_id
  12401. if v == nil {
  12402. return
  12403. }
  12404. return *v, true
  12405. }
  12406. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  12407. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12409. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  12410. if !m.op.Is(OpUpdateOne) {
  12411. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  12412. }
  12413. if m.id == nil || m.oldValue == nil {
  12414. return v, errors.New("OldUserID requires an ID field in the mutation")
  12415. }
  12416. oldValue, err := m.oldValue(ctx)
  12417. if err != nil {
  12418. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  12419. }
  12420. return oldValue.UserID, nil
  12421. }
  12422. // ClearUserID clears the value of the "user_id" field.
  12423. func (m *CreditUsageMutation) ClearUserID() {
  12424. m.user_id = nil
  12425. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  12426. }
  12427. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  12428. func (m *CreditUsageMutation) UserIDCleared() bool {
  12429. _, ok := m.clearedFields[creditusage.FieldUserID]
  12430. return ok
  12431. }
  12432. // ResetUserID resets all changes to the "user_id" field.
  12433. func (m *CreditUsageMutation) ResetUserID() {
  12434. m.user_id = nil
  12435. delete(m.clearedFields, creditusage.FieldUserID)
  12436. }
  12437. // SetNumber sets the "number" field.
  12438. func (m *CreditUsageMutation) SetNumber(f float32) {
  12439. m.number = &f
  12440. m.addnumber = nil
  12441. }
  12442. // Number returns the value of the "number" field in the mutation.
  12443. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  12444. v := m.number
  12445. if v == nil {
  12446. return
  12447. }
  12448. return *v, true
  12449. }
  12450. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  12451. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12453. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  12454. if !m.op.Is(OpUpdateOne) {
  12455. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  12456. }
  12457. if m.id == nil || m.oldValue == nil {
  12458. return v, errors.New("OldNumber requires an ID field in the mutation")
  12459. }
  12460. oldValue, err := m.oldValue(ctx)
  12461. if err != nil {
  12462. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  12463. }
  12464. return oldValue.Number, nil
  12465. }
  12466. // AddNumber adds f to the "number" field.
  12467. func (m *CreditUsageMutation) AddNumber(f float32) {
  12468. if m.addnumber != nil {
  12469. *m.addnumber += f
  12470. } else {
  12471. m.addnumber = &f
  12472. }
  12473. }
  12474. // AddedNumber returns the value that was added to the "number" field in this mutation.
  12475. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  12476. v := m.addnumber
  12477. if v == nil {
  12478. return
  12479. }
  12480. return *v, true
  12481. }
  12482. // ResetNumber resets all changes to the "number" field.
  12483. func (m *CreditUsageMutation) ResetNumber() {
  12484. m.number = nil
  12485. m.addnumber = nil
  12486. }
  12487. // SetStatus sets the "status" field.
  12488. func (m *CreditUsageMutation) SetStatus(i int) {
  12489. m.status = &i
  12490. m.addstatus = nil
  12491. }
  12492. // Status returns the value of the "status" field in the mutation.
  12493. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  12494. v := m.status
  12495. if v == nil {
  12496. return
  12497. }
  12498. return *v, true
  12499. }
  12500. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  12501. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12503. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  12504. if !m.op.Is(OpUpdateOne) {
  12505. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12506. }
  12507. if m.id == nil || m.oldValue == nil {
  12508. return v, errors.New("OldStatus requires an ID field in the mutation")
  12509. }
  12510. oldValue, err := m.oldValue(ctx)
  12511. if err != nil {
  12512. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12513. }
  12514. return oldValue.Status, nil
  12515. }
  12516. // AddStatus adds i to the "status" field.
  12517. func (m *CreditUsageMutation) AddStatus(i int) {
  12518. if m.addstatus != nil {
  12519. *m.addstatus += i
  12520. } else {
  12521. m.addstatus = &i
  12522. }
  12523. }
  12524. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12525. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  12526. v := m.addstatus
  12527. if v == nil {
  12528. return
  12529. }
  12530. return *v, true
  12531. }
  12532. // ClearStatus clears the value of the "status" field.
  12533. func (m *CreditUsageMutation) ClearStatus() {
  12534. m.status = nil
  12535. m.addstatus = nil
  12536. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  12537. }
  12538. // StatusCleared returns if the "status" field was cleared in this mutation.
  12539. func (m *CreditUsageMutation) StatusCleared() bool {
  12540. _, ok := m.clearedFields[creditusage.FieldStatus]
  12541. return ok
  12542. }
  12543. // ResetStatus resets all changes to the "status" field.
  12544. func (m *CreditUsageMutation) ResetStatus() {
  12545. m.status = nil
  12546. m.addstatus = nil
  12547. delete(m.clearedFields, creditusage.FieldStatus)
  12548. }
  12549. // SetNtype sets the "ntype" field.
  12550. func (m *CreditUsageMutation) SetNtype(i int) {
  12551. m.ntype = &i
  12552. m.addntype = nil
  12553. }
  12554. // Ntype returns the value of the "ntype" field in the mutation.
  12555. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  12556. v := m.ntype
  12557. if v == nil {
  12558. return
  12559. }
  12560. return *v, true
  12561. }
  12562. // OldNtype returns the old "ntype" 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) OldNtype(ctx context.Context) (v int, err error) {
  12566. if !m.op.Is(OpUpdateOne) {
  12567. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  12568. }
  12569. if m.id == nil || m.oldValue == nil {
  12570. return v, errors.New("OldNtype 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 OldNtype: %w", err)
  12575. }
  12576. return oldValue.Ntype, nil
  12577. }
  12578. // AddNtype adds i to the "ntype" field.
  12579. func (m *CreditUsageMutation) AddNtype(i int) {
  12580. if m.addntype != nil {
  12581. *m.addntype += i
  12582. } else {
  12583. m.addntype = &i
  12584. }
  12585. }
  12586. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  12587. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  12588. v := m.addntype
  12589. if v == nil {
  12590. return
  12591. }
  12592. return *v, true
  12593. }
  12594. // ResetNtype resets all changes to the "ntype" field.
  12595. func (m *CreditUsageMutation) ResetNtype() {
  12596. m.ntype = nil
  12597. m.addntype = nil
  12598. }
  12599. // SetTable sets the "table" field.
  12600. func (m *CreditUsageMutation) SetTable(s string) {
  12601. m.table = &s
  12602. }
  12603. // Table returns the value of the "table" field in the mutation.
  12604. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  12605. v := m.table
  12606. if v == nil {
  12607. return
  12608. }
  12609. return *v, true
  12610. }
  12611. // OldTable returns the old "table" field's value of the CreditUsage entity.
  12612. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12614. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  12615. if !m.op.Is(OpUpdateOne) {
  12616. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  12617. }
  12618. if m.id == nil || m.oldValue == nil {
  12619. return v, errors.New("OldTable requires an ID field in the mutation")
  12620. }
  12621. oldValue, err := m.oldValue(ctx)
  12622. if err != nil {
  12623. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  12624. }
  12625. return oldValue.Table, nil
  12626. }
  12627. // ResetTable resets all changes to the "table" field.
  12628. func (m *CreditUsageMutation) ResetTable() {
  12629. m.table = nil
  12630. }
  12631. // SetOrganizationID sets the "organization_id" field.
  12632. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  12633. m.organization_id = &u
  12634. m.addorganization_id = nil
  12635. }
  12636. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12637. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  12638. v := m.organization_id
  12639. if v == nil {
  12640. return
  12641. }
  12642. return *v, true
  12643. }
  12644. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  12645. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12647. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12648. if !m.op.Is(OpUpdateOne) {
  12649. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12650. }
  12651. if m.id == nil || m.oldValue == nil {
  12652. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12653. }
  12654. oldValue, err := m.oldValue(ctx)
  12655. if err != nil {
  12656. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12657. }
  12658. return oldValue.OrganizationID, nil
  12659. }
  12660. // AddOrganizationID adds u to the "organization_id" field.
  12661. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  12662. if m.addorganization_id != nil {
  12663. *m.addorganization_id += u
  12664. } else {
  12665. m.addorganization_id = &u
  12666. }
  12667. }
  12668. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12669. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  12670. v := m.addorganization_id
  12671. if v == nil {
  12672. return
  12673. }
  12674. return *v, true
  12675. }
  12676. // ClearOrganizationID clears the value of the "organization_id" field.
  12677. func (m *CreditUsageMutation) ClearOrganizationID() {
  12678. m.organization_id = nil
  12679. m.addorganization_id = nil
  12680. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  12681. }
  12682. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12683. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  12684. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  12685. return ok
  12686. }
  12687. // ResetOrganizationID resets all changes to the "organization_id" field.
  12688. func (m *CreditUsageMutation) ResetOrganizationID() {
  12689. m.organization_id = nil
  12690. m.addorganization_id = nil
  12691. delete(m.clearedFields, creditusage.FieldOrganizationID)
  12692. }
  12693. // SetNid sets the "nid" field.
  12694. func (m *CreditUsageMutation) SetNid(u uint64) {
  12695. m.nid = &u
  12696. m.addnid = nil
  12697. }
  12698. // Nid returns the value of the "nid" field in the mutation.
  12699. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  12700. v := m.nid
  12701. if v == nil {
  12702. return
  12703. }
  12704. return *v, true
  12705. }
  12706. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  12707. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12709. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  12710. if !m.op.Is(OpUpdateOne) {
  12711. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  12712. }
  12713. if m.id == nil || m.oldValue == nil {
  12714. return v, errors.New("OldNid requires an ID field in the mutation")
  12715. }
  12716. oldValue, err := m.oldValue(ctx)
  12717. if err != nil {
  12718. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  12719. }
  12720. return oldValue.Nid, nil
  12721. }
  12722. // AddNid adds u to the "nid" field.
  12723. func (m *CreditUsageMutation) AddNid(u int64) {
  12724. if m.addnid != nil {
  12725. *m.addnid += u
  12726. } else {
  12727. m.addnid = &u
  12728. }
  12729. }
  12730. // AddedNid returns the value that was added to the "nid" field in this mutation.
  12731. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  12732. v := m.addnid
  12733. if v == nil {
  12734. return
  12735. }
  12736. return *v, true
  12737. }
  12738. // ResetNid resets all changes to the "nid" field.
  12739. func (m *CreditUsageMutation) ResetNid() {
  12740. m.nid = nil
  12741. m.addnid = nil
  12742. }
  12743. // SetReason sets the "reason" field.
  12744. func (m *CreditUsageMutation) SetReason(s string) {
  12745. m.reason = &s
  12746. }
  12747. // Reason returns the value of the "reason" field in the mutation.
  12748. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  12749. v := m.reason
  12750. if v == nil {
  12751. return
  12752. }
  12753. return *v, true
  12754. }
  12755. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  12756. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12758. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  12759. if !m.op.Is(OpUpdateOne) {
  12760. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  12761. }
  12762. if m.id == nil || m.oldValue == nil {
  12763. return v, errors.New("OldReason requires an ID field in the mutation")
  12764. }
  12765. oldValue, err := m.oldValue(ctx)
  12766. if err != nil {
  12767. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  12768. }
  12769. return oldValue.Reason, nil
  12770. }
  12771. // ResetReason resets all changes to the "reason" field.
  12772. func (m *CreditUsageMutation) ResetReason() {
  12773. m.reason = nil
  12774. }
  12775. // SetOperator sets the "operator" field.
  12776. func (m *CreditUsageMutation) SetOperator(s string) {
  12777. m.operator = &s
  12778. }
  12779. // Operator returns the value of the "operator" field in the mutation.
  12780. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  12781. v := m.operator
  12782. if v == nil {
  12783. return
  12784. }
  12785. return *v, true
  12786. }
  12787. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  12788. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12790. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  12791. if !m.op.Is(OpUpdateOne) {
  12792. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  12793. }
  12794. if m.id == nil || m.oldValue == nil {
  12795. return v, errors.New("OldOperator requires an ID field in the mutation")
  12796. }
  12797. oldValue, err := m.oldValue(ctx)
  12798. if err != nil {
  12799. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  12800. }
  12801. return oldValue.Operator, nil
  12802. }
  12803. // ResetOperator resets all changes to the "operator" field.
  12804. func (m *CreditUsageMutation) ResetOperator() {
  12805. m.operator = nil
  12806. }
  12807. // Where appends a list predicates to the CreditUsageMutation builder.
  12808. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  12809. m.predicates = append(m.predicates, ps...)
  12810. }
  12811. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  12812. // users can use type-assertion to append predicates that do not depend on any generated package.
  12813. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  12814. p := make([]predicate.CreditUsage, len(ps))
  12815. for i := range ps {
  12816. p[i] = ps[i]
  12817. }
  12818. m.Where(p...)
  12819. }
  12820. // Op returns the operation name.
  12821. func (m *CreditUsageMutation) Op() Op {
  12822. return m.op
  12823. }
  12824. // SetOp allows setting the mutation operation.
  12825. func (m *CreditUsageMutation) SetOp(op Op) {
  12826. m.op = op
  12827. }
  12828. // Type returns the node type of this mutation (CreditUsage).
  12829. func (m *CreditUsageMutation) Type() string {
  12830. return m.typ
  12831. }
  12832. // Fields returns all fields that were changed during this mutation. Note that in
  12833. // order to get all numeric fields that were incremented/decremented, call
  12834. // AddedFields().
  12835. func (m *CreditUsageMutation) Fields() []string {
  12836. fields := make([]string, 0, 12)
  12837. if m.created_at != nil {
  12838. fields = append(fields, creditusage.FieldCreatedAt)
  12839. }
  12840. if m.updated_at != nil {
  12841. fields = append(fields, creditusage.FieldUpdatedAt)
  12842. }
  12843. if m.deleted_at != nil {
  12844. fields = append(fields, creditusage.FieldDeletedAt)
  12845. }
  12846. if m.user_id != nil {
  12847. fields = append(fields, creditusage.FieldUserID)
  12848. }
  12849. if m.number != nil {
  12850. fields = append(fields, creditusage.FieldNumber)
  12851. }
  12852. if m.status != nil {
  12853. fields = append(fields, creditusage.FieldStatus)
  12854. }
  12855. if m.ntype != nil {
  12856. fields = append(fields, creditusage.FieldNtype)
  12857. }
  12858. if m.table != nil {
  12859. fields = append(fields, creditusage.FieldTable)
  12860. }
  12861. if m.organization_id != nil {
  12862. fields = append(fields, creditusage.FieldOrganizationID)
  12863. }
  12864. if m.nid != nil {
  12865. fields = append(fields, creditusage.FieldNid)
  12866. }
  12867. if m.reason != nil {
  12868. fields = append(fields, creditusage.FieldReason)
  12869. }
  12870. if m.operator != nil {
  12871. fields = append(fields, creditusage.FieldOperator)
  12872. }
  12873. return fields
  12874. }
  12875. // Field returns the value of a field with the given name. The second boolean
  12876. // return value indicates that this field was not set, or was not defined in the
  12877. // schema.
  12878. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  12879. switch name {
  12880. case creditusage.FieldCreatedAt:
  12881. return m.CreatedAt()
  12882. case creditusage.FieldUpdatedAt:
  12883. return m.UpdatedAt()
  12884. case creditusage.FieldDeletedAt:
  12885. return m.DeletedAt()
  12886. case creditusage.FieldUserID:
  12887. return m.UserID()
  12888. case creditusage.FieldNumber:
  12889. return m.Number()
  12890. case creditusage.FieldStatus:
  12891. return m.Status()
  12892. case creditusage.FieldNtype:
  12893. return m.Ntype()
  12894. case creditusage.FieldTable:
  12895. return m.Table()
  12896. case creditusage.FieldOrganizationID:
  12897. return m.OrganizationID()
  12898. case creditusage.FieldNid:
  12899. return m.Nid()
  12900. case creditusage.FieldReason:
  12901. return m.Reason()
  12902. case creditusage.FieldOperator:
  12903. return m.Operator()
  12904. }
  12905. return nil, false
  12906. }
  12907. // OldField returns the old value of the field from the database. An error is
  12908. // returned if the mutation operation is not UpdateOne, or the query to the
  12909. // database failed.
  12910. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12911. switch name {
  12912. case creditusage.FieldCreatedAt:
  12913. return m.OldCreatedAt(ctx)
  12914. case creditusage.FieldUpdatedAt:
  12915. return m.OldUpdatedAt(ctx)
  12916. case creditusage.FieldDeletedAt:
  12917. return m.OldDeletedAt(ctx)
  12918. case creditusage.FieldUserID:
  12919. return m.OldUserID(ctx)
  12920. case creditusage.FieldNumber:
  12921. return m.OldNumber(ctx)
  12922. case creditusage.FieldStatus:
  12923. return m.OldStatus(ctx)
  12924. case creditusage.FieldNtype:
  12925. return m.OldNtype(ctx)
  12926. case creditusage.FieldTable:
  12927. return m.OldTable(ctx)
  12928. case creditusage.FieldOrganizationID:
  12929. return m.OldOrganizationID(ctx)
  12930. case creditusage.FieldNid:
  12931. return m.OldNid(ctx)
  12932. case creditusage.FieldReason:
  12933. return m.OldReason(ctx)
  12934. case creditusage.FieldOperator:
  12935. return m.OldOperator(ctx)
  12936. }
  12937. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  12938. }
  12939. // SetField sets the value of a field with the given name. It returns an error if
  12940. // the field is not defined in the schema, or if the type mismatched the field
  12941. // type.
  12942. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  12943. switch name {
  12944. case creditusage.FieldCreatedAt:
  12945. v, ok := value.(time.Time)
  12946. if !ok {
  12947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12948. }
  12949. m.SetCreatedAt(v)
  12950. return nil
  12951. case creditusage.FieldUpdatedAt:
  12952. v, ok := value.(time.Time)
  12953. if !ok {
  12954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12955. }
  12956. m.SetUpdatedAt(v)
  12957. return nil
  12958. case creditusage.FieldDeletedAt:
  12959. v, ok := value.(time.Time)
  12960. if !ok {
  12961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12962. }
  12963. m.SetDeletedAt(v)
  12964. return nil
  12965. case creditusage.FieldUserID:
  12966. v, ok := value.(string)
  12967. if !ok {
  12968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12969. }
  12970. m.SetUserID(v)
  12971. return nil
  12972. case creditusage.FieldNumber:
  12973. v, ok := value.(float32)
  12974. if !ok {
  12975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12976. }
  12977. m.SetNumber(v)
  12978. return nil
  12979. case creditusage.FieldStatus:
  12980. v, ok := value.(int)
  12981. if !ok {
  12982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12983. }
  12984. m.SetStatus(v)
  12985. return nil
  12986. case creditusage.FieldNtype:
  12987. v, ok := value.(int)
  12988. if !ok {
  12989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12990. }
  12991. m.SetNtype(v)
  12992. return nil
  12993. case creditusage.FieldTable:
  12994. v, ok := value.(string)
  12995. if !ok {
  12996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12997. }
  12998. m.SetTable(v)
  12999. return nil
  13000. case creditusage.FieldOrganizationID:
  13001. v, ok := value.(uint64)
  13002. if !ok {
  13003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13004. }
  13005. m.SetOrganizationID(v)
  13006. return nil
  13007. case creditusage.FieldNid:
  13008. v, ok := value.(uint64)
  13009. if !ok {
  13010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13011. }
  13012. m.SetNid(v)
  13013. return nil
  13014. case creditusage.FieldReason:
  13015. v, ok := value.(string)
  13016. if !ok {
  13017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13018. }
  13019. m.SetReason(v)
  13020. return nil
  13021. case creditusage.FieldOperator:
  13022. v, ok := value.(string)
  13023. if !ok {
  13024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13025. }
  13026. m.SetOperator(v)
  13027. return nil
  13028. }
  13029. return fmt.Errorf("unknown CreditUsage field %s", name)
  13030. }
  13031. // AddedFields returns all numeric fields that were incremented/decremented during
  13032. // this mutation.
  13033. func (m *CreditUsageMutation) AddedFields() []string {
  13034. var fields []string
  13035. if m.addnumber != nil {
  13036. fields = append(fields, creditusage.FieldNumber)
  13037. }
  13038. if m.addstatus != nil {
  13039. fields = append(fields, creditusage.FieldStatus)
  13040. }
  13041. if m.addntype != nil {
  13042. fields = append(fields, creditusage.FieldNtype)
  13043. }
  13044. if m.addorganization_id != nil {
  13045. fields = append(fields, creditusage.FieldOrganizationID)
  13046. }
  13047. if m.addnid != nil {
  13048. fields = append(fields, creditusage.FieldNid)
  13049. }
  13050. return fields
  13051. }
  13052. // AddedField returns the numeric value that was incremented/decremented on a field
  13053. // with the given name. The second boolean return value indicates that this field
  13054. // was not set, or was not defined in the schema.
  13055. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  13056. switch name {
  13057. case creditusage.FieldNumber:
  13058. return m.AddedNumber()
  13059. case creditusage.FieldStatus:
  13060. return m.AddedStatus()
  13061. case creditusage.FieldNtype:
  13062. return m.AddedNtype()
  13063. case creditusage.FieldOrganizationID:
  13064. return m.AddedOrganizationID()
  13065. case creditusage.FieldNid:
  13066. return m.AddedNid()
  13067. }
  13068. return nil, false
  13069. }
  13070. // AddField adds the value to the field with the given name. It returns an error if
  13071. // the field is not defined in the schema, or if the type mismatched the field
  13072. // type.
  13073. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  13074. switch name {
  13075. case creditusage.FieldNumber:
  13076. v, ok := value.(float32)
  13077. if !ok {
  13078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13079. }
  13080. m.AddNumber(v)
  13081. return nil
  13082. case creditusage.FieldStatus:
  13083. v, ok := value.(int)
  13084. if !ok {
  13085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13086. }
  13087. m.AddStatus(v)
  13088. return nil
  13089. case creditusage.FieldNtype:
  13090. v, ok := value.(int)
  13091. if !ok {
  13092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13093. }
  13094. m.AddNtype(v)
  13095. return nil
  13096. case creditusage.FieldOrganizationID:
  13097. v, ok := value.(int64)
  13098. if !ok {
  13099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13100. }
  13101. m.AddOrganizationID(v)
  13102. return nil
  13103. case creditusage.FieldNid:
  13104. v, ok := value.(int64)
  13105. if !ok {
  13106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13107. }
  13108. m.AddNid(v)
  13109. return nil
  13110. }
  13111. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  13112. }
  13113. // ClearedFields returns all nullable fields that were cleared during this
  13114. // mutation.
  13115. func (m *CreditUsageMutation) ClearedFields() []string {
  13116. var fields []string
  13117. if m.FieldCleared(creditusage.FieldDeletedAt) {
  13118. fields = append(fields, creditusage.FieldDeletedAt)
  13119. }
  13120. if m.FieldCleared(creditusage.FieldUserID) {
  13121. fields = append(fields, creditusage.FieldUserID)
  13122. }
  13123. if m.FieldCleared(creditusage.FieldStatus) {
  13124. fields = append(fields, creditusage.FieldStatus)
  13125. }
  13126. if m.FieldCleared(creditusage.FieldOrganizationID) {
  13127. fields = append(fields, creditusage.FieldOrganizationID)
  13128. }
  13129. return fields
  13130. }
  13131. // FieldCleared returns a boolean indicating if a field with the given name was
  13132. // cleared in this mutation.
  13133. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  13134. _, ok := m.clearedFields[name]
  13135. return ok
  13136. }
  13137. // ClearField clears the value of the field with the given name. It returns an
  13138. // error if the field is not defined in the schema.
  13139. func (m *CreditUsageMutation) ClearField(name string) error {
  13140. switch name {
  13141. case creditusage.FieldDeletedAt:
  13142. m.ClearDeletedAt()
  13143. return nil
  13144. case creditusage.FieldUserID:
  13145. m.ClearUserID()
  13146. return nil
  13147. case creditusage.FieldStatus:
  13148. m.ClearStatus()
  13149. return nil
  13150. case creditusage.FieldOrganizationID:
  13151. m.ClearOrganizationID()
  13152. return nil
  13153. }
  13154. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  13155. }
  13156. // ResetField resets all changes in the mutation for the field with the given name.
  13157. // It returns an error if the field is not defined in the schema.
  13158. func (m *CreditUsageMutation) ResetField(name string) error {
  13159. switch name {
  13160. case creditusage.FieldCreatedAt:
  13161. m.ResetCreatedAt()
  13162. return nil
  13163. case creditusage.FieldUpdatedAt:
  13164. m.ResetUpdatedAt()
  13165. return nil
  13166. case creditusage.FieldDeletedAt:
  13167. m.ResetDeletedAt()
  13168. return nil
  13169. case creditusage.FieldUserID:
  13170. m.ResetUserID()
  13171. return nil
  13172. case creditusage.FieldNumber:
  13173. m.ResetNumber()
  13174. return nil
  13175. case creditusage.FieldStatus:
  13176. m.ResetStatus()
  13177. return nil
  13178. case creditusage.FieldNtype:
  13179. m.ResetNtype()
  13180. return nil
  13181. case creditusage.FieldTable:
  13182. m.ResetTable()
  13183. return nil
  13184. case creditusage.FieldOrganizationID:
  13185. m.ResetOrganizationID()
  13186. return nil
  13187. case creditusage.FieldNid:
  13188. m.ResetNid()
  13189. return nil
  13190. case creditusage.FieldReason:
  13191. m.ResetReason()
  13192. return nil
  13193. case creditusage.FieldOperator:
  13194. m.ResetOperator()
  13195. return nil
  13196. }
  13197. return fmt.Errorf("unknown CreditUsage field %s", name)
  13198. }
  13199. // AddedEdges returns all edge names that were set/added in this mutation.
  13200. func (m *CreditUsageMutation) AddedEdges() []string {
  13201. edges := make([]string, 0, 0)
  13202. return edges
  13203. }
  13204. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13205. // name in this mutation.
  13206. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  13207. return nil
  13208. }
  13209. // RemovedEdges returns all edge names that were removed in this mutation.
  13210. func (m *CreditUsageMutation) RemovedEdges() []string {
  13211. edges := make([]string, 0, 0)
  13212. return edges
  13213. }
  13214. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13215. // the given name in this mutation.
  13216. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  13217. return nil
  13218. }
  13219. // ClearedEdges returns all edge names that were cleared in this mutation.
  13220. func (m *CreditUsageMutation) ClearedEdges() []string {
  13221. edges := make([]string, 0, 0)
  13222. return edges
  13223. }
  13224. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13225. // was cleared in this mutation.
  13226. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  13227. return false
  13228. }
  13229. // ClearEdge clears the value of the edge with the given name. It returns an error
  13230. // if that edge is not defined in the schema.
  13231. func (m *CreditUsageMutation) ClearEdge(name string) error {
  13232. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  13233. }
  13234. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13235. // It returns an error if the edge is not defined in the schema.
  13236. func (m *CreditUsageMutation) ResetEdge(name string) error {
  13237. return fmt.Errorf("unknown CreditUsage edge %s", name)
  13238. }
  13239. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  13240. type EmployeeMutation struct {
  13241. config
  13242. op Op
  13243. typ string
  13244. id *uint64
  13245. created_at *time.Time
  13246. updated_at *time.Time
  13247. deleted_at *time.Time
  13248. title *string
  13249. avatar *string
  13250. tags *string
  13251. hire_count *int
  13252. addhire_count *int
  13253. service_count *int
  13254. addservice_count *int
  13255. achievement_count *int
  13256. addachievement_count *int
  13257. intro *string
  13258. estimate *string
  13259. skill *string
  13260. ability_type *string
  13261. scene *string
  13262. switch_in *string
  13263. video_url *string
  13264. organization_id *uint64
  13265. addorganization_id *int64
  13266. category_id *uint64
  13267. addcategory_id *int64
  13268. api_base *string
  13269. api_key *string
  13270. ai_info *string
  13271. is_vip *int
  13272. addis_vip *int
  13273. chat_url *string
  13274. clearedFields map[string]struct{}
  13275. em_work_experiences map[uint64]struct{}
  13276. removedem_work_experiences map[uint64]struct{}
  13277. clearedem_work_experiences bool
  13278. em_tutorial map[uint64]struct{}
  13279. removedem_tutorial map[uint64]struct{}
  13280. clearedem_tutorial bool
  13281. done bool
  13282. oldValue func(context.Context) (*Employee, error)
  13283. predicates []predicate.Employee
  13284. }
  13285. var _ ent.Mutation = (*EmployeeMutation)(nil)
  13286. // employeeOption allows management of the mutation configuration using functional options.
  13287. type employeeOption func(*EmployeeMutation)
  13288. // newEmployeeMutation creates new mutation for the Employee entity.
  13289. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  13290. m := &EmployeeMutation{
  13291. config: c,
  13292. op: op,
  13293. typ: TypeEmployee,
  13294. clearedFields: make(map[string]struct{}),
  13295. }
  13296. for _, opt := range opts {
  13297. opt(m)
  13298. }
  13299. return m
  13300. }
  13301. // withEmployeeID sets the ID field of the mutation.
  13302. func withEmployeeID(id uint64) employeeOption {
  13303. return func(m *EmployeeMutation) {
  13304. var (
  13305. err error
  13306. once sync.Once
  13307. value *Employee
  13308. )
  13309. m.oldValue = func(ctx context.Context) (*Employee, error) {
  13310. once.Do(func() {
  13311. if m.done {
  13312. err = errors.New("querying old values post mutation is not allowed")
  13313. } else {
  13314. value, err = m.Client().Employee.Get(ctx, id)
  13315. }
  13316. })
  13317. return value, err
  13318. }
  13319. m.id = &id
  13320. }
  13321. }
  13322. // withEmployee sets the old Employee of the mutation.
  13323. func withEmployee(node *Employee) employeeOption {
  13324. return func(m *EmployeeMutation) {
  13325. m.oldValue = func(context.Context) (*Employee, error) {
  13326. return node, nil
  13327. }
  13328. m.id = &node.ID
  13329. }
  13330. }
  13331. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13332. // executed in a transaction (ent.Tx), a transactional client is returned.
  13333. func (m EmployeeMutation) Client() *Client {
  13334. client := &Client{config: m.config}
  13335. client.init()
  13336. return client
  13337. }
  13338. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13339. // it returns an error otherwise.
  13340. func (m EmployeeMutation) Tx() (*Tx, error) {
  13341. if _, ok := m.driver.(*txDriver); !ok {
  13342. return nil, errors.New("ent: mutation is not running in a transaction")
  13343. }
  13344. tx := &Tx{config: m.config}
  13345. tx.init()
  13346. return tx, nil
  13347. }
  13348. // SetID sets the value of the id field. Note that this
  13349. // operation is only accepted on creation of Employee entities.
  13350. func (m *EmployeeMutation) SetID(id uint64) {
  13351. m.id = &id
  13352. }
  13353. // ID returns the ID value in the mutation. Note that the ID is only available
  13354. // if it was provided to the builder or after it was returned from the database.
  13355. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  13356. if m.id == nil {
  13357. return
  13358. }
  13359. return *m.id, true
  13360. }
  13361. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13362. // That means, if the mutation is applied within a transaction with an isolation level such
  13363. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13364. // or updated by the mutation.
  13365. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  13366. switch {
  13367. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13368. id, exists := m.ID()
  13369. if exists {
  13370. return []uint64{id}, nil
  13371. }
  13372. fallthrough
  13373. case m.op.Is(OpUpdate | OpDelete):
  13374. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  13375. default:
  13376. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13377. }
  13378. }
  13379. // SetCreatedAt sets the "created_at" field.
  13380. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  13381. m.created_at = &t
  13382. }
  13383. // CreatedAt returns the value of the "created_at" field in the mutation.
  13384. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  13385. v := m.created_at
  13386. if v == nil {
  13387. return
  13388. }
  13389. return *v, true
  13390. }
  13391. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  13392. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13394. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13395. if !m.op.Is(OpUpdateOne) {
  13396. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13397. }
  13398. if m.id == nil || m.oldValue == nil {
  13399. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13400. }
  13401. oldValue, err := m.oldValue(ctx)
  13402. if err != nil {
  13403. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13404. }
  13405. return oldValue.CreatedAt, nil
  13406. }
  13407. // ResetCreatedAt resets all changes to the "created_at" field.
  13408. func (m *EmployeeMutation) ResetCreatedAt() {
  13409. m.created_at = nil
  13410. }
  13411. // SetUpdatedAt sets the "updated_at" field.
  13412. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  13413. m.updated_at = &t
  13414. }
  13415. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13416. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  13417. v := m.updated_at
  13418. if v == nil {
  13419. return
  13420. }
  13421. return *v, true
  13422. }
  13423. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  13424. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13426. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13427. if !m.op.Is(OpUpdateOne) {
  13428. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13429. }
  13430. if m.id == nil || m.oldValue == nil {
  13431. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13432. }
  13433. oldValue, err := m.oldValue(ctx)
  13434. if err != nil {
  13435. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13436. }
  13437. return oldValue.UpdatedAt, nil
  13438. }
  13439. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13440. func (m *EmployeeMutation) ResetUpdatedAt() {
  13441. m.updated_at = nil
  13442. }
  13443. // SetDeletedAt sets the "deleted_at" field.
  13444. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  13445. m.deleted_at = &t
  13446. }
  13447. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13448. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  13449. v := m.deleted_at
  13450. if v == nil {
  13451. return
  13452. }
  13453. return *v, true
  13454. }
  13455. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  13456. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13458. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13459. if !m.op.Is(OpUpdateOne) {
  13460. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13461. }
  13462. if m.id == nil || m.oldValue == nil {
  13463. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13464. }
  13465. oldValue, err := m.oldValue(ctx)
  13466. if err != nil {
  13467. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13468. }
  13469. return oldValue.DeletedAt, nil
  13470. }
  13471. // ClearDeletedAt clears the value of the "deleted_at" field.
  13472. func (m *EmployeeMutation) ClearDeletedAt() {
  13473. m.deleted_at = nil
  13474. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  13475. }
  13476. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13477. func (m *EmployeeMutation) DeletedAtCleared() bool {
  13478. _, ok := m.clearedFields[employee.FieldDeletedAt]
  13479. return ok
  13480. }
  13481. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13482. func (m *EmployeeMutation) ResetDeletedAt() {
  13483. m.deleted_at = nil
  13484. delete(m.clearedFields, employee.FieldDeletedAt)
  13485. }
  13486. // SetTitle sets the "title" field.
  13487. func (m *EmployeeMutation) SetTitle(s string) {
  13488. m.title = &s
  13489. }
  13490. // Title returns the value of the "title" field in the mutation.
  13491. func (m *EmployeeMutation) Title() (r string, exists bool) {
  13492. v := m.title
  13493. if v == nil {
  13494. return
  13495. }
  13496. return *v, true
  13497. }
  13498. // OldTitle returns the old "title" field's value of the Employee entity.
  13499. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13501. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  13502. if !m.op.Is(OpUpdateOne) {
  13503. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13504. }
  13505. if m.id == nil || m.oldValue == nil {
  13506. return v, errors.New("OldTitle requires an ID field in the mutation")
  13507. }
  13508. oldValue, err := m.oldValue(ctx)
  13509. if err != nil {
  13510. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13511. }
  13512. return oldValue.Title, nil
  13513. }
  13514. // ResetTitle resets all changes to the "title" field.
  13515. func (m *EmployeeMutation) ResetTitle() {
  13516. m.title = nil
  13517. }
  13518. // SetAvatar sets the "avatar" field.
  13519. func (m *EmployeeMutation) SetAvatar(s string) {
  13520. m.avatar = &s
  13521. }
  13522. // Avatar returns the value of the "avatar" field in the mutation.
  13523. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  13524. v := m.avatar
  13525. if v == nil {
  13526. return
  13527. }
  13528. return *v, true
  13529. }
  13530. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  13531. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13533. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  13534. if !m.op.Is(OpUpdateOne) {
  13535. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  13536. }
  13537. if m.id == nil || m.oldValue == nil {
  13538. return v, errors.New("OldAvatar requires an ID field in the mutation")
  13539. }
  13540. oldValue, err := m.oldValue(ctx)
  13541. if err != nil {
  13542. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  13543. }
  13544. return oldValue.Avatar, nil
  13545. }
  13546. // ResetAvatar resets all changes to the "avatar" field.
  13547. func (m *EmployeeMutation) ResetAvatar() {
  13548. m.avatar = nil
  13549. }
  13550. // SetTags sets the "tags" field.
  13551. func (m *EmployeeMutation) SetTags(s string) {
  13552. m.tags = &s
  13553. }
  13554. // Tags returns the value of the "tags" field in the mutation.
  13555. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  13556. v := m.tags
  13557. if v == nil {
  13558. return
  13559. }
  13560. return *v, true
  13561. }
  13562. // OldTags returns the old "tags" field's value of the Employee entity.
  13563. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13565. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  13566. if !m.op.Is(OpUpdateOne) {
  13567. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  13568. }
  13569. if m.id == nil || m.oldValue == nil {
  13570. return v, errors.New("OldTags requires an ID field in the mutation")
  13571. }
  13572. oldValue, err := m.oldValue(ctx)
  13573. if err != nil {
  13574. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  13575. }
  13576. return oldValue.Tags, nil
  13577. }
  13578. // ResetTags resets all changes to the "tags" field.
  13579. func (m *EmployeeMutation) ResetTags() {
  13580. m.tags = nil
  13581. }
  13582. // SetHireCount sets the "hire_count" field.
  13583. func (m *EmployeeMutation) SetHireCount(i int) {
  13584. m.hire_count = &i
  13585. m.addhire_count = nil
  13586. }
  13587. // HireCount returns the value of the "hire_count" field in the mutation.
  13588. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  13589. v := m.hire_count
  13590. if v == nil {
  13591. return
  13592. }
  13593. return *v, true
  13594. }
  13595. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  13596. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13598. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  13599. if !m.op.Is(OpUpdateOne) {
  13600. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  13601. }
  13602. if m.id == nil || m.oldValue == nil {
  13603. return v, errors.New("OldHireCount requires an ID field in the mutation")
  13604. }
  13605. oldValue, err := m.oldValue(ctx)
  13606. if err != nil {
  13607. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  13608. }
  13609. return oldValue.HireCount, nil
  13610. }
  13611. // AddHireCount adds i to the "hire_count" field.
  13612. func (m *EmployeeMutation) AddHireCount(i int) {
  13613. if m.addhire_count != nil {
  13614. *m.addhire_count += i
  13615. } else {
  13616. m.addhire_count = &i
  13617. }
  13618. }
  13619. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  13620. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  13621. v := m.addhire_count
  13622. if v == nil {
  13623. return
  13624. }
  13625. return *v, true
  13626. }
  13627. // ResetHireCount resets all changes to the "hire_count" field.
  13628. func (m *EmployeeMutation) ResetHireCount() {
  13629. m.hire_count = nil
  13630. m.addhire_count = nil
  13631. }
  13632. // SetServiceCount sets the "service_count" field.
  13633. func (m *EmployeeMutation) SetServiceCount(i int) {
  13634. m.service_count = &i
  13635. m.addservice_count = nil
  13636. }
  13637. // ServiceCount returns the value of the "service_count" field in the mutation.
  13638. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  13639. v := m.service_count
  13640. if v == nil {
  13641. return
  13642. }
  13643. return *v, true
  13644. }
  13645. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  13646. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13648. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  13649. if !m.op.Is(OpUpdateOne) {
  13650. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  13651. }
  13652. if m.id == nil || m.oldValue == nil {
  13653. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  13654. }
  13655. oldValue, err := m.oldValue(ctx)
  13656. if err != nil {
  13657. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  13658. }
  13659. return oldValue.ServiceCount, nil
  13660. }
  13661. // AddServiceCount adds i to the "service_count" field.
  13662. func (m *EmployeeMutation) AddServiceCount(i int) {
  13663. if m.addservice_count != nil {
  13664. *m.addservice_count += i
  13665. } else {
  13666. m.addservice_count = &i
  13667. }
  13668. }
  13669. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  13670. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  13671. v := m.addservice_count
  13672. if v == nil {
  13673. return
  13674. }
  13675. return *v, true
  13676. }
  13677. // ResetServiceCount resets all changes to the "service_count" field.
  13678. func (m *EmployeeMutation) ResetServiceCount() {
  13679. m.service_count = nil
  13680. m.addservice_count = nil
  13681. }
  13682. // SetAchievementCount sets the "achievement_count" field.
  13683. func (m *EmployeeMutation) SetAchievementCount(i int) {
  13684. m.achievement_count = &i
  13685. m.addachievement_count = nil
  13686. }
  13687. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  13688. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  13689. v := m.achievement_count
  13690. if v == nil {
  13691. return
  13692. }
  13693. return *v, true
  13694. }
  13695. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  13696. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13698. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  13699. if !m.op.Is(OpUpdateOne) {
  13700. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  13701. }
  13702. if m.id == nil || m.oldValue == nil {
  13703. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  13704. }
  13705. oldValue, err := m.oldValue(ctx)
  13706. if err != nil {
  13707. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  13708. }
  13709. return oldValue.AchievementCount, nil
  13710. }
  13711. // AddAchievementCount adds i to the "achievement_count" field.
  13712. func (m *EmployeeMutation) AddAchievementCount(i int) {
  13713. if m.addachievement_count != nil {
  13714. *m.addachievement_count += i
  13715. } else {
  13716. m.addachievement_count = &i
  13717. }
  13718. }
  13719. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  13720. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  13721. v := m.addachievement_count
  13722. if v == nil {
  13723. return
  13724. }
  13725. return *v, true
  13726. }
  13727. // ResetAchievementCount resets all changes to the "achievement_count" field.
  13728. func (m *EmployeeMutation) ResetAchievementCount() {
  13729. m.achievement_count = nil
  13730. m.addachievement_count = nil
  13731. }
  13732. // SetIntro sets the "intro" field.
  13733. func (m *EmployeeMutation) SetIntro(s string) {
  13734. m.intro = &s
  13735. }
  13736. // Intro returns the value of the "intro" field in the mutation.
  13737. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  13738. v := m.intro
  13739. if v == nil {
  13740. return
  13741. }
  13742. return *v, true
  13743. }
  13744. // OldIntro returns the old "intro" field's value of the Employee entity.
  13745. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13747. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  13748. if !m.op.Is(OpUpdateOne) {
  13749. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  13750. }
  13751. if m.id == nil || m.oldValue == nil {
  13752. return v, errors.New("OldIntro requires an ID field in the mutation")
  13753. }
  13754. oldValue, err := m.oldValue(ctx)
  13755. if err != nil {
  13756. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  13757. }
  13758. return oldValue.Intro, nil
  13759. }
  13760. // ResetIntro resets all changes to the "intro" field.
  13761. func (m *EmployeeMutation) ResetIntro() {
  13762. m.intro = nil
  13763. }
  13764. // SetEstimate sets the "estimate" field.
  13765. func (m *EmployeeMutation) SetEstimate(s string) {
  13766. m.estimate = &s
  13767. }
  13768. // Estimate returns the value of the "estimate" field in the mutation.
  13769. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  13770. v := m.estimate
  13771. if v == nil {
  13772. return
  13773. }
  13774. return *v, true
  13775. }
  13776. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  13777. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13779. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  13780. if !m.op.Is(OpUpdateOne) {
  13781. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  13782. }
  13783. if m.id == nil || m.oldValue == nil {
  13784. return v, errors.New("OldEstimate requires an ID field in the mutation")
  13785. }
  13786. oldValue, err := m.oldValue(ctx)
  13787. if err != nil {
  13788. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  13789. }
  13790. return oldValue.Estimate, nil
  13791. }
  13792. // ResetEstimate resets all changes to the "estimate" field.
  13793. func (m *EmployeeMutation) ResetEstimate() {
  13794. m.estimate = nil
  13795. }
  13796. // SetSkill sets the "skill" field.
  13797. func (m *EmployeeMutation) SetSkill(s string) {
  13798. m.skill = &s
  13799. }
  13800. // Skill returns the value of the "skill" field in the mutation.
  13801. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  13802. v := m.skill
  13803. if v == nil {
  13804. return
  13805. }
  13806. return *v, true
  13807. }
  13808. // OldSkill returns the old "skill" field's value of the Employee entity.
  13809. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13811. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  13812. if !m.op.Is(OpUpdateOne) {
  13813. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  13814. }
  13815. if m.id == nil || m.oldValue == nil {
  13816. return v, errors.New("OldSkill requires an ID field in the mutation")
  13817. }
  13818. oldValue, err := m.oldValue(ctx)
  13819. if err != nil {
  13820. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  13821. }
  13822. return oldValue.Skill, nil
  13823. }
  13824. // ResetSkill resets all changes to the "skill" field.
  13825. func (m *EmployeeMutation) ResetSkill() {
  13826. m.skill = nil
  13827. }
  13828. // SetAbilityType sets the "ability_type" field.
  13829. func (m *EmployeeMutation) SetAbilityType(s string) {
  13830. m.ability_type = &s
  13831. }
  13832. // AbilityType returns the value of the "ability_type" field in the mutation.
  13833. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  13834. v := m.ability_type
  13835. if v == nil {
  13836. return
  13837. }
  13838. return *v, true
  13839. }
  13840. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  13841. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13843. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  13844. if !m.op.Is(OpUpdateOne) {
  13845. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  13846. }
  13847. if m.id == nil || m.oldValue == nil {
  13848. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  13849. }
  13850. oldValue, err := m.oldValue(ctx)
  13851. if err != nil {
  13852. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  13853. }
  13854. return oldValue.AbilityType, nil
  13855. }
  13856. // ResetAbilityType resets all changes to the "ability_type" field.
  13857. func (m *EmployeeMutation) ResetAbilityType() {
  13858. m.ability_type = nil
  13859. }
  13860. // SetScene sets the "scene" field.
  13861. func (m *EmployeeMutation) SetScene(s string) {
  13862. m.scene = &s
  13863. }
  13864. // Scene returns the value of the "scene" field in the mutation.
  13865. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  13866. v := m.scene
  13867. if v == nil {
  13868. return
  13869. }
  13870. return *v, true
  13871. }
  13872. // OldScene returns the old "scene" field's value of the Employee entity.
  13873. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13875. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  13876. if !m.op.Is(OpUpdateOne) {
  13877. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  13878. }
  13879. if m.id == nil || m.oldValue == nil {
  13880. return v, errors.New("OldScene requires an ID field in the mutation")
  13881. }
  13882. oldValue, err := m.oldValue(ctx)
  13883. if err != nil {
  13884. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  13885. }
  13886. return oldValue.Scene, nil
  13887. }
  13888. // ResetScene resets all changes to the "scene" field.
  13889. func (m *EmployeeMutation) ResetScene() {
  13890. m.scene = nil
  13891. }
  13892. // SetSwitchIn sets the "switch_in" field.
  13893. func (m *EmployeeMutation) SetSwitchIn(s string) {
  13894. m.switch_in = &s
  13895. }
  13896. // SwitchIn returns the value of the "switch_in" field in the mutation.
  13897. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  13898. v := m.switch_in
  13899. if v == nil {
  13900. return
  13901. }
  13902. return *v, true
  13903. }
  13904. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  13905. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13907. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  13908. if !m.op.Is(OpUpdateOne) {
  13909. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  13910. }
  13911. if m.id == nil || m.oldValue == nil {
  13912. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  13913. }
  13914. oldValue, err := m.oldValue(ctx)
  13915. if err != nil {
  13916. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  13917. }
  13918. return oldValue.SwitchIn, nil
  13919. }
  13920. // ResetSwitchIn resets all changes to the "switch_in" field.
  13921. func (m *EmployeeMutation) ResetSwitchIn() {
  13922. m.switch_in = nil
  13923. }
  13924. // SetVideoURL sets the "video_url" field.
  13925. func (m *EmployeeMutation) SetVideoURL(s string) {
  13926. m.video_url = &s
  13927. }
  13928. // VideoURL returns the value of the "video_url" field in the mutation.
  13929. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  13930. v := m.video_url
  13931. if v == nil {
  13932. return
  13933. }
  13934. return *v, true
  13935. }
  13936. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  13937. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13939. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  13940. if !m.op.Is(OpUpdateOne) {
  13941. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  13942. }
  13943. if m.id == nil || m.oldValue == nil {
  13944. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  13945. }
  13946. oldValue, err := m.oldValue(ctx)
  13947. if err != nil {
  13948. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  13949. }
  13950. return oldValue.VideoURL, nil
  13951. }
  13952. // ResetVideoURL resets all changes to the "video_url" field.
  13953. func (m *EmployeeMutation) ResetVideoURL() {
  13954. m.video_url = nil
  13955. }
  13956. // SetOrganizationID sets the "organization_id" field.
  13957. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  13958. m.organization_id = &u
  13959. m.addorganization_id = nil
  13960. }
  13961. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13962. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  13963. v := m.organization_id
  13964. if v == nil {
  13965. return
  13966. }
  13967. return *v, true
  13968. }
  13969. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  13970. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13972. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13973. if !m.op.Is(OpUpdateOne) {
  13974. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13975. }
  13976. if m.id == nil || m.oldValue == nil {
  13977. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13978. }
  13979. oldValue, err := m.oldValue(ctx)
  13980. if err != nil {
  13981. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13982. }
  13983. return oldValue.OrganizationID, nil
  13984. }
  13985. // AddOrganizationID adds u to the "organization_id" field.
  13986. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  13987. if m.addorganization_id != nil {
  13988. *m.addorganization_id += u
  13989. } else {
  13990. m.addorganization_id = &u
  13991. }
  13992. }
  13993. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13994. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  13995. v := m.addorganization_id
  13996. if v == nil {
  13997. return
  13998. }
  13999. return *v, true
  14000. }
  14001. // ResetOrganizationID resets all changes to the "organization_id" field.
  14002. func (m *EmployeeMutation) ResetOrganizationID() {
  14003. m.organization_id = nil
  14004. m.addorganization_id = nil
  14005. }
  14006. // SetCategoryID sets the "category_id" field.
  14007. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  14008. m.category_id = &u
  14009. m.addcategory_id = nil
  14010. }
  14011. // CategoryID returns the value of the "category_id" field in the mutation.
  14012. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  14013. v := m.category_id
  14014. if v == nil {
  14015. return
  14016. }
  14017. return *v, true
  14018. }
  14019. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  14020. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14022. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  14023. if !m.op.Is(OpUpdateOne) {
  14024. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  14025. }
  14026. if m.id == nil || m.oldValue == nil {
  14027. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  14028. }
  14029. oldValue, err := m.oldValue(ctx)
  14030. if err != nil {
  14031. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  14032. }
  14033. return oldValue.CategoryID, nil
  14034. }
  14035. // AddCategoryID adds u to the "category_id" field.
  14036. func (m *EmployeeMutation) AddCategoryID(u int64) {
  14037. if m.addcategory_id != nil {
  14038. *m.addcategory_id += u
  14039. } else {
  14040. m.addcategory_id = &u
  14041. }
  14042. }
  14043. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  14044. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  14045. v := m.addcategory_id
  14046. if v == nil {
  14047. return
  14048. }
  14049. return *v, true
  14050. }
  14051. // ResetCategoryID resets all changes to the "category_id" field.
  14052. func (m *EmployeeMutation) ResetCategoryID() {
  14053. m.category_id = nil
  14054. m.addcategory_id = nil
  14055. }
  14056. // SetAPIBase sets the "api_base" field.
  14057. func (m *EmployeeMutation) SetAPIBase(s string) {
  14058. m.api_base = &s
  14059. }
  14060. // APIBase returns the value of the "api_base" field in the mutation.
  14061. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  14062. v := m.api_base
  14063. if v == nil {
  14064. return
  14065. }
  14066. return *v, true
  14067. }
  14068. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  14069. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14071. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  14072. if !m.op.Is(OpUpdateOne) {
  14073. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  14074. }
  14075. if m.id == nil || m.oldValue == nil {
  14076. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  14077. }
  14078. oldValue, err := m.oldValue(ctx)
  14079. if err != nil {
  14080. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  14081. }
  14082. return oldValue.APIBase, nil
  14083. }
  14084. // ResetAPIBase resets all changes to the "api_base" field.
  14085. func (m *EmployeeMutation) ResetAPIBase() {
  14086. m.api_base = nil
  14087. }
  14088. // SetAPIKey sets the "api_key" field.
  14089. func (m *EmployeeMutation) SetAPIKey(s string) {
  14090. m.api_key = &s
  14091. }
  14092. // APIKey returns the value of the "api_key" field in the mutation.
  14093. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  14094. v := m.api_key
  14095. if v == nil {
  14096. return
  14097. }
  14098. return *v, true
  14099. }
  14100. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  14101. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14103. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  14104. if !m.op.Is(OpUpdateOne) {
  14105. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  14106. }
  14107. if m.id == nil || m.oldValue == nil {
  14108. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  14109. }
  14110. oldValue, err := m.oldValue(ctx)
  14111. if err != nil {
  14112. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  14113. }
  14114. return oldValue.APIKey, nil
  14115. }
  14116. // ResetAPIKey resets all changes to the "api_key" field.
  14117. func (m *EmployeeMutation) ResetAPIKey() {
  14118. m.api_key = nil
  14119. }
  14120. // SetAiInfo sets the "ai_info" field.
  14121. func (m *EmployeeMutation) SetAiInfo(s string) {
  14122. m.ai_info = &s
  14123. }
  14124. // AiInfo returns the value of the "ai_info" field in the mutation.
  14125. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  14126. v := m.ai_info
  14127. if v == nil {
  14128. return
  14129. }
  14130. return *v, true
  14131. }
  14132. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  14133. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14135. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  14136. if !m.op.Is(OpUpdateOne) {
  14137. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  14138. }
  14139. if m.id == nil || m.oldValue == nil {
  14140. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  14141. }
  14142. oldValue, err := m.oldValue(ctx)
  14143. if err != nil {
  14144. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  14145. }
  14146. return oldValue.AiInfo, nil
  14147. }
  14148. // ClearAiInfo clears the value of the "ai_info" field.
  14149. func (m *EmployeeMutation) ClearAiInfo() {
  14150. m.ai_info = nil
  14151. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  14152. }
  14153. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  14154. func (m *EmployeeMutation) AiInfoCleared() bool {
  14155. _, ok := m.clearedFields[employee.FieldAiInfo]
  14156. return ok
  14157. }
  14158. // ResetAiInfo resets all changes to the "ai_info" field.
  14159. func (m *EmployeeMutation) ResetAiInfo() {
  14160. m.ai_info = nil
  14161. delete(m.clearedFields, employee.FieldAiInfo)
  14162. }
  14163. // SetIsVip sets the "is_vip" field.
  14164. func (m *EmployeeMutation) SetIsVip(i int) {
  14165. m.is_vip = &i
  14166. m.addis_vip = nil
  14167. }
  14168. // IsVip returns the value of the "is_vip" field in the mutation.
  14169. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  14170. v := m.is_vip
  14171. if v == nil {
  14172. return
  14173. }
  14174. return *v, true
  14175. }
  14176. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  14177. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14179. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  14180. if !m.op.Is(OpUpdateOne) {
  14181. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  14182. }
  14183. if m.id == nil || m.oldValue == nil {
  14184. return v, errors.New("OldIsVip requires an ID field in the mutation")
  14185. }
  14186. oldValue, err := m.oldValue(ctx)
  14187. if err != nil {
  14188. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  14189. }
  14190. return oldValue.IsVip, nil
  14191. }
  14192. // AddIsVip adds i to the "is_vip" field.
  14193. func (m *EmployeeMutation) AddIsVip(i int) {
  14194. if m.addis_vip != nil {
  14195. *m.addis_vip += i
  14196. } else {
  14197. m.addis_vip = &i
  14198. }
  14199. }
  14200. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  14201. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  14202. v := m.addis_vip
  14203. if v == nil {
  14204. return
  14205. }
  14206. return *v, true
  14207. }
  14208. // ResetIsVip resets all changes to the "is_vip" field.
  14209. func (m *EmployeeMutation) ResetIsVip() {
  14210. m.is_vip = nil
  14211. m.addis_vip = nil
  14212. }
  14213. // SetChatURL sets the "chat_url" field.
  14214. func (m *EmployeeMutation) SetChatURL(s string) {
  14215. m.chat_url = &s
  14216. }
  14217. // ChatURL returns the value of the "chat_url" field in the mutation.
  14218. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  14219. v := m.chat_url
  14220. if v == nil {
  14221. return
  14222. }
  14223. return *v, true
  14224. }
  14225. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  14226. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14228. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  14229. if !m.op.Is(OpUpdateOne) {
  14230. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  14231. }
  14232. if m.id == nil || m.oldValue == nil {
  14233. return v, errors.New("OldChatURL requires an ID field in the mutation")
  14234. }
  14235. oldValue, err := m.oldValue(ctx)
  14236. if err != nil {
  14237. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  14238. }
  14239. return oldValue.ChatURL, nil
  14240. }
  14241. // ResetChatURL resets all changes to the "chat_url" field.
  14242. func (m *EmployeeMutation) ResetChatURL() {
  14243. m.chat_url = nil
  14244. }
  14245. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  14246. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  14247. if m.em_work_experiences == nil {
  14248. m.em_work_experiences = make(map[uint64]struct{})
  14249. }
  14250. for i := range ids {
  14251. m.em_work_experiences[ids[i]] = struct{}{}
  14252. }
  14253. }
  14254. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  14255. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  14256. m.clearedem_work_experiences = true
  14257. }
  14258. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  14259. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  14260. return m.clearedem_work_experiences
  14261. }
  14262. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  14263. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  14264. if m.removedem_work_experiences == nil {
  14265. m.removedem_work_experiences = make(map[uint64]struct{})
  14266. }
  14267. for i := range ids {
  14268. delete(m.em_work_experiences, ids[i])
  14269. m.removedem_work_experiences[ids[i]] = struct{}{}
  14270. }
  14271. }
  14272. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  14273. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  14274. for id := range m.removedem_work_experiences {
  14275. ids = append(ids, id)
  14276. }
  14277. return
  14278. }
  14279. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  14280. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  14281. for id := range m.em_work_experiences {
  14282. ids = append(ids, id)
  14283. }
  14284. return
  14285. }
  14286. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  14287. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  14288. m.em_work_experiences = nil
  14289. m.clearedem_work_experiences = false
  14290. m.removedem_work_experiences = nil
  14291. }
  14292. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  14293. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  14294. if m.em_tutorial == nil {
  14295. m.em_tutorial = make(map[uint64]struct{})
  14296. }
  14297. for i := range ids {
  14298. m.em_tutorial[ids[i]] = struct{}{}
  14299. }
  14300. }
  14301. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  14302. func (m *EmployeeMutation) ClearEmTutorial() {
  14303. m.clearedem_tutorial = true
  14304. }
  14305. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  14306. func (m *EmployeeMutation) EmTutorialCleared() bool {
  14307. return m.clearedem_tutorial
  14308. }
  14309. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  14310. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  14311. if m.removedem_tutorial == nil {
  14312. m.removedem_tutorial = make(map[uint64]struct{})
  14313. }
  14314. for i := range ids {
  14315. delete(m.em_tutorial, ids[i])
  14316. m.removedem_tutorial[ids[i]] = struct{}{}
  14317. }
  14318. }
  14319. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  14320. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  14321. for id := range m.removedem_tutorial {
  14322. ids = append(ids, id)
  14323. }
  14324. return
  14325. }
  14326. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  14327. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  14328. for id := range m.em_tutorial {
  14329. ids = append(ids, id)
  14330. }
  14331. return
  14332. }
  14333. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  14334. func (m *EmployeeMutation) ResetEmTutorial() {
  14335. m.em_tutorial = nil
  14336. m.clearedem_tutorial = false
  14337. m.removedem_tutorial = nil
  14338. }
  14339. // Where appends a list predicates to the EmployeeMutation builder.
  14340. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  14341. m.predicates = append(m.predicates, ps...)
  14342. }
  14343. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  14344. // users can use type-assertion to append predicates that do not depend on any generated package.
  14345. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  14346. p := make([]predicate.Employee, len(ps))
  14347. for i := range ps {
  14348. p[i] = ps[i]
  14349. }
  14350. m.Where(p...)
  14351. }
  14352. // Op returns the operation name.
  14353. func (m *EmployeeMutation) Op() Op {
  14354. return m.op
  14355. }
  14356. // SetOp allows setting the mutation operation.
  14357. func (m *EmployeeMutation) SetOp(op Op) {
  14358. m.op = op
  14359. }
  14360. // Type returns the node type of this mutation (Employee).
  14361. func (m *EmployeeMutation) Type() string {
  14362. return m.typ
  14363. }
  14364. // Fields returns all fields that were changed during this mutation. Note that in
  14365. // order to get all numeric fields that were incremented/decremented, call
  14366. // AddedFields().
  14367. func (m *EmployeeMutation) Fields() []string {
  14368. fields := make([]string, 0, 23)
  14369. if m.created_at != nil {
  14370. fields = append(fields, employee.FieldCreatedAt)
  14371. }
  14372. if m.updated_at != nil {
  14373. fields = append(fields, employee.FieldUpdatedAt)
  14374. }
  14375. if m.deleted_at != nil {
  14376. fields = append(fields, employee.FieldDeletedAt)
  14377. }
  14378. if m.title != nil {
  14379. fields = append(fields, employee.FieldTitle)
  14380. }
  14381. if m.avatar != nil {
  14382. fields = append(fields, employee.FieldAvatar)
  14383. }
  14384. if m.tags != nil {
  14385. fields = append(fields, employee.FieldTags)
  14386. }
  14387. if m.hire_count != nil {
  14388. fields = append(fields, employee.FieldHireCount)
  14389. }
  14390. if m.service_count != nil {
  14391. fields = append(fields, employee.FieldServiceCount)
  14392. }
  14393. if m.achievement_count != nil {
  14394. fields = append(fields, employee.FieldAchievementCount)
  14395. }
  14396. if m.intro != nil {
  14397. fields = append(fields, employee.FieldIntro)
  14398. }
  14399. if m.estimate != nil {
  14400. fields = append(fields, employee.FieldEstimate)
  14401. }
  14402. if m.skill != nil {
  14403. fields = append(fields, employee.FieldSkill)
  14404. }
  14405. if m.ability_type != nil {
  14406. fields = append(fields, employee.FieldAbilityType)
  14407. }
  14408. if m.scene != nil {
  14409. fields = append(fields, employee.FieldScene)
  14410. }
  14411. if m.switch_in != nil {
  14412. fields = append(fields, employee.FieldSwitchIn)
  14413. }
  14414. if m.video_url != nil {
  14415. fields = append(fields, employee.FieldVideoURL)
  14416. }
  14417. if m.organization_id != nil {
  14418. fields = append(fields, employee.FieldOrganizationID)
  14419. }
  14420. if m.category_id != nil {
  14421. fields = append(fields, employee.FieldCategoryID)
  14422. }
  14423. if m.api_base != nil {
  14424. fields = append(fields, employee.FieldAPIBase)
  14425. }
  14426. if m.api_key != nil {
  14427. fields = append(fields, employee.FieldAPIKey)
  14428. }
  14429. if m.ai_info != nil {
  14430. fields = append(fields, employee.FieldAiInfo)
  14431. }
  14432. if m.is_vip != nil {
  14433. fields = append(fields, employee.FieldIsVip)
  14434. }
  14435. if m.chat_url != nil {
  14436. fields = append(fields, employee.FieldChatURL)
  14437. }
  14438. return fields
  14439. }
  14440. // Field returns the value of a field with the given name. The second boolean
  14441. // return value indicates that this field was not set, or was not defined in the
  14442. // schema.
  14443. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  14444. switch name {
  14445. case employee.FieldCreatedAt:
  14446. return m.CreatedAt()
  14447. case employee.FieldUpdatedAt:
  14448. return m.UpdatedAt()
  14449. case employee.FieldDeletedAt:
  14450. return m.DeletedAt()
  14451. case employee.FieldTitle:
  14452. return m.Title()
  14453. case employee.FieldAvatar:
  14454. return m.Avatar()
  14455. case employee.FieldTags:
  14456. return m.Tags()
  14457. case employee.FieldHireCount:
  14458. return m.HireCount()
  14459. case employee.FieldServiceCount:
  14460. return m.ServiceCount()
  14461. case employee.FieldAchievementCount:
  14462. return m.AchievementCount()
  14463. case employee.FieldIntro:
  14464. return m.Intro()
  14465. case employee.FieldEstimate:
  14466. return m.Estimate()
  14467. case employee.FieldSkill:
  14468. return m.Skill()
  14469. case employee.FieldAbilityType:
  14470. return m.AbilityType()
  14471. case employee.FieldScene:
  14472. return m.Scene()
  14473. case employee.FieldSwitchIn:
  14474. return m.SwitchIn()
  14475. case employee.FieldVideoURL:
  14476. return m.VideoURL()
  14477. case employee.FieldOrganizationID:
  14478. return m.OrganizationID()
  14479. case employee.FieldCategoryID:
  14480. return m.CategoryID()
  14481. case employee.FieldAPIBase:
  14482. return m.APIBase()
  14483. case employee.FieldAPIKey:
  14484. return m.APIKey()
  14485. case employee.FieldAiInfo:
  14486. return m.AiInfo()
  14487. case employee.FieldIsVip:
  14488. return m.IsVip()
  14489. case employee.FieldChatURL:
  14490. return m.ChatURL()
  14491. }
  14492. return nil, false
  14493. }
  14494. // OldField returns the old value of the field from the database. An error is
  14495. // returned if the mutation operation is not UpdateOne, or the query to the
  14496. // database failed.
  14497. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14498. switch name {
  14499. case employee.FieldCreatedAt:
  14500. return m.OldCreatedAt(ctx)
  14501. case employee.FieldUpdatedAt:
  14502. return m.OldUpdatedAt(ctx)
  14503. case employee.FieldDeletedAt:
  14504. return m.OldDeletedAt(ctx)
  14505. case employee.FieldTitle:
  14506. return m.OldTitle(ctx)
  14507. case employee.FieldAvatar:
  14508. return m.OldAvatar(ctx)
  14509. case employee.FieldTags:
  14510. return m.OldTags(ctx)
  14511. case employee.FieldHireCount:
  14512. return m.OldHireCount(ctx)
  14513. case employee.FieldServiceCount:
  14514. return m.OldServiceCount(ctx)
  14515. case employee.FieldAchievementCount:
  14516. return m.OldAchievementCount(ctx)
  14517. case employee.FieldIntro:
  14518. return m.OldIntro(ctx)
  14519. case employee.FieldEstimate:
  14520. return m.OldEstimate(ctx)
  14521. case employee.FieldSkill:
  14522. return m.OldSkill(ctx)
  14523. case employee.FieldAbilityType:
  14524. return m.OldAbilityType(ctx)
  14525. case employee.FieldScene:
  14526. return m.OldScene(ctx)
  14527. case employee.FieldSwitchIn:
  14528. return m.OldSwitchIn(ctx)
  14529. case employee.FieldVideoURL:
  14530. return m.OldVideoURL(ctx)
  14531. case employee.FieldOrganizationID:
  14532. return m.OldOrganizationID(ctx)
  14533. case employee.FieldCategoryID:
  14534. return m.OldCategoryID(ctx)
  14535. case employee.FieldAPIBase:
  14536. return m.OldAPIBase(ctx)
  14537. case employee.FieldAPIKey:
  14538. return m.OldAPIKey(ctx)
  14539. case employee.FieldAiInfo:
  14540. return m.OldAiInfo(ctx)
  14541. case employee.FieldIsVip:
  14542. return m.OldIsVip(ctx)
  14543. case employee.FieldChatURL:
  14544. return m.OldChatURL(ctx)
  14545. }
  14546. return nil, fmt.Errorf("unknown Employee field %s", name)
  14547. }
  14548. // SetField sets the value of a field with the given name. It returns an error if
  14549. // the field is not defined in the schema, or if the type mismatched the field
  14550. // type.
  14551. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  14552. switch name {
  14553. case employee.FieldCreatedAt:
  14554. v, ok := value.(time.Time)
  14555. if !ok {
  14556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14557. }
  14558. m.SetCreatedAt(v)
  14559. return nil
  14560. case employee.FieldUpdatedAt:
  14561. v, ok := value.(time.Time)
  14562. if !ok {
  14563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14564. }
  14565. m.SetUpdatedAt(v)
  14566. return nil
  14567. case employee.FieldDeletedAt:
  14568. v, ok := value.(time.Time)
  14569. if !ok {
  14570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14571. }
  14572. m.SetDeletedAt(v)
  14573. return nil
  14574. case employee.FieldTitle:
  14575. v, ok := value.(string)
  14576. if !ok {
  14577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14578. }
  14579. m.SetTitle(v)
  14580. return nil
  14581. case employee.FieldAvatar:
  14582. v, ok := value.(string)
  14583. if !ok {
  14584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14585. }
  14586. m.SetAvatar(v)
  14587. return nil
  14588. case employee.FieldTags:
  14589. v, ok := value.(string)
  14590. if !ok {
  14591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14592. }
  14593. m.SetTags(v)
  14594. return nil
  14595. case employee.FieldHireCount:
  14596. v, ok := value.(int)
  14597. if !ok {
  14598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14599. }
  14600. m.SetHireCount(v)
  14601. return nil
  14602. case employee.FieldServiceCount:
  14603. v, ok := value.(int)
  14604. if !ok {
  14605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14606. }
  14607. m.SetServiceCount(v)
  14608. return nil
  14609. case employee.FieldAchievementCount:
  14610. v, ok := value.(int)
  14611. if !ok {
  14612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14613. }
  14614. m.SetAchievementCount(v)
  14615. return nil
  14616. case employee.FieldIntro:
  14617. v, ok := value.(string)
  14618. if !ok {
  14619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14620. }
  14621. m.SetIntro(v)
  14622. return nil
  14623. case employee.FieldEstimate:
  14624. v, ok := value.(string)
  14625. if !ok {
  14626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14627. }
  14628. m.SetEstimate(v)
  14629. return nil
  14630. case employee.FieldSkill:
  14631. v, ok := value.(string)
  14632. if !ok {
  14633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14634. }
  14635. m.SetSkill(v)
  14636. return nil
  14637. case employee.FieldAbilityType:
  14638. v, ok := value.(string)
  14639. if !ok {
  14640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14641. }
  14642. m.SetAbilityType(v)
  14643. return nil
  14644. case employee.FieldScene:
  14645. v, ok := value.(string)
  14646. if !ok {
  14647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14648. }
  14649. m.SetScene(v)
  14650. return nil
  14651. case employee.FieldSwitchIn:
  14652. v, ok := value.(string)
  14653. if !ok {
  14654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14655. }
  14656. m.SetSwitchIn(v)
  14657. return nil
  14658. case employee.FieldVideoURL:
  14659. v, ok := value.(string)
  14660. if !ok {
  14661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14662. }
  14663. m.SetVideoURL(v)
  14664. return nil
  14665. case employee.FieldOrganizationID:
  14666. v, ok := value.(uint64)
  14667. if !ok {
  14668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14669. }
  14670. m.SetOrganizationID(v)
  14671. return nil
  14672. case employee.FieldCategoryID:
  14673. v, ok := value.(uint64)
  14674. if !ok {
  14675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14676. }
  14677. m.SetCategoryID(v)
  14678. return nil
  14679. case employee.FieldAPIBase:
  14680. v, ok := value.(string)
  14681. if !ok {
  14682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14683. }
  14684. m.SetAPIBase(v)
  14685. return nil
  14686. case employee.FieldAPIKey:
  14687. v, ok := value.(string)
  14688. if !ok {
  14689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14690. }
  14691. m.SetAPIKey(v)
  14692. return nil
  14693. case employee.FieldAiInfo:
  14694. v, ok := value.(string)
  14695. if !ok {
  14696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14697. }
  14698. m.SetAiInfo(v)
  14699. return nil
  14700. case employee.FieldIsVip:
  14701. v, ok := value.(int)
  14702. if !ok {
  14703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14704. }
  14705. m.SetIsVip(v)
  14706. return nil
  14707. case employee.FieldChatURL:
  14708. v, ok := value.(string)
  14709. if !ok {
  14710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14711. }
  14712. m.SetChatURL(v)
  14713. return nil
  14714. }
  14715. return fmt.Errorf("unknown Employee field %s", name)
  14716. }
  14717. // AddedFields returns all numeric fields that were incremented/decremented during
  14718. // this mutation.
  14719. func (m *EmployeeMutation) AddedFields() []string {
  14720. var fields []string
  14721. if m.addhire_count != nil {
  14722. fields = append(fields, employee.FieldHireCount)
  14723. }
  14724. if m.addservice_count != nil {
  14725. fields = append(fields, employee.FieldServiceCount)
  14726. }
  14727. if m.addachievement_count != nil {
  14728. fields = append(fields, employee.FieldAchievementCount)
  14729. }
  14730. if m.addorganization_id != nil {
  14731. fields = append(fields, employee.FieldOrganizationID)
  14732. }
  14733. if m.addcategory_id != nil {
  14734. fields = append(fields, employee.FieldCategoryID)
  14735. }
  14736. if m.addis_vip != nil {
  14737. fields = append(fields, employee.FieldIsVip)
  14738. }
  14739. return fields
  14740. }
  14741. // AddedField returns the numeric value that was incremented/decremented on a field
  14742. // with the given name. The second boolean return value indicates that this field
  14743. // was not set, or was not defined in the schema.
  14744. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  14745. switch name {
  14746. case employee.FieldHireCount:
  14747. return m.AddedHireCount()
  14748. case employee.FieldServiceCount:
  14749. return m.AddedServiceCount()
  14750. case employee.FieldAchievementCount:
  14751. return m.AddedAchievementCount()
  14752. case employee.FieldOrganizationID:
  14753. return m.AddedOrganizationID()
  14754. case employee.FieldCategoryID:
  14755. return m.AddedCategoryID()
  14756. case employee.FieldIsVip:
  14757. return m.AddedIsVip()
  14758. }
  14759. return nil, false
  14760. }
  14761. // AddField adds the value to the field with the given name. It returns an error if
  14762. // the field is not defined in the schema, or if the type mismatched the field
  14763. // type.
  14764. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  14765. switch name {
  14766. case employee.FieldHireCount:
  14767. v, ok := value.(int)
  14768. if !ok {
  14769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14770. }
  14771. m.AddHireCount(v)
  14772. return nil
  14773. case employee.FieldServiceCount:
  14774. v, ok := value.(int)
  14775. if !ok {
  14776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14777. }
  14778. m.AddServiceCount(v)
  14779. return nil
  14780. case employee.FieldAchievementCount:
  14781. v, ok := value.(int)
  14782. if !ok {
  14783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14784. }
  14785. m.AddAchievementCount(v)
  14786. return nil
  14787. case employee.FieldOrganizationID:
  14788. v, ok := value.(int64)
  14789. if !ok {
  14790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14791. }
  14792. m.AddOrganizationID(v)
  14793. return nil
  14794. case employee.FieldCategoryID:
  14795. v, ok := value.(int64)
  14796. if !ok {
  14797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14798. }
  14799. m.AddCategoryID(v)
  14800. return nil
  14801. case employee.FieldIsVip:
  14802. v, ok := value.(int)
  14803. if !ok {
  14804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14805. }
  14806. m.AddIsVip(v)
  14807. return nil
  14808. }
  14809. return fmt.Errorf("unknown Employee numeric field %s", name)
  14810. }
  14811. // ClearedFields returns all nullable fields that were cleared during this
  14812. // mutation.
  14813. func (m *EmployeeMutation) ClearedFields() []string {
  14814. var fields []string
  14815. if m.FieldCleared(employee.FieldDeletedAt) {
  14816. fields = append(fields, employee.FieldDeletedAt)
  14817. }
  14818. if m.FieldCleared(employee.FieldAiInfo) {
  14819. fields = append(fields, employee.FieldAiInfo)
  14820. }
  14821. return fields
  14822. }
  14823. // FieldCleared returns a boolean indicating if a field with the given name was
  14824. // cleared in this mutation.
  14825. func (m *EmployeeMutation) FieldCleared(name string) bool {
  14826. _, ok := m.clearedFields[name]
  14827. return ok
  14828. }
  14829. // ClearField clears the value of the field with the given name. It returns an
  14830. // error if the field is not defined in the schema.
  14831. func (m *EmployeeMutation) ClearField(name string) error {
  14832. switch name {
  14833. case employee.FieldDeletedAt:
  14834. m.ClearDeletedAt()
  14835. return nil
  14836. case employee.FieldAiInfo:
  14837. m.ClearAiInfo()
  14838. return nil
  14839. }
  14840. return fmt.Errorf("unknown Employee nullable field %s", name)
  14841. }
  14842. // ResetField resets all changes in the mutation for the field with the given name.
  14843. // It returns an error if the field is not defined in the schema.
  14844. func (m *EmployeeMutation) ResetField(name string) error {
  14845. switch name {
  14846. case employee.FieldCreatedAt:
  14847. m.ResetCreatedAt()
  14848. return nil
  14849. case employee.FieldUpdatedAt:
  14850. m.ResetUpdatedAt()
  14851. return nil
  14852. case employee.FieldDeletedAt:
  14853. m.ResetDeletedAt()
  14854. return nil
  14855. case employee.FieldTitle:
  14856. m.ResetTitle()
  14857. return nil
  14858. case employee.FieldAvatar:
  14859. m.ResetAvatar()
  14860. return nil
  14861. case employee.FieldTags:
  14862. m.ResetTags()
  14863. return nil
  14864. case employee.FieldHireCount:
  14865. m.ResetHireCount()
  14866. return nil
  14867. case employee.FieldServiceCount:
  14868. m.ResetServiceCount()
  14869. return nil
  14870. case employee.FieldAchievementCount:
  14871. m.ResetAchievementCount()
  14872. return nil
  14873. case employee.FieldIntro:
  14874. m.ResetIntro()
  14875. return nil
  14876. case employee.FieldEstimate:
  14877. m.ResetEstimate()
  14878. return nil
  14879. case employee.FieldSkill:
  14880. m.ResetSkill()
  14881. return nil
  14882. case employee.FieldAbilityType:
  14883. m.ResetAbilityType()
  14884. return nil
  14885. case employee.FieldScene:
  14886. m.ResetScene()
  14887. return nil
  14888. case employee.FieldSwitchIn:
  14889. m.ResetSwitchIn()
  14890. return nil
  14891. case employee.FieldVideoURL:
  14892. m.ResetVideoURL()
  14893. return nil
  14894. case employee.FieldOrganizationID:
  14895. m.ResetOrganizationID()
  14896. return nil
  14897. case employee.FieldCategoryID:
  14898. m.ResetCategoryID()
  14899. return nil
  14900. case employee.FieldAPIBase:
  14901. m.ResetAPIBase()
  14902. return nil
  14903. case employee.FieldAPIKey:
  14904. m.ResetAPIKey()
  14905. return nil
  14906. case employee.FieldAiInfo:
  14907. m.ResetAiInfo()
  14908. return nil
  14909. case employee.FieldIsVip:
  14910. m.ResetIsVip()
  14911. return nil
  14912. case employee.FieldChatURL:
  14913. m.ResetChatURL()
  14914. return nil
  14915. }
  14916. return fmt.Errorf("unknown Employee field %s", name)
  14917. }
  14918. // AddedEdges returns all edge names that were set/added in this mutation.
  14919. func (m *EmployeeMutation) AddedEdges() []string {
  14920. edges := make([]string, 0, 2)
  14921. if m.em_work_experiences != nil {
  14922. edges = append(edges, employee.EdgeEmWorkExperiences)
  14923. }
  14924. if m.em_tutorial != nil {
  14925. edges = append(edges, employee.EdgeEmTutorial)
  14926. }
  14927. return edges
  14928. }
  14929. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14930. // name in this mutation.
  14931. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  14932. switch name {
  14933. case employee.EdgeEmWorkExperiences:
  14934. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  14935. for id := range m.em_work_experiences {
  14936. ids = append(ids, id)
  14937. }
  14938. return ids
  14939. case employee.EdgeEmTutorial:
  14940. ids := make([]ent.Value, 0, len(m.em_tutorial))
  14941. for id := range m.em_tutorial {
  14942. ids = append(ids, id)
  14943. }
  14944. return ids
  14945. }
  14946. return nil
  14947. }
  14948. // RemovedEdges returns all edge names that were removed in this mutation.
  14949. func (m *EmployeeMutation) RemovedEdges() []string {
  14950. edges := make([]string, 0, 2)
  14951. if m.removedem_work_experiences != nil {
  14952. edges = append(edges, employee.EdgeEmWorkExperiences)
  14953. }
  14954. if m.removedem_tutorial != nil {
  14955. edges = append(edges, employee.EdgeEmTutorial)
  14956. }
  14957. return edges
  14958. }
  14959. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14960. // the given name in this mutation.
  14961. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  14962. switch name {
  14963. case employee.EdgeEmWorkExperiences:
  14964. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  14965. for id := range m.removedem_work_experiences {
  14966. ids = append(ids, id)
  14967. }
  14968. return ids
  14969. case employee.EdgeEmTutorial:
  14970. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  14971. for id := range m.removedem_tutorial {
  14972. ids = append(ids, id)
  14973. }
  14974. return ids
  14975. }
  14976. return nil
  14977. }
  14978. // ClearedEdges returns all edge names that were cleared in this mutation.
  14979. func (m *EmployeeMutation) ClearedEdges() []string {
  14980. edges := make([]string, 0, 2)
  14981. if m.clearedem_work_experiences {
  14982. edges = append(edges, employee.EdgeEmWorkExperiences)
  14983. }
  14984. if m.clearedem_tutorial {
  14985. edges = append(edges, employee.EdgeEmTutorial)
  14986. }
  14987. return edges
  14988. }
  14989. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14990. // was cleared in this mutation.
  14991. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  14992. switch name {
  14993. case employee.EdgeEmWorkExperiences:
  14994. return m.clearedem_work_experiences
  14995. case employee.EdgeEmTutorial:
  14996. return m.clearedem_tutorial
  14997. }
  14998. return false
  14999. }
  15000. // ClearEdge clears the value of the edge with the given name. It returns an error
  15001. // if that edge is not defined in the schema.
  15002. func (m *EmployeeMutation) ClearEdge(name string) error {
  15003. switch name {
  15004. }
  15005. return fmt.Errorf("unknown Employee unique edge %s", name)
  15006. }
  15007. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15008. // It returns an error if the edge is not defined in the schema.
  15009. func (m *EmployeeMutation) ResetEdge(name string) error {
  15010. switch name {
  15011. case employee.EdgeEmWorkExperiences:
  15012. m.ResetEmWorkExperiences()
  15013. return nil
  15014. case employee.EdgeEmTutorial:
  15015. m.ResetEmTutorial()
  15016. return nil
  15017. }
  15018. return fmt.Errorf("unknown Employee edge %s", name)
  15019. }
  15020. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  15021. type EmployeeConfigMutation struct {
  15022. config
  15023. op Op
  15024. typ string
  15025. id *uint64
  15026. created_at *time.Time
  15027. updated_at *time.Time
  15028. deleted_at *time.Time
  15029. stype *string
  15030. title *string
  15031. photo *string
  15032. organization_id *uint64
  15033. addorganization_id *int64
  15034. clearedFields map[string]struct{}
  15035. done bool
  15036. oldValue func(context.Context) (*EmployeeConfig, error)
  15037. predicates []predicate.EmployeeConfig
  15038. }
  15039. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  15040. // employeeconfigOption allows management of the mutation configuration using functional options.
  15041. type employeeconfigOption func(*EmployeeConfigMutation)
  15042. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  15043. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  15044. m := &EmployeeConfigMutation{
  15045. config: c,
  15046. op: op,
  15047. typ: TypeEmployeeConfig,
  15048. clearedFields: make(map[string]struct{}),
  15049. }
  15050. for _, opt := range opts {
  15051. opt(m)
  15052. }
  15053. return m
  15054. }
  15055. // withEmployeeConfigID sets the ID field of the mutation.
  15056. func withEmployeeConfigID(id uint64) employeeconfigOption {
  15057. return func(m *EmployeeConfigMutation) {
  15058. var (
  15059. err error
  15060. once sync.Once
  15061. value *EmployeeConfig
  15062. )
  15063. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  15064. once.Do(func() {
  15065. if m.done {
  15066. err = errors.New("querying old values post mutation is not allowed")
  15067. } else {
  15068. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  15069. }
  15070. })
  15071. return value, err
  15072. }
  15073. m.id = &id
  15074. }
  15075. }
  15076. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  15077. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  15078. return func(m *EmployeeConfigMutation) {
  15079. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  15080. return node, nil
  15081. }
  15082. m.id = &node.ID
  15083. }
  15084. }
  15085. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15086. // executed in a transaction (ent.Tx), a transactional client is returned.
  15087. func (m EmployeeConfigMutation) Client() *Client {
  15088. client := &Client{config: m.config}
  15089. client.init()
  15090. return client
  15091. }
  15092. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15093. // it returns an error otherwise.
  15094. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  15095. if _, ok := m.driver.(*txDriver); !ok {
  15096. return nil, errors.New("ent: mutation is not running in a transaction")
  15097. }
  15098. tx := &Tx{config: m.config}
  15099. tx.init()
  15100. return tx, nil
  15101. }
  15102. // SetID sets the value of the id field. Note that this
  15103. // operation is only accepted on creation of EmployeeConfig entities.
  15104. func (m *EmployeeConfigMutation) SetID(id uint64) {
  15105. m.id = &id
  15106. }
  15107. // ID returns the ID value in the mutation. Note that the ID is only available
  15108. // if it was provided to the builder or after it was returned from the database.
  15109. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  15110. if m.id == nil {
  15111. return
  15112. }
  15113. return *m.id, true
  15114. }
  15115. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15116. // That means, if the mutation is applied within a transaction with an isolation level such
  15117. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15118. // or updated by the mutation.
  15119. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  15120. switch {
  15121. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15122. id, exists := m.ID()
  15123. if exists {
  15124. return []uint64{id}, nil
  15125. }
  15126. fallthrough
  15127. case m.op.Is(OpUpdate | OpDelete):
  15128. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  15129. default:
  15130. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15131. }
  15132. }
  15133. // SetCreatedAt sets the "created_at" field.
  15134. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  15135. m.created_at = &t
  15136. }
  15137. // CreatedAt returns the value of the "created_at" field in the mutation.
  15138. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  15139. v := m.created_at
  15140. if v == nil {
  15141. return
  15142. }
  15143. return *v, true
  15144. }
  15145. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  15146. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15148. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15149. if !m.op.Is(OpUpdateOne) {
  15150. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15151. }
  15152. if m.id == nil || m.oldValue == nil {
  15153. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15154. }
  15155. oldValue, err := m.oldValue(ctx)
  15156. if err != nil {
  15157. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15158. }
  15159. return oldValue.CreatedAt, nil
  15160. }
  15161. // ResetCreatedAt resets all changes to the "created_at" field.
  15162. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  15163. m.created_at = nil
  15164. }
  15165. // SetUpdatedAt sets the "updated_at" field.
  15166. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  15167. m.updated_at = &t
  15168. }
  15169. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15170. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  15171. v := m.updated_at
  15172. if v == nil {
  15173. return
  15174. }
  15175. return *v, true
  15176. }
  15177. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  15178. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15180. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15181. if !m.op.Is(OpUpdateOne) {
  15182. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15183. }
  15184. if m.id == nil || m.oldValue == nil {
  15185. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15186. }
  15187. oldValue, err := m.oldValue(ctx)
  15188. if err != nil {
  15189. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15190. }
  15191. return oldValue.UpdatedAt, nil
  15192. }
  15193. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15194. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  15195. m.updated_at = nil
  15196. }
  15197. // SetDeletedAt sets the "deleted_at" field.
  15198. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  15199. m.deleted_at = &t
  15200. }
  15201. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15202. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  15203. v := m.deleted_at
  15204. if v == nil {
  15205. return
  15206. }
  15207. return *v, true
  15208. }
  15209. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  15210. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15212. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15213. if !m.op.Is(OpUpdateOne) {
  15214. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15215. }
  15216. if m.id == nil || m.oldValue == nil {
  15217. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15218. }
  15219. oldValue, err := m.oldValue(ctx)
  15220. if err != nil {
  15221. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15222. }
  15223. return oldValue.DeletedAt, nil
  15224. }
  15225. // ClearDeletedAt clears the value of the "deleted_at" field.
  15226. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  15227. m.deleted_at = nil
  15228. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  15229. }
  15230. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15231. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  15232. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  15233. return ok
  15234. }
  15235. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15236. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  15237. m.deleted_at = nil
  15238. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  15239. }
  15240. // SetStype sets the "stype" field.
  15241. func (m *EmployeeConfigMutation) SetStype(s string) {
  15242. m.stype = &s
  15243. }
  15244. // Stype returns the value of the "stype" field in the mutation.
  15245. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  15246. v := m.stype
  15247. if v == nil {
  15248. return
  15249. }
  15250. return *v, true
  15251. }
  15252. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  15253. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15255. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  15256. if !m.op.Is(OpUpdateOne) {
  15257. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  15258. }
  15259. if m.id == nil || m.oldValue == nil {
  15260. return v, errors.New("OldStype requires an ID field in the mutation")
  15261. }
  15262. oldValue, err := m.oldValue(ctx)
  15263. if err != nil {
  15264. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  15265. }
  15266. return oldValue.Stype, nil
  15267. }
  15268. // ResetStype resets all changes to the "stype" field.
  15269. func (m *EmployeeConfigMutation) ResetStype() {
  15270. m.stype = nil
  15271. }
  15272. // SetTitle sets the "title" field.
  15273. func (m *EmployeeConfigMutation) SetTitle(s string) {
  15274. m.title = &s
  15275. }
  15276. // Title returns the value of the "title" field in the mutation.
  15277. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  15278. v := m.title
  15279. if v == nil {
  15280. return
  15281. }
  15282. return *v, true
  15283. }
  15284. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  15285. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15287. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  15288. if !m.op.Is(OpUpdateOne) {
  15289. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15290. }
  15291. if m.id == nil || m.oldValue == nil {
  15292. return v, errors.New("OldTitle requires an ID field in the mutation")
  15293. }
  15294. oldValue, err := m.oldValue(ctx)
  15295. if err != nil {
  15296. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15297. }
  15298. return oldValue.Title, nil
  15299. }
  15300. // ResetTitle resets all changes to the "title" field.
  15301. func (m *EmployeeConfigMutation) ResetTitle() {
  15302. m.title = nil
  15303. }
  15304. // SetPhoto sets the "photo" field.
  15305. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  15306. m.photo = &s
  15307. }
  15308. // Photo returns the value of the "photo" field in the mutation.
  15309. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  15310. v := m.photo
  15311. if v == nil {
  15312. return
  15313. }
  15314. return *v, true
  15315. }
  15316. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  15317. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15319. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  15320. if !m.op.Is(OpUpdateOne) {
  15321. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  15322. }
  15323. if m.id == nil || m.oldValue == nil {
  15324. return v, errors.New("OldPhoto requires an ID field in the mutation")
  15325. }
  15326. oldValue, err := m.oldValue(ctx)
  15327. if err != nil {
  15328. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  15329. }
  15330. return oldValue.Photo, nil
  15331. }
  15332. // ResetPhoto resets all changes to the "photo" field.
  15333. func (m *EmployeeConfigMutation) ResetPhoto() {
  15334. m.photo = nil
  15335. }
  15336. // SetOrganizationID sets the "organization_id" field.
  15337. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  15338. m.organization_id = &u
  15339. m.addorganization_id = nil
  15340. }
  15341. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15342. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  15343. v := m.organization_id
  15344. if v == nil {
  15345. return
  15346. }
  15347. return *v, true
  15348. }
  15349. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  15350. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15352. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15353. if !m.op.Is(OpUpdateOne) {
  15354. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15355. }
  15356. if m.id == nil || m.oldValue == nil {
  15357. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15358. }
  15359. oldValue, err := m.oldValue(ctx)
  15360. if err != nil {
  15361. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15362. }
  15363. return oldValue.OrganizationID, nil
  15364. }
  15365. // AddOrganizationID adds u to the "organization_id" field.
  15366. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  15367. if m.addorganization_id != nil {
  15368. *m.addorganization_id += u
  15369. } else {
  15370. m.addorganization_id = &u
  15371. }
  15372. }
  15373. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15374. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  15375. v := m.addorganization_id
  15376. if v == nil {
  15377. return
  15378. }
  15379. return *v, true
  15380. }
  15381. // ClearOrganizationID clears the value of the "organization_id" field.
  15382. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  15383. m.organization_id = nil
  15384. m.addorganization_id = nil
  15385. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  15386. }
  15387. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15388. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  15389. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  15390. return ok
  15391. }
  15392. // ResetOrganizationID resets all changes to the "organization_id" field.
  15393. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  15394. m.organization_id = nil
  15395. m.addorganization_id = nil
  15396. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  15397. }
  15398. // Where appends a list predicates to the EmployeeConfigMutation builder.
  15399. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  15400. m.predicates = append(m.predicates, ps...)
  15401. }
  15402. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  15403. // users can use type-assertion to append predicates that do not depend on any generated package.
  15404. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  15405. p := make([]predicate.EmployeeConfig, len(ps))
  15406. for i := range ps {
  15407. p[i] = ps[i]
  15408. }
  15409. m.Where(p...)
  15410. }
  15411. // Op returns the operation name.
  15412. func (m *EmployeeConfigMutation) Op() Op {
  15413. return m.op
  15414. }
  15415. // SetOp allows setting the mutation operation.
  15416. func (m *EmployeeConfigMutation) SetOp(op Op) {
  15417. m.op = op
  15418. }
  15419. // Type returns the node type of this mutation (EmployeeConfig).
  15420. func (m *EmployeeConfigMutation) Type() string {
  15421. return m.typ
  15422. }
  15423. // Fields returns all fields that were changed during this mutation. Note that in
  15424. // order to get all numeric fields that were incremented/decremented, call
  15425. // AddedFields().
  15426. func (m *EmployeeConfigMutation) Fields() []string {
  15427. fields := make([]string, 0, 7)
  15428. if m.created_at != nil {
  15429. fields = append(fields, employeeconfig.FieldCreatedAt)
  15430. }
  15431. if m.updated_at != nil {
  15432. fields = append(fields, employeeconfig.FieldUpdatedAt)
  15433. }
  15434. if m.deleted_at != nil {
  15435. fields = append(fields, employeeconfig.FieldDeletedAt)
  15436. }
  15437. if m.stype != nil {
  15438. fields = append(fields, employeeconfig.FieldStype)
  15439. }
  15440. if m.title != nil {
  15441. fields = append(fields, employeeconfig.FieldTitle)
  15442. }
  15443. if m.photo != nil {
  15444. fields = append(fields, employeeconfig.FieldPhoto)
  15445. }
  15446. if m.organization_id != nil {
  15447. fields = append(fields, employeeconfig.FieldOrganizationID)
  15448. }
  15449. return fields
  15450. }
  15451. // Field returns the value of a field with the given name. The second boolean
  15452. // return value indicates that this field was not set, or was not defined in the
  15453. // schema.
  15454. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  15455. switch name {
  15456. case employeeconfig.FieldCreatedAt:
  15457. return m.CreatedAt()
  15458. case employeeconfig.FieldUpdatedAt:
  15459. return m.UpdatedAt()
  15460. case employeeconfig.FieldDeletedAt:
  15461. return m.DeletedAt()
  15462. case employeeconfig.FieldStype:
  15463. return m.Stype()
  15464. case employeeconfig.FieldTitle:
  15465. return m.Title()
  15466. case employeeconfig.FieldPhoto:
  15467. return m.Photo()
  15468. case employeeconfig.FieldOrganizationID:
  15469. return m.OrganizationID()
  15470. }
  15471. return nil, false
  15472. }
  15473. // OldField returns the old value of the field from the database. An error is
  15474. // returned if the mutation operation is not UpdateOne, or the query to the
  15475. // database failed.
  15476. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15477. switch name {
  15478. case employeeconfig.FieldCreatedAt:
  15479. return m.OldCreatedAt(ctx)
  15480. case employeeconfig.FieldUpdatedAt:
  15481. return m.OldUpdatedAt(ctx)
  15482. case employeeconfig.FieldDeletedAt:
  15483. return m.OldDeletedAt(ctx)
  15484. case employeeconfig.FieldStype:
  15485. return m.OldStype(ctx)
  15486. case employeeconfig.FieldTitle:
  15487. return m.OldTitle(ctx)
  15488. case employeeconfig.FieldPhoto:
  15489. return m.OldPhoto(ctx)
  15490. case employeeconfig.FieldOrganizationID:
  15491. return m.OldOrganizationID(ctx)
  15492. }
  15493. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  15494. }
  15495. // SetField sets the value of a field with the given name. It returns an error if
  15496. // the field is not defined in the schema, or if the type mismatched the field
  15497. // type.
  15498. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  15499. switch name {
  15500. case employeeconfig.FieldCreatedAt:
  15501. v, ok := value.(time.Time)
  15502. if !ok {
  15503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15504. }
  15505. m.SetCreatedAt(v)
  15506. return nil
  15507. case employeeconfig.FieldUpdatedAt:
  15508. v, ok := value.(time.Time)
  15509. if !ok {
  15510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15511. }
  15512. m.SetUpdatedAt(v)
  15513. return nil
  15514. case employeeconfig.FieldDeletedAt:
  15515. v, ok := value.(time.Time)
  15516. if !ok {
  15517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15518. }
  15519. m.SetDeletedAt(v)
  15520. return nil
  15521. case employeeconfig.FieldStype:
  15522. v, ok := value.(string)
  15523. if !ok {
  15524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15525. }
  15526. m.SetStype(v)
  15527. return nil
  15528. case employeeconfig.FieldTitle:
  15529. v, ok := value.(string)
  15530. if !ok {
  15531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15532. }
  15533. m.SetTitle(v)
  15534. return nil
  15535. case employeeconfig.FieldPhoto:
  15536. v, ok := value.(string)
  15537. if !ok {
  15538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15539. }
  15540. m.SetPhoto(v)
  15541. return nil
  15542. case employeeconfig.FieldOrganizationID:
  15543. v, ok := value.(uint64)
  15544. if !ok {
  15545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15546. }
  15547. m.SetOrganizationID(v)
  15548. return nil
  15549. }
  15550. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15551. }
  15552. // AddedFields returns all numeric fields that were incremented/decremented during
  15553. // this mutation.
  15554. func (m *EmployeeConfigMutation) AddedFields() []string {
  15555. var fields []string
  15556. if m.addorganization_id != nil {
  15557. fields = append(fields, employeeconfig.FieldOrganizationID)
  15558. }
  15559. return fields
  15560. }
  15561. // AddedField returns the numeric value that was incremented/decremented on a field
  15562. // with the given name. The second boolean return value indicates that this field
  15563. // was not set, or was not defined in the schema.
  15564. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  15565. switch name {
  15566. case employeeconfig.FieldOrganizationID:
  15567. return m.AddedOrganizationID()
  15568. }
  15569. return nil, false
  15570. }
  15571. // AddField adds the value to the field with the given name. It returns an error if
  15572. // the field is not defined in the schema, or if the type mismatched the field
  15573. // type.
  15574. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  15575. switch name {
  15576. case employeeconfig.FieldOrganizationID:
  15577. v, ok := value.(int64)
  15578. if !ok {
  15579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15580. }
  15581. m.AddOrganizationID(v)
  15582. return nil
  15583. }
  15584. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  15585. }
  15586. // ClearedFields returns all nullable fields that were cleared during this
  15587. // mutation.
  15588. func (m *EmployeeConfigMutation) ClearedFields() []string {
  15589. var fields []string
  15590. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  15591. fields = append(fields, employeeconfig.FieldDeletedAt)
  15592. }
  15593. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  15594. fields = append(fields, employeeconfig.FieldOrganizationID)
  15595. }
  15596. return fields
  15597. }
  15598. // FieldCleared returns a boolean indicating if a field with the given name was
  15599. // cleared in this mutation.
  15600. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  15601. _, ok := m.clearedFields[name]
  15602. return ok
  15603. }
  15604. // ClearField clears the value of the field with the given name. It returns an
  15605. // error if the field is not defined in the schema.
  15606. func (m *EmployeeConfigMutation) ClearField(name string) error {
  15607. switch name {
  15608. case employeeconfig.FieldDeletedAt:
  15609. m.ClearDeletedAt()
  15610. return nil
  15611. case employeeconfig.FieldOrganizationID:
  15612. m.ClearOrganizationID()
  15613. return nil
  15614. }
  15615. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  15616. }
  15617. // ResetField resets all changes in the mutation for the field with the given name.
  15618. // It returns an error if the field is not defined in the schema.
  15619. func (m *EmployeeConfigMutation) ResetField(name string) error {
  15620. switch name {
  15621. case employeeconfig.FieldCreatedAt:
  15622. m.ResetCreatedAt()
  15623. return nil
  15624. case employeeconfig.FieldUpdatedAt:
  15625. m.ResetUpdatedAt()
  15626. return nil
  15627. case employeeconfig.FieldDeletedAt:
  15628. m.ResetDeletedAt()
  15629. return nil
  15630. case employeeconfig.FieldStype:
  15631. m.ResetStype()
  15632. return nil
  15633. case employeeconfig.FieldTitle:
  15634. m.ResetTitle()
  15635. return nil
  15636. case employeeconfig.FieldPhoto:
  15637. m.ResetPhoto()
  15638. return nil
  15639. case employeeconfig.FieldOrganizationID:
  15640. m.ResetOrganizationID()
  15641. return nil
  15642. }
  15643. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15644. }
  15645. // AddedEdges returns all edge names that were set/added in this mutation.
  15646. func (m *EmployeeConfigMutation) AddedEdges() []string {
  15647. edges := make([]string, 0, 0)
  15648. return edges
  15649. }
  15650. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15651. // name in this mutation.
  15652. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  15653. return nil
  15654. }
  15655. // RemovedEdges returns all edge names that were removed in this mutation.
  15656. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  15657. edges := make([]string, 0, 0)
  15658. return edges
  15659. }
  15660. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15661. // the given name in this mutation.
  15662. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  15663. return nil
  15664. }
  15665. // ClearedEdges returns all edge names that were cleared in this mutation.
  15666. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  15667. edges := make([]string, 0, 0)
  15668. return edges
  15669. }
  15670. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15671. // was cleared in this mutation.
  15672. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  15673. return false
  15674. }
  15675. // ClearEdge clears the value of the edge with the given name. It returns an error
  15676. // if that edge is not defined in the schema.
  15677. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  15678. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  15679. }
  15680. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15681. // It returns an error if the edge is not defined in the schema.
  15682. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  15683. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  15684. }
  15685. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  15686. type LabelMutation struct {
  15687. config
  15688. op Op
  15689. typ string
  15690. id *uint64
  15691. created_at *time.Time
  15692. updated_at *time.Time
  15693. status *uint8
  15694. addstatus *int8
  15695. _type *int
  15696. add_type *int
  15697. name *string
  15698. from *int
  15699. addfrom *int
  15700. mode *int
  15701. addmode *int
  15702. conditions *string
  15703. organization_id *uint64
  15704. addorganization_id *int64
  15705. clearedFields map[string]struct{}
  15706. label_relationships map[uint64]struct{}
  15707. removedlabel_relationships map[uint64]struct{}
  15708. clearedlabel_relationships bool
  15709. done bool
  15710. oldValue func(context.Context) (*Label, error)
  15711. predicates []predicate.Label
  15712. }
  15713. var _ ent.Mutation = (*LabelMutation)(nil)
  15714. // labelOption allows management of the mutation configuration using functional options.
  15715. type labelOption func(*LabelMutation)
  15716. // newLabelMutation creates new mutation for the Label entity.
  15717. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  15718. m := &LabelMutation{
  15719. config: c,
  15720. op: op,
  15721. typ: TypeLabel,
  15722. clearedFields: make(map[string]struct{}),
  15723. }
  15724. for _, opt := range opts {
  15725. opt(m)
  15726. }
  15727. return m
  15728. }
  15729. // withLabelID sets the ID field of the mutation.
  15730. func withLabelID(id uint64) labelOption {
  15731. return func(m *LabelMutation) {
  15732. var (
  15733. err error
  15734. once sync.Once
  15735. value *Label
  15736. )
  15737. m.oldValue = func(ctx context.Context) (*Label, error) {
  15738. once.Do(func() {
  15739. if m.done {
  15740. err = errors.New("querying old values post mutation is not allowed")
  15741. } else {
  15742. value, err = m.Client().Label.Get(ctx, id)
  15743. }
  15744. })
  15745. return value, err
  15746. }
  15747. m.id = &id
  15748. }
  15749. }
  15750. // withLabel sets the old Label of the mutation.
  15751. func withLabel(node *Label) labelOption {
  15752. return func(m *LabelMutation) {
  15753. m.oldValue = func(context.Context) (*Label, error) {
  15754. return node, nil
  15755. }
  15756. m.id = &node.ID
  15757. }
  15758. }
  15759. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15760. // executed in a transaction (ent.Tx), a transactional client is returned.
  15761. func (m LabelMutation) Client() *Client {
  15762. client := &Client{config: m.config}
  15763. client.init()
  15764. return client
  15765. }
  15766. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15767. // it returns an error otherwise.
  15768. func (m LabelMutation) Tx() (*Tx, error) {
  15769. if _, ok := m.driver.(*txDriver); !ok {
  15770. return nil, errors.New("ent: mutation is not running in a transaction")
  15771. }
  15772. tx := &Tx{config: m.config}
  15773. tx.init()
  15774. return tx, nil
  15775. }
  15776. // SetID sets the value of the id field. Note that this
  15777. // operation is only accepted on creation of Label entities.
  15778. func (m *LabelMutation) SetID(id uint64) {
  15779. m.id = &id
  15780. }
  15781. // ID returns the ID value in the mutation. Note that the ID is only available
  15782. // if it was provided to the builder or after it was returned from the database.
  15783. func (m *LabelMutation) ID() (id uint64, exists bool) {
  15784. if m.id == nil {
  15785. return
  15786. }
  15787. return *m.id, true
  15788. }
  15789. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15790. // That means, if the mutation is applied within a transaction with an isolation level such
  15791. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15792. // or updated by the mutation.
  15793. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  15794. switch {
  15795. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15796. id, exists := m.ID()
  15797. if exists {
  15798. return []uint64{id}, nil
  15799. }
  15800. fallthrough
  15801. case m.op.Is(OpUpdate | OpDelete):
  15802. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  15803. default:
  15804. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15805. }
  15806. }
  15807. // SetCreatedAt sets the "created_at" field.
  15808. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  15809. m.created_at = &t
  15810. }
  15811. // CreatedAt returns the value of the "created_at" field in the mutation.
  15812. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  15813. v := m.created_at
  15814. if v == nil {
  15815. return
  15816. }
  15817. return *v, true
  15818. }
  15819. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  15820. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15822. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15823. if !m.op.Is(OpUpdateOne) {
  15824. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15825. }
  15826. if m.id == nil || m.oldValue == nil {
  15827. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15828. }
  15829. oldValue, err := m.oldValue(ctx)
  15830. if err != nil {
  15831. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15832. }
  15833. return oldValue.CreatedAt, nil
  15834. }
  15835. // ResetCreatedAt resets all changes to the "created_at" field.
  15836. func (m *LabelMutation) ResetCreatedAt() {
  15837. m.created_at = nil
  15838. }
  15839. // SetUpdatedAt sets the "updated_at" field.
  15840. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  15841. m.updated_at = &t
  15842. }
  15843. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15844. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  15845. v := m.updated_at
  15846. if v == nil {
  15847. return
  15848. }
  15849. return *v, true
  15850. }
  15851. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  15852. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15854. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15855. if !m.op.Is(OpUpdateOne) {
  15856. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15857. }
  15858. if m.id == nil || m.oldValue == nil {
  15859. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15860. }
  15861. oldValue, err := m.oldValue(ctx)
  15862. if err != nil {
  15863. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15864. }
  15865. return oldValue.UpdatedAt, nil
  15866. }
  15867. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15868. func (m *LabelMutation) ResetUpdatedAt() {
  15869. m.updated_at = nil
  15870. }
  15871. // SetStatus sets the "status" field.
  15872. func (m *LabelMutation) SetStatus(u uint8) {
  15873. m.status = &u
  15874. m.addstatus = nil
  15875. }
  15876. // Status returns the value of the "status" field in the mutation.
  15877. func (m *LabelMutation) Status() (r uint8, exists bool) {
  15878. v := m.status
  15879. if v == nil {
  15880. return
  15881. }
  15882. return *v, true
  15883. }
  15884. // OldStatus returns the old "status" field's value of the Label entity.
  15885. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15887. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15888. if !m.op.Is(OpUpdateOne) {
  15889. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15890. }
  15891. if m.id == nil || m.oldValue == nil {
  15892. return v, errors.New("OldStatus requires an ID field in the mutation")
  15893. }
  15894. oldValue, err := m.oldValue(ctx)
  15895. if err != nil {
  15896. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15897. }
  15898. return oldValue.Status, nil
  15899. }
  15900. // AddStatus adds u to the "status" field.
  15901. func (m *LabelMutation) AddStatus(u int8) {
  15902. if m.addstatus != nil {
  15903. *m.addstatus += u
  15904. } else {
  15905. m.addstatus = &u
  15906. }
  15907. }
  15908. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15909. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  15910. v := m.addstatus
  15911. if v == nil {
  15912. return
  15913. }
  15914. return *v, true
  15915. }
  15916. // ClearStatus clears the value of the "status" field.
  15917. func (m *LabelMutation) ClearStatus() {
  15918. m.status = nil
  15919. m.addstatus = nil
  15920. m.clearedFields[label.FieldStatus] = struct{}{}
  15921. }
  15922. // StatusCleared returns if the "status" field was cleared in this mutation.
  15923. func (m *LabelMutation) StatusCleared() bool {
  15924. _, ok := m.clearedFields[label.FieldStatus]
  15925. return ok
  15926. }
  15927. // ResetStatus resets all changes to the "status" field.
  15928. func (m *LabelMutation) ResetStatus() {
  15929. m.status = nil
  15930. m.addstatus = nil
  15931. delete(m.clearedFields, label.FieldStatus)
  15932. }
  15933. // SetType sets the "type" field.
  15934. func (m *LabelMutation) SetType(i int) {
  15935. m._type = &i
  15936. m.add_type = nil
  15937. }
  15938. // GetType returns the value of the "type" field in the mutation.
  15939. func (m *LabelMutation) GetType() (r int, exists bool) {
  15940. v := m._type
  15941. if v == nil {
  15942. return
  15943. }
  15944. return *v, true
  15945. }
  15946. // OldType returns the old "type" field's value of the Label entity.
  15947. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15949. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  15950. if !m.op.Is(OpUpdateOne) {
  15951. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15952. }
  15953. if m.id == nil || m.oldValue == nil {
  15954. return v, errors.New("OldType requires an ID field in the mutation")
  15955. }
  15956. oldValue, err := m.oldValue(ctx)
  15957. if err != nil {
  15958. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15959. }
  15960. return oldValue.Type, nil
  15961. }
  15962. // AddType adds i to the "type" field.
  15963. func (m *LabelMutation) AddType(i int) {
  15964. if m.add_type != nil {
  15965. *m.add_type += i
  15966. } else {
  15967. m.add_type = &i
  15968. }
  15969. }
  15970. // AddedType returns the value that was added to the "type" field in this mutation.
  15971. func (m *LabelMutation) AddedType() (r int, exists bool) {
  15972. v := m.add_type
  15973. if v == nil {
  15974. return
  15975. }
  15976. return *v, true
  15977. }
  15978. // ResetType resets all changes to the "type" field.
  15979. func (m *LabelMutation) ResetType() {
  15980. m._type = nil
  15981. m.add_type = nil
  15982. }
  15983. // SetName sets the "name" field.
  15984. func (m *LabelMutation) SetName(s string) {
  15985. m.name = &s
  15986. }
  15987. // Name returns the value of the "name" field in the mutation.
  15988. func (m *LabelMutation) Name() (r string, exists bool) {
  15989. v := m.name
  15990. if v == nil {
  15991. return
  15992. }
  15993. return *v, true
  15994. }
  15995. // OldName returns the old "name" field's value of the Label entity.
  15996. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15998. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  15999. if !m.op.Is(OpUpdateOne) {
  16000. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16001. }
  16002. if m.id == nil || m.oldValue == nil {
  16003. return v, errors.New("OldName requires an ID field in the mutation")
  16004. }
  16005. oldValue, err := m.oldValue(ctx)
  16006. if err != nil {
  16007. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16008. }
  16009. return oldValue.Name, nil
  16010. }
  16011. // ResetName resets all changes to the "name" field.
  16012. func (m *LabelMutation) ResetName() {
  16013. m.name = nil
  16014. }
  16015. // SetFrom sets the "from" field.
  16016. func (m *LabelMutation) SetFrom(i int) {
  16017. m.from = &i
  16018. m.addfrom = nil
  16019. }
  16020. // From returns the value of the "from" field in the mutation.
  16021. func (m *LabelMutation) From() (r int, exists bool) {
  16022. v := m.from
  16023. if v == nil {
  16024. return
  16025. }
  16026. return *v, true
  16027. }
  16028. // OldFrom returns the old "from" field's value of the Label entity.
  16029. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16031. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  16032. if !m.op.Is(OpUpdateOne) {
  16033. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  16034. }
  16035. if m.id == nil || m.oldValue == nil {
  16036. return v, errors.New("OldFrom requires an ID field in the mutation")
  16037. }
  16038. oldValue, err := m.oldValue(ctx)
  16039. if err != nil {
  16040. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  16041. }
  16042. return oldValue.From, nil
  16043. }
  16044. // AddFrom adds i to the "from" field.
  16045. func (m *LabelMutation) AddFrom(i int) {
  16046. if m.addfrom != nil {
  16047. *m.addfrom += i
  16048. } else {
  16049. m.addfrom = &i
  16050. }
  16051. }
  16052. // AddedFrom returns the value that was added to the "from" field in this mutation.
  16053. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  16054. v := m.addfrom
  16055. if v == nil {
  16056. return
  16057. }
  16058. return *v, true
  16059. }
  16060. // ResetFrom resets all changes to the "from" field.
  16061. func (m *LabelMutation) ResetFrom() {
  16062. m.from = nil
  16063. m.addfrom = nil
  16064. }
  16065. // SetMode sets the "mode" field.
  16066. func (m *LabelMutation) SetMode(i int) {
  16067. m.mode = &i
  16068. m.addmode = nil
  16069. }
  16070. // Mode returns the value of the "mode" field in the mutation.
  16071. func (m *LabelMutation) Mode() (r int, exists bool) {
  16072. v := m.mode
  16073. if v == nil {
  16074. return
  16075. }
  16076. return *v, true
  16077. }
  16078. // OldMode returns the old "mode" field's value of the Label entity.
  16079. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16081. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  16082. if !m.op.Is(OpUpdateOne) {
  16083. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  16084. }
  16085. if m.id == nil || m.oldValue == nil {
  16086. return v, errors.New("OldMode requires an ID field in the mutation")
  16087. }
  16088. oldValue, err := m.oldValue(ctx)
  16089. if err != nil {
  16090. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  16091. }
  16092. return oldValue.Mode, nil
  16093. }
  16094. // AddMode adds i to the "mode" field.
  16095. func (m *LabelMutation) AddMode(i int) {
  16096. if m.addmode != nil {
  16097. *m.addmode += i
  16098. } else {
  16099. m.addmode = &i
  16100. }
  16101. }
  16102. // AddedMode returns the value that was added to the "mode" field in this mutation.
  16103. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  16104. v := m.addmode
  16105. if v == nil {
  16106. return
  16107. }
  16108. return *v, true
  16109. }
  16110. // ResetMode resets all changes to the "mode" field.
  16111. func (m *LabelMutation) ResetMode() {
  16112. m.mode = nil
  16113. m.addmode = nil
  16114. }
  16115. // SetConditions sets the "conditions" field.
  16116. func (m *LabelMutation) SetConditions(s string) {
  16117. m.conditions = &s
  16118. }
  16119. // Conditions returns the value of the "conditions" field in the mutation.
  16120. func (m *LabelMutation) Conditions() (r string, exists bool) {
  16121. v := m.conditions
  16122. if v == nil {
  16123. return
  16124. }
  16125. return *v, true
  16126. }
  16127. // OldConditions returns the old "conditions" field's value of the Label entity.
  16128. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16130. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  16131. if !m.op.Is(OpUpdateOne) {
  16132. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16133. }
  16134. if m.id == nil || m.oldValue == nil {
  16135. return v, errors.New("OldConditions requires an ID field in the mutation")
  16136. }
  16137. oldValue, err := m.oldValue(ctx)
  16138. if err != nil {
  16139. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16140. }
  16141. return oldValue.Conditions, nil
  16142. }
  16143. // ClearConditions clears the value of the "conditions" field.
  16144. func (m *LabelMutation) ClearConditions() {
  16145. m.conditions = nil
  16146. m.clearedFields[label.FieldConditions] = struct{}{}
  16147. }
  16148. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  16149. func (m *LabelMutation) ConditionsCleared() bool {
  16150. _, ok := m.clearedFields[label.FieldConditions]
  16151. return ok
  16152. }
  16153. // ResetConditions resets all changes to the "conditions" field.
  16154. func (m *LabelMutation) ResetConditions() {
  16155. m.conditions = nil
  16156. delete(m.clearedFields, label.FieldConditions)
  16157. }
  16158. // SetOrganizationID sets the "organization_id" field.
  16159. func (m *LabelMutation) SetOrganizationID(u uint64) {
  16160. m.organization_id = &u
  16161. m.addorganization_id = nil
  16162. }
  16163. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16164. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  16165. v := m.organization_id
  16166. if v == nil {
  16167. return
  16168. }
  16169. return *v, true
  16170. }
  16171. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  16172. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16174. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16175. if !m.op.Is(OpUpdateOne) {
  16176. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16177. }
  16178. if m.id == nil || m.oldValue == nil {
  16179. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16180. }
  16181. oldValue, err := m.oldValue(ctx)
  16182. if err != nil {
  16183. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16184. }
  16185. return oldValue.OrganizationID, nil
  16186. }
  16187. // AddOrganizationID adds u to the "organization_id" field.
  16188. func (m *LabelMutation) AddOrganizationID(u int64) {
  16189. if m.addorganization_id != nil {
  16190. *m.addorganization_id += u
  16191. } else {
  16192. m.addorganization_id = &u
  16193. }
  16194. }
  16195. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16196. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  16197. v := m.addorganization_id
  16198. if v == nil {
  16199. return
  16200. }
  16201. return *v, true
  16202. }
  16203. // ClearOrganizationID clears the value of the "organization_id" field.
  16204. func (m *LabelMutation) ClearOrganizationID() {
  16205. m.organization_id = nil
  16206. m.addorganization_id = nil
  16207. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  16208. }
  16209. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16210. func (m *LabelMutation) OrganizationIDCleared() bool {
  16211. _, ok := m.clearedFields[label.FieldOrganizationID]
  16212. return ok
  16213. }
  16214. // ResetOrganizationID resets all changes to the "organization_id" field.
  16215. func (m *LabelMutation) ResetOrganizationID() {
  16216. m.organization_id = nil
  16217. m.addorganization_id = nil
  16218. delete(m.clearedFields, label.FieldOrganizationID)
  16219. }
  16220. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  16221. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  16222. if m.label_relationships == nil {
  16223. m.label_relationships = make(map[uint64]struct{})
  16224. }
  16225. for i := range ids {
  16226. m.label_relationships[ids[i]] = struct{}{}
  16227. }
  16228. }
  16229. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  16230. func (m *LabelMutation) ClearLabelRelationships() {
  16231. m.clearedlabel_relationships = true
  16232. }
  16233. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  16234. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  16235. return m.clearedlabel_relationships
  16236. }
  16237. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  16238. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  16239. if m.removedlabel_relationships == nil {
  16240. m.removedlabel_relationships = make(map[uint64]struct{})
  16241. }
  16242. for i := range ids {
  16243. delete(m.label_relationships, ids[i])
  16244. m.removedlabel_relationships[ids[i]] = struct{}{}
  16245. }
  16246. }
  16247. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  16248. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  16249. for id := range m.removedlabel_relationships {
  16250. ids = append(ids, id)
  16251. }
  16252. return
  16253. }
  16254. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  16255. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  16256. for id := range m.label_relationships {
  16257. ids = append(ids, id)
  16258. }
  16259. return
  16260. }
  16261. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  16262. func (m *LabelMutation) ResetLabelRelationships() {
  16263. m.label_relationships = nil
  16264. m.clearedlabel_relationships = false
  16265. m.removedlabel_relationships = nil
  16266. }
  16267. // Where appends a list predicates to the LabelMutation builder.
  16268. func (m *LabelMutation) Where(ps ...predicate.Label) {
  16269. m.predicates = append(m.predicates, ps...)
  16270. }
  16271. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  16272. // users can use type-assertion to append predicates that do not depend on any generated package.
  16273. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  16274. p := make([]predicate.Label, len(ps))
  16275. for i := range ps {
  16276. p[i] = ps[i]
  16277. }
  16278. m.Where(p...)
  16279. }
  16280. // Op returns the operation name.
  16281. func (m *LabelMutation) Op() Op {
  16282. return m.op
  16283. }
  16284. // SetOp allows setting the mutation operation.
  16285. func (m *LabelMutation) SetOp(op Op) {
  16286. m.op = op
  16287. }
  16288. // Type returns the node type of this mutation (Label).
  16289. func (m *LabelMutation) Type() string {
  16290. return m.typ
  16291. }
  16292. // Fields returns all fields that were changed during this mutation. Note that in
  16293. // order to get all numeric fields that were incremented/decremented, call
  16294. // AddedFields().
  16295. func (m *LabelMutation) Fields() []string {
  16296. fields := make([]string, 0, 9)
  16297. if m.created_at != nil {
  16298. fields = append(fields, label.FieldCreatedAt)
  16299. }
  16300. if m.updated_at != nil {
  16301. fields = append(fields, label.FieldUpdatedAt)
  16302. }
  16303. if m.status != nil {
  16304. fields = append(fields, label.FieldStatus)
  16305. }
  16306. if m._type != nil {
  16307. fields = append(fields, label.FieldType)
  16308. }
  16309. if m.name != nil {
  16310. fields = append(fields, label.FieldName)
  16311. }
  16312. if m.from != nil {
  16313. fields = append(fields, label.FieldFrom)
  16314. }
  16315. if m.mode != nil {
  16316. fields = append(fields, label.FieldMode)
  16317. }
  16318. if m.conditions != nil {
  16319. fields = append(fields, label.FieldConditions)
  16320. }
  16321. if m.organization_id != nil {
  16322. fields = append(fields, label.FieldOrganizationID)
  16323. }
  16324. return fields
  16325. }
  16326. // Field returns the value of a field with the given name. The second boolean
  16327. // return value indicates that this field was not set, or was not defined in the
  16328. // schema.
  16329. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  16330. switch name {
  16331. case label.FieldCreatedAt:
  16332. return m.CreatedAt()
  16333. case label.FieldUpdatedAt:
  16334. return m.UpdatedAt()
  16335. case label.FieldStatus:
  16336. return m.Status()
  16337. case label.FieldType:
  16338. return m.GetType()
  16339. case label.FieldName:
  16340. return m.Name()
  16341. case label.FieldFrom:
  16342. return m.From()
  16343. case label.FieldMode:
  16344. return m.Mode()
  16345. case label.FieldConditions:
  16346. return m.Conditions()
  16347. case label.FieldOrganizationID:
  16348. return m.OrganizationID()
  16349. }
  16350. return nil, false
  16351. }
  16352. // OldField returns the old value of the field from the database. An error is
  16353. // returned if the mutation operation is not UpdateOne, or the query to the
  16354. // database failed.
  16355. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16356. switch name {
  16357. case label.FieldCreatedAt:
  16358. return m.OldCreatedAt(ctx)
  16359. case label.FieldUpdatedAt:
  16360. return m.OldUpdatedAt(ctx)
  16361. case label.FieldStatus:
  16362. return m.OldStatus(ctx)
  16363. case label.FieldType:
  16364. return m.OldType(ctx)
  16365. case label.FieldName:
  16366. return m.OldName(ctx)
  16367. case label.FieldFrom:
  16368. return m.OldFrom(ctx)
  16369. case label.FieldMode:
  16370. return m.OldMode(ctx)
  16371. case label.FieldConditions:
  16372. return m.OldConditions(ctx)
  16373. case label.FieldOrganizationID:
  16374. return m.OldOrganizationID(ctx)
  16375. }
  16376. return nil, fmt.Errorf("unknown Label field %s", name)
  16377. }
  16378. // SetField sets the value of a field with the given name. It returns an error if
  16379. // the field is not defined in the schema, or if the type mismatched the field
  16380. // type.
  16381. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  16382. switch name {
  16383. case label.FieldCreatedAt:
  16384. v, ok := value.(time.Time)
  16385. if !ok {
  16386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16387. }
  16388. m.SetCreatedAt(v)
  16389. return nil
  16390. case label.FieldUpdatedAt:
  16391. v, ok := value.(time.Time)
  16392. if !ok {
  16393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16394. }
  16395. m.SetUpdatedAt(v)
  16396. return nil
  16397. case label.FieldStatus:
  16398. v, ok := value.(uint8)
  16399. if !ok {
  16400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16401. }
  16402. m.SetStatus(v)
  16403. return nil
  16404. case label.FieldType:
  16405. v, ok := value.(int)
  16406. if !ok {
  16407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16408. }
  16409. m.SetType(v)
  16410. return nil
  16411. case label.FieldName:
  16412. v, ok := value.(string)
  16413. if !ok {
  16414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16415. }
  16416. m.SetName(v)
  16417. return nil
  16418. case label.FieldFrom:
  16419. v, ok := value.(int)
  16420. if !ok {
  16421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16422. }
  16423. m.SetFrom(v)
  16424. return nil
  16425. case label.FieldMode:
  16426. v, ok := value.(int)
  16427. if !ok {
  16428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16429. }
  16430. m.SetMode(v)
  16431. return nil
  16432. case label.FieldConditions:
  16433. v, ok := value.(string)
  16434. if !ok {
  16435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16436. }
  16437. m.SetConditions(v)
  16438. return nil
  16439. case label.FieldOrganizationID:
  16440. v, ok := value.(uint64)
  16441. if !ok {
  16442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16443. }
  16444. m.SetOrganizationID(v)
  16445. return nil
  16446. }
  16447. return fmt.Errorf("unknown Label field %s", name)
  16448. }
  16449. // AddedFields returns all numeric fields that were incremented/decremented during
  16450. // this mutation.
  16451. func (m *LabelMutation) AddedFields() []string {
  16452. var fields []string
  16453. if m.addstatus != nil {
  16454. fields = append(fields, label.FieldStatus)
  16455. }
  16456. if m.add_type != nil {
  16457. fields = append(fields, label.FieldType)
  16458. }
  16459. if m.addfrom != nil {
  16460. fields = append(fields, label.FieldFrom)
  16461. }
  16462. if m.addmode != nil {
  16463. fields = append(fields, label.FieldMode)
  16464. }
  16465. if m.addorganization_id != nil {
  16466. fields = append(fields, label.FieldOrganizationID)
  16467. }
  16468. return fields
  16469. }
  16470. // AddedField returns the numeric value that was incremented/decremented on a field
  16471. // with the given name. The second boolean return value indicates that this field
  16472. // was not set, or was not defined in the schema.
  16473. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  16474. switch name {
  16475. case label.FieldStatus:
  16476. return m.AddedStatus()
  16477. case label.FieldType:
  16478. return m.AddedType()
  16479. case label.FieldFrom:
  16480. return m.AddedFrom()
  16481. case label.FieldMode:
  16482. return m.AddedMode()
  16483. case label.FieldOrganizationID:
  16484. return m.AddedOrganizationID()
  16485. }
  16486. return nil, false
  16487. }
  16488. // AddField adds the value to the field with the given name. It returns an error if
  16489. // the field is not defined in the schema, or if the type mismatched the field
  16490. // type.
  16491. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  16492. switch name {
  16493. case label.FieldStatus:
  16494. v, ok := value.(int8)
  16495. if !ok {
  16496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16497. }
  16498. m.AddStatus(v)
  16499. return nil
  16500. case label.FieldType:
  16501. v, ok := value.(int)
  16502. if !ok {
  16503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16504. }
  16505. m.AddType(v)
  16506. return nil
  16507. case label.FieldFrom:
  16508. v, ok := value.(int)
  16509. if !ok {
  16510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16511. }
  16512. m.AddFrom(v)
  16513. return nil
  16514. case label.FieldMode:
  16515. v, ok := value.(int)
  16516. if !ok {
  16517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16518. }
  16519. m.AddMode(v)
  16520. return nil
  16521. case label.FieldOrganizationID:
  16522. v, ok := value.(int64)
  16523. if !ok {
  16524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16525. }
  16526. m.AddOrganizationID(v)
  16527. return nil
  16528. }
  16529. return fmt.Errorf("unknown Label numeric field %s", name)
  16530. }
  16531. // ClearedFields returns all nullable fields that were cleared during this
  16532. // mutation.
  16533. func (m *LabelMutation) ClearedFields() []string {
  16534. var fields []string
  16535. if m.FieldCleared(label.FieldStatus) {
  16536. fields = append(fields, label.FieldStatus)
  16537. }
  16538. if m.FieldCleared(label.FieldConditions) {
  16539. fields = append(fields, label.FieldConditions)
  16540. }
  16541. if m.FieldCleared(label.FieldOrganizationID) {
  16542. fields = append(fields, label.FieldOrganizationID)
  16543. }
  16544. return fields
  16545. }
  16546. // FieldCleared returns a boolean indicating if a field with the given name was
  16547. // cleared in this mutation.
  16548. func (m *LabelMutation) FieldCleared(name string) bool {
  16549. _, ok := m.clearedFields[name]
  16550. return ok
  16551. }
  16552. // ClearField clears the value of the field with the given name. It returns an
  16553. // error if the field is not defined in the schema.
  16554. func (m *LabelMutation) ClearField(name string) error {
  16555. switch name {
  16556. case label.FieldStatus:
  16557. m.ClearStatus()
  16558. return nil
  16559. case label.FieldConditions:
  16560. m.ClearConditions()
  16561. return nil
  16562. case label.FieldOrganizationID:
  16563. m.ClearOrganizationID()
  16564. return nil
  16565. }
  16566. return fmt.Errorf("unknown Label nullable field %s", name)
  16567. }
  16568. // ResetField resets all changes in the mutation for the field with the given name.
  16569. // It returns an error if the field is not defined in the schema.
  16570. func (m *LabelMutation) ResetField(name string) error {
  16571. switch name {
  16572. case label.FieldCreatedAt:
  16573. m.ResetCreatedAt()
  16574. return nil
  16575. case label.FieldUpdatedAt:
  16576. m.ResetUpdatedAt()
  16577. return nil
  16578. case label.FieldStatus:
  16579. m.ResetStatus()
  16580. return nil
  16581. case label.FieldType:
  16582. m.ResetType()
  16583. return nil
  16584. case label.FieldName:
  16585. m.ResetName()
  16586. return nil
  16587. case label.FieldFrom:
  16588. m.ResetFrom()
  16589. return nil
  16590. case label.FieldMode:
  16591. m.ResetMode()
  16592. return nil
  16593. case label.FieldConditions:
  16594. m.ResetConditions()
  16595. return nil
  16596. case label.FieldOrganizationID:
  16597. m.ResetOrganizationID()
  16598. return nil
  16599. }
  16600. return fmt.Errorf("unknown Label field %s", name)
  16601. }
  16602. // AddedEdges returns all edge names that were set/added in this mutation.
  16603. func (m *LabelMutation) AddedEdges() []string {
  16604. edges := make([]string, 0, 1)
  16605. if m.label_relationships != nil {
  16606. edges = append(edges, label.EdgeLabelRelationships)
  16607. }
  16608. return edges
  16609. }
  16610. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16611. // name in this mutation.
  16612. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  16613. switch name {
  16614. case label.EdgeLabelRelationships:
  16615. ids := make([]ent.Value, 0, len(m.label_relationships))
  16616. for id := range m.label_relationships {
  16617. ids = append(ids, id)
  16618. }
  16619. return ids
  16620. }
  16621. return nil
  16622. }
  16623. // RemovedEdges returns all edge names that were removed in this mutation.
  16624. func (m *LabelMutation) RemovedEdges() []string {
  16625. edges := make([]string, 0, 1)
  16626. if m.removedlabel_relationships != nil {
  16627. edges = append(edges, label.EdgeLabelRelationships)
  16628. }
  16629. return edges
  16630. }
  16631. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16632. // the given name in this mutation.
  16633. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  16634. switch name {
  16635. case label.EdgeLabelRelationships:
  16636. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  16637. for id := range m.removedlabel_relationships {
  16638. ids = append(ids, id)
  16639. }
  16640. return ids
  16641. }
  16642. return nil
  16643. }
  16644. // ClearedEdges returns all edge names that were cleared in this mutation.
  16645. func (m *LabelMutation) ClearedEdges() []string {
  16646. edges := make([]string, 0, 1)
  16647. if m.clearedlabel_relationships {
  16648. edges = append(edges, label.EdgeLabelRelationships)
  16649. }
  16650. return edges
  16651. }
  16652. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16653. // was cleared in this mutation.
  16654. func (m *LabelMutation) EdgeCleared(name string) bool {
  16655. switch name {
  16656. case label.EdgeLabelRelationships:
  16657. return m.clearedlabel_relationships
  16658. }
  16659. return false
  16660. }
  16661. // ClearEdge clears the value of the edge with the given name. It returns an error
  16662. // if that edge is not defined in the schema.
  16663. func (m *LabelMutation) ClearEdge(name string) error {
  16664. switch name {
  16665. }
  16666. return fmt.Errorf("unknown Label unique edge %s", name)
  16667. }
  16668. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16669. // It returns an error if the edge is not defined in the schema.
  16670. func (m *LabelMutation) ResetEdge(name string) error {
  16671. switch name {
  16672. case label.EdgeLabelRelationships:
  16673. m.ResetLabelRelationships()
  16674. return nil
  16675. }
  16676. return fmt.Errorf("unknown Label edge %s", name)
  16677. }
  16678. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  16679. type LabelRelationshipMutation struct {
  16680. config
  16681. op Op
  16682. typ string
  16683. id *uint64
  16684. created_at *time.Time
  16685. updated_at *time.Time
  16686. status *uint8
  16687. addstatus *int8
  16688. organization_id *uint64
  16689. addorganization_id *int64
  16690. clearedFields map[string]struct{}
  16691. contacts *uint64
  16692. clearedcontacts bool
  16693. labels *uint64
  16694. clearedlabels bool
  16695. done bool
  16696. oldValue func(context.Context) (*LabelRelationship, error)
  16697. predicates []predicate.LabelRelationship
  16698. }
  16699. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  16700. // labelrelationshipOption allows management of the mutation configuration using functional options.
  16701. type labelrelationshipOption func(*LabelRelationshipMutation)
  16702. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  16703. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  16704. m := &LabelRelationshipMutation{
  16705. config: c,
  16706. op: op,
  16707. typ: TypeLabelRelationship,
  16708. clearedFields: make(map[string]struct{}),
  16709. }
  16710. for _, opt := range opts {
  16711. opt(m)
  16712. }
  16713. return m
  16714. }
  16715. // withLabelRelationshipID sets the ID field of the mutation.
  16716. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  16717. return func(m *LabelRelationshipMutation) {
  16718. var (
  16719. err error
  16720. once sync.Once
  16721. value *LabelRelationship
  16722. )
  16723. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  16724. once.Do(func() {
  16725. if m.done {
  16726. err = errors.New("querying old values post mutation is not allowed")
  16727. } else {
  16728. value, err = m.Client().LabelRelationship.Get(ctx, id)
  16729. }
  16730. })
  16731. return value, err
  16732. }
  16733. m.id = &id
  16734. }
  16735. }
  16736. // withLabelRelationship sets the old LabelRelationship of the mutation.
  16737. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  16738. return func(m *LabelRelationshipMutation) {
  16739. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  16740. return node, nil
  16741. }
  16742. m.id = &node.ID
  16743. }
  16744. }
  16745. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16746. // executed in a transaction (ent.Tx), a transactional client is returned.
  16747. func (m LabelRelationshipMutation) Client() *Client {
  16748. client := &Client{config: m.config}
  16749. client.init()
  16750. return client
  16751. }
  16752. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16753. // it returns an error otherwise.
  16754. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  16755. if _, ok := m.driver.(*txDriver); !ok {
  16756. return nil, errors.New("ent: mutation is not running in a transaction")
  16757. }
  16758. tx := &Tx{config: m.config}
  16759. tx.init()
  16760. return tx, nil
  16761. }
  16762. // SetID sets the value of the id field. Note that this
  16763. // operation is only accepted on creation of LabelRelationship entities.
  16764. func (m *LabelRelationshipMutation) SetID(id uint64) {
  16765. m.id = &id
  16766. }
  16767. // ID returns the ID value in the mutation. Note that the ID is only available
  16768. // if it was provided to the builder or after it was returned from the database.
  16769. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  16770. if m.id == nil {
  16771. return
  16772. }
  16773. return *m.id, true
  16774. }
  16775. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16776. // That means, if the mutation is applied within a transaction with an isolation level such
  16777. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16778. // or updated by the mutation.
  16779. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  16780. switch {
  16781. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16782. id, exists := m.ID()
  16783. if exists {
  16784. return []uint64{id}, nil
  16785. }
  16786. fallthrough
  16787. case m.op.Is(OpUpdate | OpDelete):
  16788. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  16789. default:
  16790. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16791. }
  16792. }
  16793. // SetCreatedAt sets the "created_at" field.
  16794. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  16795. m.created_at = &t
  16796. }
  16797. // CreatedAt returns the value of the "created_at" field in the mutation.
  16798. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  16799. v := m.created_at
  16800. if v == nil {
  16801. return
  16802. }
  16803. return *v, true
  16804. }
  16805. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  16806. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16808. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16809. if !m.op.Is(OpUpdateOne) {
  16810. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16811. }
  16812. if m.id == nil || m.oldValue == nil {
  16813. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16814. }
  16815. oldValue, err := m.oldValue(ctx)
  16816. if err != nil {
  16817. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16818. }
  16819. return oldValue.CreatedAt, nil
  16820. }
  16821. // ResetCreatedAt resets all changes to the "created_at" field.
  16822. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  16823. m.created_at = nil
  16824. }
  16825. // SetUpdatedAt sets the "updated_at" field.
  16826. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  16827. m.updated_at = &t
  16828. }
  16829. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16830. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  16831. v := m.updated_at
  16832. if v == nil {
  16833. return
  16834. }
  16835. return *v, true
  16836. }
  16837. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  16838. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16840. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16841. if !m.op.Is(OpUpdateOne) {
  16842. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16843. }
  16844. if m.id == nil || m.oldValue == nil {
  16845. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16846. }
  16847. oldValue, err := m.oldValue(ctx)
  16848. if err != nil {
  16849. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16850. }
  16851. return oldValue.UpdatedAt, nil
  16852. }
  16853. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16854. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  16855. m.updated_at = nil
  16856. }
  16857. // SetStatus sets the "status" field.
  16858. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  16859. m.status = &u
  16860. m.addstatus = nil
  16861. }
  16862. // Status returns the value of the "status" field in the mutation.
  16863. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  16864. v := m.status
  16865. if v == nil {
  16866. return
  16867. }
  16868. return *v, true
  16869. }
  16870. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  16871. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16873. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16874. if !m.op.Is(OpUpdateOne) {
  16875. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16876. }
  16877. if m.id == nil || m.oldValue == nil {
  16878. return v, errors.New("OldStatus requires an ID field in the mutation")
  16879. }
  16880. oldValue, err := m.oldValue(ctx)
  16881. if err != nil {
  16882. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16883. }
  16884. return oldValue.Status, nil
  16885. }
  16886. // AddStatus adds u to the "status" field.
  16887. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  16888. if m.addstatus != nil {
  16889. *m.addstatus += u
  16890. } else {
  16891. m.addstatus = &u
  16892. }
  16893. }
  16894. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16895. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  16896. v := m.addstatus
  16897. if v == nil {
  16898. return
  16899. }
  16900. return *v, true
  16901. }
  16902. // ClearStatus clears the value of the "status" field.
  16903. func (m *LabelRelationshipMutation) ClearStatus() {
  16904. m.status = nil
  16905. m.addstatus = nil
  16906. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  16907. }
  16908. // StatusCleared returns if the "status" field was cleared in this mutation.
  16909. func (m *LabelRelationshipMutation) StatusCleared() bool {
  16910. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  16911. return ok
  16912. }
  16913. // ResetStatus resets all changes to the "status" field.
  16914. func (m *LabelRelationshipMutation) ResetStatus() {
  16915. m.status = nil
  16916. m.addstatus = nil
  16917. delete(m.clearedFields, labelrelationship.FieldStatus)
  16918. }
  16919. // SetLabelID sets the "label_id" field.
  16920. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  16921. m.labels = &u
  16922. }
  16923. // LabelID returns the value of the "label_id" field in the mutation.
  16924. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  16925. v := m.labels
  16926. if v == nil {
  16927. return
  16928. }
  16929. return *v, true
  16930. }
  16931. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  16932. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16934. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  16935. if !m.op.Is(OpUpdateOne) {
  16936. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  16937. }
  16938. if m.id == nil || m.oldValue == nil {
  16939. return v, errors.New("OldLabelID requires an ID field in the mutation")
  16940. }
  16941. oldValue, err := m.oldValue(ctx)
  16942. if err != nil {
  16943. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  16944. }
  16945. return oldValue.LabelID, nil
  16946. }
  16947. // ResetLabelID resets all changes to the "label_id" field.
  16948. func (m *LabelRelationshipMutation) ResetLabelID() {
  16949. m.labels = nil
  16950. }
  16951. // SetContactID sets the "contact_id" field.
  16952. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  16953. m.contacts = &u
  16954. }
  16955. // ContactID returns the value of the "contact_id" field in the mutation.
  16956. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  16957. v := m.contacts
  16958. if v == nil {
  16959. return
  16960. }
  16961. return *v, true
  16962. }
  16963. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  16964. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16966. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16967. if !m.op.Is(OpUpdateOne) {
  16968. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16969. }
  16970. if m.id == nil || m.oldValue == nil {
  16971. return v, errors.New("OldContactID requires an ID field in the mutation")
  16972. }
  16973. oldValue, err := m.oldValue(ctx)
  16974. if err != nil {
  16975. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16976. }
  16977. return oldValue.ContactID, nil
  16978. }
  16979. // ResetContactID resets all changes to the "contact_id" field.
  16980. func (m *LabelRelationshipMutation) ResetContactID() {
  16981. m.contacts = nil
  16982. }
  16983. // SetOrganizationID sets the "organization_id" field.
  16984. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  16985. m.organization_id = &u
  16986. m.addorganization_id = nil
  16987. }
  16988. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16989. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  16990. v := m.organization_id
  16991. if v == nil {
  16992. return
  16993. }
  16994. return *v, true
  16995. }
  16996. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  16997. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  16998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16999. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17000. if !m.op.Is(OpUpdateOne) {
  17001. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17002. }
  17003. if m.id == nil || m.oldValue == nil {
  17004. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17005. }
  17006. oldValue, err := m.oldValue(ctx)
  17007. if err != nil {
  17008. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17009. }
  17010. return oldValue.OrganizationID, nil
  17011. }
  17012. // AddOrganizationID adds u to the "organization_id" field.
  17013. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  17014. if m.addorganization_id != nil {
  17015. *m.addorganization_id += u
  17016. } else {
  17017. m.addorganization_id = &u
  17018. }
  17019. }
  17020. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17021. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  17022. v := m.addorganization_id
  17023. if v == nil {
  17024. return
  17025. }
  17026. return *v, true
  17027. }
  17028. // ClearOrganizationID clears the value of the "organization_id" field.
  17029. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  17030. m.organization_id = nil
  17031. m.addorganization_id = nil
  17032. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  17033. }
  17034. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17035. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  17036. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  17037. return ok
  17038. }
  17039. // ResetOrganizationID resets all changes to the "organization_id" field.
  17040. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  17041. m.organization_id = nil
  17042. m.addorganization_id = nil
  17043. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  17044. }
  17045. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  17046. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  17047. m.contacts = &id
  17048. }
  17049. // ClearContacts clears the "contacts" edge to the Contact entity.
  17050. func (m *LabelRelationshipMutation) ClearContacts() {
  17051. m.clearedcontacts = true
  17052. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  17053. }
  17054. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  17055. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  17056. return m.clearedcontacts
  17057. }
  17058. // ContactsID returns the "contacts" edge ID in the mutation.
  17059. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  17060. if m.contacts != nil {
  17061. return *m.contacts, true
  17062. }
  17063. return
  17064. }
  17065. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  17066. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17067. // ContactsID instead. It exists only for internal usage by the builders.
  17068. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  17069. if id := m.contacts; id != nil {
  17070. ids = append(ids, *id)
  17071. }
  17072. return
  17073. }
  17074. // ResetContacts resets all changes to the "contacts" edge.
  17075. func (m *LabelRelationshipMutation) ResetContacts() {
  17076. m.contacts = nil
  17077. m.clearedcontacts = false
  17078. }
  17079. // SetLabelsID sets the "labels" edge to the Label entity by id.
  17080. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  17081. m.labels = &id
  17082. }
  17083. // ClearLabels clears the "labels" edge to the Label entity.
  17084. func (m *LabelRelationshipMutation) ClearLabels() {
  17085. m.clearedlabels = true
  17086. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  17087. }
  17088. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  17089. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  17090. return m.clearedlabels
  17091. }
  17092. // LabelsID returns the "labels" edge ID in the mutation.
  17093. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  17094. if m.labels != nil {
  17095. return *m.labels, true
  17096. }
  17097. return
  17098. }
  17099. // LabelsIDs returns the "labels" edge IDs in the mutation.
  17100. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17101. // LabelsID instead. It exists only for internal usage by the builders.
  17102. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  17103. if id := m.labels; id != nil {
  17104. ids = append(ids, *id)
  17105. }
  17106. return
  17107. }
  17108. // ResetLabels resets all changes to the "labels" edge.
  17109. func (m *LabelRelationshipMutation) ResetLabels() {
  17110. m.labels = nil
  17111. m.clearedlabels = false
  17112. }
  17113. // Where appends a list predicates to the LabelRelationshipMutation builder.
  17114. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  17115. m.predicates = append(m.predicates, ps...)
  17116. }
  17117. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  17118. // users can use type-assertion to append predicates that do not depend on any generated package.
  17119. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  17120. p := make([]predicate.LabelRelationship, len(ps))
  17121. for i := range ps {
  17122. p[i] = ps[i]
  17123. }
  17124. m.Where(p...)
  17125. }
  17126. // Op returns the operation name.
  17127. func (m *LabelRelationshipMutation) Op() Op {
  17128. return m.op
  17129. }
  17130. // SetOp allows setting the mutation operation.
  17131. func (m *LabelRelationshipMutation) SetOp(op Op) {
  17132. m.op = op
  17133. }
  17134. // Type returns the node type of this mutation (LabelRelationship).
  17135. func (m *LabelRelationshipMutation) Type() string {
  17136. return m.typ
  17137. }
  17138. // Fields returns all fields that were changed during this mutation. Note that in
  17139. // order to get all numeric fields that were incremented/decremented, call
  17140. // AddedFields().
  17141. func (m *LabelRelationshipMutation) Fields() []string {
  17142. fields := make([]string, 0, 6)
  17143. if m.created_at != nil {
  17144. fields = append(fields, labelrelationship.FieldCreatedAt)
  17145. }
  17146. if m.updated_at != nil {
  17147. fields = append(fields, labelrelationship.FieldUpdatedAt)
  17148. }
  17149. if m.status != nil {
  17150. fields = append(fields, labelrelationship.FieldStatus)
  17151. }
  17152. if m.labels != nil {
  17153. fields = append(fields, labelrelationship.FieldLabelID)
  17154. }
  17155. if m.contacts != nil {
  17156. fields = append(fields, labelrelationship.FieldContactID)
  17157. }
  17158. if m.organization_id != nil {
  17159. fields = append(fields, labelrelationship.FieldOrganizationID)
  17160. }
  17161. return fields
  17162. }
  17163. // Field returns the value of a field with the given name. The second boolean
  17164. // return value indicates that this field was not set, or was not defined in the
  17165. // schema.
  17166. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  17167. switch name {
  17168. case labelrelationship.FieldCreatedAt:
  17169. return m.CreatedAt()
  17170. case labelrelationship.FieldUpdatedAt:
  17171. return m.UpdatedAt()
  17172. case labelrelationship.FieldStatus:
  17173. return m.Status()
  17174. case labelrelationship.FieldLabelID:
  17175. return m.LabelID()
  17176. case labelrelationship.FieldContactID:
  17177. return m.ContactID()
  17178. case labelrelationship.FieldOrganizationID:
  17179. return m.OrganizationID()
  17180. }
  17181. return nil, false
  17182. }
  17183. // OldField returns the old value of the field from the database. An error is
  17184. // returned if the mutation operation is not UpdateOne, or the query to the
  17185. // database failed.
  17186. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17187. switch name {
  17188. case labelrelationship.FieldCreatedAt:
  17189. return m.OldCreatedAt(ctx)
  17190. case labelrelationship.FieldUpdatedAt:
  17191. return m.OldUpdatedAt(ctx)
  17192. case labelrelationship.FieldStatus:
  17193. return m.OldStatus(ctx)
  17194. case labelrelationship.FieldLabelID:
  17195. return m.OldLabelID(ctx)
  17196. case labelrelationship.FieldContactID:
  17197. return m.OldContactID(ctx)
  17198. case labelrelationship.FieldOrganizationID:
  17199. return m.OldOrganizationID(ctx)
  17200. }
  17201. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  17202. }
  17203. // SetField sets the value of a field with the given name. It returns an error if
  17204. // the field is not defined in the schema, or if the type mismatched the field
  17205. // type.
  17206. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  17207. switch name {
  17208. case labelrelationship.FieldCreatedAt:
  17209. v, ok := value.(time.Time)
  17210. if !ok {
  17211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17212. }
  17213. m.SetCreatedAt(v)
  17214. return nil
  17215. case labelrelationship.FieldUpdatedAt:
  17216. v, ok := value.(time.Time)
  17217. if !ok {
  17218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17219. }
  17220. m.SetUpdatedAt(v)
  17221. return nil
  17222. case labelrelationship.FieldStatus:
  17223. v, ok := value.(uint8)
  17224. if !ok {
  17225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17226. }
  17227. m.SetStatus(v)
  17228. return nil
  17229. case labelrelationship.FieldLabelID:
  17230. v, ok := value.(uint64)
  17231. if !ok {
  17232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17233. }
  17234. m.SetLabelID(v)
  17235. return nil
  17236. case labelrelationship.FieldContactID:
  17237. v, ok := value.(uint64)
  17238. if !ok {
  17239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17240. }
  17241. m.SetContactID(v)
  17242. return nil
  17243. case labelrelationship.FieldOrganizationID:
  17244. v, ok := value.(uint64)
  17245. if !ok {
  17246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17247. }
  17248. m.SetOrganizationID(v)
  17249. return nil
  17250. }
  17251. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17252. }
  17253. // AddedFields returns all numeric fields that were incremented/decremented during
  17254. // this mutation.
  17255. func (m *LabelRelationshipMutation) AddedFields() []string {
  17256. var fields []string
  17257. if m.addstatus != nil {
  17258. fields = append(fields, labelrelationship.FieldStatus)
  17259. }
  17260. if m.addorganization_id != nil {
  17261. fields = append(fields, labelrelationship.FieldOrganizationID)
  17262. }
  17263. return fields
  17264. }
  17265. // AddedField returns the numeric value that was incremented/decremented on a field
  17266. // with the given name. The second boolean return value indicates that this field
  17267. // was not set, or was not defined in the schema.
  17268. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  17269. switch name {
  17270. case labelrelationship.FieldStatus:
  17271. return m.AddedStatus()
  17272. case labelrelationship.FieldOrganizationID:
  17273. return m.AddedOrganizationID()
  17274. }
  17275. return nil, false
  17276. }
  17277. // AddField adds the value to the field with the given name. It returns an error if
  17278. // the field is not defined in the schema, or if the type mismatched the field
  17279. // type.
  17280. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  17281. switch name {
  17282. case labelrelationship.FieldStatus:
  17283. v, ok := value.(int8)
  17284. if !ok {
  17285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17286. }
  17287. m.AddStatus(v)
  17288. return nil
  17289. case labelrelationship.FieldOrganizationID:
  17290. v, ok := value.(int64)
  17291. if !ok {
  17292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17293. }
  17294. m.AddOrganizationID(v)
  17295. return nil
  17296. }
  17297. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  17298. }
  17299. // ClearedFields returns all nullable fields that were cleared during this
  17300. // mutation.
  17301. func (m *LabelRelationshipMutation) ClearedFields() []string {
  17302. var fields []string
  17303. if m.FieldCleared(labelrelationship.FieldStatus) {
  17304. fields = append(fields, labelrelationship.FieldStatus)
  17305. }
  17306. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  17307. fields = append(fields, labelrelationship.FieldOrganizationID)
  17308. }
  17309. return fields
  17310. }
  17311. // FieldCleared returns a boolean indicating if a field with the given name was
  17312. // cleared in this mutation.
  17313. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  17314. _, ok := m.clearedFields[name]
  17315. return ok
  17316. }
  17317. // ClearField clears the value of the field with the given name. It returns an
  17318. // error if the field is not defined in the schema.
  17319. func (m *LabelRelationshipMutation) ClearField(name string) error {
  17320. switch name {
  17321. case labelrelationship.FieldStatus:
  17322. m.ClearStatus()
  17323. return nil
  17324. case labelrelationship.FieldOrganizationID:
  17325. m.ClearOrganizationID()
  17326. return nil
  17327. }
  17328. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  17329. }
  17330. // ResetField resets all changes in the mutation for the field with the given name.
  17331. // It returns an error if the field is not defined in the schema.
  17332. func (m *LabelRelationshipMutation) ResetField(name string) error {
  17333. switch name {
  17334. case labelrelationship.FieldCreatedAt:
  17335. m.ResetCreatedAt()
  17336. return nil
  17337. case labelrelationship.FieldUpdatedAt:
  17338. m.ResetUpdatedAt()
  17339. return nil
  17340. case labelrelationship.FieldStatus:
  17341. m.ResetStatus()
  17342. return nil
  17343. case labelrelationship.FieldLabelID:
  17344. m.ResetLabelID()
  17345. return nil
  17346. case labelrelationship.FieldContactID:
  17347. m.ResetContactID()
  17348. return nil
  17349. case labelrelationship.FieldOrganizationID:
  17350. m.ResetOrganizationID()
  17351. return nil
  17352. }
  17353. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17354. }
  17355. // AddedEdges returns all edge names that were set/added in this mutation.
  17356. func (m *LabelRelationshipMutation) AddedEdges() []string {
  17357. edges := make([]string, 0, 2)
  17358. if m.contacts != nil {
  17359. edges = append(edges, labelrelationship.EdgeContacts)
  17360. }
  17361. if m.labels != nil {
  17362. edges = append(edges, labelrelationship.EdgeLabels)
  17363. }
  17364. return edges
  17365. }
  17366. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17367. // name in this mutation.
  17368. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  17369. switch name {
  17370. case labelrelationship.EdgeContacts:
  17371. if id := m.contacts; id != nil {
  17372. return []ent.Value{*id}
  17373. }
  17374. case labelrelationship.EdgeLabels:
  17375. if id := m.labels; id != nil {
  17376. return []ent.Value{*id}
  17377. }
  17378. }
  17379. return nil
  17380. }
  17381. // RemovedEdges returns all edge names that were removed in this mutation.
  17382. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  17383. edges := make([]string, 0, 2)
  17384. return edges
  17385. }
  17386. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17387. // the given name in this mutation.
  17388. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  17389. return nil
  17390. }
  17391. // ClearedEdges returns all edge names that were cleared in this mutation.
  17392. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  17393. edges := make([]string, 0, 2)
  17394. if m.clearedcontacts {
  17395. edges = append(edges, labelrelationship.EdgeContacts)
  17396. }
  17397. if m.clearedlabels {
  17398. edges = append(edges, labelrelationship.EdgeLabels)
  17399. }
  17400. return edges
  17401. }
  17402. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17403. // was cleared in this mutation.
  17404. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  17405. switch name {
  17406. case labelrelationship.EdgeContacts:
  17407. return m.clearedcontacts
  17408. case labelrelationship.EdgeLabels:
  17409. return m.clearedlabels
  17410. }
  17411. return false
  17412. }
  17413. // ClearEdge clears the value of the edge with the given name. It returns an error
  17414. // if that edge is not defined in the schema.
  17415. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  17416. switch name {
  17417. case labelrelationship.EdgeContacts:
  17418. m.ClearContacts()
  17419. return nil
  17420. case labelrelationship.EdgeLabels:
  17421. m.ClearLabels()
  17422. return nil
  17423. }
  17424. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  17425. }
  17426. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17427. // It returns an error if the edge is not defined in the schema.
  17428. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  17429. switch name {
  17430. case labelrelationship.EdgeContacts:
  17431. m.ResetContacts()
  17432. return nil
  17433. case labelrelationship.EdgeLabels:
  17434. m.ResetLabels()
  17435. return nil
  17436. }
  17437. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  17438. }
  17439. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  17440. type LabelTaggingMutation struct {
  17441. config
  17442. op Op
  17443. typ string
  17444. id *uint64
  17445. created_at *time.Time
  17446. updated_at *time.Time
  17447. status *uint8
  17448. addstatus *int8
  17449. deleted_at *time.Time
  17450. organization_id *uint64
  17451. addorganization_id *int64
  17452. _type *int
  17453. add_type *int
  17454. conditions *string
  17455. action_label_add *[]uint64
  17456. appendaction_label_add []uint64
  17457. action_label_del *[]uint64
  17458. appendaction_label_del []uint64
  17459. clearedFields map[string]struct{}
  17460. done bool
  17461. oldValue func(context.Context) (*LabelTagging, error)
  17462. predicates []predicate.LabelTagging
  17463. }
  17464. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  17465. // labeltaggingOption allows management of the mutation configuration using functional options.
  17466. type labeltaggingOption func(*LabelTaggingMutation)
  17467. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  17468. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  17469. m := &LabelTaggingMutation{
  17470. config: c,
  17471. op: op,
  17472. typ: TypeLabelTagging,
  17473. clearedFields: make(map[string]struct{}),
  17474. }
  17475. for _, opt := range opts {
  17476. opt(m)
  17477. }
  17478. return m
  17479. }
  17480. // withLabelTaggingID sets the ID field of the mutation.
  17481. func withLabelTaggingID(id uint64) labeltaggingOption {
  17482. return func(m *LabelTaggingMutation) {
  17483. var (
  17484. err error
  17485. once sync.Once
  17486. value *LabelTagging
  17487. )
  17488. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  17489. once.Do(func() {
  17490. if m.done {
  17491. err = errors.New("querying old values post mutation is not allowed")
  17492. } else {
  17493. value, err = m.Client().LabelTagging.Get(ctx, id)
  17494. }
  17495. })
  17496. return value, err
  17497. }
  17498. m.id = &id
  17499. }
  17500. }
  17501. // withLabelTagging sets the old LabelTagging of the mutation.
  17502. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  17503. return func(m *LabelTaggingMutation) {
  17504. m.oldValue = func(context.Context) (*LabelTagging, error) {
  17505. return node, nil
  17506. }
  17507. m.id = &node.ID
  17508. }
  17509. }
  17510. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17511. // executed in a transaction (ent.Tx), a transactional client is returned.
  17512. func (m LabelTaggingMutation) Client() *Client {
  17513. client := &Client{config: m.config}
  17514. client.init()
  17515. return client
  17516. }
  17517. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17518. // it returns an error otherwise.
  17519. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  17520. if _, ok := m.driver.(*txDriver); !ok {
  17521. return nil, errors.New("ent: mutation is not running in a transaction")
  17522. }
  17523. tx := &Tx{config: m.config}
  17524. tx.init()
  17525. return tx, nil
  17526. }
  17527. // SetID sets the value of the id field. Note that this
  17528. // operation is only accepted on creation of LabelTagging entities.
  17529. func (m *LabelTaggingMutation) SetID(id uint64) {
  17530. m.id = &id
  17531. }
  17532. // ID returns the ID value in the mutation. Note that the ID is only available
  17533. // if it was provided to the builder or after it was returned from the database.
  17534. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  17535. if m.id == nil {
  17536. return
  17537. }
  17538. return *m.id, true
  17539. }
  17540. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17541. // That means, if the mutation is applied within a transaction with an isolation level such
  17542. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17543. // or updated by the mutation.
  17544. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  17545. switch {
  17546. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17547. id, exists := m.ID()
  17548. if exists {
  17549. return []uint64{id}, nil
  17550. }
  17551. fallthrough
  17552. case m.op.Is(OpUpdate | OpDelete):
  17553. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  17554. default:
  17555. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17556. }
  17557. }
  17558. // SetCreatedAt sets the "created_at" field.
  17559. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  17560. m.created_at = &t
  17561. }
  17562. // CreatedAt returns the value of the "created_at" field in the mutation.
  17563. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  17564. v := m.created_at
  17565. if v == nil {
  17566. return
  17567. }
  17568. return *v, true
  17569. }
  17570. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  17571. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17573. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17574. if !m.op.Is(OpUpdateOne) {
  17575. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17576. }
  17577. if m.id == nil || m.oldValue == nil {
  17578. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17579. }
  17580. oldValue, err := m.oldValue(ctx)
  17581. if err != nil {
  17582. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17583. }
  17584. return oldValue.CreatedAt, nil
  17585. }
  17586. // ResetCreatedAt resets all changes to the "created_at" field.
  17587. func (m *LabelTaggingMutation) ResetCreatedAt() {
  17588. m.created_at = nil
  17589. }
  17590. // SetUpdatedAt sets the "updated_at" field.
  17591. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  17592. m.updated_at = &t
  17593. }
  17594. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17595. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  17596. v := m.updated_at
  17597. if v == nil {
  17598. return
  17599. }
  17600. return *v, true
  17601. }
  17602. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  17603. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17605. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17606. if !m.op.Is(OpUpdateOne) {
  17607. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17608. }
  17609. if m.id == nil || m.oldValue == nil {
  17610. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17611. }
  17612. oldValue, err := m.oldValue(ctx)
  17613. if err != nil {
  17614. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17615. }
  17616. return oldValue.UpdatedAt, nil
  17617. }
  17618. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17619. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  17620. m.updated_at = nil
  17621. }
  17622. // SetStatus sets the "status" field.
  17623. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  17624. m.status = &u
  17625. m.addstatus = nil
  17626. }
  17627. // Status returns the value of the "status" field in the mutation.
  17628. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  17629. v := m.status
  17630. if v == nil {
  17631. return
  17632. }
  17633. return *v, true
  17634. }
  17635. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  17636. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17638. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17639. if !m.op.Is(OpUpdateOne) {
  17640. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17641. }
  17642. if m.id == nil || m.oldValue == nil {
  17643. return v, errors.New("OldStatus requires an ID field in the mutation")
  17644. }
  17645. oldValue, err := m.oldValue(ctx)
  17646. if err != nil {
  17647. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17648. }
  17649. return oldValue.Status, nil
  17650. }
  17651. // AddStatus adds u to the "status" field.
  17652. func (m *LabelTaggingMutation) AddStatus(u int8) {
  17653. if m.addstatus != nil {
  17654. *m.addstatus += u
  17655. } else {
  17656. m.addstatus = &u
  17657. }
  17658. }
  17659. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17660. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  17661. v := m.addstatus
  17662. if v == nil {
  17663. return
  17664. }
  17665. return *v, true
  17666. }
  17667. // ClearStatus clears the value of the "status" field.
  17668. func (m *LabelTaggingMutation) ClearStatus() {
  17669. m.status = nil
  17670. m.addstatus = nil
  17671. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  17672. }
  17673. // StatusCleared returns if the "status" field was cleared in this mutation.
  17674. func (m *LabelTaggingMutation) StatusCleared() bool {
  17675. _, ok := m.clearedFields[labeltagging.FieldStatus]
  17676. return ok
  17677. }
  17678. // ResetStatus resets all changes to the "status" field.
  17679. func (m *LabelTaggingMutation) ResetStatus() {
  17680. m.status = nil
  17681. m.addstatus = nil
  17682. delete(m.clearedFields, labeltagging.FieldStatus)
  17683. }
  17684. // SetDeletedAt sets the "deleted_at" field.
  17685. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  17686. m.deleted_at = &t
  17687. }
  17688. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17689. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  17690. v := m.deleted_at
  17691. if v == nil {
  17692. return
  17693. }
  17694. return *v, true
  17695. }
  17696. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  17697. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17699. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17700. if !m.op.Is(OpUpdateOne) {
  17701. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17702. }
  17703. if m.id == nil || m.oldValue == nil {
  17704. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17705. }
  17706. oldValue, err := m.oldValue(ctx)
  17707. if err != nil {
  17708. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17709. }
  17710. return oldValue.DeletedAt, nil
  17711. }
  17712. // ClearDeletedAt clears the value of the "deleted_at" field.
  17713. func (m *LabelTaggingMutation) ClearDeletedAt() {
  17714. m.deleted_at = nil
  17715. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  17716. }
  17717. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17718. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  17719. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  17720. return ok
  17721. }
  17722. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17723. func (m *LabelTaggingMutation) ResetDeletedAt() {
  17724. m.deleted_at = nil
  17725. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  17726. }
  17727. // SetOrganizationID sets the "organization_id" field.
  17728. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  17729. m.organization_id = &u
  17730. m.addorganization_id = nil
  17731. }
  17732. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17733. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  17734. v := m.organization_id
  17735. if v == nil {
  17736. return
  17737. }
  17738. return *v, true
  17739. }
  17740. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  17741. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17743. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17744. if !m.op.Is(OpUpdateOne) {
  17745. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17746. }
  17747. if m.id == nil || m.oldValue == nil {
  17748. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17749. }
  17750. oldValue, err := m.oldValue(ctx)
  17751. if err != nil {
  17752. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17753. }
  17754. return oldValue.OrganizationID, nil
  17755. }
  17756. // AddOrganizationID adds u to the "organization_id" field.
  17757. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  17758. if m.addorganization_id != nil {
  17759. *m.addorganization_id += u
  17760. } else {
  17761. m.addorganization_id = &u
  17762. }
  17763. }
  17764. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17765. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  17766. v := m.addorganization_id
  17767. if v == nil {
  17768. return
  17769. }
  17770. return *v, true
  17771. }
  17772. // ResetOrganizationID resets all changes to the "organization_id" field.
  17773. func (m *LabelTaggingMutation) ResetOrganizationID() {
  17774. m.organization_id = nil
  17775. m.addorganization_id = nil
  17776. }
  17777. // SetType sets the "type" field.
  17778. func (m *LabelTaggingMutation) SetType(i int) {
  17779. m._type = &i
  17780. m.add_type = nil
  17781. }
  17782. // GetType returns the value of the "type" field in the mutation.
  17783. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  17784. v := m._type
  17785. if v == nil {
  17786. return
  17787. }
  17788. return *v, true
  17789. }
  17790. // OldType returns the old "type" field's value of the LabelTagging entity.
  17791. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17793. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  17794. if !m.op.Is(OpUpdateOne) {
  17795. return v, errors.New("OldType is only allowed on UpdateOne operations")
  17796. }
  17797. if m.id == nil || m.oldValue == nil {
  17798. return v, errors.New("OldType requires an ID field in the mutation")
  17799. }
  17800. oldValue, err := m.oldValue(ctx)
  17801. if err != nil {
  17802. return v, fmt.Errorf("querying old value for OldType: %w", err)
  17803. }
  17804. return oldValue.Type, nil
  17805. }
  17806. // AddType adds i to the "type" field.
  17807. func (m *LabelTaggingMutation) AddType(i int) {
  17808. if m.add_type != nil {
  17809. *m.add_type += i
  17810. } else {
  17811. m.add_type = &i
  17812. }
  17813. }
  17814. // AddedType returns the value that was added to the "type" field in this mutation.
  17815. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  17816. v := m.add_type
  17817. if v == nil {
  17818. return
  17819. }
  17820. return *v, true
  17821. }
  17822. // ResetType resets all changes to the "type" field.
  17823. func (m *LabelTaggingMutation) ResetType() {
  17824. m._type = nil
  17825. m.add_type = nil
  17826. }
  17827. // SetConditions sets the "conditions" field.
  17828. func (m *LabelTaggingMutation) SetConditions(s string) {
  17829. m.conditions = &s
  17830. }
  17831. // Conditions returns the value of the "conditions" field in the mutation.
  17832. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  17833. v := m.conditions
  17834. if v == nil {
  17835. return
  17836. }
  17837. return *v, true
  17838. }
  17839. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  17840. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17842. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  17843. if !m.op.Is(OpUpdateOne) {
  17844. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  17845. }
  17846. if m.id == nil || m.oldValue == nil {
  17847. return v, errors.New("OldConditions requires an ID field in the mutation")
  17848. }
  17849. oldValue, err := m.oldValue(ctx)
  17850. if err != nil {
  17851. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  17852. }
  17853. return oldValue.Conditions, nil
  17854. }
  17855. // ResetConditions resets all changes to the "conditions" field.
  17856. func (m *LabelTaggingMutation) ResetConditions() {
  17857. m.conditions = nil
  17858. }
  17859. // SetActionLabelAdd sets the "action_label_add" field.
  17860. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  17861. m.action_label_add = &u
  17862. m.appendaction_label_add = nil
  17863. }
  17864. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17865. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17866. v := m.action_label_add
  17867. if v == nil {
  17868. return
  17869. }
  17870. return *v, true
  17871. }
  17872. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  17873. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17875. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17876. if !m.op.Is(OpUpdateOne) {
  17877. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17878. }
  17879. if m.id == nil || m.oldValue == nil {
  17880. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17881. }
  17882. oldValue, err := m.oldValue(ctx)
  17883. if err != nil {
  17884. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17885. }
  17886. return oldValue.ActionLabelAdd, nil
  17887. }
  17888. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17889. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  17890. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17891. }
  17892. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17893. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17894. if len(m.appendaction_label_add) == 0 {
  17895. return nil, false
  17896. }
  17897. return m.appendaction_label_add, true
  17898. }
  17899. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17900. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  17901. m.action_label_add = nil
  17902. m.appendaction_label_add = nil
  17903. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  17904. }
  17905. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17906. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  17907. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  17908. return ok
  17909. }
  17910. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17911. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  17912. m.action_label_add = nil
  17913. m.appendaction_label_add = nil
  17914. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  17915. }
  17916. // SetActionLabelDel sets the "action_label_del" field.
  17917. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  17918. m.action_label_del = &u
  17919. m.appendaction_label_del = nil
  17920. }
  17921. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17922. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  17923. v := m.action_label_del
  17924. if v == nil {
  17925. return
  17926. }
  17927. return *v, true
  17928. }
  17929. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  17930. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17932. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17933. if !m.op.Is(OpUpdateOne) {
  17934. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17935. }
  17936. if m.id == nil || m.oldValue == nil {
  17937. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17938. }
  17939. oldValue, err := m.oldValue(ctx)
  17940. if err != nil {
  17941. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17942. }
  17943. return oldValue.ActionLabelDel, nil
  17944. }
  17945. // AppendActionLabelDel adds u to the "action_label_del" field.
  17946. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  17947. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  17948. }
  17949. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  17950. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  17951. if len(m.appendaction_label_del) == 0 {
  17952. return nil, false
  17953. }
  17954. return m.appendaction_label_del, true
  17955. }
  17956. // ClearActionLabelDel clears the value of the "action_label_del" field.
  17957. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  17958. m.action_label_del = nil
  17959. m.appendaction_label_del = nil
  17960. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  17961. }
  17962. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  17963. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  17964. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  17965. return ok
  17966. }
  17967. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  17968. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  17969. m.action_label_del = nil
  17970. m.appendaction_label_del = nil
  17971. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  17972. }
  17973. // Where appends a list predicates to the LabelTaggingMutation builder.
  17974. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  17975. m.predicates = append(m.predicates, ps...)
  17976. }
  17977. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  17978. // users can use type-assertion to append predicates that do not depend on any generated package.
  17979. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  17980. p := make([]predicate.LabelTagging, len(ps))
  17981. for i := range ps {
  17982. p[i] = ps[i]
  17983. }
  17984. m.Where(p...)
  17985. }
  17986. // Op returns the operation name.
  17987. func (m *LabelTaggingMutation) Op() Op {
  17988. return m.op
  17989. }
  17990. // SetOp allows setting the mutation operation.
  17991. func (m *LabelTaggingMutation) SetOp(op Op) {
  17992. m.op = op
  17993. }
  17994. // Type returns the node type of this mutation (LabelTagging).
  17995. func (m *LabelTaggingMutation) Type() string {
  17996. return m.typ
  17997. }
  17998. // Fields returns all fields that were changed during this mutation. Note that in
  17999. // order to get all numeric fields that were incremented/decremented, call
  18000. // AddedFields().
  18001. func (m *LabelTaggingMutation) Fields() []string {
  18002. fields := make([]string, 0, 9)
  18003. if m.created_at != nil {
  18004. fields = append(fields, labeltagging.FieldCreatedAt)
  18005. }
  18006. if m.updated_at != nil {
  18007. fields = append(fields, labeltagging.FieldUpdatedAt)
  18008. }
  18009. if m.status != nil {
  18010. fields = append(fields, labeltagging.FieldStatus)
  18011. }
  18012. if m.deleted_at != nil {
  18013. fields = append(fields, labeltagging.FieldDeletedAt)
  18014. }
  18015. if m.organization_id != nil {
  18016. fields = append(fields, labeltagging.FieldOrganizationID)
  18017. }
  18018. if m._type != nil {
  18019. fields = append(fields, labeltagging.FieldType)
  18020. }
  18021. if m.conditions != nil {
  18022. fields = append(fields, labeltagging.FieldConditions)
  18023. }
  18024. if m.action_label_add != nil {
  18025. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18026. }
  18027. if m.action_label_del != nil {
  18028. fields = append(fields, labeltagging.FieldActionLabelDel)
  18029. }
  18030. return fields
  18031. }
  18032. // Field returns the value of a field with the given name. The second boolean
  18033. // return value indicates that this field was not set, or was not defined in the
  18034. // schema.
  18035. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  18036. switch name {
  18037. case labeltagging.FieldCreatedAt:
  18038. return m.CreatedAt()
  18039. case labeltagging.FieldUpdatedAt:
  18040. return m.UpdatedAt()
  18041. case labeltagging.FieldStatus:
  18042. return m.Status()
  18043. case labeltagging.FieldDeletedAt:
  18044. return m.DeletedAt()
  18045. case labeltagging.FieldOrganizationID:
  18046. return m.OrganizationID()
  18047. case labeltagging.FieldType:
  18048. return m.GetType()
  18049. case labeltagging.FieldConditions:
  18050. return m.Conditions()
  18051. case labeltagging.FieldActionLabelAdd:
  18052. return m.ActionLabelAdd()
  18053. case labeltagging.FieldActionLabelDel:
  18054. return m.ActionLabelDel()
  18055. }
  18056. return nil, false
  18057. }
  18058. // OldField returns the old value of the field from the database. An error is
  18059. // returned if the mutation operation is not UpdateOne, or the query to the
  18060. // database failed.
  18061. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18062. switch name {
  18063. case labeltagging.FieldCreatedAt:
  18064. return m.OldCreatedAt(ctx)
  18065. case labeltagging.FieldUpdatedAt:
  18066. return m.OldUpdatedAt(ctx)
  18067. case labeltagging.FieldStatus:
  18068. return m.OldStatus(ctx)
  18069. case labeltagging.FieldDeletedAt:
  18070. return m.OldDeletedAt(ctx)
  18071. case labeltagging.FieldOrganizationID:
  18072. return m.OldOrganizationID(ctx)
  18073. case labeltagging.FieldType:
  18074. return m.OldType(ctx)
  18075. case labeltagging.FieldConditions:
  18076. return m.OldConditions(ctx)
  18077. case labeltagging.FieldActionLabelAdd:
  18078. return m.OldActionLabelAdd(ctx)
  18079. case labeltagging.FieldActionLabelDel:
  18080. return m.OldActionLabelDel(ctx)
  18081. }
  18082. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  18083. }
  18084. // SetField sets the value of a field with the given name. It returns an error if
  18085. // the field is not defined in the schema, or if the type mismatched the field
  18086. // type.
  18087. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  18088. switch name {
  18089. case labeltagging.FieldCreatedAt:
  18090. v, ok := value.(time.Time)
  18091. if !ok {
  18092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18093. }
  18094. m.SetCreatedAt(v)
  18095. return nil
  18096. case labeltagging.FieldUpdatedAt:
  18097. v, ok := value.(time.Time)
  18098. if !ok {
  18099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18100. }
  18101. m.SetUpdatedAt(v)
  18102. return nil
  18103. case labeltagging.FieldStatus:
  18104. v, ok := value.(uint8)
  18105. if !ok {
  18106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18107. }
  18108. m.SetStatus(v)
  18109. return nil
  18110. case labeltagging.FieldDeletedAt:
  18111. v, ok := value.(time.Time)
  18112. if !ok {
  18113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18114. }
  18115. m.SetDeletedAt(v)
  18116. return nil
  18117. case labeltagging.FieldOrganizationID:
  18118. v, ok := value.(uint64)
  18119. if !ok {
  18120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18121. }
  18122. m.SetOrganizationID(v)
  18123. return nil
  18124. case labeltagging.FieldType:
  18125. v, ok := value.(int)
  18126. if !ok {
  18127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18128. }
  18129. m.SetType(v)
  18130. return nil
  18131. case labeltagging.FieldConditions:
  18132. v, ok := value.(string)
  18133. if !ok {
  18134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18135. }
  18136. m.SetConditions(v)
  18137. return nil
  18138. case labeltagging.FieldActionLabelAdd:
  18139. v, ok := value.([]uint64)
  18140. if !ok {
  18141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18142. }
  18143. m.SetActionLabelAdd(v)
  18144. return nil
  18145. case labeltagging.FieldActionLabelDel:
  18146. v, ok := value.([]uint64)
  18147. if !ok {
  18148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18149. }
  18150. m.SetActionLabelDel(v)
  18151. return nil
  18152. }
  18153. return fmt.Errorf("unknown LabelTagging field %s", name)
  18154. }
  18155. // AddedFields returns all numeric fields that were incremented/decremented during
  18156. // this mutation.
  18157. func (m *LabelTaggingMutation) AddedFields() []string {
  18158. var fields []string
  18159. if m.addstatus != nil {
  18160. fields = append(fields, labeltagging.FieldStatus)
  18161. }
  18162. if m.addorganization_id != nil {
  18163. fields = append(fields, labeltagging.FieldOrganizationID)
  18164. }
  18165. if m.add_type != nil {
  18166. fields = append(fields, labeltagging.FieldType)
  18167. }
  18168. return fields
  18169. }
  18170. // AddedField returns the numeric value that was incremented/decremented on a field
  18171. // with the given name. The second boolean return value indicates that this field
  18172. // was not set, or was not defined in the schema.
  18173. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  18174. switch name {
  18175. case labeltagging.FieldStatus:
  18176. return m.AddedStatus()
  18177. case labeltagging.FieldOrganizationID:
  18178. return m.AddedOrganizationID()
  18179. case labeltagging.FieldType:
  18180. return m.AddedType()
  18181. }
  18182. return nil, false
  18183. }
  18184. // AddField adds the value to the field with the given name. It returns an error if
  18185. // the field is not defined in the schema, or if the type mismatched the field
  18186. // type.
  18187. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  18188. switch name {
  18189. case labeltagging.FieldStatus:
  18190. v, ok := value.(int8)
  18191. if !ok {
  18192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18193. }
  18194. m.AddStatus(v)
  18195. return nil
  18196. case labeltagging.FieldOrganizationID:
  18197. v, ok := value.(int64)
  18198. if !ok {
  18199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18200. }
  18201. m.AddOrganizationID(v)
  18202. return nil
  18203. case labeltagging.FieldType:
  18204. v, ok := value.(int)
  18205. if !ok {
  18206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18207. }
  18208. m.AddType(v)
  18209. return nil
  18210. }
  18211. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  18212. }
  18213. // ClearedFields returns all nullable fields that were cleared during this
  18214. // mutation.
  18215. func (m *LabelTaggingMutation) ClearedFields() []string {
  18216. var fields []string
  18217. if m.FieldCleared(labeltagging.FieldStatus) {
  18218. fields = append(fields, labeltagging.FieldStatus)
  18219. }
  18220. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  18221. fields = append(fields, labeltagging.FieldDeletedAt)
  18222. }
  18223. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  18224. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18225. }
  18226. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  18227. fields = append(fields, labeltagging.FieldActionLabelDel)
  18228. }
  18229. return fields
  18230. }
  18231. // FieldCleared returns a boolean indicating if a field with the given name was
  18232. // cleared in this mutation.
  18233. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  18234. _, ok := m.clearedFields[name]
  18235. return ok
  18236. }
  18237. // ClearField clears the value of the field with the given name. It returns an
  18238. // error if the field is not defined in the schema.
  18239. func (m *LabelTaggingMutation) ClearField(name string) error {
  18240. switch name {
  18241. case labeltagging.FieldStatus:
  18242. m.ClearStatus()
  18243. return nil
  18244. case labeltagging.FieldDeletedAt:
  18245. m.ClearDeletedAt()
  18246. return nil
  18247. case labeltagging.FieldActionLabelAdd:
  18248. m.ClearActionLabelAdd()
  18249. return nil
  18250. case labeltagging.FieldActionLabelDel:
  18251. m.ClearActionLabelDel()
  18252. return nil
  18253. }
  18254. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  18255. }
  18256. // ResetField resets all changes in the mutation for the field with the given name.
  18257. // It returns an error if the field is not defined in the schema.
  18258. func (m *LabelTaggingMutation) ResetField(name string) error {
  18259. switch name {
  18260. case labeltagging.FieldCreatedAt:
  18261. m.ResetCreatedAt()
  18262. return nil
  18263. case labeltagging.FieldUpdatedAt:
  18264. m.ResetUpdatedAt()
  18265. return nil
  18266. case labeltagging.FieldStatus:
  18267. m.ResetStatus()
  18268. return nil
  18269. case labeltagging.FieldDeletedAt:
  18270. m.ResetDeletedAt()
  18271. return nil
  18272. case labeltagging.FieldOrganizationID:
  18273. m.ResetOrganizationID()
  18274. return nil
  18275. case labeltagging.FieldType:
  18276. m.ResetType()
  18277. return nil
  18278. case labeltagging.FieldConditions:
  18279. m.ResetConditions()
  18280. return nil
  18281. case labeltagging.FieldActionLabelAdd:
  18282. m.ResetActionLabelAdd()
  18283. return nil
  18284. case labeltagging.FieldActionLabelDel:
  18285. m.ResetActionLabelDel()
  18286. return nil
  18287. }
  18288. return fmt.Errorf("unknown LabelTagging field %s", name)
  18289. }
  18290. // AddedEdges returns all edge names that were set/added in this mutation.
  18291. func (m *LabelTaggingMutation) AddedEdges() []string {
  18292. edges := make([]string, 0, 0)
  18293. return edges
  18294. }
  18295. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18296. // name in this mutation.
  18297. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  18298. return nil
  18299. }
  18300. // RemovedEdges returns all edge names that were removed in this mutation.
  18301. func (m *LabelTaggingMutation) RemovedEdges() []string {
  18302. edges := make([]string, 0, 0)
  18303. return edges
  18304. }
  18305. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18306. // the given name in this mutation.
  18307. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  18308. return nil
  18309. }
  18310. // ClearedEdges returns all edge names that were cleared in this mutation.
  18311. func (m *LabelTaggingMutation) ClearedEdges() []string {
  18312. edges := make([]string, 0, 0)
  18313. return edges
  18314. }
  18315. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18316. // was cleared in this mutation.
  18317. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  18318. return false
  18319. }
  18320. // ClearEdge clears the value of the edge with the given name. It returns an error
  18321. // if that edge is not defined in the schema.
  18322. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  18323. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  18324. }
  18325. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18326. // It returns an error if the edge is not defined in the schema.
  18327. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  18328. return fmt.Errorf("unknown LabelTagging edge %s", name)
  18329. }
  18330. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  18331. type MessageMutation struct {
  18332. config
  18333. op Op
  18334. typ string
  18335. id *int
  18336. wx_wxid *string
  18337. wxid *string
  18338. content *string
  18339. clearedFields map[string]struct{}
  18340. done bool
  18341. oldValue func(context.Context) (*Message, error)
  18342. predicates []predicate.Message
  18343. }
  18344. var _ ent.Mutation = (*MessageMutation)(nil)
  18345. // messageOption allows management of the mutation configuration using functional options.
  18346. type messageOption func(*MessageMutation)
  18347. // newMessageMutation creates new mutation for the Message entity.
  18348. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  18349. m := &MessageMutation{
  18350. config: c,
  18351. op: op,
  18352. typ: TypeMessage,
  18353. clearedFields: make(map[string]struct{}),
  18354. }
  18355. for _, opt := range opts {
  18356. opt(m)
  18357. }
  18358. return m
  18359. }
  18360. // withMessageID sets the ID field of the mutation.
  18361. func withMessageID(id int) messageOption {
  18362. return func(m *MessageMutation) {
  18363. var (
  18364. err error
  18365. once sync.Once
  18366. value *Message
  18367. )
  18368. m.oldValue = func(ctx context.Context) (*Message, error) {
  18369. once.Do(func() {
  18370. if m.done {
  18371. err = errors.New("querying old values post mutation is not allowed")
  18372. } else {
  18373. value, err = m.Client().Message.Get(ctx, id)
  18374. }
  18375. })
  18376. return value, err
  18377. }
  18378. m.id = &id
  18379. }
  18380. }
  18381. // withMessage sets the old Message of the mutation.
  18382. func withMessage(node *Message) messageOption {
  18383. return func(m *MessageMutation) {
  18384. m.oldValue = func(context.Context) (*Message, error) {
  18385. return node, nil
  18386. }
  18387. m.id = &node.ID
  18388. }
  18389. }
  18390. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18391. // executed in a transaction (ent.Tx), a transactional client is returned.
  18392. func (m MessageMutation) Client() *Client {
  18393. client := &Client{config: m.config}
  18394. client.init()
  18395. return client
  18396. }
  18397. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18398. // it returns an error otherwise.
  18399. func (m MessageMutation) Tx() (*Tx, error) {
  18400. if _, ok := m.driver.(*txDriver); !ok {
  18401. return nil, errors.New("ent: mutation is not running in a transaction")
  18402. }
  18403. tx := &Tx{config: m.config}
  18404. tx.init()
  18405. return tx, nil
  18406. }
  18407. // ID returns the ID value in the mutation. Note that the ID is only available
  18408. // if it was provided to the builder or after it was returned from the database.
  18409. func (m *MessageMutation) ID() (id int, exists bool) {
  18410. if m.id == nil {
  18411. return
  18412. }
  18413. return *m.id, true
  18414. }
  18415. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18416. // That means, if the mutation is applied within a transaction with an isolation level such
  18417. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18418. // or updated by the mutation.
  18419. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  18420. switch {
  18421. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18422. id, exists := m.ID()
  18423. if exists {
  18424. return []int{id}, nil
  18425. }
  18426. fallthrough
  18427. case m.op.Is(OpUpdate | OpDelete):
  18428. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  18429. default:
  18430. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18431. }
  18432. }
  18433. // SetWxWxid sets the "wx_wxid" field.
  18434. func (m *MessageMutation) SetWxWxid(s string) {
  18435. m.wx_wxid = &s
  18436. }
  18437. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  18438. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  18439. v := m.wx_wxid
  18440. if v == nil {
  18441. return
  18442. }
  18443. return *v, true
  18444. }
  18445. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  18446. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18448. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  18449. if !m.op.Is(OpUpdateOne) {
  18450. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  18451. }
  18452. if m.id == nil || m.oldValue == nil {
  18453. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  18454. }
  18455. oldValue, err := m.oldValue(ctx)
  18456. if err != nil {
  18457. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  18458. }
  18459. return oldValue.WxWxid, nil
  18460. }
  18461. // ClearWxWxid clears the value of the "wx_wxid" field.
  18462. func (m *MessageMutation) ClearWxWxid() {
  18463. m.wx_wxid = nil
  18464. m.clearedFields[message.FieldWxWxid] = struct{}{}
  18465. }
  18466. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  18467. func (m *MessageMutation) WxWxidCleared() bool {
  18468. _, ok := m.clearedFields[message.FieldWxWxid]
  18469. return ok
  18470. }
  18471. // ResetWxWxid resets all changes to the "wx_wxid" field.
  18472. func (m *MessageMutation) ResetWxWxid() {
  18473. m.wx_wxid = nil
  18474. delete(m.clearedFields, message.FieldWxWxid)
  18475. }
  18476. // SetWxid sets the "wxid" field.
  18477. func (m *MessageMutation) SetWxid(s string) {
  18478. m.wxid = &s
  18479. }
  18480. // Wxid returns the value of the "wxid" field in the mutation.
  18481. func (m *MessageMutation) Wxid() (r string, exists bool) {
  18482. v := m.wxid
  18483. if v == nil {
  18484. return
  18485. }
  18486. return *v, true
  18487. }
  18488. // OldWxid returns the old "wxid" field's value of the Message entity.
  18489. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18491. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  18492. if !m.op.Is(OpUpdateOne) {
  18493. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  18494. }
  18495. if m.id == nil || m.oldValue == nil {
  18496. return v, errors.New("OldWxid requires an ID field in the mutation")
  18497. }
  18498. oldValue, err := m.oldValue(ctx)
  18499. if err != nil {
  18500. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  18501. }
  18502. return oldValue.Wxid, nil
  18503. }
  18504. // ResetWxid resets all changes to the "wxid" field.
  18505. func (m *MessageMutation) ResetWxid() {
  18506. m.wxid = nil
  18507. }
  18508. // SetContent sets the "content" field.
  18509. func (m *MessageMutation) SetContent(s string) {
  18510. m.content = &s
  18511. }
  18512. // Content returns the value of the "content" field in the mutation.
  18513. func (m *MessageMutation) Content() (r string, exists bool) {
  18514. v := m.content
  18515. if v == nil {
  18516. return
  18517. }
  18518. return *v, true
  18519. }
  18520. // OldContent returns the old "content" field's value of the Message entity.
  18521. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18523. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  18524. if !m.op.Is(OpUpdateOne) {
  18525. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18526. }
  18527. if m.id == nil || m.oldValue == nil {
  18528. return v, errors.New("OldContent requires an ID field in the mutation")
  18529. }
  18530. oldValue, err := m.oldValue(ctx)
  18531. if err != nil {
  18532. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18533. }
  18534. return oldValue.Content, nil
  18535. }
  18536. // ResetContent resets all changes to the "content" field.
  18537. func (m *MessageMutation) ResetContent() {
  18538. m.content = nil
  18539. }
  18540. // Where appends a list predicates to the MessageMutation builder.
  18541. func (m *MessageMutation) Where(ps ...predicate.Message) {
  18542. m.predicates = append(m.predicates, ps...)
  18543. }
  18544. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  18545. // users can use type-assertion to append predicates that do not depend on any generated package.
  18546. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  18547. p := make([]predicate.Message, len(ps))
  18548. for i := range ps {
  18549. p[i] = ps[i]
  18550. }
  18551. m.Where(p...)
  18552. }
  18553. // Op returns the operation name.
  18554. func (m *MessageMutation) Op() Op {
  18555. return m.op
  18556. }
  18557. // SetOp allows setting the mutation operation.
  18558. func (m *MessageMutation) SetOp(op Op) {
  18559. m.op = op
  18560. }
  18561. // Type returns the node type of this mutation (Message).
  18562. func (m *MessageMutation) Type() string {
  18563. return m.typ
  18564. }
  18565. // Fields returns all fields that were changed during this mutation. Note that in
  18566. // order to get all numeric fields that were incremented/decremented, call
  18567. // AddedFields().
  18568. func (m *MessageMutation) Fields() []string {
  18569. fields := make([]string, 0, 3)
  18570. if m.wx_wxid != nil {
  18571. fields = append(fields, message.FieldWxWxid)
  18572. }
  18573. if m.wxid != nil {
  18574. fields = append(fields, message.FieldWxid)
  18575. }
  18576. if m.content != nil {
  18577. fields = append(fields, message.FieldContent)
  18578. }
  18579. return fields
  18580. }
  18581. // Field returns the value of a field with the given name. The second boolean
  18582. // return value indicates that this field was not set, or was not defined in the
  18583. // schema.
  18584. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  18585. switch name {
  18586. case message.FieldWxWxid:
  18587. return m.WxWxid()
  18588. case message.FieldWxid:
  18589. return m.Wxid()
  18590. case message.FieldContent:
  18591. return m.Content()
  18592. }
  18593. return nil, false
  18594. }
  18595. // OldField returns the old value of the field from the database. An error is
  18596. // returned if the mutation operation is not UpdateOne, or the query to the
  18597. // database failed.
  18598. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18599. switch name {
  18600. case message.FieldWxWxid:
  18601. return m.OldWxWxid(ctx)
  18602. case message.FieldWxid:
  18603. return m.OldWxid(ctx)
  18604. case message.FieldContent:
  18605. return m.OldContent(ctx)
  18606. }
  18607. return nil, fmt.Errorf("unknown Message field %s", name)
  18608. }
  18609. // SetField sets the value of a field with the given name. It returns an error if
  18610. // the field is not defined in the schema, or if the type mismatched the field
  18611. // type.
  18612. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  18613. switch name {
  18614. case message.FieldWxWxid:
  18615. v, ok := value.(string)
  18616. if !ok {
  18617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18618. }
  18619. m.SetWxWxid(v)
  18620. return nil
  18621. case message.FieldWxid:
  18622. v, ok := value.(string)
  18623. if !ok {
  18624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18625. }
  18626. m.SetWxid(v)
  18627. return nil
  18628. case message.FieldContent:
  18629. v, ok := value.(string)
  18630. if !ok {
  18631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18632. }
  18633. m.SetContent(v)
  18634. return nil
  18635. }
  18636. return fmt.Errorf("unknown Message field %s", name)
  18637. }
  18638. // AddedFields returns all numeric fields that were incremented/decremented during
  18639. // this mutation.
  18640. func (m *MessageMutation) AddedFields() []string {
  18641. return nil
  18642. }
  18643. // AddedField returns the numeric value that was incremented/decremented on a field
  18644. // with the given name. The second boolean return value indicates that this field
  18645. // was not set, or was not defined in the schema.
  18646. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  18647. return nil, false
  18648. }
  18649. // AddField adds the value to the field with the given name. It returns an error if
  18650. // the field is not defined in the schema, or if the type mismatched the field
  18651. // type.
  18652. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  18653. switch name {
  18654. }
  18655. return fmt.Errorf("unknown Message numeric field %s", name)
  18656. }
  18657. // ClearedFields returns all nullable fields that were cleared during this
  18658. // mutation.
  18659. func (m *MessageMutation) ClearedFields() []string {
  18660. var fields []string
  18661. if m.FieldCleared(message.FieldWxWxid) {
  18662. fields = append(fields, message.FieldWxWxid)
  18663. }
  18664. return fields
  18665. }
  18666. // FieldCleared returns a boolean indicating if a field with the given name was
  18667. // cleared in this mutation.
  18668. func (m *MessageMutation) FieldCleared(name string) bool {
  18669. _, ok := m.clearedFields[name]
  18670. return ok
  18671. }
  18672. // ClearField clears the value of the field with the given name. It returns an
  18673. // error if the field is not defined in the schema.
  18674. func (m *MessageMutation) ClearField(name string) error {
  18675. switch name {
  18676. case message.FieldWxWxid:
  18677. m.ClearWxWxid()
  18678. return nil
  18679. }
  18680. return fmt.Errorf("unknown Message nullable field %s", name)
  18681. }
  18682. // ResetField resets all changes in the mutation for the field with the given name.
  18683. // It returns an error if the field is not defined in the schema.
  18684. func (m *MessageMutation) ResetField(name string) error {
  18685. switch name {
  18686. case message.FieldWxWxid:
  18687. m.ResetWxWxid()
  18688. return nil
  18689. case message.FieldWxid:
  18690. m.ResetWxid()
  18691. return nil
  18692. case message.FieldContent:
  18693. m.ResetContent()
  18694. return nil
  18695. }
  18696. return fmt.Errorf("unknown Message field %s", name)
  18697. }
  18698. // AddedEdges returns all edge names that were set/added in this mutation.
  18699. func (m *MessageMutation) AddedEdges() []string {
  18700. edges := make([]string, 0, 0)
  18701. return edges
  18702. }
  18703. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18704. // name in this mutation.
  18705. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  18706. return nil
  18707. }
  18708. // RemovedEdges returns all edge names that were removed in this mutation.
  18709. func (m *MessageMutation) RemovedEdges() []string {
  18710. edges := make([]string, 0, 0)
  18711. return edges
  18712. }
  18713. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18714. // the given name in this mutation.
  18715. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  18716. return nil
  18717. }
  18718. // ClearedEdges returns all edge names that were cleared in this mutation.
  18719. func (m *MessageMutation) ClearedEdges() []string {
  18720. edges := make([]string, 0, 0)
  18721. return edges
  18722. }
  18723. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18724. // was cleared in this mutation.
  18725. func (m *MessageMutation) EdgeCleared(name string) bool {
  18726. return false
  18727. }
  18728. // ClearEdge clears the value of the edge with the given name. It returns an error
  18729. // if that edge is not defined in the schema.
  18730. func (m *MessageMutation) ClearEdge(name string) error {
  18731. return fmt.Errorf("unknown Message unique edge %s", name)
  18732. }
  18733. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18734. // It returns an error if the edge is not defined in the schema.
  18735. func (m *MessageMutation) ResetEdge(name string) error {
  18736. return fmt.Errorf("unknown Message edge %s", name)
  18737. }
  18738. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  18739. type MessageRecordsMutation struct {
  18740. config
  18741. op Op
  18742. typ string
  18743. id *uint64
  18744. created_at *time.Time
  18745. updated_at *time.Time
  18746. status *uint8
  18747. addstatus *int8
  18748. bot_wxid *string
  18749. contact_type *int
  18750. addcontact_type *int
  18751. contact_wxid *string
  18752. content_type *int
  18753. addcontent_type *int
  18754. content *string
  18755. meta *custom_types.Meta
  18756. error_detail *string
  18757. send_time *time.Time
  18758. source_type *int
  18759. addsource_type *int
  18760. organization_id *uint64
  18761. addorganization_id *int64
  18762. clearedFields map[string]struct{}
  18763. sop_stage *uint64
  18764. clearedsop_stage bool
  18765. sop_node *uint64
  18766. clearedsop_node bool
  18767. message_contact *uint64
  18768. clearedmessage_contact bool
  18769. done bool
  18770. oldValue func(context.Context) (*MessageRecords, error)
  18771. predicates []predicate.MessageRecords
  18772. }
  18773. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  18774. // messagerecordsOption allows management of the mutation configuration using functional options.
  18775. type messagerecordsOption func(*MessageRecordsMutation)
  18776. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  18777. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  18778. m := &MessageRecordsMutation{
  18779. config: c,
  18780. op: op,
  18781. typ: TypeMessageRecords,
  18782. clearedFields: make(map[string]struct{}),
  18783. }
  18784. for _, opt := range opts {
  18785. opt(m)
  18786. }
  18787. return m
  18788. }
  18789. // withMessageRecordsID sets the ID field of the mutation.
  18790. func withMessageRecordsID(id uint64) messagerecordsOption {
  18791. return func(m *MessageRecordsMutation) {
  18792. var (
  18793. err error
  18794. once sync.Once
  18795. value *MessageRecords
  18796. )
  18797. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  18798. once.Do(func() {
  18799. if m.done {
  18800. err = errors.New("querying old values post mutation is not allowed")
  18801. } else {
  18802. value, err = m.Client().MessageRecords.Get(ctx, id)
  18803. }
  18804. })
  18805. return value, err
  18806. }
  18807. m.id = &id
  18808. }
  18809. }
  18810. // withMessageRecords sets the old MessageRecords of the mutation.
  18811. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  18812. return func(m *MessageRecordsMutation) {
  18813. m.oldValue = func(context.Context) (*MessageRecords, error) {
  18814. return node, nil
  18815. }
  18816. m.id = &node.ID
  18817. }
  18818. }
  18819. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18820. // executed in a transaction (ent.Tx), a transactional client is returned.
  18821. func (m MessageRecordsMutation) Client() *Client {
  18822. client := &Client{config: m.config}
  18823. client.init()
  18824. return client
  18825. }
  18826. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18827. // it returns an error otherwise.
  18828. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  18829. if _, ok := m.driver.(*txDriver); !ok {
  18830. return nil, errors.New("ent: mutation is not running in a transaction")
  18831. }
  18832. tx := &Tx{config: m.config}
  18833. tx.init()
  18834. return tx, nil
  18835. }
  18836. // SetID sets the value of the id field. Note that this
  18837. // operation is only accepted on creation of MessageRecords entities.
  18838. func (m *MessageRecordsMutation) SetID(id uint64) {
  18839. m.id = &id
  18840. }
  18841. // ID returns the ID value in the mutation. Note that the ID is only available
  18842. // if it was provided to the builder or after it was returned from the database.
  18843. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  18844. if m.id == nil {
  18845. return
  18846. }
  18847. return *m.id, true
  18848. }
  18849. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18850. // That means, if the mutation is applied within a transaction with an isolation level such
  18851. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18852. // or updated by the mutation.
  18853. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  18854. switch {
  18855. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18856. id, exists := m.ID()
  18857. if exists {
  18858. return []uint64{id}, nil
  18859. }
  18860. fallthrough
  18861. case m.op.Is(OpUpdate | OpDelete):
  18862. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  18863. default:
  18864. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18865. }
  18866. }
  18867. // SetCreatedAt sets the "created_at" field.
  18868. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  18869. m.created_at = &t
  18870. }
  18871. // CreatedAt returns the value of the "created_at" field in the mutation.
  18872. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  18873. v := m.created_at
  18874. if v == nil {
  18875. return
  18876. }
  18877. return *v, true
  18878. }
  18879. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  18880. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18882. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18883. if !m.op.Is(OpUpdateOne) {
  18884. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18885. }
  18886. if m.id == nil || m.oldValue == nil {
  18887. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18888. }
  18889. oldValue, err := m.oldValue(ctx)
  18890. if err != nil {
  18891. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18892. }
  18893. return oldValue.CreatedAt, nil
  18894. }
  18895. // ResetCreatedAt resets all changes to the "created_at" field.
  18896. func (m *MessageRecordsMutation) ResetCreatedAt() {
  18897. m.created_at = nil
  18898. }
  18899. // SetUpdatedAt sets the "updated_at" field.
  18900. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  18901. m.updated_at = &t
  18902. }
  18903. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18904. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  18905. v := m.updated_at
  18906. if v == nil {
  18907. return
  18908. }
  18909. return *v, true
  18910. }
  18911. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  18912. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18914. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18915. if !m.op.Is(OpUpdateOne) {
  18916. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18917. }
  18918. if m.id == nil || m.oldValue == nil {
  18919. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18920. }
  18921. oldValue, err := m.oldValue(ctx)
  18922. if err != nil {
  18923. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18924. }
  18925. return oldValue.UpdatedAt, nil
  18926. }
  18927. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18928. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  18929. m.updated_at = nil
  18930. }
  18931. // SetStatus sets the "status" field.
  18932. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  18933. m.status = &u
  18934. m.addstatus = nil
  18935. }
  18936. // Status returns the value of the "status" field in the mutation.
  18937. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  18938. v := m.status
  18939. if v == nil {
  18940. return
  18941. }
  18942. return *v, true
  18943. }
  18944. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  18945. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18947. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18948. if !m.op.Is(OpUpdateOne) {
  18949. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18950. }
  18951. if m.id == nil || m.oldValue == nil {
  18952. return v, errors.New("OldStatus requires an ID field in the mutation")
  18953. }
  18954. oldValue, err := m.oldValue(ctx)
  18955. if err != nil {
  18956. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18957. }
  18958. return oldValue.Status, nil
  18959. }
  18960. // AddStatus adds u to the "status" field.
  18961. func (m *MessageRecordsMutation) AddStatus(u int8) {
  18962. if m.addstatus != nil {
  18963. *m.addstatus += u
  18964. } else {
  18965. m.addstatus = &u
  18966. }
  18967. }
  18968. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18969. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  18970. v := m.addstatus
  18971. if v == nil {
  18972. return
  18973. }
  18974. return *v, true
  18975. }
  18976. // ClearStatus clears the value of the "status" field.
  18977. func (m *MessageRecordsMutation) ClearStatus() {
  18978. m.status = nil
  18979. m.addstatus = nil
  18980. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  18981. }
  18982. // StatusCleared returns if the "status" field was cleared in this mutation.
  18983. func (m *MessageRecordsMutation) StatusCleared() bool {
  18984. _, ok := m.clearedFields[messagerecords.FieldStatus]
  18985. return ok
  18986. }
  18987. // ResetStatus resets all changes to the "status" field.
  18988. func (m *MessageRecordsMutation) ResetStatus() {
  18989. m.status = nil
  18990. m.addstatus = nil
  18991. delete(m.clearedFields, messagerecords.FieldStatus)
  18992. }
  18993. // SetBotWxid sets the "bot_wxid" field.
  18994. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  18995. m.bot_wxid = &s
  18996. }
  18997. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  18998. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  18999. v := m.bot_wxid
  19000. if v == nil {
  19001. return
  19002. }
  19003. return *v, true
  19004. }
  19005. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  19006. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19008. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  19009. if !m.op.Is(OpUpdateOne) {
  19010. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  19011. }
  19012. if m.id == nil || m.oldValue == nil {
  19013. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  19014. }
  19015. oldValue, err := m.oldValue(ctx)
  19016. if err != nil {
  19017. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  19018. }
  19019. return oldValue.BotWxid, nil
  19020. }
  19021. // ResetBotWxid resets all changes to the "bot_wxid" field.
  19022. func (m *MessageRecordsMutation) ResetBotWxid() {
  19023. m.bot_wxid = nil
  19024. }
  19025. // SetContactID sets the "contact_id" field.
  19026. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  19027. m.message_contact = &u
  19028. }
  19029. // ContactID returns the value of the "contact_id" field in the mutation.
  19030. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  19031. v := m.message_contact
  19032. if v == nil {
  19033. return
  19034. }
  19035. return *v, true
  19036. }
  19037. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  19038. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19040. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  19041. if !m.op.Is(OpUpdateOne) {
  19042. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  19043. }
  19044. if m.id == nil || m.oldValue == nil {
  19045. return v, errors.New("OldContactID requires an ID field in the mutation")
  19046. }
  19047. oldValue, err := m.oldValue(ctx)
  19048. if err != nil {
  19049. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  19050. }
  19051. return oldValue.ContactID, nil
  19052. }
  19053. // ClearContactID clears the value of the "contact_id" field.
  19054. func (m *MessageRecordsMutation) ClearContactID() {
  19055. m.message_contact = nil
  19056. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19057. }
  19058. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  19059. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  19060. _, ok := m.clearedFields[messagerecords.FieldContactID]
  19061. return ok
  19062. }
  19063. // ResetContactID resets all changes to the "contact_id" field.
  19064. func (m *MessageRecordsMutation) ResetContactID() {
  19065. m.message_contact = nil
  19066. delete(m.clearedFields, messagerecords.FieldContactID)
  19067. }
  19068. // SetContactType sets the "contact_type" field.
  19069. func (m *MessageRecordsMutation) SetContactType(i int) {
  19070. m.contact_type = &i
  19071. m.addcontact_type = nil
  19072. }
  19073. // ContactType returns the value of the "contact_type" field in the mutation.
  19074. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  19075. v := m.contact_type
  19076. if v == nil {
  19077. return
  19078. }
  19079. return *v, true
  19080. }
  19081. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  19082. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19084. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  19085. if !m.op.Is(OpUpdateOne) {
  19086. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  19087. }
  19088. if m.id == nil || m.oldValue == nil {
  19089. return v, errors.New("OldContactType requires an ID field in the mutation")
  19090. }
  19091. oldValue, err := m.oldValue(ctx)
  19092. if err != nil {
  19093. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  19094. }
  19095. return oldValue.ContactType, nil
  19096. }
  19097. // AddContactType adds i to the "contact_type" field.
  19098. func (m *MessageRecordsMutation) AddContactType(i int) {
  19099. if m.addcontact_type != nil {
  19100. *m.addcontact_type += i
  19101. } else {
  19102. m.addcontact_type = &i
  19103. }
  19104. }
  19105. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  19106. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  19107. v := m.addcontact_type
  19108. if v == nil {
  19109. return
  19110. }
  19111. return *v, true
  19112. }
  19113. // ResetContactType resets all changes to the "contact_type" field.
  19114. func (m *MessageRecordsMutation) ResetContactType() {
  19115. m.contact_type = nil
  19116. m.addcontact_type = nil
  19117. }
  19118. // SetContactWxid sets the "contact_wxid" field.
  19119. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  19120. m.contact_wxid = &s
  19121. }
  19122. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  19123. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  19124. v := m.contact_wxid
  19125. if v == nil {
  19126. return
  19127. }
  19128. return *v, true
  19129. }
  19130. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  19131. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19133. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  19134. if !m.op.Is(OpUpdateOne) {
  19135. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  19136. }
  19137. if m.id == nil || m.oldValue == nil {
  19138. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  19139. }
  19140. oldValue, err := m.oldValue(ctx)
  19141. if err != nil {
  19142. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  19143. }
  19144. return oldValue.ContactWxid, nil
  19145. }
  19146. // ResetContactWxid resets all changes to the "contact_wxid" field.
  19147. func (m *MessageRecordsMutation) ResetContactWxid() {
  19148. m.contact_wxid = nil
  19149. }
  19150. // SetContentType sets the "content_type" field.
  19151. func (m *MessageRecordsMutation) SetContentType(i int) {
  19152. m.content_type = &i
  19153. m.addcontent_type = nil
  19154. }
  19155. // ContentType returns the value of the "content_type" field in the mutation.
  19156. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  19157. v := m.content_type
  19158. if v == nil {
  19159. return
  19160. }
  19161. return *v, true
  19162. }
  19163. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  19164. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19166. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  19167. if !m.op.Is(OpUpdateOne) {
  19168. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  19169. }
  19170. if m.id == nil || m.oldValue == nil {
  19171. return v, errors.New("OldContentType requires an ID field in the mutation")
  19172. }
  19173. oldValue, err := m.oldValue(ctx)
  19174. if err != nil {
  19175. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  19176. }
  19177. return oldValue.ContentType, nil
  19178. }
  19179. // AddContentType adds i to the "content_type" field.
  19180. func (m *MessageRecordsMutation) AddContentType(i int) {
  19181. if m.addcontent_type != nil {
  19182. *m.addcontent_type += i
  19183. } else {
  19184. m.addcontent_type = &i
  19185. }
  19186. }
  19187. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  19188. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  19189. v := m.addcontent_type
  19190. if v == nil {
  19191. return
  19192. }
  19193. return *v, true
  19194. }
  19195. // ResetContentType resets all changes to the "content_type" field.
  19196. func (m *MessageRecordsMutation) ResetContentType() {
  19197. m.content_type = nil
  19198. m.addcontent_type = nil
  19199. }
  19200. // SetContent sets the "content" field.
  19201. func (m *MessageRecordsMutation) SetContent(s string) {
  19202. m.content = &s
  19203. }
  19204. // Content returns the value of the "content" field in the mutation.
  19205. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  19206. v := m.content
  19207. if v == nil {
  19208. return
  19209. }
  19210. return *v, true
  19211. }
  19212. // OldContent returns the old "content" field's value of the MessageRecords entity.
  19213. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19215. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  19216. if !m.op.Is(OpUpdateOne) {
  19217. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  19218. }
  19219. if m.id == nil || m.oldValue == nil {
  19220. return v, errors.New("OldContent requires an ID field in the mutation")
  19221. }
  19222. oldValue, err := m.oldValue(ctx)
  19223. if err != nil {
  19224. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  19225. }
  19226. return oldValue.Content, nil
  19227. }
  19228. // ResetContent resets all changes to the "content" field.
  19229. func (m *MessageRecordsMutation) ResetContent() {
  19230. m.content = nil
  19231. }
  19232. // SetMeta sets the "meta" field.
  19233. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  19234. m.meta = &ct
  19235. }
  19236. // Meta returns the value of the "meta" field in the mutation.
  19237. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  19238. v := m.meta
  19239. if v == nil {
  19240. return
  19241. }
  19242. return *v, true
  19243. }
  19244. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  19245. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19247. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  19248. if !m.op.Is(OpUpdateOne) {
  19249. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  19250. }
  19251. if m.id == nil || m.oldValue == nil {
  19252. return v, errors.New("OldMeta requires an ID field in the mutation")
  19253. }
  19254. oldValue, err := m.oldValue(ctx)
  19255. if err != nil {
  19256. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  19257. }
  19258. return oldValue.Meta, nil
  19259. }
  19260. // ClearMeta clears the value of the "meta" field.
  19261. func (m *MessageRecordsMutation) ClearMeta() {
  19262. m.meta = nil
  19263. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  19264. }
  19265. // MetaCleared returns if the "meta" field was cleared in this mutation.
  19266. func (m *MessageRecordsMutation) MetaCleared() bool {
  19267. _, ok := m.clearedFields[messagerecords.FieldMeta]
  19268. return ok
  19269. }
  19270. // ResetMeta resets all changes to the "meta" field.
  19271. func (m *MessageRecordsMutation) ResetMeta() {
  19272. m.meta = nil
  19273. delete(m.clearedFields, messagerecords.FieldMeta)
  19274. }
  19275. // SetErrorDetail sets the "error_detail" field.
  19276. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  19277. m.error_detail = &s
  19278. }
  19279. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  19280. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  19281. v := m.error_detail
  19282. if v == nil {
  19283. return
  19284. }
  19285. return *v, true
  19286. }
  19287. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  19288. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19290. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  19291. if !m.op.Is(OpUpdateOne) {
  19292. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  19293. }
  19294. if m.id == nil || m.oldValue == nil {
  19295. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  19296. }
  19297. oldValue, err := m.oldValue(ctx)
  19298. if err != nil {
  19299. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  19300. }
  19301. return oldValue.ErrorDetail, nil
  19302. }
  19303. // ResetErrorDetail resets all changes to the "error_detail" field.
  19304. func (m *MessageRecordsMutation) ResetErrorDetail() {
  19305. m.error_detail = nil
  19306. }
  19307. // SetSendTime sets the "send_time" field.
  19308. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  19309. m.send_time = &t
  19310. }
  19311. // SendTime returns the value of the "send_time" field in the mutation.
  19312. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  19313. v := m.send_time
  19314. if v == nil {
  19315. return
  19316. }
  19317. return *v, true
  19318. }
  19319. // OldSendTime returns the old "send_time" 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) OldSendTime(ctx context.Context) (v time.Time, err error) {
  19323. if !m.op.Is(OpUpdateOne) {
  19324. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  19325. }
  19326. if m.id == nil || m.oldValue == nil {
  19327. return v, errors.New("OldSendTime 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 OldSendTime: %w", err)
  19332. }
  19333. return oldValue.SendTime, nil
  19334. }
  19335. // ClearSendTime clears the value of the "send_time" field.
  19336. func (m *MessageRecordsMutation) ClearSendTime() {
  19337. m.send_time = nil
  19338. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  19339. }
  19340. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  19341. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  19342. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  19343. return ok
  19344. }
  19345. // ResetSendTime resets all changes to the "send_time" field.
  19346. func (m *MessageRecordsMutation) ResetSendTime() {
  19347. m.send_time = nil
  19348. delete(m.clearedFields, messagerecords.FieldSendTime)
  19349. }
  19350. // SetSourceType sets the "source_type" field.
  19351. func (m *MessageRecordsMutation) SetSourceType(i int) {
  19352. m.source_type = &i
  19353. m.addsource_type = nil
  19354. }
  19355. // SourceType returns the value of the "source_type" field in the mutation.
  19356. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  19357. v := m.source_type
  19358. if v == nil {
  19359. return
  19360. }
  19361. return *v, true
  19362. }
  19363. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  19364. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19366. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  19367. if !m.op.Is(OpUpdateOne) {
  19368. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  19369. }
  19370. if m.id == nil || m.oldValue == nil {
  19371. return v, errors.New("OldSourceType requires an ID field in the mutation")
  19372. }
  19373. oldValue, err := m.oldValue(ctx)
  19374. if err != nil {
  19375. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  19376. }
  19377. return oldValue.SourceType, nil
  19378. }
  19379. // AddSourceType adds i to the "source_type" field.
  19380. func (m *MessageRecordsMutation) AddSourceType(i int) {
  19381. if m.addsource_type != nil {
  19382. *m.addsource_type += i
  19383. } else {
  19384. m.addsource_type = &i
  19385. }
  19386. }
  19387. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  19388. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  19389. v := m.addsource_type
  19390. if v == nil {
  19391. return
  19392. }
  19393. return *v, true
  19394. }
  19395. // ResetSourceType resets all changes to the "source_type" field.
  19396. func (m *MessageRecordsMutation) ResetSourceType() {
  19397. m.source_type = nil
  19398. m.addsource_type = nil
  19399. }
  19400. // SetSourceID sets the "source_id" field.
  19401. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  19402. m.sop_stage = &u
  19403. }
  19404. // SourceID returns the value of the "source_id" field in the mutation.
  19405. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  19406. v := m.sop_stage
  19407. if v == nil {
  19408. return
  19409. }
  19410. return *v, true
  19411. }
  19412. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  19413. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19415. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  19416. if !m.op.Is(OpUpdateOne) {
  19417. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  19418. }
  19419. if m.id == nil || m.oldValue == nil {
  19420. return v, errors.New("OldSourceID requires an ID field in the mutation")
  19421. }
  19422. oldValue, err := m.oldValue(ctx)
  19423. if err != nil {
  19424. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  19425. }
  19426. return oldValue.SourceID, nil
  19427. }
  19428. // ClearSourceID clears the value of the "source_id" field.
  19429. func (m *MessageRecordsMutation) ClearSourceID() {
  19430. m.sop_stage = nil
  19431. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19432. }
  19433. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  19434. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  19435. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  19436. return ok
  19437. }
  19438. // ResetSourceID resets all changes to the "source_id" field.
  19439. func (m *MessageRecordsMutation) ResetSourceID() {
  19440. m.sop_stage = nil
  19441. delete(m.clearedFields, messagerecords.FieldSourceID)
  19442. }
  19443. // SetSubSourceID sets the "sub_source_id" field.
  19444. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  19445. m.sop_node = &u
  19446. }
  19447. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  19448. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  19449. v := m.sop_node
  19450. if v == nil {
  19451. return
  19452. }
  19453. return *v, true
  19454. }
  19455. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  19456. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19458. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  19459. if !m.op.Is(OpUpdateOne) {
  19460. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  19461. }
  19462. if m.id == nil || m.oldValue == nil {
  19463. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  19464. }
  19465. oldValue, err := m.oldValue(ctx)
  19466. if err != nil {
  19467. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  19468. }
  19469. return oldValue.SubSourceID, nil
  19470. }
  19471. // ClearSubSourceID clears the value of the "sub_source_id" field.
  19472. func (m *MessageRecordsMutation) ClearSubSourceID() {
  19473. m.sop_node = nil
  19474. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19475. }
  19476. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  19477. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  19478. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  19479. return ok
  19480. }
  19481. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  19482. func (m *MessageRecordsMutation) ResetSubSourceID() {
  19483. m.sop_node = nil
  19484. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  19485. }
  19486. // SetOrganizationID sets the "organization_id" field.
  19487. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  19488. m.organization_id = &u
  19489. m.addorganization_id = nil
  19490. }
  19491. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19492. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  19493. v := m.organization_id
  19494. if v == nil {
  19495. return
  19496. }
  19497. return *v, true
  19498. }
  19499. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  19500. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19502. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19503. if !m.op.Is(OpUpdateOne) {
  19504. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19505. }
  19506. if m.id == nil || m.oldValue == nil {
  19507. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19508. }
  19509. oldValue, err := m.oldValue(ctx)
  19510. if err != nil {
  19511. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19512. }
  19513. return oldValue.OrganizationID, nil
  19514. }
  19515. // AddOrganizationID adds u to the "organization_id" field.
  19516. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  19517. if m.addorganization_id != nil {
  19518. *m.addorganization_id += u
  19519. } else {
  19520. m.addorganization_id = &u
  19521. }
  19522. }
  19523. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19524. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  19525. v := m.addorganization_id
  19526. if v == nil {
  19527. return
  19528. }
  19529. return *v, true
  19530. }
  19531. // ClearOrganizationID clears the value of the "organization_id" field.
  19532. func (m *MessageRecordsMutation) ClearOrganizationID() {
  19533. m.organization_id = nil
  19534. m.addorganization_id = nil
  19535. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  19536. }
  19537. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19538. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  19539. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  19540. return ok
  19541. }
  19542. // ResetOrganizationID resets all changes to the "organization_id" field.
  19543. func (m *MessageRecordsMutation) ResetOrganizationID() {
  19544. m.organization_id = nil
  19545. m.addorganization_id = nil
  19546. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  19547. }
  19548. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  19549. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  19550. m.sop_stage = &id
  19551. }
  19552. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  19553. func (m *MessageRecordsMutation) ClearSopStage() {
  19554. m.clearedsop_stage = true
  19555. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19556. }
  19557. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  19558. func (m *MessageRecordsMutation) SopStageCleared() bool {
  19559. return m.SourceIDCleared() || m.clearedsop_stage
  19560. }
  19561. // SopStageID returns the "sop_stage" edge ID in the mutation.
  19562. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  19563. if m.sop_stage != nil {
  19564. return *m.sop_stage, true
  19565. }
  19566. return
  19567. }
  19568. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  19569. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19570. // SopStageID instead. It exists only for internal usage by the builders.
  19571. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  19572. if id := m.sop_stage; id != nil {
  19573. ids = append(ids, *id)
  19574. }
  19575. return
  19576. }
  19577. // ResetSopStage resets all changes to the "sop_stage" edge.
  19578. func (m *MessageRecordsMutation) ResetSopStage() {
  19579. m.sop_stage = nil
  19580. m.clearedsop_stage = false
  19581. }
  19582. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  19583. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  19584. m.sop_node = &id
  19585. }
  19586. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  19587. func (m *MessageRecordsMutation) ClearSopNode() {
  19588. m.clearedsop_node = true
  19589. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19590. }
  19591. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  19592. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  19593. return m.SubSourceIDCleared() || m.clearedsop_node
  19594. }
  19595. // SopNodeID returns the "sop_node" edge ID in the mutation.
  19596. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  19597. if m.sop_node != nil {
  19598. return *m.sop_node, true
  19599. }
  19600. return
  19601. }
  19602. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  19603. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19604. // SopNodeID instead. It exists only for internal usage by the builders.
  19605. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  19606. if id := m.sop_node; id != nil {
  19607. ids = append(ids, *id)
  19608. }
  19609. return
  19610. }
  19611. // ResetSopNode resets all changes to the "sop_node" edge.
  19612. func (m *MessageRecordsMutation) ResetSopNode() {
  19613. m.sop_node = nil
  19614. m.clearedsop_node = false
  19615. }
  19616. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  19617. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  19618. m.message_contact = &id
  19619. }
  19620. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  19621. func (m *MessageRecordsMutation) ClearMessageContact() {
  19622. m.clearedmessage_contact = true
  19623. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19624. }
  19625. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  19626. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  19627. return m.ContactIDCleared() || m.clearedmessage_contact
  19628. }
  19629. // MessageContactID returns the "message_contact" edge ID in the mutation.
  19630. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  19631. if m.message_contact != nil {
  19632. return *m.message_contact, true
  19633. }
  19634. return
  19635. }
  19636. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  19637. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19638. // MessageContactID instead. It exists only for internal usage by the builders.
  19639. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  19640. if id := m.message_contact; id != nil {
  19641. ids = append(ids, *id)
  19642. }
  19643. return
  19644. }
  19645. // ResetMessageContact resets all changes to the "message_contact" edge.
  19646. func (m *MessageRecordsMutation) ResetMessageContact() {
  19647. m.message_contact = nil
  19648. m.clearedmessage_contact = false
  19649. }
  19650. // Where appends a list predicates to the MessageRecordsMutation builder.
  19651. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  19652. m.predicates = append(m.predicates, ps...)
  19653. }
  19654. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  19655. // users can use type-assertion to append predicates that do not depend on any generated package.
  19656. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  19657. p := make([]predicate.MessageRecords, len(ps))
  19658. for i := range ps {
  19659. p[i] = ps[i]
  19660. }
  19661. m.Where(p...)
  19662. }
  19663. // Op returns the operation name.
  19664. func (m *MessageRecordsMutation) Op() Op {
  19665. return m.op
  19666. }
  19667. // SetOp allows setting the mutation operation.
  19668. func (m *MessageRecordsMutation) SetOp(op Op) {
  19669. m.op = op
  19670. }
  19671. // Type returns the node type of this mutation (MessageRecords).
  19672. func (m *MessageRecordsMutation) Type() string {
  19673. return m.typ
  19674. }
  19675. // Fields returns all fields that were changed during this mutation. Note that in
  19676. // order to get all numeric fields that were incremented/decremented, call
  19677. // AddedFields().
  19678. func (m *MessageRecordsMutation) Fields() []string {
  19679. fields := make([]string, 0, 16)
  19680. if m.created_at != nil {
  19681. fields = append(fields, messagerecords.FieldCreatedAt)
  19682. }
  19683. if m.updated_at != nil {
  19684. fields = append(fields, messagerecords.FieldUpdatedAt)
  19685. }
  19686. if m.status != nil {
  19687. fields = append(fields, messagerecords.FieldStatus)
  19688. }
  19689. if m.bot_wxid != nil {
  19690. fields = append(fields, messagerecords.FieldBotWxid)
  19691. }
  19692. if m.message_contact != nil {
  19693. fields = append(fields, messagerecords.FieldContactID)
  19694. }
  19695. if m.contact_type != nil {
  19696. fields = append(fields, messagerecords.FieldContactType)
  19697. }
  19698. if m.contact_wxid != nil {
  19699. fields = append(fields, messagerecords.FieldContactWxid)
  19700. }
  19701. if m.content_type != nil {
  19702. fields = append(fields, messagerecords.FieldContentType)
  19703. }
  19704. if m.content != nil {
  19705. fields = append(fields, messagerecords.FieldContent)
  19706. }
  19707. if m.meta != nil {
  19708. fields = append(fields, messagerecords.FieldMeta)
  19709. }
  19710. if m.error_detail != nil {
  19711. fields = append(fields, messagerecords.FieldErrorDetail)
  19712. }
  19713. if m.send_time != nil {
  19714. fields = append(fields, messagerecords.FieldSendTime)
  19715. }
  19716. if m.source_type != nil {
  19717. fields = append(fields, messagerecords.FieldSourceType)
  19718. }
  19719. if m.sop_stage != nil {
  19720. fields = append(fields, messagerecords.FieldSourceID)
  19721. }
  19722. if m.sop_node != nil {
  19723. fields = append(fields, messagerecords.FieldSubSourceID)
  19724. }
  19725. if m.organization_id != nil {
  19726. fields = append(fields, messagerecords.FieldOrganizationID)
  19727. }
  19728. return fields
  19729. }
  19730. // Field returns the value of a field with the given name. The second boolean
  19731. // return value indicates that this field was not set, or was not defined in the
  19732. // schema.
  19733. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  19734. switch name {
  19735. case messagerecords.FieldCreatedAt:
  19736. return m.CreatedAt()
  19737. case messagerecords.FieldUpdatedAt:
  19738. return m.UpdatedAt()
  19739. case messagerecords.FieldStatus:
  19740. return m.Status()
  19741. case messagerecords.FieldBotWxid:
  19742. return m.BotWxid()
  19743. case messagerecords.FieldContactID:
  19744. return m.ContactID()
  19745. case messagerecords.FieldContactType:
  19746. return m.ContactType()
  19747. case messagerecords.FieldContactWxid:
  19748. return m.ContactWxid()
  19749. case messagerecords.FieldContentType:
  19750. return m.ContentType()
  19751. case messagerecords.FieldContent:
  19752. return m.Content()
  19753. case messagerecords.FieldMeta:
  19754. return m.Meta()
  19755. case messagerecords.FieldErrorDetail:
  19756. return m.ErrorDetail()
  19757. case messagerecords.FieldSendTime:
  19758. return m.SendTime()
  19759. case messagerecords.FieldSourceType:
  19760. return m.SourceType()
  19761. case messagerecords.FieldSourceID:
  19762. return m.SourceID()
  19763. case messagerecords.FieldSubSourceID:
  19764. return m.SubSourceID()
  19765. case messagerecords.FieldOrganizationID:
  19766. return m.OrganizationID()
  19767. }
  19768. return nil, false
  19769. }
  19770. // OldField returns the old value of the field from the database. An error is
  19771. // returned if the mutation operation is not UpdateOne, or the query to the
  19772. // database failed.
  19773. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19774. switch name {
  19775. case messagerecords.FieldCreatedAt:
  19776. return m.OldCreatedAt(ctx)
  19777. case messagerecords.FieldUpdatedAt:
  19778. return m.OldUpdatedAt(ctx)
  19779. case messagerecords.FieldStatus:
  19780. return m.OldStatus(ctx)
  19781. case messagerecords.FieldBotWxid:
  19782. return m.OldBotWxid(ctx)
  19783. case messagerecords.FieldContactID:
  19784. return m.OldContactID(ctx)
  19785. case messagerecords.FieldContactType:
  19786. return m.OldContactType(ctx)
  19787. case messagerecords.FieldContactWxid:
  19788. return m.OldContactWxid(ctx)
  19789. case messagerecords.FieldContentType:
  19790. return m.OldContentType(ctx)
  19791. case messagerecords.FieldContent:
  19792. return m.OldContent(ctx)
  19793. case messagerecords.FieldMeta:
  19794. return m.OldMeta(ctx)
  19795. case messagerecords.FieldErrorDetail:
  19796. return m.OldErrorDetail(ctx)
  19797. case messagerecords.FieldSendTime:
  19798. return m.OldSendTime(ctx)
  19799. case messagerecords.FieldSourceType:
  19800. return m.OldSourceType(ctx)
  19801. case messagerecords.FieldSourceID:
  19802. return m.OldSourceID(ctx)
  19803. case messagerecords.FieldSubSourceID:
  19804. return m.OldSubSourceID(ctx)
  19805. case messagerecords.FieldOrganizationID:
  19806. return m.OldOrganizationID(ctx)
  19807. }
  19808. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  19809. }
  19810. // SetField sets the value of a field with the given name. It returns an error if
  19811. // the field is not defined in the schema, or if the type mismatched the field
  19812. // type.
  19813. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  19814. switch name {
  19815. case messagerecords.FieldCreatedAt:
  19816. v, ok := value.(time.Time)
  19817. if !ok {
  19818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19819. }
  19820. m.SetCreatedAt(v)
  19821. return nil
  19822. case messagerecords.FieldUpdatedAt:
  19823. v, ok := value.(time.Time)
  19824. if !ok {
  19825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19826. }
  19827. m.SetUpdatedAt(v)
  19828. return nil
  19829. case messagerecords.FieldStatus:
  19830. v, ok := value.(uint8)
  19831. if !ok {
  19832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19833. }
  19834. m.SetStatus(v)
  19835. return nil
  19836. case messagerecords.FieldBotWxid:
  19837. v, ok := value.(string)
  19838. if !ok {
  19839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19840. }
  19841. m.SetBotWxid(v)
  19842. return nil
  19843. case messagerecords.FieldContactID:
  19844. v, ok := value.(uint64)
  19845. if !ok {
  19846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19847. }
  19848. m.SetContactID(v)
  19849. return nil
  19850. case messagerecords.FieldContactType:
  19851. v, ok := value.(int)
  19852. if !ok {
  19853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19854. }
  19855. m.SetContactType(v)
  19856. return nil
  19857. case messagerecords.FieldContactWxid:
  19858. v, ok := value.(string)
  19859. if !ok {
  19860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19861. }
  19862. m.SetContactWxid(v)
  19863. return nil
  19864. case messagerecords.FieldContentType:
  19865. v, ok := value.(int)
  19866. if !ok {
  19867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19868. }
  19869. m.SetContentType(v)
  19870. return nil
  19871. case messagerecords.FieldContent:
  19872. v, ok := value.(string)
  19873. if !ok {
  19874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19875. }
  19876. m.SetContent(v)
  19877. return nil
  19878. case messagerecords.FieldMeta:
  19879. v, ok := value.(custom_types.Meta)
  19880. if !ok {
  19881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19882. }
  19883. m.SetMeta(v)
  19884. return nil
  19885. case messagerecords.FieldErrorDetail:
  19886. v, ok := value.(string)
  19887. if !ok {
  19888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19889. }
  19890. m.SetErrorDetail(v)
  19891. return nil
  19892. case messagerecords.FieldSendTime:
  19893. v, ok := value.(time.Time)
  19894. if !ok {
  19895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19896. }
  19897. m.SetSendTime(v)
  19898. return nil
  19899. case messagerecords.FieldSourceType:
  19900. v, ok := value.(int)
  19901. if !ok {
  19902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19903. }
  19904. m.SetSourceType(v)
  19905. return nil
  19906. case messagerecords.FieldSourceID:
  19907. v, ok := value.(uint64)
  19908. if !ok {
  19909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19910. }
  19911. m.SetSourceID(v)
  19912. return nil
  19913. case messagerecords.FieldSubSourceID:
  19914. v, ok := value.(uint64)
  19915. if !ok {
  19916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19917. }
  19918. m.SetSubSourceID(v)
  19919. return nil
  19920. case messagerecords.FieldOrganizationID:
  19921. v, ok := value.(uint64)
  19922. if !ok {
  19923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19924. }
  19925. m.SetOrganizationID(v)
  19926. return nil
  19927. }
  19928. return fmt.Errorf("unknown MessageRecords field %s", name)
  19929. }
  19930. // AddedFields returns all numeric fields that were incremented/decremented during
  19931. // this mutation.
  19932. func (m *MessageRecordsMutation) AddedFields() []string {
  19933. var fields []string
  19934. if m.addstatus != nil {
  19935. fields = append(fields, messagerecords.FieldStatus)
  19936. }
  19937. if m.addcontact_type != nil {
  19938. fields = append(fields, messagerecords.FieldContactType)
  19939. }
  19940. if m.addcontent_type != nil {
  19941. fields = append(fields, messagerecords.FieldContentType)
  19942. }
  19943. if m.addsource_type != nil {
  19944. fields = append(fields, messagerecords.FieldSourceType)
  19945. }
  19946. if m.addorganization_id != nil {
  19947. fields = append(fields, messagerecords.FieldOrganizationID)
  19948. }
  19949. return fields
  19950. }
  19951. // AddedField returns the numeric value that was incremented/decremented on a field
  19952. // with the given name. The second boolean return value indicates that this field
  19953. // was not set, or was not defined in the schema.
  19954. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  19955. switch name {
  19956. case messagerecords.FieldStatus:
  19957. return m.AddedStatus()
  19958. case messagerecords.FieldContactType:
  19959. return m.AddedContactType()
  19960. case messagerecords.FieldContentType:
  19961. return m.AddedContentType()
  19962. case messagerecords.FieldSourceType:
  19963. return m.AddedSourceType()
  19964. case messagerecords.FieldOrganizationID:
  19965. return m.AddedOrganizationID()
  19966. }
  19967. return nil, false
  19968. }
  19969. // AddField adds the value to the field with the given name. It returns an error if
  19970. // the field is not defined in the schema, or if the type mismatched the field
  19971. // type.
  19972. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  19973. switch name {
  19974. case messagerecords.FieldStatus:
  19975. v, ok := value.(int8)
  19976. if !ok {
  19977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19978. }
  19979. m.AddStatus(v)
  19980. return nil
  19981. case messagerecords.FieldContactType:
  19982. v, ok := value.(int)
  19983. if !ok {
  19984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19985. }
  19986. m.AddContactType(v)
  19987. return nil
  19988. case messagerecords.FieldContentType:
  19989. v, ok := value.(int)
  19990. if !ok {
  19991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19992. }
  19993. m.AddContentType(v)
  19994. return nil
  19995. case messagerecords.FieldSourceType:
  19996. v, ok := value.(int)
  19997. if !ok {
  19998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19999. }
  20000. m.AddSourceType(v)
  20001. return nil
  20002. case messagerecords.FieldOrganizationID:
  20003. v, ok := value.(int64)
  20004. if !ok {
  20005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20006. }
  20007. m.AddOrganizationID(v)
  20008. return nil
  20009. }
  20010. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  20011. }
  20012. // ClearedFields returns all nullable fields that were cleared during this
  20013. // mutation.
  20014. func (m *MessageRecordsMutation) ClearedFields() []string {
  20015. var fields []string
  20016. if m.FieldCleared(messagerecords.FieldStatus) {
  20017. fields = append(fields, messagerecords.FieldStatus)
  20018. }
  20019. if m.FieldCleared(messagerecords.FieldContactID) {
  20020. fields = append(fields, messagerecords.FieldContactID)
  20021. }
  20022. if m.FieldCleared(messagerecords.FieldMeta) {
  20023. fields = append(fields, messagerecords.FieldMeta)
  20024. }
  20025. if m.FieldCleared(messagerecords.FieldSendTime) {
  20026. fields = append(fields, messagerecords.FieldSendTime)
  20027. }
  20028. if m.FieldCleared(messagerecords.FieldSourceID) {
  20029. fields = append(fields, messagerecords.FieldSourceID)
  20030. }
  20031. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  20032. fields = append(fields, messagerecords.FieldSubSourceID)
  20033. }
  20034. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  20035. fields = append(fields, messagerecords.FieldOrganizationID)
  20036. }
  20037. return fields
  20038. }
  20039. // FieldCleared returns a boolean indicating if a field with the given name was
  20040. // cleared in this mutation.
  20041. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  20042. _, ok := m.clearedFields[name]
  20043. return ok
  20044. }
  20045. // ClearField clears the value of the field with the given name. It returns an
  20046. // error if the field is not defined in the schema.
  20047. func (m *MessageRecordsMutation) ClearField(name string) error {
  20048. switch name {
  20049. case messagerecords.FieldStatus:
  20050. m.ClearStatus()
  20051. return nil
  20052. case messagerecords.FieldContactID:
  20053. m.ClearContactID()
  20054. return nil
  20055. case messagerecords.FieldMeta:
  20056. m.ClearMeta()
  20057. return nil
  20058. case messagerecords.FieldSendTime:
  20059. m.ClearSendTime()
  20060. return nil
  20061. case messagerecords.FieldSourceID:
  20062. m.ClearSourceID()
  20063. return nil
  20064. case messagerecords.FieldSubSourceID:
  20065. m.ClearSubSourceID()
  20066. return nil
  20067. case messagerecords.FieldOrganizationID:
  20068. m.ClearOrganizationID()
  20069. return nil
  20070. }
  20071. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  20072. }
  20073. // ResetField resets all changes in the mutation for the field with the given name.
  20074. // It returns an error if the field is not defined in the schema.
  20075. func (m *MessageRecordsMutation) ResetField(name string) error {
  20076. switch name {
  20077. case messagerecords.FieldCreatedAt:
  20078. m.ResetCreatedAt()
  20079. return nil
  20080. case messagerecords.FieldUpdatedAt:
  20081. m.ResetUpdatedAt()
  20082. return nil
  20083. case messagerecords.FieldStatus:
  20084. m.ResetStatus()
  20085. return nil
  20086. case messagerecords.FieldBotWxid:
  20087. m.ResetBotWxid()
  20088. return nil
  20089. case messagerecords.FieldContactID:
  20090. m.ResetContactID()
  20091. return nil
  20092. case messagerecords.FieldContactType:
  20093. m.ResetContactType()
  20094. return nil
  20095. case messagerecords.FieldContactWxid:
  20096. m.ResetContactWxid()
  20097. return nil
  20098. case messagerecords.FieldContentType:
  20099. m.ResetContentType()
  20100. return nil
  20101. case messagerecords.FieldContent:
  20102. m.ResetContent()
  20103. return nil
  20104. case messagerecords.FieldMeta:
  20105. m.ResetMeta()
  20106. return nil
  20107. case messagerecords.FieldErrorDetail:
  20108. m.ResetErrorDetail()
  20109. return nil
  20110. case messagerecords.FieldSendTime:
  20111. m.ResetSendTime()
  20112. return nil
  20113. case messagerecords.FieldSourceType:
  20114. m.ResetSourceType()
  20115. return nil
  20116. case messagerecords.FieldSourceID:
  20117. m.ResetSourceID()
  20118. return nil
  20119. case messagerecords.FieldSubSourceID:
  20120. m.ResetSubSourceID()
  20121. return nil
  20122. case messagerecords.FieldOrganizationID:
  20123. m.ResetOrganizationID()
  20124. return nil
  20125. }
  20126. return fmt.Errorf("unknown MessageRecords field %s", name)
  20127. }
  20128. // AddedEdges returns all edge names that were set/added in this mutation.
  20129. func (m *MessageRecordsMutation) AddedEdges() []string {
  20130. edges := make([]string, 0, 3)
  20131. if m.sop_stage != nil {
  20132. edges = append(edges, messagerecords.EdgeSopStage)
  20133. }
  20134. if m.sop_node != nil {
  20135. edges = append(edges, messagerecords.EdgeSopNode)
  20136. }
  20137. if m.message_contact != nil {
  20138. edges = append(edges, messagerecords.EdgeMessageContact)
  20139. }
  20140. return edges
  20141. }
  20142. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20143. // name in this mutation.
  20144. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  20145. switch name {
  20146. case messagerecords.EdgeSopStage:
  20147. if id := m.sop_stage; id != nil {
  20148. return []ent.Value{*id}
  20149. }
  20150. case messagerecords.EdgeSopNode:
  20151. if id := m.sop_node; id != nil {
  20152. return []ent.Value{*id}
  20153. }
  20154. case messagerecords.EdgeMessageContact:
  20155. if id := m.message_contact; id != nil {
  20156. return []ent.Value{*id}
  20157. }
  20158. }
  20159. return nil
  20160. }
  20161. // RemovedEdges returns all edge names that were removed in this mutation.
  20162. func (m *MessageRecordsMutation) RemovedEdges() []string {
  20163. edges := make([]string, 0, 3)
  20164. return edges
  20165. }
  20166. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20167. // the given name in this mutation.
  20168. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  20169. return nil
  20170. }
  20171. // ClearedEdges returns all edge names that were cleared in this mutation.
  20172. func (m *MessageRecordsMutation) ClearedEdges() []string {
  20173. edges := make([]string, 0, 3)
  20174. if m.clearedsop_stage {
  20175. edges = append(edges, messagerecords.EdgeSopStage)
  20176. }
  20177. if m.clearedsop_node {
  20178. edges = append(edges, messagerecords.EdgeSopNode)
  20179. }
  20180. if m.clearedmessage_contact {
  20181. edges = append(edges, messagerecords.EdgeMessageContact)
  20182. }
  20183. return edges
  20184. }
  20185. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20186. // was cleared in this mutation.
  20187. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  20188. switch name {
  20189. case messagerecords.EdgeSopStage:
  20190. return m.clearedsop_stage
  20191. case messagerecords.EdgeSopNode:
  20192. return m.clearedsop_node
  20193. case messagerecords.EdgeMessageContact:
  20194. return m.clearedmessage_contact
  20195. }
  20196. return false
  20197. }
  20198. // ClearEdge clears the value of the edge with the given name. It returns an error
  20199. // if that edge is not defined in the schema.
  20200. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  20201. switch name {
  20202. case messagerecords.EdgeSopStage:
  20203. m.ClearSopStage()
  20204. return nil
  20205. case messagerecords.EdgeSopNode:
  20206. m.ClearSopNode()
  20207. return nil
  20208. case messagerecords.EdgeMessageContact:
  20209. m.ClearMessageContact()
  20210. return nil
  20211. }
  20212. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  20213. }
  20214. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20215. // It returns an error if the edge is not defined in the schema.
  20216. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  20217. switch name {
  20218. case messagerecords.EdgeSopStage:
  20219. m.ResetSopStage()
  20220. return nil
  20221. case messagerecords.EdgeSopNode:
  20222. m.ResetSopNode()
  20223. return nil
  20224. case messagerecords.EdgeMessageContact:
  20225. m.ResetMessageContact()
  20226. return nil
  20227. }
  20228. return fmt.Errorf("unknown MessageRecords edge %s", name)
  20229. }
  20230. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  20231. type MsgMutation struct {
  20232. config
  20233. op Op
  20234. typ string
  20235. id *uint64
  20236. created_at *time.Time
  20237. updated_at *time.Time
  20238. deleted_at *time.Time
  20239. status *uint8
  20240. addstatus *int8
  20241. fromwxid *string
  20242. toid *string
  20243. msgtype *int32
  20244. addmsgtype *int32
  20245. msg *string
  20246. batch_no *string
  20247. cc *string
  20248. phone *string
  20249. clearedFields map[string]struct{}
  20250. done bool
  20251. oldValue func(context.Context) (*Msg, error)
  20252. predicates []predicate.Msg
  20253. }
  20254. var _ ent.Mutation = (*MsgMutation)(nil)
  20255. // msgOption allows management of the mutation configuration using functional options.
  20256. type msgOption func(*MsgMutation)
  20257. // newMsgMutation creates new mutation for the Msg entity.
  20258. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  20259. m := &MsgMutation{
  20260. config: c,
  20261. op: op,
  20262. typ: TypeMsg,
  20263. clearedFields: make(map[string]struct{}),
  20264. }
  20265. for _, opt := range opts {
  20266. opt(m)
  20267. }
  20268. return m
  20269. }
  20270. // withMsgID sets the ID field of the mutation.
  20271. func withMsgID(id uint64) msgOption {
  20272. return func(m *MsgMutation) {
  20273. var (
  20274. err error
  20275. once sync.Once
  20276. value *Msg
  20277. )
  20278. m.oldValue = func(ctx context.Context) (*Msg, error) {
  20279. once.Do(func() {
  20280. if m.done {
  20281. err = errors.New("querying old values post mutation is not allowed")
  20282. } else {
  20283. value, err = m.Client().Msg.Get(ctx, id)
  20284. }
  20285. })
  20286. return value, err
  20287. }
  20288. m.id = &id
  20289. }
  20290. }
  20291. // withMsg sets the old Msg of the mutation.
  20292. func withMsg(node *Msg) msgOption {
  20293. return func(m *MsgMutation) {
  20294. m.oldValue = func(context.Context) (*Msg, error) {
  20295. return node, nil
  20296. }
  20297. m.id = &node.ID
  20298. }
  20299. }
  20300. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20301. // executed in a transaction (ent.Tx), a transactional client is returned.
  20302. func (m MsgMutation) Client() *Client {
  20303. client := &Client{config: m.config}
  20304. client.init()
  20305. return client
  20306. }
  20307. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20308. // it returns an error otherwise.
  20309. func (m MsgMutation) Tx() (*Tx, error) {
  20310. if _, ok := m.driver.(*txDriver); !ok {
  20311. return nil, errors.New("ent: mutation is not running in a transaction")
  20312. }
  20313. tx := &Tx{config: m.config}
  20314. tx.init()
  20315. return tx, nil
  20316. }
  20317. // SetID sets the value of the id field. Note that this
  20318. // operation is only accepted on creation of Msg entities.
  20319. func (m *MsgMutation) SetID(id uint64) {
  20320. m.id = &id
  20321. }
  20322. // ID returns the ID value in the mutation. Note that the ID is only available
  20323. // if it was provided to the builder or after it was returned from the database.
  20324. func (m *MsgMutation) ID() (id uint64, exists bool) {
  20325. if m.id == nil {
  20326. return
  20327. }
  20328. return *m.id, true
  20329. }
  20330. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20331. // That means, if the mutation is applied within a transaction with an isolation level such
  20332. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20333. // or updated by the mutation.
  20334. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  20335. switch {
  20336. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20337. id, exists := m.ID()
  20338. if exists {
  20339. return []uint64{id}, nil
  20340. }
  20341. fallthrough
  20342. case m.op.Is(OpUpdate | OpDelete):
  20343. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  20344. default:
  20345. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20346. }
  20347. }
  20348. // SetCreatedAt sets the "created_at" field.
  20349. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  20350. m.created_at = &t
  20351. }
  20352. // CreatedAt returns the value of the "created_at" field in the mutation.
  20353. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  20354. v := m.created_at
  20355. if v == nil {
  20356. return
  20357. }
  20358. return *v, true
  20359. }
  20360. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  20361. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20363. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20364. if !m.op.Is(OpUpdateOne) {
  20365. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20366. }
  20367. if m.id == nil || m.oldValue == nil {
  20368. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20369. }
  20370. oldValue, err := m.oldValue(ctx)
  20371. if err != nil {
  20372. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20373. }
  20374. return oldValue.CreatedAt, nil
  20375. }
  20376. // ResetCreatedAt resets all changes to the "created_at" field.
  20377. func (m *MsgMutation) ResetCreatedAt() {
  20378. m.created_at = nil
  20379. }
  20380. // SetUpdatedAt sets the "updated_at" field.
  20381. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  20382. m.updated_at = &t
  20383. }
  20384. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20385. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  20386. v := m.updated_at
  20387. if v == nil {
  20388. return
  20389. }
  20390. return *v, true
  20391. }
  20392. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  20393. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20395. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20396. if !m.op.Is(OpUpdateOne) {
  20397. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20398. }
  20399. if m.id == nil || m.oldValue == nil {
  20400. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20401. }
  20402. oldValue, err := m.oldValue(ctx)
  20403. if err != nil {
  20404. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20405. }
  20406. return oldValue.UpdatedAt, nil
  20407. }
  20408. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20409. func (m *MsgMutation) ResetUpdatedAt() {
  20410. m.updated_at = nil
  20411. }
  20412. // SetDeletedAt sets the "deleted_at" field.
  20413. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  20414. m.deleted_at = &t
  20415. }
  20416. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20417. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  20418. v := m.deleted_at
  20419. if v == nil {
  20420. return
  20421. }
  20422. return *v, true
  20423. }
  20424. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  20425. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20427. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20428. if !m.op.Is(OpUpdateOne) {
  20429. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20430. }
  20431. if m.id == nil || m.oldValue == nil {
  20432. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20433. }
  20434. oldValue, err := m.oldValue(ctx)
  20435. if err != nil {
  20436. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20437. }
  20438. return oldValue.DeletedAt, nil
  20439. }
  20440. // ClearDeletedAt clears the value of the "deleted_at" field.
  20441. func (m *MsgMutation) ClearDeletedAt() {
  20442. m.deleted_at = nil
  20443. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  20444. }
  20445. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20446. func (m *MsgMutation) DeletedAtCleared() bool {
  20447. _, ok := m.clearedFields[msg.FieldDeletedAt]
  20448. return ok
  20449. }
  20450. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20451. func (m *MsgMutation) ResetDeletedAt() {
  20452. m.deleted_at = nil
  20453. delete(m.clearedFields, msg.FieldDeletedAt)
  20454. }
  20455. // SetStatus sets the "status" field.
  20456. func (m *MsgMutation) SetStatus(u uint8) {
  20457. m.status = &u
  20458. m.addstatus = nil
  20459. }
  20460. // Status returns the value of the "status" field in the mutation.
  20461. func (m *MsgMutation) Status() (r uint8, exists bool) {
  20462. v := m.status
  20463. if v == nil {
  20464. return
  20465. }
  20466. return *v, true
  20467. }
  20468. // OldStatus returns the old "status" field's value of the Msg entity.
  20469. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20471. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20472. if !m.op.Is(OpUpdateOne) {
  20473. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20474. }
  20475. if m.id == nil || m.oldValue == nil {
  20476. return v, errors.New("OldStatus requires an ID field in the mutation")
  20477. }
  20478. oldValue, err := m.oldValue(ctx)
  20479. if err != nil {
  20480. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20481. }
  20482. return oldValue.Status, nil
  20483. }
  20484. // AddStatus adds u to the "status" field.
  20485. func (m *MsgMutation) AddStatus(u int8) {
  20486. if m.addstatus != nil {
  20487. *m.addstatus += u
  20488. } else {
  20489. m.addstatus = &u
  20490. }
  20491. }
  20492. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20493. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  20494. v := m.addstatus
  20495. if v == nil {
  20496. return
  20497. }
  20498. return *v, true
  20499. }
  20500. // ClearStatus clears the value of the "status" field.
  20501. func (m *MsgMutation) ClearStatus() {
  20502. m.status = nil
  20503. m.addstatus = nil
  20504. m.clearedFields[msg.FieldStatus] = struct{}{}
  20505. }
  20506. // StatusCleared returns if the "status" field was cleared in this mutation.
  20507. func (m *MsgMutation) StatusCleared() bool {
  20508. _, ok := m.clearedFields[msg.FieldStatus]
  20509. return ok
  20510. }
  20511. // ResetStatus resets all changes to the "status" field.
  20512. func (m *MsgMutation) ResetStatus() {
  20513. m.status = nil
  20514. m.addstatus = nil
  20515. delete(m.clearedFields, msg.FieldStatus)
  20516. }
  20517. // SetFromwxid sets the "fromwxid" field.
  20518. func (m *MsgMutation) SetFromwxid(s string) {
  20519. m.fromwxid = &s
  20520. }
  20521. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  20522. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  20523. v := m.fromwxid
  20524. if v == nil {
  20525. return
  20526. }
  20527. return *v, true
  20528. }
  20529. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  20530. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20532. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  20533. if !m.op.Is(OpUpdateOne) {
  20534. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  20535. }
  20536. if m.id == nil || m.oldValue == nil {
  20537. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  20538. }
  20539. oldValue, err := m.oldValue(ctx)
  20540. if err != nil {
  20541. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  20542. }
  20543. return oldValue.Fromwxid, nil
  20544. }
  20545. // ClearFromwxid clears the value of the "fromwxid" field.
  20546. func (m *MsgMutation) ClearFromwxid() {
  20547. m.fromwxid = nil
  20548. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  20549. }
  20550. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  20551. func (m *MsgMutation) FromwxidCleared() bool {
  20552. _, ok := m.clearedFields[msg.FieldFromwxid]
  20553. return ok
  20554. }
  20555. // ResetFromwxid resets all changes to the "fromwxid" field.
  20556. func (m *MsgMutation) ResetFromwxid() {
  20557. m.fromwxid = nil
  20558. delete(m.clearedFields, msg.FieldFromwxid)
  20559. }
  20560. // SetToid sets the "toid" field.
  20561. func (m *MsgMutation) SetToid(s string) {
  20562. m.toid = &s
  20563. }
  20564. // Toid returns the value of the "toid" field in the mutation.
  20565. func (m *MsgMutation) Toid() (r string, exists bool) {
  20566. v := m.toid
  20567. if v == nil {
  20568. return
  20569. }
  20570. return *v, true
  20571. }
  20572. // OldToid returns the old "toid" field's value of the Msg entity.
  20573. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20575. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  20576. if !m.op.Is(OpUpdateOne) {
  20577. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  20578. }
  20579. if m.id == nil || m.oldValue == nil {
  20580. return v, errors.New("OldToid requires an ID field in the mutation")
  20581. }
  20582. oldValue, err := m.oldValue(ctx)
  20583. if err != nil {
  20584. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  20585. }
  20586. return oldValue.Toid, nil
  20587. }
  20588. // ClearToid clears the value of the "toid" field.
  20589. func (m *MsgMutation) ClearToid() {
  20590. m.toid = nil
  20591. m.clearedFields[msg.FieldToid] = struct{}{}
  20592. }
  20593. // ToidCleared returns if the "toid" field was cleared in this mutation.
  20594. func (m *MsgMutation) ToidCleared() bool {
  20595. _, ok := m.clearedFields[msg.FieldToid]
  20596. return ok
  20597. }
  20598. // ResetToid resets all changes to the "toid" field.
  20599. func (m *MsgMutation) ResetToid() {
  20600. m.toid = nil
  20601. delete(m.clearedFields, msg.FieldToid)
  20602. }
  20603. // SetMsgtype sets the "msgtype" field.
  20604. func (m *MsgMutation) SetMsgtype(i int32) {
  20605. m.msgtype = &i
  20606. m.addmsgtype = nil
  20607. }
  20608. // Msgtype returns the value of the "msgtype" field in the mutation.
  20609. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  20610. v := m.msgtype
  20611. if v == nil {
  20612. return
  20613. }
  20614. return *v, true
  20615. }
  20616. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  20617. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20619. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  20620. if !m.op.Is(OpUpdateOne) {
  20621. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  20622. }
  20623. if m.id == nil || m.oldValue == nil {
  20624. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  20625. }
  20626. oldValue, err := m.oldValue(ctx)
  20627. if err != nil {
  20628. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  20629. }
  20630. return oldValue.Msgtype, nil
  20631. }
  20632. // AddMsgtype adds i to the "msgtype" field.
  20633. func (m *MsgMutation) AddMsgtype(i int32) {
  20634. if m.addmsgtype != nil {
  20635. *m.addmsgtype += i
  20636. } else {
  20637. m.addmsgtype = &i
  20638. }
  20639. }
  20640. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  20641. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  20642. v := m.addmsgtype
  20643. if v == nil {
  20644. return
  20645. }
  20646. return *v, true
  20647. }
  20648. // ClearMsgtype clears the value of the "msgtype" field.
  20649. func (m *MsgMutation) ClearMsgtype() {
  20650. m.msgtype = nil
  20651. m.addmsgtype = nil
  20652. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  20653. }
  20654. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  20655. func (m *MsgMutation) MsgtypeCleared() bool {
  20656. _, ok := m.clearedFields[msg.FieldMsgtype]
  20657. return ok
  20658. }
  20659. // ResetMsgtype resets all changes to the "msgtype" field.
  20660. func (m *MsgMutation) ResetMsgtype() {
  20661. m.msgtype = nil
  20662. m.addmsgtype = nil
  20663. delete(m.clearedFields, msg.FieldMsgtype)
  20664. }
  20665. // SetMsg sets the "msg" field.
  20666. func (m *MsgMutation) SetMsg(s string) {
  20667. m.msg = &s
  20668. }
  20669. // Msg returns the value of the "msg" field in the mutation.
  20670. func (m *MsgMutation) Msg() (r string, exists bool) {
  20671. v := m.msg
  20672. if v == nil {
  20673. return
  20674. }
  20675. return *v, true
  20676. }
  20677. // OldMsg returns the old "msg" field's value of the Msg entity.
  20678. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20680. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  20681. if !m.op.Is(OpUpdateOne) {
  20682. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  20683. }
  20684. if m.id == nil || m.oldValue == nil {
  20685. return v, errors.New("OldMsg requires an ID field in the mutation")
  20686. }
  20687. oldValue, err := m.oldValue(ctx)
  20688. if err != nil {
  20689. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  20690. }
  20691. return oldValue.Msg, nil
  20692. }
  20693. // ClearMsg clears the value of the "msg" field.
  20694. func (m *MsgMutation) ClearMsg() {
  20695. m.msg = nil
  20696. m.clearedFields[msg.FieldMsg] = struct{}{}
  20697. }
  20698. // MsgCleared returns if the "msg" field was cleared in this mutation.
  20699. func (m *MsgMutation) MsgCleared() bool {
  20700. _, ok := m.clearedFields[msg.FieldMsg]
  20701. return ok
  20702. }
  20703. // ResetMsg resets all changes to the "msg" field.
  20704. func (m *MsgMutation) ResetMsg() {
  20705. m.msg = nil
  20706. delete(m.clearedFields, msg.FieldMsg)
  20707. }
  20708. // SetBatchNo sets the "batch_no" field.
  20709. func (m *MsgMutation) SetBatchNo(s string) {
  20710. m.batch_no = &s
  20711. }
  20712. // BatchNo returns the value of the "batch_no" field in the mutation.
  20713. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  20714. v := m.batch_no
  20715. if v == nil {
  20716. return
  20717. }
  20718. return *v, true
  20719. }
  20720. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  20721. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20723. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  20724. if !m.op.Is(OpUpdateOne) {
  20725. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  20726. }
  20727. if m.id == nil || m.oldValue == nil {
  20728. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  20729. }
  20730. oldValue, err := m.oldValue(ctx)
  20731. if err != nil {
  20732. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  20733. }
  20734. return oldValue.BatchNo, nil
  20735. }
  20736. // ClearBatchNo clears the value of the "batch_no" field.
  20737. func (m *MsgMutation) ClearBatchNo() {
  20738. m.batch_no = nil
  20739. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  20740. }
  20741. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  20742. func (m *MsgMutation) BatchNoCleared() bool {
  20743. _, ok := m.clearedFields[msg.FieldBatchNo]
  20744. return ok
  20745. }
  20746. // ResetBatchNo resets all changes to the "batch_no" field.
  20747. func (m *MsgMutation) ResetBatchNo() {
  20748. m.batch_no = nil
  20749. delete(m.clearedFields, msg.FieldBatchNo)
  20750. }
  20751. // SetCc sets the "cc" field.
  20752. func (m *MsgMutation) SetCc(s string) {
  20753. m.cc = &s
  20754. }
  20755. // Cc returns the value of the "cc" field in the mutation.
  20756. func (m *MsgMutation) Cc() (r string, exists bool) {
  20757. v := m.cc
  20758. if v == nil {
  20759. return
  20760. }
  20761. return *v, true
  20762. }
  20763. // OldCc returns the old "cc" field's value of the Msg entity.
  20764. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20766. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  20767. if !m.op.Is(OpUpdateOne) {
  20768. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  20769. }
  20770. if m.id == nil || m.oldValue == nil {
  20771. return v, errors.New("OldCc requires an ID field in the mutation")
  20772. }
  20773. oldValue, err := m.oldValue(ctx)
  20774. if err != nil {
  20775. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  20776. }
  20777. return oldValue.Cc, nil
  20778. }
  20779. // ResetCc resets all changes to the "cc" field.
  20780. func (m *MsgMutation) ResetCc() {
  20781. m.cc = nil
  20782. }
  20783. // SetPhone sets the "phone" field.
  20784. func (m *MsgMutation) SetPhone(s string) {
  20785. m.phone = &s
  20786. }
  20787. // Phone returns the value of the "phone" field in the mutation.
  20788. func (m *MsgMutation) Phone() (r string, exists bool) {
  20789. v := m.phone
  20790. if v == nil {
  20791. return
  20792. }
  20793. return *v, true
  20794. }
  20795. // OldPhone returns the old "phone" field's value of the Msg entity.
  20796. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20798. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  20799. if !m.op.Is(OpUpdateOne) {
  20800. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  20801. }
  20802. if m.id == nil || m.oldValue == nil {
  20803. return v, errors.New("OldPhone requires an ID field in the mutation")
  20804. }
  20805. oldValue, err := m.oldValue(ctx)
  20806. if err != nil {
  20807. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  20808. }
  20809. return oldValue.Phone, nil
  20810. }
  20811. // ResetPhone resets all changes to the "phone" field.
  20812. func (m *MsgMutation) ResetPhone() {
  20813. m.phone = nil
  20814. }
  20815. // Where appends a list predicates to the MsgMutation builder.
  20816. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  20817. m.predicates = append(m.predicates, ps...)
  20818. }
  20819. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  20820. // users can use type-assertion to append predicates that do not depend on any generated package.
  20821. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  20822. p := make([]predicate.Msg, len(ps))
  20823. for i := range ps {
  20824. p[i] = ps[i]
  20825. }
  20826. m.Where(p...)
  20827. }
  20828. // Op returns the operation name.
  20829. func (m *MsgMutation) Op() Op {
  20830. return m.op
  20831. }
  20832. // SetOp allows setting the mutation operation.
  20833. func (m *MsgMutation) SetOp(op Op) {
  20834. m.op = op
  20835. }
  20836. // Type returns the node type of this mutation (Msg).
  20837. func (m *MsgMutation) Type() string {
  20838. return m.typ
  20839. }
  20840. // Fields returns all fields that were changed during this mutation. Note that in
  20841. // order to get all numeric fields that were incremented/decremented, call
  20842. // AddedFields().
  20843. func (m *MsgMutation) Fields() []string {
  20844. fields := make([]string, 0, 11)
  20845. if m.created_at != nil {
  20846. fields = append(fields, msg.FieldCreatedAt)
  20847. }
  20848. if m.updated_at != nil {
  20849. fields = append(fields, msg.FieldUpdatedAt)
  20850. }
  20851. if m.deleted_at != nil {
  20852. fields = append(fields, msg.FieldDeletedAt)
  20853. }
  20854. if m.status != nil {
  20855. fields = append(fields, msg.FieldStatus)
  20856. }
  20857. if m.fromwxid != nil {
  20858. fields = append(fields, msg.FieldFromwxid)
  20859. }
  20860. if m.toid != nil {
  20861. fields = append(fields, msg.FieldToid)
  20862. }
  20863. if m.msgtype != nil {
  20864. fields = append(fields, msg.FieldMsgtype)
  20865. }
  20866. if m.msg != nil {
  20867. fields = append(fields, msg.FieldMsg)
  20868. }
  20869. if m.batch_no != nil {
  20870. fields = append(fields, msg.FieldBatchNo)
  20871. }
  20872. if m.cc != nil {
  20873. fields = append(fields, msg.FieldCc)
  20874. }
  20875. if m.phone != nil {
  20876. fields = append(fields, msg.FieldPhone)
  20877. }
  20878. return fields
  20879. }
  20880. // Field returns the value of a field with the given name. The second boolean
  20881. // return value indicates that this field was not set, or was not defined in the
  20882. // schema.
  20883. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  20884. switch name {
  20885. case msg.FieldCreatedAt:
  20886. return m.CreatedAt()
  20887. case msg.FieldUpdatedAt:
  20888. return m.UpdatedAt()
  20889. case msg.FieldDeletedAt:
  20890. return m.DeletedAt()
  20891. case msg.FieldStatus:
  20892. return m.Status()
  20893. case msg.FieldFromwxid:
  20894. return m.Fromwxid()
  20895. case msg.FieldToid:
  20896. return m.Toid()
  20897. case msg.FieldMsgtype:
  20898. return m.Msgtype()
  20899. case msg.FieldMsg:
  20900. return m.Msg()
  20901. case msg.FieldBatchNo:
  20902. return m.BatchNo()
  20903. case msg.FieldCc:
  20904. return m.Cc()
  20905. case msg.FieldPhone:
  20906. return m.Phone()
  20907. }
  20908. return nil, false
  20909. }
  20910. // OldField returns the old value of the field from the database. An error is
  20911. // returned if the mutation operation is not UpdateOne, or the query to the
  20912. // database failed.
  20913. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20914. switch name {
  20915. case msg.FieldCreatedAt:
  20916. return m.OldCreatedAt(ctx)
  20917. case msg.FieldUpdatedAt:
  20918. return m.OldUpdatedAt(ctx)
  20919. case msg.FieldDeletedAt:
  20920. return m.OldDeletedAt(ctx)
  20921. case msg.FieldStatus:
  20922. return m.OldStatus(ctx)
  20923. case msg.FieldFromwxid:
  20924. return m.OldFromwxid(ctx)
  20925. case msg.FieldToid:
  20926. return m.OldToid(ctx)
  20927. case msg.FieldMsgtype:
  20928. return m.OldMsgtype(ctx)
  20929. case msg.FieldMsg:
  20930. return m.OldMsg(ctx)
  20931. case msg.FieldBatchNo:
  20932. return m.OldBatchNo(ctx)
  20933. case msg.FieldCc:
  20934. return m.OldCc(ctx)
  20935. case msg.FieldPhone:
  20936. return m.OldPhone(ctx)
  20937. }
  20938. return nil, fmt.Errorf("unknown Msg field %s", name)
  20939. }
  20940. // SetField sets the value of a field with the given name. It returns an error if
  20941. // the field is not defined in the schema, or if the type mismatched the field
  20942. // type.
  20943. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  20944. switch name {
  20945. case msg.FieldCreatedAt:
  20946. v, ok := value.(time.Time)
  20947. if !ok {
  20948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20949. }
  20950. m.SetCreatedAt(v)
  20951. return nil
  20952. case msg.FieldUpdatedAt:
  20953. v, ok := value.(time.Time)
  20954. if !ok {
  20955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20956. }
  20957. m.SetUpdatedAt(v)
  20958. return nil
  20959. case msg.FieldDeletedAt:
  20960. v, ok := value.(time.Time)
  20961. if !ok {
  20962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20963. }
  20964. m.SetDeletedAt(v)
  20965. return nil
  20966. case msg.FieldStatus:
  20967. v, ok := value.(uint8)
  20968. if !ok {
  20969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20970. }
  20971. m.SetStatus(v)
  20972. return nil
  20973. case msg.FieldFromwxid:
  20974. v, ok := value.(string)
  20975. if !ok {
  20976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20977. }
  20978. m.SetFromwxid(v)
  20979. return nil
  20980. case msg.FieldToid:
  20981. v, ok := value.(string)
  20982. if !ok {
  20983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20984. }
  20985. m.SetToid(v)
  20986. return nil
  20987. case msg.FieldMsgtype:
  20988. v, ok := value.(int32)
  20989. if !ok {
  20990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20991. }
  20992. m.SetMsgtype(v)
  20993. return nil
  20994. case msg.FieldMsg:
  20995. v, ok := value.(string)
  20996. if !ok {
  20997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20998. }
  20999. m.SetMsg(v)
  21000. return nil
  21001. case msg.FieldBatchNo:
  21002. v, ok := value.(string)
  21003. if !ok {
  21004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21005. }
  21006. m.SetBatchNo(v)
  21007. return nil
  21008. case msg.FieldCc:
  21009. v, ok := value.(string)
  21010. if !ok {
  21011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21012. }
  21013. m.SetCc(v)
  21014. return nil
  21015. case msg.FieldPhone:
  21016. v, ok := value.(string)
  21017. if !ok {
  21018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21019. }
  21020. m.SetPhone(v)
  21021. return nil
  21022. }
  21023. return fmt.Errorf("unknown Msg field %s", name)
  21024. }
  21025. // AddedFields returns all numeric fields that were incremented/decremented during
  21026. // this mutation.
  21027. func (m *MsgMutation) AddedFields() []string {
  21028. var fields []string
  21029. if m.addstatus != nil {
  21030. fields = append(fields, msg.FieldStatus)
  21031. }
  21032. if m.addmsgtype != nil {
  21033. fields = append(fields, msg.FieldMsgtype)
  21034. }
  21035. return fields
  21036. }
  21037. // AddedField returns the numeric value that was incremented/decremented on a field
  21038. // with the given name. The second boolean return value indicates that this field
  21039. // was not set, or was not defined in the schema.
  21040. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  21041. switch name {
  21042. case msg.FieldStatus:
  21043. return m.AddedStatus()
  21044. case msg.FieldMsgtype:
  21045. return m.AddedMsgtype()
  21046. }
  21047. return nil, false
  21048. }
  21049. // AddField adds the value to the field with the given name. It returns an error if
  21050. // the field is not defined in the schema, or if the type mismatched the field
  21051. // type.
  21052. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  21053. switch name {
  21054. case msg.FieldStatus:
  21055. v, ok := value.(int8)
  21056. if !ok {
  21057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21058. }
  21059. m.AddStatus(v)
  21060. return nil
  21061. case msg.FieldMsgtype:
  21062. v, ok := value.(int32)
  21063. if !ok {
  21064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21065. }
  21066. m.AddMsgtype(v)
  21067. return nil
  21068. }
  21069. return fmt.Errorf("unknown Msg numeric field %s", name)
  21070. }
  21071. // ClearedFields returns all nullable fields that were cleared during this
  21072. // mutation.
  21073. func (m *MsgMutation) ClearedFields() []string {
  21074. var fields []string
  21075. if m.FieldCleared(msg.FieldDeletedAt) {
  21076. fields = append(fields, msg.FieldDeletedAt)
  21077. }
  21078. if m.FieldCleared(msg.FieldStatus) {
  21079. fields = append(fields, msg.FieldStatus)
  21080. }
  21081. if m.FieldCleared(msg.FieldFromwxid) {
  21082. fields = append(fields, msg.FieldFromwxid)
  21083. }
  21084. if m.FieldCleared(msg.FieldToid) {
  21085. fields = append(fields, msg.FieldToid)
  21086. }
  21087. if m.FieldCleared(msg.FieldMsgtype) {
  21088. fields = append(fields, msg.FieldMsgtype)
  21089. }
  21090. if m.FieldCleared(msg.FieldMsg) {
  21091. fields = append(fields, msg.FieldMsg)
  21092. }
  21093. if m.FieldCleared(msg.FieldBatchNo) {
  21094. fields = append(fields, msg.FieldBatchNo)
  21095. }
  21096. return fields
  21097. }
  21098. // FieldCleared returns a boolean indicating if a field with the given name was
  21099. // cleared in this mutation.
  21100. func (m *MsgMutation) FieldCleared(name string) bool {
  21101. _, ok := m.clearedFields[name]
  21102. return ok
  21103. }
  21104. // ClearField clears the value of the field with the given name. It returns an
  21105. // error if the field is not defined in the schema.
  21106. func (m *MsgMutation) ClearField(name string) error {
  21107. switch name {
  21108. case msg.FieldDeletedAt:
  21109. m.ClearDeletedAt()
  21110. return nil
  21111. case msg.FieldStatus:
  21112. m.ClearStatus()
  21113. return nil
  21114. case msg.FieldFromwxid:
  21115. m.ClearFromwxid()
  21116. return nil
  21117. case msg.FieldToid:
  21118. m.ClearToid()
  21119. return nil
  21120. case msg.FieldMsgtype:
  21121. m.ClearMsgtype()
  21122. return nil
  21123. case msg.FieldMsg:
  21124. m.ClearMsg()
  21125. return nil
  21126. case msg.FieldBatchNo:
  21127. m.ClearBatchNo()
  21128. return nil
  21129. }
  21130. return fmt.Errorf("unknown Msg nullable field %s", name)
  21131. }
  21132. // ResetField resets all changes in the mutation for the field with the given name.
  21133. // It returns an error if the field is not defined in the schema.
  21134. func (m *MsgMutation) ResetField(name string) error {
  21135. switch name {
  21136. case msg.FieldCreatedAt:
  21137. m.ResetCreatedAt()
  21138. return nil
  21139. case msg.FieldUpdatedAt:
  21140. m.ResetUpdatedAt()
  21141. return nil
  21142. case msg.FieldDeletedAt:
  21143. m.ResetDeletedAt()
  21144. return nil
  21145. case msg.FieldStatus:
  21146. m.ResetStatus()
  21147. return nil
  21148. case msg.FieldFromwxid:
  21149. m.ResetFromwxid()
  21150. return nil
  21151. case msg.FieldToid:
  21152. m.ResetToid()
  21153. return nil
  21154. case msg.FieldMsgtype:
  21155. m.ResetMsgtype()
  21156. return nil
  21157. case msg.FieldMsg:
  21158. m.ResetMsg()
  21159. return nil
  21160. case msg.FieldBatchNo:
  21161. m.ResetBatchNo()
  21162. return nil
  21163. case msg.FieldCc:
  21164. m.ResetCc()
  21165. return nil
  21166. case msg.FieldPhone:
  21167. m.ResetPhone()
  21168. return nil
  21169. }
  21170. return fmt.Errorf("unknown Msg field %s", name)
  21171. }
  21172. // AddedEdges returns all edge names that were set/added in this mutation.
  21173. func (m *MsgMutation) AddedEdges() []string {
  21174. edges := make([]string, 0, 0)
  21175. return edges
  21176. }
  21177. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21178. // name in this mutation.
  21179. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  21180. return nil
  21181. }
  21182. // RemovedEdges returns all edge names that were removed in this mutation.
  21183. func (m *MsgMutation) RemovedEdges() []string {
  21184. edges := make([]string, 0, 0)
  21185. return edges
  21186. }
  21187. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21188. // the given name in this mutation.
  21189. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  21190. return nil
  21191. }
  21192. // ClearedEdges returns all edge names that were cleared in this mutation.
  21193. func (m *MsgMutation) ClearedEdges() []string {
  21194. edges := make([]string, 0, 0)
  21195. return edges
  21196. }
  21197. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21198. // was cleared in this mutation.
  21199. func (m *MsgMutation) EdgeCleared(name string) bool {
  21200. return false
  21201. }
  21202. // ClearEdge clears the value of the edge with the given name. It returns an error
  21203. // if that edge is not defined in the schema.
  21204. func (m *MsgMutation) ClearEdge(name string) error {
  21205. return fmt.Errorf("unknown Msg unique edge %s", name)
  21206. }
  21207. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21208. // It returns an error if the edge is not defined in the schema.
  21209. func (m *MsgMutation) ResetEdge(name string) error {
  21210. return fmt.Errorf("unknown Msg edge %s", name)
  21211. }
  21212. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  21213. type PayRechargeMutation struct {
  21214. config
  21215. op Op
  21216. typ string
  21217. id *uint64
  21218. created_at *time.Time
  21219. updated_at *time.Time
  21220. deleted_at *time.Time
  21221. user_id *string
  21222. number *float32
  21223. addnumber *float32
  21224. status *int
  21225. addstatus *int
  21226. money *float32
  21227. addmoney *float32
  21228. out_trade_no *string
  21229. organization_id *uint64
  21230. addorganization_id *int64
  21231. clearedFields map[string]struct{}
  21232. done bool
  21233. oldValue func(context.Context) (*PayRecharge, error)
  21234. predicates []predicate.PayRecharge
  21235. }
  21236. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  21237. // payrechargeOption allows management of the mutation configuration using functional options.
  21238. type payrechargeOption func(*PayRechargeMutation)
  21239. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  21240. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  21241. m := &PayRechargeMutation{
  21242. config: c,
  21243. op: op,
  21244. typ: TypePayRecharge,
  21245. clearedFields: make(map[string]struct{}),
  21246. }
  21247. for _, opt := range opts {
  21248. opt(m)
  21249. }
  21250. return m
  21251. }
  21252. // withPayRechargeID sets the ID field of the mutation.
  21253. func withPayRechargeID(id uint64) payrechargeOption {
  21254. return func(m *PayRechargeMutation) {
  21255. var (
  21256. err error
  21257. once sync.Once
  21258. value *PayRecharge
  21259. )
  21260. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  21261. once.Do(func() {
  21262. if m.done {
  21263. err = errors.New("querying old values post mutation is not allowed")
  21264. } else {
  21265. value, err = m.Client().PayRecharge.Get(ctx, id)
  21266. }
  21267. })
  21268. return value, err
  21269. }
  21270. m.id = &id
  21271. }
  21272. }
  21273. // withPayRecharge sets the old PayRecharge of the mutation.
  21274. func withPayRecharge(node *PayRecharge) payrechargeOption {
  21275. return func(m *PayRechargeMutation) {
  21276. m.oldValue = func(context.Context) (*PayRecharge, error) {
  21277. return node, nil
  21278. }
  21279. m.id = &node.ID
  21280. }
  21281. }
  21282. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21283. // executed in a transaction (ent.Tx), a transactional client is returned.
  21284. func (m PayRechargeMutation) Client() *Client {
  21285. client := &Client{config: m.config}
  21286. client.init()
  21287. return client
  21288. }
  21289. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21290. // it returns an error otherwise.
  21291. func (m PayRechargeMutation) Tx() (*Tx, error) {
  21292. if _, ok := m.driver.(*txDriver); !ok {
  21293. return nil, errors.New("ent: mutation is not running in a transaction")
  21294. }
  21295. tx := &Tx{config: m.config}
  21296. tx.init()
  21297. return tx, nil
  21298. }
  21299. // SetID sets the value of the id field. Note that this
  21300. // operation is only accepted on creation of PayRecharge entities.
  21301. func (m *PayRechargeMutation) SetID(id uint64) {
  21302. m.id = &id
  21303. }
  21304. // ID returns the ID value in the mutation. Note that the ID is only available
  21305. // if it was provided to the builder or after it was returned from the database.
  21306. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  21307. if m.id == nil {
  21308. return
  21309. }
  21310. return *m.id, true
  21311. }
  21312. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21313. // That means, if the mutation is applied within a transaction with an isolation level such
  21314. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21315. // or updated by the mutation.
  21316. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  21317. switch {
  21318. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21319. id, exists := m.ID()
  21320. if exists {
  21321. return []uint64{id}, nil
  21322. }
  21323. fallthrough
  21324. case m.op.Is(OpUpdate | OpDelete):
  21325. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  21326. default:
  21327. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21328. }
  21329. }
  21330. // SetCreatedAt sets the "created_at" field.
  21331. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  21332. m.created_at = &t
  21333. }
  21334. // CreatedAt returns the value of the "created_at" field in the mutation.
  21335. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  21336. v := m.created_at
  21337. if v == nil {
  21338. return
  21339. }
  21340. return *v, true
  21341. }
  21342. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  21343. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21345. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21346. if !m.op.Is(OpUpdateOne) {
  21347. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21348. }
  21349. if m.id == nil || m.oldValue == nil {
  21350. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21351. }
  21352. oldValue, err := m.oldValue(ctx)
  21353. if err != nil {
  21354. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21355. }
  21356. return oldValue.CreatedAt, nil
  21357. }
  21358. // ResetCreatedAt resets all changes to the "created_at" field.
  21359. func (m *PayRechargeMutation) ResetCreatedAt() {
  21360. m.created_at = nil
  21361. }
  21362. // SetUpdatedAt sets the "updated_at" field.
  21363. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  21364. m.updated_at = &t
  21365. }
  21366. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21367. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  21368. v := m.updated_at
  21369. if v == nil {
  21370. return
  21371. }
  21372. return *v, true
  21373. }
  21374. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  21375. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21377. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21378. if !m.op.Is(OpUpdateOne) {
  21379. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21380. }
  21381. if m.id == nil || m.oldValue == nil {
  21382. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21383. }
  21384. oldValue, err := m.oldValue(ctx)
  21385. if err != nil {
  21386. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21387. }
  21388. return oldValue.UpdatedAt, nil
  21389. }
  21390. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21391. func (m *PayRechargeMutation) ResetUpdatedAt() {
  21392. m.updated_at = nil
  21393. }
  21394. // SetDeletedAt sets the "deleted_at" field.
  21395. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  21396. m.deleted_at = &t
  21397. }
  21398. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21399. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  21400. v := m.deleted_at
  21401. if v == nil {
  21402. return
  21403. }
  21404. return *v, true
  21405. }
  21406. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  21407. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21409. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21410. if !m.op.Is(OpUpdateOne) {
  21411. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21412. }
  21413. if m.id == nil || m.oldValue == nil {
  21414. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21415. }
  21416. oldValue, err := m.oldValue(ctx)
  21417. if err != nil {
  21418. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21419. }
  21420. return oldValue.DeletedAt, nil
  21421. }
  21422. // ClearDeletedAt clears the value of the "deleted_at" field.
  21423. func (m *PayRechargeMutation) ClearDeletedAt() {
  21424. m.deleted_at = nil
  21425. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  21426. }
  21427. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21428. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  21429. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  21430. return ok
  21431. }
  21432. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21433. func (m *PayRechargeMutation) ResetDeletedAt() {
  21434. m.deleted_at = nil
  21435. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  21436. }
  21437. // SetUserID sets the "user_id" field.
  21438. func (m *PayRechargeMutation) SetUserID(s string) {
  21439. m.user_id = &s
  21440. }
  21441. // UserID returns the value of the "user_id" field in the mutation.
  21442. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  21443. v := m.user_id
  21444. if v == nil {
  21445. return
  21446. }
  21447. return *v, true
  21448. }
  21449. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  21450. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21452. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  21453. if !m.op.Is(OpUpdateOne) {
  21454. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  21455. }
  21456. if m.id == nil || m.oldValue == nil {
  21457. return v, errors.New("OldUserID requires an ID field in the mutation")
  21458. }
  21459. oldValue, err := m.oldValue(ctx)
  21460. if err != nil {
  21461. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  21462. }
  21463. return oldValue.UserID, nil
  21464. }
  21465. // ResetUserID resets all changes to the "user_id" field.
  21466. func (m *PayRechargeMutation) ResetUserID() {
  21467. m.user_id = nil
  21468. }
  21469. // SetNumber sets the "number" field.
  21470. func (m *PayRechargeMutation) SetNumber(f float32) {
  21471. m.number = &f
  21472. m.addnumber = nil
  21473. }
  21474. // Number returns the value of the "number" field in the mutation.
  21475. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  21476. v := m.number
  21477. if v == nil {
  21478. return
  21479. }
  21480. return *v, true
  21481. }
  21482. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  21483. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21485. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  21486. if !m.op.Is(OpUpdateOne) {
  21487. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  21488. }
  21489. if m.id == nil || m.oldValue == nil {
  21490. return v, errors.New("OldNumber requires an ID field in the mutation")
  21491. }
  21492. oldValue, err := m.oldValue(ctx)
  21493. if err != nil {
  21494. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  21495. }
  21496. return oldValue.Number, nil
  21497. }
  21498. // AddNumber adds f to the "number" field.
  21499. func (m *PayRechargeMutation) AddNumber(f float32) {
  21500. if m.addnumber != nil {
  21501. *m.addnumber += f
  21502. } else {
  21503. m.addnumber = &f
  21504. }
  21505. }
  21506. // AddedNumber returns the value that was added to the "number" field in this mutation.
  21507. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  21508. v := m.addnumber
  21509. if v == nil {
  21510. return
  21511. }
  21512. return *v, true
  21513. }
  21514. // ResetNumber resets all changes to the "number" field.
  21515. func (m *PayRechargeMutation) ResetNumber() {
  21516. m.number = nil
  21517. m.addnumber = nil
  21518. }
  21519. // SetStatus sets the "status" field.
  21520. func (m *PayRechargeMutation) SetStatus(i int) {
  21521. m.status = &i
  21522. m.addstatus = nil
  21523. }
  21524. // Status returns the value of the "status" field in the mutation.
  21525. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  21526. v := m.status
  21527. if v == nil {
  21528. return
  21529. }
  21530. return *v, true
  21531. }
  21532. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  21533. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21535. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  21536. if !m.op.Is(OpUpdateOne) {
  21537. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21538. }
  21539. if m.id == nil || m.oldValue == nil {
  21540. return v, errors.New("OldStatus requires an ID field in the mutation")
  21541. }
  21542. oldValue, err := m.oldValue(ctx)
  21543. if err != nil {
  21544. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21545. }
  21546. return oldValue.Status, nil
  21547. }
  21548. // AddStatus adds i to the "status" field.
  21549. func (m *PayRechargeMutation) AddStatus(i int) {
  21550. if m.addstatus != nil {
  21551. *m.addstatus += i
  21552. } else {
  21553. m.addstatus = &i
  21554. }
  21555. }
  21556. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21557. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  21558. v := m.addstatus
  21559. if v == nil {
  21560. return
  21561. }
  21562. return *v, true
  21563. }
  21564. // ClearStatus clears the value of the "status" field.
  21565. func (m *PayRechargeMutation) ClearStatus() {
  21566. m.status = nil
  21567. m.addstatus = nil
  21568. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  21569. }
  21570. // StatusCleared returns if the "status" field was cleared in this mutation.
  21571. func (m *PayRechargeMutation) StatusCleared() bool {
  21572. _, ok := m.clearedFields[payrecharge.FieldStatus]
  21573. return ok
  21574. }
  21575. // ResetStatus resets all changes to the "status" field.
  21576. func (m *PayRechargeMutation) ResetStatus() {
  21577. m.status = nil
  21578. m.addstatus = nil
  21579. delete(m.clearedFields, payrecharge.FieldStatus)
  21580. }
  21581. // SetMoney sets the "money" field.
  21582. func (m *PayRechargeMutation) SetMoney(f float32) {
  21583. m.money = &f
  21584. m.addmoney = nil
  21585. }
  21586. // Money returns the value of the "money" field in the mutation.
  21587. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  21588. v := m.money
  21589. if v == nil {
  21590. return
  21591. }
  21592. return *v, true
  21593. }
  21594. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  21595. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21597. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  21598. if !m.op.Is(OpUpdateOne) {
  21599. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  21600. }
  21601. if m.id == nil || m.oldValue == nil {
  21602. return v, errors.New("OldMoney requires an ID field in the mutation")
  21603. }
  21604. oldValue, err := m.oldValue(ctx)
  21605. if err != nil {
  21606. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  21607. }
  21608. return oldValue.Money, nil
  21609. }
  21610. // AddMoney adds f to the "money" field.
  21611. func (m *PayRechargeMutation) AddMoney(f float32) {
  21612. if m.addmoney != nil {
  21613. *m.addmoney += f
  21614. } else {
  21615. m.addmoney = &f
  21616. }
  21617. }
  21618. // AddedMoney returns the value that was added to the "money" field in this mutation.
  21619. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  21620. v := m.addmoney
  21621. if v == nil {
  21622. return
  21623. }
  21624. return *v, true
  21625. }
  21626. // ClearMoney clears the value of the "money" field.
  21627. func (m *PayRechargeMutation) ClearMoney() {
  21628. m.money = nil
  21629. m.addmoney = nil
  21630. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  21631. }
  21632. // MoneyCleared returns if the "money" field was cleared in this mutation.
  21633. func (m *PayRechargeMutation) MoneyCleared() bool {
  21634. _, ok := m.clearedFields[payrecharge.FieldMoney]
  21635. return ok
  21636. }
  21637. // ResetMoney resets all changes to the "money" field.
  21638. func (m *PayRechargeMutation) ResetMoney() {
  21639. m.money = nil
  21640. m.addmoney = nil
  21641. delete(m.clearedFields, payrecharge.FieldMoney)
  21642. }
  21643. // SetOutTradeNo sets the "out_trade_no" field.
  21644. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  21645. m.out_trade_no = &s
  21646. }
  21647. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  21648. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  21649. v := m.out_trade_no
  21650. if v == nil {
  21651. return
  21652. }
  21653. return *v, true
  21654. }
  21655. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  21656. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21658. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  21659. if !m.op.Is(OpUpdateOne) {
  21660. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  21661. }
  21662. if m.id == nil || m.oldValue == nil {
  21663. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  21664. }
  21665. oldValue, err := m.oldValue(ctx)
  21666. if err != nil {
  21667. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  21668. }
  21669. return oldValue.OutTradeNo, nil
  21670. }
  21671. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  21672. func (m *PayRechargeMutation) ClearOutTradeNo() {
  21673. m.out_trade_no = nil
  21674. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  21675. }
  21676. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  21677. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  21678. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  21679. return ok
  21680. }
  21681. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  21682. func (m *PayRechargeMutation) ResetOutTradeNo() {
  21683. m.out_trade_no = nil
  21684. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  21685. }
  21686. // SetOrganizationID sets the "organization_id" field.
  21687. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  21688. m.organization_id = &u
  21689. m.addorganization_id = nil
  21690. }
  21691. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21692. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  21693. v := m.organization_id
  21694. if v == nil {
  21695. return
  21696. }
  21697. return *v, true
  21698. }
  21699. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  21700. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21702. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21703. if !m.op.Is(OpUpdateOne) {
  21704. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21705. }
  21706. if m.id == nil || m.oldValue == nil {
  21707. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21708. }
  21709. oldValue, err := m.oldValue(ctx)
  21710. if err != nil {
  21711. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21712. }
  21713. return oldValue.OrganizationID, nil
  21714. }
  21715. // AddOrganizationID adds u to the "organization_id" field.
  21716. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  21717. if m.addorganization_id != nil {
  21718. *m.addorganization_id += u
  21719. } else {
  21720. m.addorganization_id = &u
  21721. }
  21722. }
  21723. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21724. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  21725. v := m.addorganization_id
  21726. if v == nil {
  21727. return
  21728. }
  21729. return *v, true
  21730. }
  21731. // ResetOrganizationID resets all changes to the "organization_id" field.
  21732. func (m *PayRechargeMutation) ResetOrganizationID() {
  21733. m.organization_id = nil
  21734. m.addorganization_id = nil
  21735. }
  21736. // Where appends a list predicates to the PayRechargeMutation builder.
  21737. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  21738. m.predicates = append(m.predicates, ps...)
  21739. }
  21740. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  21741. // users can use type-assertion to append predicates that do not depend on any generated package.
  21742. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  21743. p := make([]predicate.PayRecharge, len(ps))
  21744. for i := range ps {
  21745. p[i] = ps[i]
  21746. }
  21747. m.Where(p...)
  21748. }
  21749. // Op returns the operation name.
  21750. func (m *PayRechargeMutation) Op() Op {
  21751. return m.op
  21752. }
  21753. // SetOp allows setting the mutation operation.
  21754. func (m *PayRechargeMutation) SetOp(op Op) {
  21755. m.op = op
  21756. }
  21757. // Type returns the node type of this mutation (PayRecharge).
  21758. func (m *PayRechargeMutation) Type() string {
  21759. return m.typ
  21760. }
  21761. // Fields returns all fields that were changed during this mutation. Note that in
  21762. // order to get all numeric fields that were incremented/decremented, call
  21763. // AddedFields().
  21764. func (m *PayRechargeMutation) Fields() []string {
  21765. fields := make([]string, 0, 9)
  21766. if m.created_at != nil {
  21767. fields = append(fields, payrecharge.FieldCreatedAt)
  21768. }
  21769. if m.updated_at != nil {
  21770. fields = append(fields, payrecharge.FieldUpdatedAt)
  21771. }
  21772. if m.deleted_at != nil {
  21773. fields = append(fields, payrecharge.FieldDeletedAt)
  21774. }
  21775. if m.user_id != nil {
  21776. fields = append(fields, payrecharge.FieldUserID)
  21777. }
  21778. if m.number != nil {
  21779. fields = append(fields, payrecharge.FieldNumber)
  21780. }
  21781. if m.status != nil {
  21782. fields = append(fields, payrecharge.FieldStatus)
  21783. }
  21784. if m.money != nil {
  21785. fields = append(fields, payrecharge.FieldMoney)
  21786. }
  21787. if m.out_trade_no != nil {
  21788. fields = append(fields, payrecharge.FieldOutTradeNo)
  21789. }
  21790. if m.organization_id != nil {
  21791. fields = append(fields, payrecharge.FieldOrganizationID)
  21792. }
  21793. return fields
  21794. }
  21795. // Field returns the value of a field with the given name. The second boolean
  21796. // return value indicates that this field was not set, or was not defined in the
  21797. // schema.
  21798. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  21799. switch name {
  21800. case payrecharge.FieldCreatedAt:
  21801. return m.CreatedAt()
  21802. case payrecharge.FieldUpdatedAt:
  21803. return m.UpdatedAt()
  21804. case payrecharge.FieldDeletedAt:
  21805. return m.DeletedAt()
  21806. case payrecharge.FieldUserID:
  21807. return m.UserID()
  21808. case payrecharge.FieldNumber:
  21809. return m.Number()
  21810. case payrecharge.FieldStatus:
  21811. return m.Status()
  21812. case payrecharge.FieldMoney:
  21813. return m.Money()
  21814. case payrecharge.FieldOutTradeNo:
  21815. return m.OutTradeNo()
  21816. case payrecharge.FieldOrganizationID:
  21817. return m.OrganizationID()
  21818. }
  21819. return nil, false
  21820. }
  21821. // OldField returns the old value of the field from the database. An error is
  21822. // returned if the mutation operation is not UpdateOne, or the query to the
  21823. // database failed.
  21824. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21825. switch name {
  21826. case payrecharge.FieldCreatedAt:
  21827. return m.OldCreatedAt(ctx)
  21828. case payrecharge.FieldUpdatedAt:
  21829. return m.OldUpdatedAt(ctx)
  21830. case payrecharge.FieldDeletedAt:
  21831. return m.OldDeletedAt(ctx)
  21832. case payrecharge.FieldUserID:
  21833. return m.OldUserID(ctx)
  21834. case payrecharge.FieldNumber:
  21835. return m.OldNumber(ctx)
  21836. case payrecharge.FieldStatus:
  21837. return m.OldStatus(ctx)
  21838. case payrecharge.FieldMoney:
  21839. return m.OldMoney(ctx)
  21840. case payrecharge.FieldOutTradeNo:
  21841. return m.OldOutTradeNo(ctx)
  21842. case payrecharge.FieldOrganizationID:
  21843. return m.OldOrganizationID(ctx)
  21844. }
  21845. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  21846. }
  21847. // SetField sets the value of a field with the given name. It returns an error if
  21848. // the field is not defined in the schema, or if the type mismatched the field
  21849. // type.
  21850. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  21851. switch name {
  21852. case payrecharge.FieldCreatedAt:
  21853. v, ok := value.(time.Time)
  21854. if !ok {
  21855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21856. }
  21857. m.SetCreatedAt(v)
  21858. return nil
  21859. case payrecharge.FieldUpdatedAt:
  21860. v, ok := value.(time.Time)
  21861. if !ok {
  21862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21863. }
  21864. m.SetUpdatedAt(v)
  21865. return nil
  21866. case payrecharge.FieldDeletedAt:
  21867. v, ok := value.(time.Time)
  21868. if !ok {
  21869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21870. }
  21871. m.SetDeletedAt(v)
  21872. return nil
  21873. case payrecharge.FieldUserID:
  21874. v, ok := value.(string)
  21875. if !ok {
  21876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21877. }
  21878. m.SetUserID(v)
  21879. return nil
  21880. case payrecharge.FieldNumber:
  21881. v, ok := value.(float32)
  21882. if !ok {
  21883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21884. }
  21885. m.SetNumber(v)
  21886. return nil
  21887. case payrecharge.FieldStatus:
  21888. v, ok := value.(int)
  21889. if !ok {
  21890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21891. }
  21892. m.SetStatus(v)
  21893. return nil
  21894. case payrecharge.FieldMoney:
  21895. v, ok := value.(float32)
  21896. if !ok {
  21897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21898. }
  21899. m.SetMoney(v)
  21900. return nil
  21901. case payrecharge.FieldOutTradeNo:
  21902. v, ok := value.(string)
  21903. if !ok {
  21904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21905. }
  21906. m.SetOutTradeNo(v)
  21907. return nil
  21908. case payrecharge.FieldOrganizationID:
  21909. v, ok := value.(uint64)
  21910. if !ok {
  21911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21912. }
  21913. m.SetOrganizationID(v)
  21914. return nil
  21915. }
  21916. return fmt.Errorf("unknown PayRecharge field %s", name)
  21917. }
  21918. // AddedFields returns all numeric fields that were incremented/decremented during
  21919. // this mutation.
  21920. func (m *PayRechargeMutation) AddedFields() []string {
  21921. var fields []string
  21922. if m.addnumber != nil {
  21923. fields = append(fields, payrecharge.FieldNumber)
  21924. }
  21925. if m.addstatus != nil {
  21926. fields = append(fields, payrecharge.FieldStatus)
  21927. }
  21928. if m.addmoney != nil {
  21929. fields = append(fields, payrecharge.FieldMoney)
  21930. }
  21931. if m.addorganization_id != nil {
  21932. fields = append(fields, payrecharge.FieldOrganizationID)
  21933. }
  21934. return fields
  21935. }
  21936. // AddedField returns the numeric value that was incremented/decremented on a field
  21937. // with the given name. The second boolean return value indicates that this field
  21938. // was not set, or was not defined in the schema.
  21939. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  21940. switch name {
  21941. case payrecharge.FieldNumber:
  21942. return m.AddedNumber()
  21943. case payrecharge.FieldStatus:
  21944. return m.AddedStatus()
  21945. case payrecharge.FieldMoney:
  21946. return m.AddedMoney()
  21947. case payrecharge.FieldOrganizationID:
  21948. return m.AddedOrganizationID()
  21949. }
  21950. return nil, false
  21951. }
  21952. // AddField adds the value to the field with the given name. It returns an error if
  21953. // the field is not defined in the schema, or if the type mismatched the field
  21954. // type.
  21955. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  21956. switch name {
  21957. case payrecharge.FieldNumber:
  21958. v, ok := value.(float32)
  21959. if !ok {
  21960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21961. }
  21962. m.AddNumber(v)
  21963. return nil
  21964. case payrecharge.FieldStatus:
  21965. v, ok := value.(int)
  21966. if !ok {
  21967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21968. }
  21969. m.AddStatus(v)
  21970. return nil
  21971. case payrecharge.FieldMoney:
  21972. v, ok := value.(float32)
  21973. if !ok {
  21974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21975. }
  21976. m.AddMoney(v)
  21977. return nil
  21978. case payrecharge.FieldOrganizationID:
  21979. v, ok := value.(int64)
  21980. if !ok {
  21981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21982. }
  21983. m.AddOrganizationID(v)
  21984. return nil
  21985. }
  21986. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  21987. }
  21988. // ClearedFields returns all nullable fields that were cleared during this
  21989. // mutation.
  21990. func (m *PayRechargeMutation) ClearedFields() []string {
  21991. var fields []string
  21992. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  21993. fields = append(fields, payrecharge.FieldDeletedAt)
  21994. }
  21995. if m.FieldCleared(payrecharge.FieldStatus) {
  21996. fields = append(fields, payrecharge.FieldStatus)
  21997. }
  21998. if m.FieldCleared(payrecharge.FieldMoney) {
  21999. fields = append(fields, payrecharge.FieldMoney)
  22000. }
  22001. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  22002. fields = append(fields, payrecharge.FieldOutTradeNo)
  22003. }
  22004. return fields
  22005. }
  22006. // FieldCleared returns a boolean indicating if a field with the given name was
  22007. // cleared in this mutation.
  22008. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  22009. _, ok := m.clearedFields[name]
  22010. return ok
  22011. }
  22012. // ClearField clears the value of the field with the given name. It returns an
  22013. // error if the field is not defined in the schema.
  22014. func (m *PayRechargeMutation) ClearField(name string) error {
  22015. switch name {
  22016. case payrecharge.FieldDeletedAt:
  22017. m.ClearDeletedAt()
  22018. return nil
  22019. case payrecharge.FieldStatus:
  22020. m.ClearStatus()
  22021. return nil
  22022. case payrecharge.FieldMoney:
  22023. m.ClearMoney()
  22024. return nil
  22025. case payrecharge.FieldOutTradeNo:
  22026. m.ClearOutTradeNo()
  22027. return nil
  22028. }
  22029. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  22030. }
  22031. // ResetField resets all changes in the mutation for the field with the given name.
  22032. // It returns an error if the field is not defined in the schema.
  22033. func (m *PayRechargeMutation) ResetField(name string) error {
  22034. switch name {
  22035. case payrecharge.FieldCreatedAt:
  22036. m.ResetCreatedAt()
  22037. return nil
  22038. case payrecharge.FieldUpdatedAt:
  22039. m.ResetUpdatedAt()
  22040. return nil
  22041. case payrecharge.FieldDeletedAt:
  22042. m.ResetDeletedAt()
  22043. return nil
  22044. case payrecharge.FieldUserID:
  22045. m.ResetUserID()
  22046. return nil
  22047. case payrecharge.FieldNumber:
  22048. m.ResetNumber()
  22049. return nil
  22050. case payrecharge.FieldStatus:
  22051. m.ResetStatus()
  22052. return nil
  22053. case payrecharge.FieldMoney:
  22054. m.ResetMoney()
  22055. return nil
  22056. case payrecharge.FieldOutTradeNo:
  22057. m.ResetOutTradeNo()
  22058. return nil
  22059. case payrecharge.FieldOrganizationID:
  22060. m.ResetOrganizationID()
  22061. return nil
  22062. }
  22063. return fmt.Errorf("unknown PayRecharge field %s", name)
  22064. }
  22065. // AddedEdges returns all edge names that were set/added in this mutation.
  22066. func (m *PayRechargeMutation) AddedEdges() []string {
  22067. edges := make([]string, 0, 0)
  22068. return edges
  22069. }
  22070. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22071. // name in this mutation.
  22072. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  22073. return nil
  22074. }
  22075. // RemovedEdges returns all edge names that were removed in this mutation.
  22076. func (m *PayRechargeMutation) RemovedEdges() []string {
  22077. edges := make([]string, 0, 0)
  22078. return edges
  22079. }
  22080. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22081. // the given name in this mutation.
  22082. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  22083. return nil
  22084. }
  22085. // ClearedEdges returns all edge names that were cleared in this mutation.
  22086. func (m *PayRechargeMutation) ClearedEdges() []string {
  22087. edges := make([]string, 0, 0)
  22088. return edges
  22089. }
  22090. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22091. // was cleared in this mutation.
  22092. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  22093. return false
  22094. }
  22095. // ClearEdge clears the value of the edge with the given name. It returns an error
  22096. // if that edge is not defined in the schema.
  22097. func (m *PayRechargeMutation) ClearEdge(name string) error {
  22098. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  22099. }
  22100. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22101. // It returns an error if the edge is not defined in the schema.
  22102. func (m *PayRechargeMutation) ResetEdge(name string) error {
  22103. return fmt.Errorf("unknown PayRecharge edge %s", name)
  22104. }
  22105. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  22106. type ServerMutation struct {
  22107. config
  22108. op Op
  22109. typ string
  22110. id *uint64
  22111. created_at *time.Time
  22112. updated_at *time.Time
  22113. status *uint8
  22114. addstatus *int8
  22115. deleted_at *time.Time
  22116. name *string
  22117. public_ip *string
  22118. private_ip *string
  22119. admin_port *string
  22120. clearedFields map[string]struct{}
  22121. wxs map[uint64]struct{}
  22122. removedwxs map[uint64]struct{}
  22123. clearedwxs bool
  22124. done bool
  22125. oldValue func(context.Context) (*Server, error)
  22126. predicates []predicate.Server
  22127. }
  22128. var _ ent.Mutation = (*ServerMutation)(nil)
  22129. // serverOption allows management of the mutation configuration using functional options.
  22130. type serverOption func(*ServerMutation)
  22131. // newServerMutation creates new mutation for the Server entity.
  22132. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  22133. m := &ServerMutation{
  22134. config: c,
  22135. op: op,
  22136. typ: TypeServer,
  22137. clearedFields: make(map[string]struct{}),
  22138. }
  22139. for _, opt := range opts {
  22140. opt(m)
  22141. }
  22142. return m
  22143. }
  22144. // withServerID sets the ID field of the mutation.
  22145. func withServerID(id uint64) serverOption {
  22146. return func(m *ServerMutation) {
  22147. var (
  22148. err error
  22149. once sync.Once
  22150. value *Server
  22151. )
  22152. m.oldValue = func(ctx context.Context) (*Server, error) {
  22153. once.Do(func() {
  22154. if m.done {
  22155. err = errors.New("querying old values post mutation is not allowed")
  22156. } else {
  22157. value, err = m.Client().Server.Get(ctx, id)
  22158. }
  22159. })
  22160. return value, err
  22161. }
  22162. m.id = &id
  22163. }
  22164. }
  22165. // withServer sets the old Server of the mutation.
  22166. func withServer(node *Server) serverOption {
  22167. return func(m *ServerMutation) {
  22168. m.oldValue = func(context.Context) (*Server, error) {
  22169. return node, nil
  22170. }
  22171. m.id = &node.ID
  22172. }
  22173. }
  22174. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22175. // executed in a transaction (ent.Tx), a transactional client is returned.
  22176. func (m ServerMutation) Client() *Client {
  22177. client := &Client{config: m.config}
  22178. client.init()
  22179. return client
  22180. }
  22181. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22182. // it returns an error otherwise.
  22183. func (m ServerMutation) Tx() (*Tx, error) {
  22184. if _, ok := m.driver.(*txDriver); !ok {
  22185. return nil, errors.New("ent: mutation is not running in a transaction")
  22186. }
  22187. tx := &Tx{config: m.config}
  22188. tx.init()
  22189. return tx, nil
  22190. }
  22191. // SetID sets the value of the id field. Note that this
  22192. // operation is only accepted on creation of Server entities.
  22193. func (m *ServerMutation) SetID(id uint64) {
  22194. m.id = &id
  22195. }
  22196. // ID returns the ID value in the mutation. Note that the ID is only available
  22197. // if it was provided to the builder or after it was returned from the database.
  22198. func (m *ServerMutation) ID() (id uint64, exists bool) {
  22199. if m.id == nil {
  22200. return
  22201. }
  22202. return *m.id, true
  22203. }
  22204. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22205. // That means, if the mutation is applied within a transaction with an isolation level such
  22206. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22207. // or updated by the mutation.
  22208. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  22209. switch {
  22210. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22211. id, exists := m.ID()
  22212. if exists {
  22213. return []uint64{id}, nil
  22214. }
  22215. fallthrough
  22216. case m.op.Is(OpUpdate | OpDelete):
  22217. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  22218. default:
  22219. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22220. }
  22221. }
  22222. // SetCreatedAt sets the "created_at" field.
  22223. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  22224. m.created_at = &t
  22225. }
  22226. // CreatedAt returns the value of the "created_at" field in the mutation.
  22227. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  22228. v := m.created_at
  22229. if v == nil {
  22230. return
  22231. }
  22232. return *v, true
  22233. }
  22234. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  22235. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22237. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22238. if !m.op.Is(OpUpdateOne) {
  22239. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22240. }
  22241. if m.id == nil || m.oldValue == nil {
  22242. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22243. }
  22244. oldValue, err := m.oldValue(ctx)
  22245. if err != nil {
  22246. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22247. }
  22248. return oldValue.CreatedAt, nil
  22249. }
  22250. // ResetCreatedAt resets all changes to the "created_at" field.
  22251. func (m *ServerMutation) ResetCreatedAt() {
  22252. m.created_at = nil
  22253. }
  22254. // SetUpdatedAt sets the "updated_at" field.
  22255. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  22256. m.updated_at = &t
  22257. }
  22258. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22259. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  22260. v := m.updated_at
  22261. if v == nil {
  22262. return
  22263. }
  22264. return *v, true
  22265. }
  22266. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  22267. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22269. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22270. if !m.op.Is(OpUpdateOne) {
  22271. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22272. }
  22273. if m.id == nil || m.oldValue == nil {
  22274. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22275. }
  22276. oldValue, err := m.oldValue(ctx)
  22277. if err != nil {
  22278. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22279. }
  22280. return oldValue.UpdatedAt, nil
  22281. }
  22282. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22283. func (m *ServerMutation) ResetUpdatedAt() {
  22284. m.updated_at = nil
  22285. }
  22286. // SetStatus sets the "status" field.
  22287. func (m *ServerMutation) SetStatus(u uint8) {
  22288. m.status = &u
  22289. m.addstatus = nil
  22290. }
  22291. // Status returns the value of the "status" field in the mutation.
  22292. func (m *ServerMutation) Status() (r uint8, exists bool) {
  22293. v := m.status
  22294. if v == nil {
  22295. return
  22296. }
  22297. return *v, true
  22298. }
  22299. // OldStatus returns the old "status" field's value of the Server entity.
  22300. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22302. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22303. if !m.op.Is(OpUpdateOne) {
  22304. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22305. }
  22306. if m.id == nil || m.oldValue == nil {
  22307. return v, errors.New("OldStatus requires an ID field in the mutation")
  22308. }
  22309. oldValue, err := m.oldValue(ctx)
  22310. if err != nil {
  22311. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22312. }
  22313. return oldValue.Status, nil
  22314. }
  22315. // AddStatus adds u to the "status" field.
  22316. func (m *ServerMutation) AddStatus(u int8) {
  22317. if m.addstatus != nil {
  22318. *m.addstatus += u
  22319. } else {
  22320. m.addstatus = &u
  22321. }
  22322. }
  22323. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22324. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  22325. v := m.addstatus
  22326. if v == nil {
  22327. return
  22328. }
  22329. return *v, true
  22330. }
  22331. // ClearStatus clears the value of the "status" field.
  22332. func (m *ServerMutation) ClearStatus() {
  22333. m.status = nil
  22334. m.addstatus = nil
  22335. m.clearedFields[server.FieldStatus] = struct{}{}
  22336. }
  22337. // StatusCleared returns if the "status" field was cleared in this mutation.
  22338. func (m *ServerMutation) StatusCleared() bool {
  22339. _, ok := m.clearedFields[server.FieldStatus]
  22340. return ok
  22341. }
  22342. // ResetStatus resets all changes to the "status" field.
  22343. func (m *ServerMutation) ResetStatus() {
  22344. m.status = nil
  22345. m.addstatus = nil
  22346. delete(m.clearedFields, server.FieldStatus)
  22347. }
  22348. // SetDeletedAt sets the "deleted_at" field.
  22349. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  22350. m.deleted_at = &t
  22351. }
  22352. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22353. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  22354. v := m.deleted_at
  22355. if v == nil {
  22356. return
  22357. }
  22358. return *v, true
  22359. }
  22360. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  22361. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22363. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22364. if !m.op.Is(OpUpdateOne) {
  22365. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22366. }
  22367. if m.id == nil || m.oldValue == nil {
  22368. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22369. }
  22370. oldValue, err := m.oldValue(ctx)
  22371. if err != nil {
  22372. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22373. }
  22374. return oldValue.DeletedAt, nil
  22375. }
  22376. // ClearDeletedAt clears the value of the "deleted_at" field.
  22377. func (m *ServerMutation) ClearDeletedAt() {
  22378. m.deleted_at = nil
  22379. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  22380. }
  22381. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22382. func (m *ServerMutation) DeletedAtCleared() bool {
  22383. _, ok := m.clearedFields[server.FieldDeletedAt]
  22384. return ok
  22385. }
  22386. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22387. func (m *ServerMutation) ResetDeletedAt() {
  22388. m.deleted_at = nil
  22389. delete(m.clearedFields, server.FieldDeletedAt)
  22390. }
  22391. // SetName sets the "name" field.
  22392. func (m *ServerMutation) SetName(s string) {
  22393. m.name = &s
  22394. }
  22395. // Name returns the value of the "name" field in the mutation.
  22396. func (m *ServerMutation) Name() (r string, exists bool) {
  22397. v := m.name
  22398. if v == nil {
  22399. return
  22400. }
  22401. return *v, true
  22402. }
  22403. // OldName returns the old "name" field's value of the Server entity.
  22404. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22406. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  22407. if !m.op.Is(OpUpdateOne) {
  22408. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22409. }
  22410. if m.id == nil || m.oldValue == nil {
  22411. return v, errors.New("OldName requires an ID field in the mutation")
  22412. }
  22413. oldValue, err := m.oldValue(ctx)
  22414. if err != nil {
  22415. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22416. }
  22417. return oldValue.Name, nil
  22418. }
  22419. // ResetName resets all changes to the "name" field.
  22420. func (m *ServerMutation) ResetName() {
  22421. m.name = nil
  22422. }
  22423. // SetPublicIP sets the "public_ip" field.
  22424. func (m *ServerMutation) SetPublicIP(s string) {
  22425. m.public_ip = &s
  22426. }
  22427. // PublicIP returns the value of the "public_ip" field in the mutation.
  22428. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  22429. v := m.public_ip
  22430. if v == nil {
  22431. return
  22432. }
  22433. return *v, true
  22434. }
  22435. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  22436. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22438. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  22439. if !m.op.Is(OpUpdateOne) {
  22440. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  22441. }
  22442. if m.id == nil || m.oldValue == nil {
  22443. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  22444. }
  22445. oldValue, err := m.oldValue(ctx)
  22446. if err != nil {
  22447. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  22448. }
  22449. return oldValue.PublicIP, nil
  22450. }
  22451. // ResetPublicIP resets all changes to the "public_ip" field.
  22452. func (m *ServerMutation) ResetPublicIP() {
  22453. m.public_ip = nil
  22454. }
  22455. // SetPrivateIP sets the "private_ip" field.
  22456. func (m *ServerMutation) SetPrivateIP(s string) {
  22457. m.private_ip = &s
  22458. }
  22459. // PrivateIP returns the value of the "private_ip" field in the mutation.
  22460. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  22461. v := m.private_ip
  22462. if v == nil {
  22463. return
  22464. }
  22465. return *v, true
  22466. }
  22467. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  22468. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22470. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  22471. if !m.op.Is(OpUpdateOne) {
  22472. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  22473. }
  22474. if m.id == nil || m.oldValue == nil {
  22475. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  22476. }
  22477. oldValue, err := m.oldValue(ctx)
  22478. if err != nil {
  22479. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  22480. }
  22481. return oldValue.PrivateIP, nil
  22482. }
  22483. // ResetPrivateIP resets all changes to the "private_ip" field.
  22484. func (m *ServerMutation) ResetPrivateIP() {
  22485. m.private_ip = nil
  22486. }
  22487. // SetAdminPort sets the "admin_port" field.
  22488. func (m *ServerMutation) SetAdminPort(s string) {
  22489. m.admin_port = &s
  22490. }
  22491. // AdminPort returns the value of the "admin_port" field in the mutation.
  22492. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  22493. v := m.admin_port
  22494. if v == nil {
  22495. return
  22496. }
  22497. return *v, true
  22498. }
  22499. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  22500. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22502. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  22503. if !m.op.Is(OpUpdateOne) {
  22504. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  22505. }
  22506. if m.id == nil || m.oldValue == nil {
  22507. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  22508. }
  22509. oldValue, err := m.oldValue(ctx)
  22510. if err != nil {
  22511. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  22512. }
  22513. return oldValue.AdminPort, nil
  22514. }
  22515. // ResetAdminPort resets all changes to the "admin_port" field.
  22516. func (m *ServerMutation) ResetAdminPort() {
  22517. m.admin_port = nil
  22518. }
  22519. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  22520. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  22521. if m.wxs == nil {
  22522. m.wxs = make(map[uint64]struct{})
  22523. }
  22524. for i := range ids {
  22525. m.wxs[ids[i]] = struct{}{}
  22526. }
  22527. }
  22528. // ClearWxs clears the "wxs" edge to the Wx entity.
  22529. func (m *ServerMutation) ClearWxs() {
  22530. m.clearedwxs = true
  22531. }
  22532. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  22533. func (m *ServerMutation) WxsCleared() bool {
  22534. return m.clearedwxs
  22535. }
  22536. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  22537. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  22538. if m.removedwxs == nil {
  22539. m.removedwxs = make(map[uint64]struct{})
  22540. }
  22541. for i := range ids {
  22542. delete(m.wxs, ids[i])
  22543. m.removedwxs[ids[i]] = struct{}{}
  22544. }
  22545. }
  22546. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  22547. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  22548. for id := range m.removedwxs {
  22549. ids = append(ids, id)
  22550. }
  22551. return
  22552. }
  22553. // WxsIDs returns the "wxs" edge IDs in the mutation.
  22554. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  22555. for id := range m.wxs {
  22556. ids = append(ids, id)
  22557. }
  22558. return
  22559. }
  22560. // ResetWxs resets all changes to the "wxs" edge.
  22561. func (m *ServerMutation) ResetWxs() {
  22562. m.wxs = nil
  22563. m.clearedwxs = false
  22564. m.removedwxs = nil
  22565. }
  22566. // Where appends a list predicates to the ServerMutation builder.
  22567. func (m *ServerMutation) Where(ps ...predicate.Server) {
  22568. m.predicates = append(m.predicates, ps...)
  22569. }
  22570. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  22571. // users can use type-assertion to append predicates that do not depend on any generated package.
  22572. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  22573. p := make([]predicate.Server, len(ps))
  22574. for i := range ps {
  22575. p[i] = ps[i]
  22576. }
  22577. m.Where(p...)
  22578. }
  22579. // Op returns the operation name.
  22580. func (m *ServerMutation) Op() Op {
  22581. return m.op
  22582. }
  22583. // SetOp allows setting the mutation operation.
  22584. func (m *ServerMutation) SetOp(op Op) {
  22585. m.op = op
  22586. }
  22587. // Type returns the node type of this mutation (Server).
  22588. func (m *ServerMutation) Type() string {
  22589. return m.typ
  22590. }
  22591. // Fields returns all fields that were changed during this mutation. Note that in
  22592. // order to get all numeric fields that were incremented/decremented, call
  22593. // AddedFields().
  22594. func (m *ServerMutation) Fields() []string {
  22595. fields := make([]string, 0, 8)
  22596. if m.created_at != nil {
  22597. fields = append(fields, server.FieldCreatedAt)
  22598. }
  22599. if m.updated_at != nil {
  22600. fields = append(fields, server.FieldUpdatedAt)
  22601. }
  22602. if m.status != nil {
  22603. fields = append(fields, server.FieldStatus)
  22604. }
  22605. if m.deleted_at != nil {
  22606. fields = append(fields, server.FieldDeletedAt)
  22607. }
  22608. if m.name != nil {
  22609. fields = append(fields, server.FieldName)
  22610. }
  22611. if m.public_ip != nil {
  22612. fields = append(fields, server.FieldPublicIP)
  22613. }
  22614. if m.private_ip != nil {
  22615. fields = append(fields, server.FieldPrivateIP)
  22616. }
  22617. if m.admin_port != nil {
  22618. fields = append(fields, server.FieldAdminPort)
  22619. }
  22620. return fields
  22621. }
  22622. // Field returns the value of a field with the given name. The second boolean
  22623. // return value indicates that this field was not set, or was not defined in the
  22624. // schema.
  22625. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  22626. switch name {
  22627. case server.FieldCreatedAt:
  22628. return m.CreatedAt()
  22629. case server.FieldUpdatedAt:
  22630. return m.UpdatedAt()
  22631. case server.FieldStatus:
  22632. return m.Status()
  22633. case server.FieldDeletedAt:
  22634. return m.DeletedAt()
  22635. case server.FieldName:
  22636. return m.Name()
  22637. case server.FieldPublicIP:
  22638. return m.PublicIP()
  22639. case server.FieldPrivateIP:
  22640. return m.PrivateIP()
  22641. case server.FieldAdminPort:
  22642. return m.AdminPort()
  22643. }
  22644. return nil, false
  22645. }
  22646. // OldField returns the old value of the field from the database. An error is
  22647. // returned if the mutation operation is not UpdateOne, or the query to the
  22648. // database failed.
  22649. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22650. switch name {
  22651. case server.FieldCreatedAt:
  22652. return m.OldCreatedAt(ctx)
  22653. case server.FieldUpdatedAt:
  22654. return m.OldUpdatedAt(ctx)
  22655. case server.FieldStatus:
  22656. return m.OldStatus(ctx)
  22657. case server.FieldDeletedAt:
  22658. return m.OldDeletedAt(ctx)
  22659. case server.FieldName:
  22660. return m.OldName(ctx)
  22661. case server.FieldPublicIP:
  22662. return m.OldPublicIP(ctx)
  22663. case server.FieldPrivateIP:
  22664. return m.OldPrivateIP(ctx)
  22665. case server.FieldAdminPort:
  22666. return m.OldAdminPort(ctx)
  22667. }
  22668. return nil, fmt.Errorf("unknown Server field %s", name)
  22669. }
  22670. // SetField sets the value of a field with the given name. It returns an error if
  22671. // the field is not defined in the schema, or if the type mismatched the field
  22672. // type.
  22673. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  22674. switch name {
  22675. case server.FieldCreatedAt:
  22676. v, ok := value.(time.Time)
  22677. if !ok {
  22678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22679. }
  22680. m.SetCreatedAt(v)
  22681. return nil
  22682. case server.FieldUpdatedAt:
  22683. v, ok := value.(time.Time)
  22684. if !ok {
  22685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22686. }
  22687. m.SetUpdatedAt(v)
  22688. return nil
  22689. case server.FieldStatus:
  22690. v, ok := value.(uint8)
  22691. if !ok {
  22692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22693. }
  22694. m.SetStatus(v)
  22695. return nil
  22696. case server.FieldDeletedAt:
  22697. v, ok := value.(time.Time)
  22698. if !ok {
  22699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22700. }
  22701. m.SetDeletedAt(v)
  22702. return nil
  22703. case server.FieldName:
  22704. v, ok := value.(string)
  22705. if !ok {
  22706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22707. }
  22708. m.SetName(v)
  22709. return nil
  22710. case server.FieldPublicIP:
  22711. v, ok := value.(string)
  22712. if !ok {
  22713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22714. }
  22715. m.SetPublicIP(v)
  22716. return nil
  22717. case server.FieldPrivateIP:
  22718. v, ok := value.(string)
  22719. if !ok {
  22720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22721. }
  22722. m.SetPrivateIP(v)
  22723. return nil
  22724. case server.FieldAdminPort:
  22725. v, ok := value.(string)
  22726. if !ok {
  22727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22728. }
  22729. m.SetAdminPort(v)
  22730. return nil
  22731. }
  22732. return fmt.Errorf("unknown Server field %s", name)
  22733. }
  22734. // AddedFields returns all numeric fields that were incremented/decremented during
  22735. // this mutation.
  22736. func (m *ServerMutation) AddedFields() []string {
  22737. var fields []string
  22738. if m.addstatus != nil {
  22739. fields = append(fields, server.FieldStatus)
  22740. }
  22741. return fields
  22742. }
  22743. // AddedField returns the numeric value that was incremented/decremented on a field
  22744. // with the given name. The second boolean return value indicates that this field
  22745. // was not set, or was not defined in the schema.
  22746. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  22747. switch name {
  22748. case server.FieldStatus:
  22749. return m.AddedStatus()
  22750. }
  22751. return nil, false
  22752. }
  22753. // AddField adds the value to the field with the given name. It returns an error if
  22754. // the field is not defined in the schema, or if the type mismatched the field
  22755. // type.
  22756. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  22757. switch name {
  22758. case server.FieldStatus:
  22759. v, ok := value.(int8)
  22760. if !ok {
  22761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22762. }
  22763. m.AddStatus(v)
  22764. return nil
  22765. }
  22766. return fmt.Errorf("unknown Server numeric field %s", name)
  22767. }
  22768. // ClearedFields returns all nullable fields that were cleared during this
  22769. // mutation.
  22770. func (m *ServerMutation) ClearedFields() []string {
  22771. var fields []string
  22772. if m.FieldCleared(server.FieldStatus) {
  22773. fields = append(fields, server.FieldStatus)
  22774. }
  22775. if m.FieldCleared(server.FieldDeletedAt) {
  22776. fields = append(fields, server.FieldDeletedAt)
  22777. }
  22778. return fields
  22779. }
  22780. // FieldCleared returns a boolean indicating if a field with the given name was
  22781. // cleared in this mutation.
  22782. func (m *ServerMutation) FieldCleared(name string) bool {
  22783. _, ok := m.clearedFields[name]
  22784. return ok
  22785. }
  22786. // ClearField clears the value of the field with the given name. It returns an
  22787. // error if the field is not defined in the schema.
  22788. func (m *ServerMutation) ClearField(name string) error {
  22789. switch name {
  22790. case server.FieldStatus:
  22791. m.ClearStatus()
  22792. return nil
  22793. case server.FieldDeletedAt:
  22794. m.ClearDeletedAt()
  22795. return nil
  22796. }
  22797. return fmt.Errorf("unknown Server nullable field %s", name)
  22798. }
  22799. // ResetField resets all changes in the mutation for the field with the given name.
  22800. // It returns an error if the field is not defined in the schema.
  22801. func (m *ServerMutation) ResetField(name string) error {
  22802. switch name {
  22803. case server.FieldCreatedAt:
  22804. m.ResetCreatedAt()
  22805. return nil
  22806. case server.FieldUpdatedAt:
  22807. m.ResetUpdatedAt()
  22808. return nil
  22809. case server.FieldStatus:
  22810. m.ResetStatus()
  22811. return nil
  22812. case server.FieldDeletedAt:
  22813. m.ResetDeletedAt()
  22814. return nil
  22815. case server.FieldName:
  22816. m.ResetName()
  22817. return nil
  22818. case server.FieldPublicIP:
  22819. m.ResetPublicIP()
  22820. return nil
  22821. case server.FieldPrivateIP:
  22822. m.ResetPrivateIP()
  22823. return nil
  22824. case server.FieldAdminPort:
  22825. m.ResetAdminPort()
  22826. return nil
  22827. }
  22828. return fmt.Errorf("unknown Server field %s", name)
  22829. }
  22830. // AddedEdges returns all edge names that were set/added in this mutation.
  22831. func (m *ServerMutation) AddedEdges() []string {
  22832. edges := make([]string, 0, 1)
  22833. if m.wxs != nil {
  22834. edges = append(edges, server.EdgeWxs)
  22835. }
  22836. return edges
  22837. }
  22838. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22839. // name in this mutation.
  22840. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  22841. switch name {
  22842. case server.EdgeWxs:
  22843. ids := make([]ent.Value, 0, len(m.wxs))
  22844. for id := range m.wxs {
  22845. ids = append(ids, id)
  22846. }
  22847. return ids
  22848. }
  22849. return nil
  22850. }
  22851. // RemovedEdges returns all edge names that were removed in this mutation.
  22852. func (m *ServerMutation) RemovedEdges() []string {
  22853. edges := make([]string, 0, 1)
  22854. if m.removedwxs != nil {
  22855. edges = append(edges, server.EdgeWxs)
  22856. }
  22857. return edges
  22858. }
  22859. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22860. // the given name in this mutation.
  22861. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  22862. switch name {
  22863. case server.EdgeWxs:
  22864. ids := make([]ent.Value, 0, len(m.removedwxs))
  22865. for id := range m.removedwxs {
  22866. ids = append(ids, id)
  22867. }
  22868. return ids
  22869. }
  22870. return nil
  22871. }
  22872. // ClearedEdges returns all edge names that were cleared in this mutation.
  22873. func (m *ServerMutation) ClearedEdges() []string {
  22874. edges := make([]string, 0, 1)
  22875. if m.clearedwxs {
  22876. edges = append(edges, server.EdgeWxs)
  22877. }
  22878. return edges
  22879. }
  22880. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22881. // was cleared in this mutation.
  22882. func (m *ServerMutation) EdgeCleared(name string) bool {
  22883. switch name {
  22884. case server.EdgeWxs:
  22885. return m.clearedwxs
  22886. }
  22887. return false
  22888. }
  22889. // ClearEdge clears the value of the edge with the given name. It returns an error
  22890. // if that edge is not defined in the schema.
  22891. func (m *ServerMutation) ClearEdge(name string) error {
  22892. switch name {
  22893. }
  22894. return fmt.Errorf("unknown Server unique edge %s", name)
  22895. }
  22896. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22897. // It returns an error if the edge is not defined in the schema.
  22898. func (m *ServerMutation) ResetEdge(name string) error {
  22899. switch name {
  22900. case server.EdgeWxs:
  22901. m.ResetWxs()
  22902. return nil
  22903. }
  22904. return fmt.Errorf("unknown Server edge %s", name)
  22905. }
  22906. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  22907. type SopNodeMutation struct {
  22908. config
  22909. op Op
  22910. typ string
  22911. id *uint64
  22912. created_at *time.Time
  22913. updated_at *time.Time
  22914. status *uint8
  22915. addstatus *int8
  22916. deleted_at *time.Time
  22917. parent_id *uint64
  22918. addparent_id *int64
  22919. name *string
  22920. condition_type *int
  22921. addcondition_type *int
  22922. condition_list *[]string
  22923. appendcondition_list []string
  22924. no_reply_condition *uint64
  22925. addno_reply_condition *int64
  22926. no_reply_unit *string
  22927. action_message *[]custom_types.Action
  22928. appendaction_message []custom_types.Action
  22929. action_label_add *[]uint64
  22930. appendaction_label_add []uint64
  22931. action_label_del *[]uint64
  22932. appendaction_label_del []uint64
  22933. action_forward **custom_types.ActionForward
  22934. clearedFields map[string]struct{}
  22935. sop_stage *uint64
  22936. clearedsop_stage bool
  22937. node_messages map[uint64]struct{}
  22938. removednode_messages map[uint64]struct{}
  22939. clearednode_messages bool
  22940. done bool
  22941. oldValue func(context.Context) (*SopNode, error)
  22942. predicates []predicate.SopNode
  22943. }
  22944. var _ ent.Mutation = (*SopNodeMutation)(nil)
  22945. // sopnodeOption allows management of the mutation configuration using functional options.
  22946. type sopnodeOption func(*SopNodeMutation)
  22947. // newSopNodeMutation creates new mutation for the SopNode entity.
  22948. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  22949. m := &SopNodeMutation{
  22950. config: c,
  22951. op: op,
  22952. typ: TypeSopNode,
  22953. clearedFields: make(map[string]struct{}),
  22954. }
  22955. for _, opt := range opts {
  22956. opt(m)
  22957. }
  22958. return m
  22959. }
  22960. // withSopNodeID sets the ID field of the mutation.
  22961. func withSopNodeID(id uint64) sopnodeOption {
  22962. return func(m *SopNodeMutation) {
  22963. var (
  22964. err error
  22965. once sync.Once
  22966. value *SopNode
  22967. )
  22968. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  22969. once.Do(func() {
  22970. if m.done {
  22971. err = errors.New("querying old values post mutation is not allowed")
  22972. } else {
  22973. value, err = m.Client().SopNode.Get(ctx, id)
  22974. }
  22975. })
  22976. return value, err
  22977. }
  22978. m.id = &id
  22979. }
  22980. }
  22981. // withSopNode sets the old SopNode of the mutation.
  22982. func withSopNode(node *SopNode) sopnodeOption {
  22983. return func(m *SopNodeMutation) {
  22984. m.oldValue = func(context.Context) (*SopNode, error) {
  22985. return node, nil
  22986. }
  22987. m.id = &node.ID
  22988. }
  22989. }
  22990. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22991. // executed in a transaction (ent.Tx), a transactional client is returned.
  22992. func (m SopNodeMutation) Client() *Client {
  22993. client := &Client{config: m.config}
  22994. client.init()
  22995. return client
  22996. }
  22997. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22998. // it returns an error otherwise.
  22999. func (m SopNodeMutation) Tx() (*Tx, error) {
  23000. if _, ok := m.driver.(*txDriver); !ok {
  23001. return nil, errors.New("ent: mutation is not running in a transaction")
  23002. }
  23003. tx := &Tx{config: m.config}
  23004. tx.init()
  23005. return tx, nil
  23006. }
  23007. // SetID sets the value of the id field. Note that this
  23008. // operation is only accepted on creation of SopNode entities.
  23009. func (m *SopNodeMutation) SetID(id uint64) {
  23010. m.id = &id
  23011. }
  23012. // ID returns the ID value in the mutation. Note that the ID is only available
  23013. // if it was provided to the builder or after it was returned from the database.
  23014. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  23015. if m.id == nil {
  23016. return
  23017. }
  23018. return *m.id, true
  23019. }
  23020. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23021. // That means, if the mutation is applied within a transaction with an isolation level such
  23022. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23023. // or updated by the mutation.
  23024. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  23025. switch {
  23026. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23027. id, exists := m.ID()
  23028. if exists {
  23029. return []uint64{id}, nil
  23030. }
  23031. fallthrough
  23032. case m.op.Is(OpUpdate | OpDelete):
  23033. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  23034. default:
  23035. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23036. }
  23037. }
  23038. // SetCreatedAt sets the "created_at" field.
  23039. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  23040. m.created_at = &t
  23041. }
  23042. // CreatedAt returns the value of the "created_at" field in the mutation.
  23043. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  23044. v := m.created_at
  23045. if v == nil {
  23046. return
  23047. }
  23048. return *v, true
  23049. }
  23050. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  23051. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23053. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23054. if !m.op.Is(OpUpdateOne) {
  23055. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23056. }
  23057. if m.id == nil || m.oldValue == nil {
  23058. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23059. }
  23060. oldValue, err := m.oldValue(ctx)
  23061. if err != nil {
  23062. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23063. }
  23064. return oldValue.CreatedAt, nil
  23065. }
  23066. // ResetCreatedAt resets all changes to the "created_at" field.
  23067. func (m *SopNodeMutation) ResetCreatedAt() {
  23068. m.created_at = nil
  23069. }
  23070. // SetUpdatedAt sets the "updated_at" field.
  23071. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  23072. m.updated_at = &t
  23073. }
  23074. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23075. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  23076. v := m.updated_at
  23077. if v == nil {
  23078. return
  23079. }
  23080. return *v, true
  23081. }
  23082. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  23083. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23085. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23086. if !m.op.Is(OpUpdateOne) {
  23087. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23088. }
  23089. if m.id == nil || m.oldValue == nil {
  23090. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23091. }
  23092. oldValue, err := m.oldValue(ctx)
  23093. if err != nil {
  23094. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23095. }
  23096. return oldValue.UpdatedAt, nil
  23097. }
  23098. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23099. func (m *SopNodeMutation) ResetUpdatedAt() {
  23100. m.updated_at = nil
  23101. }
  23102. // SetStatus sets the "status" field.
  23103. func (m *SopNodeMutation) SetStatus(u uint8) {
  23104. m.status = &u
  23105. m.addstatus = nil
  23106. }
  23107. // Status returns the value of the "status" field in the mutation.
  23108. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  23109. v := m.status
  23110. if v == nil {
  23111. return
  23112. }
  23113. return *v, true
  23114. }
  23115. // OldStatus returns the old "status" field's value of the SopNode entity.
  23116. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23118. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23119. if !m.op.Is(OpUpdateOne) {
  23120. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23121. }
  23122. if m.id == nil || m.oldValue == nil {
  23123. return v, errors.New("OldStatus requires an ID field in the mutation")
  23124. }
  23125. oldValue, err := m.oldValue(ctx)
  23126. if err != nil {
  23127. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23128. }
  23129. return oldValue.Status, nil
  23130. }
  23131. // AddStatus adds u to the "status" field.
  23132. func (m *SopNodeMutation) AddStatus(u int8) {
  23133. if m.addstatus != nil {
  23134. *m.addstatus += u
  23135. } else {
  23136. m.addstatus = &u
  23137. }
  23138. }
  23139. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23140. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  23141. v := m.addstatus
  23142. if v == nil {
  23143. return
  23144. }
  23145. return *v, true
  23146. }
  23147. // ClearStatus clears the value of the "status" field.
  23148. func (m *SopNodeMutation) ClearStatus() {
  23149. m.status = nil
  23150. m.addstatus = nil
  23151. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  23152. }
  23153. // StatusCleared returns if the "status" field was cleared in this mutation.
  23154. func (m *SopNodeMutation) StatusCleared() bool {
  23155. _, ok := m.clearedFields[sopnode.FieldStatus]
  23156. return ok
  23157. }
  23158. // ResetStatus resets all changes to the "status" field.
  23159. func (m *SopNodeMutation) ResetStatus() {
  23160. m.status = nil
  23161. m.addstatus = nil
  23162. delete(m.clearedFields, sopnode.FieldStatus)
  23163. }
  23164. // SetDeletedAt sets the "deleted_at" field.
  23165. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  23166. m.deleted_at = &t
  23167. }
  23168. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23169. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  23170. v := m.deleted_at
  23171. if v == nil {
  23172. return
  23173. }
  23174. return *v, true
  23175. }
  23176. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  23177. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23179. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23180. if !m.op.Is(OpUpdateOne) {
  23181. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23182. }
  23183. if m.id == nil || m.oldValue == nil {
  23184. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23185. }
  23186. oldValue, err := m.oldValue(ctx)
  23187. if err != nil {
  23188. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23189. }
  23190. return oldValue.DeletedAt, nil
  23191. }
  23192. // ClearDeletedAt clears the value of the "deleted_at" field.
  23193. func (m *SopNodeMutation) ClearDeletedAt() {
  23194. m.deleted_at = nil
  23195. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  23196. }
  23197. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23198. func (m *SopNodeMutation) DeletedAtCleared() bool {
  23199. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  23200. return ok
  23201. }
  23202. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23203. func (m *SopNodeMutation) ResetDeletedAt() {
  23204. m.deleted_at = nil
  23205. delete(m.clearedFields, sopnode.FieldDeletedAt)
  23206. }
  23207. // SetStageID sets the "stage_id" field.
  23208. func (m *SopNodeMutation) SetStageID(u uint64) {
  23209. m.sop_stage = &u
  23210. }
  23211. // StageID returns the value of the "stage_id" field in the mutation.
  23212. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  23213. v := m.sop_stage
  23214. if v == nil {
  23215. return
  23216. }
  23217. return *v, true
  23218. }
  23219. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  23220. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23222. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  23223. if !m.op.Is(OpUpdateOne) {
  23224. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  23225. }
  23226. if m.id == nil || m.oldValue == nil {
  23227. return v, errors.New("OldStageID requires an ID field in the mutation")
  23228. }
  23229. oldValue, err := m.oldValue(ctx)
  23230. if err != nil {
  23231. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  23232. }
  23233. return oldValue.StageID, nil
  23234. }
  23235. // ResetStageID resets all changes to the "stage_id" field.
  23236. func (m *SopNodeMutation) ResetStageID() {
  23237. m.sop_stage = nil
  23238. }
  23239. // SetParentID sets the "parent_id" field.
  23240. func (m *SopNodeMutation) SetParentID(u uint64) {
  23241. m.parent_id = &u
  23242. m.addparent_id = nil
  23243. }
  23244. // ParentID returns the value of the "parent_id" field in the mutation.
  23245. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  23246. v := m.parent_id
  23247. if v == nil {
  23248. return
  23249. }
  23250. return *v, true
  23251. }
  23252. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  23253. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23255. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  23256. if !m.op.Is(OpUpdateOne) {
  23257. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  23258. }
  23259. if m.id == nil || m.oldValue == nil {
  23260. return v, errors.New("OldParentID requires an ID field in the mutation")
  23261. }
  23262. oldValue, err := m.oldValue(ctx)
  23263. if err != nil {
  23264. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  23265. }
  23266. return oldValue.ParentID, nil
  23267. }
  23268. // AddParentID adds u to the "parent_id" field.
  23269. func (m *SopNodeMutation) AddParentID(u int64) {
  23270. if m.addparent_id != nil {
  23271. *m.addparent_id += u
  23272. } else {
  23273. m.addparent_id = &u
  23274. }
  23275. }
  23276. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  23277. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  23278. v := m.addparent_id
  23279. if v == nil {
  23280. return
  23281. }
  23282. return *v, true
  23283. }
  23284. // ResetParentID resets all changes to the "parent_id" field.
  23285. func (m *SopNodeMutation) ResetParentID() {
  23286. m.parent_id = nil
  23287. m.addparent_id = nil
  23288. }
  23289. // SetName sets the "name" field.
  23290. func (m *SopNodeMutation) SetName(s string) {
  23291. m.name = &s
  23292. }
  23293. // Name returns the value of the "name" field in the mutation.
  23294. func (m *SopNodeMutation) Name() (r string, exists bool) {
  23295. v := m.name
  23296. if v == nil {
  23297. return
  23298. }
  23299. return *v, true
  23300. }
  23301. // OldName returns the old "name" field's value of the SopNode entity.
  23302. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23304. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  23305. if !m.op.Is(OpUpdateOne) {
  23306. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23307. }
  23308. if m.id == nil || m.oldValue == nil {
  23309. return v, errors.New("OldName requires an ID field in the mutation")
  23310. }
  23311. oldValue, err := m.oldValue(ctx)
  23312. if err != nil {
  23313. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23314. }
  23315. return oldValue.Name, nil
  23316. }
  23317. // ResetName resets all changes to the "name" field.
  23318. func (m *SopNodeMutation) ResetName() {
  23319. m.name = nil
  23320. }
  23321. // SetConditionType sets the "condition_type" field.
  23322. func (m *SopNodeMutation) SetConditionType(i int) {
  23323. m.condition_type = &i
  23324. m.addcondition_type = nil
  23325. }
  23326. // ConditionType returns the value of the "condition_type" field in the mutation.
  23327. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  23328. v := m.condition_type
  23329. if v == nil {
  23330. return
  23331. }
  23332. return *v, true
  23333. }
  23334. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  23335. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23337. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23338. if !m.op.Is(OpUpdateOne) {
  23339. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23340. }
  23341. if m.id == nil || m.oldValue == nil {
  23342. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23343. }
  23344. oldValue, err := m.oldValue(ctx)
  23345. if err != nil {
  23346. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23347. }
  23348. return oldValue.ConditionType, nil
  23349. }
  23350. // AddConditionType adds i to the "condition_type" field.
  23351. func (m *SopNodeMutation) AddConditionType(i int) {
  23352. if m.addcondition_type != nil {
  23353. *m.addcondition_type += i
  23354. } else {
  23355. m.addcondition_type = &i
  23356. }
  23357. }
  23358. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23359. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  23360. v := m.addcondition_type
  23361. if v == nil {
  23362. return
  23363. }
  23364. return *v, true
  23365. }
  23366. // ResetConditionType resets all changes to the "condition_type" field.
  23367. func (m *SopNodeMutation) ResetConditionType() {
  23368. m.condition_type = nil
  23369. m.addcondition_type = nil
  23370. }
  23371. // SetConditionList sets the "condition_list" field.
  23372. func (m *SopNodeMutation) SetConditionList(s []string) {
  23373. m.condition_list = &s
  23374. m.appendcondition_list = nil
  23375. }
  23376. // ConditionList returns the value of the "condition_list" field in the mutation.
  23377. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  23378. v := m.condition_list
  23379. if v == nil {
  23380. return
  23381. }
  23382. return *v, true
  23383. }
  23384. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  23385. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23387. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  23388. if !m.op.Is(OpUpdateOne) {
  23389. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23390. }
  23391. if m.id == nil || m.oldValue == nil {
  23392. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23393. }
  23394. oldValue, err := m.oldValue(ctx)
  23395. if err != nil {
  23396. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23397. }
  23398. return oldValue.ConditionList, nil
  23399. }
  23400. // AppendConditionList adds s to the "condition_list" field.
  23401. func (m *SopNodeMutation) AppendConditionList(s []string) {
  23402. m.appendcondition_list = append(m.appendcondition_list, s...)
  23403. }
  23404. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23405. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  23406. if len(m.appendcondition_list) == 0 {
  23407. return nil, false
  23408. }
  23409. return m.appendcondition_list, true
  23410. }
  23411. // ClearConditionList clears the value of the "condition_list" field.
  23412. func (m *SopNodeMutation) ClearConditionList() {
  23413. m.condition_list = nil
  23414. m.appendcondition_list = nil
  23415. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  23416. }
  23417. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  23418. func (m *SopNodeMutation) ConditionListCleared() bool {
  23419. _, ok := m.clearedFields[sopnode.FieldConditionList]
  23420. return ok
  23421. }
  23422. // ResetConditionList resets all changes to the "condition_list" field.
  23423. func (m *SopNodeMutation) ResetConditionList() {
  23424. m.condition_list = nil
  23425. m.appendcondition_list = nil
  23426. delete(m.clearedFields, sopnode.FieldConditionList)
  23427. }
  23428. // SetNoReplyCondition sets the "no_reply_condition" field.
  23429. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  23430. m.no_reply_condition = &u
  23431. m.addno_reply_condition = nil
  23432. }
  23433. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  23434. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  23435. v := m.no_reply_condition
  23436. if v == nil {
  23437. return
  23438. }
  23439. return *v, true
  23440. }
  23441. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  23442. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23444. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  23445. if !m.op.Is(OpUpdateOne) {
  23446. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  23447. }
  23448. if m.id == nil || m.oldValue == nil {
  23449. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  23450. }
  23451. oldValue, err := m.oldValue(ctx)
  23452. if err != nil {
  23453. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  23454. }
  23455. return oldValue.NoReplyCondition, nil
  23456. }
  23457. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  23458. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  23459. if m.addno_reply_condition != nil {
  23460. *m.addno_reply_condition += u
  23461. } else {
  23462. m.addno_reply_condition = &u
  23463. }
  23464. }
  23465. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  23466. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  23467. v := m.addno_reply_condition
  23468. if v == nil {
  23469. return
  23470. }
  23471. return *v, true
  23472. }
  23473. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  23474. func (m *SopNodeMutation) ResetNoReplyCondition() {
  23475. m.no_reply_condition = nil
  23476. m.addno_reply_condition = nil
  23477. }
  23478. // SetNoReplyUnit sets the "no_reply_unit" field.
  23479. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  23480. m.no_reply_unit = &s
  23481. }
  23482. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  23483. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  23484. v := m.no_reply_unit
  23485. if v == nil {
  23486. return
  23487. }
  23488. return *v, true
  23489. }
  23490. // OldNoReplyUnit returns the old "no_reply_unit" 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) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  23494. if !m.op.Is(OpUpdateOne) {
  23495. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  23496. }
  23497. if m.id == nil || m.oldValue == nil {
  23498. return v, errors.New("OldNoReplyUnit 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 OldNoReplyUnit: %w", err)
  23503. }
  23504. return oldValue.NoReplyUnit, nil
  23505. }
  23506. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  23507. func (m *SopNodeMutation) ResetNoReplyUnit() {
  23508. m.no_reply_unit = nil
  23509. }
  23510. // SetActionMessage sets the "action_message" field.
  23511. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  23512. m.action_message = &ct
  23513. m.appendaction_message = nil
  23514. }
  23515. // ActionMessage returns the value of the "action_message" field in the mutation.
  23516. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23517. v := m.action_message
  23518. if v == nil {
  23519. return
  23520. }
  23521. return *v, true
  23522. }
  23523. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  23524. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23526. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23527. if !m.op.Is(OpUpdateOne) {
  23528. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23529. }
  23530. if m.id == nil || m.oldValue == nil {
  23531. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23532. }
  23533. oldValue, err := m.oldValue(ctx)
  23534. if err != nil {
  23535. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23536. }
  23537. return oldValue.ActionMessage, nil
  23538. }
  23539. // AppendActionMessage adds ct to the "action_message" field.
  23540. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  23541. m.appendaction_message = append(m.appendaction_message, ct...)
  23542. }
  23543. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23544. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23545. if len(m.appendaction_message) == 0 {
  23546. return nil, false
  23547. }
  23548. return m.appendaction_message, true
  23549. }
  23550. // ClearActionMessage clears the value of the "action_message" field.
  23551. func (m *SopNodeMutation) ClearActionMessage() {
  23552. m.action_message = nil
  23553. m.appendaction_message = nil
  23554. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  23555. }
  23556. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  23557. func (m *SopNodeMutation) ActionMessageCleared() bool {
  23558. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  23559. return ok
  23560. }
  23561. // ResetActionMessage resets all changes to the "action_message" field.
  23562. func (m *SopNodeMutation) ResetActionMessage() {
  23563. m.action_message = nil
  23564. m.appendaction_message = nil
  23565. delete(m.clearedFields, sopnode.FieldActionMessage)
  23566. }
  23567. // SetActionLabelAdd sets the "action_label_add" field.
  23568. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  23569. m.action_label_add = &u
  23570. m.appendaction_label_add = nil
  23571. }
  23572. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23573. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23574. v := m.action_label_add
  23575. if v == nil {
  23576. return
  23577. }
  23578. return *v, true
  23579. }
  23580. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  23581. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23583. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23584. if !m.op.Is(OpUpdateOne) {
  23585. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23586. }
  23587. if m.id == nil || m.oldValue == nil {
  23588. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23589. }
  23590. oldValue, err := m.oldValue(ctx)
  23591. if err != nil {
  23592. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23593. }
  23594. return oldValue.ActionLabelAdd, nil
  23595. }
  23596. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23597. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  23598. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23599. }
  23600. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23601. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23602. if len(m.appendaction_label_add) == 0 {
  23603. return nil, false
  23604. }
  23605. return m.appendaction_label_add, true
  23606. }
  23607. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23608. func (m *SopNodeMutation) ClearActionLabelAdd() {
  23609. m.action_label_add = nil
  23610. m.appendaction_label_add = nil
  23611. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  23612. }
  23613. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23614. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  23615. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  23616. return ok
  23617. }
  23618. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23619. func (m *SopNodeMutation) ResetActionLabelAdd() {
  23620. m.action_label_add = nil
  23621. m.appendaction_label_add = nil
  23622. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  23623. }
  23624. // SetActionLabelDel sets the "action_label_del" field.
  23625. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  23626. m.action_label_del = &u
  23627. m.appendaction_label_del = nil
  23628. }
  23629. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23630. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  23631. v := m.action_label_del
  23632. if v == nil {
  23633. return
  23634. }
  23635. return *v, true
  23636. }
  23637. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  23638. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23640. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23641. if !m.op.Is(OpUpdateOne) {
  23642. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23643. }
  23644. if m.id == nil || m.oldValue == nil {
  23645. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23646. }
  23647. oldValue, err := m.oldValue(ctx)
  23648. if err != nil {
  23649. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23650. }
  23651. return oldValue.ActionLabelDel, nil
  23652. }
  23653. // AppendActionLabelDel adds u to the "action_label_del" field.
  23654. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  23655. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23656. }
  23657. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23658. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23659. if len(m.appendaction_label_del) == 0 {
  23660. return nil, false
  23661. }
  23662. return m.appendaction_label_del, true
  23663. }
  23664. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23665. func (m *SopNodeMutation) ClearActionLabelDel() {
  23666. m.action_label_del = nil
  23667. m.appendaction_label_del = nil
  23668. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  23669. }
  23670. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23671. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  23672. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  23673. return ok
  23674. }
  23675. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23676. func (m *SopNodeMutation) ResetActionLabelDel() {
  23677. m.action_label_del = nil
  23678. m.appendaction_label_del = nil
  23679. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  23680. }
  23681. // SetActionForward sets the "action_forward" field.
  23682. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  23683. m.action_forward = &ctf
  23684. }
  23685. // ActionForward returns the value of the "action_forward" field in the mutation.
  23686. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  23687. v := m.action_forward
  23688. if v == nil {
  23689. return
  23690. }
  23691. return *v, true
  23692. }
  23693. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  23694. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23696. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  23697. if !m.op.Is(OpUpdateOne) {
  23698. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  23699. }
  23700. if m.id == nil || m.oldValue == nil {
  23701. return v, errors.New("OldActionForward requires an ID field in the mutation")
  23702. }
  23703. oldValue, err := m.oldValue(ctx)
  23704. if err != nil {
  23705. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  23706. }
  23707. return oldValue.ActionForward, nil
  23708. }
  23709. // ClearActionForward clears the value of the "action_forward" field.
  23710. func (m *SopNodeMutation) ClearActionForward() {
  23711. m.action_forward = nil
  23712. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  23713. }
  23714. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  23715. func (m *SopNodeMutation) ActionForwardCleared() bool {
  23716. _, ok := m.clearedFields[sopnode.FieldActionForward]
  23717. return ok
  23718. }
  23719. // ResetActionForward resets all changes to the "action_forward" field.
  23720. func (m *SopNodeMutation) ResetActionForward() {
  23721. m.action_forward = nil
  23722. delete(m.clearedFields, sopnode.FieldActionForward)
  23723. }
  23724. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  23725. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  23726. m.sop_stage = &id
  23727. }
  23728. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  23729. func (m *SopNodeMutation) ClearSopStage() {
  23730. m.clearedsop_stage = true
  23731. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  23732. }
  23733. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  23734. func (m *SopNodeMutation) SopStageCleared() bool {
  23735. return m.clearedsop_stage
  23736. }
  23737. // SopStageID returns the "sop_stage" edge ID in the mutation.
  23738. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  23739. if m.sop_stage != nil {
  23740. return *m.sop_stage, true
  23741. }
  23742. return
  23743. }
  23744. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  23745. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23746. // SopStageID instead. It exists only for internal usage by the builders.
  23747. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  23748. if id := m.sop_stage; id != nil {
  23749. ids = append(ids, *id)
  23750. }
  23751. return
  23752. }
  23753. // ResetSopStage resets all changes to the "sop_stage" edge.
  23754. func (m *SopNodeMutation) ResetSopStage() {
  23755. m.sop_stage = nil
  23756. m.clearedsop_stage = false
  23757. }
  23758. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  23759. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  23760. if m.node_messages == nil {
  23761. m.node_messages = make(map[uint64]struct{})
  23762. }
  23763. for i := range ids {
  23764. m.node_messages[ids[i]] = struct{}{}
  23765. }
  23766. }
  23767. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  23768. func (m *SopNodeMutation) ClearNodeMessages() {
  23769. m.clearednode_messages = true
  23770. }
  23771. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  23772. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  23773. return m.clearednode_messages
  23774. }
  23775. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  23776. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  23777. if m.removednode_messages == nil {
  23778. m.removednode_messages = make(map[uint64]struct{})
  23779. }
  23780. for i := range ids {
  23781. delete(m.node_messages, ids[i])
  23782. m.removednode_messages[ids[i]] = struct{}{}
  23783. }
  23784. }
  23785. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  23786. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  23787. for id := range m.removednode_messages {
  23788. ids = append(ids, id)
  23789. }
  23790. return
  23791. }
  23792. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  23793. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  23794. for id := range m.node_messages {
  23795. ids = append(ids, id)
  23796. }
  23797. return
  23798. }
  23799. // ResetNodeMessages resets all changes to the "node_messages" edge.
  23800. func (m *SopNodeMutation) ResetNodeMessages() {
  23801. m.node_messages = nil
  23802. m.clearednode_messages = false
  23803. m.removednode_messages = nil
  23804. }
  23805. // Where appends a list predicates to the SopNodeMutation builder.
  23806. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  23807. m.predicates = append(m.predicates, ps...)
  23808. }
  23809. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  23810. // users can use type-assertion to append predicates that do not depend on any generated package.
  23811. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  23812. p := make([]predicate.SopNode, len(ps))
  23813. for i := range ps {
  23814. p[i] = ps[i]
  23815. }
  23816. m.Where(p...)
  23817. }
  23818. // Op returns the operation name.
  23819. func (m *SopNodeMutation) Op() Op {
  23820. return m.op
  23821. }
  23822. // SetOp allows setting the mutation operation.
  23823. func (m *SopNodeMutation) SetOp(op Op) {
  23824. m.op = op
  23825. }
  23826. // Type returns the node type of this mutation (SopNode).
  23827. func (m *SopNodeMutation) Type() string {
  23828. return m.typ
  23829. }
  23830. // Fields returns all fields that were changed during this mutation. Note that in
  23831. // order to get all numeric fields that were incremented/decremented, call
  23832. // AddedFields().
  23833. func (m *SopNodeMutation) Fields() []string {
  23834. fields := make([]string, 0, 15)
  23835. if m.created_at != nil {
  23836. fields = append(fields, sopnode.FieldCreatedAt)
  23837. }
  23838. if m.updated_at != nil {
  23839. fields = append(fields, sopnode.FieldUpdatedAt)
  23840. }
  23841. if m.status != nil {
  23842. fields = append(fields, sopnode.FieldStatus)
  23843. }
  23844. if m.deleted_at != nil {
  23845. fields = append(fields, sopnode.FieldDeletedAt)
  23846. }
  23847. if m.sop_stage != nil {
  23848. fields = append(fields, sopnode.FieldStageID)
  23849. }
  23850. if m.parent_id != nil {
  23851. fields = append(fields, sopnode.FieldParentID)
  23852. }
  23853. if m.name != nil {
  23854. fields = append(fields, sopnode.FieldName)
  23855. }
  23856. if m.condition_type != nil {
  23857. fields = append(fields, sopnode.FieldConditionType)
  23858. }
  23859. if m.condition_list != nil {
  23860. fields = append(fields, sopnode.FieldConditionList)
  23861. }
  23862. if m.no_reply_condition != nil {
  23863. fields = append(fields, sopnode.FieldNoReplyCondition)
  23864. }
  23865. if m.no_reply_unit != nil {
  23866. fields = append(fields, sopnode.FieldNoReplyUnit)
  23867. }
  23868. if m.action_message != nil {
  23869. fields = append(fields, sopnode.FieldActionMessage)
  23870. }
  23871. if m.action_label_add != nil {
  23872. fields = append(fields, sopnode.FieldActionLabelAdd)
  23873. }
  23874. if m.action_label_del != nil {
  23875. fields = append(fields, sopnode.FieldActionLabelDel)
  23876. }
  23877. if m.action_forward != nil {
  23878. fields = append(fields, sopnode.FieldActionForward)
  23879. }
  23880. return fields
  23881. }
  23882. // Field returns the value of a field with the given name. The second boolean
  23883. // return value indicates that this field was not set, or was not defined in the
  23884. // schema.
  23885. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  23886. switch name {
  23887. case sopnode.FieldCreatedAt:
  23888. return m.CreatedAt()
  23889. case sopnode.FieldUpdatedAt:
  23890. return m.UpdatedAt()
  23891. case sopnode.FieldStatus:
  23892. return m.Status()
  23893. case sopnode.FieldDeletedAt:
  23894. return m.DeletedAt()
  23895. case sopnode.FieldStageID:
  23896. return m.StageID()
  23897. case sopnode.FieldParentID:
  23898. return m.ParentID()
  23899. case sopnode.FieldName:
  23900. return m.Name()
  23901. case sopnode.FieldConditionType:
  23902. return m.ConditionType()
  23903. case sopnode.FieldConditionList:
  23904. return m.ConditionList()
  23905. case sopnode.FieldNoReplyCondition:
  23906. return m.NoReplyCondition()
  23907. case sopnode.FieldNoReplyUnit:
  23908. return m.NoReplyUnit()
  23909. case sopnode.FieldActionMessage:
  23910. return m.ActionMessage()
  23911. case sopnode.FieldActionLabelAdd:
  23912. return m.ActionLabelAdd()
  23913. case sopnode.FieldActionLabelDel:
  23914. return m.ActionLabelDel()
  23915. case sopnode.FieldActionForward:
  23916. return m.ActionForward()
  23917. }
  23918. return nil, false
  23919. }
  23920. // OldField returns the old value of the field from the database. An error is
  23921. // returned if the mutation operation is not UpdateOne, or the query to the
  23922. // database failed.
  23923. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23924. switch name {
  23925. case sopnode.FieldCreatedAt:
  23926. return m.OldCreatedAt(ctx)
  23927. case sopnode.FieldUpdatedAt:
  23928. return m.OldUpdatedAt(ctx)
  23929. case sopnode.FieldStatus:
  23930. return m.OldStatus(ctx)
  23931. case sopnode.FieldDeletedAt:
  23932. return m.OldDeletedAt(ctx)
  23933. case sopnode.FieldStageID:
  23934. return m.OldStageID(ctx)
  23935. case sopnode.FieldParentID:
  23936. return m.OldParentID(ctx)
  23937. case sopnode.FieldName:
  23938. return m.OldName(ctx)
  23939. case sopnode.FieldConditionType:
  23940. return m.OldConditionType(ctx)
  23941. case sopnode.FieldConditionList:
  23942. return m.OldConditionList(ctx)
  23943. case sopnode.FieldNoReplyCondition:
  23944. return m.OldNoReplyCondition(ctx)
  23945. case sopnode.FieldNoReplyUnit:
  23946. return m.OldNoReplyUnit(ctx)
  23947. case sopnode.FieldActionMessage:
  23948. return m.OldActionMessage(ctx)
  23949. case sopnode.FieldActionLabelAdd:
  23950. return m.OldActionLabelAdd(ctx)
  23951. case sopnode.FieldActionLabelDel:
  23952. return m.OldActionLabelDel(ctx)
  23953. case sopnode.FieldActionForward:
  23954. return m.OldActionForward(ctx)
  23955. }
  23956. return nil, fmt.Errorf("unknown SopNode field %s", name)
  23957. }
  23958. // SetField sets the value of a field with the given name. It returns an error if
  23959. // the field is not defined in the schema, or if the type mismatched the field
  23960. // type.
  23961. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  23962. switch name {
  23963. case sopnode.FieldCreatedAt:
  23964. v, ok := value.(time.Time)
  23965. if !ok {
  23966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23967. }
  23968. m.SetCreatedAt(v)
  23969. return nil
  23970. case sopnode.FieldUpdatedAt:
  23971. v, ok := value.(time.Time)
  23972. if !ok {
  23973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23974. }
  23975. m.SetUpdatedAt(v)
  23976. return nil
  23977. case sopnode.FieldStatus:
  23978. v, ok := value.(uint8)
  23979. if !ok {
  23980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23981. }
  23982. m.SetStatus(v)
  23983. return nil
  23984. case sopnode.FieldDeletedAt:
  23985. v, ok := value.(time.Time)
  23986. if !ok {
  23987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23988. }
  23989. m.SetDeletedAt(v)
  23990. return nil
  23991. case sopnode.FieldStageID:
  23992. v, ok := value.(uint64)
  23993. if !ok {
  23994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23995. }
  23996. m.SetStageID(v)
  23997. return nil
  23998. case sopnode.FieldParentID:
  23999. v, ok := value.(uint64)
  24000. if !ok {
  24001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24002. }
  24003. m.SetParentID(v)
  24004. return nil
  24005. case sopnode.FieldName:
  24006. v, ok := value.(string)
  24007. if !ok {
  24008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24009. }
  24010. m.SetName(v)
  24011. return nil
  24012. case sopnode.FieldConditionType:
  24013. v, ok := value.(int)
  24014. if !ok {
  24015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24016. }
  24017. m.SetConditionType(v)
  24018. return nil
  24019. case sopnode.FieldConditionList:
  24020. v, ok := value.([]string)
  24021. if !ok {
  24022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24023. }
  24024. m.SetConditionList(v)
  24025. return nil
  24026. case sopnode.FieldNoReplyCondition:
  24027. v, ok := value.(uint64)
  24028. if !ok {
  24029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24030. }
  24031. m.SetNoReplyCondition(v)
  24032. return nil
  24033. case sopnode.FieldNoReplyUnit:
  24034. v, ok := value.(string)
  24035. if !ok {
  24036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24037. }
  24038. m.SetNoReplyUnit(v)
  24039. return nil
  24040. case sopnode.FieldActionMessage:
  24041. v, ok := value.([]custom_types.Action)
  24042. if !ok {
  24043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24044. }
  24045. m.SetActionMessage(v)
  24046. return nil
  24047. case sopnode.FieldActionLabelAdd:
  24048. v, ok := value.([]uint64)
  24049. if !ok {
  24050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24051. }
  24052. m.SetActionLabelAdd(v)
  24053. return nil
  24054. case sopnode.FieldActionLabelDel:
  24055. v, ok := value.([]uint64)
  24056. if !ok {
  24057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24058. }
  24059. m.SetActionLabelDel(v)
  24060. return nil
  24061. case sopnode.FieldActionForward:
  24062. v, ok := value.(*custom_types.ActionForward)
  24063. if !ok {
  24064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24065. }
  24066. m.SetActionForward(v)
  24067. return nil
  24068. }
  24069. return fmt.Errorf("unknown SopNode field %s", name)
  24070. }
  24071. // AddedFields returns all numeric fields that were incremented/decremented during
  24072. // this mutation.
  24073. func (m *SopNodeMutation) AddedFields() []string {
  24074. var fields []string
  24075. if m.addstatus != nil {
  24076. fields = append(fields, sopnode.FieldStatus)
  24077. }
  24078. if m.addparent_id != nil {
  24079. fields = append(fields, sopnode.FieldParentID)
  24080. }
  24081. if m.addcondition_type != nil {
  24082. fields = append(fields, sopnode.FieldConditionType)
  24083. }
  24084. if m.addno_reply_condition != nil {
  24085. fields = append(fields, sopnode.FieldNoReplyCondition)
  24086. }
  24087. return fields
  24088. }
  24089. // AddedField returns the numeric value that was incremented/decremented on a field
  24090. // with the given name. The second boolean return value indicates that this field
  24091. // was not set, or was not defined in the schema.
  24092. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  24093. switch name {
  24094. case sopnode.FieldStatus:
  24095. return m.AddedStatus()
  24096. case sopnode.FieldParentID:
  24097. return m.AddedParentID()
  24098. case sopnode.FieldConditionType:
  24099. return m.AddedConditionType()
  24100. case sopnode.FieldNoReplyCondition:
  24101. return m.AddedNoReplyCondition()
  24102. }
  24103. return nil, false
  24104. }
  24105. // AddField adds the value to the field with the given name. It returns an error if
  24106. // the field is not defined in the schema, or if the type mismatched the field
  24107. // type.
  24108. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  24109. switch name {
  24110. case sopnode.FieldStatus:
  24111. v, ok := value.(int8)
  24112. if !ok {
  24113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24114. }
  24115. m.AddStatus(v)
  24116. return nil
  24117. case sopnode.FieldParentID:
  24118. v, ok := value.(int64)
  24119. if !ok {
  24120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24121. }
  24122. m.AddParentID(v)
  24123. return nil
  24124. case sopnode.FieldConditionType:
  24125. v, ok := value.(int)
  24126. if !ok {
  24127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24128. }
  24129. m.AddConditionType(v)
  24130. return nil
  24131. case sopnode.FieldNoReplyCondition:
  24132. v, ok := value.(int64)
  24133. if !ok {
  24134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24135. }
  24136. m.AddNoReplyCondition(v)
  24137. return nil
  24138. }
  24139. return fmt.Errorf("unknown SopNode numeric field %s", name)
  24140. }
  24141. // ClearedFields returns all nullable fields that were cleared during this
  24142. // mutation.
  24143. func (m *SopNodeMutation) ClearedFields() []string {
  24144. var fields []string
  24145. if m.FieldCleared(sopnode.FieldStatus) {
  24146. fields = append(fields, sopnode.FieldStatus)
  24147. }
  24148. if m.FieldCleared(sopnode.FieldDeletedAt) {
  24149. fields = append(fields, sopnode.FieldDeletedAt)
  24150. }
  24151. if m.FieldCleared(sopnode.FieldConditionList) {
  24152. fields = append(fields, sopnode.FieldConditionList)
  24153. }
  24154. if m.FieldCleared(sopnode.FieldActionMessage) {
  24155. fields = append(fields, sopnode.FieldActionMessage)
  24156. }
  24157. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  24158. fields = append(fields, sopnode.FieldActionLabelAdd)
  24159. }
  24160. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  24161. fields = append(fields, sopnode.FieldActionLabelDel)
  24162. }
  24163. if m.FieldCleared(sopnode.FieldActionForward) {
  24164. fields = append(fields, sopnode.FieldActionForward)
  24165. }
  24166. return fields
  24167. }
  24168. // FieldCleared returns a boolean indicating if a field with the given name was
  24169. // cleared in this mutation.
  24170. func (m *SopNodeMutation) FieldCleared(name string) bool {
  24171. _, ok := m.clearedFields[name]
  24172. return ok
  24173. }
  24174. // ClearField clears the value of the field with the given name. It returns an
  24175. // error if the field is not defined in the schema.
  24176. func (m *SopNodeMutation) ClearField(name string) error {
  24177. switch name {
  24178. case sopnode.FieldStatus:
  24179. m.ClearStatus()
  24180. return nil
  24181. case sopnode.FieldDeletedAt:
  24182. m.ClearDeletedAt()
  24183. return nil
  24184. case sopnode.FieldConditionList:
  24185. m.ClearConditionList()
  24186. return nil
  24187. case sopnode.FieldActionMessage:
  24188. m.ClearActionMessage()
  24189. return nil
  24190. case sopnode.FieldActionLabelAdd:
  24191. m.ClearActionLabelAdd()
  24192. return nil
  24193. case sopnode.FieldActionLabelDel:
  24194. m.ClearActionLabelDel()
  24195. return nil
  24196. case sopnode.FieldActionForward:
  24197. m.ClearActionForward()
  24198. return nil
  24199. }
  24200. return fmt.Errorf("unknown SopNode nullable field %s", name)
  24201. }
  24202. // ResetField resets all changes in the mutation for the field with the given name.
  24203. // It returns an error if the field is not defined in the schema.
  24204. func (m *SopNodeMutation) ResetField(name string) error {
  24205. switch name {
  24206. case sopnode.FieldCreatedAt:
  24207. m.ResetCreatedAt()
  24208. return nil
  24209. case sopnode.FieldUpdatedAt:
  24210. m.ResetUpdatedAt()
  24211. return nil
  24212. case sopnode.FieldStatus:
  24213. m.ResetStatus()
  24214. return nil
  24215. case sopnode.FieldDeletedAt:
  24216. m.ResetDeletedAt()
  24217. return nil
  24218. case sopnode.FieldStageID:
  24219. m.ResetStageID()
  24220. return nil
  24221. case sopnode.FieldParentID:
  24222. m.ResetParentID()
  24223. return nil
  24224. case sopnode.FieldName:
  24225. m.ResetName()
  24226. return nil
  24227. case sopnode.FieldConditionType:
  24228. m.ResetConditionType()
  24229. return nil
  24230. case sopnode.FieldConditionList:
  24231. m.ResetConditionList()
  24232. return nil
  24233. case sopnode.FieldNoReplyCondition:
  24234. m.ResetNoReplyCondition()
  24235. return nil
  24236. case sopnode.FieldNoReplyUnit:
  24237. m.ResetNoReplyUnit()
  24238. return nil
  24239. case sopnode.FieldActionMessage:
  24240. m.ResetActionMessage()
  24241. return nil
  24242. case sopnode.FieldActionLabelAdd:
  24243. m.ResetActionLabelAdd()
  24244. return nil
  24245. case sopnode.FieldActionLabelDel:
  24246. m.ResetActionLabelDel()
  24247. return nil
  24248. case sopnode.FieldActionForward:
  24249. m.ResetActionForward()
  24250. return nil
  24251. }
  24252. return fmt.Errorf("unknown SopNode field %s", name)
  24253. }
  24254. // AddedEdges returns all edge names that were set/added in this mutation.
  24255. func (m *SopNodeMutation) AddedEdges() []string {
  24256. edges := make([]string, 0, 2)
  24257. if m.sop_stage != nil {
  24258. edges = append(edges, sopnode.EdgeSopStage)
  24259. }
  24260. if m.node_messages != nil {
  24261. edges = append(edges, sopnode.EdgeNodeMessages)
  24262. }
  24263. return edges
  24264. }
  24265. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24266. // name in this mutation.
  24267. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  24268. switch name {
  24269. case sopnode.EdgeSopStage:
  24270. if id := m.sop_stage; id != nil {
  24271. return []ent.Value{*id}
  24272. }
  24273. case sopnode.EdgeNodeMessages:
  24274. ids := make([]ent.Value, 0, len(m.node_messages))
  24275. for id := range m.node_messages {
  24276. ids = append(ids, id)
  24277. }
  24278. return ids
  24279. }
  24280. return nil
  24281. }
  24282. // RemovedEdges returns all edge names that were removed in this mutation.
  24283. func (m *SopNodeMutation) RemovedEdges() []string {
  24284. edges := make([]string, 0, 2)
  24285. if m.removednode_messages != nil {
  24286. edges = append(edges, sopnode.EdgeNodeMessages)
  24287. }
  24288. return edges
  24289. }
  24290. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24291. // the given name in this mutation.
  24292. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  24293. switch name {
  24294. case sopnode.EdgeNodeMessages:
  24295. ids := make([]ent.Value, 0, len(m.removednode_messages))
  24296. for id := range m.removednode_messages {
  24297. ids = append(ids, id)
  24298. }
  24299. return ids
  24300. }
  24301. return nil
  24302. }
  24303. // ClearedEdges returns all edge names that were cleared in this mutation.
  24304. func (m *SopNodeMutation) ClearedEdges() []string {
  24305. edges := make([]string, 0, 2)
  24306. if m.clearedsop_stage {
  24307. edges = append(edges, sopnode.EdgeSopStage)
  24308. }
  24309. if m.clearednode_messages {
  24310. edges = append(edges, sopnode.EdgeNodeMessages)
  24311. }
  24312. return edges
  24313. }
  24314. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24315. // was cleared in this mutation.
  24316. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  24317. switch name {
  24318. case sopnode.EdgeSopStage:
  24319. return m.clearedsop_stage
  24320. case sopnode.EdgeNodeMessages:
  24321. return m.clearednode_messages
  24322. }
  24323. return false
  24324. }
  24325. // ClearEdge clears the value of the edge with the given name. It returns an error
  24326. // if that edge is not defined in the schema.
  24327. func (m *SopNodeMutation) ClearEdge(name string) error {
  24328. switch name {
  24329. case sopnode.EdgeSopStage:
  24330. m.ClearSopStage()
  24331. return nil
  24332. }
  24333. return fmt.Errorf("unknown SopNode unique edge %s", name)
  24334. }
  24335. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24336. // It returns an error if the edge is not defined in the schema.
  24337. func (m *SopNodeMutation) ResetEdge(name string) error {
  24338. switch name {
  24339. case sopnode.EdgeSopStage:
  24340. m.ResetSopStage()
  24341. return nil
  24342. case sopnode.EdgeNodeMessages:
  24343. m.ResetNodeMessages()
  24344. return nil
  24345. }
  24346. return fmt.Errorf("unknown SopNode edge %s", name)
  24347. }
  24348. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  24349. type SopStageMutation struct {
  24350. config
  24351. op Op
  24352. typ string
  24353. id *uint64
  24354. created_at *time.Time
  24355. updated_at *time.Time
  24356. status *uint8
  24357. addstatus *int8
  24358. deleted_at *time.Time
  24359. name *string
  24360. condition_type *int
  24361. addcondition_type *int
  24362. condition_operator *int
  24363. addcondition_operator *int
  24364. condition_list *[]custom_types.Condition
  24365. appendcondition_list []custom_types.Condition
  24366. action_message *[]custom_types.Action
  24367. appendaction_message []custom_types.Action
  24368. action_label_add *[]uint64
  24369. appendaction_label_add []uint64
  24370. action_label_del *[]uint64
  24371. appendaction_label_del []uint64
  24372. action_forward **custom_types.ActionForward
  24373. index_sort *int
  24374. addindex_sort *int
  24375. clearedFields map[string]struct{}
  24376. sop_task *uint64
  24377. clearedsop_task bool
  24378. stage_nodes map[uint64]struct{}
  24379. removedstage_nodes map[uint64]struct{}
  24380. clearedstage_nodes bool
  24381. stage_messages map[uint64]struct{}
  24382. removedstage_messages map[uint64]struct{}
  24383. clearedstage_messages bool
  24384. done bool
  24385. oldValue func(context.Context) (*SopStage, error)
  24386. predicates []predicate.SopStage
  24387. }
  24388. var _ ent.Mutation = (*SopStageMutation)(nil)
  24389. // sopstageOption allows management of the mutation configuration using functional options.
  24390. type sopstageOption func(*SopStageMutation)
  24391. // newSopStageMutation creates new mutation for the SopStage entity.
  24392. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  24393. m := &SopStageMutation{
  24394. config: c,
  24395. op: op,
  24396. typ: TypeSopStage,
  24397. clearedFields: make(map[string]struct{}),
  24398. }
  24399. for _, opt := range opts {
  24400. opt(m)
  24401. }
  24402. return m
  24403. }
  24404. // withSopStageID sets the ID field of the mutation.
  24405. func withSopStageID(id uint64) sopstageOption {
  24406. return func(m *SopStageMutation) {
  24407. var (
  24408. err error
  24409. once sync.Once
  24410. value *SopStage
  24411. )
  24412. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  24413. once.Do(func() {
  24414. if m.done {
  24415. err = errors.New("querying old values post mutation is not allowed")
  24416. } else {
  24417. value, err = m.Client().SopStage.Get(ctx, id)
  24418. }
  24419. })
  24420. return value, err
  24421. }
  24422. m.id = &id
  24423. }
  24424. }
  24425. // withSopStage sets the old SopStage of the mutation.
  24426. func withSopStage(node *SopStage) sopstageOption {
  24427. return func(m *SopStageMutation) {
  24428. m.oldValue = func(context.Context) (*SopStage, error) {
  24429. return node, nil
  24430. }
  24431. m.id = &node.ID
  24432. }
  24433. }
  24434. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24435. // executed in a transaction (ent.Tx), a transactional client is returned.
  24436. func (m SopStageMutation) Client() *Client {
  24437. client := &Client{config: m.config}
  24438. client.init()
  24439. return client
  24440. }
  24441. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24442. // it returns an error otherwise.
  24443. func (m SopStageMutation) Tx() (*Tx, error) {
  24444. if _, ok := m.driver.(*txDriver); !ok {
  24445. return nil, errors.New("ent: mutation is not running in a transaction")
  24446. }
  24447. tx := &Tx{config: m.config}
  24448. tx.init()
  24449. return tx, nil
  24450. }
  24451. // SetID sets the value of the id field. Note that this
  24452. // operation is only accepted on creation of SopStage entities.
  24453. func (m *SopStageMutation) SetID(id uint64) {
  24454. m.id = &id
  24455. }
  24456. // ID returns the ID value in the mutation. Note that the ID is only available
  24457. // if it was provided to the builder or after it was returned from the database.
  24458. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  24459. if m.id == nil {
  24460. return
  24461. }
  24462. return *m.id, true
  24463. }
  24464. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24465. // That means, if the mutation is applied within a transaction with an isolation level such
  24466. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24467. // or updated by the mutation.
  24468. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  24469. switch {
  24470. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24471. id, exists := m.ID()
  24472. if exists {
  24473. return []uint64{id}, nil
  24474. }
  24475. fallthrough
  24476. case m.op.Is(OpUpdate | OpDelete):
  24477. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  24478. default:
  24479. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24480. }
  24481. }
  24482. // SetCreatedAt sets the "created_at" field.
  24483. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  24484. m.created_at = &t
  24485. }
  24486. // CreatedAt returns the value of the "created_at" field in the mutation.
  24487. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  24488. v := m.created_at
  24489. if v == nil {
  24490. return
  24491. }
  24492. return *v, true
  24493. }
  24494. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  24495. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24497. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24498. if !m.op.Is(OpUpdateOne) {
  24499. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24500. }
  24501. if m.id == nil || m.oldValue == nil {
  24502. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24503. }
  24504. oldValue, err := m.oldValue(ctx)
  24505. if err != nil {
  24506. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24507. }
  24508. return oldValue.CreatedAt, nil
  24509. }
  24510. // ResetCreatedAt resets all changes to the "created_at" field.
  24511. func (m *SopStageMutation) ResetCreatedAt() {
  24512. m.created_at = nil
  24513. }
  24514. // SetUpdatedAt sets the "updated_at" field.
  24515. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  24516. m.updated_at = &t
  24517. }
  24518. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24519. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  24520. v := m.updated_at
  24521. if v == nil {
  24522. return
  24523. }
  24524. return *v, true
  24525. }
  24526. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  24527. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24529. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24530. if !m.op.Is(OpUpdateOne) {
  24531. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24532. }
  24533. if m.id == nil || m.oldValue == nil {
  24534. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24535. }
  24536. oldValue, err := m.oldValue(ctx)
  24537. if err != nil {
  24538. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24539. }
  24540. return oldValue.UpdatedAt, nil
  24541. }
  24542. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24543. func (m *SopStageMutation) ResetUpdatedAt() {
  24544. m.updated_at = nil
  24545. }
  24546. // SetStatus sets the "status" field.
  24547. func (m *SopStageMutation) SetStatus(u uint8) {
  24548. m.status = &u
  24549. m.addstatus = nil
  24550. }
  24551. // Status returns the value of the "status" field in the mutation.
  24552. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  24553. v := m.status
  24554. if v == nil {
  24555. return
  24556. }
  24557. return *v, true
  24558. }
  24559. // OldStatus returns the old "status" field's value of the SopStage entity.
  24560. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24562. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24563. if !m.op.Is(OpUpdateOne) {
  24564. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24565. }
  24566. if m.id == nil || m.oldValue == nil {
  24567. return v, errors.New("OldStatus requires an ID field in the mutation")
  24568. }
  24569. oldValue, err := m.oldValue(ctx)
  24570. if err != nil {
  24571. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24572. }
  24573. return oldValue.Status, nil
  24574. }
  24575. // AddStatus adds u to the "status" field.
  24576. func (m *SopStageMutation) AddStatus(u int8) {
  24577. if m.addstatus != nil {
  24578. *m.addstatus += u
  24579. } else {
  24580. m.addstatus = &u
  24581. }
  24582. }
  24583. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24584. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  24585. v := m.addstatus
  24586. if v == nil {
  24587. return
  24588. }
  24589. return *v, true
  24590. }
  24591. // ClearStatus clears the value of the "status" field.
  24592. func (m *SopStageMutation) ClearStatus() {
  24593. m.status = nil
  24594. m.addstatus = nil
  24595. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  24596. }
  24597. // StatusCleared returns if the "status" field was cleared in this mutation.
  24598. func (m *SopStageMutation) StatusCleared() bool {
  24599. _, ok := m.clearedFields[sopstage.FieldStatus]
  24600. return ok
  24601. }
  24602. // ResetStatus resets all changes to the "status" field.
  24603. func (m *SopStageMutation) ResetStatus() {
  24604. m.status = nil
  24605. m.addstatus = nil
  24606. delete(m.clearedFields, sopstage.FieldStatus)
  24607. }
  24608. // SetDeletedAt sets the "deleted_at" field.
  24609. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  24610. m.deleted_at = &t
  24611. }
  24612. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24613. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  24614. v := m.deleted_at
  24615. if v == nil {
  24616. return
  24617. }
  24618. return *v, true
  24619. }
  24620. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  24621. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24623. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24624. if !m.op.Is(OpUpdateOne) {
  24625. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24626. }
  24627. if m.id == nil || m.oldValue == nil {
  24628. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24629. }
  24630. oldValue, err := m.oldValue(ctx)
  24631. if err != nil {
  24632. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24633. }
  24634. return oldValue.DeletedAt, nil
  24635. }
  24636. // ClearDeletedAt clears the value of the "deleted_at" field.
  24637. func (m *SopStageMutation) ClearDeletedAt() {
  24638. m.deleted_at = nil
  24639. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  24640. }
  24641. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24642. func (m *SopStageMutation) DeletedAtCleared() bool {
  24643. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  24644. return ok
  24645. }
  24646. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24647. func (m *SopStageMutation) ResetDeletedAt() {
  24648. m.deleted_at = nil
  24649. delete(m.clearedFields, sopstage.FieldDeletedAt)
  24650. }
  24651. // SetTaskID sets the "task_id" field.
  24652. func (m *SopStageMutation) SetTaskID(u uint64) {
  24653. m.sop_task = &u
  24654. }
  24655. // TaskID returns the value of the "task_id" field in the mutation.
  24656. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  24657. v := m.sop_task
  24658. if v == nil {
  24659. return
  24660. }
  24661. return *v, true
  24662. }
  24663. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  24664. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24666. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  24667. if !m.op.Is(OpUpdateOne) {
  24668. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  24669. }
  24670. if m.id == nil || m.oldValue == nil {
  24671. return v, errors.New("OldTaskID requires an ID field in the mutation")
  24672. }
  24673. oldValue, err := m.oldValue(ctx)
  24674. if err != nil {
  24675. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  24676. }
  24677. return oldValue.TaskID, nil
  24678. }
  24679. // ResetTaskID resets all changes to the "task_id" field.
  24680. func (m *SopStageMutation) ResetTaskID() {
  24681. m.sop_task = nil
  24682. }
  24683. // SetName sets the "name" field.
  24684. func (m *SopStageMutation) SetName(s string) {
  24685. m.name = &s
  24686. }
  24687. // Name returns the value of the "name" field in the mutation.
  24688. func (m *SopStageMutation) Name() (r string, exists bool) {
  24689. v := m.name
  24690. if v == nil {
  24691. return
  24692. }
  24693. return *v, true
  24694. }
  24695. // OldName returns the old "name" field's value of the SopStage entity.
  24696. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24698. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  24699. if !m.op.Is(OpUpdateOne) {
  24700. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24701. }
  24702. if m.id == nil || m.oldValue == nil {
  24703. return v, errors.New("OldName requires an ID field in the mutation")
  24704. }
  24705. oldValue, err := m.oldValue(ctx)
  24706. if err != nil {
  24707. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24708. }
  24709. return oldValue.Name, nil
  24710. }
  24711. // ResetName resets all changes to the "name" field.
  24712. func (m *SopStageMutation) ResetName() {
  24713. m.name = nil
  24714. }
  24715. // SetConditionType sets the "condition_type" field.
  24716. func (m *SopStageMutation) SetConditionType(i int) {
  24717. m.condition_type = &i
  24718. m.addcondition_type = nil
  24719. }
  24720. // ConditionType returns the value of the "condition_type" field in the mutation.
  24721. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  24722. v := m.condition_type
  24723. if v == nil {
  24724. return
  24725. }
  24726. return *v, true
  24727. }
  24728. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  24729. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24731. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  24732. if !m.op.Is(OpUpdateOne) {
  24733. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  24734. }
  24735. if m.id == nil || m.oldValue == nil {
  24736. return v, errors.New("OldConditionType requires an ID field in the mutation")
  24737. }
  24738. oldValue, err := m.oldValue(ctx)
  24739. if err != nil {
  24740. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  24741. }
  24742. return oldValue.ConditionType, nil
  24743. }
  24744. // AddConditionType adds i to the "condition_type" field.
  24745. func (m *SopStageMutation) AddConditionType(i int) {
  24746. if m.addcondition_type != nil {
  24747. *m.addcondition_type += i
  24748. } else {
  24749. m.addcondition_type = &i
  24750. }
  24751. }
  24752. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  24753. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  24754. v := m.addcondition_type
  24755. if v == nil {
  24756. return
  24757. }
  24758. return *v, true
  24759. }
  24760. // ResetConditionType resets all changes to the "condition_type" field.
  24761. func (m *SopStageMutation) ResetConditionType() {
  24762. m.condition_type = nil
  24763. m.addcondition_type = nil
  24764. }
  24765. // SetConditionOperator sets the "condition_operator" field.
  24766. func (m *SopStageMutation) SetConditionOperator(i int) {
  24767. m.condition_operator = &i
  24768. m.addcondition_operator = nil
  24769. }
  24770. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  24771. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  24772. v := m.condition_operator
  24773. if v == nil {
  24774. return
  24775. }
  24776. return *v, true
  24777. }
  24778. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  24779. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24781. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  24782. if !m.op.Is(OpUpdateOne) {
  24783. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  24784. }
  24785. if m.id == nil || m.oldValue == nil {
  24786. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  24787. }
  24788. oldValue, err := m.oldValue(ctx)
  24789. if err != nil {
  24790. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  24791. }
  24792. return oldValue.ConditionOperator, nil
  24793. }
  24794. // AddConditionOperator adds i to the "condition_operator" field.
  24795. func (m *SopStageMutation) AddConditionOperator(i int) {
  24796. if m.addcondition_operator != nil {
  24797. *m.addcondition_operator += i
  24798. } else {
  24799. m.addcondition_operator = &i
  24800. }
  24801. }
  24802. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  24803. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  24804. v := m.addcondition_operator
  24805. if v == nil {
  24806. return
  24807. }
  24808. return *v, true
  24809. }
  24810. // ResetConditionOperator resets all changes to the "condition_operator" field.
  24811. func (m *SopStageMutation) ResetConditionOperator() {
  24812. m.condition_operator = nil
  24813. m.addcondition_operator = nil
  24814. }
  24815. // SetConditionList sets the "condition_list" field.
  24816. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  24817. m.condition_list = &ct
  24818. m.appendcondition_list = nil
  24819. }
  24820. // ConditionList returns the value of the "condition_list" field in the mutation.
  24821. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  24822. v := m.condition_list
  24823. if v == nil {
  24824. return
  24825. }
  24826. return *v, true
  24827. }
  24828. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  24829. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24831. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  24832. if !m.op.Is(OpUpdateOne) {
  24833. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  24834. }
  24835. if m.id == nil || m.oldValue == nil {
  24836. return v, errors.New("OldConditionList requires an ID field in the mutation")
  24837. }
  24838. oldValue, err := m.oldValue(ctx)
  24839. if err != nil {
  24840. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  24841. }
  24842. return oldValue.ConditionList, nil
  24843. }
  24844. // AppendConditionList adds ct to the "condition_list" field.
  24845. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  24846. m.appendcondition_list = append(m.appendcondition_list, ct...)
  24847. }
  24848. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  24849. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  24850. if len(m.appendcondition_list) == 0 {
  24851. return nil, false
  24852. }
  24853. return m.appendcondition_list, true
  24854. }
  24855. // ResetConditionList resets all changes to the "condition_list" field.
  24856. func (m *SopStageMutation) ResetConditionList() {
  24857. m.condition_list = nil
  24858. m.appendcondition_list = nil
  24859. }
  24860. // SetActionMessage sets the "action_message" field.
  24861. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  24862. m.action_message = &ct
  24863. m.appendaction_message = nil
  24864. }
  24865. // ActionMessage returns the value of the "action_message" field in the mutation.
  24866. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  24867. v := m.action_message
  24868. if v == nil {
  24869. return
  24870. }
  24871. return *v, true
  24872. }
  24873. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  24874. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24876. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  24877. if !m.op.Is(OpUpdateOne) {
  24878. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  24879. }
  24880. if m.id == nil || m.oldValue == nil {
  24881. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  24882. }
  24883. oldValue, err := m.oldValue(ctx)
  24884. if err != nil {
  24885. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  24886. }
  24887. return oldValue.ActionMessage, nil
  24888. }
  24889. // AppendActionMessage adds ct to the "action_message" field.
  24890. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  24891. m.appendaction_message = append(m.appendaction_message, ct...)
  24892. }
  24893. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  24894. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  24895. if len(m.appendaction_message) == 0 {
  24896. return nil, false
  24897. }
  24898. return m.appendaction_message, true
  24899. }
  24900. // ClearActionMessage clears the value of the "action_message" field.
  24901. func (m *SopStageMutation) ClearActionMessage() {
  24902. m.action_message = nil
  24903. m.appendaction_message = nil
  24904. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  24905. }
  24906. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  24907. func (m *SopStageMutation) ActionMessageCleared() bool {
  24908. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  24909. return ok
  24910. }
  24911. // ResetActionMessage resets all changes to the "action_message" field.
  24912. func (m *SopStageMutation) ResetActionMessage() {
  24913. m.action_message = nil
  24914. m.appendaction_message = nil
  24915. delete(m.clearedFields, sopstage.FieldActionMessage)
  24916. }
  24917. // SetActionLabelAdd sets the "action_label_add" field.
  24918. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  24919. m.action_label_add = &u
  24920. m.appendaction_label_add = nil
  24921. }
  24922. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  24923. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  24924. v := m.action_label_add
  24925. if v == nil {
  24926. return
  24927. }
  24928. return *v, true
  24929. }
  24930. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  24931. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24933. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  24934. if !m.op.Is(OpUpdateOne) {
  24935. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  24936. }
  24937. if m.id == nil || m.oldValue == nil {
  24938. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  24939. }
  24940. oldValue, err := m.oldValue(ctx)
  24941. if err != nil {
  24942. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  24943. }
  24944. return oldValue.ActionLabelAdd, nil
  24945. }
  24946. // AppendActionLabelAdd adds u to the "action_label_add" field.
  24947. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  24948. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  24949. }
  24950. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  24951. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  24952. if len(m.appendaction_label_add) == 0 {
  24953. return nil, false
  24954. }
  24955. return m.appendaction_label_add, true
  24956. }
  24957. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  24958. func (m *SopStageMutation) ClearActionLabelAdd() {
  24959. m.action_label_add = nil
  24960. m.appendaction_label_add = nil
  24961. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  24962. }
  24963. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  24964. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  24965. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  24966. return ok
  24967. }
  24968. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  24969. func (m *SopStageMutation) ResetActionLabelAdd() {
  24970. m.action_label_add = nil
  24971. m.appendaction_label_add = nil
  24972. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  24973. }
  24974. // SetActionLabelDel sets the "action_label_del" field.
  24975. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  24976. m.action_label_del = &u
  24977. m.appendaction_label_del = nil
  24978. }
  24979. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  24980. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  24981. v := m.action_label_del
  24982. if v == nil {
  24983. return
  24984. }
  24985. return *v, true
  24986. }
  24987. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  24988. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24990. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  24991. if !m.op.Is(OpUpdateOne) {
  24992. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  24993. }
  24994. if m.id == nil || m.oldValue == nil {
  24995. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  24996. }
  24997. oldValue, err := m.oldValue(ctx)
  24998. if err != nil {
  24999. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  25000. }
  25001. return oldValue.ActionLabelDel, nil
  25002. }
  25003. // AppendActionLabelDel adds u to the "action_label_del" field.
  25004. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  25005. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25006. }
  25007. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25008. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25009. if len(m.appendaction_label_del) == 0 {
  25010. return nil, false
  25011. }
  25012. return m.appendaction_label_del, true
  25013. }
  25014. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25015. func (m *SopStageMutation) ClearActionLabelDel() {
  25016. m.action_label_del = nil
  25017. m.appendaction_label_del = nil
  25018. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  25019. }
  25020. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25021. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  25022. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  25023. return ok
  25024. }
  25025. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25026. func (m *SopStageMutation) ResetActionLabelDel() {
  25027. m.action_label_del = nil
  25028. m.appendaction_label_del = nil
  25029. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  25030. }
  25031. // SetActionForward sets the "action_forward" field.
  25032. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25033. m.action_forward = &ctf
  25034. }
  25035. // ActionForward returns the value of the "action_forward" field in the mutation.
  25036. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25037. v := m.action_forward
  25038. if v == nil {
  25039. return
  25040. }
  25041. return *v, true
  25042. }
  25043. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  25044. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25046. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25047. if !m.op.Is(OpUpdateOne) {
  25048. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25049. }
  25050. if m.id == nil || m.oldValue == nil {
  25051. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25052. }
  25053. oldValue, err := m.oldValue(ctx)
  25054. if err != nil {
  25055. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25056. }
  25057. return oldValue.ActionForward, nil
  25058. }
  25059. // ClearActionForward clears the value of the "action_forward" field.
  25060. func (m *SopStageMutation) ClearActionForward() {
  25061. m.action_forward = nil
  25062. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  25063. }
  25064. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25065. func (m *SopStageMutation) ActionForwardCleared() bool {
  25066. _, ok := m.clearedFields[sopstage.FieldActionForward]
  25067. return ok
  25068. }
  25069. // ResetActionForward resets all changes to the "action_forward" field.
  25070. func (m *SopStageMutation) ResetActionForward() {
  25071. m.action_forward = nil
  25072. delete(m.clearedFields, sopstage.FieldActionForward)
  25073. }
  25074. // SetIndexSort sets the "index_sort" field.
  25075. func (m *SopStageMutation) SetIndexSort(i int) {
  25076. m.index_sort = &i
  25077. m.addindex_sort = nil
  25078. }
  25079. // IndexSort returns the value of the "index_sort" field in the mutation.
  25080. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  25081. v := m.index_sort
  25082. if v == nil {
  25083. return
  25084. }
  25085. return *v, true
  25086. }
  25087. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  25088. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25090. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  25091. if !m.op.Is(OpUpdateOne) {
  25092. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  25093. }
  25094. if m.id == nil || m.oldValue == nil {
  25095. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  25096. }
  25097. oldValue, err := m.oldValue(ctx)
  25098. if err != nil {
  25099. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  25100. }
  25101. return oldValue.IndexSort, nil
  25102. }
  25103. // AddIndexSort adds i to the "index_sort" field.
  25104. func (m *SopStageMutation) AddIndexSort(i int) {
  25105. if m.addindex_sort != nil {
  25106. *m.addindex_sort += i
  25107. } else {
  25108. m.addindex_sort = &i
  25109. }
  25110. }
  25111. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  25112. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  25113. v := m.addindex_sort
  25114. if v == nil {
  25115. return
  25116. }
  25117. return *v, true
  25118. }
  25119. // ClearIndexSort clears the value of the "index_sort" field.
  25120. func (m *SopStageMutation) ClearIndexSort() {
  25121. m.index_sort = nil
  25122. m.addindex_sort = nil
  25123. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  25124. }
  25125. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  25126. func (m *SopStageMutation) IndexSortCleared() bool {
  25127. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  25128. return ok
  25129. }
  25130. // ResetIndexSort resets all changes to the "index_sort" field.
  25131. func (m *SopStageMutation) ResetIndexSort() {
  25132. m.index_sort = nil
  25133. m.addindex_sort = nil
  25134. delete(m.clearedFields, sopstage.FieldIndexSort)
  25135. }
  25136. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  25137. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  25138. m.sop_task = &id
  25139. }
  25140. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  25141. func (m *SopStageMutation) ClearSopTask() {
  25142. m.clearedsop_task = true
  25143. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  25144. }
  25145. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  25146. func (m *SopStageMutation) SopTaskCleared() bool {
  25147. return m.clearedsop_task
  25148. }
  25149. // SopTaskID returns the "sop_task" edge ID in the mutation.
  25150. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  25151. if m.sop_task != nil {
  25152. return *m.sop_task, true
  25153. }
  25154. return
  25155. }
  25156. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  25157. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25158. // SopTaskID instead. It exists only for internal usage by the builders.
  25159. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  25160. if id := m.sop_task; id != nil {
  25161. ids = append(ids, *id)
  25162. }
  25163. return
  25164. }
  25165. // ResetSopTask resets all changes to the "sop_task" edge.
  25166. func (m *SopStageMutation) ResetSopTask() {
  25167. m.sop_task = nil
  25168. m.clearedsop_task = false
  25169. }
  25170. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  25171. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  25172. if m.stage_nodes == nil {
  25173. m.stage_nodes = make(map[uint64]struct{})
  25174. }
  25175. for i := range ids {
  25176. m.stage_nodes[ids[i]] = struct{}{}
  25177. }
  25178. }
  25179. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  25180. func (m *SopStageMutation) ClearStageNodes() {
  25181. m.clearedstage_nodes = true
  25182. }
  25183. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  25184. func (m *SopStageMutation) StageNodesCleared() bool {
  25185. return m.clearedstage_nodes
  25186. }
  25187. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  25188. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  25189. if m.removedstage_nodes == nil {
  25190. m.removedstage_nodes = make(map[uint64]struct{})
  25191. }
  25192. for i := range ids {
  25193. delete(m.stage_nodes, ids[i])
  25194. m.removedstage_nodes[ids[i]] = struct{}{}
  25195. }
  25196. }
  25197. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  25198. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  25199. for id := range m.removedstage_nodes {
  25200. ids = append(ids, id)
  25201. }
  25202. return
  25203. }
  25204. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  25205. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  25206. for id := range m.stage_nodes {
  25207. ids = append(ids, id)
  25208. }
  25209. return
  25210. }
  25211. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  25212. func (m *SopStageMutation) ResetStageNodes() {
  25213. m.stage_nodes = nil
  25214. m.clearedstage_nodes = false
  25215. m.removedstage_nodes = nil
  25216. }
  25217. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  25218. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  25219. if m.stage_messages == nil {
  25220. m.stage_messages = make(map[uint64]struct{})
  25221. }
  25222. for i := range ids {
  25223. m.stage_messages[ids[i]] = struct{}{}
  25224. }
  25225. }
  25226. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  25227. func (m *SopStageMutation) ClearStageMessages() {
  25228. m.clearedstage_messages = true
  25229. }
  25230. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  25231. func (m *SopStageMutation) StageMessagesCleared() bool {
  25232. return m.clearedstage_messages
  25233. }
  25234. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  25235. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  25236. if m.removedstage_messages == nil {
  25237. m.removedstage_messages = make(map[uint64]struct{})
  25238. }
  25239. for i := range ids {
  25240. delete(m.stage_messages, ids[i])
  25241. m.removedstage_messages[ids[i]] = struct{}{}
  25242. }
  25243. }
  25244. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  25245. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  25246. for id := range m.removedstage_messages {
  25247. ids = append(ids, id)
  25248. }
  25249. return
  25250. }
  25251. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  25252. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  25253. for id := range m.stage_messages {
  25254. ids = append(ids, id)
  25255. }
  25256. return
  25257. }
  25258. // ResetStageMessages resets all changes to the "stage_messages" edge.
  25259. func (m *SopStageMutation) ResetStageMessages() {
  25260. m.stage_messages = nil
  25261. m.clearedstage_messages = false
  25262. m.removedstage_messages = nil
  25263. }
  25264. // Where appends a list predicates to the SopStageMutation builder.
  25265. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  25266. m.predicates = append(m.predicates, ps...)
  25267. }
  25268. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  25269. // users can use type-assertion to append predicates that do not depend on any generated package.
  25270. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  25271. p := make([]predicate.SopStage, len(ps))
  25272. for i := range ps {
  25273. p[i] = ps[i]
  25274. }
  25275. m.Where(p...)
  25276. }
  25277. // Op returns the operation name.
  25278. func (m *SopStageMutation) Op() Op {
  25279. return m.op
  25280. }
  25281. // SetOp allows setting the mutation operation.
  25282. func (m *SopStageMutation) SetOp(op Op) {
  25283. m.op = op
  25284. }
  25285. // Type returns the node type of this mutation (SopStage).
  25286. func (m *SopStageMutation) Type() string {
  25287. return m.typ
  25288. }
  25289. // Fields returns all fields that were changed during this mutation. Note that in
  25290. // order to get all numeric fields that were incremented/decremented, call
  25291. // AddedFields().
  25292. func (m *SopStageMutation) Fields() []string {
  25293. fields := make([]string, 0, 14)
  25294. if m.created_at != nil {
  25295. fields = append(fields, sopstage.FieldCreatedAt)
  25296. }
  25297. if m.updated_at != nil {
  25298. fields = append(fields, sopstage.FieldUpdatedAt)
  25299. }
  25300. if m.status != nil {
  25301. fields = append(fields, sopstage.FieldStatus)
  25302. }
  25303. if m.deleted_at != nil {
  25304. fields = append(fields, sopstage.FieldDeletedAt)
  25305. }
  25306. if m.sop_task != nil {
  25307. fields = append(fields, sopstage.FieldTaskID)
  25308. }
  25309. if m.name != nil {
  25310. fields = append(fields, sopstage.FieldName)
  25311. }
  25312. if m.condition_type != nil {
  25313. fields = append(fields, sopstage.FieldConditionType)
  25314. }
  25315. if m.condition_operator != nil {
  25316. fields = append(fields, sopstage.FieldConditionOperator)
  25317. }
  25318. if m.condition_list != nil {
  25319. fields = append(fields, sopstage.FieldConditionList)
  25320. }
  25321. if m.action_message != nil {
  25322. fields = append(fields, sopstage.FieldActionMessage)
  25323. }
  25324. if m.action_label_add != nil {
  25325. fields = append(fields, sopstage.FieldActionLabelAdd)
  25326. }
  25327. if m.action_label_del != nil {
  25328. fields = append(fields, sopstage.FieldActionLabelDel)
  25329. }
  25330. if m.action_forward != nil {
  25331. fields = append(fields, sopstage.FieldActionForward)
  25332. }
  25333. if m.index_sort != nil {
  25334. fields = append(fields, sopstage.FieldIndexSort)
  25335. }
  25336. return fields
  25337. }
  25338. // Field returns the value of a field with the given name. The second boolean
  25339. // return value indicates that this field was not set, or was not defined in the
  25340. // schema.
  25341. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  25342. switch name {
  25343. case sopstage.FieldCreatedAt:
  25344. return m.CreatedAt()
  25345. case sopstage.FieldUpdatedAt:
  25346. return m.UpdatedAt()
  25347. case sopstage.FieldStatus:
  25348. return m.Status()
  25349. case sopstage.FieldDeletedAt:
  25350. return m.DeletedAt()
  25351. case sopstage.FieldTaskID:
  25352. return m.TaskID()
  25353. case sopstage.FieldName:
  25354. return m.Name()
  25355. case sopstage.FieldConditionType:
  25356. return m.ConditionType()
  25357. case sopstage.FieldConditionOperator:
  25358. return m.ConditionOperator()
  25359. case sopstage.FieldConditionList:
  25360. return m.ConditionList()
  25361. case sopstage.FieldActionMessage:
  25362. return m.ActionMessage()
  25363. case sopstage.FieldActionLabelAdd:
  25364. return m.ActionLabelAdd()
  25365. case sopstage.FieldActionLabelDel:
  25366. return m.ActionLabelDel()
  25367. case sopstage.FieldActionForward:
  25368. return m.ActionForward()
  25369. case sopstage.FieldIndexSort:
  25370. return m.IndexSort()
  25371. }
  25372. return nil, false
  25373. }
  25374. // OldField returns the old value of the field from the database. An error is
  25375. // returned if the mutation operation is not UpdateOne, or the query to the
  25376. // database failed.
  25377. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25378. switch name {
  25379. case sopstage.FieldCreatedAt:
  25380. return m.OldCreatedAt(ctx)
  25381. case sopstage.FieldUpdatedAt:
  25382. return m.OldUpdatedAt(ctx)
  25383. case sopstage.FieldStatus:
  25384. return m.OldStatus(ctx)
  25385. case sopstage.FieldDeletedAt:
  25386. return m.OldDeletedAt(ctx)
  25387. case sopstage.FieldTaskID:
  25388. return m.OldTaskID(ctx)
  25389. case sopstage.FieldName:
  25390. return m.OldName(ctx)
  25391. case sopstage.FieldConditionType:
  25392. return m.OldConditionType(ctx)
  25393. case sopstage.FieldConditionOperator:
  25394. return m.OldConditionOperator(ctx)
  25395. case sopstage.FieldConditionList:
  25396. return m.OldConditionList(ctx)
  25397. case sopstage.FieldActionMessage:
  25398. return m.OldActionMessage(ctx)
  25399. case sopstage.FieldActionLabelAdd:
  25400. return m.OldActionLabelAdd(ctx)
  25401. case sopstage.FieldActionLabelDel:
  25402. return m.OldActionLabelDel(ctx)
  25403. case sopstage.FieldActionForward:
  25404. return m.OldActionForward(ctx)
  25405. case sopstage.FieldIndexSort:
  25406. return m.OldIndexSort(ctx)
  25407. }
  25408. return nil, fmt.Errorf("unknown SopStage field %s", name)
  25409. }
  25410. // SetField sets the value of a field with the given name. It returns an error if
  25411. // the field is not defined in the schema, or if the type mismatched the field
  25412. // type.
  25413. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  25414. switch name {
  25415. case sopstage.FieldCreatedAt:
  25416. v, ok := value.(time.Time)
  25417. if !ok {
  25418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25419. }
  25420. m.SetCreatedAt(v)
  25421. return nil
  25422. case sopstage.FieldUpdatedAt:
  25423. v, ok := value.(time.Time)
  25424. if !ok {
  25425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25426. }
  25427. m.SetUpdatedAt(v)
  25428. return nil
  25429. case sopstage.FieldStatus:
  25430. v, ok := value.(uint8)
  25431. if !ok {
  25432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25433. }
  25434. m.SetStatus(v)
  25435. return nil
  25436. case sopstage.FieldDeletedAt:
  25437. v, ok := value.(time.Time)
  25438. if !ok {
  25439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25440. }
  25441. m.SetDeletedAt(v)
  25442. return nil
  25443. case sopstage.FieldTaskID:
  25444. v, ok := value.(uint64)
  25445. if !ok {
  25446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25447. }
  25448. m.SetTaskID(v)
  25449. return nil
  25450. case sopstage.FieldName:
  25451. v, ok := value.(string)
  25452. if !ok {
  25453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25454. }
  25455. m.SetName(v)
  25456. return nil
  25457. case sopstage.FieldConditionType:
  25458. v, ok := value.(int)
  25459. if !ok {
  25460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25461. }
  25462. m.SetConditionType(v)
  25463. return nil
  25464. case sopstage.FieldConditionOperator:
  25465. v, ok := value.(int)
  25466. if !ok {
  25467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25468. }
  25469. m.SetConditionOperator(v)
  25470. return nil
  25471. case sopstage.FieldConditionList:
  25472. v, ok := value.([]custom_types.Condition)
  25473. if !ok {
  25474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25475. }
  25476. m.SetConditionList(v)
  25477. return nil
  25478. case sopstage.FieldActionMessage:
  25479. v, ok := value.([]custom_types.Action)
  25480. if !ok {
  25481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25482. }
  25483. m.SetActionMessage(v)
  25484. return nil
  25485. case sopstage.FieldActionLabelAdd:
  25486. v, ok := value.([]uint64)
  25487. if !ok {
  25488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25489. }
  25490. m.SetActionLabelAdd(v)
  25491. return nil
  25492. case sopstage.FieldActionLabelDel:
  25493. v, ok := value.([]uint64)
  25494. if !ok {
  25495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25496. }
  25497. m.SetActionLabelDel(v)
  25498. return nil
  25499. case sopstage.FieldActionForward:
  25500. v, ok := value.(*custom_types.ActionForward)
  25501. if !ok {
  25502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25503. }
  25504. m.SetActionForward(v)
  25505. return nil
  25506. case sopstage.FieldIndexSort:
  25507. v, ok := value.(int)
  25508. if !ok {
  25509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25510. }
  25511. m.SetIndexSort(v)
  25512. return nil
  25513. }
  25514. return fmt.Errorf("unknown SopStage field %s", name)
  25515. }
  25516. // AddedFields returns all numeric fields that were incremented/decremented during
  25517. // this mutation.
  25518. func (m *SopStageMutation) AddedFields() []string {
  25519. var fields []string
  25520. if m.addstatus != nil {
  25521. fields = append(fields, sopstage.FieldStatus)
  25522. }
  25523. if m.addcondition_type != nil {
  25524. fields = append(fields, sopstage.FieldConditionType)
  25525. }
  25526. if m.addcondition_operator != nil {
  25527. fields = append(fields, sopstage.FieldConditionOperator)
  25528. }
  25529. if m.addindex_sort != nil {
  25530. fields = append(fields, sopstage.FieldIndexSort)
  25531. }
  25532. return fields
  25533. }
  25534. // AddedField returns the numeric value that was incremented/decremented on a field
  25535. // with the given name. The second boolean return value indicates that this field
  25536. // was not set, or was not defined in the schema.
  25537. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  25538. switch name {
  25539. case sopstage.FieldStatus:
  25540. return m.AddedStatus()
  25541. case sopstage.FieldConditionType:
  25542. return m.AddedConditionType()
  25543. case sopstage.FieldConditionOperator:
  25544. return m.AddedConditionOperator()
  25545. case sopstage.FieldIndexSort:
  25546. return m.AddedIndexSort()
  25547. }
  25548. return nil, false
  25549. }
  25550. // AddField adds the value to the field with the given name. It returns an error if
  25551. // the field is not defined in the schema, or if the type mismatched the field
  25552. // type.
  25553. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  25554. switch name {
  25555. case sopstage.FieldStatus:
  25556. v, ok := value.(int8)
  25557. if !ok {
  25558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25559. }
  25560. m.AddStatus(v)
  25561. return nil
  25562. case sopstage.FieldConditionType:
  25563. v, ok := value.(int)
  25564. if !ok {
  25565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25566. }
  25567. m.AddConditionType(v)
  25568. return nil
  25569. case sopstage.FieldConditionOperator:
  25570. v, ok := value.(int)
  25571. if !ok {
  25572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25573. }
  25574. m.AddConditionOperator(v)
  25575. return nil
  25576. case sopstage.FieldIndexSort:
  25577. v, ok := value.(int)
  25578. if !ok {
  25579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25580. }
  25581. m.AddIndexSort(v)
  25582. return nil
  25583. }
  25584. return fmt.Errorf("unknown SopStage numeric field %s", name)
  25585. }
  25586. // ClearedFields returns all nullable fields that were cleared during this
  25587. // mutation.
  25588. func (m *SopStageMutation) ClearedFields() []string {
  25589. var fields []string
  25590. if m.FieldCleared(sopstage.FieldStatus) {
  25591. fields = append(fields, sopstage.FieldStatus)
  25592. }
  25593. if m.FieldCleared(sopstage.FieldDeletedAt) {
  25594. fields = append(fields, sopstage.FieldDeletedAt)
  25595. }
  25596. if m.FieldCleared(sopstage.FieldActionMessage) {
  25597. fields = append(fields, sopstage.FieldActionMessage)
  25598. }
  25599. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  25600. fields = append(fields, sopstage.FieldActionLabelAdd)
  25601. }
  25602. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  25603. fields = append(fields, sopstage.FieldActionLabelDel)
  25604. }
  25605. if m.FieldCleared(sopstage.FieldActionForward) {
  25606. fields = append(fields, sopstage.FieldActionForward)
  25607. }
  25608. if m.FieldCleared(sopstage.FieldIndexSort) {
  25609. fields = append(fields, sopstage.FieldIndexSort)
  25610. }
  25611. return fields
  25612. }
  25613. // FieldCleared returns a boolean indicating if a field with the given name was
  25614. // cleared in this mutation.
  25615. func (m *SopStageMutation) FieldCleared(name string) bool {
  25616. _, ok := m.clearedFields[name]
  25617. return ok
  25618. }
  25619. // ClearField clears the value of the field with the given name. It returns an
  25620. // error if the field is not defined in the schema.
  25621. func (m *SopStageMutation) ClearField(name string) error {
  25622. switch name {
  25623. case sopstage.FieldStatus:
  25624. m.ClearStatus()
  25625. return nil
  25626. case sopstage.FieldDeletedAt:
  25627. m.ClearDeletedAt()
  25628. return nil
  25629. case sopstage.FieldActionMessage:
  25630. m.ClearActionMessage()
  25631. return nil
  25632. case sopstage.FieldActionLabelAdd:
  25633. m.ClearActionLabelAdd()
  25634. return nil
  25635. case sopstage.FieldActionLabelDel:
  25636. m.ClearActionLabelDel()
  25637. return nil
  25638. case sopstage.FieldActionForward:
  25639. m.ClearActionForward()
  25640. return nil
  25641. case sopstage.FieldIndexSort:
  25642. m.ClearIndexSort()
  25643. return nil
  25644. }
  25645. return fmt.Errorf("unknown SopStage nullable field %s", name)
  25646. }
  25647. // ResetField resets all changes in the mutation for the field with the given name.
  25648. // It returns an error if the field is not defined in the schema.
  25649. func (m *SopStageMutation) ResetField(name string) error {
  25650. switch name {
  25651. case sopstage.FieldCreatedAt:
  25652. m.ResetCreatedAt()
  25653. return nil
  25654. case sopstage.FieldUpdatedAt:
  25655. m.ResetUpdatedAt()
  25656. return nil
  25657. case sopstage.FieldStatus:
  25658. m.ResetStatus()
  25659. return nil
  25660. case sopstage.FieldDeletedAt:
  25661. m.ResetDeletedAt()
  25662. return nil
  25663. case sopstage.FieldTaskID:
  25664. m.ResetTaskID()
  25665. return nil
  25666. case sopstage.FieldName:
  25667. m.ResetName()
  25668. return nil
  25669. case sopstage.FieldConditionType:
  25670. m.ResetConditionType()
  25671. return nil
  25672. case sopstage.FieldConditionOperator:
  25673. m.ResetConditionOperator()
  25674. return nil
  25675. case sopstage.FieldConditionList:
  25676. m.ResetConditionList()
  25677. return nil
  25678. case sopstage.FieldActionMessage:
  25679. m.ResetActionMessage()
  25680. return nil
  25681. case sopstage.FieldActionLabelAdd:
  25682. m.ResetActionLabelAdd()
  25683. return nil
  25684. case sopstage.FieldActionLabelDel:
  25685. m.ResetActionLabelDel()
  25686. return nil
  25687. case sopstage.FieldActionForward:
  25688. m.ResetActionForward()
  25689. return nil
  25690. case sopstage.FieldIndexSort:
  25691. m.ResetIndexSort()
  25692. return nil
  25693. }
  25694. return fmt.Errorf("unknown SopStage field %s", name)
  25695. }
  25696. // AddedEdges returns all edge names that were set/added in this mutation.
  25697. func (m *SopStageMutation) AddedEdges() []string {
  25698. edges := make([]string, 0, 3)
  25699. if m.sop_task != nil {
  25700. edges = append(edges, sopstage.EdgeSopTask)
  25701. }
  25702. if m.stage_nodes != nil {
  25703. edges = append(edges, sopstage.EdgeStageNodes)
  25704. }
  25705. if m.stage_messages != nil {
  25706. edges = append(edges, sopstage.EdgeStageMessages)
  25707. }
  25708. return edges
  25709. }
  25710. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25711. // name in this mutation.
  25712. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  25713. switch name {
  25714. case sopstage.EdgeSopTask:
  25715. if id := m.sop_task; id != nil {
  25716. return []ent.Value{*id}
  25717. }
  25718. case sopstage.EdgeStageNodes:
  25719. ids := make([]ent.Value, 0, len(m.stage_nodes))
  25720. for id := range m.stage_nodes {
  25721. ids = append(ids, id)
  25722. }
  25723. return ids
  25724. case sopstage.EdgeStageMessages:
  25725. ids := make([]ent.Value, 0, len(m.stage_messages))
  25726. for id := range m.stage_messages {
  25727. ids = append(ids, id)
  25728. }
  25729. return ids
  25730. }
  25731. return nil
  25732. }
  25733. // RemovedEdges returns all edge names that were removed in this mutation.
  25734. func (m *SopStageMutation) RemovedEdges() []string {
  25735. edges := make([]string, 0, 3)
  25736. if m.removedstage_nodes != nil {
  25737. edges = append(edges, sopstage.EdgeStageNodes)
  25738. }
  25739. if m.removedstage_messages != nil {
  25740. edges = append(edges, sopstage.EdgeStageMessages)
  25741. }
  25742. return edges
  25743. }
  25744. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25745. // the given name in this mutation.
  25746. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  25747. switch name {
  25748. case sopstage.EdgeStageNodes:
  25749. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  25750. for id := range m.removedstage_nodes {
  25751. ids = append(ids, id)
  25752. }
  25753. return ids
  25754. case sopstage.EdgeStageMessages:
  25755. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  25756. for id := range m.removedstage_messages {
  25757. ids = append(ids, id)
  25758. }
  25759. return ids
  25760. }
  25761. return nil
  25762. }
  25763. // ClearedEdges returns all edge names that were cleared in this mutation.
  25764. func (m *SopStageMutation) ClearedEdges() []string {
  25765. edges := make([]string, 0, 3)
  25766. if m.clearedsop_task {
  25767. edges = append(edges, sopstage.EdgeSopTask)
  25768. }
  25769. if m.clearedstage_nodes {
  25770. edges = append(edges, sopstage.EdgeStageNodes)
  25771. }
  25772. if m.clearedstage_messages {
  25773. edges = append(edges, sopstage.EdgeStageMessages)
  25774. }
  25775. return edges
  25776. }
  25777. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25778. // was cleared in this mutation.
  25779. func (m *SopStageMutation) EdgeCleared(name string) bool {
  25780. switch name {
  25781. case sopstage.EdgeSopTask:
  25782. return m.clearedsop_task
  25783. case sopstage.EdgeStageNodes:
  25784. return m.clearedstage_nodes
  25785. case sopstage.EdgeStageMessages:
  25786. return m.clearedstage_messages
  25787. }
  25788. return false
  25789. }
  25790. // ClearEdge clears the value of the edge with the given name. It returns an error
  25791. // if that edge is not defined in the schema.
  25792. func (m *SopStageMutation) ClearEdge(name string) error {
  25793. switch name {
  25794. case sopstage.EdgeSopTask:
  25795. m.ClearSopTask()
  25796. return nil
  25797. }
  25798. return fmt.Errorf("unknown SopStage unique edge %s", name)
  25799. }
  25800. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25801. // It returns an error if the edge is not defined in the schema.
  25802. func (m *SopStageMutation) ResetEdge(name string) error {
  25803. switch name {
  25804. case sopstage.EdgeSopTask:
  25805. m.ResetSopTask()
  25806. return nil
  25807. case sopstage.EdgeStageNodes:
  25808. m.ResetStageNodes()
  25809. return nil
  25810. case sopstage.EdgeStageMessages:
  25811. m.ResetStageMessages()
  25812. return nil
  25813. }
  25814. return fmt.Errorf("unknown SopStage edge %s", name)
  25815. }
  25816. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  25817. type SopTaskMutation struct {
  25818. config
  25819. op Op
  25820. typ string
  25821. id *uint64
  25822. created_at *time.Time
  25823. updated_at *time.Time
  25824. status *uint8
  25825. addstatus *int8
  25826. deleted_at *time.Time
  25827. name *string
  25828. bot_wxid_list *[]string
  25829. appendbot_wxid_list []string
  25830. _type *int
  25831. add_type *int
  25832. plan_start_time *time.Time
  25833. plan_end_time *time.Time
  25834. creator_id *string
  25835. organization_id *uint64
  25836. addorganization_id *int64
  25837. token *[]string
  25838. appendtoken []string
  25839. clearedFields map[string]struct{}
  25840. task_stages map[uint64]struct{}
  25841. removedtask_stages map[uint64]struct{}
  25842. clearedtask_stages bool
  25843. done bool
  25844. oldValue func(context.Context) (*SopTask, error)
  25845. predicates []predicate.SopTask
  25846. }
  25847. var _ ent.Mutation = (*SopTaskMutation)(nil)
  25848. // soptaskOption allows management of the mutation configuration using functional options.
  25849. type soptaskOption func(*SopTaskMutation)
  25850. // newSopTaskMutation creates new mutation for the SopTask entity.
  25851. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  25852. m := &SopTaskMutation{
  25853. config: c,
  25854. op: op,
  25855. typ: TypeSopTask,
  25856. clearedFields: make(map[string]struct{}),
  25857. }
  25858. for _, opt := range opts {
  25859. opt(m)
  25860. }
  25861. return m
  25862. }
  25863. // withSopTaskID sets the ID field of the mutation.
  25864. func withSopTaskID(id uint64) soptaskOption {
  25865. return func(m *SopTaskMutation) {
  25866. var (
  25867. err error
  25868. once sync.Once
  25869. value *SopTask
  25870. )
  25871. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  25872. once.Do(func() {
  25873. if m.done {
  25874. err = errors.New("querying old values post mutation is not allowed")
  25875. } else {
  25876. value, err = m.Client().SopTask.Get(ctx, id)
  25877. }
  25878. })
  25879. return value, err
  25880. }
  25881. m.id = &id
  25882. }
  25883. }
  25884. // withSopTask sets the old SopTask of the mutation.
  25885. func withSopTask(node *SopTask) soptaskOption {
  25886. return func(m *SopTaskMutation) {
  25887. m.oldValue = func(context.Context) (*SopTask, error) {
  25888. return node, nil
  25889. }
  25890. m.id = &node.ID
  25891. }
  25892. }
  25893. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25894. // executed in a transaction (ent.Tx), a transactional client is returned.
  25895. func (m SopTaskMutation) Client() *Client {
  25896. client := &Client{config: m.config}
  25897. client.init()
  25898. return client
  25899. }
  25900. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25901. // it returns an error otherwise.
  25902. func (m SopTaskMutation) Tx() (*Tx, error) {
  25903. if _, ok := m.driver.(*txDriver); !ok {
  25904. return nil, errors.New("ent: mutation is not running in a transaction")
  25905. }
  25906. tx := &Tx{config: m.config}
  25907. tx.init()
  25908. return tx, nil
  25909. }
  25910. // SetID sets the value of the id field. Note that this
  25911. // operation is only accepted on creation of SopTask entities.
  25912. func (m *SopTaskMutation) SetID(id uint64) {
  25913. m.id = &id
  25914. }
  25915. // ID returns the ID value in the mutation. Note that the ID is only available
  25916. // if it was provided to the builder or after it was returned from the database.
  25917. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  25918. if m.id == nil {
  25919. return
  25920. }
  25921. return *m.id, true
  25922. }
  25923. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25924. // That means, if the mutation is applied within a transaction with an isolation level such
  25925. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25926. // or updated by the mutation.
  25927. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  25928. switch {
  25929. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25930. id, exists := m.ID()
  25931. if exists {
  25932. return []uint64{id}, nil
  25933. }
  25934. fallthrough
  25935. case m.op.Is(OpUpdate | OpDelete):
  25936. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  25937. default:
  25938. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25939. }
  25940. }
  25941. // SetCreatedAt sets the "created_at" field.
  25942. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  25943. m.created_at = &t
  25944. }
  25945. // CreatedAt returns the value of the "created_at" field in the mutation.
  25946. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  25947. v := m.created_at
  25948. if v == nil {
  25949. return
  25950. }
  25951. return *v, true
  25952. }
  25953. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  25954. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25956. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25957. if !m.op.Is(OpUpdateOne) {
  25958. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25959. }
  25960. if m.id == nil || m.oldValue == nil {
  25961. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25962. }
  25963. oldValue, err := m.oldValue(ctx)
  25964. if err != nil {
  25965. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25966. }
  25967. return oldValue.CreatedAt, nil
  25968. }
  25969. // ResetCreatedAt resets all changes to the "created_at" field.
  25970. func (m *SopTaskMutation) ResetCreatedAt() {
  25971. m.created_at = nil
  25972. }
  25973. // SetUpdatedAt sets the "updated_at" field.
  25974. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  25975. m.updated_at = &t
  25976. }
  25977. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25978. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  25979. v := m.updated_at
  25980. if v == nil {
  25981. return
  25982. }
  25983. return *v, true
  25984. }
  25985. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  25986. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25988. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25989. if !m.op.Is(OpUpdateOne) {
  25990. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25991. }
  25992. if m.id == nil || m.oldValue == nil {
  25993. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25994. }
  25995. oldValue, err := m.oldValue(ctx)
  25996. if err != nil {
  25997. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25998. }
  25999. return oldValue.UpdatedAt, nil
  26000. }
  26001. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26002. func (m *SopTaskMutation) ResetUpdatedAt() {
  26003. m.updated_at = nil
  26004. }
  26005. // SetStatus sets the "status" field.
  26006. func (m *SopTaskMutation) SetStatus(u uint8) {
  26007. m.status = &u
  26008. m.addstatus = nil
  26009. }
  26010. // Status returns the value of the "status" field in the mutation.
  26011. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  26012. v := m.status
  26013. if v == nil {
  26014. return
  26015. }
  26016. return *v, true
  26017. }
  26018. // OldStatus returns the old "status" field's value of the SopTask entity.
  26019. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26021. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26022. if !m.op.Is(OpUpdateOne) {
  26023. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26024. }
  26025. if m.id == nil || m.oldValue == nil {
  26026. return v, errors.New("OldStatus requires an ID field in the mutation")
  26027. }
  26028. oldValue, err := m.oldValue(ctx)
  26029. if err != nil {
  26030. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26031. }
  26032. return oldValue.Status, nil
  26033. }
  26034. // AddStatus adds u to the "status" field.
  26035. func (m *SopTaskMutation) AddStatus(u int8) {
  26036. if m.addstatus != nil {
  26037. *m.addstatus += u
  26038. } else {
  26039. m.addstatus = &u
  26040. }
  26041. }
  26042. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26043. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  26044. v := m.addstatus
  26045. if v == nil {
  26046. return
  26047. }
  26048. return *v, true
  26049. }
  26050. // ClearStatus clears the value of the "status" field.
  26051. func (m *SopTaskMutation) ClearStatus() {
  26052. m.status = nil
  26053. m.addstatus = nil
  26054. m.clearedFields[soptask.FieldStatus] = struct{}{}
  26055. }
  26056. // StatusCleared returns if the "status" field was cleared in this mutation.
  26057. func (m *SopTaskMutation) StatusCleared() bool {
  26058. _, ok := m.clearedFields[soptask.FieldStatus]
  26059. return ok
  26060. }
  26061. // ResetStatus resets all changes to the "status" field.
  26062. func (m *SopTaskMutation) ResetStatus() {
  26063. m.status = nil
  26064. m.addstatus = nil
  26065. delete(m.clearedFields, soptask.FieldStatus)
  26066. }
  26067. // SetDeletedAt sets the "deleted_at" field.
  26068. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  26069. m.deleted_at = &t
  26070. }
  26071. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26072. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  26073. v := m.deleted_at
  26074. if v == nil {
  26075. return
  26076. }
  26077. return *v, true
  26078. }
  26079. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  26080. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26082. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26083. if !m.op.Is(OpUpdateOne) {
  26084. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26085. }
  26086. if m.id == nil || m.oldValue == nil {
  26087. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26088. }
  26089. oldValue, err := m.oldValue(ctx)
  26090. if err != nil {
  26091. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26092. }
  26093. return oldValue.DeletedAt, nil
  26094. }
  26095. // ClearDeletedAt clears the value of the "deleted_at" field.
  26096. func (m *SopTaskMutation) ClearDeletedAt() {
  26097. m.deleted_at = nil
  26098. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  26099. }
  26100. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26101. func (m *SopTaskMutation) DeletedAtCleared() bool {
  26102. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  26103. return ok
  26104. }
  26105. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26106. func (m *SopTaskMutation) ResetDeletedAt() {
  26107. m.deleted_at = nil
  26108. delete(m.clearedFields, soptask.FieldDeletedAt)
  26109. }
  26110. // SetName sets the "name" field.
  26111. func (m *SopTaskMutation) SetName(s string) {
  26112. m.name = &s
  26113. }
  26114. // Name returns the value of the "name" field in the mutation.
  26115. func (m *SopTaskMutation) Name() (r string, exists bool) {
  26116. v := m.name
  26117. if v == nil {
  26118. return
  26119. }
  26120. return *v, true
  26121. }
  26122. // OldName returns the old "name" field's value of the SopTask entity.
  26123. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26125. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  26126. if !m.op.Is(OpUpdateOne) {
  26127. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26128. }
  26129. if m.id == nil || m.oldValue == nil {
  26130. return v, errors.New("OldName requires an ID field in the mutation")
  26131. }
  26132. oldValue, err := m.oldValue(ctx)
  26133. if err != nil {
  26134. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26135. }
  26136. return oldValue.Name, nil
  26137. }
  26138. // ResetName resets all changes to the "name" field.
  26139. func (m *SopTaskMutation) ResetName() {
  26140. m.name = nil
  26141. }
  26142. // SetBotWxidList sets the "bot_wxid_list" field.
  26143. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  26144. m.bot_wxid_list = &s
  26145. m.appendbot_wxid_list = nil
  26146. }
  26147. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  26148. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  26149. v := m.bot_wxid_list
  26150. if v == nil {
  26151. return
  26152. }
  26153. return *v, true
  26154. }
  26155. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  26156. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26158. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  26159. if !m.op.Is(OpUpdateOne) {
  26160. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  26161. }
  26162. if m.id == nil || m.oldValue == nil {
  26163. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  26164. }
  26165. oldValue, err := m.oldValue(ctx)
  26166. if err != nil {
  26167. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  26168. }
  26169. return oldValue.BotWxidList, nil
  26170. }
  26171. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  26172. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  26173. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  26174. }
  26175. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  26176. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  26177. if len(m.appendbot_wxid_list) == 0 {
  26178. return nil, false
  26179. }
  26180. return m.appendbot_wxid_list, true
  26181. }
  26182. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  26183. func (m *SopTaskMutation) ClearBotWxidList() {
  26184. m.bot_wxid_list = nil
  26185. m.appendbot_wxid_list = nil
  26186. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  26187. }
  26188. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  26189. func (m *SopTaskMutation) BotWxidListCleared() bool {
  26190. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  26191. return ok
  26192. }
  26193. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  26194. func (m *SopTaskMutation) ResetBotWxidList() {
  26195. m.bot_wxid_list = nil
  26196. m.appendbot_wxid_list = nil
  26197. delete(m.clearedFields, soptask.FieldBotWxidList)
  26198. }
  26199. // SetType sets the "type" field.
  26200. func (m *SopTaskMutation) SetType(i int) {
  26201. m._type = &i
  26202. m.add_type = nil
  26203. }
  26204. // GetType returns the value of the "type" field in the mutation.
  26205. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  26206. v := m._type
  26207. if v == nil {
  26208. return
  26209. }
  26210. return *v, true
  26211. }
  26212. // OldType returns the old "type" field's value of the SopTask entity.
  26213. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26215. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  26216. if !m.op.Is(OpUpdateOne) {
  26217. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26218. }
  26219. if m.id == nil || m.oldValue == nil {
  26220. return v, errors.New("OldType requires an ID field in the mutation")
  26221. }
  26222. oldValue, err := m.oldValue(ctx)
  26223. if err != nil {
  26224. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26225. }
  26226. return oldValue.Type, nil
  26227. }
  26228. // AddType adds i to the "type" field.
  26229. func (m *SopTaskMutation) AddType(i int) {
  26230. if m.add_type != nil {
  26231. *m.add_type += i
  26232. } else {
  26233. m.add_type = &i
  26234. }
  26235. }
  26236. // AddedType returns the value that was added to the "type" field in this mutation.
  26237. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  26238. v := m.add_type
  26239. if v == nil {
  26240. return
  26241. }
  26242. return *v, true
  26243. }
  26244. // ResetType resets all changes to the "type" field.
  26245. func (m *SopTaskMutation) ResetType() {
  26246. m._type = nil
  26247. m.add_type = nil
  26248. }
  26249. // SetPlanStartTime sets the "plan_start_time" field.
  26250. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  26251. m.plan_start_time = &t
  26252. }
  26253. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  26254. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  26255. v := m.plan_start_time
  26256. if v == nil {
  26257. return
  26258. }
  26259. return *v, true
  26260. }
  26261. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  26262. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26264. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  26265. if !m.op.Is(OpUpdateOne) {
  26266. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  26267. }
  26268. if m.id == nil || m.oldValue == nil {
  26269. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  26270. }
  26271. oldValue, err := m.oldValue(ctx)
  26272. if err != nil {
  26273. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  26274. }
  26275. return oldValue.PlanStartTime, nil
  26276. }
  26277. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  26278. func (m *SopTaskMutation) ClearPlanStartTime() {
  26279. m.plan_start_time = nil
  26280. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  26281. }
  26282. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  26283. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  26284. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  26285. return ok
  26286. }
  26287. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  26288. func (m *SopTaskMutation) ResetPlanStartTime() {
  26289. m.plan_start_time = nil
  26290. delete(m.clearedFields, soptask.FieldPlanStartTime)
  26291. }
  26292. // SetPlanEndTime sets the "plan_end_time" field.
  26293. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  26294. m.plan_end_time = &t
  26295. }
  26296. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  26297. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  26298. v := m.plan_end_time
  26299. if v == nil {
  26300. return
  26301. }
  26302. return *v, true
  26303. }
  26304. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  26305. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26307. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  26308. if !m.op.Is(OpUpdateOne) {
  26309. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  26310. }
  26311. if m.id == nil || m.oldValue == nil {
  26312. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  26313. }
  26314. oldValue, err := m.oldValue(ctx)
  26315. if err != nil {
  26316. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  26317. }
  26318. return oldValue.PlanEndTime, nil
  26319. }
  26320. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  26321. func (m *SopTaskMutation) ClearPlanEndTime() {
  26322. m.plan_end_time = nil
  26323. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  26324. }
  26325. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  26326. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  26327. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  26328. return ok
  26329. }
  26330. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  26331. func (m *SopTaskMutation) ResetPlanEndTime() {
  26332. m.plan_end_time = nil
  26333. delete(m.clearedFields, soptask.FieldPlanEndTime)
  26334. }
  26335. // SetCreatorID sets the "creator_id" field.
  26336. func (m *SopTaskMutation) SetCreatorID(s string) {
  26337. m.creator_id = &s
  26338. }
  26339. // CreatorID returns the value of the "creator_id" field in the mutation.
  26340. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  26341. v := m.creator_id
  26342. if v == nil {
  26343. return
  26344. }
  26345. return *v, true
  26346. }
  26347. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  26348. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26350. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  26351. if !m.op.Is(OpUpdateOne) {
  26352. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  26353. }
  26354. if m.id == nil || m.oldValue == nil {
  26355. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  26356. }
  26357. oldValue, err := m.oldValue(ctx)
  26358. if err != nil {
  26359. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  26360. }
  26361. return oldValue.CreatorID, nil
  26362. }
  26363. // ClearCreatorID clears the value of the "creator_id" field.
  26364. func (m *SopTaskMutation) ClearCreatorID() {
  26365. m.creator_id = nil
  26366. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  26367. }
  26368. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  26369. func (m *SopTaskMutation) CreatorIDCleared() bool {
  26370. _, ok := m.clearedFields[soptask.FieldCreatorID]
  26371. return ok
  26372. }
  26373. // ResetCreatorID resets all changes to the "creator_id" field.
  26374. func (m *SopTaskMutation) ResetCreatorID() {
  26375. m.creator_id = nil
  26376. delete(m.clearedFields, soptask.FieldCreatorID)
  26377. }
  26378. // SetOrganizationID sets the "organization_id" field.
  26379. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  26380. m.organization_id = &u
  26381. m.addorganization_id = nil
  26382. }
  26383. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26384. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  26385. v := m.organization_id
  26386. if v == nil {
  26387. return
  26388. }
  26389. return *v, true
  26390. }
  26391. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  26392. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26394. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26395. if !m.op.Is(OpUpdateOne) {
  26396. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26397. }
  26398. if m.id == nil || m.oldValue == nil {
  26399. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26400. }
  26401. oldValue, err := m.oldValue(ctx)
  26402. if err != nil {
  26403. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26404. }
  26405. return oldValue.OrganizationID, nil
  26406. }
  26407. // AddOrganizationID adds u to the "organization_id" field.
  26408. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  26409. if m.addorganization_id != nil {
  26410. *m.addorganization_id += u
  26411. } else {
  26412. m.addorganization_id = &u
  26413. }
  26414. }
  26415. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26416. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  26417. v := m.addorganization_id
  26418. if v == nil {
  26419. return
  26420. }
  26421. return *v, true
  26422. }
  26423. // ClearOrganizationID clears the value of the "organization_id" field.
  26424. func (m *SopTaskMutation) ClearOrganizationID() {
  26425. m.organization_id = nil
  26426. m.addorganization_id = nil
  26427. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  26428. }
  26429. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  26430. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  26431. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  26432. return ok
  26433. }
  26434. // ResetOrganizationID resets all changes to the "organization_id" field.
  26435. func (m *SopTaskMutation) ResetOrganizationID() {
  26436. m.organization_id = nil
  26437. m.addorganization_id = nil
  26438. delete(m.clearedFields, soptask.FieldOrganizationID)
  26439. }
  26440. // SetToken sets the "token" field.
  26441. func (m *SopTaskMutation) SetToken(s []string) {
  26442. m.token = &s
  26443. m.appendtoken = nil
  26444. }
  26445. // Token returns the value of the "token" field in the mutation.
  26446. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  26447. v := m.token
  26448. if v == nil {
  26449. return
  26450. }
  26451. return *v, true
  26452. }
  26453. // OldToken returns the old "token" field's value of the SopTask entity.
  26454. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26456. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  26457. if !m.op.Is(OpUpdateOne) {
  26458. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26459. }
  26460. if m.id == nil || m.oldValue == nil {
  26461. return v, errors.New("OldToken requires an ID field in the mutation")
  26462. }
  26463. oldValue, err := m.oldValue(ctx)
  26464. if err != nil {
  26465. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26466. }
  26467. return oldValue.Token, nil
  26468. }
  26469. // AppendToken adds s to the "token" field.
  26470. func (m *SopTaskMutation) AppendToken(s []string) {
  26471. m.appendtoken = append(m.appendtoken, s...)
  26472. }
  26473. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  26474. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  26475. if len(m.appendtoken) == 0 {
  26476. return nil, false
  26477. }
  26478. return m.appendtoken, true
  26479. }
  26480. // ClearToken clears the value of the "token" field.
  26481. func (m *SopTaskMutation) ClearToken() {
  26482. m.token = nil
  26483. m.appendtoken = nil
  26484. m.clearedFields[soptask.FieldToken] = struct{}{}
  26485. }
  26486. // TokenCleared returns if the "token" field was cleared in this mutation.
  26487. func (m *SopTaskMutation) TokenCleared() bool {
  26488. _, ok := m.clearedFields[soptask.FieldToken]
  26489. return ok
  26490. }
  26491. // ResetToken resets all changes to the "token" field.
  26492. func (m *SopTaskMutation) ResetToken() {
  26493. m.token = nil
  26494. m.appendtoken = nil
  26495. delete(m.clearedFields, soptask.FieldToken)
  26496. }
  26497. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  26498. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  26499. if m.task_stages == nil {
  26500. m.task_stages = make(map[uint64]struct{})
  26501. }
  26502. for i := range ids {
  26503. m.task_stages[ids[i]] = struct{}{}
  26504. }
  26505. }
  26506. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  26507. func (m *SopTaskMutation) ClearTaskStages() {
  26508. m.clearedtask_stages = true
  26509. }
  26510. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  26511. func (m *SopTaskMutation) TaskStagesCleared() bool {
  26512. return m.clearedtask_stages
  26513. }
  26514. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  26515. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  26516. if m.removedtask_stages == nil {
  26517. m.removedtask_stages = make(map[uint64]struct{})
  26518. }
  26519. for i := range ids {
  26520. delete(m.task_stages, ids[i])
  26521. m.removedtask_stages[ids[i]] = struct{}{}
  26522. }
  26523. }
  26524. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  26525. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  26526. for id := range m.removedtask_stages {
  26527. ids = append(ids, id)
  26528. }
  26529. return
  26530. }
  26531. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  26532. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  26533. for id := range m.task_stages {
  26534. ids = append(ids, id)
  26535. }
  26536. return
  26537. }
  26538. // ResetTaskStages resets all changes to the "task_stages" edge.
  26539. func (m *SopTaskMutation) ResetTaskStages() {
  26540. m.task_stages = nil
  26541. m.clearedtask_stages = false
  26542. m.removedtask_stages = nil
  26543. }
  26544. // Where appends a list predicates to the SopTaskMutation builder.
  26545. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  26546. m.predicates = append(m.predicates, ps...)
  26547. }
  26548. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  26549. // users can use type-assertion to append predicates that do not depend on any generated package.
  26550. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  26551. p := make([]predicate.SopTask, len(ps))
  26552. for i := range ps {
  26553. p[i] = ps[i]
  26554. }
  26555. m.Where(p...)
  26556. }
  26557. // Op returns the operation name.
  26558. func (m *SopTaskMutation) Op() Op {
  26559. return m.op
  26560. }
  26561. // SetOp allows setting the mutation operation.
  26562. func (m *SopTaskMutation) SetOp(op Op) {
  26563. m.op = op
  26564. }
  26565. // Type returns the node type of this mutation (SopTask).
  26566. func (m *SopTaskMutation) Type() string {
  26567. return m.typ
  26568. }
  26569. // Fields returns all fields that were changed during this mutation. Note that in
  26570. // order to get all numeric fields that were incremented/decremented, call
  26571. // AddedFields().
  26572. func (m *SopTaskMutation) Fields() []string {
  26573. fields := make([]string, 0, 12)
  26574. if m.created_at != nil {
  26575. fields = append(fields, soptask.FieldCreatedAt)
  26576. }
  26577. if m.updated_at != nil {
  26578. fields = append(fields, soptask.FieldUpdatedAt)
  26579. }
  26580. if m.status != nil {
  26581. fields = append(fields, soptask.FieldStatus)
  26582. }
  26583. if m.deleted_at != nil {
  26584. fields = append(fields, soptask.FieldDeletedAt)
  26585. }
  26586. if m.name != nil {
  26587. fields = append(fields, soptask.FieldName)
  26588. }
  26589. if m.bot_wxid_list != nil {
  26590. fields = append(fields, soptask.FieldBotWxidList)
  26591. }
  26592. if m._type != nil {
  26593. fields = append(fields, soptask.FieldType)
  26594. }
  26595. if m.plan_start_time != nil {
  26596. fields = append(fields, soptask.FieldPlanStartTime)
  26597. }
  26598. if m.plan_end_time != nil {
  26599. fields = append(fields, soptask.FieldPlanEndTime)
  26600. }
  26601. if m.creator_id != nil {
  26602. fields = append(fields, soptask.FieldCreatorID)
  26603. }
  26604. if m.organization_id != nil {
  26605. fields = append(fields, soptask.FieldOrganizationID)
  26606. }
  26607. if m.token != nil {
  26608. fields = append(fields, soptask.FieldToken)
  26609. }
  26610. return fields
  26611. }
  26612. // Field returns the value of a field with the given name. The second boolean
  26613. // return value indicates that this field was not set, or was not defined in the
  26614. // schema.
  26615. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  26616. switch name {
  26617. case soptask.FieldCreatedAt:
  26618. return m.CreatedAt()
  26619. case soptask.FieldUpdatedAt:
  26620. return m.UpdatedAt()
  26621. case soptask.FieldStatus:
  26622. return m.Status()
  26623. case soptask.FieldDeletedAt:
  26624. return m.DeletedAt()
  26625. case soptask.FieldName:
  26626. return m.Name()
  26627. case soptask.FieldBotWxidList:
  26628. return m.BotWxidList()
  26629. case soptask.FieldType:
  26630. return m.GetType()
  26631. case soptask.FieldPlanStartTime:
  26632. return m.PlanStartTime()
  26633. case soptask.FieldPlanEndTime:
  26634. return m.PlanEndTime()
  26635. case soptask.FieldCreatorID:
  26636. return m.CreatorID()
  26637. case soptask.FieldOrganizationID:
  26638. return m.OrganizationID()
  26639. case soptask.FieldToken:
  26640. return m.Token()
  26641. }
  26642. return nil, false
  26643. }
  26644. // OldField returns the old value of the field from the database. An error is
  26645. // returned if the mutation operation is not UpdateOne, or the query to the
  26646. // database failed.
  26647. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26648. switch name {
  26649. case soptask.FieldCreatedAt:
  26650. return m.OldCreatedAt(ctx)
  26651. case soptask.FieldUpdatedAt:
  26652. return m.OldUpdatedAt(ctx)
  26653. case soptask.FieldStatus:
  26654. return m.OldStatus(ctx)
  26655. case soptask.FieldDeletedAt:
  26656. return m.OldDeletedAt(ctx)
  26657. case soptask.FieldName:
  26658. return m.OldName(ctx)
  26659. case soptask.FieldBotWxidList:
  26660. return m.OldBotWxidList(ctx)
  26661. case soptask.FieldType:
  26662. return m.OldType(ctx)
  26663. case soptask.FieldPlanStartTime:
  26664. return m.OldPlanStartTime(ctx)
  26665. case soptask.FieldPlanEndTime:
  26666. return m.OldPlanEndTime(ctx)
  26667. case soptask.FieldCreatorID:
  26668. return m.OldCreatorID(ctx)
  26669. case soptask.FieldOrganizationID:
  26670. return m.OldOrganizationID(ctx)
  26671. case soptask.FieldToken:
  26672. return m.OldToken(ctx)
  26673. }
  26674. return nil, fmt.Errorf("unknown SopTask field %s", name)
  26675. }
  26676. // SetField sets the value of a field with the given name. It returns an error if
  26677. // the field is not defined in the schema, or if the type mismatched the field
  26678. // type.
  26679. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  26680. switch name {
  26681. case soptask.FieldCreatedAt:
  26682. v, ok := value.(time.Time)
  26683. if !ok {
  26684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26685. }
  26686. m.SetCreatedAt(v)
  26687. return nil
  26688. case soptask.FieldUpdatedAt:
  26689. v, ok := value.(time.Time)
  26690. if !ok {
  26691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26692. }
  26693. m.SetUpdatedAt(v)
  26694. return nil
  26695. case soptask.FieldStatus:
  26696. v, ok := value.(uint8)
  26697. if !ok {
  26698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26699. }
  26700. m.SetStatus(v)
  26701. return nil
  26702. case soptask.FieldDeletedAt:
  26703. v, ok := value.(time.Time)
  26704. if !ok {
  26705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26706. }
  26707. m.SetDeletedAt(v)
  26708. return nil
  26709. case soptask.FieldName:
  26710. v, ok := value.(string)
  26711. if !ok {
  26712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26713. }
  26714. m.SetName(v)
  26715. return nil
  26716. case soptask.FieldBotWxidList:
  26717. v, ok := value.([]string)
  26718. if !ok {
  26719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26720. }
  26721. m.SetBotWxidList(v)
  26722. return nil
  26723. case soptask.FieldType:
  26724. v, ok := value.(int)
  26725. if !ok {
  26726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26727. }
  26728. m.SetType(v)
  26729. return nil
  26730. case soptask.FieldPlanStartTime:
  26731. v, ok := value.(time.Time)
  26732. if !ok {
  26733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26734. }
  26735. m.SetPlanStartTime(v)
  26736. return nil
  26737. case soptask.FieldPlanEndTime:
  26738. v, ok := value.(time.Time)
  26739. if !ok {
  26740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26741. }
  26742. m.SetPlanEndTime(v)
  26743. return nil
  26744. case soptask.FieldCreatorID:
  26745. v, ok := value.(string)
  26746. if !ok {
  26747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26748. }
  26749. m.SetCreatorID(v)
  26750. return nil
  26751. case soptask.FieldOrganizationID:
  26752. v, ok := value.(uint64)
  26753. if !ok {
  26754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26755. }
  26756. m.SetOrganizationID(v)
  26757. return nil
  26758. case soptask.FieldToken:
  26759. v, ok := value.([]string)
  26760. if !ok {
  26761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26762. }
  26763. m.SetToken(v)
  26764. return nil
  26765. }
  26766. return fmt.Errorf("unknown SopTask field %s", name)
  26767. }
  26768. // AddedFields returns all numeric fields that were incremented/decremented during
  26769. // this mutation.
  26770. func (m *SopTaskMutation) AddedFields() []string {
  26771. var fields []string
  26772. if m.addstatus != nil {
  26773. fields = append(fields, soptask.FieldStatus)
  26774. }
  26775. if m.add_type != nil {
  26776. fields = append(fields, soptask.FieldType)
  26777. }
  26778. if m.addorganization_id != nil {
  26779. fields = append(fields, soptask.FieldOrganizationID)
  26780. }
  26781. return fields
  26782. }
  26783. // AddedField returns the numeric value that was incremented/decremented on a field
  26784. // with the given name. The second boolean return value indicates that this field
  26785. // was not set, or was not defined in the schema.
  26786. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  26787. switch name {
  26788. case soptask.FieldStatus:
  26789. return m.AddedStatus()
  26790. case soptask.FieldType:
  26791. return m.AddedType()
  26792. case soptask.FieldOrganizationID:
  26793. return m.AddedOrganizationID()
  26794. }
  26795. return nil, false
  26796. }
  26797. // AddField adds the value to the field with the given name. It returns an error if
  26798. // the field is not defined in the schema, or if the type mismatched the field
  26799. // type.
  26800. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  26801. switch name {
  26802. case soptask.FieldStatus:
  26803. v, ok := value.(int8)
  26804. if !ok {
  26805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26806. }
  26807. m.AddStatus(v)
  26808. return nil
  26809. case soptask.FieldType:
  26810. v, ok := value.(int)
  26811. if !ok {
  26812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26813. }
  26814. m.AddType(v)
  26815. return nil
  26816. case soptask.FieldOrganizationID:
  26817. v, ok := value.(int64)
  26818. if !ok {
  26819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26820. }
  26821. m.AddOrganizationID(v)
  26822. return nil
  26823. }
  26824. return fmt.Errorf("unknown SopTask numeric field %s", name)
  26825. }
  26826. // ClearedFields returns all nullable fields that were cleared during this
  26827. // mutation.
  26828. func (m *SopTaskMutation) ClearedFields() []string {
  26829. var fields []string
  26830. if m.FieldCleared(soptask.FieldStatus) {
  26831. fields = append(fields, soptask.FieldStatus)
  26832. }
  26833. if m.FieldCleared(soptask.FieldDeletedAt) {
  26834. fields = append(fields, soptask.FieldDeletedAt)
  26835. }
  26836. if m.FieldCleared(soptask.FieldBotWxidList) {
  26837. fields = append(fields, soptask.FieldBotWxidList)
  26838. }
  26839. if m.FieldCleared(soptask.FieldPlanStartTime) {
  26840. fields = append(fields, soptask.FieldPlanStartTime)
  26841. }
  26842. if m.FieldCleared(soptask.FieldPlanEndTime) {
  26843. fields = append(fields, soptask.FieldPlanEndTime)
  26844. }
  26845. if m.FieldCleared(soptask.FieldCreatorID) {
  26846. fields = append(fields, soptask.FieldCreatorID)
  26847. }
  26848. if m.FieldCleared(soptask.FieldOrganizationID) {
  26849. fields = append(fields, soptask.FieldOrganizationID)
  26850. }
  26851. if m.FieldCleared(soptask.FieldToken) {
  26852. fields = append(fields, soptask.FieldToken)
  26853. }
  26854. return fields
  26855. }
  26856. // FieldCleared returns a boolean indicating if a field with the given name was
  26857. // cleared in this mutation.
  26858. func (m *SopTaskMutation) FieldCleared(name string) bool {
  26859. _, ok := m.clearedFields[name]
  26860. return ok
  26861. }
  26862. // ClearField clears the value of the field with the given name. It returns an
  26863. // error if the field is not defined in the schema.
  26864. func (m *SopTaskMutation) ClearField(name string) error {
  26865. switch name {
  26866. case soptask.FieldStatus:
  26867. m.ClearStatus()
  26868. return nil
  26869. case soptask.FieldDeletedAt:
  26870. m.ClearDeletedAt()
  26871. return nil
  26872. case soptask.FieldBotWxidList:
  26873. m.ClearBotWxidList()
  26874. return nil
  26875. case soptask.FieldPlanStartTime:
  26876. m.ClearPlanStartTime()
  26877. return nil
  26878. case soptask.FieldPlanEndTime:
  26879. m.ClearPlanEndTime()
  26880. return nil
  26881. case soptask.FieldCreatorID:
  26882. m.ClearCreatorID()
  26883. return nil
  26884. case soptask.FieldOrganizationID:
  26885. m.ClearOrganizationID()
  26886. return nil
  26887. case soptask.FieldToken:
  26888. m.ClearToken()
  26889. return nil
  26890. }
  26891. return fmt.Errorf("unknown SopTask nullable field %s", name)
  26892. }
  26893. // ResetField resets all changes in the mutation for the field with the given name.
  26894. // It returns an error if the field is not defined in the schema.
  26895. func (m *SopTaskMutation) ResetField(name string) error {
  26896. switch name {
  26897. case soptask.FieldCreatedAt:
  26898. m.ResetCreatedAt()
  26899. return nil
  26900. case soptask.FieldUpdatedAt:
  26901. m.ResetUpdatedAt()
  26902. return nil
  26903. case soptask.FieldStatus:
  26904. m.ResetStatus()
  26905. return nil
  26906. case soptask.FieldDeletedAt:
  26907. m.ResetDeletedAt()
  26908. return nil
  26909. case soptask.FieldName:
  26910. m.ResetName()
  26911. return nil
  26912. case soptask.FieldBotWxidList:
  26913. m.ResetBotWxidList()
  26914. return nil
  26915. case soptask.FieldType:
  26916. m.ResetType()
  26917. return nil
  26918. case soptask.FieldPlanStartTime:
  26919. m.ResetPlanStartTime()
  26920. return nil
  26921. case soptask.FieldPlanEndTime:
  26922. m.ResetPlanEndTime()
  26923. return nil
  26924. case soptask.FieldCreatorID:
  26925. m.ResetCreatorID()
  26926. return nil
  26927. case soptask.FieldOrganizationID:
  26928. m.ResetOrganizationID()
  26929. return nil
  26930. case soptask.FieldToken:
  26931. m.ResetToken()
  26932. return nil
  26933. }
  26934. return fmt.Errorf("unknown SopTask field %s", name)
  26935. }
  26936. // AddedEdges returns all edge names that were set/added in this mutation.
  26937. func (m *SopTaskMutation) AddedEdges() []string {
  26938. edges := make([]string, 0, 1)
  26939. if m.task_stages != nil {
  26940. edges = append(edges, soptask.EdgeTaskStages)
  26941. }
  26942. return edges
  26943. }
  26944. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26945. // name in this mutation.
  26946. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  26947. switch name {
  26948. case soptask.EdgeTaskStages:
  26949. ids := make([]ent.Value, 0, len(m.task_stages))
  26950. for id := range m.task_stages {
  26951. ids = append(ids, id)
  26952. }
  26953. return ids
  26954. }
  26955. return nil
  26956. }
  26957. // RemovedEdges returns all edge names that were removed in this mutation.
  26958. func (m *SopTaskMutation) RemovedEdges() []string {
  26959. edges := make([]string, 0, 1)
  26960. if m.removedtask_stages != nil {
  26961. edges = append(edges, soptask.EdgeTaskStages)
  26962. }
  26963. return edges
  26964. }
  26965. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26966. // the given name in this mutation.
  26967. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  26968. switch name {
  26969. case soptask.EdgeTaskStages:
  26970. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  26971. for id := range m.removedtask_stages {
  26972. ids = append(ids, id)
  26973. }
  26974. return ids
  26975. }
  26976. return nil
  26977. }
  26978. // ClearedEdges returns all edge names that were cleared in this mutation.
  26979. func (m *SopTaskMutation) ClearedEdges() []string {
  26980. edges := make([]string, 0, 1)
  26981. if m.clearedtask_stages {
  26982. edges = append(edges, soptask.EdgeTaskStages)
  26983. }
  26984. return edges
  26985. }
  26986. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26987. // was cleared in this mutation.
  26988. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  26989. switch name {
  26990. case soptask.EdgeTaskStages:
  26991. return m.clearedtask_stages
  26992. }
  26993. return false
  26994. }
  26995. // ClearEdge clears the value of the edge with the given name. It returns an error
  26996. // if that edge is not defined in the schema.
  26997. func (m *SopTaskMutation) ClearEdge(name string) error {
  26998. switch name {
  26999. }
  27000. return fmt.Errorf("unknown SopTask unique edge %s", name)
  27001. }
  27002. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27003. // It returns an error if the edge is not defined in the schema.
  27004. func (m *SopTaskMutation) ResetEdge(name string) error {
  27005. switch name {
  27006. case soptask.EdgeTaskStages:
  27007. m.ResetTaskStages()
  27008. return nil
  27009. }
  27010. return fmt.Errorf("unknown SopTask edge %s", name)
  27011. }
  27012. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  27013. type TokenMutation struct {
  27014. config
  27015. op Op
  27016. typ string
  27017. id *uint64
  27018. created_at *time.Time
  27019. updated_at *time.Time
  27020. deleted_at *time.Time
  27021. expire_at *time.Time
  27022. token *string
  27023. mac *string
  27024. organization_id *uint64
  27025. addorganization_id *int64
  27026. custom_agent_base *string
  27027. custom_agent_key *string
  27028. openai_base *string
  27029. openai_key *string
  27030. clearedFields map[string]struct{}
  27031. agent *uint64
  27032. clearedagent bool
  27033. done bool
  27034. oldValue func(context.Context) (*Token, error)
  27035. predicates []predicate.Token
  27036. }
  27037. var _ ent.Mutation = (*TokenMutation)(nil)
  27038. // tokenOption allows management of the mutation configuration using functional options.
  27039. type tokenOption func(*TokenMutation)
  27040. // newTokenMutation creates new mutation for the Token entity.
  27041. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  27042. m := &TokenMutation{
  27043. config: c,
  27044. op: op,
  27045. typ: TypeToken,
  27046. clearedFields: make(map[string]struct{}),
  27047. }
  27048. for _, opt := range opts {
  27049. opt(m)
  27050. }
  27051. return m
  27052. }
  27053. // withTokenID sets the ID field of the mutation.
  27054. func withTokenID(id uint64) tokenOption {
  27055. return func(m *TokenMutation) {
  27056. var (
  27057. err error
  27058. once sync.Once
  27059. value *Token
  27060. )
  27061. m.oldValue = func(ctx context.Context) (*Token, error) {
  27062. once.Do(func() {
  27063. if m.done {
  27064. err = errors.New("querying old values post mutation is not allowed")
  27065. } else {
  27066. value, err = m.Client().Token.Get(ctx, id)
  27067. }
  27068. })
  27069. return value, err
  27070. }
  27071. m.id = &id
  27072. }
  27073. }
  27074. // withToken sets the old Token of the mutation.
  27075. func withToken(node *Token) tokenOption {
  27076. return func(m *TokenMutation) {
  27077. m.oldValue = func(context.Context) (*Token, error) {
  27078. return node, nil
  27079. }
  27080. m.id = &node.ID
  27081. }
  27082. }
  27083. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27084. // executed in a transaction (ent.Tx), a transactional client is returned.
  27085. func (m TokenMutation) Client() *Client {
  27086. client := &Client{config: m.config}
  27087. client.init()
  27088. return client
  27089. }
  27090. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27091. // it returns an error otherwise.
  27092. func (m TokenMutation) Tx() (*Tx, error) {
  27093. if _, ok := m.driver.(*txDriver); !ok {
  27094. return nil, errors.New("ent: mutation is not running in a transaction")
  27095. }
  27096. tx := &Tx{config: m.config}
  27097. tx.init()
  27098. return tx, nil
  27099. }
  27100. // SetID sets the value of the id field. Note that this
  27101. // operation is only accepted on creation of Token entities.
  27102. func (m *TokenMutation) SetID(id uint64) {
  27103. m.id = &id
  27104. }
  27105. // ID returns the ID value in the mutation. Note that the ID is only available
  27106. // if it was provided to the builder or after it was returned from the database.
  27107. func (m *TokenMutation) ID() (id uint64, exists bool) {
  27108. if m.id == nil {
  27109. return
  27110. }
  27111. return *m.id, true
  27112. }
  27113. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27114. // That means, if the mutation is applied within a transaction with an isolation level such
  27115. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27116. // or updated by the mutation.
  27117. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  27118. switch {
  27119. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27120. id, exists := m.ID()
  27121. if exists {
  27122. return []uint64{id}, nil
  27123. }
  27124. fallthrough
  27125. case m.op.Is(OpUpdate | OpDelete):
  27126. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  27127. default:
  27128. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27129. }
  27130. }
  27131. // SetCreatedAt sets the "created_at" field.
  27132. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  27133. m.created_at = &t
  27134. }
  27135. // CreatedAt returns the value of the "created_at" field in the mutation.
  27136. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  27137. v := m.created_at
  27138. if v == nil {
  27139. return
  27140. }
  27141. return *v, true
  27142. }
  27143. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  27144. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27146. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27147. if !m.op.Is(OpUpdateOne) {
  27148. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27149. }
  27150. if m.id == nil || m.oldValue == nil {
  27151. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27152. }
  27153. oldValue, err := m.oldValue(ctx)
  27154. if err != nil {
  27155. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27156. }
  27157. return oldValue.CreatedAt, nil
  27158. }
  27159. // ResetCreatedAt resets all changes to the "created_at" field.
  27160. func (m *TokenMutation) ResetCreatedAt() {
  27161. m.created_at = nil
  27162. }
  27163. // SetUpdatedAt sets the "updated_at" field.
  27164. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  27165. m.updated_at = &t
  27166. }
  27167. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27168. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  27169. v := m.updated_at
  27170. if v == nil {
  27171. return
  27172. }
  27173. return *v, true
  27174. }
  27175. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  27176. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27178. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27179. if !m.op.Is(OpUpdateOne) {
  27180. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27181. }
  27182. if m.id == nil || m.oldValue == nil {
  27183. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27184. }
  27185. oldValue, err := m.oldValue(ctx)
  27186. if err != nil {
  27187. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27188. }
  27189. return oldValue.UpdatedAt, nil
  27190. }
  27191. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27192. func (m *TokenMutation) ResetUpdatedAt() {
  27193. m.updated_at = nil
  27194. }
  27195. // SetDeletedAt sets the "deleted_at" field.
  27196. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  27197. m.deleted_at = &t
  27198. }
  27199. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27200. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  27201. v := m.deleted_at
  27202. if v == nil {
  27203. return
  27204. }
  27205. return *v, true
  27206. }
  27207. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  27208. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27210. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27211. if !m.op.Is(OpUpdateOne) {
  27212. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27213. }
  27214. if m.id == nil || m.oldValue == nil {
  27215. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27216. }
  27217. oldValue, err := m.oldValue(ctx)
  27218. if err != nil {
  27219. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27220. }
  27221. return oldValue.DeletedAt, nil
  27222. }
  27223. // ClearDeletedAt clears the value of the "deleted_at" field.
  27224. func (m *TokenMutation) ClearDeletedAt() {
  27225. m.deleted_at = nil
  27226. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  27227. }
  27228. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27229. func (m *TokenMutation) DeletedAtCleared() bool {
  27230. _, ok := m.clearedFields[token.FieldDeletedAt]
  27231. return ok
  27232. }
  27233. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27234. func (m *TokenMutation) ResetDeletedAt() {
  27235. m.deleted_at = nil
  27236. delete(m.clearedFields, token.FieldDeletedAt)
  27237. }
  27238. // SetExpireAt sets the "expire_at" field.
  27239. func (m *TokenMutation) SetExpireAt(t time.Time) {
  27240. m.expire_at = &t
  27241. }
  27242. // ExpireAt returns the value of the "expire_at" field in the mutation.
  27243. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  27244. v := m.expire_at
  27245. if v == nil {
  27246. return
  27247. }
  27248. return *v, true
  27249. }
  27250. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  27251. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27253. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  27254. if !m.op.Is(OpUpdateOne) {
  27255. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  27256. }
  27257. if m.id == nil || m.oldValue == nil {
  27258. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  27259. }
  27260. oldValue, err := m.oldValue(ctx)
  27261. if err != nil {
  27262. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  27263. }
  27264. return oldValue.ExpireAt, nil
  27265. }
  27266. // ClearExpireAt clears the value of the "expire_at" field.
  27267. func (m *TokenMutation) ClearExpireAt() {
  27268. m.expire_at = nil
  27269. m.clearedFields[token.FieldExpireAt] = struct{}{}
  27270. }
  27271. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  27272. func (m *TokenMutation) ExpireAtCleared() bool {
  27273. _, ok := m.clearedFields[token.FieldExpireAt]
  27274. return ok
  27275. }
  27276. // ResetExpireAt resets all changes to the "expire_at" field.
  27277. func (m *TokenMutation) ResetExpireAt() {
  27278. m.expire_at = nil
  27279. delete(m.clearedFields, token.FieldExpireAt)
  27280. }
  27281. // SetToken sets the "token" field.
  27282. func (m *TokenMutation) SetToken(s string) {
  27283. m.token = &s
  27284. }
  27285. // Token returns the value of the "token" field in the mutation.
  27286. func (m *TokenMutation) Token() (r string, exists bool) {
  27287. v := m.token
  27288. if v == nil {
  27289. return
  27290. }
  27291. return *v, true
  27292. }
  27293. // OldToken returns the old "token" field's value of the Token entity.
  27294. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27296. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  27297. if !m.op.Is(OpUpdateOne) {
  27298. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  27299. }
  27300. if m.id == nil || m.oldValue == nil {
  27301. return v, errors.New("OldToken requires an ID field in the mutation")
  27302. }
  27303. oldValue, err := m.oldValue(ctx)
  27304. if err != nil {
  27305. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  27306. }
  27307. return oldValue.Token, nil
  27308. }
  27309. // ClearToken clears the value of the "token" field.
  27310. func (m *TokenMutation) ClearToken() {
  27311. m.token = nil
  27312. m.clearedFields[token.FieldToken] = struct{}{}
  27313. }
  27314. // TokenCleared returns if the "token" field was cleared in this mutation.
  27315. func (m *TokenMutation) TokenCleared() bool {
  27316. _, ok := m.clearedFields[token.FieldToken]
  27317. return ok
  27318. }
  27319. // ResetToken resets all changes to the "token" field.
  27320. func (m *TokenMutation) ResetToken() {
  27321. m.token = nil
  27322. delete(m.clearedFields, token.FieldToken)
  27323. }
  27324. // SetMAC sets the "mac" field.
  27325. func (m *TokenMutation) SetMAC(s string) {
  27326. m.mac = &s
  27327. }
  27328. // MAC returns the value of the "mac" field in the mutation.
  27329. func (m *TokenMutation) MAC() (r string, exists bool) {
  27330. v := m.mac
  27331. if v == nil {
  27332. return
  27333. }
  27334. return *v, true
  27335. }
  27336. // OldMAC returns the old "mac" field's value of the Token entity.
  27337. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27339. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  27340. if !m.op.Is(OpUpdateOne) {
  27341. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  27342. }
  27343. if m.id == nil || m.oldValue == nil {
  27344. return v, errors.New("OldMAC requires an ID field in the mutation")
  27345. }
  27346. oldValue, err := m.oldValue(ctx)
  27347. if err != nil {
  27348. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  27349. }
  27350. return oldValue.MAC, nil
  27351. }
  27352. // ClearMAC clears the value of the "mac" field.
  27353. func (m *TokenMutation) ClearMAC() {
  27354. m.mac = nil
  27355. m.clearedFields[token.FieldMAC] = struct{}{}
  27356. }
  27357. // MACCleared returns if the "mac" field was cleared in this mutation.
  27358. func (m *TokenMutation) MACCleared() bool {
  27359. _, ok := m.clearedFields[token.FieldMAC]
  27360. return ok
  27361. }
  27362. // ResetMAC resets all changes to the "mac" field.
  27363. func (m *TokenMutation) ResetMAC() {
  27364. m.mac = nil
  27365. delete(m.clearedFields, token.FieldMAC)
  27366. }
  27367. // SetOrganizationID sets the "organization_id" field.
  27368. func (m *TokenMutation) SetOrganizationID(u uint64) {
  27369. m.organization_id = &u
  27370. m.addorganization_id = nil
  27371. }
  27372. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27373. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  27374. v := m.organization_id
  27375. if v == nil {
  27376. return
  27377. }
  27378. return *v, true
  27379. }
  27380. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  27381. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27383. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27384. if !m.op.Is(OpUpdateOne) {
  27385. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27386. }
  27387. if m.id == nil || m.oldValue == nil {
  27388. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27389. }
  27390. oldValue, err := m.oldValue(ctx)
  27391. if err != nil {
  27392. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27393. }
  27394. return oldValue.OrganizationID, nil
  27395. }
  27396. // AddOrganizationID adds u to the "organization_id" field.
  27397. func (m *TokenMutation) AddOrganizationID(u int64) {
  27398. if m.addorganization_id != nil {
  27399. *m.addorganization_id += u
  27400. } else {
  27401. m.addorganization_id = &u
  27402. }
  27403. }
  27404. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27405. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  27406. v := m.addorganization_id
  27407. if v == nil {
  27408. return
  27409. }
  27410. return *v, true
  27411. }
  27412. // ResetOrganizationID resets all changes to the "organization_id" field.
  27413. func (m *TokenMutation) ResetOrganizationID() {
  27414. m.organization_id = nil
  27415. m.addorganization_id = nil
  27416. }
  27417. // SetAgentID sets the "agent_id" field.
  27418. func (m *TokenMutation) SetAgentID(u uint64) {
  27419. m.agent = &u
  27420. }
  27421. // AgentID returns the value of the "agent_id" field in the mutation.
  27422. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  27423. v := m.agent
  27424. if v == nil {
  27425. return
  27426. }
  27427. return *v, true
  27428. }
  27429. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  27430. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27432. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  27433. if !m.op.Is(OpUpdateOne) {
  27434. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  27435. }
  27436. if m.id == nil || m.oldValue == nil {
  27437. return v, errors.New("OldAgentID requires an ID field in the mutation")
  27438. }
  27439. oldValue, err := m.oldValue(ctx)
  27440. if err != nil {
  27441. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  27442. }
  27443. return oldValue.AgentID, nil
  27444. }
  27445. // ResetAgentID resets all changes to the "agent_id" field.
  27446. func (m *TokenMutation) ResetAgentID() {
  27447. m.agent = nil
  27448. }
  27449. // SetCustomAgentBase sets the "custom_agent_base" field.
  27450. func (m *TokenMutation) SetCustomAgentBase(s string) {
  27451. m.custom_agent_base = &s
  27452. }
  27453. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  27454. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  27455. v := m.custom_agent_base
  27456. if v == nil {
  27457. return
  27458. }
  27459. return *v, true
  27460. }
  27461. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  27462. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27464. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  27465. if !m.op.Is(OpUpdateOne) {
  27466. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  27467. }
  27468. if m.id == nil || m.oldValue == nil {
  27469. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  27470. }
  27471. oldValue, err := m.oldValue(ctx)
  27472. if err != nil {
  27473. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  27474. }
  27475. return oldValue.CustomAgentBase, nil
  27476. }
  27477. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  27478. func (m *TokenMutation) ClearCustomAgentBase() {
  27479. m.custom_agent_base = nil
  27480. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  27481. }
  27482. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  27483. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  27484. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  27485. return ok
  27486. }
  27487. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  27488. func (m *TokenMutation) ResetCustomAgentBase() {
  27489. m.custom_agent_base = nil
  27490. delete(m.clearedFields, token.FieldCustomAgentBase)
  27491. }
  27492. // SetCustomAgentKey sets the "custom_agent_key" field.
  27493. func (m *TokenMutation) SetCustomAgentKey(s string) {
  27494. m.custom_agent_key = &s
  27495. }
  27496. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  27497. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  27498. v := m.custom_agent_key
  27499. if v == nil {
  27500. return
  27501. }
  27502. return *v, true
  27503. }
  27504. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  27505. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27507. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  27508. if !m.op.Is(OpUpdateOne) {
  27509. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  27510. }
  27511. if m.id == nil || m.oldValue == nil {
  27512. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  27513. }
  27514. oldValue, err := m.oldValue(ctx)
  27515. if err != nil {
  27516. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  27517. }
  27518. return oldValue.CustomAgentKey, nil
  27519. }
  27520. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  27521. func (m *TokenMutation) ClearCustomAgentKey() {
  27522. m.custom_agent_key = nil
  27523. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  27524. }
  27525. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  27526. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  27527. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  27528. return ok
  27529. }
  27530. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  27531. func (m *TokenMutation) ResetCustomAgentKey() {
  27532. m.custom_agent_key = nil
  27533. delete(m.clearedFields, token.FieldCustomAgentKey)
  27534. }
  27535. // SetOpenaiBase sets the "openai_base" field.
  27536. func (m *TokenMutation) SetOpenaiBase(s string) {
  27537. m.openai_base = &s
  27538. }
  27539. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  27540. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  27541. v := m.openai_base
  27542. if v == nil {
  27543. return
  27544. }
  27545. return *v, true
  27546. }
  27547. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  27548. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27550. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  27551. if !m.op.Is(OpUpdateOne) {
  27552. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  27553. }
  27554. if m.id == nil || m.oldValue == nil {
  27555. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  27556. }
  27557. oldValue, err := m.oldValue(ctx)
  27558. if err != nil {
  27559. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  27560. }
  27561. return oldValue.OpenaiBase, nil
  27562. }
  27563. // ClearOpenaiBase clears the value of the "openai_base" field.
  27564. func (m *TokenMutation) ClearOpenaiBase() {
  27565. m.openai_base = nil
  27566. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  27567. }
  27568. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  27569. func (m *TokenMutation) OpenaiBaseCleared() bool {
  27570. _, ok := m.clearedFields[token.FieldOpenaiBase]
  27571. return ok
  27572. }
  27573. // ResetOpenaiBase resets all changes to the "openai_base" field.
  27574. func (m *TokenMutation) ResetOpenaiBase() {
  27575. m.openai_base = nil
  27576. delete(m.clearedFields, token.FieldOpenaiBase)
  27577. }
  27578. // SetOpenaiKey sets the "openai_key" field.
  27579. func (m *TokenMutation) SetOpenaiKey(s string) {
  27580. m.openai_key = &s
  27581. }
  27582. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  27583. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  27584. v := m.openai_key
  27585. if v == nil {
  27586. return
  27587. }
  27588. return *v, true
  27589. }
  27590. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  27591. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27593. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  27594. if !m.op.Is(OpUpdateOne) {
  27595. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  27596. }
  27597. if m.id == nil || m.oldValue == nil {
  27598. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  27599. }
  27600. oldValue, err := m.oldValue(ctx)
  27601. if err != nil {
  27602. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  27603. }
  27604. return oldValue.OpenaiKey, nil
  27605. }
  27606. // ClearOpenaiKey clears the value of the "openai_key" field.
  27607. func (m *TokenMutation) ClearOpenaiKey() {
  27608. m.openai_key = nil
  27609. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  27610. }
  27611. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  27612. func (m *TokenMutation) OpenaiKeyCleared() bool {
  27613. _, ok := m.clearedFields[token.FieldOpenaiKey]
  27614. return ok
  27615. }
  27616. // ResetOpenaiKey resets all changes to the "openai_key" field.
  27617. func (m *TokenMutation) ResetOpenaiKey() {
  27618. m.openai_key = nil
  27619. delete(m.clearedFields, token.FieldOpenaiKey)
  27620. }
  27621. // ClearAgent clears the "agent" edge to the Agent entity.
  27622. func (m *TokenMutation) ClearAgent() {
  27623. m.clearedagent = true
  27624. m.clearedFields[token.FieldAgentID] = struct{}{}
  27625. }
  27626. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  27627. func (m *TokenMutation) AgentCleared() bool {
  27628. return m.clearedagent
  27629. }
  27630. // AgentIDs returns the "agent" edge IDs in the mutation.
  27631. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27632. // AgentID instead. It exists only for internal usage by the builders.
  27633. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  27634. if id := m.agent; id != nil {
  27635. ids = append(ids, *id)
  27636. }
  27637. return
  27638. }
  27639. // ResetAgent resets all changes to the "agent" edge.
  27640. func (m *TokenMutation) ResetAgent() {
  27641. m.agent = nil
  27642. m.clearedagent = false
  27643. }
  27644. // Where appends a list predicates to the TokenMutation builder.
  27645. func (m *TokenMutation) Where(ps ...predicate.Token) {
  27646. m.predicates = append(m.predicates, ps...)
  27647. }
  27648. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  27649. // users can use type-assertion to append predicates that do not depend on any generated package.
  27650. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  27651. p := make([]predicate.Token, len(ps))
  27652. for i := range ps {
  27653. p[i] = ps[i]
  27654. }
  27655. m.Where(p...)
  27656. }
  27657. // Op returns the operation name.
  27658. func (m *TokenMutation) Op() Op {
  27659. return m.op
  27660. }
  27661. // SetOp allows setting the mutation operation.
  27662. func (m *TokenMutation) SetOp(op Op) {
  27663. m.op = op
  27664. }
  27665. // Type returns the node type of this mutation (Token).
  27666. func (m *TokenMutation) Type() string {
  27667. return m.typ
  27668. }
  27669. // Fields returns all fields that were changed during this mutation. Note that in
  27670. // order to get all numeric fields that were incremented/decremented, call
  27671. // AddedFields().
  27672. func (m *TokenMutation) Fields() []string {
  27673. fields := make([]string, 0, 12)
  27674. if m.created_at != nil {
  27675. fields = append(fields, token.FieldCreatedAt)
  27676. }
  27677. if m.updated_at != nil {
  27678. fields = append(fields, token.FieldUpdatedAt)
  27679. }
  27680. if m.deleted_at != nil {
  27681. fields = append(fields, token.FieldDeletedAt)
  27682. }
  27683. if m.expire_at != nil {
  27684. fields = append(fields, token.FieldExpireAt)
  27685. }
  27686. if m.token != nil {
  27687. fields = append(fields, token.FieldToken)
  27688. }
  27689. if m.mac != nil {
  27690. fields = append(fields, token.FieldMAC)
  27691. }
  27692. if m.organization_id != nil {
  27693. fields = append(fields, token.FieldOrganizationID)
  27694. }
  27695. if m.agent != nil {
  27696. fields = append(fields, token.FieldAgentID)
  27697. }
  27698. if m.custom_agent_base != nil {
  27699. fields = append(fields, token.FieldCustomAgentBase)
  27700. }
  27701. if m.custom_agent_key != nil {
  27702. fields = append(fields, token.FieldCustomAgentKey)
  27703. }
  27704. if m.openai_base != nil {
  27705. fields = append(fields, token.FieldOpenaiBase)
  27706. }
  27707. if m.openai_key != nil {
  27708. fields = append(fields, token.FieldOpenaiKey)
  27709. }
  27710. return fields
  27711. }
  27712. // Field returns the value of a field with the given name. The second boolean
  27713. // return value indicates that this field was not set, or was not defined in the
  27714. // schema.
  27715. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  27716. switch name {
  27717. case token.FieldCreatedAt:
  27718. return m.CreatedAt()
  27719. case token.FieldUpdatedAt:
  27720. return m.UpdatedAt()
  27721. case token.FieldDeletedAt:
  27722. return m.DeletedAt()
  27723. case token.FieldExpireAt:
  27724. return m.ExpireAt()
  27725. case token.FieldToken:
  27726. return m.Token()
  27727. case token.FieldMAC:
  27728. return m.MAC()
  27729. case token.FieldOrganizationID:
  27730. return m.OrganizationID()
  27731. case token.FieldAgentID:
  27732. return m.AgentID()
  27733. case token.FieldCustomAgentBase:
  27734. return m.CustomAgentBase()
  27735. case token.FieldCustomAgentKey:
  27736. return m.CustomAgentKey()
  27737. case token.FieldOpenaiBase:
  27738. return m.OpenaiBase()
  27739. case token.FieldOpenaiKey:
  27740. return m.OpenaiKey()
  27741. }
  27742. return nil, false
  27743. }
  27744. // OldField returns the old value of the field from the database. An error is
  27745. // returned if the mutation operation is not UpdateOne, or the query to the
  27746. // database failed.
  27747. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27748. switch name {
  27749. case token.FieldCreatedAt:
  27750. return m.OldCreatedAt(ctx)
  27751. case token.FieldUpdatedAt:
  27752. return m.OldUpdatedAt(ctx)
  27753. case token.FieldDeletedAt:
  27754. return m.OldDeletedAt(ctx)
  27755. case token.FieldExpireAt:
  27756. return m.OldExpireAt(ctx)
  27757. case token.FieldToken:
  27758. return m.OldToken(ctx)
  27759. case token.FieldMAC:
  27760. return m.OldMAC(ctx)
  27761. case token.FieldOrganizationID:
  27762. return m.OldOrganizationID(ctx)
  27763. case token.FieldAgentID:
  27764. return m.OldAgentID(ctx)
  27765. case token.FieldCustomAgentBase:
  27766. return m.OldCustomAgentBase(ctx)
  27767. case token.FieldCustomAgentKey:
  27768. return m.OldCustomAgentKey(ctx)
  27769. case token.FieldOpenaiBase:
  27770. return m.OldOpenaiBase(ctx)
  27771. case token.FieldOpenaiKey:
  27772. return m.OldOpenaiKey(ctx)
  27773. }
  27774. return nil, fmt.Errorf("unknown Token field %s", name)
  27775. }
  27776. // SetField sets the value of a field with the given name. It returns an error if
  27777. // the field is not defined in the schema, or if the type mismatched the field
  27778. // type.
  27779. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  27780. switch name {
  27781. case token.FieldCreatedAt:
  27782. v, ok := value.(time.Time)
  27783. if !ok {
  27784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27785. }
  27786. m.SetCreatedAt(v)
  27787. return nil
  27788. case token.FieldUpdatedAt:
  27789. v, ok := value.(time.Time)
  27790. if !ok {
  27791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27792. }
  27793. m.SetUpdatedAt(v)
  27794. return nil
  27795. case token.FieldDeletedAt:
  27796. v, ok := value.(time.Time)
  27797. if !ok {
  27798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27799. }
  27800. m.SetDeletedAt(v)
  27801. return nil
  27802. case token.FieldExpireAt:
  27803. v, ok := value.(time.Time)
  27804. if !ok {
  27805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27806. }
  27807. m.SetExpireAt(v)
  27808. return nil
  27809. case token.FieldToken:
  27810. v, ok := value.(string)
  27811. if !ok {
  27812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27813. }
  27814. m.SetToken(v)
  27815. return nil
  27816. case token.FieldMAC:
  27817. v, ok := value.(string)
  27818. if !ok {
  27819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27820. }
  27821. m.SetMAC(v)
  27822. return nil
  27823. case token.FieldOrganizationID:
  27824. v, ok := value.(uint64)
  27825. if !ok {
  27826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27827. }
  27828. m.SetOrganizationID(v)
  27829. return nil
  27830. case token.FieldAgentID:
  27831. v, ok := value.(uint64)
  27832. if !ok {
  27833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27834. }
  27835. m.SetAgentID(v)
  27836. return nil
  27837. case token.FieldCustomAgentBase:
  27838. v, ok := value.(string)
  27839. if !ok {
  27840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27841. }
  27842. m.SetCustomAgentBase(v)
  27843. return nil
  27844. case token.FieldCustomAgentKey:
  27845. v, ok := value.(string)
  27846. if !ok {
  27847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27848. }
  27849. m.SetCustomAgentKey(v)
  27850. return nil
  27851. case token.FieldOpenaiBase:
  27852. v, ok := value.(string)
  27853. if !ok {
  27854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27855. }
  27856. m.SetOpenaiBase(v)
  27857. return nil
  27858. case token.FieldOpenaiKey:
  27859. v, ok := value.(string)
  27860. if !ok {
  27861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27862. }
  27863. m.SetOpenaiKey(v)
  27864. return nil
  27865. }
  27866. return fmt.Errorf("unknown Token field %s", name)
  27867. }
  27868. // AddedFields returns all numeric fields that were incremented/decremented during
  27869. // this mutation.
  27870. func (m *TokenMutation) AddedFields() []string {
  27871. var fields []string
  27872. if m.addorganization_id != nil {
  27873. fields = append(fields, token.FieldOrganizationID)
  27874. }
  27875. return fields
  27876. }
  27877. // AddedField returns the numeric value that was incremented/decremented on a field
  27878. // with the given name. The second boolean return value indicates that this field
  27879. // was not set, or was not defined in the schema.
  27880. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  27881. switch name {
  27882. case token.FieldOrganizationID:
  27883. return m.AddedOrganizationID()
  27884. }
  27885. return nil, false
  27886. }
  27887. // AddField adds the value to the field with the given name. It returns an error if
  27888. // the field is not defined in the schema, or if the type mismatched the field
  27889. // type.
  27890. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  27891. switch name {
  27892. case token.FieldOrganizationID:
  27893. v, ok := value.(int64)
  27894. if !ok {
  27895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27896. }
  27897. m.AddOrganizationID(v)
  27898. return nil
  27899. }
  27900. return fmt.Errorf("unknown Token numeric field %s", name)
  27901. }
  27902. // ClearedFields returns all nullable fields that were cleared during this
  27903. // mutation.
  27904. func (m *TokenMutation) ClearedFields() []string {
  27905. var fields []string
  27906. if m.FieldCleared(token.FieldDeletedAt) {
  27907. fields = append(fields, token.FieldDeletedAt)
  27908. }
  27909. if m.FieldCleared(token.FieldExpireAt) {
  27910. fields = append(fields, token.FieldExpireAt)
  27911. }
  27912. if m.FieldCleared(token.FieldToken) {
  27913. fields = append(fields, token.FieldToken)
  27914. }
  27915. if m.FieldCleared(token.FieldMAC) {
  27916. fields = append(fields, token.FieldMAC)
  27917. }
  27918. if m.FieldCleared(token.FieldCustomAgentBase) {
  27919. fields = append(fields, token.FieldCustomAgentBase)
  27920. }
  27921. if m.FieldCleared(token.FieldCustomAgentKey) {
  27922. fields = append(fields, token.FieldCustomAgentKey)
  27923. }
  27924. if m.FieldCleared(token.FieldOpenaiBase) {
  27925. fields = append(fields, token.FieldOpenaiBase)
  27926. }
  27927. if m.FieldCleared(token.FieldOpenaiKey) {
  27928. fields = append(fields, token.FieldOpenaiKey)
  27929. }
  27930. return fields
  27931. }
  27932. // FieldCleared returns a boolean indicating if a field with the given name was
  27933. // cleared in this mutation.
  27934. func (m *TokenMutation) FieldCleared(name string) bool {
  27935. _, ok := m.clearedFields[name]
  27936. return ok
  27937. }
  27938. // ClearField clears the value of the field with the given name. It returns an
  27939. // error if the field is not defined in the schema.
  27940. func (m *TokenMutation) ClearField(name string) error {
  27941. switch name {
  27942. case token.FieldDeletedAt:
  27943. m.ClearDeletedAt()
  27944. return nil
  27945. case token.FieldExpireAt:
  27946. m.ClearExpireAt()
  27947. return nil
  27948. case token.FieldToken:
  27949. m.ClearToken()
  27950. return nil
  27951. case token.FieldMAC:
  27952. m.ClearMAC()
  27953. return nil
  27954. case token.FieldCustomAgentBase:
  27955. m.ClearCustomAgentBase()
  27956. return nil
  27957. case token.FieldCustomAgentKey:
  27958. m.ClearCustomAgentKey()
  27959. return nil
  27960. case token.FieldOpenaiBase:
  27961. m.ClearOpenaiBase()
  27962. return nil
  27963. case token.FieldOpenaiKey:
  27964. m.ClearOpenaiKey()
  27965. return nil
  27966. }
  27967. return fmt.Errorf("unknown Token nullable field %s", name)
  27968. }
  27969. // ResetField resets all changes in the mutation for the field with the given name.
  27970. // It returns an error if the field is not defined in the schema.
  27971. func (m *TokenMutation) ResetField(name string) error {
  27972. switch name {
  27973. case token.FieldCreatedAt:
  27974. m.ResetCreatedAt()
  27975. return nil
  27976. case token.FieldUpdatedAt:
  27977. m.ResetUpdatedAt()
  27978. return nil
  27979. case token.FieldDeletedAt:
  27980. m.ResetDeletedAt()
  27981. return nil
  27982. case token.FieldExpireAt:
  27983. m.ResetExpireAt()
  27984. return nil
  27985. case token.FieldToken:
  27986. m.ResetToken()
  27987. return nil
  27988. case token.FieldMAC:
  27989. m.ResetMAC()
  27990. return nil
  27991. case token.FieldOrganizationID:
  27992. m.ResetOrganizationID()
  27993. return nil
  27994. case token.FieldAgentID:
  27995. m.ResetAgentID()
  27996. return nil
  27997. case token.FieldCustomAgentBase:
  27998. m.ResetCustomAgentBase()
  27999. return nil
  28000. case token.FieldCustomAgentKey:
  28001. m.ResetCustomAgentKey()
  28002. return nil
  28003. case token.FieldOpenaiBase:
  28004. m.ResetOpenaiBase()
  28005. return nil
  28006. case token.FieldOpenaiKey:
  28007. m.ResetOpenaiKey()
  28008. return nil
  28009. }
  28010. return fmt.Errorf("unknown Token field %s", name)
  28011. }
  28012. // AddedEdges returns all edge names that were set/added in this mutation.
  28013. func (m *TokenMutation) AddedEdges() []string {
  28014. edges := make([]string, 0, 1)
  28015. if m.agent != nil {
  28016. edges = append(edges, token.EdgeAgent)
  28017. }
  28018. return edges
  28019. }
  28020. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28021. // name in this mutation.
  28022. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  28023. switch name {
  28024. case token.EdgeAgent:
  28025. if id := m.agent; id != nil {
  28026. return []ent.Value{*id}
  28027. }
  28028. }
  28029. return nil
  28030. }
  28031. // RemovedEdges returns all edge names that were removed in this mutation.
  28032. func (m *TokenMutation) RemovedEdges() []string {
  28033. edges := make([]string, 0, 1)
  28034. return edges
  28035. }
  28036. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28037. // the given name in this mutation.
  28038. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  28039. return nil
  28040. }
  28041. // ClearedEdges returns all edge names that were cleared in this mutation.
  28042. func (m *TokenMutation) ClearedEdges() []string {
  28043. edges := make([]string, 0, 1)
  28044. if m.clearedagent {
  28045. edges = append(edges, token.EdgeAgent)
  28046. }
  28047. return edges
  28048. }
  28049. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28050. // was cleared in this mutation.
  28051. func (m *TokenMutation) EdgeCleared(name string) bool {
  28052. switch name {
  28053. case token.EdgeAgent:
  28054. return m.clearedagent
  28055. }
  28056. return false
  28057. }
  28058. // ClearEdge clears the value of the edge with the given name. It returns an error
  28059. // if that edge is not defined in the schema.
  28060. func (m *TokenMutation) ClearEdge(name string) error {
  28061. switch name {
  28062. case token.EdgeAgent:
  28063. m.ClearAgent()
  28064. return nil
  28065. }
  28066. return fmt.Errorf("unknown Token unique edge %s", name)
  28067. }
  28068. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28069. // It returns an error if the edge is not defined in the schema.
  28070. func (m *TokenMutation) ResetEdge(name string) error {
  28071. switch name {
  28072. case token.EdgeAgent:
  28073. m.ResetAgent()
  28074. return nil
  28075. }
  28076. return fmt.Errorf("unknown Token edge %s", name)
  28077. }
  28078. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  28079. type TutorialMutation struct {
  28080. config
  28081. op Op
  28082. typ string
  28083. id *uint64
  28084. created_at *time.Time
  28085. updated_at *time.Time
  28086. deleted_at *time.Time
  28087. index *int
  28088. addindex *int
  28089. title *string
  28090. content *string
  28091. organization_id *uint64
  28092. addorganization_id *int64
  28093. clearedFields map[string]struct{}
  28094. employee *uint64
  28095. clearedemployee bool
  28096. done bool
  28097. oldValue func(context.Context) (*Tutorial, error)
  28098. predicates []predicate.Tutorial
  28099. }
  28100. var _ ent.Mutation = (*TutorialMutation)(nil)
  28101. // tutorialOption allows management of the mutation configuration using functional options.
  28102. type tutorialOption func(*TutorialMutation)
  28103. // newTutorialMutation creates new mutation for the Tutorial entity.
  28104. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  28105. m := &TutorialMutation{
  28106. config: c,
  28107. op: op,
  28108. typ: TypeTutorial,
  28109. clearedFields: make(map[string]struct{}),
  28110. }
  28111. for _, opt := range opts {
  28112. opt(m)
  28113. }
  28114. return m
  28115. }
  28116. // withTutorialID sets the ID field of the mutation.
  28117. func withTutorialID(id uint64) tutorialOption {
  28118. return func(m *TutorialMutation) {
  28119. var (
  28120. err error
  28121. once sync.Once
  28122. value *Tutorial
  28123. )
  28124. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  28125. once.Do(func() {
  28126. if m.done {
  28127. err = errors.New("querying old values post mutation is not allowed")
  28128. } else {
  28129. value, err = m.Client().Tutorial.Get(ctx, id)
  28130. }
  28131. })
  28132. return value, err
  28133. }
  28134. m.id = &id
  28135. }
  28136. }
  28137. // withTutorial sets the old Tutorial of the mutation.
  28138. func withTutorial(node *Tutorial) tutorialOption {
  28139. return func(m *TutorialMutation) {
  28140. m.oldValue = func(context.Context) (*Tutorial, error) {
  28141. return node, nil
  28142. }
  28143. m.id = &node.ID
  28144. }
  28145. }
  28146. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28147. // executed in a transaction (ent.Tx), a transactional client is returned.
  28148. func (m TutorialMutation) Client() *Client {
  28149. client := &Client{config: m.config}
  28150. client.init()
  28151. return client
  28152. }
  28153. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28154. // it returns an error otherwise.
  28155. func (m TutorialMutation) Tx() (*Tx, error) {
  28156. if _, ok := m.driver.(*txDriver); !ok {
  28157. return nil, errors.New("ent: mutation is not running in a transaction")
  28158. }
  28159. tx := &Tx{config: m.config}
  28160. tx.init()
  28161. return tx, nil
  28162. }
  28163. // SetID sets the value of the id field. Note that this
  28164. // operation is only accepted on creation of Tutorial entities.
  28165. func (m *TutorialMutation) SetID(id uint64) {
  28166. m.id = &id
  28167. }
  28168. // ID returns the ID value in the mutation. Note that the ID is only available
  28169. // if it was provided to the builder or after it was returned from the database.
  28170. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  28171. if m.id == nil {
  28172. return
  28173. }
  28174. return *m.id, true
  28175. }
  28176. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28177. // That means, if the mutation is applied within a transaction with an isolation level such
  28178. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28179. // or updated by the mutation.
  28180. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  28181. switch {
  28182. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28183. id, exists := m.ID()
  28184. if exists {
  28185. return []uint64{id}, nil
  28186. }
  28187. fallthrough
  28188. case m.op.Is(OpUpdate | OpDelete):
  28189. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  28190. default:
  28191. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28192. }
  28193. }
  28194. // SetCreatedAt sets the "created_at" field.
  28195. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  28196. m.created_at = &t
  28197. }
  28198. // CreatedAt returns the value of the "created_at" field in the mutation.
  28199. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  28200. v := m.created_at
  28201. if v == nil {
  28202. return
  28203. }
  28204. return *v, true
  28205. }
  28206. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  28207. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28209. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28210. if !m.op.Is(OpUpdateOne) {
  28211. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28212. }
  28213. if m.id == nil || m.oldValue == nil {
  28214. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28215. }
  28216. oldValue, err := m.oldValue(ctx)
  28217. if err != nil {
  28218. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28219. }
  28220. return oldValue.CreatedAt, nil
  28221. }
  28222. // ResetCreatedAt resets all changes to the "created_at" field.
  28223. func (m *TutorialMutation) ResetCreatedAt() {
  28224. m.created_at = nil
  28225. }
  28226. // SetUpdatedAt sets the "updated_at" field.
  28227. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  28228. m.updated_at = &t
  28229. }
  28230. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28231. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  28232. v := m.updated_at
  28233. if v == nil {
  28234. return
  28235. }
  28236. return *v, true
  28237. }
  28238. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  28239. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28241. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28242. if !m.op.Is(OpUpdateOne) {
  28243. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28244. }
  28245. if m.id == nil || m.oldValue == nil {
  28246. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28247. }
  28248. oldValue, err := m.oldValue(ctx)
  28249. if err != nil {
  28250. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28251. }
  28252. return oldValue.UpdatedAt, nil
  28253. }
  28254. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28255. func (m *TutorialMutation) ResetUpdatedAt() {
  28256. m.updated_at = nil
  28257. }
  28258. // SetDeletedAt sets the "deleted_at" field.
  28259. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  28260. m.deleted_at = &t
  28261. }
  28262. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28263. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  28264. v := m.deleted_at
  28265. if v == nil {
  28266. return
  28267. }
  28268. return *v, true
  28269. }
  28270. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  28271. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28273. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28274. if !m.op.Is(OpUpdateOne) {
  28275. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28276. }
  28277. if m.id == nil || m.oldValue == nil {
  28278. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28279. }
  28280. oldValue, err := m.oldValue(ctx)
  28281. if err != nil {
  28282. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28283. }
  28284. return oldValue.DeletedAt, nil
  28285. }
  28286. // ClearDeletedAt clears the value of the "deleted_at" field.
  28287. func (m *TutorialMutation) ClearDeletedAt() {
  28288. m.deleted_at = nil
  28289. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  28290. }
  28291. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28292. func (m *TutorialMutation) DeletedAtCleared() bool {
  28293. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  28294. return ok
  28295. }
  28296. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28297. func (m *TutorialMutation) ResetDeletedAt() {
  28298. m.deleted_at = nil
  28299. delete(m.clearedFields, tutorial.FieldDeletedAt)
  28300. }
  28301. // SetEmployeeID sets the "employee_id" field.
  28302. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  28303. m.employee = &u
  28304. }
  28305. // EmployeeID returns the value of the "employee_id" field in the mutation.
  28306. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  28307. v := m.employee
  28308. if v == nil {
  28309. return
  28310. }
  28311. return *v, true
  28312. }
  28313. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  28314. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28316. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  28317. if !m.op.Is(OpUpdateOne) {
  28318. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  28319. }
  28320. if m.id == nil || m.oldValue == nil {
  28321. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  28322. }
  28323. oldValue, err := m.oldValue(ctx)
  28324. if err != nil {
  28325. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  28326. }
  28327. return oldValue.EmployeeID, nil
  28328. }
  28329. // ResetEmployeeID resets all changes to the "employee_id" field.
  28330. func (m *TutorialMutation) ResetEmployeeID() {
  28331. m.employee = nil
  28332. }
  28333. // SetIndex sets the "index" field.
  28334. func (m *TutorialMutation) SetIndex(i int) {
  28335. m.index = &i
  28336. m.addindex = nil
  28337. }
  28338. // Index returns the value of the "index" field in the mutation.
  28339. func (m *TutorialMutation) Index() (r int, exists bool) {
  28340. v := m.index
  28341. if v == nil {
  28342. return
  28343. }
  28344. return *v, true
  28345. }
  28346. // OldIndex returns the old "index" field's value of the Tutorial entity.
  28347. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28349. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  28350. if !m.op.Is(OpUpdateOne) {
  28351. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  28352. }
  28353. if m.id == nil || m.oldValue == nil {
  28354. return v, errors.New("OldIndex requires an ID field in the mutation")
  28355. }
  28356. oldValue, err := m.oldValue(ctx)
  28357. if err != nil {
  28358. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  28359. }
  28360. return oldValue.Index, nil
  28361. }
  28362. // AddIndex adds i to the "index" field.
  28363. func (m *TutorialMutation) AddIndex(i int) {
  28364. if m.addindex != nil {
  28365. *m.addindex += i
  28366. } else {
  28367. m.addindex = &i
  28368. }
  28369. }
  28370. // AddedIndex returns the value that was added to the "index" field in this mutation.
  28371. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  28372. v := m.addindex
  28373. if v == nil {
  28374. return
  28375. }
  28376. return *v, true
  28377. }
  28378. // ResetIndex resets all changes to the "index" field.
  28379. func (m *TutorialMutation) ResetIndex() {
  28380. m.index = nil
  28381. m.addindex = nil
  28382. }
  28383. // SetTitle sets the "title" field.
  28384. func (m *TutorialMutation) SetTitle(s string) {
  28385. m.title = &s
  28386. }
  28387. // Title returns the value of the "title" field in the mutation.
  28388. func (m *TutorialMutation) Title() (r string, exists bool) {
  28389. v := m.title
  28390. if v == nil {
  28391. return
  28392. }
  28393. return *v, true
  28394. }
  28395. // OldTitle returns the old "title" field's value of the Tutorial entity.
  28396. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28398. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  28399. if !m.op.Is(OpUpdateOne) {
  28400. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  28401. }
  28402. if m.id == nil || m.oldValue == nil {
  28403. return v, errors.New("OldTitle requires an ID field in the mutation")
  28404. }
  28405. oldValue, err := m.oldValue(ctx)
  28406. if err != nil {
  28407. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  28408. }
  28409. return oldValue.Title, nil
  28410. }
  28411. // ResetTitle resets all changes to the "title" field.
  28412. func (m *TutorialMutation) ResetTitle() {
  28413. m.title = nil
  28414. }
  28415. // SetContent sets the "content" field.
  28416. func (m *TutorialMutation) SetContent(s string) {
  28417. m.content = &s
  28418. }
  28419. // Content returns the value of the "content" field in the mutation.
  28420. func (m *TutorialMutation) Content() (r string, exists bool) {
  28421. v := m.content
  28422. if v == nil {
  28423. return
  28424. }
  28425. return *v, true
  28426. }
  28427. // OldContent returns the old "content" field's value of the Tutorial entity.
  28428. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28430. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  28431. if !m.op.Is(OpUpdateOne) {
  28432. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  28433. }
  28434. if m.id == nil || m.oldValue == nil {
  28435. return v, errors.New("OldContent requires an ID field in the mutation")
  28436. }
  28437. oldValue, err := m.oldValue(ctx)
  28438. if err != nil {
  28439. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  28440. }
  28441. return oldValue.Content, nil
  28442. }
  28443. // ResetContent resets all changes to the "content" field.
  28444. func (m *TutorialMutation) ResetContent() {
  28445. m.content = nil
  28446. }
  28447. // SetOrganizationID sets the "organization_id" field.
  28448. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  28449. m.organization_id = &u
  28450. m.addorganization_id = nil
  28451. }
  28452. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28453. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  28454. v := m.organization_id
  28455. if v == nil {
  28456. return
  28457. }
  28458. return *v, true
  28459. }
  28460. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  28461. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28463. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28464. if !m.op.Is(OpUpdateOne) {
  28465. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28466. }
  28467. if m.id == nil || m.oldValue == nil {
  28468. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28469. }
  28470. oldValue, err := m.oldValue(ctx)
  28471. if err != nil {
  28472. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28473. }
  28474. return oldValue.OrganizationID, nil
  28475. }
  28476. // AddOrganizationID adds u to the "organization_id" field.
  28477. func (m *TutorialMutation) AddOrganizationID(u int64) {
  28478. if m.addorganization_id != nil {
  28479. *m.addorganization_id += u
  28480. } else {
  28481. m.addorganization_id = &u
  28482. }
  28483. }
  28484. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28485. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  28486. v := m.addorganization_id
  28487. if v == nil {
  28488. return
  28489. }
  28490. return *v, true
  28491. }
  28492. // ResetOrganizationID resets all changes to the "organization_id" field.
  28493. func (m *TutorialMutation) ResetOrganizationID() {
  28494. m.organization_id = nil
  28495. m.addorganization_id = nil
  28496. }
  28497. // ClearEmployee clears the "employee" edge to the Employee entity.
  28498. func (m *TutorialMutation) ClearEmployee() {
  28499. m.clearedemployee = true
  28500. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  28501. }
  28502. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  28503. func (m *TutorialMutation) EmployeeCleared() bool {
  28504. return m.clearedemployee
  28505. }
  28506. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  28507. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28508. // EmployeeID instead. It exists only for internal usage by the builders.
  28509. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  28510. if id := m.employee; id != nil {
  28511. ids = append(ids, *id)
  28512. }
  28513. return
  28514. }
  28515. // ResetEmployee resets all changes to the "employee" edge.
  28516. func (m *TutorialMutation) ResetEmployee() {
  28517. m.employee = nil
  28518. m.clearedemployee = false
  28519. }
  28520. // Where appends a list predicates to the TutorialMutation builder.
  28521. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  28522. m.predicates = append(m.predicates, ps...)
  28523. }
  28524. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  28525. // users can use type-assertion to append predicates that do not depend on any generated package.
  28526. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  28527. p := make([]predicate.Tutorial, len(ps))
  28528. for i := range ps {
  28529. p[i] = ps[i]
  28530. }
  28531. m.Where(p...)
  28532. }
  28533. // Op returns the operation name.
  28534. func (m *TutorialMutation) Op() Op {
  28535. return m.op
  28536. }
  28537. // SetOp allows setting the mutation operation.
  28538. func (m *TutorialMutation) SetOp(op Op) {
  28539. m.op = op
  28540. }
  28541. // Type returns the node type of this mutation (Tutorial).
  28542. func (m *TutorialMutation) Type() string {
  28543. return m.typ
  28544. }
  28545. // Fields returns all fields that were changed during this mutation. Note that in
  28546. // order to get all numeric fields that were incremented/decremented, call
  28547. // AddedFields().
  28548. func (m *TutorialMutation) Fields() []string {
  28549. fields := make([]string, 0, 8)
  28550. if m.created_at != nil {
  28551. fields = append(fields, tutorial.FieldCreatedAt)
  28552. }
  28553. if m.updated_at != nil {
  28554. fields = append(fields, tutorial.FieldUpdatedAt)
  28555. }
  28556. if m.deleted_at != nil {
  28557. fields = append(fields, tutorial.FieldDeletedAt)
  28558. }
  28559. if m.employee != nil {
  28560. fields = append(fields, tutorial.FieldEmployeeID)
  28561. }
  28562. if m.index != nil {
  28563. fields = append(fields, tutorial.FieldIndex)
  28564. }
  28565. if m.title != nil {
  28566. fields = append(fields, tutorial.FieldTitle)
  28567. }
  28568. if m.content != nil {
  28569. fields = append(fields, tutorial.FieldContent)
  28570. }
  28571. if m.organization_id != nil {
  28572. fields = append(fields, tutorial.FieldOrganizationID)
  28573. }
  28574. return fields
  28575. }
  28576. // Field returns the value of a field with the given name. The second boolean
  28577. // return value indicates that this field was not set, or was not defined in the
  28578. // schema.
  28579. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  28580. switch name {
  28581. case tutorial.FieldCreatedAt:
  28582. return m.CreatedAt()
  28583. case tutorial.FieldUpdatedAt:
  28584. return m.UpdatedAt()
  28585. case tutorial.FieldDeletedAt:
  28586. return m.DeletedAt()
  28587. case tutorial.FieldEmployeeID:
  28588. return m.EmployeeID()
  28589. case tutorial.FieldIndex:
  28590. return m.Index()
  28591. case tutorial.FieldTitle:
  28592. return m.Title()
  28593. case tutorial.FieldContent:
  28594. return m.Content()
  28595. case tutorial.FieldOrganizationID:
  28596. return m.OrganizationID()
  28597. }
  28598. return nil, false
  28599. }
  28600. // OldField returns the old value of the field from the database. An error is
  28601. // returned if the mutation operation is not UpdateOne, or the query to the
  28602. // database failed.
  28603. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28604. switch name {
  28605. case tutorial.FieldCreatedAt:
  28606. return m.OldCreatedAt(ctx)
  28607. case tutorial.FieldUpdatedAt:
  28608. return m.OldUpdatedAt(ctx)
  28609. case tutorial.FieldDeletedAt:
  28610. return m.OldDeletedAt(ctx)
  28611. case tutorial.FieldEmployeeID:
  28612. return m.OldEmployeeID(ctx)
  28613. case tutorial.FieldIndex:
  28614. return m.OldIndex(ctx)
  28615. case tutorial.FieldTitle:
  28616. return m.OldTitle(ctx)
  28617. case tutorial.FieldContent:
  28618. return m.OldContent(ctx)
  28619. case tutorial.FieldOrganizationID:
  28620. return m.OldOrganizationID(ctx)
  28621. }
  28622. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  28623. }
  28624. // SetField sets the value of a field with the given name. It returns an error if
  28625. // the field is not defined in the schema, or if the type mismatched the field
  28626. // type.
  28627. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  28628. switch name {
  28629. case tutorial.FieldCreatedAt:
  28630. v, ok := value.(time.Time)
  28631. if !ok {
  28632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28633. }
  28634. m.SetCreatedAt(v)
  28635. return nil
  28636. case tutorial.FieldUpdatedAt:
  28637. v, ok := value.(time.Time)
  28638. if !ok {
  28639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28640. }
  28641. m.SetUpdatedAt(v)
  28642. return nil
  28643. case tutorial.FieldDeletedAt:
  28644. v, ok := value.(time.Time)
  28645. if !ok {
  28646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28647. }
  28648. m.SetDeletedAt(v)
  28649. return nil
  28650. case tutorial.FieldEmployeeID:
  28651. v, ok := value.(uint64)
  28652. if !ok {
  28653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28654. }
  28655. m.SetEmployeeID(v)
  28656. return nil
  28657. case tutorial.FieldIndex:
  28658. v, ok := value.(int)
  28659. if !ok {
  28660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28661. }
  28662. m.SetIndex(v)
  28663. return nil
  28664. case tutorial.FieldTitle:
  28665. v, ok := value.(string)
  28666. if !ok {
  28667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28668. }
  28669. m.SetTitle(v)
  28670. return nil
  28671. case tutorial.FieldContent:
  28672. v, ok := value.(string)
  28673. if !ok {
  28674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28675. }
  28676. m.SetContent(v)
  28677. return nil
  28678. case tutorial.FieldOrganizationID:
  28679. v, ok := value.(uint64)
  28680. if !ok {
  28681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28682. }
  28683. m.SetOrganizationID(v)
  28684. return nil
  28685. }
  28686. return fmt.Errorf("unknown Tutorial field %s", name)
  28687. }
  28688. // AddedFields returns all numeric fields that were incremented/decremented during
  28689. // this mutation.
  28690. func (m *TutorialMutation) AddedFields() []string {
  28691. var fields []string
  28692. if m.addindex != nil {
  28693. fields = append(fields, tutorial.FieldIndex)
  28694. }
  28695. if m.addorganization_id != nil {
  28696. fields = append(fields, tutorial.FieldOrganizationID)
  28697. }
  28698. return fields
  28699. }
  28700. // AddedField returns the numeric value that was incremented/decremented on a field
  28701. // with the given name. The second boolean return value indicates that this field
  28702. // was not set, or was not defined in the schema.
  28703. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  28704. switch name {
  28705. case tutorial.FieldIndex:
  28706. return m.AddedIndex()
  28707. case tutorial.FieldOrganizationID:
  28708. return m.AddedOrganizationID()
  28709. }
  28710. return nil, false
  28711. }
  28712. // AddField adds the value to the field with the given name. It returns an error if
  28713. // the field is not defined in the schema, or if the type mismatched the field
  28714. // type.
  28715. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  28716. switch name {
  28717. case tutorial.FieldIndex:
  28718. v, ok := value.(int)
  28719. if !ok {
  28720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28721. }
  28722. m.AddIndex(v)
  28723. return nil
  28724. case tutorial.FieldOrganizationID:
  28725. v, ok := value.(int64)
  28726. if !ok {
  28727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28728. }
  28729. m.AddOrganizationID(v)
  28730. return nil
  28731. }
  28732. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  28733. }
  28734. // ClearedFields returns all nullable fields that were cleared during this
  28735. // mutation.
  28736. func (m *TutorialMutation) ClearedFields() []string {
  28737. var fields []string
  28738. if m.FieldCleared(tutorial.FieldDeletedAt) {
  28739. fields = append(fields, tutorial.FieldDeletedAt)
  28740. }
  28741. return fields
  28742. }
  28743. // FieldCleared returns a boolean indicating if a field with the given name was
  28744. // cleared in this mutation.
  28745. func (m *TutorialMutation) FieldCleared(name string) bool {
  28746. _, ok := m.clearedFields[name]
  28747. return ok
  28748. }
  28749. // ClearField clears the value of the field with the given name. It returns an
  28750. // error if the field is not defined in the schema.
  28751. func (m *TutorialMutation) ClearField(name string) error {
  28752. switch name {
  28753. case tutorial.FieldDeletedAt:
  28754. m.ClearDeletedAt()
  28755. return nil
  28756. }
  28757. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  28758. }
  28759. // ResetField resets all changes in the mutation for the field with the given name.
  28760. // It returns an error if the field is not defined in the schema.
  28761. func (m *TutorialMutation) ResetField(name string) error {
  28762. switch name {
  28763. case tutorial.FieldCreatedAt:
  28764. m.ResetCreatedAt()
  28765. return nil
  28766. case tutorial.FieldUpdatedAt:
  28767. m.ResetUpdatedAt()
  28768. return nil
  28769. case tutorial.FieldDeletedAt:
  28770. m.ResetDeletedAt()
  28771. return nil
  28772. case tutorial.FieldEmployeeID:
  28773. m.ResetEmployeeID()
  28774. return nil
  28775. case tutorial.FieldIndex:
  28776. m.ResetIndex()
  28777. return nil
  28778. case tutorial.FieldTitle:
  28779. m.ResetTitle()
  28780. return nil
  28781. case tutorial.FieldContent:
  28782. m.ResetContent()
  28783. return nil
  28784. case tutorial.FieldOrganizationID:
  28785. m.ResetOrganizationID()
  28786. return nil
  28787. }
  28788. return fmt.Errorf("unknown Tutorial field %s", name)
  28789. }
  28790. // AddedEdges returns all edge names that were set/added in this mutation.
  28791. func (m *TutorialMutation) AddedEdges() []string {
  28792. edges := make([]string, 0, 1)
  28793. if m.employee != nil {
  28794. edges = append(edges, tutorial.EdgeEmployee)
  28795. }
  28796. return edges
  28797. }
  28798. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28799. // name in this mutation.
  28800. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  28801. switch name {
  28802. case tutorial.EdgeEmployee:
  28803. if id := m.employee; id != nil {
  28804. return []ent.Value{*id}
  28805. }
  28806. }
  28807. return nil
  28808. }
  28809. // RemovedEdges returns all edge names that were removed in this mutation.
  28810. func (m *TutorialMutation) RemovedEdges() []string {
  28811. edges := make([]string, 0, 1)
  28812. return edges
  28813. }
  28814. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28815. // the given name in this mutation.
  28816. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  28817. return nil
  28818. }
  28819. // ClearedEdges returns all edge names that were cleared in this mutation.
  28820. func (m *TutorialMutation) ClearedEdges() []string {
  28821. edges := make([]string, 0, 1)
  28822. if m.clearedemployee {
  28823. edges = append(edges, tutorial.EdgeEmployee)
  28824. }
  28825. return edges
  28826. }
  28827. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28828. // was cleared in this mutation.
  28829. func (m *TutorialMutation) EdgeCleared(name string) bool {
  28830. switch name {
  28831. case tutorial.EdgeEmployee:
  28832. return m.clearedemployee
  28833. }
  28834. return false
  28835. }
  28836. // ClearEdge clears the value of the edge with the given name. It returns an error
  28837. // if that edge is not defined in the schema.
  28838. func (m *TutorialMutation) ClearEdge(name string) error {
  28839. switch name {
  28840. case tutorial.EdgeEmployee:
  28841. m.ClearEmployee()
  28842. return nil
  28843. }
  28844. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  28845. }
  28846. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28847. // It returns an error if the edge is not defined in the schema.
  28848. func (m *TutorialMutation) ResetEdge(name string) error {
  28849. switch name {
  28850. case tutorial.EdgeEmployee:
  28851. m.ResetEmployee()
  28852. return nil
  28853. }
  28854. return fmt.Errorf("unknown Tutorial edge %s", name)
  28855. }
  28856. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  28857. type UsageDetailMutation struct {
  28858. config
  28859. op Op
  28860. typ string
  28861. id *uint64
  28862. created_at *time.Time
  28863. updated_at *time.Time
  28864. status *uint8
  28865. addstatus *int8
  28866. _type *int
  28867. add_type *int
  28868. bot_id *string
  28869. receiver_id *string
  28870. app *int
  28871. addapp *int
  28872. session_id *uint64
  28873. addsession_id *int64
  28874. request *string
  28875. response *string
  28876. original_data *custom_types.OriginalData
  28877. total_tokens *uint64
  28878. addtotal_tokens *int64
  28879. prompt_tokens *uint64
  28880. addprompt_tokens *int64
  28881. completion_tokens *uint64
  28882. addcompletion_tokens *int64
  28883. organization_id *uint64
  28884. addorganization_id *int64
  28885. clearedFields map[string]struct{}
  28886. done bool
  28887. oldValue func(context.Context) (*UsageDetail, error)
  28888. predicates []predicate.UsageDetail
  28889. }
  28890. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  28891. // usagedetailOption allows management of the mutation configuration using functional options.
  28892. type usagedetailOption func(*UsageDetailMutation)
  28893. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  28894. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  28895. m := &UsageDetailMutation{
  28896. config: c,
  28897. op: op,
  28898. typ: TypeUsageDetail,
  28899. clearedFields: make(map[string]struct{}),
  28900. }
  28901. for _, opt := range opts {
  28902. opt(m)
  28903. }
  28904. return m
  28905. }
  28906. // withUsageDetailID sets the ID field of the mutation.
  28907. func withUsageDetailID(id uint64) usagedetailOption {
  28908. return func(m *UsageDetailMutation) {
  28909. var (
  28910. err error
  28911. once sync.Once
  28912. value *UsageDetail
  28913. )
  28914. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  28915. once.Do(func() {
  28916. if m.done {
  28917. err = errors.New("querying old values post mutation is not allowed")
  28918. } else {
  28919. value, err = m.Client().UsageDetail.Get(ctx, id)
  28920. }
  28921. })
  28922. return value, err
  28923. }
  28924. m.id = &id
  28925. }
  28926. }
  28927. // withUsageDetail sets the old UsageDetail of the mutation.
  28928. func withUsageDetail(node *UsageDetail) usagedetailOption {
  28929. return func(m *UsageDetailMutation) {
  28930. m.oldValue = func(context.Context) (*UsageDetail, error) {
  28931. return node, nil
  28932. }
  28933. m.id = &node.ID
  28934. }
  28935. }
  28936. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28937. // executed in a transaction (ent.Tx), a transactional client is returned.
  28938. func (m UsageDetailMutation) Client() *Client {
  28939. client := &Client{config: m.config}
  28940. client.init()
  28941. return client
  28942. }
  28943. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28944. // it returns an error otherwise.
  28945. func (m UsageDetailMutation) Tx() (*Tx, error) {
  28946. if _, ok := m.driver.(*txDriver); !ok {
  28947. return nil, errors.New("ent: mutation is not running in a transaction")
  28948. }
  28949. tx := &Tx{config: m.config}
  28950. tx.init()
  28951. return tx, nil
  28952. }
  28953. // SetID sets the value of the id field. Note that this
  28954. // operation is only accepted on creation of UsageDetail entities.
  28955. func (m *UsageDetailMutation) SetID(id uint64) {
  28956. m.id = &id
  28957. }
  28958. // ID returns the ID value in the mutation. Note that the ID is only available
  28959. // if it was provided to the builder or after it was returned from the database.
  28960. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  28961. if m.id == nil {
  28962. return
  28963. }
  28964. return *m.id, true
  28965. }
  28966. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28967. // That means, if the mutation is applied within a transaction with an isolation level such
  28968. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28969. // or updated by the mutation.
  28970. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  28971. switch {
  28972. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28973. id, exists := m.ID()
  28974. if exists {
  28975. return []uint64{id}, nil
  28976. }
  28977. fallthrough
  28978. case m.op.Is(OpUpdate | OpDelete):
  28979. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  28980. default:
  28981. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28982. }
  28983. }
  28984. // SetCreatedAt sets the "created_at" field.
  28985. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  28986. m.created_at = &t
  28987. }
  28988. // CreatedAt returns the value of the "created_at" field in the mutation.
  28989. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  28990. v := m.created_at
  28991. if v == nil {
  28992. return
  28993. }
  28994. return *v, true
  28995. }
  28996. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  28997. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28999. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29000. if !m.op.Is(OpUpdateOne) {
  29001. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29002. }
  29003. if m.id == nil || m.oldValue == nil {
  29004. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29005. }
  29006. oldValue, err := m.oldValue(ctx)
  29007. if err != nil {
  29008. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29009. }
  29010. return oldValue.CreatedAt, nil
  29011. }
  29012. // ResetCreatedAt resets all changes to the "created_at" field.
  29013. func (m *UsageDetailMutation) ResetCreatedAt() {
  29014. m.created_at = nil
  29015. }
  29016. // SetUpdatedAt sets the "updated_at" field.
  29017. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  29018. m.updated_at = &t
  29019. }
  29020. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29021. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  29022. v := m.updated_at
  29023. if v == nil {
  29024. return
  29025. }
  29026. return *v, true
  29027. }
  29028. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  29029. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29031. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29032. if !m.op.Is(OpUpdateOne) {
  29033. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29034. }
  29035. if m.id == nil || m.oldValue == nil {
  29036. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29037. }
  29038. oldValue, err := m.oldValue(ctx)
  29039. if err != nil {
  29040. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29041. }
  29042. return oldValue.UpdatedAt, nil
  29043. }
  29044. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29045. func (m *UsageDetailMutation) ResetUpdatedAt() {
  29046. m.updated_at = nil
  29047. }
  29048. // SetStatus sets the "status" field.
  29049. func (m *UsageDetailMutation) SetStatus(u uint8) {
  29050. m.status = &u
  29051. m.addstatus = nil
  29052. }
  29053. // Status returns the value of the "status" field in the mutation.
  29054. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  29055. v := m.status
  29056. if v == nil {
  29057. return
  29058. }
  29059. return *v, true
  29060. }
  29061. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  29062. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29064. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29065. if !m.op.Is(OpUpdateOne) {
  29066. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29067. }
  29068. if m.id == nil || m.oldValue == nil {
  29069. return v, errors.New("OldStatus requires an ID field in the mutation")
  29070. }
  29071. oldValue, err := m.oldValue(ctx)
  29072. if err != nil {
  29073. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29074. }
  29075. return oldValue.Status, nil
  29076. }
  29077. // AddStatus adds u to the "status" field.
  29078. func (m *UsageDetailMutation) AddStatus(u int8) {
  29079. if m.addstatus != nil {
  29080. *m.addstatus += u
  29081. } else {
  29082. m.addstatus = &u
  29083. }
  29084. }
  29085. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29086. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  29087. v := m.addstatus
  29088. if v == nil {
  29089. return
  29090. }
  29091. return *v, true
  29092. }
  29093. // ClearStatus clears the value of the "status" field.
  29094. func (m *UsageDetailMutation) ClearStatus() {
  29095. m.status = nil
  29096. m.addstatus = nil
  29097. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  29098. }
  29099. // StatusCleared returns if the "status" field was cleared in this mutation.
  29100. func (m *UsageDetailMutation) StatusCleared() bool {
  29101. _, ok := m.clearedFields[usagedetail.FieldStatus]
  29102. return ok
  29103. }
  29104. // ResetStatus resets all changes to the "status" field.
  29105. func (m *UsageDetailMutation) ResetStatus() {
  29106. m.status = nil
  29107. m.addstatus = nil
  29108. delete(m.clearedFields, usagedetail.FieldStatus)
  29109. }
  29110. // SetType sets the "type" field.
  29111. func (m *UsageDetailMutation) SetType(i int) {
  29112. m._type = &i
  29113. m.add_type = nil
  29114. }
  29115. // GetType returns the value of the "type" field in the mutation.
  29116. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  29117. v := m._type
  29118. if v == nil {
  29119. return
  29120. }
  29121. return *v, true
  29122. }
  29123. // OldType returns the old "type" field's value of the UsageDetail entity.
  29124. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29126. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  29127. if !m.op.Is(OpUpdateOne) {
  29128. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29129. }
  29130. if m.id == nil || m.oldValue == nil {
  29131. return v, errors.New("OldType requires an ID field in the mutation")
  29132. }
  29133. oldValue, err := m.oldValue(ctx)
  29134. if err != nil {
  29135. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29136. }
  29137. return oldValue.Type, nil
  29138. }
  29139. // AddType adds i to the "type" field.
  29140. func (m *UsageDetailMutation) AddType(i int) {
  29141. if m.add_type != nil {
  29142. *m.add_type += i
  29143. } else {
  29144. m.add_type = &i
  29145. }
  29146. }
  29147. // AddedType returns the value that was added to the "type" field in this mutation.
  29148. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  29149. v := m.add_type
  29150. if v == nil {
  29151. return
  29152. }
  29153. return *v, true
  29154. }
  29155. // ClearType clears the value of the "type" field.
  29156. func (m *UsageDetailMutation) ClearType() {
  29157. m._type = nil
  29158. m.add_type = nil
  29159. m.clearedFields[usagedetail.FieldType] = struct{}{}
  29160. }
  29161. // TypeCleared returns if the "type" field was cleared in this mutation.
  29162. func (m *UsageDetailMutation) TypeCleared() bool {
  29163. _, ok := m.clearedFields[usagedetail.FieldType]
  29164. return ok
  29165. }
  29166. // ResetType resets all changes to the "type" field.
  29167. func (m *UsageDetailMutation) ResetType() {
  29168. m._type = nil
  29169. m.add_type = nil
  29170. delete(m.clearedFields, usagedetail.FieldType)
  29171. }
  29172. // SetBotID sets the "bot_id" field.
  29173. func (m *UsageDetailMutation) SetBotID(s string) {
  29174. m.bot_id = &s
  29175. }
  29176. // BotID returns the value of the "bot_id" field in the mutation.
  29177. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  29178. v := m.bot_id
  29179. if v == nil {
  29180. return
  29181. }
  29182. return *v, true
  29183. }
  29184. // OldBotID returns the old "bot_id" 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) OldBotID(ctx context.Context) (v string, err error) {
  29188. if !m.op.Is(OpUpdateOne) {
  29189. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29190. }
  29191. if m.id == nil || m.oldValue == nil {
  29192. return v, errors.New("OldBotID 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 OldBotID: %w", err)
  29197. }
  29198. return oldValue.BotID, nil
  29199. }
  29200. // ResetBotID resets all changes to the "bot_id" field.
  29201. func (m *UsageDetailMutation) ResetBotID() {
  29202. m.bot_id = nil
  29203. }
  29204. // SetReceiverID sets the "receiver_id" field.
  29205. func (m *UsageDetailMutation) SetReceiverID(s string) {
  29206. m.receiver_id = &s
  29207. }
  29208. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  29209. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  29210. v := m.receiver_id
  29211. if v == nil {
  29212. return
  29213. }
  29214. return *v, true
  29215. }
  29216. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  29217. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29219. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  29220. if !m.op.Is(OpUpdateOne) {
  29221. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  29222. }
  29223. if m.id == nil || m.oldValue == nil {
  29224. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  29225. }
  29226. oldValue, err := m.oldValue(ctx)
  29227. if err != nil {
  29228. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  29229. }
  29230. return oldValue.ReceiverID, nil
  29231. }
  29232. // ResetReceiverID resets all changes to the "receiver_id" field.
  29233. func (m *UsageDetailMutation) ResetReceiverID() {
  29234. m.receiver_id = nil
  29235. }
  29236. // SetApp sets the "app" field.
  29237. func (m *UsageDetailMutation) SetApp(i int) {
  29238. m.app = &i
  29239. m.addapp = nil
  29240. }
  29241. // App returns the value of the "app" field in the mutation.
  29242. func (m *UsageDetailMutation) App() (r int, exists bool) {
  29243. v := m.app
  29244. if v == nil {
  29245. return
  29246. }
  29247. return *v, true
  29248. }
  29249. // OldApp returns the old "app" field's value of the UsageDetail entity.
  29250. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29252. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  29253. if !m.op.Is(OpUpdateOne) {
  29254. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  29255. }
  29256. if m.id == nil || m.oldValue == nil {
  29257. return v, errors.New("OldApp requires an ID field in the mutation")
  29258. }
  29259. oldValue, err := m.oldValue(ctx)
  29260. if err != nil {
  29261. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  29262. }
  29263. return oldValue.App, nil
  29264. }
  29265. // AddApp adds i to the "app" field.
  29266. func (m *UsageDetailMutation) AddApp(i int) {
  29267. if m.addapp != nil {
  29268. *m.addapp += i
  29269. } else {
  29270. m.addapp = &i
  29271. }
  29272. }
  29273. // AddedApp returns the value that was added to the "app" field in this mutation.
  29274. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  29275. v := m.addapp
  29276. if v == nil {
  29277. return
  29278. }
  29279. return *v, true
  29280. }
  29281. // ClearApp clears the value of the "app" field.
  29282. func (m *UsageDetailMutation) ClearApp() {
  29283. m.app = nil
  29284. m.addapp = nil
  29285. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  29286. }
  29287. // AppCleared returns if the "app" field was cleared in this mutation.
  29288. func (m *UsageDetailMutation) AppCleared() bool {
  29289. _, ok := m.clearedFields[usagedetail.FieldApp]
  29290. return ok
  29291. }
  29292. // ResetApp resets all changes to the "app" field.
  29293. func (m *UsageDetailMutation) ResetApp() {
  29294. m.app = nil
  29295. m.addapp = nil
  29296. delete(m.clearedFields, usagedetail.FieldApp)
  29297. }
  29298. // SetSessionID sets the "session_id" field.
  29299. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  29300. m.session_id = &u
  29301. m.addsession_id = nil
  29302. }
  29303. // SessionID returns the value of the "session_id" field in the mutation.
  29304. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  29305. v := m.session_id
  29306. if v == nil {
  29307. return
  29308. }
  29309. return *v, true
  29310. }
  29311. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  29312. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29314. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  29315. if !m.op.Is(OpUpdateOne) {
  29316. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  29317. }
  29318. if m.id == nil || m.oldValue == nil {
  29319. return v, errors.New("OldSessionID requires an ID field in the mutation")
  29320. }
  29321. oldValue, err := m.oldValue(ctx)
  29322. if err != nil {
  29323. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  29324. }
  29325. return oldValue.SessionID, nil
  29326. }
  29327. // AddSessionID adds u to the "session_id" field.
  29328. func (m *UsageDetailMutation) AddSessionID(u int64) {
  29329. if m.addsession_id != nil {
  29330. *m.addsession_id += u
  29331. } else {
  29332. m.addsession_id = &u
  29333. }
  29334. }
  29335. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  29336. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  29337. v := m.addsession_id
  29338. if v == nil {
  29339. return
  29340. }
  29341. return *v, true
  29342. }
  29343. // ClearSessionID clears the value of the "session_id" field.
  29344. func (m *UsageDetailMutation) ClearSessionID() {
  29345. m.session_id = nil
  29346. m.addsession_id = nil
  29347. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  29348. }
  29349. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  29350. func (m *UsageDetailMutation) SessionIDCleared() bool {
  29351. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  29352. return ok
  29353. }
  29354. // ResetSessionID resets all changes to the "session_id" field.
  29355. func (m *UsageDetailMutation) ResetSessionID() {
  29356. m.session_id = nil
  29357. m.addsession_id = nil
  29358. delete(m.clearedFields, usagedetail.FieldSessionID)
  29359. }
  29360. // SetRequest sets the "request" field.
  29361. func (m *UsageDetailMutation) SetRequest(s string) {
  29362. m.request = &s
  29363. }
  29364. // Request returns the value of the "request" field in the mutation.
  29365. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  29366. v := m.request
  29367. if v == nil {
  29368. return
  29369. }
  29370. return *v, true
  29371. }
  29372. // OldRequest returns the old "request" 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) OldRequest(ctx context.Context) (v string, err error) {
  29376. if !m.op.Is(OpUpdateOne) {
  29377. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  29378. }
  29379. if m.id == nil || m.oldValue == nil {
  29380. return v, errors.New("OldRequest 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 OldRequest: %w", err)
  29385. }
  29386. return oldValue.Request, nil
  29387. }
  29388. // ResetRequest resets all changes to the "request" field.
  29389. func (m *UsageDetailMutation) ResetRequest() {
  29390. m.request = nil
  29391. }
  29392. // SetResponse sets the "response" field.
  29393. func (m *UsageDetailMutation) SetResponse(s string) {
  29394. m.response = &s
  29395. }
  29396. // Response returns the value of the "response" field in the mutation.
  29397. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  29398. v := m.response
  29399. if v == nil {
  29400. return
  29401. }
  29402. return *v, true
  29403. }
  29404. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  29405. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29407. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  29408. if !m.op.Is(OpUpdateOne) {
  29409. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  29410. }
  29411. if m.id == nil || m.oldValue == nil {
  29412. return v, errors.New("OldResponse requires an ID field in the mutation")
  29413. }
  29414. oldValue, err := m.oldValue(ctx)
  29415. if err != nil {
  29416. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  29417. }
  29418. return oldValue.Response, nil
  29419. }
  29420. // ResetResponse resets all changes to the "response" field.
  29421. func (m *UsageDetailMutation) ResetResponse() {
  29422. m.response = nil
  29423. }
  29424. // SetOriginalData sets the "original_data" field.
  29425. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  29426. m.original_data = &ctd
  29427. }
  29428. // OriginalData returns the value of the "original_data" field in the mutation.
  29429. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  29430. v := m.original_data
  29431. if v == nil {
  29432. return
  29433. }
  29434. return *v, true
  29435. }
  29436. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  29437. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29439. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  29440. if !m.op.Is(OpUpdateOne) {
  29441. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  29442. }
  29443. if m.id == nil || m.oldValue == nil {
  29444. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  29445. }
  29446. oldValue, err := m.oldValue(ctx)
  29447. if err != nil {
  29448. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  29449. }
  29450. return oldValue.OriginalData, nil
  29451. }
  29452. // ResetOriginalData resets all changes to the "original_data" field.
  29453. func (m *UsageDetailMutation) ResetOriginalData() {
  29454. m.original_data = nil
  29455. }
  29456. // SetTotalTokens sets the "total_tokens" field.
  29457. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  29458. m.total_tokens = &u
  29459. m.addtotal_tokens = nil
  29460. }
  29461. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  29462. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  29463. v := m.total_tokens
  29464. if v == nil {
  29465. return
  29466. }
  29467. return *v, true
  29468. }
  29469. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  29470. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29472. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  29473. if !m.op.Is(OpUpdateOne) {
  29474. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  29475. }
  29476. if m.id == nil || m.oldValue == nil {
  29477. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  29478. }
  29479. oldValue, err := m.oldValue(ctx)
  29480. if err != nil {
  29481. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  29482. }
  29483. return oldValue.TotalTokens, nil
  29484. }
  29485. // AddTotalTokens adds u to the "total_tokens" field.
  29486. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  29487. if m.addtotal_tokens != nil {
  29488. *m.addtotal_tokens += u
  29489. } else {
  29490. m.addtotal_tokens = &u
  29491. }
  29492. }
  29493. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  29494. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  29495. v := m.addtotal_tokens
  29496. if v == nil {
  29497. return
  29498. }
  29499. return *v, true
  29500. }
  29501. // ClearTotalTokens clears the value of the "total_tokens" field.
  29502. func (m *UsageDetailMutation) ClearTotalTokens() {
  29503. m.total_tokens = nil
  29504. m.addtotal_tokens = nil
  29505. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  29506. }
  29507. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  29508. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  29509. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  29510. return ok
  29511. }
  29512. // ResetTotalTokens resets all changes to the "total_tokens" field.
  29513. func (m *UsageDetailMutation) ResetTotalTokens() {
  29514. m.total_tokens = nil
  29515. m.addtotal_tokens = nil
  29516. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  29517. }
  29518. // SetPromptTokens sets the "prompt_tokens" field.
  29519. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  29520. m.prompt_tokens = &u
  29521. m.addprompt_tokens = nil
  29522. }
  29523. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  29524. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  29525. v := m.prompt_tokens
  29526. if v == nil {
  29527. return
  29528. }
  29529. return *v, true
  29530. }
  29531. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  29532. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29534. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  29535. if !m.op.Is(OpUpdateOne) {
  29536. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  29537. }
  29538. if m.id == nil || m.oldValue == nil {
  29539. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  29540. }
  29541. oldValue, err := m.oldValue(ctx)
  29542. if err != nil {
  29543. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  29544. }
  29545. return oldValue.PromptTokens, nil
  29546. }
  29547. // AddPromptTokens adds u to the "prompt_tokens" field.
  29548. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  29549. if m.addprompt_tokens != nil {
  29550. *m.addprompt_tokens += u
  29551. } else {
  29552. m.addprompt_tokens = &u
  29553. }
  29554. }
  29555. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  29556. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  29557. v := m.addprompt_tokens
  29558. if v == nil {
  29559. return
  29560. }
  29561. return *v, true
  29562. }
  29563. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  29564. func (m *UsageDetailMutation) ClearPromptTokens() {
  29565. m.prompt_tokens = nil
  29566. m.addprompt_tokens = nil
  29567. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  29568. }
  29569. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  29570. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  29571. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  29572. return ok
  29573. }
  29574. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  29575. func (m *UsageDetailMutation) ResetPromptTokens() {
  29576. m.prompt_tokens = nil
  29577. m.addprompt_tokens = nil
  29578. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  29579. }
  29580. // SetCompletionTokens sets the "completion_tokens" field.
  29581. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  29582. m.completion_tokens = &u
  29583. m.addcompletion_tokens = nil
  29584. }
  29585. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  29586. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  29587. v := m.completion_tokens
  29588. if v == nil {
  29589. return
  29590. }
  29591. return *v, true
  29592. }
  29593. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  29594. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29596. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  29597. if !m.op.Is(OpUpdateOne) {
  29598. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  29599. }
  29600. if m.id == nil || m.oldValue == nil {
  29601. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  29602. }
  29603. oldValue, err := m.oldValue(ctx)
  29604. if err != nil {
  29605. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  29606. }
  29607. return oldValue.CompletionTokens, nil
  29608. }
  29609. // AddCompletionTokens adds u to the "completion_tokens" field.
  29610. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  29611. if m.addcompletion_tokens != nil {
  29612. *m.addcompletion_tokens += u
  29613. } else {
  29614. m.addcompletion_tokens = &u
  29615. }
  29616. }
  29617. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  29618. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  29619. v := m.addcompletion_tokens
  29620. if v == nil {
  29621. return
  29622. }
  29623. return *v, true
  29624. }
  29625. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  29626. func (m *UsageDetailMutation) ClearCompletionTokens() {
  29627. m.completion_tokens = nil
  29628. m.addcompletion_tokens = nil
  29629. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  29630. }
  29631. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  29632. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  29633. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  29634. return ok
  29635. }
  29636. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  29637. func (m *UsageDetailMutation) ResetCompletionTokens() {
  29638. m.completion_tokens = nil
  29639. m.addcompletion_tokens = nil
  29640. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  29641. }
  29642. // SetOrganizationID sets the "organization_id" field.
  29643. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  29644. m.organization_id = &u
  29645. m.addorganization_id = nil
  29646. }
  29647. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29648. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  29649. v := m.organization_id
  29650. if v == nil {
  29651. return
  29652. }
  29653. return *v, true
  29654. }
  29655. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  29656. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29658. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29659. if !m.op.Is(OpUpdateOne) {
  29660. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29661. }
  29662. if m.id == nil || m.oldValue == nil {
  29663. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29664. }
  29665. oldValue, err := m.oldValue(ctx)
  29666. if err != nil {
  29667. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29668. }
  29669. return oldValue.OrganizationID, nil
  29670. }
  29671. // AddOrganizationID adds u to the "organization_id" field.
  29672. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  29673. if m.addorganization_id != nil {
  29674. *m.addorganization_id += u
  29675. } else {
  29676. m.addorganization_id = &u
  29677. }
  29678. }
  29679. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29680. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  29681. v := m.addorganization_id
  29682. if v == nil {
  29683. return
  29684. }
  29685. return *v, true
  29686. }
  29687. // ClearOrganizationID clears the value of the "organization_id" field.
  29688. func (m *UsageDetailMutation) ClearOrganizationID() {
  29689. m.organization_id = nil
  29690. m.addorganization_id = nil
  29691. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  29692. }
  29693. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29694. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  29695. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  29696. return ok
  29697. }
  29698. // ResetOrganizationID resets all changes to the "organization_id" field.
  29699. func (m *UsageDetailMutation) ResetOrganizationID() {
  29700. m.organization_id = nil
  29701. m.addorganization_id = nil
  29702. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  29703. }
  29704. // Where appends a list predicates to the UsageDetailMutation builder.
  29705. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  29706. m.predicates = append(m.predicates, ps...)
  29707. }
  29708. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  29709. // users can use type-assertion to append predicates that do not depend on any generated package.
  29710. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  29711. p := make([]predicate.UsageDetail, len(ps))
  29712. for i := range ps {
  29713. p[i] = ps[i]
  29714. }
  29715. m.Where(p...)
  29716. }
  29717. // Op returns the operation name.
  29718. func (m *UsageDetailMutation) Op() Op {
  29719. return m.op
  29720. }
  29721. // SetOp allows setting the mutation operation.
  29722. func (m *UsageDetailMutation) SetOp(op Op) {
  29723. m.op = op
  29724. }
  29725. // Type returns the node type of this mutation (UsageDetail).
  29726. func (m *UsageDetailMutation) Type() string {
  29727. return m.typ
  29728. }
  29729. // Fields returns all fields that were changed during this mutation. Note that in
  29730. // order to get all numeric fields that were incremented/decremented, call
  29731. // AddedFields().
  29732. func (m *UsageDetailMutation) Fields() []string {
  29733. fields := make([]string, 0, 15)
  29734. if m.created_at != nil {
  29735. fields = append(fields, usagedetail.FieldCreatedAt)
  29736. }
  29737. if m.updated_at != nil {
  29738. fields = append(fields, usagedetail.FieldUpdatedAt)
  29739. }
  29740. if m.status != nil {
  29741. fields = append(fields, usagedetail.FieldStatus)
  29742. }
  29743. if m._type != nil {
  29744. fields = append(fields, usagedetail.FieldType)
  29745. }
  29746. if m.bot_id != nil {
  29747. fields = append(fields, usagedetail.FieldBotID)
  29748. }
  29749. if m.receiver_id != nil {
  29750. fields = append(fields, usagedetail.FieldReceiverID)
  29751. }
  29752. if m.app != nil {
  29753. fields = append(fields, usagedetail.FieldApp)
  29754. }
  29755. if m.session_id != nil {
  29756. fields = append(fields, usagedetail.FieldSessionID)
  29757. }
  29758. if m.request != nil {
  29759. fields = append(fields, usagedetail.FieldRequest)
  29760. }
  29761. if m.response != nil {
  29762. fields = append(fields, usagedetail.FieldResponse)
  29763. }
  29764. if m.original_data != nil {
  29765. fields = append(fields, usagedetail.FieldOriginalData)
  29766. }
  29767. if m.total_tokens != nil {
  29768. fields = append(fields, usagedetail.FieldTotalTokens)
  29769. }
  29770. if m.prompt_tokens != nil {
  29771. fields = append(fields, usagedetail.FieldPromptTokens)
  29772. }
  29773. if m.completion_tokens != nil {
  29774. fields = append(fields, usagedetail.FieldCompletionTokens)
  29775. }
  29776. if m.organization_id != nil {
  29777. fields = append(fields, usagedetail.FieldOrganizationID)
  29778. }
  29779. return fields
  29780. }
  29781. // Field returns the value of a field with the given name. The second boolean
  29782. // return value indicates that this field was not set, or was not defined in the
  29783. // schema.
  29784. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  29785. switch name {
  29786. case usagedetail.FieldCreatedAt:
  29787. return m.CreatedAt()
  29788. case usagedetail.FieldUpdatedAt:
  29789. return m.UpdatedAt()
  29790. case usagedetail.FieldStatus:
  29791. return m.Status()
  29792. case usagedetail.FieldType:
  29793. return m.GetType()
  29794. case usagedetail.FieldBotID:
  29795. return m.BotID()
  29796. case usagedetail.FieldReceiverID:
  29797. return m.ReceiverID()
  29798. case usagedetail.FieldApp:
  29799. return m.App()
  29800. case usagedetail.FieldSessionID:
  29801. return m.SessionID()
  29802. case usagedetail.FieldRequest:
  29803. return m.Request()
  29804. case usagedetail.FieldResponse:
  29805. return m.Response()
  29806. case usagedetail.FieldOriginalData:
  29807. return m.OriginalData()
  29808. case usagedetail.FieldTotalTokens:
  29809. return m.TotalTokens()
  29810. case usagedetail.FieldPromptTokens:
  29811. return m.PromptTokens()
  29812. case usagedetail.FieldCompletionTokens:
  29813. return m.CompletionTokens()
  29814. case usagedetail.FieldOrganizationID:
  29815. return m.OrganizationID()
  29816. }
  29817. return nil, false
  29818. }
  29819. // OldField returns the old value of the field from the database. An error is
  29820. // returned if the mutation operation is not UpdateOne, or the query to the
  29821. // database failed.
  29822. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29823. switch name {
  29824. case usagedetail.FieldCreatedAt:
  29825. return m.OldCreatedAt(ctx)
  29826. case usagedetail.FieldUpdatedAt:
  29827. return m.OldUpdatedAt(ctx)
  29828. case usagedetail.FieldStatus:
  29829. return m.OldStatus(ctx)
  29830. case usagedetail.FieldType:
  29831. return m.OldType(ctx)
  29832. case usagedetail.FieldBotID:
  29833. return m.OldBotID(ctx)
  29834. case usagedetail.FieldReceiverID:
  29835. return m.OldReceiverID(ctx)
  29836. case usagedetail.FieldApp:
  29837. return m.OldApp(ctx)
  29838. case usagedetail.FieldSessionID:
  29839. return m.OldSessionID(ctx)
  29840. case usagedetail.FieldRequest:
  29841. return m.OldRequest(ctx)
  29842. case usagedetail.FieldResponse:
  29843. return m.OldResponse(ctx)
  29844. case usagedetail.FieldOriginalData:
  29845. return m.OldOriginalData(ctx)
  29846. case usagedetail.FieldTotalTokens:
  29847. return m.OldTotalTokens(ctx)
  29848. case usagedetail.FieldPromptTokens:
  29849. return m.OldPromptTokens(ctx)
  29850. case usagedetail.FieldCompletionTokens:
  29851. return m.OldCompletionTokens(ctx)
  29852. case usagedetail.FieldOrganizationID:
  29853. return m.OldOrganizationID(ctx)
  29854. }
  29855. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  29856. }
  29857. // SetField sets the value of a field with the given name. It returns an error if
  29858. // the field is not defined in the schema, or if the type mismatched the field
  29859. // type.
  29860. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  29861. switch name {
  29862. case usagedetail.FieldCreatedAt:
  29863. v, ok := value.(time.Time)
  29864. if !ok {
  29865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29866. }
  29867. m.SetCreatedAt(v)
  29868. return nil
  29869. case usagedetail.FieldUpdatedAt:
  29870. v, ok := value.(time.Time)
  29871. if !ok {
  29872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29873. }
  29874. m.SetUpdatedAt(v)
  29875. return nil
  29876. case usagedetail.FieldStatus:
  29877. v, ok := value.(uint8)
  29878. if !ok {
  29879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29880. }
  29881. m.SetStatus(v)
  29882. return nil
  29883. case usagedetail.FieldType:
  29884. v, ok := value.(int)
  29885. if !ok {
  29886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29887. }
  29888. m.SetType(v)
  29889. return nil
  29890. case usagedetail.FieldBotID:
  29891. v, ok := value.(string)
  29892. if !ok {
  29893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29894. }
  29895. m.SetBotID(v)
  29896. return nil
  29897. case usagedetail.FieldReceiverID:
  29898. v, ok := value.(string)
  29899. if !ok {
  29900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29901. }
  29902. m.SetReceiverID(v)
  29903. return nil
  29904. case usagedetail.FieldApp:
  29905. v, ok := value.(int)
  29906. if !ok {
  29907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29908. }
  29909. m.SetApp(v)
  29910. return nil
  29911. case usagedetail.FieldSessionID:
  29912. v, ok := value.(uint64)
  29913. if !ok {
  29914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29915. }
  29916. m.SetSessionID(v)
  29917. return nil
  29918. case usagedetail.FieldRequest:
  29919. v, ok := value.(string)
  29920. if !ok {
  29921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29922. }
  29923. m.SetRequest(v)
  29924. return nil
  29925. case usagedetail.FieldResponse:
  29926. v, ok := value.(string)
  29927. if !ok {
  29928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29929. }
  29930. m.SetResponse(v)
  29931. return nil
  29932. case usagedetail.FieldOriginalData:
  29933. v, ok := value.(custom_types.OriginalData)
  29934. if !ok {
  29935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29936. }
  29937. m.SetOriginalData(v)
  29938. return nil
  29939. case usagedetail.FieldTotalTokens:
  29940. v, ok := value.(uint64)
  29941. if !ok {
  29942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29943. }
  29944. m.SetTotalTokens(v)
  29945. return nil
  29946. case usagedetail.FieldPromptTokens:
  29947. v, ok := value.(uint64)
  29948. if !ok {
  29949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29950. }
  29951. m.SetPromptTokens(v)
  29952. return nil
  29953. case usagedetail.FieldCompletionTokens:
  29954. v, ok := value.(uint64)
  29955. if !ok {
  29956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29957. }
  29958. m.SetCompletionTokens(v)
  29959. return nil
  29960. case usagedetail.FieldOrganizationID:
  29961. v, ok := value.(uint64)
  29962. if !ok {
  29963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29964. }
  29965. m.SetOrganizationID(v)
  29966. return nil
  29967. }
  29968. return fmt.Errorf("unknown UsageDetail field %s", name)
  29969. }
  29970. // AddedFields returns all numeric fields that were incremented/decremented during
  29971. // this mutation.
  29972. func (m *UsageDetailMutation) AddedFields() []string {
  29973. var fields []string
  29974. if m.addstatus != nil {
  29975. fields = append(fields, usagedetail.FieldStatus)
  29976. }
  29977. if m.add_type != nil {
  29978. fields = append(fields, usagedetail.FieldType)
  29979. }
  29980. if m.addapp != nil {
  29981. fields = append(fields, usagedetail.FieldApp)
  29982. }
  29983. if m.addsession_id != nil {
  29984. fields = append(fields, usagedetail.FieldSessionID)
  29985. }
  29986. if m.addtotal_tokens != nil {
  29987. fields = append(fields, usagedetail.FieldTotalTokens)
  29988. }
  29989. if m.addprompt_tokens != nil {
  29990. fields = append(fields, usagedetail.FieldPromptTokens)
  29991. }
  29992. if m.addcompletion_tokens != nil {
  29993. fields = append(fields, usagedetail.FieldCompletionTokens)
  29994. }
  29995. if m.addorganization_id != nil {
  29996. fields = append(fields, usagedetail.FieldOrganizationID)
  29997. }
  29998. return fields
  29999. }
  30000. // AddedField returns the numeric value that was incremented/decremented on a field
  30001. // with the given name. The second boolean return value indicates that this field
  30002. // was not set, or was not defined in the schema.
  30003. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  30004. switch name {
  30005. case usagedetail.FieldStatus:
  30006. return m.AddedStatus()
  30007. case usagedetail.FieldType:
  30008. return m.AddedType()
  30009. case usagedetail.FieldApp:
  30010. return m.AddedApp()
  30011. case usagedetail.FieldSessionID:
  30012. return m.AddedSessionID()
  30013. case usagedetail.FieldTotalTokens:
  30014. return m.AddedTotalTokens()
  30015. case usagedetail.FieldPromptTokens:
  30016. return m.AddedPromptTokens()
  30017. case usagedetail.FieldCompletionTokens:
  30018. return m.AddedCompletionTokens()
  30019. case usagedetail.FieldOrganizationID:
  30020. return m.AddedOrganizationID()
  30021. }
  30022. return nil, false
  30023. }
  30024. // AddField adds the value to the field with the given name. It returns an error if
  30025. // the field is not defined in the schema, or if the type mismatched the field
  30026. // type.
  30027. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  30028. switch name {
  30029. case usagedetail.FieldStatus:
  30030. v, ok := value.(int8)
  30031. if !ok {
  30032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30033. }
  30034. m.AddStatus(v)
  30035. return nil
  30036. case usagedetail.FieldType:
  30037. v, ok := value.(int)
  30038. if !ok {
  30039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30040. }
  30041. m.AddType(v)
  30042. return nil
  30043. case usagedetail.FieldApp:
  30044. v, ok := value.(int)
  30045. if !ok {
  30046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30047. }
  30048. m.AddApp(v)
  30049. return nil
  30050. case usagedetail.FieldSessionID:
  30051. v, ok := value.(int64)
  30052. if !ok {
  30053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30054. }
  30055. m.AddSessionID(v)
  30056. return nil
  30057. case usagedetail.FieldTotalTokens:
  30058. v, ok := value.(int64)
  30059. if !ok {
  30060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30061. }
  30062. m.AddTotalTokens(v)
  30063. return nil
  30064. case usagedetail.FieldPromptTokens:
  30065. v, ok := value.(int64)
  30066. if !ok {
  30067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30068. }
  30069. m.AddPromptTokens(v)
  30070. return nil
  30071. case usagedetail.FieldCompletionTokens:
  30072. v, ok := value.(int64)
  30073. if !ok {
  30074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30075. }
  30076. m.AddCompletionTokens(v)
  30077. return nil
  30078. case usagedetail.FieldOrganizationID:
  30079. v, ok := value.(int64)
  30080. if !ok {
  30081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30082. }
  30083. m.AddOrganizationID(v)
  30084. return nil
  30085. }
  30086. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  30087. }
  30088. // ClearedFields returns all nullable fields that were cleared during this
  30089. // mutation.
  30090. func (m *UsageDetailMutation) ClearedFields() []string {
  30091. var fields []string
  30092. if m.FieldCleared(usagedetail.FieldStatus) {
  30093. fields = append(fields, usagedetail.FieldStatus)
  30094. }
  30095. if m.FieldCleared(usagedetail.FieldType) {
  30096. fields = append(fields, usagedetail.FieldType)
  30097. }
  30098. if m.FieldCleared(usagedetail.FieldApp) {
  30099. fields = append(fields, usagedetail.FieldApp)
  30100. }
  30101. if m.FieldCleared(usagedetail.FieldSessionID) {
  30102. fields = append(fields, usagedetail.FieldSessionID)
  30103. }
  30104. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  30105. fields = append(fields, usagedetail.FieldTotalTokens)
  30106. }
  30107. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  30108. fields = append(fields, usagedetail.FieldPromptTokens)
  30109. }
  30110. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  30111. fields = append(fields, usagedetail.FieldCompletionTokens)
  30112. }
  30113. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  30114. fields = append(fields, usagedetail.FieldOrganizationID)
  30115. }
  30116. return fields
  30117. }
  30118. // FieldCleared returns a boolean indicating if a field with the given name was
  30119. // cleared in this mutation.
  30120. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  30121. _, ok := m.clearedFields[name]
  30122. return ok
  30123. }
  30124. // ClearField clears the value of the field with the given name. It returns an
  30125. // error if the field is not defined in the schema.
  30126. func (m *UsageDetailMutation) ClearField(name string) error {
  30127. switch name {
  30128. case usagedetail.FieldStatus:
  30129. m.ClearStatus()
  30130. return nil
  30131. case usagedetail.FieldType:
  30132. m.ClearType()
  30133. return nil
  30134. case usagedetail.FieldApp:
  30135. m.ClearApp()
  30136. return nil
  30137. case usagedetail.FieldSessionID:
  30138. m.ClearSessionID()
  30139. return nil
  30140. case usagedetail.FieldTotalTokens:
  30141. m.ClearTotalTokens()
  30142. return nil
  30143. case usagedetail.FieldPromptTokens:
  30144. m.ClearPromptTokens()
  30145. return nil
  30146. case usagedetail.FieldCompletionTokens:
  30147. m.ClearCompletionTokens()
  30148. return nil
  30149. case usagedetail.FieldOrganizationID:
  30150. m.ClearOrganizationID()
  30151. return nil
  30152. }
  30153. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  30154. }
  30155. // ResetField resets all changes in the mutation for the field with the given name.
  30156. // It returns an error if the field is not defined in the schema.
  30157. func (m *UsageDetailMutation) ResetField(name string) error {
  30158. switch name {
  30159. case usagedetail.FieldCreatedAt:
  30160. m.ResetCreatedAt()
  30161. return nil
  30162. case usagedetail.FieldUpdatedAt:
  30163. m.ResetUpdatedAt()
  30164. return nil
  30165. case usagedetail.FieldStatus:
  30166. m.ResetStatus()
  30167. return nil
  30168. case usagedetail.FieldType:
  30169. m.ResetType()
  30170. return nil
  30171. case usagedetail.FieldBotID:
  30172. m.ResetBotID()
  30173. return nil
  30174. case usagedetail.FieldReceiverID:
  30175. m.ResetReceiverID()
  30176. return nil
  30177. case usagedetail.FieldApp:
  30178. m.ResetApp()
  30179. return nil
  30180. case usagedetail.FieldSessionID:
  30181. m.ResetSessionID()
  30182. return nil
  30183. case usagedetail.FieldRequest:
  30184. m.ResetRequest()
  30185. return nil
  30186. case usagedetail.FieldResponse:
  30187. m.ResetResponse()
  30188. return nil
  30189. case usagedetail.FieldOriginalData:
  30190. m.ResetOriginalData()
  30191. return nil
  30192. case usagedetail.FieldTotalTokens:
  30193. m.ResetTotalTokens()
  30194. return nil
  30195. case usagedetail.FieldPromptTokens:
  30196. m.ResetPromptTokens()
  30197. return nil
  30198. case usagedetail.FieldCompletionTokens:
  30199. m.ResetCompletionTokens()
  30200. return nil
  30201. case usagedetail.FieldOrganizationID:
  30202. m.ResetOrganizationID()
  30203. return nil
  30204. }
  30205. return fmt.Errorf("unknown UsageDetail field %s", name)
  30206. }
  30207. // AddedEdges returns all edge names that were set/added in this mutation.
  30208. func (m *UsageDetailMutation) AddedEdges() []string {
  30209. edges := make([]string, 0, 0)
  30210. return edges
  30211. }
  30212. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30213. // name in this mutation.
  30214. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  30215. return nil
  30216. }
  30217. // RemovedEdges returns all edge names that were removed in this mutation.
  30218. func (m *UsageDetailMutation) RemovedEdges() []string {
  30219. edges := make([]string, 0, 0)
  30220. return edges
  30221. }
  30222. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30223. // the given name in this mutation.
  30224. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  30225. return nil
  30226. }
  30227. // ClearedEdges returns all edge names that were cleared in this mutation.
  30228. func (m *UsageDetailMutation) ClearedEdges() []string {
  30229. edges := make([]string, 0, 0)
  30230. return edges
  30231. }
  30232. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30233. // was cleared in this mutation.
  30234. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  30235. return false
  30236. }
  30237. // ClearEdge clears the value of the edge with the given name. It returns an error
  30238. // if that edge is not defined in the schema.
  30239. func (m *UsageDetailMutation) ClearEdge(name string) error {
  30240. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  30241. }
  30242. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30243. // It returns an error if the edge is not defined in the schema.
  30244. func (m *UsageDetailMutation) ResetEdge(name string) error {
  30245. return fmt.Errorf("unknown UsageDetail edge %s", name)
  30246. }
  30247. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  30248. type UsageStatisticDayMutation struct {
  30249. config
  30250. op Op
  30251. typ string
  30252. id *uint64
  30253. created_at *time.Time
  30254. updated_at *time.Time
  30255. status *uint8
  30256. addstatus *int8
  30257. deleted_at *time.Time
  30258. addtime *uint64
  30259. addaddtime *int64
  30260. _type *int
  30261. add_type *int
  30262. bot_id *string
  30263. organization_id *uint64
  30264. addorganization_id *int64
  30265. ai_response *uint64
  30266. addai_response *int64
  30267. sop_run *uint64
  30268. addsop_run *int64
  30269. total_friend *uint64
  30270. addtotal_friend *int64
  30271. total_group *uint64
  30272. addtotal_group *int64
  30273. account_balance *uint64
  30274. addaccount_balance *int64
  30275. consume_token *uint64
  30276. addconsume_token *int64
  30277. active_user *uint64
  30278. addactive_user *int64
  30279. new_user *int64
  30280. addnew_user *int64
  30281. label_dist *[]custom_types.LabelDist
  30282. appendlabel_dist []custom_types.LabelDist
  30283. clearedFields map[string]struct{}
  30284. done bool
  30285. oldValue func(context.Context) (*UsageStatisticDay, error)
  30286. predicates []predicate.UsageStatisticDay
  30287. }
  30288. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  30289. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  30290. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  30291. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  30292. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  30293. m := &UsageStatisticDayMutation{
  30294. config: c,
  30295. op: op,
  30296. typ: TypeUsageStatisticDay,
  30297. clearedFields: make(map[string]struct{}),
  30298. }
  30299. for _, opt := range opts {
  30300. opt(m)
  30301. }
  30302. return m
  30303. }
  30304. // withUsageStatisticDayID sets the ID field of the mutation.
  30305. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  30306. return func(m *UsageStatisticDayMutation) {
  30307. var (
  30308. err error
  30309. once sync.Once
  30310. value *UsageStatisticDay
  30311. )
  30312. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  30313. once.Do(func() {
  30314. if m.done {
  30315. err = errors.New("querying old values post mutation is not allowed")
  30316. } else {
  30317. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  30318. }
  30319. })
  30320. return value, err
  30321. }
  30322. m.id = &id
  30323. }
  30324. }
  30325. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  30326. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  30327. return func(m *UsageStatisticDayMutation) {
  30328. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  30329. return node, nil
  30330. }
  30331. m.id = &node.ID
  30332. }
  30333. }
  30334. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30335. // executed in a transaction (ent.Tx), a transactional client is returned.
  30336. func (m UsageStatisticDayMutation) Client() *Client {
  30337. client := &Client{config: m.config}
  30338. client.init()
  30339. return client
  30340. }
  30341. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30342. // it returns an error otherwise.
  30343. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  30344. if _, ok := m.driver.(*txDriver); !ok {
  30345. return nil, errors.New("ent: mutation is not running in a transaction")
  30346. }
  30347. tx := &Tx{config: m.config}
  30348. tx.init()
  30349. return tx, nil
  30350. }
  30351. // SetID sets the value of the id field. Note that this
  30352. // operation is only accepted on creation of UsageStatisticDay entities.
  30353. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  30354. m.id = &id
  30355. }
  30356. // ID returns the ID value in the mutation. Note that the ID is only available
  30357. // if it was provided to the builder or after it was returned from the database.
  30358. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  30359. if m.id == nil {
  30360. return
  30361. }
  30362. return *m.id, true
  30363. }
  30364. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30365. // That means, if the mutation is applied within a transaction with an isolation level such
  30366. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30367. // or updated by the mutation.
  30368. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  30369. switch {
  30370. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30371. id, exists := m.ID()
  30372. if exists {
  30373. return []uint64{id}, nil
  30374. }
  30375. fallthrough
  30376. case m.op.Is(OpUpdate | OpDelete):
  30377. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  30378. default:
  30379. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30380. }
  30381. }
  30382. // SetCreatedAt sets the "created_at" field.
  30383. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  30384. m.created_at = &t
  30385. }
  30386. // CreatedAt returns the value of the "created_at" field in the mutation.
  30387. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  30388. v := m.created_at
  30389. if v == nil {
  30390. return
  30391. }
  30392. return *v, true
  30393. }
  30394. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  30395. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30397. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30398. if !m.op.Is(OpUpdateOne) {
  30399. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30400. }
  30401. if m.id == nil || m.oldValue == nil {
  30402. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30403. }
  30404. oldValue, err := m.oldValue(ctx)
  30405. if err != nil {
  30406. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30407. }
  30408. return oldValue.CreatedAt, nil
  30409. }
  30410. // ResetCreatedAt resets all changes to the "created_at" field.
  30411. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  30412. m.created_at = nil
  30413. }
  30414. // SetUpdatedAt sets the "updated_at" field.
  30415. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  30416. m.updated_at = &t
  30417. }
  30418. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30419. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  30420. v := m.updated_at
  30421. if v == nil {
  30422. return
  30423. }
  30424. return *v, true
  30425. }
  30426. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  30427. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30429. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30430. if !m.op.Is(OpUpdateOne) {
  30431. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30432. }
  30433. if m.id == nil || m.oldValue == nil {
  30434. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30435. }
  30436. oldValue, err := m.oldValue(ctx)
  30437. if err != nil {
  30438. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30439. }
  30440. return oldValue.UpdatedAt, nil
  30441. }
  30442. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30443. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  30444. m.updated_at = nil
  30445. }
  30446. // SetStatus sets the "status" field.
  30447. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  30448. m.status = &u
  30449. m.addstatus = nil
  30450. }
  30451. // Status returns the value of the "status" field in the mutation.
  30452. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  30453. v := m.status
  30454. if v == nil {
  30455. return
  30456. }
  30457. return *v, true
  30458. }
  30459. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  30460. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30462. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30463. if !m.op.Is(OpUpdateOne) {
  30464. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30465. }
  30466. if m.id == nil || m.oldValue == nil {
  30467. return v, errors.New("OldStatus requires an ID field in the mutation")
  30468. }
  30469. oldValue, err := m.oldValue(ctx)
  30470. if err != nil {
  30471. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30472. }
  30473. return oldValue.Status, nil
  30474. }
  30475. // AddStatus adds u to the "status" field.
  30476. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  30477. if m.addstatus != nil {
  30478. *m.addstatus += u
  30479. } else {
  30480. m.addstatus = &u
  30481. }
  30482. }
  30483. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30484. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  30485. v := m.addstatus
  30486. if v == nil {
  30487. return
  30488. }
  30489. return *v, true
  30490. }
  30491. // ClearStatus clears the value of the "status" field.
  30492. func (m *UsageStatisticDayMutation) ClearStatus() {
  30493. m.status = nil
  30494. m.addstatus = nil
  30495. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  30496. }
  30497. // StatusCleared returns if the "status" field was cleared in this mutation.
  30498. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  30499. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  30500. return ok
  30501. }
  30502. // ResetStatus resets all changes to the "status" field.
  30503. func (m *UsageStatisticDayMutation) ResetStatus() {
  30504. m.status = nil
  30505. m.addstatus = nil
  30506. delete(m.clearedFields, usagestatisticday.FieldStatus)
  30507. }
  30508. // SetDeletedAt sets the "deleted_at" field.
  30509. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  30510. m.deleted_at = &t
  30511. }
  30512. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30513. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  30514. v := m.deleted_at
  30515. if v == nil {
  30516. return
  30517. }
  30518. return *v, true
  30519. }
  30520. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  30521. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30523. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30524. if !m.op.Is(OpUpdateOne) {
  30525. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30526. }
  30527. if m.id == nil || m.oldValue == nil {
  30528. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30529. }
  30530. oldValue, err := m.oldValue(ctx)
  30531. if err != nil {
  30532. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30533. }
  30534. return oldValue.DeletedAt, nil
  30535. }
  30536. // ClearDeletedAt clears the value of the "deleted_at" field.
  30537. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  30538. m.deleted_at = nil
  30539. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  30540. }
  30541. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30542. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  30543. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  30544. return ok
  30545. }
  30546. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30547. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  30548. m.deleted_at = nil
  30549. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  30550. }
  30551. // SetAddtime sets the "addtime" field.
  30552. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  30553. m.addtime = &u
  30554. m.addaddtime = nil
  30555. }
  30556. // Addtime returns the value of the "addtime" field in the mutation.
  30557. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  30558. v := m.addtime
  30559. if v == nil {
  30560. return
  30561. }
  30562. return *v, true
  30563. }
  30564. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  30565. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30567. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  30568. if !m.op.Is(OpUpdateOne) {
  30569. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  30570. }
  30571. if m.id == nil || m.oldValue == nil {
  30572. return v, errors.New("OldAddtime requires an ID field in the mutation")
  30573. }
  30574. oldValue, err := m.oldValue(ctx)
  30575. if err != nil {
  30576. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  30577. }
  30578. return oldValue.Addtime, nil
  30579. }
  30580. // AddAddtime adds u to the "addtime" field.
  30581. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  30582. if m.addaddtime != nil {
  30583. *m.addaddtime += u
  30584. } else {
  30585. m.addaddtime = &u
  30586. }
  30587. }
  30588. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  30589. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  30590. v := m.addaddtime
  30591. if v == nil {
  30592. return
  30593. }
  30594. return *v, true
  30595. }
  30596. // ResetAddtime resets all changes to the "addtime" field.
  30597. func (m *UsageStatisticDayMutation) ResetAddtime() {
  30598. m.addtime = nil
  30599. m.addaddtime = nil
  30600. }
  30601. // SetType sets the "type" field.
  30602. func (m *UsageStatisticDayMutation) SetType(i int) {
  30603. m._type = &i
  30604. m.add_type = nil
  30605. }
  30606. // GetType returns the value of the "type" field in the mutation.
  30607. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  30608. v := m._type
  30609. if v == nil {
  30610. return
  30611. }
  30612. return *v, true
  30613. }
  30614. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  30615. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30617. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  30618. if !m.op.Is(OpUpdateOne) {
  30619. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30620. }
  30621. if m.id == nil || m.oldValue == nil {
  30622. return v, errors.New("OldType requires an ID field in the mutation")
  30623. }
  30624. oldValue, err := m.oldValue(ctx)
  30625. if err != nil {
  30626. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30627. }
  30628. return oldValue.Type, nil
  30629. }
  30630. // AddType adds i to the "type" field.
  30631. func (m *UsageStatisticDayMutation) AddType(i int) {
  30632. if m.add_type != nil {
  30633. *m.add_type += i
  30634. } else {
  30635. m.add_type = &i
  30636. }
  30637. }
  30638. // AddedType returns the value that was added to the "type" field in this mutation.
  30639. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  30640. v := m.add_type
  30641. if v == nil {
  30642. return
  30643. }
  30644. return *v, true
  30645. }
  30646. // ResetType resets all changes to the "type" field.
  30647. func (m *UsageStatisticDayMutation) ResetType() {
  30648. m._type = nil
  30649. m.add_type = nil
  30650. }
  30651. // SetBotID sets the "bot_id" field.
  30652. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  30653. m.bot_id = &s
  30654. }
  30655. // BotID returns the value of the "bot_id" field in the mutation.
  30656. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  30657. v := m.bot_id
  30658. if v == nil {
  30659. return
  30660. }
  30661. return *v, true
  30662. }
  30663. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  30664. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30666. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  30667. if !m.op.Is(OpUpdateOne) {
  30668. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30669. }
  30670. if m.id == nil || m.oldValue == nil {
  30671. return v, errors.New("OldBotID requires an ID field in the mutation")
  30672. }
  30673. oldValue, err := m.oldValue(ctx)
  30674. if err != nil {
  30675. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30676. }
  30677. return oldValue.BotID, nil
  30678. }
  30679. // ClearBotID clears the value of the "bot_id" field.
  30680. func (m *UsageStatisticDayMutation) ClearBotID() {
  30681. m.bot_id = nil
  30682. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  30683. }
  30684. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30685. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  30686. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  30687. return ok
  30688. }
  30689. // ResetBotID resets all changes to the "bot_id" field.
  30690. func (m *UsageStatisticDayMutation) ResetBotID() {
  30691. m.bot_id = nil
  30692. delete(m.clearedFields, usagestatisticday.FieldBotID)
  30693. }
  30694. // SetOrganizationID sets the "organization_id" field.
  30695. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  30696. m.organization_id = &u
  30697. m.addorganization_id = nil
  30698. }
  30699. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30700. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  30701. v := m.organization_id
  30702. if v == nil {
  30703. return
  30704. }
  30705. return *v, true
  30706. }
  30707. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  30708. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30710. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30711. if !m.op.Is(OpUpdateOne) {
  30712. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30713. }
  30714. if m.id == nil || m.oldValue == nil {
  30715. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30716. }
  30717. oldValue, err := m.oldValue(ctx)
  30718. if err != nil {
  30719. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30720. }
  30721. return oldValue.OrganizationID, nil
  30722. }
  30723. // AddOrganizationID adds u to the "organization_id" field.
  30724. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  30725. if m.addorganization_id != nil {
  30726. *m.addorganization_id += u
  30727. } else {
  30728. m.addorganization_id = &u
  30729. }
  30730. }
  30731. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30732. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  30733. v := m.addorganization_id
  30734. if v == nil {
  30735. return
  30736. }
  30737. return *v, true
  30738. }
  30739. // ClearOrganizationID clears the value of the "organization_id" field.
  30740. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  30741. m.organization_id = nil
  30742. m.addorganization_id = nil
  30743. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  30744. }
  30745. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30746. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  30747. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  30748. return ok
  30749. }
  30750. // ResetOrganizationID resets all changes to the "organization_id" field.
  30751. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  30752. m.organization_id = nil
  30753. m.addorganization_id = nil
  30754. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  30755. }
  30756. // SetAiResponse sets the "ai_response" field.
  30757. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  30758. m.ai_response = &u
  30759. m.addai_response = nil
  30760. }
  30761. // AiResponse returns the value of the "ai_response" field in the mutation.
  30762. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  30763. v := m.ai_response
  30764. if v == nil {
  30765. return
  30766. }
  30767. return *v, true
  30768. }
  30769. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  30770. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30772. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30773. if !m.op.Is(OpUpdateOne) {
  30774. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30775. }
  30776. if m.id == nil || m.oldValue == nil {
  30777. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30778. }
  30779. oldValue, err := m.oldValue(ctx)
  30780. if err != nil {
  30781. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30782. }
  30783. return oldValue.AiResponse, nil
  30784. }
  30785. // AddAiResponse adds u to the "ai_response" field.
  30786. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  30787. if m.addai_response != nil {
  30788. *m.addai_response += u
  30789. } else {
  30790. m.addai_response = &u
  30791. }
  30792. }
  30793. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30794. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  30795. v := m.addai_response
  30796. if v == nil {
  30797. return
  30798. }
  30799. return *v, true
  30800. }
  30801. // ResetAiResponse resets all changes to the "ai_response" field.
  30802. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  30803. m.ai_response = nil
  30804. m.addai_response = nil
  30805. }
  30806. // SetSopRun sets the "sop_run" field.
  30807. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  30808. m.sop_run = &u
  30809. m.addsop_run = nil
  30810. }
  30811. // SopRun returns the value of the "sop_run" field in the mutation.
  30812. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  30813. v := m.sop_run
  30814. if v == nil {
  30815. return
  30816. }
  30817. return *v, true
  30818. }
  30819. // OldSopRun returns the old "sop_run" 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) OldSopRun(ctx context.Context) (v uint64, err error) {
  30823. if !m.op.Is(OpUpdateOne) {
  30824. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30825. }
  30826. if m.id == nil || m.oldValue == nil {
  30827. return v, errors.New("OldSopRun 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 OldSopRun: %w", err)
  30832. }
  30833. return oldValue.SopRun, nil
  30834. }
  30835. // AddSopRun adds u to the "sop_run" field.
  30836. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  30837. if m.addsop_run != nil {
  30838. *m.addsop_run += u
  30839. } else {
  30840. m.addsop_run = &u
  30841. }
  30842. }
  30843. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30844. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  30845. v := m.addsop_run
  30846. if v == nil {
  30847. return
  30848. }
  30849. return *v, true
  30850. }
  30851. // ResetSopRun resets all changes to the "sop_run" field.
  30852. func (m *UsageStatisticDayMutation) ResetSopRun() {
  30853. m.sop_run = nil
  30854. m.addsop_run = nil
  30855. }
  30856. // SetTotalFriend sets the "total_friend" field.
  30857. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  30858. m.total_friend = &u
  30859. m.addtotal_friend = nil
  30860. }
  30861. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30862. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  30863. v := m.total_friend
  30864. if v == nil {
  30865. return
  30866. }
  30867. return *v, true
  30868. }
  30869. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  30870. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30872. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30873. if !m.op.Is(OpUpdateOne) {
  30874. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30875. }
  30876. if m.id == nil || m.oldValue == nil {
  30877. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30878. }
  30879. oldValue, err := m.oldValue(ctx)
  30880. if err != nil {
  30881. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30882. }
  30883. return oldValue.TotalFriend, nil
  30884. }
  30885. // AddTotalFriend adds u to the "total_friend" field.
  30886. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  30887. if m.addtotal_friend != nil {
  30888. *m.addtotal_friend += u
  30889. } else {
  30890. m.addtotal_friend = &u
  30891. }
  30892. }
  30893. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30894. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  30895. v := m.addtotal_friend
  30896. if v == nil {
  30897. return
  30898. }
  30899. return *v, true
  30900. }
  30901. // ResetTotalFriend resets all changes to the "total_friend" field.
  30902. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  30903. m.total_friend = nil
  30904. m.addtotal_friend = nil
  30905. }
  30906. // SetTotalGroup sets the "total_group" field.
  30907. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  30908. m.total_group = &u
  30909. m.addtotal_group = nil
  30910. }
  30911. // TotalGroup returns the value of the "total_group" field in the mutation.
  30912. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  30913. v := m.total_group
  30914. if v == nil {
  30915. return
  30916. }
  30917. return *v, true
  30918. }
  30919. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  30920. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30922. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30923. if !m.op.Is(OpUpdateOne) {
  30924. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30925. }
  30926. if m.id == nil || m.oldValue == nil {
  30927. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30928. }
  30929. oldValue, err := m.oldValue(ctx)
  30930. if err != nil {
  30931. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30932. }
  30933. return oldValue.TotalGroup, nil
  30934. }
  30935. // AddTotalGroup adds u to the "total_group" field.
  30936. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  30937. if m.addtotal_group != nil {
  30938. *m.addtotal_group += u
  30939. } else {
  30940. m.addtotal_group = &u
  30941. }
  30942. }
  30943. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30944. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  30945. v := m.addtotal_group
  30946. if v == nil {
  30947. return
  30948. }
  30949. return *v, true
  30950. }
  30951. // ResetTotalGroup resets all changes to the "total_group" field.
  30952. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  30953. m.total_group = nil
  30954. m.addtotal_group = nil
  30955. }
  30956. // SetAccountBalance sets the "account_balance" field.
  30957. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  30958. m.account_balance = &u
  30959. m.addaccount_balance = nil
  30960. }
  30961. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30962. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  30963. v := m.account_balance
  30964. if v == nil {
  30965. return
  30966. }
  30967. return *v, true
  30968. }
  30969. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  30970. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30972. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30973. if !m.op.Is(OpUpdateOne) {
  30974. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30975. }
  30976. if m.id == nil || m.oldValue == nil {
  30977. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30978. }
  30979. oldValue, err := m.oldValue(ctx)
  30980. if err != nil {
  30981. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30982. }
  30983. return oldValue.AccountBalance, nil
  30984. }
  30985. // AddAccountBalance adds u to the "account_balance" field.
  30986. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  30987. if m.addaccount_balance != nil {
  30988. *m.addaccount_balance += u
  30989. } else {
  30990. m.addaccount_balance = &u
  30991. }
  30992. }
  30993. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30994. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  30995. v := m.addaccount_balance
  30996. if v == nil {
  30997. return
  30998. }
  30999. return *v, true
  31000. }
  31001. // ResetAccountBalance resets all changes to the "account_balance" field.
  31002. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  31003. m.account_balance = nil
  31004. m.addaccount_balance = nil
  31005. }
  31006. // SetConsumeToken sets the "consume_token" field.
  31007. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  31008. m.consume_token = &u
  31009. m.addconsume_token = nil
  31010. }
  31011. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31012. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  31013. v := m.consume_token
  31014. if v == nil {
  31015. return
  31016. }
  31017. return *v, true
  31018. }
  31019. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  31020. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31022. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31023. if !m.op.Is(OpUpdateOne) {
  31024. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31025. }
  31026. if m.id == nil || m.oldValue == nil {
  31027. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31028. }
  31029. oldValue, err := m.oldValue(ctx)
  31030. if err != nil {
  31031. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31032. }
  31033. return oldValue.ConsumeToken, nil
  31034. }
  31035. // AddConsumeToken adds u to the "consume_token" field.
  31036. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  31037. if m.addconsume_token != nil {
  31038. *m.addconsume_token += u
  31039. } else {
  31040. m.addconsume_token = &u
  31041. }
  31042. }
  31043. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31044. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  31045. v := m.addconsume_token
  31046. if v == nil {
  31047. return
  31048. }
  31049. return *v, true
  31050. }
  31051. // ResetConsumeToken resets all changes to the "consume_token" field.
  31052. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  31053. m.consume_token = nil
  31054. m.addconsume_token = nil
  31055. }
  31056. // SetActiveUser sets the "active_user" field.
  31057. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  31058. m.active_user = &u
  31059. m.addactive_user = nil
  31060. }
  31061. // ActiveUser returns the value of the "active_user" field in the mutation.
  31062. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  31063. v := m.active_user
  31064. if v == nil {
  31065. return
  31066. }
  31067. return *v, true
  31068. }
  31069. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  31070. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31072. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31073. if !m.op.Is(OpUpdateOne) {
  31074. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31075. }
  31076. if m.id == nil || m.oldValue == nil {
  31077. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31078. }
  31079. oldValue, err := m.oldValue(ctx)
  31080. if err != nil {
  31081. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31082. }
  31083. return oldValue.ActiveUser, nil
  31084. }
  31085. // AddActiveUser adds u to the "active_user" field.
  31086. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  31087. if m.addactive_user != nil {
  31088. *m.addactive_user += u
  31089. } else {
  31090. m.addactive_user = &u
  31091. }
  31092. }
  31093. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31094. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  31095. v := m.addactive_user
  31096. if v == nil {
  31097. return
  31098. }
  31099. return *v, true
  31100. }
  31101. // ResetActiveUser resets all changes to the "active_user" field.
  31102. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  31103. m.active_user = nil
  31104. m.addactive_user = nil
  31105. }
  31106. // SetNewUser sets the "new_user" field.
  31107. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  31108. m.new_user = &i
  31109. m.addnew_user = nil
  31110. }
  31111. // NewUser returns the value of the "new_user" field in the mutation.
  31112. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  31113. v := m.new_user
  31114. if v == nil {
  31115. return
  31116. }
  31117. return *v, true
  31118. }
  31119. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  31120. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31122. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31123. if !m.op.Is(OpUpdateOne) {
  31124. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31125. }
  31126. if m.id == nil || m.oldValue == nil {
  31127. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31128. }
  31129. oldValue, err := m.oldValue(ctx)
  31130. if err != nil {
  31131. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31132. }
  31133. return oldValue.NewUser, nil
  31134. }
  31135. // AddNewUser adds i to the "new_user" field.
  31136. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  31137. if m.addnew_user != nil {
  31138. *m.addnew_user += i
  31139. } else {
  31140. m.addnew_user = &i
  31141. }
  31142. }
  31143. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31144. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  31145. v := m.addnew_user
  31146. if v == nil {
  31147. return
  31148. }
  31149. return *v, true
  31150. }
  31151. // ResetNewUser resets all changes to the "new_user" field.
  31152. func (m *UsageStatisticDayMutation) ResetNewUser() {
  31153. m.new_user = nil
  31154. m.addnew_user = nil
  31155. }
  31156. // SetLabelDist sets the "label_dist" field.
  31157. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31158. m.label_dist = &ctd
  31159. m.appendlabel_dist = nil
  31160. }
  31161. // LabelDist returns the value of the "label_dist" field in the mutation.
  31162. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31163. v := m.label_dist
  31164. if v == nil {
  31165. return
  31166. }
  31167. return *v, true
  31168. }
  31169. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  31170. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31172. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31173. if !m.op.Is(OpUpdateOne) {
  31174. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31175. }
  31176. if m.id == nil || m.oldValue == nil {
  31177. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31178. }
  31179. oldValue, err := m.oldValue(ctx)
  31180. if err != nil {
  31181. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31182. }
  31183. return oldValue.LabelDist, nil
  31184. }
  31185. // AppendLabelDist adds ctd to the "label_dist" field.
  31186. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31187. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31188. }
  31189. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31190. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31191. if len(m.appendlabel_dist) == 0 {
  31192. return nil, false
  31193. }
  31194. return m.appendlabel_dist, true
  31195. }
  31196. // ResetLabelDist resets all changes to the "label_dist" field.
  31197. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  31198. m.label_dist = nil
  31199. m.appendlabel_dist = nil
  31200. }
  31201. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  31202. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  31203. m.predicates = append(m.predicates, ps...)
  31204. }
  31205. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  31206. // users can use type-assertion to append predicates that do not depend on any generated package.
  31207. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  31208. p := make([]predicate.UsageStatisticDay, len(ps))
  31209. for i := range ps {
  31210. p[i] = ps[i]
  31211. }
  31212. m.Where(p...)
  31213. }
  31214. // Op returns the operation name.
  31215. func (m *UsageStatisticDayMutation) Op() Op {
  31216. return m.op
  31217. }
  31218. // SetOp allows setting the mutation operation.
  31219. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  31220. m.op = op
  31221. }
  31222. // Type returns the node type of this mutation (UsageStatisticDay).
  31223. func (m *UsageStatisticDayMutation) Type() string {
  31224. return m.typ
  31225. }
  31226. // Fields returns all fields that were changed during this mutation. Note that in
  31227. // order to get all numeric fields that were incremented/decremented, call
  31228. // AddedFields().
  31229. func (m *UsageStatisticDayMutation) Fields() []string {
  31230. fields := make([]string, 0, 17)
  31231. if m.created_at != nil {
  31232. fields = append(fields, usagestatisticday.FieldCreatedAt)
  31233. }
  31234. if m.updated_at != nil {
  31235. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  31236. }
  31237. if m.status != nil {
  31238. fields = append(fields, usagestatisticday.FieldStatus)
  31239. }
  31240. if m.deleted_at != nil {
  31241. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31242. }
  31243. if m.addtime != nil {
  31244. fields = append(fields, usagestatisticday.FieldAddtime)
  31245. }
  31246. if m._type != nil {
  31247. fields = append(fields, usagestatisticday.FieldType)
  31248. }
  31249. if m.bot_id != nil {
  31250. fields = append(fields, usagestatisticday.FieldBotID)
  31251. }
  31252. if m.organization_id != nil {
  31253. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31254. }
  31255. if m.ai_response != nil {
  31256. fields = append(fields, usagestatisticday.FieldAiResponse)
  31257. }
  31258. if m.sop_run != nil {
  31259. fields = append(fields, usagestatisticday.FieldSopRun)
  31260. }
  31261. if m.total_friend != nil {
  31262. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31263. }
  31264. if m.total_group != nil {
  31265. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31266. }
  31267. if m.account_balance != nil {
  31268. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31269. }
  31270. if m.consume_token != nil {
  31271. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31272. }
  31273. if m.active_user != nil {
  31274. fields = append(fields, usagestatisticday.FieldActiveUser)
  31275. }
  31276. if m.new_user != nil {
  31277. fields = append(fields, usagestatisticday.FieldNewUser)
  31278. }
  31279. if m.label_dist != nil {
  31280. fields = append(fields, usagestatisticday.FieldLabelDist)
  31281. }
  31282. return fields
  31283. }
  31284. // Field returns the value of a field with the given name. The second boolean
  31285. // return value indicates that this field was not set, or was not defined in the
  31286. // schema.
  31287. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  31288. switch name {
  31289. case usagestatisticday.FieldCreatedAt:
  31290. return m.CreatedAt()
  31291. case usagestatisticday.FieldUpdatedAt:
  31292. return m.UpdatedAt()
  31293. case usagestatisticday.FieldStatus:
  31294. return m.Status()
  31295. case usagestatisticday.FieldDeletedAt:
  31296. return m.DeletedAt()
  31297. case usagestatisticday.FieldAddtime:
  31298. return m.Addtime()
  31299. case usagestatisticday.FieldType:
  31300. return m.GetType()
  31301. case usagestatisticday.FieldBotID:
  31302. return m.BotID()
  31303. case usagestatisticday.FieldOrganizationID:
  31304. return m.OrganizationID()
  31305. case usagestatisticday.FieldAiResponse:
  31306. return m.AiResponse()
  31307. case usagestatisticday.FieldSopRun:
  31308. return m.SopRun()
  31309. case usagestatisticday.FieldTotalFriend:
  31310. return m.TotalFriend()
  31311. case usagestatisticday.FieldTotalGroup:
  31312. return m.TotalGroup()
  31313. case usagestatisticday.FieldAccountBalance:
  31314. return m.AccountBalance()
  31315. case usagestatisticday.FieldConsumeToken:
  31316. return m.ConsumeToken()
  31317. case usagestatisticday.FieldActiveUser:
  31318. return m.ActiveUser()
  31319. case usagestatisticday.FieldNewUser:
  31320. return m.NewUser()
  31321. case usagestatisticday.FieldLabelDist:
  31322. return m.LabelDist()
  31323. }
  31324. return nil, false
  31325. }
  31326. // OldField returns the old value of the field from the database. An error is
  31327. // returned if the mutation operation is not UpdateOne, or the query to the
  31328. // database failed.
  31329. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31330. switch name {
  31331. case usagestatisticday.FieldCreatedAt:
  31332. return m.OldCreatedAt(ctx)
  31333. case usagestatisticday.FieldUpdatedAt:
  31334. return m.OldUpdatedAt(ctx)
  31335. case usagestatisticday.FieldStatus:
  31336. return m.OldStatus(ctx)
  31337. case usagestatisticday.FieldDeletedAt:
  31338. return m.OldDeletedAt(ctx)
  31339. case usagestatisticday.FieldAddtime:
  31340. return m.OldAddtime(ctx)
  31341. case usagestatisticday.FieldType:
  31342. return m.OldType(ctx)
  31343. case usagestatisticday.FieldBotID:
  31344. return m.OldBotID(ctx)
  31345. case usagestatisticday.FieldOrganizationID:
  31346. return m.OldOrganizationID(ctx)
  31347. case usagestatisticday.FieldAiResponse:
  31348. return m.OldAiResponse(ctx)
  31349. case usagestatisticday.FieldSopRun:
  31350. return m.OldSopRun(ctx)
  31351. case usagestatisticday.FieldTotalFriend:
  31352. return m.OldTotalFriend(ctx)
  31353. case usagestatisticday.FieldTotalGroup:
  31354. return m.OldTotalGroup(ctx)
  31355. case usagestatisticday.FieldAccountBalance:
  31356. return m.OldAccountBalance(ctx)
  31357. case usagestatisticday.FieldConsumeToken:
  31358. return m.OldConsumeToken(ctx)
  31359. case usagestatisticday.FieldActiveUser:
  31360. return m.OldActiveUser(ctx)
  31361. case usagestatisticday.FieldNewUser:
  31362. return m.OldNewUser(ctx)
  31363. case usagestatisticday.FieldLabelDist:
  31364. return m.OldLabelDist(ctx)
  31365. }
  31366. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31367. }
  31368. // SetField sets the value of a field with the given name. It returns an error if
  31369. // the field is not defined in the schema, or if the type mismatched the field
  31370. // type.
  31371. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  31372. switch name {
  31373. case usagestatisticday.FieldCreatedAt:
  31374. v, ok := value.(time.Time)
  31375. if !ok {
  31376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31377. }
  31378. m.SetCreatedAt(v)
  31379. return nil
  31380. case usagestatisticday.FieldUpdatedAt:
  31381. v, ok := value.(time.Time)
  31382. if !ok {
  31383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31384. }
  31385. m.SetUpdatedAt(v)
  31386. return nil
  31387. case usagestatisticday.FieldStatus:
  31388. v, ok := value.(uint8)
  31389. if !ok {
  31390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31391. }
  31392. m.SetStatus(v)
  31393. return nil
  31394. case usagestatisticday.FieldDeletedAt:
  31395. v, ok := value.(time.Time)
  31396. if !ok {
  31397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31398. }
  31399. m.SetDeletedAt(v)
  31400. return nil
  31401. case usagestatisticday.FieldAddtime:
  31402. v, ok := value.(uint64)
  31403. if !ok {
  31404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31405. }
  31406. m.SetAddtime(v)
  31407. return nil
  31408. case usagestatisticday.FieldType:
  31409. v, ok := value.(int)
  31410. if !ok {
  31411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31412. }
  31413. m.SetType(v)
  31414. return nil
  31415. case usagestatisticday.FieldBotID:
  31416. v, ok := value.(string)
  31417. if !ok {
  31418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31419. }
  31420. m.SetBotID(v)
  31421. return nil
  31422. case usagestatisticday.FieldOrganizationID:
  31423. v, ok := value.(uint64)
  31424. if !ok {
  31425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31426. }
  31427. m.SetOrganizationID(v)
  31428. return nil
  31429. case usagestatisticday.FieldAiResponse:
  31430. v, ok := value.(uint64)
  31431. if !ok {
  31432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31433. }
  31434. m.SetAiResponse(v)
  31435. return nil
  31436. case usagestatisticday.FieldSopRun:
  31437. v, ok := value.(uint64)
  31438. if !ok {
  31439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31440. }
  31441. m.SetSopRun(v)
  31442. return nil
  31443. case usagestatisticday.FieldTotalFriend:
  31444. v, ok := value.(uint64)
  31445. if !ok {
  31446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31447. }
  31448. m.SetTotalFriend(v)
  31449. return nil
  31450. case usagestatisticday.FieldTotalGroup:
  31451. v, ok := value.(uint64)
  31452. if !ok {
  31453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31454. }
  31455. m.SetTotalGroup(v)
  31456. return nil
  31457. case usagestatisticday.FieldAccountBalance:
  31458. v, ok := value.(uint64)
  31459. if !ok {
  31460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31461. }
  31462. m.SetAccountBalance(v)
  31463. return nil
  31464. case usagestatisticday.FieldConsumeToken:
  31465. v, ok := value.(uint64)
  31466. if !ok {
  31467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31468. }
  31469. m.SetConsumeToken(v)
  31470. return nil
  31471. case usagestatisticday.FieldActiveUser:
  31472. v, ok := value.(uint64)
  31473. if !ok {
  31474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31475. }
  31476. m.SetActiveUser(v)
  31477. return nil
  31478. case usagestatisticday.FieldNewUser:
  31479. v, ok := value.(int64)
  31480. if !ok {
  31481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31482. }
  31483. m.SetNewUser(v)
  31484. return nil
  31485. case usagestatisticday.FieldLabelDist:
  31486. v, ok := value.([]custom_types.LabelDist)
  31487. if !ok {
  31488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31489. }
  31490. m.SetLabelDist(v)
  31491. return nil
  31492. }
  31493. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31494. }
  31495. // AddedFields returns all numeric fields that were incremented/decremented during
  31496. // this mutation.
  31497. func (m *UsageStatisticDayMutation) AddedFields() []string {
  31498. var fields []string
  31499. if m.addstatus != nil {
  31500. fields = append(fields, usagestatisticday.FieldStatus)
  31501. }
  31502. if m.addaddtime != nil {
  31503. fields = append(fields, usagestatisticday.FieldAddtime)
  31504. }
  31505. if m.add_type != nil {
  31506. fields = append(fields, usagestatisticday.FieldType)
  31507. }
  31508. if m.addorganization_id != nil {
  31509. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31510. }
  31511. if m.addai_response != nil {
  31512. fields = append(fields, usagestatisticday.FieldAiResponse)
  31513. }
  31514. if m.addsop_run != nil {
  31515. fields = append(fields, usagestatisticday.FieldSopRun)
  31516. }
  31517. if m.addtotal_friend != nil {
  31518. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31519. }
  31520. if m.addtotal_group != nil {
  31521. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31522. }
  31523. if m.addaccount_balance != nil {
  31524. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31525. }
  31526. if m.addconsume_token != nil {
  31527. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31528. }
  31529. if m.addactive_user != nil {
  31530. fields = append(fields, usagestatisticday.FieldActiveUser)
  31531. }
  31532. if m.addnew_user != nil {
  31533. fields = append(fields, usagestatisticday.FieldNewUser)
  31534. }
  31535. return fields
  31536. }
  31537. // AddedField returns the numeric value that was incremented/decremented on a field
  31538. // with the given name. The second boolean return value indicates that this field
  31539. // was not set, or was not defined in the schema.
  31540. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  31541. switch name {
  31542. case usagestatisticday.FieldStatus:
  31543. return m.AddedStatus()
  31544. case usagestatisticday.FieldAddtime:
  31545. return m.AddedAddtime()
  31546. case usagestatisticday.FieldType:
  31547. return m.AddedType()
  31548. case usagestatisticday.FieldOrganizationID:
  31549. return m.AddedOrganizationID()
  31550. case usagestatisticday.FieldAiResponse:
  31551. return m.AddedAiResponse()
  31552. case usagestatisticday.FieldSopRun:
  31553. return m.AddedSopRun()
  31554. case usagestatisticday.FieldTotalFriend:
  31555. return m.AddedTotalFriend()
  31556. case usagestatisticday.FieldTotalGroup:
  31557. return m.AddedTotalGroup()
  31558. case usagestatisticday.FieldAccountBalance:
  31559. return m.AddedAccountBalance()
  31560. case usagestatisticday.FieldConsumeToken:
  31561. return m.AddedConsumeToken()
  31562. case usagestatisticday.FieldActiveUser:
  31563. return m.AddedActiveUser()
  31564. case usagestatisticday.FieldNewUser:
  31565. return m.AddedNewUser()
  31566. }
  31567. return nil, false
  31568. }
  31569. // AddField adds the value to the field with the given name. It returns an error if
  31570. // the field is not defined in the schema, or if the type mismatched the field
  31571. // type.
  31572. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  31573. switch name {
  31574. case usagestatisticday.FieldStatus:
  31575. v, ok := value.(int8)
  31576. if !ok {
  31577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31578. }
  31579. m.AddStatus(v)
  31580. return nil
  31581. case usagestatisticday.FieldAddtime:
  31582. v, ok := value.(int64)
  31583. if !ok {
  31584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31585. }
  31586. m.AddAddtime(v)
  31587. return nil
  31588. case usagestatisticday.FieldType:
  31589. v, ok := value.(int)
  31590. if !ok {
  31591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31592. }
  31593. m.AddType(v)
  31594. return nil
  31595. case usagestatisticday.FieldOrganizationID:
  31596. v, ok := value.(int64)
  31597. if !ok {
  31598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31599. }
  31600. m.AddOrganizationID(v)
  31601. return nil
  31602. case usagestatisticday.FieldAiResponse:
  31603. v, ok := value.(int64)
  31604. if !ok {
  31605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31606. }
  31607. m.AddAiResponse(v)
  31608. return nil
  31609. case usagestatisticday.FieldSopRun:
  31610. v, ok := value.(int64)
  31611. if !ok {
  31612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31613. }
  31614. m.AddSopRun(v)
  31615. return nil
  31616. case usagestatisticday.FieldTotalFriend:
  31617. v, ok := value.(int64)
  31618. if !ok {
  31619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31620. }
  31621. m.AddTotalFriend(v)
  31622. return nil
  31623. case usagestatisticday.FieldTotalGroup:
  31624. v, ok := value.(int64)
  31625. if !ok {
  31626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31627. }
  31628. m.AddTotalGroup(v)
  31629. return nil
  31630. case usagestatisticday.FieldAccountBalance:
  31631. v, ok := value.(int64)
  31632. if !ok {
  31633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31634. }
  31635. m.AddAccountBalance(v)
  31636. return nil
  31637. case usagestatisticday.FieldConsumeToken:
  31638. v, ok := value.(int64)
  31639. if !ok {
  31640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31641. }
  31642. m.AddConsumeToken(v)
  31643. return nil
  31644. case usagestatisticday.FieldActiveUser:
  31645. v, ok := value.(int64)
  31646. if !ok {
  31647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31648. }
  31649. m.AddActiveUser(v)
  31650. return nil
  31651. case usagestatisticday.FieldNewUser:
  31652. v, ok := value.(int64)
  31653. if !ok {
  31654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31655. }
  31656. m.AddNewUser(v)
  31657. return nil
  31658. }
  31659. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  31660. }
  31661. // ClearedFields returns all nullable fields that were cleared during this
  31662. // mutation.
  31663. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  31664. var fields []string
  31665. if m.FieldCleared(usagestatisticday.FieldStatus) {
  31666. fields = append(fields, usagestatisticday.FieldStatus)
  31667. }
  31668. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  31669. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31670. }
  31671. if m.FieldCleared(usagestatisticday.FieldBotID) {
  31672. fields = append(fields, usagestatisticday.FieldBotID)
  31673. }
  31674. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  31675. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31676. }
  31677. return fields
  31678. }
  31679. // FieldCleared returns a boolean indicating if a field with the given name was
  31680. // cleared in this mutation.
  31681. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  31682. _, ok := m.clearedFields[name]
  31683. return ok
  31684. }
  31685. // ClearField clears the value of the field with the given name. It returns an
  31686. // error if the field is not defined in the schema.
  31687. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  31688. switch name {
  31689. case usagestatisticday.FieldStatus:
  31690. m.ClearStatus()
  31691. return nil
  31692. case usagestatisticday.FieldDeletedAt:
  31693. m.ClearDeletedAt()
  31694. return nil
  31695. case usagestatisticday.FieldBotID:
  31696. m.ClearBotID()
  31697. return nil
  31698. case usagestatisticday.FieldOrganizationID:
  31699. m.ClearOrganizationID()
  31700. return nil
  31701. }
  31702. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  31703. }
  31704. // ResetField resets all changes in the mutation for the field with the given name.
  31705. // It returns an error if the field is not defined in the schema.
  31706. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  31707. switch name {
  31708. case usagestatisticday.FieldCreatedAt:
  31709. m.ResetCreatedAt()
  31710. return nil
  31711. case usagestatisticday.FieldUpdatedAt:
  31712. m.ResetUpdatedAt()
  31713. return nil
  31714. case usagestatisticday.FieldStatus:
  31715. m.ResetStatus()
  31716. return nil
  31717. case usagestatisticday.FieldDeletedAt:
  31718. m.ResetDeletedAt()
  31719. return nil
  31720. case usagestatisticday.FieldAddtime:
  31721. m.ResetAddtime()
  31722. return nil
  31723. case usagestatisticday.FieldType:
  31724. m.ResetType()
  31725. return nil
  31726. case usagestatisticday.FieldBotID:
  31727. m.ResetBotID()
  31728. return nil
  31729. case usagestatisticday.FieldOrganizationID:
  31730. m.ResetOrganizationID()
  31731. return nil
  31732. case usagestatisticday.FieldAiResponse:
  31733. m.ResetAiResponse()
  31734. return nil
  31735. case usagestatisticday.FieldSopRun:
  31736. m.ResetSopRun()
  31737. return nil
  31738. case usagestatisticday.FieldTotalFriend:
  31739. m.ResetTotalFriend()
  31740. return nil
  31741. case usagestatisticday.FieldTotalGroup:
  31742. m.ResetTotalGroup()
  31743. return nil
  31744. case usagestatisticday.FieldAccountBalance:
  31745. m.ResetAccountBalance()
  31746. return nil
  31747. case usagestatisticday.FieldConsumeToken:
  31748. m.ResetConsumeToken()
  31749. return nil
  31750. case usagestatisticday.FieldActiveUser:
  31751. m.ResetActiveUser()
  31752. return nil
  31753. case usagestatisticday.FieldNewUser:
  31754. m.ResetNewUser()
  31755. return nil
  31756. case usagestatisticday.FieldLabelDist:
  31757. m.ResetLabelDist()
  31758. return nil
  31759. }
  31760. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31761. }
  31762. // AddedEdges returns all edge names that were set/added in this mutation.
  31763. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  31764. edges := make([]string, 0, 0)
  31765. return edges
  31766. }
  31767. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31768. // name in this mutation.
  31769. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  31770. return nil
  31771. }
  31772. // RemovedEdges returns all edge names that were removed in this mutation.
  31773. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  31774. edges := make([]string, 0, 0)
  31775. return edges
  31776. }
  31777. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31778. // the given name in this mutation.
  31779. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  31780. return nil
  31781. }
  31782. // ClearedEdges returns all edge names that were cleared in this mutation.
  31783. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  31784. edges := make([]string, 0, 0)
  31785. return edges
  31786. }
  31787. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31788. // was cleared in this mutation.
  31789. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  31790. return false
  31791. }
  31792. // ClearEdge clears the value of the edge with the given name. It returns an error
  31793. // if that edge is not defined in the schema.
  31794. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  31795. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  31796. }
  31797. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31798. // It returns an error if the edge is not defined in the schema.
  31799. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  31800. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  31801. }
  31802. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  31803. type UsageStatisticHourMutation struct {
  31804. config
  31805. op Op
  31806. typ string
  31807. id *uint64
  31808. created_at *time.Time
  31809. updated_at *time.Time
  31810. status *uint8
  31811. addstatus *int8
  31812. deleted_at *time.Time
  31813. addtime *uint64
  31814. addaddtime *int64
  31815. _type *int
  31816. add_type *int
  31817. bot_id *string
  31818. organization_id *uint64
  31819. addorganization_id *int64
  31820. ai_response *uint64
  31821. addai_response *int64
  31822. sop_run *uint64
  31823. addsop_run *int64
  31824. total_friend *uint64
  31825. addtotal_friend *int64
  31826. total_group *uint64
  31827. addtotal_group *int64
  31828. account_balance *uint64
  31829. addaccount_balance *int64
  31830. consume_token *uint64
  31831. addconsume_token *int64
  31832. active_user *uint64
  31833. addactive_user *int64
  31834. new_user *int64
  31835. addnew_user *int64
  31836. label_dist *[]custom_types.LabelDist
  31837. appendlabel_dist []custom_types.LabelDist
  31838. clearedFields map[string]struct{}
  31839. done bool
  31840. oldValue func(context.Context) (*UsageStatisticHour, error)
  31841. predicates []predicate.UsageStatisticHour
  31842. }
  31843. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  31844. // usagestatistichourOption allows management of the mutation configuration using functional options.
  31845. type usagestatistichourOption func(*UsageStatisticHourMutation)
  31846. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  31847. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  31848. m := &UsageStatisticHourMutation{
  31849. config: c,
  31850. op: op,
  31851. typ: TypeUsageStatisticHour,
  31852. clearedFields: make(map[string]struct{}),
  31853. }
  31854. for _, opt := range opts {
  31855. opt(m)
  31856. }
  31857. return m
  31858. }
  31859. // withUsageStatisticHourID sets the ID field of the mutation.
  31860. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  31861. return func(m *UsageStatisticHourMutation) {
  31862. var (
  31863. err error
  31864. once sync.Once
  31865. value *UsageStatisticHour
  31866. )
  31867. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  31868. once.Do(func() {
  31869. if m.done {
  31870. err = errors.New("querying old values post mutation is not allowed")
  31871. } else {
  31872. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  31873. }
  31874. })
  31875. return value, err
  31876. }
  31877. m.id = &id
  31878. }
  31879. }
  31880. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  31881. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  31882. return func(m *UsageStatisticHourMutation) {
  31883. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  31884. return node, nil
  31885. }
  31886. m.id = &node.ID
  31887. }
  31888. }
  31889. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31890. // executed in a transaction (ent.Tx), a transactional client is returned.
  31891. func (m UsageStatisticHourMutation) Client() *Client {
  31892. client := &Client{config: m.config}
  31893. client.init()
  31894. return client
  31895. }
  31896. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31897. // it returns an error otherwise.
  31898. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  31899. if _, ok := m.driver.(*txDriver); !ok {
  31900. return nil, errors.New("ent: mutation is not running in a transaction")
  31901. }
  31902. tx := &Tx{config: m.config}
  31903. tx.init()
  31904. return tx, nil
  31905. }
  31906. // SetID sets the value of the id field. Note that this
  31907. // operation is only accepted on creation of UsageStatisticHour entities.
  31908. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  31909. m.id = &id
  31910. }
  31911. // ID returns the ID value in the mutation. Note that the ID is only available
  31912. // if it was provided to the builder or after it was returned from the database.
  31913. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  31914. if m.id == nil {
  31915. return
  31916. }
  31917. return *m.id, true
  31918. }
  31919. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31920. // That means, if the mutation is applied within a transaction with an isolation level such
  31921. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31922. // or updated by the mutation.
  31923. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  31924. switch {
  31925. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31926. id, exists := m.ID()
  31927. if exists {
  31928. return []uint64{id}, nil
  31929. }
  31930. fallthrough
  31931. case m.op.Is(OpUpdate | OpDelete):
  31932. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  31933. default:
  31934. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31935. }
  31936. }
  31937. // SetCreatedAt sets the "created_at" field.
  31938. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  31939. m.created_at = &t
  31940. }
  31941. // CreatedAt returns the value of the "created_at" field in the mutation.
  31942. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  31943. v := m.created_at
  31944. if v == nil {
  31945. return
  31946. }
  31947. return *v, true
  31948. }
  31949. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  31950. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31952. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31953. if !m.op.Is(OpUpdateOne) {
  31954. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31955. }
  31956. if m.id == nil || m.oldValue == nil {
  31957. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31958. }
  31959. oldValue, err := m.oldValue(ctx)
  31960. if err != nil {
  31961. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31962. }
  31963. return oldValue.CreatedAt, nil
  31964. }
  31965. // ResetCreatedAt resets all changes to the "created_at" field.
  31966. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  31967. m.created_at = nil
  31968. }
  31969. // SetUpdatedAt sets the "updated_at" field.
  31970. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  31971. m.updated_at = &t
  31972. }
  31973. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31974. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  31975. v := m.updated_at
  31976. if v == nil {
  31977. return
  31978. }
  31979. return *v, true
  31980. }
  31981. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  31982. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31984. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31985. if !m.op.Is(OpUpdateOne) {
  31986. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31987. }
  31988. if m.id == nil || m.oldValue == nil {
  31989. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31990. }
  31991. oldValue, err := m.oldValue(ctx)
  31992. if err != nil {
  31993. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31994. }
  31995. return oldValue.UpdatedAt, nil
  31996. }
  31997. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31998. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  31999. m.updated_at = nil
  32000. }
  32001. // SetStatus sets the "status" field.
  32002. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  32003. m.status = &u
  32004. m.addstatus = nil
  32005. }
  32006. // Status returns the value of the "status" field in the mutation.
  32007. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  32008. v := m.status
  32009. if v == nil {
  32010. return
  32011. }
  32012. return *v, true
  32013. }
  32014. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  32015. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32017. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32018. if !m.op.Is(OpUpdateOne) {
  32019. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32020. }
  32021. if m.id == nil || m.oldValue == nil {
  32022. return v, errors.New("OldStatus requires an ID field in the mutation")
  32023. }
  32024. oldValue, err := m.oldValue(ctx)
  32025. if err != nil {
  32026. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32027. }
  32028. return oldValue.Status, nil
  32029. }
  32030. // AddStatus adds u to the "status" field.
  32031. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  32032. if m.addstatus != nil {
  32033. *m.addstatus += u
  32034. } else {
  32035. m.addstatus = &u
  32036. }
  32037. }
  32038. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32039. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  32040. v := m.addstatus
  32041. if v == nil {
  32042. return
  32043. }
  32044. return *v, true
  32045. }
  32046. // ClearStatus clears the value of the "status" field.
  32047. func (m *UsageStatisticHourMutation) ClearStatus() {
  32048. m.status = nil
  32049. m.addstatus = nil
  32050. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  32051. }
  32052. // StatusCleared returns if the "status" field was cleared in this mutation.
  32053. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  32054. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  32055. return ok
  32056. }
  32057. // ResetStatus resets all changes to the "status" field.
  32058. func (m *UsageStatisticHourMutation) ResetStatus() {
  32059. m.status = nil
  32060. m.addstatus = nil
  32061. delete(m.clearedFields, usagestatistichour.FieldStatus)
  32062. }
  32063. // SetDeletedAt sets the "deleted_at" field.
  32064. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  32065. m.deleted_at = &t
  32066. }
  32067. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32068. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  32069. v := m.deleted_at
  32070. if v == nil {
  32071. return
  32072. }
  32073. return *v, true
  32074. }
  32075. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  32076. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32078. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32079. if !m.op.Is(OpUpdateOne) {
  32080. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32081. }
  32082. if m.id == nil || m.oldValue == nil {
  32083. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32084. }
  32085. oldValue, err := m.oldValue(ctx)
  32086. if err != nil {
  32087. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32088. }
  32089. return oldValue.DeletedAt, nil
  32090. }
  32091. // ClearDeletedAt clears the value of the "deleted_at" field.
  32092. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  32093. m.deleted_at = nil
  32094. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  32095. }
  32096. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32097. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  32098. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  32099. return ok
  32100. }
  32101. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32102. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  32103. m.deleted_at = nil
  32104. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  32105. }
  32106. // SetAddtime sets the "addtime" field.
  32107. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  32108. m.addtime = &u
  32109. m.addaddtime = nil
  32110. }
  32111. // Addtime returns the value of the "addtime" field in the mutation.
  32112. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  32113. v := m.addtime
  32114. if v == nil {
  32115. return
  32116. }
  32117. return *v, true
  32118. }
  32119. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  32120. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32122. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32123. if !m.op.Is(OpUpdateOne) {
  32124. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32125. }
  32126. if m.id == nil || m.oldValue == nil {
  32127. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32128. }
  32129. oldValue, err := m.oldValue(ctx)
  32130. if err != nil {
  32131. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32132. }
  32133. return oldValue.Addtime, nil
  32134. }
  32135. // AddAddtime adds u to the "addtime" field.
  32136. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  32137. if m.addaddtime != nil {
  32138. *m.addaddtime += u
  32139. } else {
  32140. m.addaddtime = &u
  32141. }
  32142. }
  32143. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32144. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  32145. v := m.addaddtime
  32146. if v == nil {
  32147. return
  32148. }
  32149. return *v, true
  32150. }
  32151. // ResetAddtime resets all changes to the "addtime" field.
  32152. func (m *UsageStatisticHourMutation) ResetAddtime() {
  32153. m.addtime = nil
  32154. m.addaddtime = nil
  32155. }
  32156. // SetType sets the "type" field.
  32157. func (m *UsageStatisticHourMutation) SetType(i int) {
  32158. m._type = &i
  32159. m.add_type = nil
  32160. }
  32161. // GetType returns the value of the "type" field in the mutation.
  32162. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  32163. v := m._type
  32164. if v == nil {
  32165. return
  32166. }
  32167. return *v, true
  32168. }
  32169. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  32170. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32172. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  32173. if !m.op.Is(OpUpdateOne) {
  32174. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32175. }
  32176. if m.id == nil || m.oldValue == nil {
  32177. return v, errors.New("OldType requires an ID field in the mutation")
  32178. }
  32179. oldValue, err := m.oldValue(ctx)
  32180. if err != nil {
  32181. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32182. }
  32183. return oldValue.Type, nil
  32184. }
  32185. // AddType adds i to the "type" field.
  32186. func (m *UsageStatisticHourMutation) AddType(i int) {
  32187. if m.add_type != nil {
  32188. *m.add_type += i
  32189. } else {
  32190. m.add_type = &i
  32191. }
  32192. }
  32193. // AddedType returns the value that was added to the "type" field in this mutation.
  32194. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  32195. v := m.add_type
  32196. if v == nil {
  32197. return
  32198. }
  32199. return *v, true
  32200. }
  32201. // ResetType resets all changes to the "type" field.
  32202. func (m *UsageStatisticHourMutation) ResetType() {
  32203. m._type = nil
  32204. m.add_type = nil
  32205. }
  32206. // SetBotID sets the "bot_id" field.
  32207. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  32208. m.bot_id = &s
  32209. }
  32210. // BotID returns the value of the "bot_id" field in the mutation.
  32211. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  32212. v := m.bot_id
  32213. if v == nil {
  32214. return
  32215. }
  32216. return *v, true
  32217. }
  32218. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  32219. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32221. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  32222. if !m.op.Is(OpUpdateOne) {
  32223. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32224. }
  32225. if m.id == nil || m.oldValue == nil {
  32226. return v, errors.New("OldBotID requires an ID field in the mutation")
  32227. }
  32228. oldValue, err := m.oldValue(ctx)
  32229. if err != nil {
  32230. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32231. }
  32232. return oldValue.BotID, nil
  32233. }
  32234. // ClearBotID clears the value of the "bot_id" field.
  32235. func (m *UsageStatisticHourMutation) ClearBotID() {
  32236. m.bot_id = nil
  32237. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  32238. }
  32239. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32240. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  32241. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  32242. return ok
  32243. }
  32244. // ResetBotID resets all changes to the "bot_id" field.
  32245. func (m *UsageStatisticHourMutation) ResetBotID() {
  32246. m.bot_id = nil
  32247. delete(m.clearedFields, usagestatistichour.FieldBotID)
  32248. }
  32249. // SetOrganizationID sets the "organization_id" field.
  32250. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  32251. m.organization_id = &u
  32252. m.addorganization_id = nil
  32253. }
  32254. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32255. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  32256. v := m.organization_id
  32257. if v == nil {
  32258. return
  32259. }
  32260. return *v, true
  32261. }
  32262. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  32263. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32265. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32266. if !m.op.Is(OpUpdateOne) {
  32267. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32268. }
  32269. if m.id == nil || m.oldValue == nil {
  32270. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32271. }
  32272. oldValue, err := m.oldValue(ctx)
  32273. if err != nil {
  32274. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32275. }
  32276. return oldValue.OrganizationID, nil
  32277. }
  32278. // AddOrganizationID adds u to the "organization_id" field.
  32279. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  32280. if m.addorganization_id != nil {
  32281. *m.addorganization_id += u
  32282. } else {
  32283. m.addorganization_id = &u
  32284. }
  32285. }
  32286. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32287. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  32288. v := m.addorganization_id
  32289. if v == nil {
  32290. return
  32291. }
  32292. return *v, true
  32293. }
  32294. // ClearOrganizationID clears the value of the "organization_id" field.
  32295. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  32296. m.organization_id = nil
  32297. m.addorganization_id = nil
  32298. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  32299. }
  32300. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32301. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  32302. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  32303. return ok
  32304. }
  32305. // ResetOrganizationID resets all changes to the "organization_id" field.
  32306. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  32307. m.organization_id = nil
  32308. m.addorganization_id = nil
  32309. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  32310. }
  32311. // SetAiResponse sets the "ai_response" field.
  32312. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  32313. m.ai_response = &u
  32314. m.addai_response = nil
  32315. }
  32316. // AiResponse returns the value of the "ai_response" field in the mutation.
  32317. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  32318. v := m.ai_response
  32319. if v == nil {
  32320. return
  32321. }
  32322. return *v, true
  32323. }
  32324. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  32325. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32327. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32328. if !m.op.Is(OpUpdateOne) {
  32329. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32330. }
  32331. if m.id == nil || m.oldValue == nil {
  32332. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32333. }
  32334. oldValue, err := m.oldValue(ctx)
  32335. if err != nil {
  32336. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32337. }
  32338. return oldValue.AiResponse, nil
  32339. }
  32340. // AddAiResponse adds u to the "ai_response" field.
  32341. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  32342. if m.addai_response != nil {
  32343. *m.addai_response += u
  32344. } else {
  32345. m.addai_response = &u
  32346. }
  32347. }
  32348. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32349. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  32350. v := m.addai_response
  32351. if v == nil {
  32352. return
  32353. }
  32354. return *v, true
  32355. }
  32356. // ResetAiResponse resets all changes to the "ai_response" field.
  32357. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  32358. m.ai_response = nil
  32359. m.addai_response = nil
  32360. }
  32361. // SetSopRun sets the "sop_run" field.
  32362. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  32363. m.sop_run = &u
  32364. m.addsop_run = nil
  32365. }
  32366. // SopRun returns the value of the "sop_run" field in the mutation.
  32367. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  32368. v := m.sop_run
  32369. if v == nil {
  32370. return
  32371. }
  32372. return *v, true
  32373. }
  32374. // OldSopRun returns the old "sop_run" 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) OldSopRun(ctx context.Context) (v uint64, err error) {
  32378. if !m.op.Is(OpUpdateOne) {
  32379. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32380. }
  32381. if m.id == nil || m.oldValue == nil {
  32382. return v, errors.New("OldSopRun 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 OldSopRun: %w", err)
  32387. }
  32388. return oldValue.SopRun, nil
  32389. }
  32390. // AddSopRun adds u to the "sop_run" field.
  32391. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  32392. if m.addsop_run != nil {
  32393. *m.addsop_run += u
  32394. } else {
  32395. m.addsop_run = &u
  32396. }
  32397. }
  32398. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32399. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  32400. v := m.addsop_run
  32401. if v == nil {
  32402. return
  32403. }
  32404. return *v, true
  32405. }
  32406. // ResetSopRun resets all changes to the "sop_run" field.
  32407. func (m *UsageStatisticHourMutation) ResetSopRun() {
  32408. m.sop_run = nil
  32409. m.addsop_run = nil
  32410. }
  32411. // SetTotalFriend sets the "total_friend" field.
  32412. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  32413. m.total_friend = &u
  32414. m.addtotal_friend = nil
  32415. }
  32416. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32417. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  32418. v := m.total_friend
  32419. if v == nil {
  32420. return
  32421. }
  32422. return *v, true
  32423. }
  32424. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  32425. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32427. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32428. if !m.op.Is(OpUpdateOne) {
  32429. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32430. }
  32431. if m.id == nil || m.oldValue == nil {
  32432. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32433. }
  32434. oldValue, err := m.oldValue(ctx)
  32435. if err != nil {
  32436. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32437. }
  32438. return oldValue.TotalFriend, nil
  32439. }
  32440. // AddTotalFriend adds u to the "total_friend" field.
  32441. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  32442. if m.addtotal_friend != nil {
  32443. *m.addtotal_friend += u
  32444. } else {
  32445. m.addtotal_friend = &u
  32446. }
  32447. }
  32448. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32449. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  32450. v := m.addtotal_friend
  32451. if v == nil {
  32452. return
  32453. }
  32454. return *v, true
  32455. }
  32456. // ResetTotalFriend resets all changes to the "total_friend" field.
  32457. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  32458. m.total_friend = nil
  32459. m.addtotal_friend = nil
  32460. }
  32461. // SetTotalGroup sets the "total_group" field.
  32462. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  32463. m.total_group = &u
  32464. m.addtotal_group = nil
  32465. }
  32466. // TotalGroup returns the value of the "total_group" field in the mutation.
  32467. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  32468. v := m.total_group
  32469. if v == nil {
  32470. return
  32471. }
  32472. return *v, true
  32473. }
  32474. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  32475. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32477. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32478. if !m.op.Is(OpUpdateOne) {
  32479. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32480. }
  32481. if m.id == nil || m.oldValue == nil {
  32482. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32483. }
  32484. oldValue, err := m.oldValue(ctx)
  32485. if err != nil {
  32486. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32487. }
  32488. return oldValue.TotalGroup, nil
  32489. }
  32490. // AddTotalGroup adds u to the "total_group" field.
  32491. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  32492. if m.addtotal_group != nil {
  32493. *m.addtotal_group += u
  32494. } else {
  32495. m.addtotal_group = &u
  32496. }
  32497. }
  32498. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32499. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  32500. v := m.addtotal_group
  32501. if v == nil {
  32502. return
  32503. }
  32504. return *v, true
  32505. }
  32506. // ResetTotalGroup resets all changes to the "total_group" field.
  32507. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  32508. m.total_group = nil
  32509. m.addtotal_group = nil
  32510. }
  32511. // SetAccountBalance sets the "account_balance" field.
  32512. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  32513. m.account_balance = &u
  32514. m.addaccount_balance = nil
  32515. }
  32516. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32517. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  32518. v := m.account_balance
  32519. if v == nil {
  32520. return
  32521. }
  32522. return *v, true
  32523. }
  32524. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  32525. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32527. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32528. if !m.op.Is(OpUpdateOne) {
  32529. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32530. }
  32531. if m.id == nil || m.oldValue == nil {
  32532. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32533. }
  32534. oldValue, err := m.oldValue(ctx)
  32535. if err != nil {
  32536. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32537. }
  32538. return oldValue.AccountBalance, nil
  32539. }
  32540. // AddAccountBalance adds u to the "account_balance" field.
  32541. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  32542. if m.addaccount_balance != nil {
  32543. *m.addaccount_balance += u
  32544. } else {
  32545. m.addaccount_balance = &u
  32546. }
  32547. }
  32548. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32549. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  32550. v := m.addaccount_balance
  32551. if v == nil {
  32552. return
  32553. }
  32554. return *v, true
  32555. }
  32556. // ResetAccountBalance resets all changes to the "account_balance" field.
  32557. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  32558. m.account_balance = nil
  32559. m.addaccount_balance = nil
  32560. }
  32561. // SetConsumeToken sets the "consume_token" field.
  32562. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  32563. m.consume_token = &u
  32564. m.addconsume_token = nil
  32565. }
  32566. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32567. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  32568. v := m.consume_token
  32569. if v == nil {
  32570. return
  32571. }
  32572. return *v, true
  32573. }
  32574. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  32575. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32577. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32578. if !m.op.Is(OpUpdateOne) {
  32579. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32580. }
  32581. if m.id == nil || m.oldValue == nil {
  32582. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32583. }
  32584. oldValue, err := m.oldValue(ctx)
  32585. if err != nil {
  32586. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32587. }
  32588. return oldValue.ConsumeToken, nil
  32589. }
  32590. // AddConsumeToken adds u to the "consume_token" field.
  32591. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  32592. if m.addconsume_token != nil {
  32593. *m.addconsume_token += u
  32594. } else {
  32595. m.addconsume_token = &u
  32596. }
  32597. }
  32598. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  32599. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  32600. v := m.addconsume_token
  32601. if v == nil {
  32602. return
  32603. }
  32604. return *v, true
  32605. }
  32606. // ResetConsumeToken resets all changes to the "consume_token" field.
  32607. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  32608. m.consume_token = nil
  32609. m.addconsume_token = nil
  32610. }
  32611. // SetActiveUser sets the "active_user" field.
  32612. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  32613. m.active_user = &u
  32614. m.addactive_user = nil
  32615. }
  32616. // ActiveUser returns the value of the "active_user" field in the mutation.
  32617. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  32618. v := m.active_user
  32619. if v == nil {
  32620. return
  32621. }
  32622. return *v, true
  32623. }
  32624. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  32625. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32627. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32628. if !m.op.Is(OpUpdateOne) {
  32629. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32630. }
  32631. if m.id == nil || m.oldValue == nil {
  32632. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32633. }
  32634. oldValue, err := m.oldValue(ctx)
  32635. if err != nil {
  32636. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32637. }
  32638. return oldValue.ActiveUser, nil
  32639. }
  32640. // AddActiveUser adds u to the "active_user" field.
  32641. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  32642. if m.addactive_user != nil {
  32643. *m.addactive_user += u
  32644. } else {
  32645. m.addactive_user = &u
  32646. }
  32647. }
  32648. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32649. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  32650. v := m.addactive_user
  32651. if v == nil {
  32652. return
  32653. }
  32654. return *v, true
  32655. }
  32656. // ResetActiveUser resets all changes to the "active_user" field.
  32657. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  32658. m.active_user = nil
  32659. m.addactive_user = nil
  32660. }
  32661. // SetNewUser sets the "new_user" field.
  32662. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  32663. m.new_user = &i
  32664. m.addnew_user = nil
  32665. }
  32666. // NewUser returns the value of the "new_user" field in the mutation.
  32667. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  32668. v := m.new_user
  32669. if v == nil {
  32670. return
  32671. }
  32672. return *v, true
  32673. }
  32674. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  32675. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32677. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32678. if !m.op.Is(OpUpdateOne) {
  32679. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32680. }
  32681. if m.id == nil || m.oldValue == nil {
  32682. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32683. }
  32684. oldValue, err := m.oldValue(ctx)
  32685. if err != nil {
  32686. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32687. }
  32688. return oldValue.NewUser, nil
  32689. }
  32690. // AddNewUser adds i to the "new_user" field.
  32691. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  32692. if m.addnew_user != nil {
  32693. *m.addnew_user += i
  32694. } else {
  32695. m.addnew_user = &i
  32696. }
  32697. }
  32698. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32699. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  32700. v := m.addnew_user
  32701. if v == nil {
  32702. return
  32703. }
  32704. return *v, true
  32705. }
  32706. // ResetNewUser resets all changes to the "new_user" field.
  32707. func (m *UsageStatisticHourMutation) ResetNewUser() {
  32708. m.new_user = nil
  32709. m.addnew_user = nil
  32710. }
  32711. // SetLabelDist sets the "label_dist" field.
  32712. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32713. m.label_dist = &ctd
  32714. m.appendlabel_dist = nil
  32715. }
  32716. // LabelDist returns the value of the "label_dist" field in the mutation.
  32717. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32718. v := m.label_dist
  32719. if v == nil {
  32720. return
  32721. }
  32722. return *v, true
  32723. }
  32724. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  32725. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32727. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32728. if !m.op.Is(OpUpdateOne) {
  32729. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32730. }
  32731. if m.id == nil || m.oldValue == nil {
  32732. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32733. }
  32734. oldValue, err := m.oldValue(ctx)
  32735. if err != nil {
  32736. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32737. }
  32738. return oldValue.LabelDist, nil
  32739. }
  32740. // AppendLabelDist adds ctd to the "label_dist" field.
  32741. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32742. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32743. }
  32744. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32745. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32746. if len(m.appendlabel_dist) == 0 {
  32747. return nil, false
  32748. }
  32749. return m.appendlabel_dist, true
  32750. }
  32751. // ResetLabelDist resets all changes to the "label_dist" field.
  32752. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  32753. m.label_dist = nil
  32754. m.appendlabel_dist = nil
  32755. }
  32756. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  32757. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  32758. m.predicates = append(m.predicates, ps...)
  32759. }
  32760. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  32761. // users can use type-assertion to append predicates that do not depend on any generated package.
  32762. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  32763. p := make([]predicate.UsageStatisticHour, len(ps))
  32764. for i := range ps {
  32765. p[i] = ps[i]
  32766. }
  32767. m.Where(p...)
  32768. }
  32769. // Op returns the operation name.
  32770. func (m *UsageStatisticHourMutation) Op() Op {
  32771. return m.op
  32772. }
  32773. // SetOp allows setting the mutation operation.
  32774. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  32775. m.op = op
  32776. }
  32777. // Type returns the node type of this mutation (UsageStatisticHour).
  32778. func (m *UsageStatisticHourMutation) Type() string {
  32779. return m.typ
  32780. }
  32781. // Fields returns all fields that were changed during this mutation. Note that in
  32782. // order to get all numeric fields that were incremented/decremented, call
  32783. // AddedFields().
  32784. func (m *UsageStatisticHourMutation) Fields() []string {
  32785. fields := make([]string, 0, 17)
  32786. if m.created_at != nil {
  32787. fields = append(fields, usagestatistichour.FieldCreatedAt)
  32788. }
  32789. if m.updated_at != nil {
  32790. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  32791. }
  32792. if m.status != nil {
  32793. fields = append(fields, usagestatistichour.FieldStatus)
  32794. }
  32795. if m.deleted_at != nil {
  32796. fields = append(fields, usagestatistichour.FieldDeletedAt)
  32797. }
  32798. if m.addtime != nil {
  32799. fields = append(fields, usagestatistichour.FieldAddtime)
  32800. }
  32801. if m._type != nil {
  32802. fields = append(fields, usagestatistichour.FieldType)
  32803. }
  32804. if m.bot_id != nil {
  32805. fields = append(fields, usagestatistichour.FieldBotID)
  32806. }
  32807. if m.organization_id != nil {
  32808. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32809. }
  32810. if m.ai_response != nil {
  32811. fields = append(fields, usagestatistichour.FieldAiResponse)
  32812. }
  32813. if m.sop_run != nil {
  32814. fields = append(fields, usagestatistichour.FieldSopRun)
  32815. }
  32816. if m.total_friend != nil {
  32817. fields = append(fields, usagestatistichour.FieldTotalFriend)
  32818. }
  32819. if m.total_group != nil {
  32820. fields = append(fields, usagestatistichour.FieldTotalGroup)
  32821. }
  32822. if m.account_balance != nil {
  32823. fields = append(fields, usagestatistichour.FieldAccountBalance)
  32824. }
  32825. if m.consume_token != nil {
  32826. fields = append(fields, usagestatistichour.FieldConsumeToken)
  32827. }
  32828. if m.active_user != nil {
  32829. fields = append(fields, usagestatistichour.FieldActiveUser)
  32830. }
  32831. if m.new_user != nil {
  32832. fields = append(fields, usagestatistichour.FieldNewUser)
  32833. }
  32834. if m.label_dist != nil {
  32835. fields = append(fields, usagestatistichour.FieldLabelDist)
  32836. }
  32837. return fields
  32838. }
  32839. // Field returns the value of a field with the given name. The second boolean
  32840. // return value indicates that this field was not set, or was not defined in the
  32841. // schema.
  32842. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  32843. switch name {
  32844. case usagestatistichour.FieldCreatedAt:
  32845. return m.CreatedAt()
  32846. case usagestatistichour.FieldUpdatedAt:
  32847. return m.UpdatedAt()
  32848. case usagestatistichour.FieldStatus:
  32849. return m.Status()
  32850. case usagestatistichour.FieldDeletedAt:
  32851. return m.DeletedAt()
  32852. case usagestatistichour.FieldAddtime:
  32853. return m.Addtime()
  32854. case usagestatistichour.FieldType:
  32855. return m.GetType()
  32856. case usagestatistichour.FieldBotID:
  32857. return m.BotID()
  32858. case usagestatistichour.FieldOrganizationID:
  32859. return m.OrganizationID()
  32860. case usagestatistichour.FieldAiResponse:
  32861. return m.AiResponse()
  32862. case usagestatistichour.FieldSopRun:
  32863. return m.SopRun()
  32864. case usagestatistichour.FieldTotalFriend:
  32865. return m.TotalFriend()
  32866. case usagestatistichour.FieldTotalGroup:
  32867. return m.TotalGroup()
  32868. case usagestatistichour.FieldAccountBalance:
  32869. return m.AccountBalance()
  32870. case usagestatistichour.FieldConsumeToken:
  32871. return m.ConsumeToken()
  32872. case usagestatistichour.FieldActiveUser:
  32873. return m.ActiveUser()
  32874. case usagestatistichour.FieldNewUser:
  32875. return m.NewUser()
  32876. case usagestatistichour.FieldLabelDist:
  32877. return m.LabelDist()
  32878. }
  32879. return nil, false
  32880. }
  32881. // OldField returns the old value of the field from the database. An error is
  32882. // returned if the mutation operation is not UpdateOne, or the query to the
  32883. // database failed.
  32884. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32885. switch name {
  32886. case usagestatistichour.FieldCreatedAt:
  32887. return m.OldCreatedAt(ctx)
  32888. case usagestatistichour.FieldUpdatedAt:
  32889. return m.OldUpdatedAt(ctx)
  32890. case usagestatistichour.FieldStatus:
  32891. return m.OldStatus(ctx)
  32892. case usagestatistichour.FieldDeletedAt:
  32893. return m.OldDeletedAt(ctx)
  32894. case usagestatistichour.FieldAddtime:
  32895. return m.OldAddtime(ctx)
  32896. case usagestatistichour.FieldType:
  32897. return m.OldType(ctx)
  32898. case usagestatistichour.FieldBotID:
  32899. return m.OldBotID(ctx)
  32900. case usagestatistichour.FieldOrganizationID:
  32901. return m.OldOrganizationID(ctx)
  32902. case usagestatistichour.FieldAiResponse:
  32903. return m.OldAiResponse(ctx)
  32904. case usagestatistichour.FieldSopRun:
  32905. return m.OldSopRun(ctx)
  32906. case usagestatistichour.FieldTotalFriend:
  32907. return m.OldTotalFriend(ctx)
  32908. case usagestatistichour.FieldTotalGroup:
  32909. return m.OldTotalGroup(ctx)
  32910. case usagestatistichour.FieldAccountBalance:
  32911. return m.OldAccountBalance(ctx)
  32912. case usagestatistichour.FieldConsumeToken:
  32913. return m.OldConsumeToken(ctx)
  32914. case usagestatistichour.FieldActiveUser:
  32915. return m.OldActiveUser(ctx)
  32916. case usagestatistichour.FieldNewUser:
  32917. return m.OldNewUser(ctx)
  32918. case usagestatistichour.FieldLabelDist:
  32919. return m.OldLabelDist(ctx)
  32920. }
  32921. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  32922. }
  32923. // SetField sets the value of a field with the given name. It returns an error if
  32924. // the field is not defined in the schema, or if the type mismatched the field
  32925. // type.
  32926. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  32927. switch name {
  32928. case usagestatistichour.FieldCreatedAt:
  32929. v, ok := value.(time.Time)
  32930. if !ok {
  32931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32932. }
  32933. m.SetCreatedAt(v)
  32934. return nil
  32935. case usagestatistichour.FieldUpdatedAt:
  32936. v, ok := value.(time.Time)
  32937. if !ok {
  32938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32939. }
  32940. m.SetUpdatedAt(v)
  32941. return nil
  32942. case usagestatistichour.FieldStatus:
  32943. v, ok := value.(uint8)
  32944. if !ok {
  32945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32946. }
  32947. m.SetStatus(v)
  32948. return nil
  32949. case usagestatistichour.FieldDeletedAt:
  32950. v, ok := value.(time.Time)
  32951. if !ok {
  32952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32953. }
  32954. m.SetDeletedAt(v)
  32955. return nil
  32956. case usagestatistichour.FieldAddtime:
  32957. v, ok := value.(uint64)
  32958. if !ok {
  32959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32960. }
  32961. m.SetAddtime(v)
  32962. return nil
  32963. case usagestatistichour.FieldType:
  32964. v, ok := value.(int)
  32965. if !ok {
  32966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32967. }
  32968. m.SetType(v)
  32969. return nil
  32970. case usagestatistichour.FieldBotID:
  32971. v, ok := value.(string)
  32972. if !ok {
  32973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32974. }
  32975. m.SetBotID(v)
  32976. return nil
  32977. case usagestatistichour.FieldOrganizationID:
  32978. v, ok := value.(uint64)
  32979. if !ok {
  32980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32981. }
  32982. m.SetOrganizationID(v)
  32983. return nil
  32984. case usagestatistichour.FieldAiResponse:
  32985. v, ok := value.(uint64)
  32986. if !ok {
  32987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32988. }
  32989. m.SetAiResponse(v)
  32990. return nil
  32991. case usagestatistichour.FieldSopRun:
  32992. v, ok := value.(uint64)
  32993. if !ok {
  32994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32995. }
  32996. m.SetSopRun(v)
  32997. return nil
  32998. case usagestatistichour.FieldTotalFriend:
  32999. v, ok := value.(uint64)
  33000. if !ok {
  33001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33002. }
  33003. m.SetTotalFriend(v)
  33004. return nil
  33005. case usagestatistichour.FieldTotalGroup:
  33006. v, ok := value.(uint64)
  33007. if !ok {
  33008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33009. }
  33010. m.SetTotalGroup(v)
  33011. return nil
  33012. case usagestatistichour.FieldAccountBalance:
  33013. v, ok := value.(uint64)
  33014. if !ok {
  33015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33016. }
  33017. m.SetAccountBalance(v)
  33018. return nil
  33019. case usagestatistichour.FieldConsumeToken:
  33020. v, ok := value.(uint64)
  33021. if !ok {
  33022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33023. }
  33024. m.SetConsumeToken(v)
  33025. return nil
  33026. case usagestatistichour.FieldActiveUser:
  33027. v, ok := value.(uint64)
  33028. if !ok {
  33029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33030. }
  33031. m.SetActiveUser(v)
  33032. return nil
  33033. case usagestatistichour.FieldNewUser:
  33034. v, ok := value.(int64)
  33035. if !ok {
  33036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33037. }
  33038. m.SetNewUser(v)
  33039. return nil
  33040. case usagestatistichour.FieldLabelDist:
  33041. v, ok := value.([]custom_types.LabelDist)
  33042. if !ok {
  33043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33044. }
  33045. m.SetLabelDist(v)
  33046. return nil
  33047. }
  33048. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33049. }
  33050. // AddedFields returns all numeric fields that were incremented/decremented during
  33051. // this mutation.
  33052. func (m *UsageStatisticHourMutation) AddedFields() []string {
  33053. var fields []string
  33054. if m.addstatus != nil {
  33055. fields = append(fields, usagestatistichour.FieldStatus)
  33056. }
  33057. if m.addaddtime != nil {
  33058. fields = append(fields, usagestatistichour.FieldAddtime)
  33059. }
  33060. if m.add_type != nil {
  33061. fields = append(fields, usagestatistichour.FieldType)
  33062. }
  33063. if m.addorganization_id != nil {
  33064. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33065. }
  33066. if m.addai_response != nil {
  33067. fields = append(fields, usagestatistichour.FieldAiResponse)
  33068. }
  33069. if m.addsop_run != nil {
  33070. fields = append(fields, usagestatistichour.FieldSopRun)
  33071. }
  33072. if m.addtotal_friend != nil {
  33073. fields = append(fields, usagestatistichour.FieldTotalFriend)
  33074. }
  33075. if m.addtotal_group != nil {
  33076. fields = append(fields, usagestatistichour.FieldTotalGroup)
  33077. }
  33078. if m.addaccount_balance != nil {
  33079. fields = append(fields, usagestatistichour.FieldAccountBalance)
  33080. }
  33081. if m.addconsume_token != nil {
  33082. fields = append(fields, usagestatistichour.FieldConsumeToken)
  33083. }
  33084. if m.addactive_user != nil {
  33085. fields = append(fields, usagestatistichour.FieldActiveUser)
  33086. }
  33087. if m.addnew_user != nil {
  33088. fields = append(fields, usagestatistichour.FieldNewUser)
  33089. }
  33090. return fields
  33091. }
  33092. // AddedField returns the numeric value that was incremented/decremented on a field
  33093. // with the given name. The second boolean return value indicates that this field
  33094. // was not set, or was not defined in the schema.
  33095. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  33096. switch name {
  33097. case usagestatistichour.FieldStatus:
  33098. return m.AddedStatus()
  33099. case usagestatistichour.FieldAddtime:
  33100. return m.AddedAddtime()
  33101. case usagestatistichour.FieldType:
  33102. return m.AddedType()
  33103. case usagestatistichour.FieldOrganizationID:
  33104. return m.AddedOrganizationID()
  33105. case usagestatistichour.FieldAiResponse:
  33106. return m.AddedAiResponse()
  33107. case usagestatistichour.FieldSopRun:
  33108. return m.AddedSopRun()
  33109. case usagestatistichour.FieldTotalFriend:
  33110. return m.AddedTotalFriend()
  33111. case usagestatistichour.FieldTotalGroup:
  33112. return m.AddedTotalGroup()
  33113. case usagestatistichour.FieldAccountBalance:
  33114. return m.AddedAccountBalance()
  33115. case usagestatistichour.FieldConsumeToken:
  33116. return m.AddedConsumeToken()
  33117. case usagestatistichour.FieldActiveUser:
  33118. return m.AddedActiveUser()
  33119. case usagestatistichour.FieldNewUser:
  33120. return m.AddedNewUser()
  33121. }
  33122. return nil, false
  33123. }
  33124. // AddField adds the value to the field with the given name. It returns an error if
  33125. // the field is not defined in the schema, or if the type mismatched the field
  33126. // type.
  33127. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  33128. switch name {
  33129. case usagestatistichour.FieldStatus:
  33130. v, ok := value.(int8)
  33131. if !ok {
  33132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33133. }
  33134. m.AddStatus(v)
  33135. return nil
  33136. case usagestatistichour.FieldAddtime:
  33137. v, ok := value.(int64)
  33138. if !ok {
  33139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33140. }
  33141. m.AddAddtime(v)
  33142. return nil
  33143. case usagestatistichour.FieldType:
  33144. v, ok := value.(int)
  33145. if !ok {
  33146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33147. }
  33148. m.AddType(v)
  33149. return nil
  33150. case usagestatistichour.FieldOrganizationID:
  33151. v, ok := value.(int64)
  33152. if !ok {
  33153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33154. }
  33155. m.AddOrganizationID(v)
  33156. return nil
  33157. case usagestatistichour.FieldAiResponse:
  33158. v, ok := value.(int64)
  33159. if !ok {
  33160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33161. }
  33162. m.AddAiResponse(v)
  33163. return nil
  33164. case usagestatistichour.FieldSopRun:
  33165. v, ok := value.(int64)
  33166. if !ok {
  33167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33168. }
  33169. m.AddSopRun(v)
  33170. return nil
  33171. case usagestatistichour.FieldTotalFriend:
  33172. v, ok := value.(int64)
  33173. if !ok {
  33174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33175. }
  33176. m.AddTotalFriend(v)
  33177. return nil
  33178. case usagestatistichour.FieldTotalGroup:
  33179. v, ok := value.(int64)
  33180. if !ok {
  33181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33182. }
  33183. m.AddTotalGroup(v)
  33184. return nil
  33185. case usagestatistichour.FieldAccountBalance:
  33186. v, ok := value.(int64)
  33187. if !ok {
  33188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33189. }
  33190. m.AddAccountBalance(v)
  33191. return nil
  33192. case usagestatistichour.FieldConsumeToken:
  33193. v, ok := value.(int64)
  33194. if !ok {
  33195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33196. }
  33197. m.AddConsumeToken(v)
  33198. return nil
  33199. case usagestatistichour.FieldActiveUser:
  33200. v, ok := value.(int64)
  33201. if !ok {
  33202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33203. }
  33204. m.AddActiveUser(v)
  33205. return nil
  33206. case usagestatistichour.FieldNewUser:
  33207. v, ok := value.(int64)
  33208. if !ok {
  33209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33210. }
  33211. m.AddNewUser(v)
  33212. return nil
  33213. }
  33214. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  33215. }
  33216. // ClearedFields returns all nullable fields that were cleared during this
  33217. // mutation.
  33218. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  33219. var fields []string
  33220. if m.FieldCleared(usagestatistichour.FieldStatus) {
  33221. fields = append(fields, usagestatistichour.FieldStatus)
  33222. }
  33223. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  33224. fields = append(fields, usagestatistichour.FieldDeletedAt)
  33225. }
  33226. if m.FieldCleared(usagestatistichour.FieldBotID) {
  33227. fields = append(fields, usagestatistichour.FieldBotID)
  33228. }
  33229. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  33230. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33231. }
  33232. return fields
  33233. }
  33234. // FieldCleared returns a boolean indicating if a field with the given name was
  33235. // cleared in this mutation.
  33236. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  33237. _, ok := m.clearedFields[name]
  33238. return ok
  33239. }
  33240. // ClearField clears the value of the field with the given name. It returns an
  33241. // error if the field is not defined in the schema.
  33242. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  33243. switch name {
  33244. case usagestatistichour.FieldStatus:
  33245. m.ClearStatus()
  33246. return nil
  33247. case usagestatistichour.FieldDeletedAt:
  33248. m.ClearDeletedAt()
  33249. return nil
  33250. case usagestatistichour.FieldBotID:
  33251. m.ClearBotID()
  33252. return nil
  33253. case usagestatistichour.FieldOrganizationID:
  33254. m.ClearOrganizationID()
  33255. return nil
  33256. }
  33257. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  33258. }
  33259. // ResetField resets all changes in the mutation for the field with the given name.
  33260. // It returns an error if the field is not defined in the schema.
  33261. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  33262. switch name {
  33263. case usagestatistichour.FieldCreatedAt:
  33264. m.ResetCreatedAt()
  33265. return nil
  33266. case usagestatistichour.FieldUpdatedAt:
  33267. m.ResetUpdatedAt()
  33268. return nil
  33269. case usagestatistichour.FieldStatus:
  33270. m.ResetStatus()
  33271. return nil
  33272. case usagestatistichour.FieldDeletedAt:
  33273. m.ResetDeletedAt()
  33274. return nil
  33275. case usagestatistichour.FieldAddtime:
  33276. m.ResetAddtime()
  33277. return nil
  33278. case usagestatistichour.FieldType:
  33279. m.ResetType()
  33280. return nil
  33281. case usagestatistichour.FieldBotID:
  33282. m.ResetBotID()
  33283. return nil
  33284. case usagestatistichour.FieldOrganizationID:
  33285. m.ResetOrganizationID()
  33286. return nil
  33287. case usagestatistichour.FieldAiResponse:
  33288. m.ResetAiResponse()
  33289. return nil
  33290. case usagestatistichour.FieldSopRun:
  33291. m.ResetSopRun()
  33292. return nil
  33293. case usagestatistichour.FieldTotalFriend:
  33294. m.ResetTotalFriend()
  33295. return nil
  33296. case usagestatistichour.FieldTotalGroup:
  33297. m.ResetTotalGroup()
  33298. return nil
  33299. case usagestatistichour.FieldAccountBalance:
  33300. m.ResetAccountBalance()
  33301. return nil
  33302. case usagestatistichour.FieldConsumeToken:
  33303. m.ResetConsumeToken()
  33304. return nil
  33305. case usagestatistichour.FieldActiveUser:
  33306. m.ResetActiveUser()
  33307. return nil
  33308. case usagestatistichour.FieldNewUser:
  33309. m.ResetNewUser()
  33310. return nil
  33311. case usagestatistichour.FieldLabelDist:
  33312. m.ResetLabelDist()
  33313. return nil
  33314. }
  33315. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33316. }
  33317. // AddedEdges returns all edge names that were set/added in this mutation.
  33318. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  33319. edges := make([]string, 0, 0)
  33320. return edges
  33321. }
  33322. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33323. // name in this mutation.
  33324. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  33325. return nil
  33326. }
  33327. // RemovedEdges returns all edge names that were removed in this mutation.
  33328. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  33329. edges := make([]string, 0, 0)
  33330. return edges
  33331. }
  33332. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33333. // the given name in this mutation.
  33334. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  33335. return nil
  33336. }
  33337. // ClearedEdges returns all edge names that were cleared in this mutation.
  33338. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  33339. edges := make([]string, 0, 0)
  33340. return edges
  33341. }
  33342. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33343. // was cleared in this mutation.
  33344. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  33345. return false
  33346. }
  33347. // ClearEdge clears the value of the edge with the given name. It returns an error
  33348. // if that edge is not defined in the schema.
  33349. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  33350. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  33351. }
  33352. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33353. // It returns an error if the edge is not defined in the schema.
  33354. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  33355. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  33356. }
  33357. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  33358. type UsageStatisticMonthMutation struct {
  33359. config
  33360. op Op
  33361. typ string
  33362. id *uint64
  33363. created_at *time.Time
  33364. updated_at *time.Time
  33365. status *uint8
  33366. addstatus *int8
  33367. deleted_at *time.Time
  33368. addtime *uint64
  33369. addaddtime *int64
  33370. _type *int
  33371. add_type *int
  33372. bot_id *string
  33373. organization_id *uint64
  33374. addorganization_id *int64
  33375. ai_response *uint64
  33376. addai_response *int64
  33377. sop_run *uint64
  33378. addsop_run *int64
  33379. total_friend *uint64
  33380. addtotal_friend *int64
  33381. total_group *uint64
  33382. addtotal_group *int64
  33383. account_balance *uint64
  33384. addaccount_balance *int64
  33385. consume_token *uint64
  33386. addconsume_token *int64
  33387. active_user *uint64
  33388. addactive_user *int64
  33389. new_user *int64
  33390. addnew_user *int64
  33391. label_dist *[]custom_types.LabelDist
  33392. appendlabel_dist []custom_types.LabelDist
  33393. clearedFields map[string]struct{}
  33394. done bool
  33395. oldValue func(context.Context) (*UsageStatisticMonth, error)
  33396. predicates []predicate.UsageStatisticMonth
  33397. }
  33398. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  33399. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  33400. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  33401. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  33402. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  33403. m := &UsageStatisticMonthMutation{
  33404. config: c,
  33405. op: op,
  33406. typ: TypeUsageStatisticMonth,
  33407. clearedFields: make(map[string]struct{}),
  33408. }
  33409. for _, opt := range opts {
  33410. opt(m)
  33411. }
  33412. return m
  33413. }
  33414. // withUsageStatisticMonthID sets the ID field of the mutation.
  33415. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  33416. return func(m *UsageStatisticMonthMutation) {
  33417. var (
  33418. err error
  33419. once sync.Once
  33420. value *UsageStatisticMonth
  33421. )
  33422. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  33423. once.Do(func() {
  33424. if m.done {
  33425. err = errors.New("querying old values post mutation is not allowed")
  33426. } else {
  33427. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  33428. }
  33429. })
  33430. return value, err
  33431. }
  33432. m.id = &id
  33433. }
  33434. }
  33435. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  33436. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  33437. return func(m *UsageStatisticMonthMutation) {
  33438. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  33439. return node, nil
  33440. }
  33441. m.id = &node.ID
  33442. }
  33443. }
  33444. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33445. // executed in a transaction (ent.Tx), a transactional client is returned.
  33446. func (m UsageStatisticMonthMutation) Client() *Client {
  33447. client := &Client{config: m.config}
  33448. client.init()
  33449. return client
  33450. }
  33451. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33452. // it returns an error otherwise.
  33453. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  33454. if _, ok := m.driver.(*txDriver); !ok {
  33455. return nil, errors.New("ent: mutation is not running in a transaction")
  33456. }
  33457. tx := &Tx{config: m.config}
  33458. tx.init()
  33459. return tx, nil
  33460. }
  33461. // SetID sets the value of the id field. Note that this
  33462. // operation is only accepted on creation of UsageStatisticMonth entities.
  33463. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  33464. m.id = &id
  33465. }
  33466. // ID returns the ID value in the mutation. Note that the ID is only available
  33467. // if it was provided to the builder or after it was returned from the database.
  33468. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  33469. if m.id == nil {
  33470. return
  33471. }
  33472. return *m.id, true
  33473. }
  33474. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33475. // That means, if the mutation is applied within a transaction with an isolation level such
  33476. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33477. // or updated by the mutation.
  33478. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  33479. switch {
  33480. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33481. id, exists := m.ID()
  33482. if exists {
  33483. return []uint64{id}, nil
  33484. }
  33485. fallthrough
  33486. case m.op.Is(OpUpdate | OpDelete):
  33487. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  33488. default:
  33489. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33490. }
  33491. }
  33492. // SetCreatedAt sets the "created_at" field.
  33493. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  33494. m.created_at = &t
  33495. }
  33496. // CreatedAt returns the value of the "created_at" field in the mutation.
  33497. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  33498. v := m.created_at
  33499. if v == nil {
  33500. return
  33501. }
  33502. return *v, true
  33503. }
  33504. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  33505. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33507. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33508. if !m.op.Is(OpUpdateOne) {
  33509. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33510. }
  33511. if m.id == nil || m.oldValue == nil {
  33512. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33513. }
  33514. oldValue, err := m.oldValue(ctx)
  33515. if err != nil {
  33516. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33517. }
  33518. return oldValue.CreatedAt, nil
  33519. }
  33520. // ResetCreatedAt resets all changes to the "created_at" field.
  33521. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  33522. m.created_at = nil
  33523. }
  33524. // SetUpdatedAt sets the "updated_at" field.
  33525. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  33526. m.updated_at = &t
  33527. }
  33528. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33529. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  33530. v := m.updated_at
  33531. if v == nil {
  33532. return
  33533. }
  33534. return *v, true
  33535. }
  33536. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  33537. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33539. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33540. if !m.op.Is(OpUpdateOne) {
  33541. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33542. }
  33543. if m.id == nil || m.oldValue == nil {
  33544. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33545. }
  33546. oldValue, err := m.oldValue(ctx)
  33547. if err != nil {
  33548. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33549. }
  33550. return oldValue.UpdatedAt, nil
  33551. }
  33552. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33553. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  33554. m.updated_at = nil
  33555. }
  33556. // SetStatus sets the "status" field.
  33557. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  33558. m.status = &u
  33559. m.addstatus = nil
  33560. }
  33561. // Status returns the value of the "status" field in the mutation.
  33562. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  33563. v := m.status
  33564. if v == nil {
  33565. return
  33566. }
  33567. return *v, true
  33568. }
  33569. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  33570. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33572. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33573. if !m.op.Is(OpUpdateOne) {
  33574. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33575. }
  33576. if m.id == nil || m.oldValue == nil {
  33577. return v, errors.New("OldStatus requires an ID field in the mutation")
  33578. }
  33579. oldValue, err := m.oldValue(ctx)
  33580. if err != nil {
  33581. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33582. }
  33583. return oldValue.Status, nil
  33584. }
  33585. // AddStatus adds u to the "status" field.
  33586. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  33587. if m.addstatus != nil {
  33588. *m.addstatus += u
  33589. } else {
  33590. m.addstatus = &u
  33591. }
  33592. }
  33593. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33594. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  33595. v := m.addstatus
  33596. if v == nil {
  33597. return
  33598. }
  33599. return *v, true
  33600. }
  33601. // ClearStatus clears the value of the "status" field.
  33602. func (m *UsageStatisticMonthMutation) ClearStatus() {
  33603. m.status = nil
  33604. m.addstatus = nil
  33605. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  33606. }
  33607. // StatusCleared returns if the "status" field was cleared in this mutation.
  33608. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  33609. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  33610. return ok
  33611. }
  33612. // ResetStatus resets all changes to the "status" field.
  33613. func (m *UsageStatisticMonthMutation) ResetStatus() {
  33614. m.status = nil
  33615. m.addstatus = nil
  33616. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  33617. }
  33618. // SetDeletedAt sets the "deleted_at" field.
  33619. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  33620. m.deleted_at = &t
  33621. }
  33622. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33623. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  33624. v := m.deleted_at
  33625. if v == nil {
  33626. return
  33627. }
  33628. return *v, true
  33629. }
  33630. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  33631. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33633. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33634. if !m.op.Is(OpUpdateOne) {
  33635. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33636. }
  33637. if m.id == nil || m.oldValue == nil {
  33638. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33639. }
  33640. oldValue, err := m.oldValue(ctx)
  33641. if err != nil {
  33642. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33643. }
  33644. return oldValue.DeletedAt, nil
  33645. }
  33646. // ClearDeletedAt clears the value of the "deleted_at" field.
  33647. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  33648. m.deleted_at = nil
  33649. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  33650. }
  33651. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33652. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  33653. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  33654. return ok
  33655. }
  33656. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33657. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  33658. m.deleted_at = nil
  33659. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  33660. }
  33661. // SetAddtime sets the "addtime" field.
  33662. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  33663. m.addtime = &u
  33664. m.addaddtime = nil
  33665. }
  33666. // Addtime returns the value of the "addtime" field in the mutation.
  33667. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  33668. v := m.addtime
  33669. if v == nil {
  33670. return
  33671. }
  33672. return *v, true
  33673. }
  33674. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  33675. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33677. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  33678. if !m.op.Is(OpUpdateOne) {
  33679. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  33680. }
  33681. if m.id == nil || m.oldValue == nil {
  33682. return v, errors.New("OldAddtime requires an ID field in the mutation")
  33683. }
  33684. oldValue, err := m.oldValue(ctx)
  33685. if err != nil {
  33686. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  33687. }
  33688. return oldValue.Addtime, nil
  33689. }
  33690. // AddAddtime adds u to the "addtime" field.
  33691. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  33692. if m.addaddtime != nil {
  33693. *m.addaddtime += u
  33694. } else {
  33695. m.addaddtime = &u
  33696. }
  33697. }
  33698. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  33699. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  33700. v := m.addaddtime
  33701. if v == nil {
  33702. return
  33703. }
  33704. return *v, true
  33705. }
  33706. // ResetAddtime resets all changes to the "addtime" field.
  33707. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  33708. m.addtime = nil
  33709. m.addaddtime = nil
  33710. }
  33711. // SetType sets the "type" field.
  33712. func (m *UsageStatisticMonthMutation) SetType(i int) {
  33713. m._type = &i
  33714. m.add_type = nil
  33715. }
  33716. // GetType returns the value of the "type" field in the mutation.
  33717. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  33718. v := m._type
  33719. if v == nil {
  33720. return
  33721. }
  33722. return *v, true
  33723. }
  33724. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  33725. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33727. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  33728. if !m.op.Is(OpUpdateOne) {
  33729. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33730. }
  33731. if m.id == nil || m.oldValue == nil {
  33732. return v, errors.New("OldType requires an ID field in the mutation")
  33733. }
  33734. oldValue, err := m.oldValue(ctx)
  33735. if err != nil {
  33736. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33737. }
  33738. return oldValue.Type, nil
  33739. }
  33740. // AddType adds i to the "type" field.
  33741. func (m *UsageStatisticMonthMutation) AddType(i int) {
  33742. if m.add_type != nil {
  33743. *m.add_type += i
  33744. } else {
  33745. m.add_type = &i
  33746. }
  33747. }
  33748. // AddedType returns the value that was added to the "type" field in this mutation.
  33749. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  33750. v := m.add_type
  33751. if v == nil {
  33752. return
  33753. }
  33754. return *v, true
  33755. }
  33756. // ResetType resets all changes to the "type" field.
  33757. func (m *UsageStatisticMonthMutation) ResetType() {
  33758. m._type = nil
  33759. m.add_type = nil
  33760. }
  33761. // SetBotID sets the "bot_id" field.
  33762. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  33763. m.bot_id = &s
  33764. }
  33765. // BotID returns the value of the "bot_id" field in the mutation.
  33766. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  33767. v := m.bot_id
  33768. if v == nil {
  33769. return
  33770. }
  33771. return *v, true
  33772. }
  33773. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  33774. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33776. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  33777. if !m.op.Is(OpUpdateOne) {
  33778. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33779. }
  33780. if m.id == nil || m.oldValue == nil {
  33781. return v, errors.New("OldBotID requires an ID field in the mutation")
  33782. }
  33783. oldValue, err := m.oldValue(ctx)
  33784. if err != nil {
  33785. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33786. }
  33787. return oldValue.BotID, nil
  33788. }
  33789. // ClearBotID clears the value of the "bot_id" field.
  33790. func (m *UsageStatisticMonthMutation) ClearBotID() {
  33791. m.bot_id = nil
  33792. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  33793. }
  33794. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  33795. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  33796. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  33797. return ok
  33798. }
  33799. // ResetBotID resets all changes to the "bot_id" field.
  33800. func (m *UsageStatisticMonthMutation) ResetBotID() {
  33801. m.bot_id = nil
  33802. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  33803. }
  33804. // SetOrganizationID sets the "organization_id" field.
  33805. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  33806. m.organization_id = &u
  33807. m.addorganization_id = nil
  33808. }
  33809. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33810. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  33811. v := m.organization_id
  33812. if v == nil {
  33813. return
  33814. }
  33815. return *v, true
  33816. }
  33817. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  33818. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33820. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33821. if !m.op.Is(OpUpdateOne) {
  33822. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33823. }
  33824. if m.id == nil || m.oldValue == nil {
  33825. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33826. }
  33827. oldValue, err := m.oldValue(ctx)
  33828. if err != nil {
  33829. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33830. }
  33831. return oldValue.OrganizationID, nil
  33832. }
  33833. // AddOrganizationID adds u to the "organization_id" field.
  33834. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  33835. if m.addorganization_id != nil {
  33836. *m.addorganization_id += u
  33837. } else {
  33838. m.addorganization_id = &u
  33839. }
  33840. }
  33841. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33842. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  33843. v := m.addorganization_id
  33844. if v == nil {
  33845. return
  33846. }
  33847. return *v, true
  33848. }
  33849. // ClearOrganizationID clears the value of the "organization_id" field.
  33850. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  33851. m.organization_id = nil
  33852. m.addorganization_id = nil
  33853. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  33854. }
  33855. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33856. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  33857. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  33858. return ok
  33859. }
  33860. // ResetOrganizationID resets all changes to the "organization_id" field.
  33861. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  33862. m.organization_id = nil
  33863. m.addorganization_id = nil
  33864. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  33865. }
  33866. // SetAiResponse sets the "ai_response" field.
  33867. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  33868. m.ai_response = &u
  33869. m.addai_response = nil
  33870. }
  33871. // AiResponse returns the value of the "ai_response" field in the mutation.
  33872. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  33873. v := m.ai_response
  33874. if v == nil {
  33875. return
  33876. }
  33877. return *v, true
  33878. }
  33879. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  33880. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33882. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  33883. if !m.op.Is(OpUpdateOne) {
  33884. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  33885. }
  33886. if m.id == nil || m.oldValue == nil {
  33887. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  33888. }
  33889. oldValue, err := m.oldValue(ctx)
  33890. if err != nil {
  33891. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  33892. }
  33893. return oldValue.AiResponse, nil
  33894. }
  33895. // AddAiResponse adds u to the "ai_response" field.
  33896. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  33897. if m.addai_response != nil {
  33898. *m.addai_response += u
  33899. } else {
  33900. m.addai_response = &u
  33901. }
  33902. }
  33903. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  33904. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  33905. v := m.addai_response
  33906. if v == nil {
  33907. return
  33908. }
  33909. return *v, true
  33910. }
  33911. // ResetAiResponse resets all changes to the "ai_response" field.
  33912. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  33913. m.ai_response = nil
  33914. m.addai_response = nil
  33915. }
  33916. // SetSopRun sets the "sop_run" field.
  33917. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  33918. m.sop_run = &u
  33919. m.addsop_run = nil
  33920. }
  33921. // SopRun returns the value of the "sop_run" field in the mutation.
  33922. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  33923. v := m.sop_run
  33924. if v == nil {
  33925. return
  33926. }
  33927. return *v, true
  33928. }
  33929. // OldSopRun returns the old "sop_run" 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) OldSopRun(ctx context.Context) (v uint64, err error) {
  33933. if !m.op.Is(OpUpdateOne) {
  33934. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  33935. }
  33936. if m.id == nil || m.oldValue == nil {
  33937. return v, errors.New("OldSopRun 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 OldSopRun: %w", err)
  33942. }
  33943. return oldValue.SopRun, nil
  33944. }
  33945. // AddSopRun adds u to the "sop_run" field.
  33946. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  33947. if m.addsop_run != nil {
  33948. *m.addsop_run += u
  33949. } else {
  33950. m.addsop_run = &u
  33951. }
  33952. }
  33953. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  33954. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  33955. v := m.addsop_run
  33956. if v == nil {
  33957. return
  33958. }
  33959. return *v, true
  33960. }
  33961. // ResetSopRun resets all changes to the "sop_run" field.
  33962. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  33963. m.sop_run = nil
  33964. m.addsop_run = nil
  33965. }
  33966. // SetTotalFriend sets the "total_friend" field.
  33967. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  33968. m.total_friend = &u
  33969. m.addtotal_friend = nil
  33970. }
  33971. // TotalFriend returns the value of the "total_friend" field in the mutation.
  33972. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  33973. v := m.total_friend
  33974. if v == nil {
  33975. return
  33976. }
  33977. return *v, true
  33978. }
  33979. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  33980. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33982. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  33983. if !m.op.Is(OpUpdateOne) {
  33984. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  33985. }
  33986. if m.id == nil || m.oldValue == nil {
  33987. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  33988. }
  33989. oldValue, err := m.oldValue(ctx)
  33990. if err != nil {
  33991. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  33992. }
  33993. return oldValue.TotalFriend, nil
  33994. }
  33995. // AddTotalFriend adds u to the "total_friend" field.
  33996. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  33997. if m.addtotal_friend != nil {
  33998. *m.addtotal_friend += u
  33999. } else {
  34000. m.addtotal_friend = &u
  34001. }
  34002. }
  34003. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34004. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  34005. v := m.addtotal_friend
  34006. if v == nil {
  34007. return
  34008. }
  34009. return *v, true
  34010. }
  34011. // ResetTotalFriend resets all changes to the "total_friend" field.
  34012. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  34013. m.total_friend = nil
  34014. m.addtotal_friend = nil
  34015. }
  34016. // SetTotalGroup sets the "total_group" field.
  34017. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  34018. m.total_group = &u
  34019. m.addtotal_group = nil
  34020. }
  34021. // TotalGroup returns the value of the "total_group" field in the mutation.
  34022. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  34023. v := m.total_group
  34024. if v == nil {
  34025. return
  34026. }
  34027. return *v, true
  34028. }
  34029. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  34030. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34032. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34033. if !m.op.Is(OpUpdateOne) {
  34034. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34035. }
  34036. if m.id == nil || m.oldValue == nil {
  34037. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34038. }
  34039. oldValue, err := m.oldValue(ctx)
  34040. if err != nil {
  34041. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34042. }
  34043. return oldValue.TotalGroup, nil
  34044. }
  34045. // AddTotalGroup adds u to the "total_group" field.
  34046. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  34047. if m.addtotal_group != nil {
  34048. *m.addtotal_group += u
  34049. } else {
  34050. m.addtotal_group = &u
  34051. }
  34052. }
  34053. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34054. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  34055. v := m.addtotal_group
  34056. if v == nil {
  34057. return
  34058. }
  34059. return *v, true
  34060. }
  34061. // ResetTotalGroup resets all changes to the "total_group" field.
  34062. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  34063. m.total_group = nil
  34064. m.addtotal_group = nil
  34065. }
  34066. // SetAccountBalance sets the "account_balance" field.
  34067. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  34068. m.account_balance = &u
  34069. m.addaccount_balance = nil
  34070. }
  34071. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34072. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  34073. v := m.account_balance
  34074. if v == nil {
  34075. return
  34076. }
  34077. return *v, true
  34078. }
  34079. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  34080. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34082. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34083. if !m.op.Is(OpUpdateOne) {
  34084. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34085. }
  34086. if m.id == nil || m.oldValue == nil {
  34087. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34088. }
  34089. oldValue, err := m.oldValue(ctx)
  34090. if err != nil {
  34091. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34092. }
  34093. return oldValue.AccountBalance, nil
  34094. }
  34095. // AddAccountBalance adds u to the "account_balance" field.
  34096. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  34097. if m.addaccount_balance != nil {
  34098. *m.addaccount_balance += u
  34099. } else {
  34100. m.addaccount_balance = &u
  34101. }
  34102. }
  34103. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34104. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  34105. v := m.addaccount_balance
  34106. if v == nil {
  34107. return
  34108. }
  34109. return *v, true
  34110. }
  34111. // ResetAccountBalance resets all changes to the "account_balance" field.
  34112. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  34113. m.account_balance = nil
  34114. m.addaccount_balance = nil
  34115. }
  34116. // SetConsumeToken sets the "consume_token" field.
  34117. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  34118. m.consume_token = &u
  34119. m.addconsume_token = nil
  34120. }
  34121. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34122. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  34123. v := m.consume_token
  34124. if v == nil {
  34125. return
  34126. }
  34127. return *v, true
  34128. }
  34129. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  34130. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34132. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34133. if !m.op.Is(OpUpdateOne) {
  34134. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34135. }
  34136. if m.id == nil || m.oldValue == nil {
  34137. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34138. }
  34139. oldValue, err := m.oldValue(ctx)
  34140. if err != nil {
  34141. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34142. }
  34143. return oldValue.ConsumeToken, nil
  34144. }
  34145. // AddConsumeToken adds u to the "consume_token" field.
  34146. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  34147. if m.addconsume_token != nil {
  34148. *m.addconsume_token += u
  34149. } else {
  34150. m.addconsume_token = &u
  34151. }
  34152. }
  34153. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34154. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  34155. v := m.addconsume_token
  34156. if v == nil {
  34157. return
  34158. }
  34159. return *v, true
  34160. }
  34161. // ResetConsumeToken resets all changes to the "consume_token" field.
  34162. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  34163. m.consume_token = nil
  34164. m.addconsume_token = nil
  34165. }
  34166. // SetActiveUser sets the "active_user" field.
  34167. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  34168. m.active_user = &u
  34169. m.addactive_user = nil
  34170. }
  34171. // ActiveUser returns the value of the "active_user" field in the mutation.
  34172. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  34173. v := m.active_user
  34174. if v == nil {
  34175. return
  34176. }
  34177. return *v, true
  34178. }
  34179. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  34180. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34182. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34183. if !m.op.Is(OpUpdateOne) {
  34184. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34185. }
  34186. if m.id == nil || m.oldValue == nil {
  34187. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34188. }
  34189. oldValue, err := m.oldValue(ctx)
  34190. if err != nil {
  34191. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34192. }
  34193. return oldValue.ActiveUser, nil
  34194. }
  34195. // AddActiveUser adds u to the "active_user" field.
  34196. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  34197. if m.addactive_user != nil {
  34198. *m.addactive_user += u
  34199. } else {
  34200. m.addactive_user = &u
  34201. }
  34202. }
  34203. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34204. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  34205. v := m.addactive_user
  34206. if v == nil {
  34207. return
  34208. }
  34209. return *v, true
  34210. }
  34211. // ResetActiveUser resets all changes to the "active_user" field.
  34212. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  34213. m.active_user = nil
  34214. m.addactive_user = nil
  34215. }
  34216. // SetNewUser sets the "new_user" field.
  34217. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  34218. m.new_user = &i
  34219. m.addnew_user = nil
  34220. }
  34221. // NewUser returns the value of the "new_user" field in the mutation.
  34222. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  34223. v := m.new_user
  34224. if v == nil {
  34225. return
  34226. }
  34227. return *v, true
  34228. }
  34229. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  34230. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34232. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34233. if !m.op.Is(OpUpdateOne) {
  34234. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34235. }
  34236. if m.id == nil || m.oldValue == nil {
  34237. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34238. }
  34239. oldValue, err := m.oldValue(ctx)
  34240. if err != nil {
  34241. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34242. }
  34243. return oldValue.NewUser, nil
  34244. }
  34245. // AddNewUser adds i to the "new_user" field.
  34246. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  34247. if m.addnew_user != nil {
  34248. *m.addnew_user += i
  34249. } else {
  34250. m.addnew_user = &i
  34251. }
  34252. }
  34253. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34254. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  34255. v := m.addnew_user
  34256. if v == nil {
  34257. return
  34258. }
  34259. return *v, true
  34260. }
  34261. // ResetNewUser resets all changes to the "new_user" field.
  34262. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  34263. m.new_user = nil
  34264. m.addnew_user = nil
  34265. }
  34266. // SetLabelDist sets the "label_dist" field.
  34267. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34268. m.label_dist = &ctd
  34269. m.appendlabel_dist = nil
  34270. }
  34271. // LabelDist returns the value of the "label_dist" field in the mutation.
  34272. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34273. v := m.label_dist
  34274. if v == nil {
  34275. return
  34276. }
  34277. return *v, true
  34278. }
  34279. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  34280. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34282. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34283. if !m.op.Is(OpUpdateOne) {
  34284. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34285. }
  34286. if m.id == nil || m.oldValue == nil {
  34287. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34288. }
  34289. oldValue, err := m.oldValue(ctx)
  34290. if err != nil {
  34291. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34292. }
  34293. return oldValue.LabelDist, nil
  34294. }
  34295. // AppendLabelDist adds ctd to the "label_dist" field.
  34296. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34297. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34298. }
  34299. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34300. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34301. if len(m.appendlabel_dist) == 0 {
  34302. return nil, false
  34303. }
  34304. return m.appendlabel_dist, true
  34305. }
  34306. // ResetLabelDist resets all changes to the "label_dist" field.
  34307. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  34308. m.label_dist = nil
  34309. m.appendlabel_dist = nil
  34310. }
  34311. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  34312. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  34313. m.predicates = append(m.predicates, ps...)
  34314. }
  34315. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  34316. // users can use type-assertion to append predicates that do not depend on any generated package.
  34317. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  34318. p := make([]predicate.UsageStatisticMonth, len(ps))
  34319. for i := range ps {
  34320. p[i] = ps[i]
  34321. }
  34322. m.Where(p...)
  34323. }
  34324. // Op returns the operation name.
  34325. func (m *UsageStatisticMonthMutation) Op() Op {
  34326. return m.op
  34327. }
  34328. // SetOp allows setting the mutation operation.
  34329. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  34330. m.op = op
  34331. }
  34332. // Type returns the node type of this mutation (UsageStatisticMonth).
  34333. func (m *UsageStatisticMonthMutation) Type() string {
  34334. return m.typ
  34335. }
  34336. // Fields returns all fields that were changed during this mutation. Note that in
  34337. // order to get all numeric fields that were incremented/decremented, call
  34338. // AddedFields().
  34339. func (m *UsageStatisticMonthMutation) Fields() []string {
  34340. fields := make([]string, 0, 17)
  34341. if m.created_at != nil {
  34342. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  34343. }
  34344. if m.updated_at != nil {
  34345. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  34346. }
  34347. if m.status != nil {
  34348. fields = append(fields, usagestatisticmonth.FieldStatus)
  34349. }
  34350. if m.deleted_at != nil {
  34351. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34352. }
  34353. if m.addtime != nil {
  34354. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34355. }
  34356. if m._type != nil {
  34357. fields = append(fields, usagestatisticmonth.FieldType)
  34358. }
  34359. if m.bot_id != nil {
  34360. fields = append(fields, usagestatisticmonth.FieldBotID)
  34361. }
  34362. if m.organization_id != nil {
  34363. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34364. }
  34365. if m.ai_response != nil {
  34366. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34367. }
  34368. if m.sop_run != nil {
  34369. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34370. }
  34371. if m.total_friend != nil {
  34372. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34373. }
  34374. if m.total_group != nil {
  34375. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34376. }
  34377. if m.account_balance != nil {
  34378. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34379. }
  34380. if m.consume_token != nil {
  34381. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34382. }
  34383. if m.active_user != nil {
  34384. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34385. }
  34386. if m.new_user != nil {
  34387. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34388. }
  34389. if m.label_dist != nil {
  34390. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  34391. }
  34392. return fields
  34393. }
  34394. // Field returns the value of a field with the given name. The second boolean
  34395. // return value indicates that this field was not set, or was not defined in the
  34396. // schema.
  34397. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  34398. switch name {
  34399. case usagestatisticmonth.FieldCreatedAt:
  34400. return m.CreatedAt()
  34401. case usagestatisticmonth.FieldUpdatedAt:
  34402. return m.UpdatedAt()
  34403. case usagestatisticmonth.FieldStatus:
  34404. return m.Status()
  34405. case usagestatisticmonth.FieldDeletedAt:
  34406. return m.DeletedAt()
  34407. case usagestatisticmonth.FieldAddtime:
  34408. return m.Addtime()
  34409. case usagestatisticmonth.FieldType:
  34410. return m.GetType()
  34411. case usagestatisticmonth.FieldBotID:
  34412. return m.BotID()
  34413. case usagestatisticmonth.FieldOrganizationID:
  34414. return m.OrganizationID()
  34415. case usagestatisticmonth.FieldAiResponse:
  34416. return m.AiResponse()
  34417. case usagestatisticmonth.FieldSopRun:
  34418. return m.SopRun()
  34419. case usagestatisticmonth.FieldTotalFriend:
  34420. return m.TotalFriend()
  34421. case usagestatisticmonth.FieldTotalGroup:
  34422. return m.TotalGroup()
  34423. case usagestatisticmonth.FieldAccountBalance:
  34424. return m.AccountBalance()
  34425. case usagestatisticmonth.FieldConsumeToken:
  34426. return m.ConsumeToken()
  34427. case usagestatisticmonth.FieldActiveUser:
  34428. return m.ActiveUser()
  34429. case usagestatisticmonth.FieldNewUser:
  34430. return m.NewUser()
  34431. case usagestatisticmonth.FieldLabelDist:
  34432. return m.LabelDist()
  34433. }
  34434. return nil, false
  34435. }
  34436. // OldField returns the old value of the field from the database. An error is
  34437. // returned if the mutation operation is not UpdateOne, or the query to the
  34438. // database failed.
  34439. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34440. switch name {
  34441. case usagestatisticmonth.FieldCreatedAt:
  34442. return m.OldCreatedAt(ctx)
  34443. case usagestatisticmonth.FieldUpdatedAt:
  34444. return m.OldUpdatedAt(ctx)
  34445. case usagestatisticmonth.FieldStatus:
  34446. return m.OldStatus(ctx)
  34447. case usagestatisticmonth.FieldDeletedAt:
  34448. return m.OldDeletedAt(ctx)
  34449. case usagestatisticmonth.FieldAddtime:
  34450. return m.OldAddtime(ctx)
  34451. case usagestatisticmonth.FieldType:
  34452. return m.OldType(ctx)
  34453. case usagestatisticmonth.FieldBotID:
  34454. return m.OldBotID(ctx)
  34455. case usagestatisticmonth.FieldOrganizationID:
  34456. return m.OldOrganizationID(ctx)
  34457. case usagestatisticmonth.FieldAiResponse:
  34458. return m.OldAiResponse(ctx)
  34459. case usagestatisticmonth.FieldSopRun:
  34460. return m.OldSopRun(ctx)
  34461. case usagestatisticmonth.FieldTotalFriend:
  34462. return m.OldTotalFriend(ctx)
  34463. case usagestatisticmonth.FieldTotalGroup:
  34464. return m.OldTotalGroup(ctx)
  34465. case usagestatisticmonth.FieldAccountBalance:
  34466. return m.OldAccountBalance(ctx)
  34467. case usagestatisticmonth.FieldConsumeToken:
  34468. return m.OldConsumeToken(ctx)
  34469. case usagestatisticmonth.FieldActiveUser:
  34470. return m.OldActiveUser(ctx)
  34471. case usagestatisticmonth.FieldNewUser:
  34472. return m.OldNewUser(ctx)
  34473. case usagestatisticmonth.FieldLabelDist:
  34474. return m.OldLabelDist(ctx)
  34475. }
  34476. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34477. }
  34478. // SetField sets the value of a field with the given name. It returns an error if
  34479. // the field is not defined in the schema, or if the type mismatched the field
  34480. // type.
  34481. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  34482. switch name {
  34483. case usagestatisticmonth.FieldCreatedAt:
  34484. v, ok := value.(time.Time)
  34485. if !ok {
  34486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34487. }
  34488. m.SetCreatedAt(v)
  34489. return nil
  34490. case usagestatisticmonth.FieldUpdatedAt:
  34491. v, ok := value.(time.Time)
  34492. if !ok {
  34493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34494. }
  34495. m.SetUpdatedAt(v)
  34496. return nil
  34497. case usagestatisticmonth.FieldStatus:
  34498. v, ok := value.(uint8)
  34499. if !ok {
  34500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34501. }
  34502. m.SetStatus(v)
  34503. return nil
  34504. case usagestatisticmonth.FieldDeletedAt:
  34505. v, ok := value.(time.Time)
  34506. if !ok {
  34507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34508. }
  34509. m.SetDeletedAt(v)
  34510. return nil
  34511. case usagestatisticmonth.FieldAddtime:
  34512. v, ok := value.(uint64)
  34513. if !ok {
  34514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34515. }
  34516. m.SetAddtime(v)
  34517. return nil
  34518. case usagestatisticmonth.FieldType:
  34519. v, ok := value.(int)
  34520. if !ok {
  34521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34522. }
  34523. m.SetType(v)
  34524. return nil
  34525. case usagestatisticmonth.FieldBotID:
  34526. v, ok := value.(string)
  34527. if !ok {
  34528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34529. }
  34530. m.SetBotID(v)
  34531. return nil
  34532. case usagestatisticmonth.FieldOrganizationID:
  34533. v, ok := value.(uint64)
  34534. if !ok {
  34535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34536. }
  34537. m.SetOrganizationID(v)
  34538. return nil
  34539. case usagestatisticmonth.FieldAiResponse:
  34540. v, ok := value.(uint64)
  34541. if !ok {
  34542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34543. }
  34544. m.SetAiResponse(v)
  34545. return nil
  34546. case usagestatisticmonth.FieldSopRun:
  34547. v, ok := value.(uint64)
  34548. if !ok {
  34549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34550. }
  34551. m.SetSopRun(v)
  34552. return nil
  34553. case usagestatisticmonth.FieldTotalFriend:
  34554. v, ok := value.(uint64)
  34555. if !ok {
  34556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34557. }
  34558. m.SetTotalFriend(v)
  34559. return nil
  34560. case usagestatisticmonth.FieldTotalGroup:
  34561. v, ok := value.(uint64)
  34562. if !ok {
  34563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34564. }
  34565. m.SetTotalGroup(v)
  34566. return nil
  34567. case usagestatisticmonth.FieldAccountBalance:
  34568. v, ok := value.(uint64)
  34569. if !ok {
  34570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34571. }
  34572. m.SetAccountBalance(v)
  34573. return nil
  34574. case usagestatisticmonth.FieldConsumeToken:
  34575. v, ok := value.(uint64)
  34576. if !ok {
  34577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34578. }
  34579. m.SetConsumeToken(v)
  34580. return nil
  34581. case usagestatisticmonth.FieldActiveUser:
  34582. v, ok := value.(uint64)
  34583. if !ok {
  34584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34585. }
  34586. m.SetActiveUser(v)
  34587. return nil
  34588. case usagestatisticmonth.FieldNewUser:
  34589. v, ok := value.(int64)
  34590. if !ok {
  34591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34592. }
  34593. m.SetNewUser(v)
  34594. return nil
  34595. case usagestatisticmonth.FieldLabelDist:
  34596. v, ok := value.([]custom_types.LabelDist)
  34597. if !ok {
  34598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34599. }
  34600. m.SetLabelDist(v)
  34601. return nil
  34602. }
  34603. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34604. }
  34605. // AddedFields returns all numeric fields that were incremented/decremented during
  34606. // this mutation.
  34607. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  34608. var fields []string
  34609. if m.addstatus != nil {
  34610. fields = append(fields, usagestatisticmonth.FieldStatus)
  34611. }
  34612. if m.addaddtime != nil {
  34613. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34614. }
  34615. if m.add_type != nil {
  34616. fields = append(fields, usagestatisticmonth.FieldType)
  34617. }
  34618. if m.addorganization_id != nil {
  34619. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34620. }
  34621. if m.addai_response != nil {
  34622. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34623. }
  34624. if m.addsop_run != nil {
  34625. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34626. }
  34627. if m.addtotal_friend != nil {
  34628. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34629. }
  34630. if m.addtotal_group != nil {
  34631. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34632. }
  34633. if m.addaccount_balance != nil {
  34634. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34635. }
  34636. if m.addconsume_token != nil {
  34637. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34638. }
  34639. if m.addactive_user != nil {
  34640. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34641. }
  34642. if m.addnew_user != nil {
  34643. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34644. }
  34645. return fields
  34646. }
  34647. // AddedField returns the numeric value that was incremented/decremented on a field
  34648. // with the given name. The second boolean return value indicates that this field
  34649. // was not set, or was not defined in the schema.
  34650. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  34651. switch name {
  34652. case usagestatisticmonth.FieldStatus:
  34653. return m.AddedStatus()
  34654. case usagestatisticmonth.FieldAddtime:
  34655. return m.AddedAddtime()
  34656. case usagestatisticmonth.FieldType:
  34657. return m.AddedType()
  34658. case usagestatisticmonth.FieldOrganizationID:
  34659. return m.AddedOrganizationID()
  34660. case usagestatisticmonth.FieldAiResponse:
  34661. return m.AddedAiResponse()
  34662. case usagestatisticmonth.FieldSopRun:
  34663. return m.AddedSopRun()
  34664. case usagestatisticmonth.FieldTotalFriend:
  34665. return m.AddedTotalFriend()
  34666. case usagestatisticmonth.FieldTotalGroup:
  34667. return m.AddedTotalGroup()
  34668. case usagestatisticmonth.FieldAccountBalance:
  34669. return m.AddedAccountBalance()
  34670. case usagestatisticmonth.FieldConsumeToken:
  34671. return m.AddedConsumeToken()
  34672. case usagestatisticmonth.FieldActiveUser:
  34673. return m.AddedActiveUser()
  34674. case usagestatisticmonth.FieldNewUser:
  34675. return m.AddedNewUser()
  34676. }
  34677. return nil, false
  34678. }
  34679. // AddField adds the value to the field with the given name. It returns an error if
  34680. // the field is not defined in the schema, or if the type mismatched the field
  34681. // type.
  34682. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  34683. switch name {
  34684. case usagestatisticmonth.FieldStatus:
  34685. v, ok := value.(int8)
  34686. if !ok {
  34687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34688. }
  34689. m.AddStatus(v)
  34690. return nil
  34691. case usagestatisticmonth.FieldAddtime:
  34692. v, ok := value.(int64)
  34693. if !ok {
  34694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34695. }
  34696. m.AddAddtime(v)
  34697. return nil
  34698. case usagestatisticmonth.FieldType:
  34699. v, ok := value.(int)
  34700. if !ok {
  34701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34702. }
  34703. m.AddType(v)
  34704. return nil
  34705. case usagestatisticmonth.FieldOrganizationID:
  34706. v, ok := value.(int64)
  34707. if !ok {
  34708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34709. }
  34710. m.AddOrganizationID(v)
  34711. return nil
  34712. case usagestatisticmonth.FieldAiResponse:
  34713. v, ok := value.(int64)
  34714. if !ok {
  34715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34716. }
  34717. m.AddAiResponse(v)
  34718. return nil
  34719. case usagestatisticmonth.FieldSopRun:
  34720. v, ok := value.(int64)
  34721. if !ok {
  34722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34723. }
  34724. m.AddSopRun(v)
  34725. return nil
  34726. case usagestatisticmonth.FieldTotalFriend:
  34727. v, ok := value.(int64)
  34728. if !ok {
  34729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34730. }
  34731. m.AddTotalFriend(v)
  34732. return nil
  34733. case usagestatisticmonth.FieldTotalGroup:
  34734. v, ok := value.(int64)
  34735. if !ok {
  34736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34737. }
  34738. m.AddTotalGroup(v)
  34739. return nil
  34740. case usagestatisticmonth.FieldAccountBalance:
  34741. v, ok := value.(int64)
  34742. if !ok {
  34743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34744. }
  34745. m.AddAccountBalance(v)
  34746. return nil
  34747. case usagestatisticmonth.FieldConsumeToken:
  34748. v, ok := value.(int64)
  34749. if !ok {
  34750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34751. }
  34752. m.AddConsumeToken(v)
  34753. return nil
  34754. case usagestatisticmonth.FieldActiveUser:
  34755. v, ok := value.(int64)
  34756. if !ok {
  34757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34758. }
  34759. m.AddActiveUser(v)
  34760. return nil
  34761. case usagestatisticmonth.FieldNewUser:
  34762. v, ok := value.(int64)
  34763. if !ok {
  34764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34765. }
  34766. m.AddNewUser(v)
  34767. return nil
  34768. }
  34769. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  34770. }
  34771. // ClearedFields returns all nullable fields that were cleared during this
  34772. // mutation.
  34773. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  34774. var fields []string
  34775. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  34776. fields = append(fields, usagestatisticmonth.FieldStatus)
  34777. }
  34778. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  34779. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34780. }
  34781. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  34782. fields = append(fields, usagestatisticmonth.FieldBotID)
  34783. }
  34784. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  34785. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34786. }
  34787. return fields
  34788. }
  34789. // FieldCleared returns a boolean indicating if a field with the given name was
  34790. // cleared in this mutation.
  34791. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  34792. _, ok := m.clearedFields[name]
  34793. return ok
  34794. }
  34795. // ClearField clears the value of the field with the given name. It returns an
  34796. // error if the field is not defined in the schema.
  34797. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  34798. switch name {
  34799. case usagestatisticmonth.FieldStatus:
  34800. m.ClearStatus()
  34801. return nil
  34802. case usagestatisticmonth.FieldDeletedAt:
  34803. m.ClearDeletedAt()
  34804. return nil
  34805. case usagestatisticmonth.FieldBotID:
  34806. m.ClearBotID()
  34807. return nil
  34808. case usagestatisticmonth.FieldOrganizationID:
  34809. m.ClearOrganizationID()
  34810. return nil
  34811. }
  34812. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  34813. }
  34814. // ResetField resets all changes in the mutation for the field with the given name.
  34815. // It returns an error if the field is not defined in the schema.
  34816. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  34817. switch name {
  34818. case usagestatisticmonth.FieldCreatedAt:
  34819. m.ResetCreatedAt()
  34820. return nil
  34821. case usagestatisticmonth.FieldUpdatedAt:
  34822. m.ResetUpdatedAt()
  34823. return nil
  34824. case usagestatisticmonth.FieldStatus:
  34825. m.ResetStatus()
  34826. return nil
  34827. case usagestatisticmonth.FieldDeletedAt:
  34828. m.ResetDeletedAt()
  34829. return nil
  34830. case usagestatisticmonth.FieldAddtime:
  34831. m.ResetAddtime()
  34832. return nil
  34833. case usagestatisticmonth.FieldType:
  34834. m.ResetType()
  34835. return nil
  34836. case usagestatisticmonth.FieldBotID:
  34837. m.ResetBotID()
  34838. return nil
  34839. case usagestatisticmonth.FieldOrganizationID:
  34840. m.ResetOrganizationID()
  34841. return nil
  34842. case usagestatisticmonth.FieldAiResponse:
  34843. m.ResetAiResponse()
  34844. return nil
  34845. case usagestatisticmonth.FieldSopRun:
  34846. m.ResetSopRun()
  34847. return nil
  34848. case usagestatisticmonth.FieldTotalFriend:
  34849. m.ResetTotalFriend()
  34850. return nil
  34851. case usagestatisticmonth.FieldTotalGroup:
  34852. m.ResetTotalGroup()
  34853. return nil
  34854. case usagestatisticmonth.FieldAccountBalance:
  34855. m.ResetAccountBalance()
  34856. return nil
  34857. case usagestatisticmonth.FieldConsumeToken:
  34858. m.ResetConsumeToken()
  34859. return nil
  34860. case usagestatisticmonth.FieldActiveUser:
  34861. m.ResetActiveUser()
  34862. return nil
  34863. case usagestatisticmonth.FieldNewUser:
  34864. m.ResetNewUser()
  34865. return nil
  34866. case usagestatisticmonth.FieldLabelDist:
  34867. m.ResetLabelDist()
  34868. return nil
  34869. }
  34870. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34871. }
  34872. // AddedEdges returns all edge names that were set/added in this mutation.
  34873. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  34874. edges := make([]string, 0, 0)
  34875. return edges
  34876. }
  34877. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34878. // name in this mutation.
  34879. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  34880. return nil
  34881. }
  34882. // RemovedEdges returns all edge names that were removed in this mutation.
  34883. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  34884. edges := make([]string, 0, 0)
  34885. return edges
  34886. }
  34887. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34888. // the given name in this mutation.
  34889. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  34890. return nil
  34891. }
  34892. // ClearedEdges returns all edge names that were cleared in this mutation.
  34893. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  34894. edges := make([]string, 0, 0)
  34895. return edges
  34896. }
  34897. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34898. // was cleared in this mutation.
  34899. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  34900. return false
  34901. }
  34902. // ClearEdge clears the value of the edge with the given name. It returns an error
  34903. // if that edge is not defined in the schema.
  34904. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  34905. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  34906. }
  34907. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34908. // It returns an error if the edge is not defined in the schema.
  34909. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  34910. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  34911. }
  34912. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  34913. type UsageTotalMutation struct {
  34914. config
  34915. op Op
  34916. typ string
  34917. id *uint64
  34918. created_at *time.Time
  34919. updated_at *time.Time
  34920. status *uint8
  34921. addstatus *int8
  34922. _type *int
  34923. add_type *int
  34924. bot_id *string
  34925. total_tokens *uint64
  34926. addtotal_tokens *int64
  34927. start_index *uint64
  34928. addstart_index *int64
  34929. end_index *uint64
  34930. addend_index *int64
  34931. organization_id *uint64
  34932. addorganization_id *int64
  34933. clearedFields map[string]struct{}
  34934. done bool
  34935. oldValue func(context.Context) (*UsageTotal, error)
  34936. predicates []predicate.UsageTotal
  34937. }
  34938. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  34939. // usagetotalOption allows management of the mutation configuration using functional options.
  34940. type usagetotalOption func(*UsageTotalMutation)
  34941. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  34942. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  34943. m := &UsageTotalMutation{
  34944. config: c,
  34945. op: op,
  34946. typ: TypeUsageTotal,
  34947. clearedFields: make(map[string]struct{}),
  34948. }
  34949. for _, opt := range opts {
  34950. opt(m)
  34951. }
  34952. return m
  34953. }
  34954. // withUsageTotalID sets the ID field of the mutation.
  34955. func withUsageTotalID(id uint64) usagetotalOption {
  34956. return func(m *UsageTotalMutation) {
  34957. var (
  34958. err error
  34959. once sync.Once
  34960. value *UsageTotal
  34961. )
  34962. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  34963. once.Do(func() {
  34964. if m.done {
  34965. err = errors.New("querying old values post mutation is not allowed")
  34966. } else {
  34967. value, err = m.Client().UsageTotal.Get(ctx, id)
  34968. }
  34969. })
  34970. return value, err
  34971. }
  34972. m.id = &id
  34973. }
  34974. }
  34975. // withUsageTotal sets the old UsageTotal of the mutation.
  34976. func withUsageTotal(node *UsageTotal) usagetotalOption {
  34977. return func(m *UsageTotalMutation) {
  34978. m.oldValue = func(context.Context) (*UsageTotal, error) {
  34979. return node, nil
  34980. }
  34981. m.id = &node.ID
  34982. }
  34983. }
  34984. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34985. // executed in a transaction (ent.Tx), a transactional client is returned.
  34986. func (m UsageTotalMutation) Client() *Client {
  34987. client := &Client{config: m.config}
  34988. client.init()
  34989. return client
  34990. }
  34991. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34992. // it returns an error otherwise.
  34993. func (m UsageTotalMutation) Tx() (*Tx, error) {
  34994. if _, ok := m.driver.(*txDriver); !ok {
  34995. return nil, errors.New("ent: mutation is not running in a transaction")
  34996. }
  34997. tx := &Tx{config: m.config}
  34998. tx.init()
  34999. return tx, nil
  35000. }
  35001. // SetID sets the value of the id field. Note that this
  35002. // operation is only accepted on creation of UsageTotal entities.
  35003. func (m *UsageTotalMutation) SetID(id uint64) {
  35004. m.id = &id
  35005. }
  35006. // ID returns the ID value in the mutation. Note that the ID is only available
  35007. // if it was provided to the builder or after it was returned from the database.
  35008. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  35009. if m.id == nil {
  35010. return
  35011. }
  35012. return *m.id, true
  35013. }
  35014. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35015. // That means, if the mutation is applied within a transaction with an isolation level such
  35016. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35017. // or updated by the mutation.
  35018. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  35019. switch {
  35020. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35021. id, exists := m.ID()
  35022. if exists {
  35023. return []uint64{id}, nil
  35024. }
  35025. fallthrough
  35026. case m.op.Is(OpUpdate | OpDelete):
  35027. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  35028. default:
  35029. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35030. }
  35031. }
  35032. // SetCreatedAt sets the "created_at" field.
  35033. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  35034. m.created_at = &t
  35035. }
  35036. // CreatedAt returns the value of the "created_at" field in the mutation.
  35037. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  35038. v := m.created_at
  35039. if v == nil {
  35040. return
  35041. }
  35042. return *v, true
  35043. }
  35044. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  35045. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35047. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35048. if !m.op.Is(OpUpdateOne) {
  35049. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35050. }
  35051. if m.id == nil || m.oldValue == nil {
  35052. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35053. }
  35054. oldValue, err := m.oldValue(ctx)
  35055. if err != nil {
  35056. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35057. }
  35058. return oldValue.CreatedAt, nil
  35059. }
  35060. // ResetCreatedAt resets all changes to the "created_at" field.
  35061. func (m *UsageTotalMutation) ResetCreatedAt() {
  35062. m.created_at = nil
  35063. }
  35064. // SetUpdatedAt sets the "updated_at" field.
  35065. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  35066. m.updated_at = &t
  35067. }
  35068. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35069. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  35070. v := m.updated_at
  35071. if v == nil {
  35072. return
  35073. }
  35074. return *v, true
  35075. }
  35076. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  35077. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35079. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35080. if !m.op.Is(OpUpdateOne) {
  35081. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35082. }
  35083. if m.id == nil || m.oldValue == nil {
  35084. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35085. }
  35086. oldValue, err := m.oldValue(ctx)
  35087. if err != nil {
  35088. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35089. }
  35090. return oldValue.UpdatedAt, nil
  35091. }
  35092. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35093. func (m *UsageTotalMutation) ResetUpdatedAt() {
  35094. m.updated_at = nil
  35095. }
  35096. // SetStatus sets the "status" field.
  35097. func (m *UsageTotalMutation) SetStatus(u uint8) {
  35098. m.status = &u
  35099. m.addstatus = nil
  35100. }
  35101. // Status returns the value of the "status" field in the mutation.
  35102. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  35103. v := m.status
  35104. if v == nil {
  35105. return
  35106. }
  35107. return *v, true
  35108. }
  35109. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  35110. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35112. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35113. if !m.op.Is(OpUpdateOne) {
  35114. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35115. }
  35116. if m.id == nil || m.oldValue == nil {
  35117. return v, errors.New("OldStatus requires an ID field in the mutation")
  35118. }
  35119. oldValue, err := m.oldValue(ctx)
  35120. if err != nil {
  35121. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35122. }
  35123. return oldValue.Status, nil
  35124. }
  35125. // AddStatus adds u to the "status" field.
  35126. func (m *UsageTotalMutation) AddStatus(u int8) {
  35127. if m.addstatus != nil {
  35128. *m.addstatus += u
  35129. } else {
  35130. m.addstatus = &u
  35131. }
  35132. }
  35133. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35134. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  35135. v := m.addstatus
  35136. if v == nil {
  35137. return
  35138. }
  35139. return *v, true
  35140. }
  35141. // ClearStatus clears the value of the "status" field.
  35142. func (m *UsageTotalMutation) ClearStatus() {
  35143. m.status = nil
  35144. m.addstatus = nil
  35145. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  35146. }
  35147. // StatusCleared returns if the "status" field was cleared in this mutation.
  35148. func (m *UsageTotalMutation) StatusCleared() bool {
  35149. _, ok := m.clearedFields[usagetotal.FieldStatus]
  35150. return ok
  35151. }
  35152. // ResetStatus resets all changes to the "status" field.
  35153. func (m *UsageTotalMutation) ResetStatus() {
  35154. m.status = nil
  35155. m.addstatus = nil
  35156. delete(m.clearedFields, usagetotal.FieldStatus)
  35157. }
  35158. // SetType sets the "type" field.
  35159. func (m *UsageTotalMutation) SetType(i int) {
  35160. m._type = &i
  35161. m.add_type = nil
  35162. }
  35163. // GetType returns the value of the "type" field in the mutation.
  35164. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  35165. v := m._type
  35166. if v == nil {
  35167. return
  35168. }
  35169. return *v, true
  35170. }
  35171. // OldType returns the old "type" field's value of the UsageTotal entity.
  35172. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35174. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  35175. if !m.op.Is(OpUpdateOne) {
  35176. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35177. }
  35178. if m.id == nil || m.oldValue == nil {
  35179. return v, errors.New("OldType requires an ID field in the mutation")
  35180. }
  35181. oldValue, err := m.oldValue(ctx)
  35182. if err != nil {
  35183. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35184. }
  35185. return oldValue.Type, nil
  35186. }
  35187. // AddType adds i to the "type" field.
  35188. func (m *UsageTotalMutation) AddType(i int) {
  35189. if m.add_type != nil {
  35190. *m.add_type += i
  35191. } else {
  35192. m.add_type = &i
  35193. }
  35194. }
  35195. // AddedType returns the value that was added to the "type" field in this mutation.
  35196. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  35197. v := m.add_type
  35198. if v == nil {
  35199. return
  35200. }
  35201. return *v, true
  35202. }
  35203. // ClearType clears the value of the "type" field.
  35204. func (m *UsageTotalMutation) ClearType() {
  35205. m._type = nil
  35206. m.add_type = nil
  35207. m.clearedFields[usagetotal.FieldType] = struct{}{}
  35208. }
  35209. // TypeCleared returns if the "type" field was cleared in this mutation.
  35210. func (m *UsageTotalMutation) TypeCleared() bool {
  35211. _, ok := m.clearedFields[usagetotal.FieldType]
  35212. return ok
  35213. }
  35214. // ResetType resets all changes to the "type" field.
  35215. func (m *UsageTotalMutation) ResetType() {
  35216. m._type = nil
  35217. m.add_type = nil
  35218. delete(m.clearedFields, usagetotal.FieldType)
  35219. }
  35220. // SetBotID sets the "bot_id" field.
  35221. func (m *UsageTotalMutation) SetBotID(s string) {
  35222. m.bot_id = &s
  35223. }
  35224. // BotID returns the value of the "bot_id" field in the mutation.
  35225. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  35226. v := m.bot_id
  35227. if v == nil {
  35228. return
  35229. }
  35230. return *v, true
  35231. }
  35232. // OldBotID returns the old "bot_id" 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) OldBotID(ctx context.Context) (v string, err error) {
  35236. if !m.op.Is(OpUpdateOne) {
  35237. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35238. }
  35239. if m.id == nil || m.oldValue == nil {
  35240. return v, errors.New("OldBotID 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 OldBotID: %w", err)
  35245. }
  35246. return oldValue.BotID, nil
  35247. }
  35248. // ResetBotID resets all changes to the "bot_id" field.
  35249. func (m *UsageTotalMutation) ResetBotID() {
  35250. m.bot_id = nil
  35251. }
  35252. // SetTotalTokens sets the "total_tokens" field.
  35253. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  35254. m.total_tokens = &u
  35255. m.addtotal_tokens = nil
  35256. }
  35257. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  35258. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  35259. v := m.total_tokens
  35260. if v == nil {
  35261. return
  35262. }
  35263. return *v, true
  35264. }
  35265. // OldTotalTokens returns the old "total_tokens" 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) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  35269. if !m.op.Is(OpUpdateOne) {
  35270. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  35271. }
  35272. if m.id == nil || m.oldValue == nil {
  35273. return v, errors.New("OldTotalTokens 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 OldTotalTokens: %w", err)
  35278. }
  35279. return oldValue.TotalTokens, nil
  35280. }
  35281. // AddTotalTokens adds u to the "total_tokens" field.
  35282. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  35283. if m.addtotal_tokens != nil {
  35284. *m.addtotal_tokens += u
  35285. } else {
  35286. m.addtotal_tokens = &u
  35287. }
  35288. }
  35289. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  35290. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  35291. v := m.addtotal_tokens
  35292. if v == nil {
  35293. return
  35294. }
  35295. return *v, true
  35296. }
  35297. // ClearTotalTokens clears the value of the "total_tokens" field.
  35298. func (m *UsageTotalMutation) ClearTotalTokens() {
  35299. m.total_tokens = nil
  35300. m.addtotal_tokens = nil
  35301. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  35302. }
  35303. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  35304. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  35305. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  35306. return ok
  35307. }
  35308. // ResetTotalTokens resets all changes to the "total_tokens" field.
  35309. func (m *UsageTotalMutation) ResetTotalTokens() {
  35310. m.total_tokens = nil
  35311. m.addtotal_tokens = nil
  35312. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  35313. }
  35314. // SetStartIndex sets the "start_index" field.
  35315. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  35316. m.start_index = &u
  35317. m.addstart_index = nil
  35318. }
  35319. // StartIndex returns the value of the "start_index" field in the mutation.
  35320. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  35321. v := m.start_index
  35322. if v == nil {
  35323. return
  35324. }
  35325. return *v, true
  35326. }
  35327. // OldStartIndex returns the old "start_index" 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) OldStartIndex(ctx context.Context) (v uint64, err error) {
  35331. if !m.op.Is(OpUpdateOne) {
  35332. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  35333. }
  35334. if m.id == nil || m.oldValue == nil {
  35335. return v, errors.New("OldStartIndex 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 OldStartIndex: %w", err)
  35340. }
  35341. return oldValue.StartIndex, nil
  35342. }
  35343. // AddStartIndex adds u to the "start_index" field.
  35344. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  35345. if m.addstart_index != nil {
  35346. *m.addstart_index += u
  35347. } else {
  35348. m.addstart_index = &u
  35349. }
  35350. }
  35351. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  35352. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  35353. v := m.addstart_index
  35354. if v == nil {
  35355. return
  35356. }
  35357. return *v, true
  35358. }
  35359. // ClearStartIndex clears the value of the "start_index" field.
  35360. func (m *UsageTotalMutation) ClearStartIndex() {
  35361. m.start_index = nil
  35362. m.addstart_index = nil
  35363. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  35364. }
  35365. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  35366. func (m *UsageTotalMutation) StartIndexCleared() bool {
  35367. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  35368. return ok
  35369. }
  35370. // ResetStartIndex resets all changes to the "start_index" field.
  35371. func (m *UsageTotalMutation) ResetStartIndex() {
  35372. m.start_index = nil
  35373. m.addstart_index = nil
  35374. delete(m.clearedFields, usagetotal.FieldStartIndex)
  35375. }
  35376. // SetEndIndex sets the "end_index" field.
  35377. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  35378. m.end_index = &u
  35379. m.addend_index = nil
  35380. }
  35381. // EndIndex returns the value of the "end_index" field in the mutation.
  35382. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  35383. v := m.end_index
  35384. if v == nil {
  35385. return
  35386. }
  35387. return *v, true
  35388. }
  35389. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  35390. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35392. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  35393. if !m.op.Is(OpUpdateOne) {
  35394. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  35395. }
  35396. if m.id == nil || m.oldValue == nil {
  35397. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  35398. }
  35399. oldValue, err := m.oldValue(ctx)
  35400. if err != nil {
  35401. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  35402. }
  35403. return oldValue.EndIndex, nil
  35404. }
  35405. // AddEndIndex adds u to the "end_index" field.
  35406. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  35407. if m.addend_index != nil {
  35408. *m.addend_index += u
  35409. } else {
  35410. m.addend_index = &u
  35411. }
  35412. }
  35413. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  35414. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  35415. v := m.addend_index
  35416. if v == nil {
  35417. return
  35418. }
  35419. return *v, true
  35420. }
  35421. // ClearEndIndex clears the value of the "end_index" field.
  35422. func (m *UsageTotalMutation) ClearEndIndex() {
  35423. m.end_index = nil
  35424. m.addend_index = nil
  35425. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  35426. }
  35427. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  35428. func (m *UsageTotalMutation) EndIndexCleared() bool {
  35429. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  35430. return ok
  35431. }
  35432. // ResetEndIndex resets all changes to the "end_index" field.
  35433. func (m *UsageTotalMutation) ResetEndIndex() {
  35434. m.end_index = nil
  35435. m.addend_index = nil
  35436. delete(m.clearedFields, usagetotal.FieldEndIndex)
  35437. }
  35438. // SetOrganizationID sets the "organization_id" field.
  35439. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  35440. m.organization_id = &u
  35441. m.addorganization_id = nil
  35442. }
  35443. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35444. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  35445. v := m.organization_id
  35446. if v == nil {
  35447. return
  35448. }
  35449. return *v, true
  35450. }
  35451. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  35452. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35454. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35455. if !m.op.Is(OpUpdateOne) {
  35456. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35457. }
  35458. if m.id == nil || m.oldValue == nil {
  35459. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35460. }
  35461. oldValue, err := m.oldValue(ctx)
  35462. if err != nil {
  35463. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35464. }
  35465. return oldValue.OrganizationID, nil
  35466. }
  35467. // AddOrganizationID adds u to the "organization_id" field.
  35468. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  35469. if m.addorganization_id != nil {
  35470. *m.addorganization_id += u
  35471. } else {
  35472. m.addorganization_id = &u
  35473. }
  35474. }
  35475. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35476. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  35477. v := m.addorganization_id
  35478. if v == nil {
  35479. return
  35480. }
  35481. return *v, true
  35482. }
  35483. // ClearOrganizationID clears the value of the "organization_id" field.
  35484. func (m *UsageTotalMutation) ClearOrganizationID() {
  35485. m.organization_id = nil
  35486. m.addorganization_id = nil
  35487. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  35488. }
  35489. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35490. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  35491. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  35492. return ok
  35493. }
  35494. // ResetOrganizationID resets all changes to the "organization_id" field.
  35495. func (m *UsageTotalMutation) ResetOrganizationID() {
  35496. m.organization_id = nil
  35497. m.addorganization_id = nil
  35498. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  35499. }
  35500. // Where appends a list predicates to the UsageTotalMutation builder.
  35501. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  35502. m.predicates = append(m.predicates, ps...)
  35503. }
  35504. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  35505. // users can use type-assertion to append predicates that do not depend on any generated package.
  35506. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  35507. p := make([]predicate.UsageTotal, len(ps))
  35508. for i := range ps {
  35509. p[i] = ps[i]
  35510. }
  35511. m.Where(p...)
  35512. }
  35513. // Op returns the operation name.
  35514. func (m *UsageTotalMutation) Op() Op {
  35515. return m.op
  35516. }
  35517. // SetOp allows setting the mutation operation.
  35518. func (m *UsageTotalMutation) SetOp(op Op) {
  35519. m.op = op
  35520. }
  35521. // Type returns the node type of this mutation (UsageTotal).
  35522. func (m *UsageTotalMutation) Type() string {
  35523. return m.typ
  35524. }
  35525. // Fields returns all fields that were changed during this mutation. Note that in
  35526. // order to get all numeric fields that were incremented/decremented, call
  35527. // AddedFields().
  35528. func (m *UsageTotalMutation) Fields() []string {
  35529. fields := make([]string, 0, 9)
  35530. if m.created_at != nil {
  35531. fields = append(fields, usagetotal.FieldCreatedAt)
  35532. }
  35533. if m.updated_at != nil {
  35534. fields = append(fields, usagetotal.FieldUpdatedAt)
  35535. }
  35536. if m.status != nil {
  35537. fields = append(fields, usagetotal.FieldStatus)
  35538. }
  35539. if m._type != nil {
  35540. fields = append(fields, usagetotal.FieldType)
  35541. }
  35542. if m.bot_id != nil {
  35543. fields = append(fields, usagetotal.FieldBotID)
  35544. }
  35545. if m.total_tokens != nil {
  35546. fields = append(fields, usagetotal.FieldTotalTokens)
  35547. }
  35548. if m.start_index != nil {
  35549. fields = append(fields, usagetotal.FieldStartIndex)
  35550. }
  35551. if m.end_index != nil {
  35552. fields = append(fields, usagetotal.FieldEndIndex)
  35553. }
  35554. if m.organization_id != nil {
  35555. fields = append(fields, usagetotal.FieldOrganizationID)
  35556. }
  35557. return fields
  35558. }
  35559. // Field returns the value of a field with the given name. The second boolean
  35560. // return value indicates that this field was not set, or was not defined in the
  35561. // schema.
  35562. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  35563. switch name {
  35564. case usagetotal.FieldCreatedAt:
  35565. return m.CreatedAt()
  35566. case usagetotal.FieldUpdatedAt:
  35567. return m.UpdatedAt()
  35568. case usagetotal.FieldStatus:
  35569. return m.Status()
  35570. case usagetotal.FieldType:
  35571. return m.GetType()
  35572. case usagetotal.FieldBotID:
  35573. return m.BotID()
  35574. case usagetotal.FieldTotalTokens:
  35575. return m.TotalTokens()
  35576. case usagetotal.FieldStartIndex:
  35577. return m.StartIndex()
  35578. case usagetotal.FieldEndIndex:
  35579. return m.EndIndex()
  35580. case usagetotal.FieldOrganizationID:
  35581. return m.OrganizationID()
  35582. }
  35583. return nil, false
  35584. }
  35585. // OldField returns the old value of the field from the database. An error is
  35586. // returned if the mutation operation is not UpdateOne, or the query to the
  35587. // database failed.
  35588. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35589. switch name {
  35590. case usagetotal.FieldCreatedAt:
  35591. return m.OldCreatedAt(ctx)
  35592. case usagetotal.FieldUpdatedAt:
  35593. return m.OldUpdatedAt(ctx)
  35594. case usagetotal.FieldStatus:
  35595. return m.OldStatus(ctx)
  35596. case usagetotal.FieldType:
  35597. return m.OldType(ctx)
  35598. case usagetotal.FieldBotID:
  35599. return m.OldBotID(ctx)
  35600. case usagetotal.FieldTotalTokens:
  35601. return m.OldTotalTokens(ctx)
  35602. case usagetotal.FieldStartIndex:
  35603. return m.OldStartIndex(ctx)
  35604. case usagetotal.FieldEndIndex:
  35605. return m.OldEndIndex(ctx)
  35606. case usagetotal.FieldOrganizationID:
  35607. return m.OldOrganizationID(ctx)
  35608. }
  35609. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  35610. }
  35611. // SetField sets the value of a field with the given name. It returns an error if
  35612. // the field is not defined in the schema, or if the type mismatched the field
  35613. // type.
  35614. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  35615. switch name {
  35616. case usagetotal.FieldCreatedAt:
  35617. v, ok := value.(time.Time)
  35618. if !ok {
  35619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35620. }
  35621. m.SetCreatedAt(v)
  35622. return nil
  35623. case usagetotal.FieldUpdatedAt:
  35624. v, ok := value.(time.Time)
  35625. if !ok {
  35626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35627. }
  35628. m.SetUpdatedAt(v)
  35629. return nil
  35630. case usagetotal.FieldStatus:
  35631. v, ok := value.(uint8)
  35632. if !ok {
  35633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35634. }
  35635. m.SetStatus(v)
  35636. return nil
  35637. case usagetotal.FieldType:
  35638. v, ok := value.(int)
  35639. if !ok {
  35640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35641. }
  35642. m.SetType(v)
  35643. return nil
  35644. case usagetotal.FieldBotID:
  35645. v, ok := value.(string)
  35646. if !ok {
  35647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35648. }
  35649. m.SetBotID(v)
  35650. return nil
  35651. case usagetotal.FieldTotalTokens:
  35652. v, ok := value.(uint64)
  35653. if !ok {
  35654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35655. }
  35656. m.SetTotalTokens(v)
  35657. return nil
  35658. case usagetotal.FieldStartIndex:
  35659. v, ok := value.(uint64)
  35660. if !ok {
  35661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35662. }
  35663. m.SetStartIndex(v)
  35664. return nil
  35665. case usagetotal.FieldEndIndex:
  35666. v, ok := value.(uint64)
  35667. if !ok {
  35668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35669. }
  35670. m.SetEndIndex(v)
  35671. return nil
  35672. case usagetotal.FieldOrganizationID:
  35673. v, ok := value.(uint64)
  35674. if !ok {
  35675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35676. }
  35677. m.SetOrganizationID(v)
  35678. return nil
  35679. }
  35680. return fmt.Errorf("unknown UsageTotal field %s", name)
  35681. }
  35682. // AddedFields returns all numeric fields that were incremented/decremented during
  35683. // this mutation.
  35684. func (m *UsageTotalMutation) AddedFields() []string {
  35685. var fields []string
  35686. if m.addstatus != nil {
  35687. fields = append(fields, usagetotal.FieldStatus)
  35688. }
  35689. if m.add_type != nil {
  35690. fields = append(fields, usagetotal.FieldType)
  35691. }
  35692. if m.addtotal_tokens != nil {
  35693. fields = append(fields, usagetotal.FieldTotalTokens)
  35694. }
  35695. if m.addstart_index != nil {
  35696. fields = append(fields, usagetotal.FieldStartIndex)
  35697. }
  35698. if m.addend_index != nil {
  35699. fields = append(fields, usagetotal.FieldEndIndex)
  35700. }
  35701. if m.addorganization_id != nil {
  35702. fields = append(fields, usagetotal.FieldOrganizationID)
  35703. }
  35704. return fields
  35705. }
  35706. // AddedField returns the numeric value that was incremented/decremented on a field
  35707. // with the given name. The second boolean return value indicates that this field
  35708. // was not set, or was not defined in the schema.
  35709. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  35710. switch name {
  35711. case usagetotal.FieldStatus:
  35712. return m.AddedStatus()
  35713. case usagetotal.FieldType:
  35714. return m.AddedType()
  35715. case usagetotal.FieldTotalTokens:
  35716. return m.AddedTotalTokens()
  35717. case usagetotal.FieldStartIndex:
  35718. return m.AddedStartIndex()
  35719. case usagetotal.FieldEndIndex:
  35720. return m.AddedEndIndex()
  35721. case usagetotal.FieldOrganizationID:
  35722. return m.AddedOrganizationID()
  35723. }
  35724. return nil, false
  35725. }
  35726. // AddField adds the value to the field with the given name. It returns an error if
  35727. // the field is not defined in the schema, or if the type mismatched the field
  35728. // type.
  35729. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  35730. switch name {
  35731. case usagetotal.FieldStatus:
  35732. v, ok := value.(int8)
  35733. if !ok {
  35734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35735. }
  35736. m.AddStatus(v)
  35737. return nil
  35738. case usagetotal.FieldType:
  35739. v, ok := value.(int)
  35740. if !ok {
  35741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35742. }
  35743. m.AddType(v)
  35744. return nil
  35745. case usagetotal.FieldTotalTokens:
  35746. v, ok := value.(int64)
  35747. if !ok {
  35748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35749. }
  35750. m.AddTotalTokens(v)
  35751. return nil
  35752. case usagetotal.FieldStartIndex:
  35753. v, ok := value.(int64)
  35754. if !ok {
  35755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35756. }
  35757. m.AddStartIndex(v)
  35758. return nil
  35759. case usagetotal.FieldEndIndex:
  35760. v, ok := value.(int64)
  35761. if !ok {
  35762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35763. }
  35764. m.AddEndIndex(v)
  35765. return nil
  35766. case usagetotal.FieldOrganizationID:
  35767. v, ok := value.(int64)
  35768. if !ok {
  35769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35770. }
  35771. m.AddOrganizationID(v)
  35772. return nil
  35773. }
  35774. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  35775. }
  35776. // ClearedFields returns all nullable fields that were cleared during this
  35777. // mutation.
  35778. func (m *UsageTotalMutation) ClearedFields() []string {
  35779. var fields []string
  35780. if m.FieldCleared(usagetotal.FieldStatus) {
  35781. fields = append(fields, usagetotal.FieldStatus)
  35782. }
  35783. if m.FieldCleared(usagetotal.FieldType) {
  35784. fields = append(fields, usagetotal.FieldType)
  35785. }
  35786. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  35787. fields = append(fields, usagetotal.FieldTotalTokens)
  35788. }
  35789. if m.FieldCleared(usagetotal.FieldStartIndex) {
  35790. fields = append(fields, usagetotal.FieldStartIndex)
  35791. }
  35792. if m.FieldCleared(usagetotal.FieldEndIndex) {
  35793. fields = append(fields, usagetotal.FieldEndIndex)
  35794. }
  35795. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  35796. fields = append(fields, usagetotal.FieldOrganizationID)
  35797. }
  35798. return fields
  35799. }
  35800. // FieldCleared returns a boolean indicating if a field with the given name was
  35801. // cleared in this mutation.
  35802. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  35803. _, ok := m.clearedFields[name]
  35804. return ok
  35805. }
  35806. // ClearField clears the value of the field with the given name. It returns an
  35807. // error if the field is not defined in the schema.
  35808. func (m *UsageTotalMutation) ClearField(name string) error {
  35809. switch name {
  35810. case usagetotal.FieldStatus:
  35811. m.ClearStatus()
  35812. return nil
  35813. case usagetotal.FieldType:
  35814. m.ClearType()
  35815. return nil
  35816. case usagetotal.FieldTotalTokens:
  35817. m.ClearTotalTokens()
  35818. return nil
  35819. case usagetotal.FieldStartIndex:
  35820. m.ClearStartIndex()
  35821. return nil
  35822. case usagetotal.FieldEndIndex:
  35823. m.ClearEndIndex()
  35824. return nil
  35825. case usagetotal.FieldOrganizationID:
  35826. m.ClearOrganizationID()
  35827. return nil
  35828. }
  35829. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  35830. }
  35831. // ResetField resets all changes in the mutation for the field with the given name.
  35832. // It returns an error if the field is not defined in the schema.
  35833. func (m *UsageTotalMutation) ResetField(name string) error {
  35834. switch name {
  35835. case usagetotal.FieldCreatedAt:
  35836. m.ResetCreatedAt()
  35837. return nil
  35838. case usagetotal.FieldUpdatedAt:
  35839. m.ResetUpdatedAt()
  35840. return nil
  35841. case usagetotal.FieldStatus:
  35842. m.ResetStatus()
  35843. return nil
  35844. case usagetotal.FieldType:
  35845. m.ResetType()
  35846. return nil
  35847. case usagetotal.FieldBotID:
  35848. m.ResetBotID()
  35849. return nil
  35850. case usagetotal.FieldTotalTokens:
  35851. m.ResetTotalTokens()
  35852. return nil
  35853. case usagetotal.FieldStartIndex:
  35854. m.ResetStartIndex()
  35855. return nil
  35856. case usagetotal.FieldEndIndex:
  35857. m.ResetEndIndex()
  35858. return nil
  35859. case usagetotal.FieldOrganizationID:
  35860. m.ResetOrganizationID()
  35861. return nil
  35862. }
  35863. return fmt.Errorf("unknown UsageTotal field %s", name)
  35864. }
  35865. // AddedEdges returns all edge names that were set/added in this mutation.
  35866. func (m *UsageTotalMutation) AddedEdges() []string {
  35867. edges := make([]string, 0, 0)
  35868. return edges
  35869. }
  35870. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35871. // name in this mutation.
  35872. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  35873. return nil
  35874. }
  35875. // RemovedEdges returns all edge names that were removed in this mutation.
  35876. func (m *UsageTotalMutation) RemovedEdges() []string {
  35877. edges := make([]string, 0, 0)
  35878. return edges
  35879. }
  35880. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35881. // the given name in this mutation.
  35882. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  35883. return nil
  35884. }
  35885. // ClearedEdges returns all edge names that were cleared in this mutation.
  35886. func (m *UsageTotalMutation) ClearedEdges() []string {
  35887. edges := make([]string, 0, 0)
  35888. return edges
  35889. }
  35890. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35891. // was cleared in this mutation.
  35892. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  35893. return false
  35894. }
  35895. // ClearEdge clears the value of the edge with the given name. It returns an error
  35896. // if that edge is not defined in the schema.
  35897. func (m *UsageTotalMutation) ClearEdge(name string) error {
  35898. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  35899. }
  35900. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35901. // It returns an error if the edge is not defined in the schema.
  35902. func (m *UsageTotalMutation) ResetEdge(name string) error {
  35903. return fmt.Errorf("unknown UsageTotal edge %s", name)
  35904. }
  35905. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  35906. type WhatsappMutation struct {
  35907. config
  35908. op Op
  35909. typ string
  35910. id *uint64
  35911. created_at *time.Time
  35912. updated_at *time.Time
  35913. status *uint8
  35914. addstatus *int8
  35915. deleted_at *time.Time
  35916. wa_id *string
  35917. wa_name *string
  35918. callback *string
  35919. account *string
  35920. cc *string
  35921. phone *string
  35922. cc_phone *string
  35923. phone_name *string
  35924. phone_status *int8
  35925. addphone_status *int8
  35926. organization_id *uint64
  35927. addorganization_id *int64
  35928. api_base *string
  35929. api_key *string
  35930. allow_list *[]string
  35931. appendallow_list []string
  35932. group_allow_list *[]string
  35933. appendgroup_allow_list []string
  35934. block_list *[]string
  35935. appendblock_list []string
  35936. group_block_list *[]string
  35937. appendgroup_block_list []string
  35938. clearedFields map[string]struct{}
  35939. agent *uint64
  35940. clearedagent bool
  35941. done bool
  35942. oldValue func(context.Context) (*Whatsapp, error)
  35943. predicates []predicate.Whatsapp
  35944. }
  35945. var _ ent.Mutation = (*WhatsappMutation)(nil)
  35946. // whatsappOption allows management of the mutation configuration using functional options.
  35947. type whatsappOption func(*WhatsappMutation)
  35948. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  35949. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  35950. m := &WhatsappMutation{
  35951. config: c,
  35952. op: op,
  35953. typ: TypeWhatsapp,
  35954. clearedFields: make(map[string]struct{}),
  35955. }
  35956. for _, opt := range opts {
  35957. opt(m)
  35958. }
  35959. return m
  35960. }
  35961. // withWhatsappID sets the ID field of the mutation.
  35962. func withWhatsappID(id uint64) whatsappOption {
  35963. return func(m *WhatsappMutation) {
  35964. var (
  35965. err error
  35966. once sync.Once
  35967. value *Whatsapp
  35968. )
  35969. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  35970. once.Do(func() {
  35971. if m.done {
  35972. err = errors.New("querying old values post mutation is not allowed")
  35973. } else {
  35974. value, err = m.Client().Whatsapp.Get(ctx, id)
  35975. }
  35976. })
  35977. return value, err
  35978. }
  35979. m.id = &id
  35980. }
  35981. }
  35982. // withWhatsapp sets the old Whatsapp of the mutation.
  35983. func withWhatsapp(node *Whatsapp) whatsappOption {
  35984. return func(m *WhatsappMutation) {
  35985. m.oldValue = func(context.Context) (*Whatsapp, error) {
  35986. return node, nil
  35987. }
  35988. m.id = &node.ID
  35989. }
  35990. }
  35991. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35992. // executed in a transaction (ent.Tx), a transactional client is returned.
  35993. func (m WhatsappMutation) Client() *Client {
  35994. client := &Client{config: m.config}
  35995. client.init()
  35996. return client
  35997. }
  35998. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35999. // it returns an error otherwise.
  36000. func (m WhatsappMutation) Tx() (*Tx, error) {
  36001. if _, ok := m.driver.(*txDriver); !ok {
  36002. return nil, errors.New("ent: mutation is not running in a transaction")
  36003. }
  36004. tx := &Tx{config: m.config}
  36005. tx.init()
  36006. return tx, nil
  36007. }
  36008. // SetID sets the value of the id field. Note that this
  36009. // operation is only accepted on creation of Whatsapp entities.
  36010. func (m *WhatsappMutation) SetID(id uint64) {
  36011. m.id = &id
  36012. }
  36013. // ID returns the ID value in the mutation. Note that the ID is only available
  36014. // if it was provided to the builder or after it was returned from the database.
  36015. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  36016. if m.id == nil {
  36017. return
  36018. }
  36019. return *m.id, true
  36020. }
  36021. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36022. // That means, if the mutation is applied within a transaction with an isolation level such
  36023. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36024. // or updated by the mutation.
  36025. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  36026. switch {
  36027. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36028. id, exists := m.ID()
  36029. if exists {
  36030. return []uint64{id}, nil
  36031. }
  36032. fallthrough
  36033. case m.op.Is(OpUpdate | OpDelete):
  36034. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  36035. default:
  36036. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36037. }
  36038. }
  36039. // SetCreatedAt sets the "created_at" field.
  36040. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  36041. m.created_at = &t
  36042. }
  36043. // CreatedAt returns the value of the "created_at" field in the mutation.
  36044. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  36045. v := m.created_at
  36046. if v == nil {
  36047. return
  36048. }
  36049. return *v, true
  36050. }
  36051. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  36052. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36054. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36055. if !m.op.Is(OpUpdateOne) {
  36056. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36057. }
  36058. if m.id == nil || m.oldValue == nil {
  36059. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36060. }
  36061. oldValue, err := m.oldValue(ctx)
  36062. if err != nil {
  36063. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36064. }
  36065. return oldValue.CreatedAt, nil
  36066. }
  36067. // ResetCreatedAt resets all changes to the "created_at" field.
  36068. func (m *WhatsappMutation) ResetCreatedAt() {
  36069. m.created_at = nil
  36070. }
  36071. // SetUpdatedAt sets the "updated_at" field.
  36072. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  36073. m.updated_at = &t
  36074. }
  36075. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36076. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  36077. v := m.updated_at
  36078. if v == nil {
  36079. return
  36080. }
  36081. return *v, true
  36082. }
  36083. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  36084. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36086. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36087. if !m.op.Is(OpUpdateOne) {
  36088. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36089. }
  36090. if m.id == nil || m.oldValue == nil {
  36091. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36092. }
  36093. oldValue, err := m.oldValue(ctx)
  36094. if err != nil {
  36095. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36096. }
  36097. return oldValue.UpdatedAt, nil
  36098. }
  36099. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36100. func (m *WhatsappMutation) ResetUpdatedAt() {
  36101. m.updated_at = nil
  36102. }
  36103. // SetStatus sets the "status" field.
  36104. func (m *WhatsappMutation) SetStatus(u uint8) {
  36105. m.status = &u
  36106. m.addstatus = nil
  36107. }
  36108. // Status returns the value of the "status" field in the mutation.
  36109. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  36110. v := m.status
  36111. if v == nil {
  36112. return
  36113. }
  36114. return *v, true
  36115. }
  36116. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  36117. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36119. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36120. if !m.op.Is(OpUpdateOne) {
  36121. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36122. }
  36123. if m.id == nil || m.oldValue == nil {
  36124. return v, errors.New("OldStatus requires an ID field in the mutation")
  36125. }
  36126. oldValue, err := m.oldValue(ctx)
  36127. if err != nil {
  36128. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36129. }
  36130. return oldValue.Status, nil
  36131. }
  36132. // AddStatus adds u to the "status" field.
  36133. func (m *WhatsappMutation) AddStatus(u int8) {
  36134. if m.addstatus != nil {
  36135. *m.addstatus += u
  36136. } else {
  36137. m.addstatus = &u
  36138. }
  36139. }
  36140. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36141. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  36142. v := m.addstatus
  36143. if v == nil {
  36144. return
  36145. }
  36146. return *v, true
  36147. }
  36148. // ClearStatus clears the value of the "status" field.
  36149. func (m *WhatsappMutation) ClearStatus() {
  36150. m.status = nil
  36151. m.addstatus = nil
  36152. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  36153. }
  36154. // StatusCleared returns if the "status" field was cleared in this mutation.
  36155. func (m *WhatsappMutation) StatusCleared() bool {
  36156. _, ok := m.clearedFields[whatsapp.FieldStatus]
  36157. return ok
  36158. }
  36159. // ResetStatus resets all changes to the "status" field.
  36160. func (m *WhatsappMutation) ResetStatus() {
  36161. m.status = nil
  36162. m.addstatus = nil
  36163. delete(m.clearedFields, whatsapp.FieldStatus)
  36164. }
  36165. // SetDeletedAt sets the "deleted_at" field.
  36166. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  36167. m.deleted_at = &t
  36168. }
  36169. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36170. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  36171. v := m.deleted_at
  36172. if v == nil {
  36173. return
  36174. }
  36175. return *v, true
  36176. }
  36177. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  36178. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36180. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36181. if !m.op.Is(OpUpdateOne) {
  36182. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36183. }
  36184. if m.id == nil || m.oldValue == nil {
  36185. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36186. }
  36187. oldValue, err := m.oldValue(ctx)
  36188. if err != nil {
  36189. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36190. }
  36191. return oldValue.DeletedAt, nil
  36192. }
  36193. // ClearDeletedAt clears the value of the "deleted_at" field.
  36194. func (m *WhatsappMutation) ClearDeletedAt() {
  36195. m.deleted_at = nil
  36196. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  36197. }
  36198. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36199. func (m *WhatsappMutation) DeletedAtCleared() bool {
  36200. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  36201. return ok
  36202. }
  36203. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36204. func (m *WhatsappMutation) ResetDeletedAt() {
  36205. m.deleted_at = nil
  36206. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  36207. }
  36208. // SetWaID sets the "wa_id" field.
  36209. func (m *WhatsappMutation) SetWaID(s string) {
  36210. m.wa_id = &s
  36211. }
  36212. // WaID returns the value of the "wa_id" field in the mutation.
  36213. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  36214. v := m.wa_id
  36215. if v == nil {
  36216. return
  36217. }
  36218. return *v, true
  36219. }
  36220. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  36221. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36223. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  36224. if !m.op.Is(OpUpdateOne) {
  36225. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  36226. }
  36227. if m.id == nil || m.oldValue == nil {
  36228. return v, errors.New("OldWaID requires an ID field in the mutation")
  36229. }
  36230. oldValue, err := m.oldValue(ctx)
  36231. if err != nil {
  36232. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  36233. }
  36234. return oldValue.WaID, nil
  36235. }
  36236. // ClearWaID clears the value of the "wa_id" field.
  36237. func (m *WhatsappMutation) ClearWaID() {
  36238. m.wa_id = nil
  36239. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  36240. }
  36241. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  36242. func (m *WhatsappMutation) WaIDCleared() bool {
  36243. _, ok := m.clearedFields[whatsapp.FieldWaID]
  36244. return ok
  36245. }
  36246. // ResetWaID resets all changes to the "wa_id" field.
  36247. func (m *WhatsappMutation) ResetWaID() {
  36248. m.wa_id = nil
  36249. delete(m.clearedFields, whatsapp.FieldWaID)
  36250. }
  36251. // SetWaName sets the "wa_name" field.
  36252. func (m *WhatsappMutation) SetWaName(s string) {
  36253. m.wa_name = &s
  36254. }
  36255. // WaName returns the value of the "wa_name" field in the mutation.
  36256. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  36257. v := m.wa_name
  36258. if v == nil {
  36259. return
  36260. }
  36261. return *v, true
  36262. }
  36263. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  36264. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36266. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  36267. if !m.op.Is(OpUpdateOne) {
  36268. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  36269. }
  36270. if m.id == nil || m.oldValue == nil {
  36271. return v, errors.New("OldWaName requires an ID field in the mutation")
  36272. }
  36273. oldValue, err := m.oldValue(ctx)
  36274. if err != nil {
  36275. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  36276. }
  36277. return oldValue.WaName, nil
  36278. }
  36279. // ClearWaName clears the value of the "wa_name" field.
  36280. func (m *WhatsappMutation) ClearWaName() {
  36281. m.wa_name = nil
  36282. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  36283. }
  36284. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  36285. func (m *WhatsappMutation) WaNameCleared() bool {
  36286. _, ok := m.clearedFields[whatsapp.FieldWaName]
  36287. return ok
  36288. }
  36289. // ResetWaName resets all changes to the "wa_name" field.
  36290. func (m *WhatsappMutation) ResetWaName() {
  36291. m.wa_name = nil
  36292. delete(m.clearedFields, whatsapp.FieldWaName)
  36293. }
  36294. // SetCallback sets the "callback" field.
  36295. func (m *WhatsappMutation) SetCallback(s string) {
  36296. m.callback = &s
  36297. }
  36298. // Callback returns the value of the "callback" field in the mutation.
  36299. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  36300. v := m.callback
  36301. if v == nil {
  36302. return
  36303. }
  36304. return *v, true
  36305. }
  36306. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  36307. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36309. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  36310. if !m.op.Is(OpUpdateOne) {
  36311. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  36312. }
  36313. if m.id == nil || m.oldValue == nil {
  36314. return v, errors.New("OldCallback requires an ID field in the mutation")
  36315. }
  36316. oldValue, err := m.oldValue(ctx)
  36317. if err != nil {
  36318. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  36319. }
  36320. return oldValue.Callback, nil
  36321. }
  36322. // ClearCallback clears the value of the "callback" field.
  36323. func (m *WhatsappMutation) ClearCallback() {
  36324. m.callback = nil
  36325. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  36326. }
  36327. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  36328. func (m *WhatsappMutation) CallbackCleared() bool {
  36329. _, ok := m.clearedFields[whatsapp.FieldCallback]
  36330. return ok
  36331. }
  36332. // ResetCallback resets all changes to the "callback" field.
  36333. func (m *WhatsappMutation) ResetCallback() {
  36334. m.callback = nil
  36335. delete(m.clearedFields, whatsapp.FieldCallback)
  36336. }
  36337. // SetAgentID sets the "agent_id" field.
  36338. func (m *WhatsappMutation) SetAgentID(u uint64) {
  36339. m.agent = &u
  36340. }
  36341. // AgentID returns the value of the "agent_id" field in the mutation.
  36342. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  36343. v := m.agent
  36344. if v == nil {
  36345. return
  36346. }
  36347. return *v, true
  36348. }
  36349. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  36350. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36352. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  36353. if !m.op.Is(OpUpdateOne) {
  36354. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  36355. }
  36356. if m.id == nil || m.oldValue == nil {
  36357. return v, errors.New("OldAgentID requires an ID field in the mutation")
  36358. }
  36359. oldValue, err := m.oldValue(ctx)
  36360. if err != nil {
  36361. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  36362. }
  36363. return oldValue.AgentID, nil
  36364. }
  36365. // ResetAgentID resets all changes to the "agent_id" field.
  36366. func (m *WhatsappMutation) ResetAgentID() {
  36367. m.agent = nil
  36368. }
  36369. // SetAccount sets the "account" field.
  36370. func (m *WhatsappMutation) SetAccount(s string) {
  36371. m.account = &s
  36372. }
  36373. // Account returns the value of the "account" field in the mutation.
  36374. func (m *WhatsappMutation) Account() (r string, exists bool) {
  36375. v := m.account
  36376. if v == nil {
  36377. return
  36378. }
  36379. return *v, true
  36380. }
  36381. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  36382. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36384. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  36385. if !m.op.Is(OpUpdateOne) {
  36386. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  36387. }
  36388. if m.id == nil || m.oldValue == nil {
  36389. return v, errors.New("OldAccount requires an ID field in the mutation")
  36390. }
  36391. oldValue, err := m.oldValue(ctx)
  36392. if err != nil {
  36393. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  36394. }
  36395. return oldValue.Account, nil
  36396. }
  36397. // ClearAccount clears the value of the "account" field.
  36398. func (m *WhatsappMutation) ClearAccount() {
  36399. m.account = nil
  36400. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  36401. }
  36402. // AccountCleared returns if the "account" field was cleared in this mutation.
  36403. func (m *WhatsappMutation) AccountCleared() bool {
  36404. _, ok := m.clearedFields[whatsapp.FieldAccount]
  36405. return ok
  36406. }
  36407. // ResetAccount resets all changes to the "account" field.
  36408. func (m *WhatsappMutation) ResetAccount() {
  36409. m.account = nil
  36410. delete(m.clearedFields, whatsapp.FieldAccount)
  36411. }
  36412. // SetCc sets the "cc" field.
  36413. func (m *WhatsappMutation) SetCc(s string) {
  36414. m.cc = &s
  36415. }
  36416. // Cc returns the value of the "cc" field in the mutation.
  36417. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  36418. v := m.cc
  36419. if v == nil {
  36420. return
  36421. }
  36422. return *v, true
  36423. }
  36424. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  36425. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36427. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  36428. if !m.op.Is(OpUpdateOne) {
  36429. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  36430. }
  36431. if m.id == nil || m.oldValue == nil {
  36432. return v, errors.New("OldCc requires an ID field in the mutation")
  36433. }
  36434. oldValue, err := m.oldValue(ctx)
  36435. if err != nil {
  36436. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  36437. }
  36438. return oldValue.Cc, nil
  36439. }
  36440. // ResetCc resets all changes to the "cc" field.
  36441. func (m *WhatsappMutation) ResetCc() {
  36442. m.cc = nil
  36443. }
  36444. // SetPhone sets the "phone" field.
  36445. func (m *WhatsappMutation) SetPhone(s string) {
  36446. m.phone = &s
  36447. }
  36448. // Phone returns the value of the "phone" field in the mutation.
  36449. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  36450. v := m.phone
  36451. if v == nil {
  36452. return
  36453. }
  36454. return *v, true
  36455. }
  36456. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  36457. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36459. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  36460. if !m.op.Is(OpUpdateOne) {
  36461. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  36462. }
  36463. if m.id == nil || m.oldValue == nil {
  36464. return v, errors.New("OldPhone requires an ID field in the mutation")
  36465. }
  36466. oldValue, err := m.oldValue(ctx)
  36467. if err != nil {
  36468. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  36469. }
  36470. return oldValue.Phone, nil
  36471. }
  36472. // ResetPhone resets all changes to the "phone" field.
  36473. func (m *WhatsappMutation) ResetPhone() {
  36474. m.phone = nil
  36475. }
  36476. // SetCcPhone sets the "cc_phone" field.
  36477. func (m *WhatsappMutation) SetCcPhone(s string) {
  36478. m.cc_phone = &s
  36479. }
  36480. // CcPhone returns the value of the "cc_phone" field in the mutation.
  36481. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  36482. v := m.cc_phone
  36483. if v == nil {
  36484. return
  36485. }
  36486. return *v, true
  36487. }
  36488. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  36489. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36491. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  36492. if !m.op.Is(OpUpdateOne) {
  36493. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  36494. }
  36495. if m.id == nil || m.oldValue == nil {
  36496. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  36497. }
  36498. oldValue, err := m.oldValue(ctx)
  36499. if err != nil {
  36500. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  36501. }
  36502. return oldValue.CcPhone, nil
  36503. }
  36504. // ResetCcPhone resets all changes to the "cc_phone" field.
  36505. func (m *WhatsappMutation) ResetCcPhone() {
  36506. m.cc_phone = nil
  36507. }
  36508. // SetPhoneName sets the "phone_name" field.
  36509. func (m *WhatsappMutation) SetPhoneName(s string) {
  36510. m.phone_name = &s
  36511. }
  36512. // PhoneName returns the value of the "phone_name" field in the mutation.
  36513. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  36514. v := m.phone_name
  36515. if v == nil {
  36516. return
  36517. }
  36518. return *v, true
  36519. }
  36520. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  36521. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36523. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  36524. if !m.op.Is(OpUpdateOne) {
  36525. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  36526. }
  36527. if m.id == nil || m.oldValue == nil {
  36528. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  36529. }
  36530. oldValue, err := m.oldValue(ctx)
  36531. if err != nil {
  36532. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  36533. }
  36534. return oldValue.PhoneName, nil
  36535. }
  36536. // ResetPhoneName resets all changes to the "phone_name" field.
  36537. func (m *WhatsappMutation) ResetPhoneName() {
  36538. m.phone_name = nil
  36539. }
  36540. // SetPhoneStatus sets the "phone_status" field.
  36541. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  36542. m.phone_status = &i
  36543. m.addphone_status = nil
  36544. }
  36545. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  36546. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  36547. v := m.phone_status
  36548. if v == nil {
  36549. return
  36550. }
  36551. return *v, true
  36552. }
  36553. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  36554. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36556. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  36557. if !m.op.Is(OpUpdateOne) {
  36558. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  36559. }
  36560. if m.id == nil || m.oldValue == nil {
  36561. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  36562. }
  36563. oldValue, err := m.oldValue(ctx)
  36564. if err != nil {
  36565. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  36566. }
  36567. return oldValue.PhoneStatus, nil
  36568. }
  36569. // AddPhoneStatus adds i to the "phone_status" field.
  36570. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  36571. if m.addphone_status != nil {
  36572. *m.addphone_status += i
  36573. } else {
  36574. m.addphone_status = &i
  36575. }
  36576. }
  36577. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  36578. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  36579. v := m.addphone_status
  36580. if v == nil {
  36581. return
  36582. }
  36583. return *v, true
  36584. }
  36585. // ResetPhoneStatus resets all changes to the "phone_status" field.
  36586. func (m *WhatsappMutation) ResetPhoneStatus() {
  36587. m.phone_status = nil
  36588. m.addphone_status = nil
  36589. }
  36590. // SetOrganizationID sets the "organization_id" field.
  36591. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  36592. m.organization_id = &u
  36593. m.addorganization_id = nil
  36594. }
  36595. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36596. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  36597. v := m.organization_id
  36598. if v == nil {
  36599. return
  36600. }
  36601. return *v, true
  36602. }
  36603. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  36604. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36606. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36607. if !m.op.Is(OpUpdateOne) {
  36608. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36609. }
  36610. if m.id == nil || m.oldValue == nil {
  36611. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36612. }
  36613. oldValue, err := m.oldValue(ctx)
  36614. if err != nil {
  36615. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36616. }
  36617. return oldValue.OrganizationID, nil
  36618. }
  36619. // AddOrganizationID adds u to the "organization_id" field.
  36620. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  36621. if m.addorganization_id != nil {
  36622. *m.addorganization_id += u
  36623. } else {
  36624. m.addorganization_id = &u
  36625. }
  36626. }
  36627. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36628. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  36629. v := m.addorganization_id
  36630. if v == nil {
  36631. return
  36632. }
  36633. return *v, true
  36634. }
  36635. // ClearOrganizationID clears the value of the "organization_id" field.
  36636. func (m *WhatsappMutation) ClearOrganizationID() {
  36637. m.organization_id = nil
  36638. m.addorganization_id = nil
  36639. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  36640. }
  36641. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36642. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  36643. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  36644. return ok
  36645. }
  36646. // ResetOrganizationID resets all changes to the "organization_id" field.
  36647. func (m *WhatsappMutation) ResetOrganizationID() {
  36648. m.organization_id = nil
  36649. m.addorganization_id = nil
  36650. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  36651. }
  36652. // SetAPIBase sets the "api_base" field.
  36653. func (m *WhatsappMutation) SetAPIBase(s string) {
  36654. m.api_base = &s
  36655. }
  36656. // APIBase returns the value of the "api_base" field in the mutation.
  36657. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  36658. v := m.api_base
  36659. if v == nil {
  36660. return
  36661. }
  36662. return *v, true
  36663. }
  36664. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  36665. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36667. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  36668. if !m.op.Is(OpUpdateOne) {
  36669. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  36670. }
  36671. if m.id == nil || m.oldValue == nil {
  36672. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  36673. }
  36674. oldValue, err := m.oldValue(ctx)
  36675. if err != nil {
  36676. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  36677. }
  36678. return oldValue.APIBase, nil
  36679. }
  36680. // ClearAPIBase clears the value of the "api_base" field.
  36681. func (m *WhatsappMutation) ClearAPIBase() {
  36682. m.api_base = nil
  36683. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  36684. }
  36685. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  36686. func (m *WhatsappMutation) APIBaseCleared() bool {
  36687. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  36688. return ok
  36689. }
  36690. // ResetAPIBase resets all changes to the "api_base" field.
  36691. func (m *WhatsappMutation) ResetAPIBase() {
  36692. m.api_base = nil
  36693. delete(m.clearedFields, whatsapp.FieldAPIBase)
  36694. }
  36695. // SetAPIKey sets the "api_key" field.
  36696. func (m *WhatsappMutation) SetAPIKey(s string) {
  36697. m.api_key = &s
  36698. }
  36699. // APIKey returns the value of the "api_key" field in the mutation.
  36700. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  36701. v := m.api_key
  36702. if v == nil {
  36703. return
  36704. }
  36705. return *v, true
  36706. }
  36707. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  36708. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36710. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  36711. if !m.op.Is(OpUpdateOne) {
  36712. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  36713. }
  36714. if m.id == nil || m.oldValue == nil {
  36715. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  36716. }
  36717. oldValue, err := m.oldValue(ctx)
  36718. if err != nil {
  36719. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  36720. }
  36721. return oldValue.APIKey, nil
  36722. }
  36723. // ClearAPIKey clears the value of the "api_key" field.
  36724. func (m *WhatsappMutation) ClearAPIKey() {
  36725. m.api_key = nil
  36726. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  36727. }
  36728. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  36729. func (m *WhatsappMutation) APIKeyCleared() bool {
  36730. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  36731. return ok
  36732. }
  36733. // ResetAPIKey resets all changes to the "api_key" field.
  36734. func (m *WhatsappMutation) ResetAPIKey() {
  36735. m.api_key = nil
  36736. delete(m.clearedFields, whatsapp.FieldAPIKey)
  36737. }
  36738. // SetAllowList sets the "allow_list" field.
  36739. func (m *WhatsappMutation) SetAllowList(s []string) {
  36740. m.allow_list = &s
  36741. m.appendallow_list = nil
  36742. }
  36743. // AllowList returns the value of the "allow_list" field in the mutation.
  36744. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  36745. v := m.allow_list
  36746. if v == nil {
  36747. return
  36748. }
  36749. return *v, true
  36750. }
  36751. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  36752. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36754. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  36755. if !m.op.Is(OpUpdateOne) {
  36756. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  36757. }
  36758. if m.id == nil || m.oldValue == nil {
  36759. return v, errors.New("OldAllowList requires an ID field in the mutation")
  36760. }
  36761. oldValue, err := m.oldValue(ctx)
  36762. if err != nil {
  36763. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  36764. }
  36765. return oldValue.AllowList, nil
  36766. }
  36767. // AppendAllowList adds s to the "allow_list" field.
  36768. func (m *WhatsappMutation) AppendAllowList(s []string) {
  36769. m.appendallow_list = append(m.appendallow_list, s...)
  36770. }
  36771. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  36772. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  36773. if len(m.appendallow_list) == 0 {
  36774. return nil, false
  36775. }
  36776. return m.appendallow_list, true
  36777. }
  36778. // ClearAllowList clears the value of the "allow_list" field.
  36779. func (m *WhatsappMutation) ClearAllowList() {
  36780. m.allow_list = nil
  36781. m.appendallow_list = nil
  36782. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  36783. }
  36784. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  36785. func (m *WhatsappMutation) AllowListCleared() bool {
  36786. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  36787. return ok
  36788. }
  36789. // ResetAllowList resets all changes to the "allow_list" field.
  36790. func (m *WhatsappMutation) ResetAllowList() {
  36791. m.allow_list = nil
  36792. m.appendallow_list = nil
  36793. delete(m.clearedFields, whatsapp.FieldAllowList)
  36794. }
  36795. // SetGroupAllowList sets the "group_allow_list" field.
  36796. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  36797. m.group_allow_list = &s
  36798. m.appendgroup_allow_list = nil
  36799. }
  36800. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  36801. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  36802. v := m.group_allow_list
  36803. if v == nil {
  36804. return
  36805. }
  36806. return *v, true
  36807. }
  36808. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  36809. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36811. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  36812. if !m.op.Is(OpUpdateOne) {
  36813. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  36814. }
  36815. if m.id == nil || m.oldValue == nil {
  36816. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  36817. }
  36818. oldValue, err := m.oldValue(ctx)
  36819. if err != nil {
  36820. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  36821. }
  36822. return oldValue.GroupAllowList, nil
  36823. }
  36824. // AppendGroupAllowList adds s to the "group_allow_list" field.
  36825. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  36826. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  36827. }
  36828. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  36829. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  36830. if len(m.appendgroup_allow_list) == 0 {
  36831. return nil, false
  36832. }
  36833. return m.appendgroup_allow_list, true
  36834. }
  36835. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  36836. func (m *WhatsappMutation) ClearGroupAllowList() {
  36837. m.group_allow_list = nil
  36838. m.appendgroup_allow_list = nil
  36839. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  36840. }
  36841. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  36842. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  36843. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  36844. return ok
  36845. }
  36846. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  36847. func (m *WhatsappMutation) ResetGroupAllowList() {
  36848. m.group_allow_list = nil
  36849. m.appendgroup_allow_list = nil
  36850. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  36851. }
  36852. // SetBlockList sets the "block_list" field.
  36853. func (m *WhatsappMutation) SetBlockList(s []string) {
  36854. m.block_list = &s
  36855. m.appendblock_list = nil
  36856. }
  36857. // BlockList returns the value of the "block_list" field in the mutation.
  36858. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  36859. v := m.block_list
  36860. if v == nil {
  36861. return
  36862. }
  36863. return *v, true
  36864. }
  36865. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  36866. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36868. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  36869. if !m.op.Is(OpUpdateOne) {
  36870. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  36871. }
  36872. if m.id == nil || m.oldValue == nil {
  36873. return v, errors.New("OldBlockList requires an ID field in the mutation")
  36874. }
  36875. oldValue, err := m.oldValue(ctx)
  36876. if err != nil {
  36877. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  36878. }
  36879. return oldValue.BlockList, nil
  36880. }
  36881. // AppendBlockList adds s to the "block_list" field.
  36882. func (m *WhatsappMutation) AppendBlockList(s []string) {
  36883. m.appendblock_list = append(m.appendblock_list, s...)
  36884. }
  36885. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  36886. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  36887. if len(m.appendblock_list) == 0 {
  36888. return nil, false
  36889. }
  36890. return m.appendblock_list, true
  36891. }
  36892. // ClearBlockList clears the value of the "block_list" field.
  36893. func (m *WhatsappMutation) ClearBlockList() {
  36894. m.block_list = nil
  36895. m.appendblock_list = nil
  36896. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  36897. }
  36898. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  36899. func (m *WhatsappMutation) BlockListCleared() bool {
  36900. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  36901. return ok
  36902. }
  36903. // ResetBlockList resets all changes to the "block_list" field.
  36904. func (m *WhatsappMutation) ResetBlockList() {
  36905. m.block_list = nil
  36906. m.appendblock_list = nil
  36907. delete(m.clearedFields, whatsapp.FieldBlockList)
  36908. }
  36909. // SetGroupBlockList sets the "group_block_list" field.
  36910. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  36911. m.group_block_list = &s
  36912. m.appendgroup_block_list = nil
  36913. }
  36914. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  36915. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  36916. v := m.group_block_list
  36917. if v == nil {
  36918. return
  36919. }
  36920. return *v, true
  36921. }
  36922. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  36923. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36925. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  36926. if !m.op.Is(OpUpdateOne) {
  36927. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  36928. }
  36929. if m.id == nil || m.oldValue == nil {
  36930. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  36931. }
  36932. oldValue, err := m.oldValue(ctx)
  36933. if err != nil {
  36934. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  36935. }
  36936. return oldValue.GroupBlockList, nil
  36937. }
  36938. // AppendGroupBlockList adds s to the "group_block_list" field.
  36939. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  36940. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  36941. }
  36942. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  36943. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  36944. if len(m.appendgroup_block_list) == 0 {
  36945. return nil, false
  36946. }
  36947. return m.appendgroup_block_list, true
  36948. }
  36949. // ClearGroupBlockList clears the value of the "group_block_list" field.
  36950. func (m *WhatsappMutation) ClearGroupBlockList() {
  36951. m.group_block_list = nil
  36952. m.appendgroup_block_list = nil
  36953. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  36954. }
  36955. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  36956. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  36957. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  36958. return ok
  36959. }
  36960. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  36961. func (m *WhatsappMutation) ResetGroupBlockList() {
  36962. m.group_block_list = nil
  36963. m.appendgroup_block_list = nil
  36964. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  36965. }
  36966. // ClearAgent clears the "agent" edge to the Agent entity.
  36967. func (m *WhatsappMutation) ClearAgent() {
  36968. m.clearedagent = true
  36969. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  36970. }
  36971. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  36972. func (m *WhatsappMutation) AgentCleared() bool {
  36973. return m.clearedagent
  36974. }
  36975. // AgentIDs returns the "agent" edge IDs in the mutation.
  36976. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  36977. // AgentID instead. It exists only for internal usage by the builders.
  36978. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  36979. if id := m.agent; id != nil {
  36980. ids = append(ids, *id)
  36981. }
  36982. return
  36983. }
  36984. // ResetAgent resets all changes to the "agent" edge.
  36985. func (m *WhatsappMutation) ResetAgent() {
  36986. m.agent = nil
  36987. m.clearedagent = false
  36988. }
  36989. // Where appends a list predicates to the WhatsappMutation builder.
  36990. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  36991. m.predicates = append(m.predicates, ps...)
  36992. }
  36993. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  36994. // users can use type-assertion to append predicates that do not depend on any generated package.
  36995. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  36996. p := make([]predicate.Whatsapp, len(ps))
  36997. for i := range ps {
  36998. p[i] = ps[i]
  36999. }
  37000. m.Where(p...)
  37001. }
  37002. // Op returns the operation name.
  37003. func (m *WhatsappMutation) Op() Op {
  37004. return m.op
  37005. }
  37006. // SetOp allows setting the mutation operation.
  37007. func (m *WhatsappMutation) SetOp(op Op) {
  37008. m.op = op
  37009. }
  37010. // Type returns the node type of this mutation (Whatsapp).
  37011. func (m *WhatsappMutation) Type() string {
  37012. return m.typ
  37013. }
  37014. // Fields returns all fields that were changed during this mutation. Note that in
  37015. // order to get all numeric fields that were incremented/decremented, call
  37016. // AddedFields().
  37017. func (m *WhatsappMutation) Fields() []string {
  37018. fields := make([]string, 0, 21)
  37019. if m.created_at != nil {
  37020. fields = append(fields, whatsapp.FieldCreatedAt)
  37021. }
  37022. if m.updated_at != nil {
  37023. fields = append(fields, whatsapp.FieldUpdatedAt)
  37024. }
  37025. if m.status != nil {
  37026. fields = append(fields, whatsapp.FieldStatus)
  37027. }
  37028. if m.deleted_at != nil {
  37029. fields = append(fields, whatsapp.FieldDeletedAt)
  37030. }
  37031. if m.wa_id != nil {
  37032. fields = append(fields, whatsapp.FieldWaID)
  37033. }
  37034. if m.wa_name != nil {
  37035. fields = append(fields, whatsapp.FieldWaName)
  37036. }
  37037. if m.callback != nil {
  37038. fields = append(fields, whatsapp.FieldCallback)
  37039. }
  37040. if m.agent != nil {
  37041. fields = append(fields, whatsapp.FieldAgentID)
  37042. }
  37043. if m.account != nil {
  37044. fields = append(fields, whatsapp.FieldAccount)
  37045. }
  37046. if m.cc != nil {
  37047. fields = append(fields, whatsapp.FieldCc)
  37048. }
  37049. if m.phone != nil {
  37050. fields = append(fields, whatsapp.FieldPhone)
  37051. }
  37052. if m.cc_phone != nil {
  37053. fields = append(fields, whatsapp.FieldCcPhone)
  37054. }
  37055. if m.phone_name != nil {
  37056. fields = append(fields, whatsapp.FieldPhoneName)
  37057. }
  37058. if m.phone_status != nil {
  37059. fields = append(fields, whatsapp.FieldPhoneStatus)
  37060. }
  37061. if m.organization_id != nil {
  37062. fields = append(fields, whatsapp.FieldOrganizationID)
  37063. }
  37064. if m.api_base != nil {
  37065. fields = append(fields, whatsapp.FieldAPIBase)
  37066. }
  37067. if m.api_key != nil {
  37068. fields = append(fields, whatsapp.FieldAPIKey)
  37069. }
  37070. if m.allow_list != nil {
  37071. fields = append(fields, whatsapp.FieldAllowList)
  37072. }
  37073. if m.group_allow_list != nil {
  37074. fields = append(fields, whatsapp.FieldGroupAllowList)
  37075. }
  37076. if m.block_list != nil {
  37077. fields = append(fields, whatsapp.FieldBlockList)
  37078. }
  37079. if m.group_block_list != nil {
  37080. fields = append(fields, whatsapp.FieldGroupBlockList)
  37081. }
  37082. return fields
  37083. }
  37084. // Field returns the value of a field with the given name. The second boolean
  37085. // return value indicates that this field was not set, or was not defined in the
  37086. // schema.
  37087. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  37088. switch name {
  37089. case whatsapp.FieldCreatedAt:
  37090. return m.CreatedAt()
  37091. case whatsapp.FieldUpdatedAt:
  37092. return m.UpdatedAt()
  37093. case whatsapp.FieldStatus:
  37094. return m.Status()
  37095. case whatsapp.FieldDeletedAt:
  37096. return m.DeletedAt()
  37097. case whatsapp.FieldWaID:
  37098. return m.WaID()
  37099. case whatsapp.FieldWaName:
  37100. return m.WaName()
  37101. case whatsapp.FieldCallback:
  37102. return m.Callback()
  37103. case whatsapp.FieldAgentID:
  37104. return m.AgentID()
  37105. case whatsapp.FieldAccount:
  37106. return m.Account()
  37107. case whatsapp.FieldCc:
  37108. return m.Cc()
  37109. case whatsapp.FieldPhone:
  37110. return m.Phone()
  37111. case whatsapp.FieldCcPhone:
  37112. return m.CcPhone()
  37113. case whatsapp.FieldPhoneName:
  37114. return m.PhoneName()
  37115. case whatsapp.FieldPhoneStatus:
  37116. return m.PhoneStatus()
  37117. case whatsapp.FieldOrganizationID:
  37118. return m.OrganizationID()
  37119. case whatsapp.FieldAPIBase:
  37120. return m.APIBase()
  37121. case whatsapp.FieldAPIKey:
  37122. return m.APIKey()
  37123. case whatsapp.FieldAllowList:
  37124. return m.AllowList()
  37125. case whatsapp.FieldGroupAllowList:
  37126. return m.GroupAllowList()
  37127. case whatsapp.FieldBlockList:
  37128. return m.BlockList()
  37129. case whatsapp.FieldGroupBlockList:
  37130. return m.GroupBlockList()
  37131. }
  37132. return nil, false
  37133. }
  37134. // OldField returns the old value of the field from the database. An error is
  37135. // returned if the mutation operation is not UpdateOne, or the query to the
  37136. // database failed.
  37137. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37138. switch name {
  37139. case whatsapp.FieldCreatedAt:
  37140. return m.OldCreatedAt(ctx)
  37141. case whatsapp.FieldUpdatedAt:
  37142. return m.OldUpdatedAt(ctx)
  37143. case whatsapp.FieldStatus:
  37144. return m.OldStatus(ctx)
  37145. case whatsapp.FieldDeletedAt:
  37146. return m.OldDeletedAt(ctx)
  37147. case whatsapp.FieldWaID:
  37148. return m.OldWaID(ctx)
  37149. case whatsapp.FieldWaName:
  37150. return m.OldWaName(ctx)
  37151. case whatsapp.FieldCallback:
  37152. return m.OldCallback(ctx)
  37153. case whatsapp.FieldAgentID:
  37154. return m.OldAgentID(ctx)
  37155. case whatsapp.FieldAccount:
  37156. return m.OldAccount(ctx)
  37157. case whatsapp.FieldCc:
  37158. return m.OldCc(ctx)
  37159. case whatsapp.FieldPhone:
  37160. return m.OldPhone(ctx)
  37161. case whatsapp.FieldCcPhone:
  37162. return m.OldCcPhone(ctx)
  37163. case whatsapp.FieldPhoneName:
  37164. return m.OldPhoneName(ctx)
  37165. case whatsapp.FieldPhoneStatus:
  37166. return m.OldPhoneStatus(ctx)
  37167. case whatsapp.FieldOrganizationID:
  37168. return m.OldOrganizationID(ctx)
  37169. case whatsapp.FieldAPIBase:
  37170. return m.OldAPIBase(ctx)
  37171. case whatsapp.FieldAPIKey:
  37172. return m.OldAPIKey(ctx)
  37173. case whatsapp.FieldAllowList:
  37174. return m.OldAllowList(ctx)
  37175. case whatsapp.FieldGroupAllowList:
  37176. return m.OldGroupAllowList(ctx)
  37177. case whatsapp.FieldBlockList:
  37178. return m.OldBlockList(ctx)
  37179. case whatsapp.FieldGroupBlockList:
  37180. return m.OldGroupBlockList(ctx)
  37181. }
  37182. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  37183. }
  37184. // SetField sets the value of a field with the given name. It returns an error if
  37185. // the field is not defined in the schema, or if the type mismatched the field
  37186. // type.
  37187. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  37188. switch name {
  37189. case whatsapp.FieldCreatedAt:
  37190. v, ok := value.(time.Time)
  37191. if !ok {
  37192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37193. }
  37194. m.SetCreatedAt(v)
  37195. return nil
  37196. case whatsapp.FieldUpdatedAt:
  37197. v, ok := value.(time.Time)
  37198. if !ok {
  37199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37200. }
  37201. m.SetUpdatedAt(v)
  37202. return nil
  37203. case whatsapp.FieldStatus:
  37204. v, ok := value.(uint8)
  37205. if !ok {
  37206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37207. }
  37208. m.SetStatus(v)
  37209. return nil
  37210. case whatsapp.FieldDeletedAt:
  37211. v, ok := value.(time.Time)
  37212. if !ok {
  37213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37214. }
  37215. m.SetDeletedAt(v)
  37216. return nil
  37217. case whatsapp.FieldWaID:
  37218. v, ok := value.(string)
  37219. if !ok {
  37220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37221. }
  37222. m.SetWaID(v)
  37223. return nil
  37224. case whatsapp.FieldWaName:
  37225. v, ok := value.(string)
  37226. if !ok {
  37227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37228. }
  37229. m.SetWaName(v)
  37230. return nil
  37231. case whatsapp.FieldCallback:
  37232. v, ok := value.(string)
  37233. if !ok {
  37234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37235. }
  37236. m.SetCallback(v)
  37237. return nil
  37238. case whatsapp.FieldAgentID:
  37239. v, ok := value.(uint64)
  37240. if !ok {
  37241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37242. }
  37243. m.SetAgentID(v)
  37244. return nil
  37245. case whatsapp.FieldAccount:
  37246. v, ok := value.(string)
  37247. if !ok {
  37248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37249. }
  37250. m.SetAccount(v)
  37251. return nil
  37252. case whatsapp.FieldCc:
  37253. v, ok := value.(string)
  37254. if !ok {
  37255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37256. }
  37257. m.SetCc(v)
  37258. return nil
  37259. case whatsapp.FieldPhone:
  37260. v, ok := value.(string)
  37261. if !ok {
  37262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37263. }
  37264. m.SetPhone(v)
  37265. return nil
  37266. case whatsapp.FieldCcPhone:
  37267. v, ok := value.(string)
  37268. if !ok {
  37269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37270. }
  37271. m.SetCcPhone(v)
  37272. return nil
  37273. case whatsapp.FieldPhoneName:
  37274. v, ok := value.(string)
  37275. if !ok {
  37276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37277. }
  37278. m.SetPhoneName(v)
  37279. return nil
  37280. case whatsapp.FieldPhoneStatus:
  37281. v, ok := value.(int8)
  37282. if !ok {
  37283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37284. }
  37285. m.SetPhoneStatus(v)
  37286. return nil
  37287. case whatsapp.FieldOrganizationID:
  37288. v, ok := value.(uint64)
  37289. if !ok {
  37290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37291. }
  37292. m.SetOrganizationID(v)
  37293. return nil
  37294. case whatsapp.FieldAPIBase:
  37295. v, ok := value.(string)
  37296. if !ok {
  37297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37298. }
  37299. m.SetAPIBase(v)
  37300. return nil
  37301. case whatsapp.FieldAPIKey:
  37302. v, ok := value.(string)
  37303. if !ok {
  37304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37305. }
  37306. m.SetAPIKey(v)
  37307. return nil
  37308. case whatsapp.FieldAllowList:
  37309. v, ok := value.([]string)
  37310. if !ok {
  37311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37312. }
  37313. m.SetAllowList(v)
  37314. return nil
  37315. case whatsapp.FieldGroupAllowList:
  37316. v, ok := value.([]string)
  37317. if !ok {
  37318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37319. }
  37320. m.SetGroupAllowList(v)
  37321. return nil
  37322. case whatsapp.FieldBlockList:
  37323. v, ok := value.([]string)
  37324. if !ok {
  37325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37326. }
  37327. m.SetBlockList(v)
  37328. return nil
  37329. case whatsapp.FieldGroupBlockList:
  37330. v, ok := value.([]string)
  37331. if !ok {
  37332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37333. }
  37334. m.SetGroupBlockList(v)
  37335. return nil
  37336. }
  37337. return fmt.Errorf("unknown Whatsapp field %s", name)
  37338. }
  37339. // AddedFields returns all numeric fields that were incremented/decremented during
  37340. // this mutation.
  37341. func (m *WhatsappMutation) AddedFields() []string {
  37342. var fields []string
  37343. if m.addstatus != nil {
  37344. fields = append(fields, whatsapp.FieldStatus)
  37345. }
  37346. if m.addphone_status != nil {
  37347. fields = append(fields, whatsapp.FieldPhoneStatus)
  37348. }
  37349. if m.addorganization_id != nil {
  37350. fields = append(fields, whatsapp.FieldOrganizationID)
  37351. }
  37352. return fields
  37353. }
  37354. // AddedField returns the numeric value that was incremented/decremented on a field
  37355. // with the given name. The second boolean return value indicates that this field
  37356. // was not set, or was not defined in the schema.
  37357. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  37358. switch name {
  37359. case whatsapp.FieldStatus:
  37360. return m.AddedStatus()
  37361. case whatsapp.FieldPhoneStatus:
  37362. return m.AddedPhoneStatus()
  37363. case whatsapp.FieldOrganizationID:
  37364. return m.AddedOrganizationID()
  37365. }
  37366. return nil, false
  37367. }
  37368. // AddField adds the value to the field with the given name. It returns an error if
  37369. // the field is not defined in the schema, or if the type mismatched the field
  37370. // type.
  37371. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  37372. switch name {
  37373. case whatsapp.FieldStatus:
  37374. v, ok := value.(int8)
  37375. if !ok {
  37376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37377. }
  37378. m.AddStatus(v)
  37379. return nil
  37380. case whatsapp.FieldPhoneStatus:
  37381. v, ok := value.(int8)
  37382. if !ok {
  37383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37384. }
  37385. m.AddPhoneStatus(v)
  37386. return nil
  37387. case whatsapp.FieldOrganizationID:
  37388. v, ok := value.(int64)
  37389. if !ok {
  37390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37391. }
  37392. m.AddOrganizationID(v)
  37393. return nil
  37394. }
  37395. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  37396. }
  37397. // ClearedFields returns all nullable fields that were cleared during this
  37398. // mutation.
  37399. func (m *WhatsappMutation) ClearedFields() []string {
  37400. var fields []string
  37401. if m.FieldCleared(whatsapp.FieldStatus) {
  37402. fields = append(fields, whatsapp.FieldStatus)
  37403. }
  37404. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  37405. fields = append(fields, whatsapp.FieldDeletedAt)
  37406. }
  37407. if m.FieldCleared(whatsapp.FieldWaID) {
  37408. fields = append(fields, whatsapp.FieldWaID)
  37409. }
  37410. if m.FieldCleared(whatsapp.FieldWaName) {
  37411. fields = append(fields, whatsapp.FieldWaName)
  37412. }
  37413. if m.FieldCleared(whatsapp.FieldCallback) {
  37414. fields = append(fields, whatsapp.FieldCallback)
  37415. }
  37416. if m.FieldCleared(whatsapp.FieldAccount) {
  37417. fields = append(fields, whatsapp.FieldAccount)
  37418. }
  37419. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  37420. fields = append(fields, whatsapp.FieldOrganizationID)
  37421. }
  37422. if m.FieldCleared(whatsapp.FieldAPIBase) {
  37423. fields = append(fields, whatsapp.FieldAPIBase)
  37424. }
  37425. if m.FieldCleared(whatsapp.FieldAPIKey) {
  37426. fields = append(fields, whatsapp.FieldAPIKey)
  37427. }
  37428. if m.FieldCleared(whatsapp.FieldAllowList) {
  37429. fields = append(fields, whatsapp.FieldAllowList)
  37430. }
  37431. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  37432. fields = append(fields, whatsapp.FieldGroupAllowList)
  37433. }
  37434. if m.FieldCleared(whatsapp.FieldBlockList) {
  37435. fields = append(fields, whatsapp.FieldBlockList)
  37436. }
  37437. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  37438. fields = append(fields, whatsapp.FieldGroupBlockList)
  37439. }
  37440. return fields
  37441. }
  37442. // FieldCleared returns a boolean indicating if a field with the given name was
  37443. // cleared in this mutation.
  37444. func (m *WhatsappMutation) FieldCleared(name string) bool {
  37445. _, ok := m.clearedFields[name]
  37446. return ok
  37447. }
  37448. // ClearField clears the value of the field with the given name. It returns an
  37449. // error if the field is not defined in the schema.
  37450. func (m *WhatsappMutation) ClearField(name string) error {
  37451. switch name {
  37452. case whatsapp.FieldStatus:
  37453. m.ClearStatus()
  37454. return nil
  37455. case whatsapp.FieldDeletedAt:
  37456. m.ClearDeletedAt()
  37457. return nil
  37458. case whatsapp.FieldWaID:
  37459. m.ClearWaID()
  37460. return nil
  37461. case whatsapp.FieldWaName:
  37462. m.ClearWaName()
  37463. return nil
  37464. case whatsapp.FieldCallback:
  37465. m.ClearCallback()
  37466. return nil
  37467. case whatsapp.FieldAccount:
  37468. m.ClearAccount()
  37469. return nil
  37470. case whatsapp.FieldOrganizationID:
  37471. m.ClearOrganizationID()
  37472. return nil
  37473. case whatsapp.FieldAPIBase:
  37474. m.ClearAPIBase()
  37475. return nil
  37476. case whatsapp.FieldAPIKey:
  37477. m.ClearAPIKey()
  37478. return nil
  37479. case whatsapp.FieldAllowList:
  37480. m.ClearAllowList()
  37481. return nil
  37482. case whatsapp.FieldGroupAllowList:
  37483. m.ClearGroupAllowList()
  37484. return nil
  37485. case whatsapp.FieldBlockList:
  37486. m.ClearBlockList()
  37487. return nil
  37488. case whatsapp.FieldGroupBlockList:
  37489. m.ClearGroupBlockList()
  37490. return nil
  37491. }
  37492. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  37493. }
  37494. // ResetField resets all changes in the mutation for the field with the given name.
  37495. // It returns an error if the field is not defined in the schema.
  37496. func (m *WhatsappMutation) ResetField(name string) error {
  37497. switch name {
  37498. case whatsapp.FieldCreatedAt:
  37499. m.ResetCreatedAt()
  37500. return nil
  37501. case whatsapp.FieldUpdatedAt:
  37502. m.ResetUpdatedAt()
  37503. return nil
  37504. case whatsapp.FieldStatus:
  37505. m.ResetStatus()
  37506. return nil
  37507. case whatsapp.FieldDeletedAt:
  37508. m.ResetDeletedAt()
  37509. return nil
  37510. case whatsapp.FieldWaID:
  37511. m.ResetWaID()
  37512. return nil
  37513. case whatsapp.FieldWaName:
  37514. m.ResetWaName()
  37515. return nil
  37516. case whatsapp.FieldCallback:
  37517. m.ResetCallback()
  37518. return nil
  37519. case whatsapp.FieldAgentID:
  37520. m.ResetAgentID()
  37521. return nil
  37522. case whatsapp.FieldAccount:
  37523. m.ResetAccount()
  37524. return nil
  37525. case whatsapp.FieldCc:
  37526. m.ResetCc()
  37527. return nil
  37528. case whatsapp.FieldPhone:
  37529. m.ResetPhone()
  37530. return nil
  37531. case whatsapp.FieldCcPhone:
  37532. m.ResetCcPhone()
  37533. return nil
  37534. case whatsapp.FieldPhoneName:
  37535. m.ResetPhoneName()
  37536. return nil
  37537. case whatsapp.FieldPhoneStatus:
  37538. m.ResetPhoneStatus()
  37539. return nil
  37540. case whatsapp.FieldOrganizationID:
  37541. m.ResetOrganizationID()
  37542. return nil
  37543. case whatsapp.FieldAPIBase:
  37544. m.ResetAPIBase()
  37545. return nil
  37546. case whatsapp.FieldAPIKey:
  37547. m.ResetAPIKey()
  37548. return nil
  37549. case whatsapp.FieldAllowList:
  37550. m.ResetAllowList()
  37551. return nil
  37552. case whatsapp.FieldGroupAllowList:
  37553. m.ResetGroupAllowList()
  37554. return nil
  37555. case whatsapp.FieldBlockList:
  37556. m.ResetBlockList()
  37557. return nil
  37558. case whatsapp.FieldGroupBlockList:
  37559. m.ResetGroupBlockList()
  37560. return nil
  37561. }
  37562. return fmt.Errorf("unknown Whatsapp field %s", name)
  37563. }
  37564. // AddedEdges returns all edge names that were set/added in this mutation.
  37565. func (m *WhatsappMutation) AddedEdges() []string {
  37566. edges := make([]string, 0, 1)
  37567. if m.agent != nil {
  37568. edges = append(edges, whatsapp.EdgeAgent)
  37569. }
  37570. return edges
  37571. }
  37572. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37573. // name in this mutation.
  37574. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  37575. switch name {
  37576. case whatsapp.EdgeAgent:
  37577. if id := m.agent; id != nil {
  37578. return []ent.Value{*id}
  37579. }
  37580. }
  37581. return nil
  37582. }
  37583. // RemovedEdges returns all edge names that were removed in this mutation.
  37584. func (m *WhatsappMutation) RemovedEdges() []string {
  37585. edges := make([]string, 0, 1)
  37586. return edges
  37587. }
  37588. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37589. // the given name in this mutation.
  37590. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  37591. return nil
  37592. }
  37593. // ClearedEdges returns all edge names that were cleared in this mutation.
  37594. func (m *WhatsappMutation) ClearedEdges() []string {
  37595. edges := make([]string, 0, 1)
  37596. if m.clearedagent {
  37597. edges = append(edges, whatsapp.EdgeAgent)
  37598. }
  37599. return edges
  37600. }
  37601. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37602. // was cleared in this mutation.
  37603. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  37604. switch name {
  37605. case whatsapp.EdgeAgent:
  37606. return m.clearedagent
  37607. }
  37608. return false
  37609. }
  37610. // ClearEdge clears the value of the edge with the given name. It returns an error
  37611. // if that edge is not defined in the schema.
  37612. func (m *WhatsappMutation) ClearEdge(name string) error {
  37613. switch name {
  37614. case whatsapp.EdgeAgent:
  37615. m.ClearAgent()
  37616. return nil
  37617. }
  37618. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  37619. }
  37620. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37621. // It returns an error if the edge is not defined in the schema.
  37622. func (m *WhatsappMutation) ResetEdge(name string) error {
  37623. switch name {
  37624. case whatsapp.EdgeAgent:
  37625. m.ResetAgent()
  37626. return nil
  37627. }
  37628. return fmt.Errorf("unknown Whatsapp edge %s", name)
  37629. }
  37630. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  37631. type WhatsappChannelMutation struct {
  37632. config
  37633. op Op
  37634. typ string
  37635. id *uint64
  37636. created_at *time.Time
  37637. updated_at *time.Time
  37638. status *uint8
  37639. addstatus *int8
  37640. deleted_at *time.Time
  37641. ak *string
  37642. sk *string
  37643. wa_id *string
  37644. wa_name *string
  37645. waba_id *uint64
  37646. addwaba_id *int64
  37647. business_id *uint64
  37648. addbusiness_id *int64
  37649. organization_id *uint64
  37650. addorganization_id *int64
  37651. verify_account *string
  37652. clearedFields map[string]struct{}
  37653. done bool
  37654. oldValue func(context.Context) (*WhatsappChannel, error)
  37655. predicates []predicate.WhatsappChannel
  37656. }
  37657. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  37658. // whatsappchannelOption allows management of the mutation configuration using functional options.
  37659. type whatsappchannelOption func(*WhatsappChannelMutation)
  37660. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  37661. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  37662. m := &WhatsappChannelMutation{
  37663. config: c,
  37664. op: op,
  37665. typ: TypeWhatsappChannel,
  37666. clearedFields: make(map[string]struct{}),
  37667. }
  37668. for _, opt := range opts {
  37669. opt(m)
  37670. }
  37671. return m
  37672. }
  37673. // withWhatsappChannelID sets the ID field of the mutation.
  37674. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  37675. return func(m *WhatsappChannelMutation) {
  37676. var (
  37677. err error
  37678. once sync.Once
  37679. value *WhatsappChannel
  37680. )
  37681. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  37682. once.Do(func() {
  37683. if m.done {
  37684. err = errors.New("querying old values post mutation is not allowed")
  37685. } else {
  37686. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  37687. }
  37688. })
  37689. return value, err
  37690. }
  37691. m.id = &id
  37692. }
  37693. }
  37694. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  37695. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  37696. return func(m *WhatsappChannelMutation) {
  37697. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  37698. return node, nil
  37699. }
  37700. m.id = &node.ID
  37701. }
  37702. }
  37703. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37704. // executed in a transaction (ent.Tx), a transactional client is returned.
  37705. func (m WhatsappChannelMutation) Client() *Client {
  37706. client := &Client{config: m.config}
  37707. client.init()
  37708. return client
  37709. }
  37710. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37711. // it returns an error otherwise.
  37712. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  37713. if _, ok := m.driver.(*txDriver); !ok {
  37714. return nil, errors.New("ent: mutation is not running in a transaction")
  37715. }
  37716. tx := &Tx{config: m.config}
  37717. tx.init()
  37718. return tx, nil
  37719. }
  37720. // SetID sets the value of the id field. Note that this
  37721. // operation is only accepted on creation of WhatsappChannel entities.
  37722. func (m *WhatsappChannelMutation) SetID(id uint64) {
  37723. m.id = &id
  37724. }
  37725. // ID returns the ID value in the mutation. Note that the ID is only available
  37726. // if it was provided to the builder or after it was returned from the database.
  37727. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  37728. if m.id == nil {
  37729. return
  37730. }
  37731. return *m.id, true
  37732. }
  37733. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37734. // That means, if the mutation is applied within a transaction with an isolation level such
  37735. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37736. // or updated by the mutation.
  37737. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  37738. switch {
  37739. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37740. id, exists := m.ID()
  37741. if exists {
  37742. return []uint64{id}, nil
  37743. }
  37744. fallthrough
  37745. case m.op.Is(OpUpdate | OpDelete):
  37746. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  37747. default:
  37748. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37749. }
  37750. }
  37751. // SetCreatedAt sets the "created_at" field.
  37752. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  37753. m.created_at = &t
  37754. }
  37755. // CreatedAt returns the value of the "created_at" field in the mutation.
  37756. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  37757. v := m.created_at
  37758. if v == nil {
  37759. return
  37760. }
  37761. return *v, true
  37762. }
  37763. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  37764. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37766. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37767. if !m.op.Is(OpUpdateOne) {
  37768. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37769. }
  37770. if m.id == nil || m.oldValue == nil {
  37771. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37772. }
  37773. oldValue, err := m.oldValue(ctx)
  37774. if err != nil {
  37775. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37776. }
  37777. return oldValue.CreatedAt, nil
  37778. }
  37779. // ResetCreatedAt resets all changes to the "created_at" field.
  37780. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  37781. m.created_at = nil
  37782. }
  37783. // SetUpdatedAt sets the "updated_at" field.
  37784. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  37785. m.updated_at = &t
  37786. }
  37787. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37788. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  37789. v := m.updated_at
  37790. if v == nil {
  37791. return
  37792. }
  37793. return *v, true
  37794. }
  37795. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  37796. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37798. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37799. if !m.op.Is(OpUpdateOne) {
  37800. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37801. }
  37802. if m.id == nil || m.oldValue == nil {
  37803. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37804. }
  37805. oldValue, err := m.oldValue(ctx)
  37806. if err != nil {
  37807. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37808. }
  37809. return oldValue.UpdatedAt, nil
  37810. }
  37811. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37812. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  37813. m.updated_at = nil
  37814. }
  37815. // SetStatus sets the "status" field.
  37816. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  37817. m.status = &u
  37818. m.addstatus = nil
  37819. }
  37820. // Status returns the value of the "status" field in the mutation.
  37821. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  37822. v := m.status
  37823. if v == nil {
  37824. return
  37825. }
  37826. return *v, true
  37827. }
  37828. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  37829. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37831. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37832. if !m.op.Is(OpUpdateOne) {
  37833. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37834. }
  37835. if m.id == nil || m.oldValue == nil {
  37836. return v, errors.New("OldStatus requires an ID field in the mutation")
  37837. }
  37838. oldValue, err := m.oldValue(ctx)
  37839. if err != nil {
  37840. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37841. }
  37842. return oldValue.Status, nil
  37843. }
  37844. // AddStatus adds u to the "status" field.
  37845. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  37846. if m.addstatus != nil {
  37847. *m.addstatus += u
  37848. } else {
  37849. m.addstatus = &u
  37850. }
  37851. }
  37852. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37853. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  37854. v := m.addstatus
  37855. if v == nil {
  37856. return
  37857. }
  37858. return *v, true
  37859. }
  37860. // ClearStatus clears the value of the "status" field.
  37861. func (m *WhatsappChannelMutation) ClearStatus() {
  37862. m.status = nil
  37863. m.addstatus = nil
  37864. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  37865. }
  37866. // StatusCleared returns if the "status" field was cleared in this mutation.
  37867. func (m *WhatsappChannelMutation) StatusCleared() bool {
  37868. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  37869. return ok
  37870. }
  37871. // ResetStatus resets all changes to the "status" field.
  37872. func (m *WhatsappChannelMutation) ResetStatus() {
  37873. m.status = nil
  37874. m.addstatus = nil
  37875. delete(m.clearedFields, whatsappchannel.FieldStatus)
  37876. }
  37877. // SetDeletedAt sets the "deleted_at" field.
  37878. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  37879. m.deleted_at = &t
  37880. }
  37881. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37882. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  37883. v := m.deleted_at
  37884. if v == nil {
  37885. return
  37886. }
  37887. return *v, true
  37888. }
  37889. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  37890. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37892. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37893. if !m.op.Is(OpUpdateOne) {
  37894. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37895. }
  37896. if m.id == nil || m.oldValue == nil {
  37897. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37898. }
  37899. oldValue, err := m.oldValue(ctx)
  37900. if err != nil {
  37901. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37902. }
  37903. return oldValue.DeletedAt, nil
  37904. }
  37905. // ClearDeletedAt clears the value of the "deleted_at" field.
  37906. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  37907. m.deleted_at = nil
  37908. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  37909. }
  37910. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37911. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  37912. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  37913. return ok
  37914. }
  37915. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37916. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  37917. m.deleted_at = nil
  37918. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  37919. }
  37920. // SetAk sets the "ak" field.
  37921. func (m *WhatsappChannelMutation) SetAk(s string) {
  37922. m.ak = &s
  37923. }
  37924. // Ak returns the value of the "ak" field in the mutation.
  37925. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  37926. v := m.ak
  37927. if v == nil {
  37928. return
  37929. }
  37930. return *v, true
  37931. }
  37932. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  37933. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37935. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  37936. if !m.op.Is(OpUpdateOne) {
  37937. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  37938. }
  37939. if m.id == nil || m.oldValue == nil {
  37940. return v, errors.New("OldAk requires an ID field in the mutation")
  37941. }
  37942. oldValue, err := m.oldValue(ctx)
  37943. if err != nil {
  37944. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  37945. }
  37946. return oldValue.Ak, nil
  37947. }
  37948. // ClearAk clears the value of the "ak" field.
  37949. func (m *WhatsappChannelMutation) ClearAk() {
  37950. m.ak = nil
  37951. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  37952. }
  37953. // AkCleared returns if the "ak" field was cleared in this mutation.
  37954. func (m *WhatsappChannelMutation) AkCleared() bool {
  37955. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  37956. return ok
  37957. }
  37958. // ResetAk resets all changes to the "ak" field.
  37959. func (m *WhatsappChannelMutation) ResetAk() {
  37960. m.ak = nil
  37961. delete(m.clearedFields, whatsappchannel.FieldAk)
  37962. }
  37963. // SetSk sets the "sk" field.
  37964. func (m *WhatsappChannelMutation) SetSk(s string) {
  37965. m.sk = &s
  37966. }
  37967. // Sk returns the value of the "sk" field in the mutation.
  37968. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  37969. v := m.sk
  37970. if v == nil {
  37971. return
  37972. }
  37973. return *v, true
  37974. }
  37975. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  37976. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37978. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  37979. if !m.op.Is(OpUpdateOne) {
  37980. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  37981. }
  37982. if m.id == nil || m.oldValue == nil {
  37983. return v, errors.New("OldSk requires an ID field in the mutation")
  37984. }
  37985. oldValue, err := m.oldValue(ctx)
  37986. if err != nil {
  37987. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  37988. }
  37989. return oldValue.Sk, nil
  37990. }
  37991. // ResetSk resets all changes to the "sk" field.
  37992. func (m *WhatsappChannelMutation) ResetSk() {
  37993. m.sk = nil
  37994. }
  37995. // SetWaID sets the "wa_id" field.
  37996. func (m *WhatsappChannelMutation) SetWaID(s string) {
  37997. m.wa_id = &s
  37998. }
  37999. // WaID returns the value of the "wa_id" field in the mutation.
  38000. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  38001. v := m.wa_id
  38002. if v == nil {
  38003. return
  38004. }
  38005. return *v, true
  38006. }
  38007. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  38008. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38010. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  38011. if !m.op.Is(OpUpdateOne) {
  38012. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  38013. }
  38014. if m.id == nil || m.oldValue == nil {
  38015. return v, errors.New("OldWaID requires an ID field in the mutation")
  38016. }
  38017. oldValue, err := m.oldValue(ctx)
  38018. if err != nil {
  38019. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  38020. }
  38021. return oldValue.WaID, nil
  38022. }
  38023. // ClearWaID clears the value of the "wa_id" field.
  38024. func (m *WhatsappChannelMutation) ClearWaID() {
  38025. m.wa_id = nil
  38026. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  38027. }
  38028. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  38029. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  38030. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  38031. return ok
  38032. }
  38033. // ResetWaID resets all changes to the "wa_id" field.
  38034. func (m *WhatsappChannelMutation) ResetWaID() {
  38035. m.wa_id = nil
  38036. delete(m.clearedFields, whatsappchannel.FieldWaID)
  38037. }
  38038. // SetWaName sets the "wa_name" field.
  38039. func (m *WhatsappChannelMutation) SetWaName(s string) {
  38040. m.wa_name = &s
  38041. }
  38042. // WaName returns the value of the "wa_name" field in the mutation.
  38043. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  38044. v := m.wa_name
  38045. if v == nil {
  38046. return
  38047. }
  38048. return *v, true
  38049. }
  38050. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  38051. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38053. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  38054. if !m.op.Is(OpUpdateOne) {
  38055. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  38056. }
  38057. if m.id == nil || m.oldValue == nil {
  38058. return v, errors.New("OldWaName requires an ID field in the mutation")
  38059. }
  38060. oldValue, err := m.oldValue(ctx)
  38061. if err != nil {
  38062. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  38063. }
  38064. return oldValue.WaName, nil
  38065. }
  38066. // ClearWaName clears the value of the "wa_name" field.
  38067. func (m *WhatsappChannelMutation) ClearWaName() {
  38068. m.wa_name = nil
  38069. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  38070. }
  38071. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  38072. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  38073. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  38074. return ok
  38075. }
  38076. // ResetWaName resets all changes to the "wa_name" field.
  38077. func (m *WhatsappChannelMutation) ResetWaName() {
  38078. m.wa_name = nil
  38079. delete(m.clearedFields, whatsappchannel.FieldWaName)
  38080. }
  38081. // SetWabaID sets the "waba_id" field.
  38082. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  38083. m.waba_id = &u
  38084. m.addwaba_id = nil
  38085. }
  38086. // WabaID returns the value of the "waba_id" field in the mutation.
  38087. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  38088. v := m.waba_id
  38089. if v == nil {
  38090. return
  38091. }
  38092. return *v, true
  38093. }
  38094. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  38095. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38097. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  38098. if !m.op.Is(OpUpdateOne) {
  38099. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  38100. }
  38101. if m.id == nil || m.oldValue == nil {
  38102. return v, errors.New("OldWabaID requires an ID field in the mutation")
  38103. }
  38104. oldValue, err := m.oldValue(ctx)
  38105. if err != nil {
  38106. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  38107. }
  38108. return oldValue.WabaID, nil
  38109. }
  38110. // AddWabaID adds u to the "waba_id" field.
  38111. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  38112. if m.addwaba_id != nil {
  38113. *m.addwaba_id += u
  38114. } else {
  38115. m.addwaba_id = &u
  38116. }
  38117. }
  38118. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  38119. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  38120. v := m.addwaba_id
  38121. if v == nil {
  38122. return
  38123. }
  38124. return *v, true
  38125. }
  38126. // ResetWabaID resets all changes to the "waba_id" field.
  38127. func (m *WhatsappChannelMutation) ResetWabaID() {
  38128. m.waba_id = nil
  38129. m.addwaba_id = nil
  38130. }
  38131. // SetBusinessID sets the "business_id" field.
  38132. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  38133. m.business_id = &u
  38134. m.addbusiness_id = nil
  38135. }
  38136. // BusinessID returns the value of the "business_id" field in the mutation.
  38137. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  38138. v := m.business_id
  38139. if v == nil {
  38140. return
  38141. }
  38142. return *v, true
  38143. }
  38144. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  38145. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38147. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  38148. if !m.op.Is(OpUpdateOne) {
  38149. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  38150. }
  38151. if m.id == nil || m.oldValue == nil {
  38152. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  38153. }
  38154. oldValue, err := m.oldValue(ctx)
  38155. if err != nil {
  38156. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  38157. }
  38158. return oldValue.BusinessID, nil
  38159. }
  38160. // AddBusinessID adds u to the "business_id" field.
  38161. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  38162. if m.addbusiness_id != nil {
  38163. *m.addbusiness_id += u
  38164. } else {
  38165. m.addbusiness_id = &u
  38166. }
  38167. }
  38168. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  38169. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  38170. v := m.addbusiness_id
  38171. if v == nil {
  38172. return
  38173. }
  38174. return *v, true
  38175. }
  38176. // ResetBusinessID resets all changes to the "business_id" field.
  38177. func (m *WhatsappChannelMutation) ResetBusinessID() {
  38178. m.business_id = nil
  38179. m.addbusiness_id = nil
  38180. }
  38181. // SetOrganizationID sets the "organization_id" field.
  38182. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  38183. m.organization_id = &u
  38184. m.addorganization_id = nil
  38185. }
  38186. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38187. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  38188. v := m.organization_id
  38189. if v == nil {
  38190. return
  38191. }
  38192. return *v, true
  38193. }
  38194. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  38195. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38197. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38198. if !m.op.Is(OpUpdateOne) {
  38199. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38200. }
  38201. if m.id == nil || m.oldValue == nil {
  38202. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38203. }
  38204. oldValue, err := m.oldValue(ctx)
  38205. if err != nil {
  38206. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38207. }
  38208. return oldValue.OrganizationID, nil
  38209. }
  38210. // AddOrganizationID adds u to the "organization_id" field.
  38211. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  38212. if m.addorganization_id != nil {
  38213. *m.addorganization_id += u
  38214. } else {
  38215. m.addorganization_id = &u
  38216. }
  38217. }
  38218. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38219. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  38220. v := m.addorganization_id
  38221. if v == nil {
  38222. return
  38223. }
  38224. return *v, true
  38225. }
  38226. // ClearOrganizationID clears the value of the "organization_id" field.
  38227. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  38228. m.organization_id = nil
  38229. m.addorganization_id = nil
  38230. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  38231. }
  38232. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38233. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  38234. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  38235. return ok
  38236. }
  38237. // ResetOrganizationID resets all changes to the "organization_id" field.
  38238. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  38239. m.organization_id = nil
  38240. m.addorganization_id = nil
  38241. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  38242. }
  38243. // SetVerifyAccount sets the "verify_account" field.
  38244. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  38245. m.verify_account = &s
  38246. }
  38247. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  38248. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  38249. v := m.verify_account
  38250. if v == nil {
  38251. return
  38252. }
  38253. return *v, true
  38254. }
  38255. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  38256. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38258. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  38259. if !m.op.Is(OpUpdateOne) {
  38260. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  38261. }
  38262. if m.id == nil || m.oldValue == nil {
  38263. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  38264. }
  38265. oldValue, err := m.oldValue(ctx)
  38266. if err != nil {
  38267. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  38268. }
  38269. return oldValue.VerifyAccount, nil
  38270. }
  38271. // ResetVerifyAccount resets all changes to the "verify_account" field.
  38272. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  38273. m.verify_account = nil
  38274. }
  38275. // Where appends a list predicates to the WhatsappChannelMutation builder.
  38276. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  38277. m.predicates = append(m.predicates, ps...)
  38278. }
  38279. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  38280. // users can use type-assertion to append predicates that do not depend on any generated package.
  38281. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  38282. p := make([]predicate.WhatsappChannel, len(ps))
  38283. for i := range ps {
  38284. p[i] = ps[i]
  38285. }
  38286. m.Where(p...)
  38287. }
  38288. // Op returns the operation name.
  38289. func (m *WhatsappChannelMutation) Op() Op {
  38290. return m.op
  38291. }
  38292. // SetOp allows setting the mutation operation.
  38293. func (m *WhatsappChannelMutation) SetOp(op Op) {
  38294. m.op = op
  38295. }
  38296. // Type returns the node type of this mutation (WhatsappChannel).
  38297. func (m *WhatsappChannelMutation) Type() string {
  38298. return m.typ
  38299. }
  38300. // Fields returns all fields that were changed during this mutation. Note that in
  38301. // order to get all numeric fields that were incremented/decremented, call
  38302. // AddedFields().
  38303. func (m *WhatsappChannelMutation) Fields() []string {
  38304. fields := make([]string, 0, 12)
  38305. if m.created_at != nil {
  38306. fields = append(fields, whatsappchannel.FieldCreatedAt)
  38307. }
  38308. if m.updated_at != nil {
  38309. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  38310. }
  38311. if m.status != nil {
  38312. fields = append(fields, whatsappchannel.FieldStatus)
  38313. }
  38314. if m.deleted_at != nil {
  38315. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38316. }
  38317. if m.ak != nil {
  38318. fields = append(fields, whatsappchannel.FieldAk)
  38319. }
  38320. if m.sk != nil {
  38321. fields = append(fields, whatsappchannel.FieldSk)
  38322. }
  38323. if m.wa_id != nil {
  38324. fields = append(fields, whatsappchannel.FieldWaID)
  38325. }
  38326. if m.wa_name != nil {
  38327. fields = append(fields, whatsappchannel.FieldWaName)
  38328. }
  38329. if m.waba_id != nil {
  38330. fields = append(fields, whatsappchannel.FieldWabaID)
  38331. }
  38332. if m.business_id != nil {
  38333. fields = append(fields, whatsappchannel.FieldBusinessID)
  38334. }
  38335. if m.organization_id != nil {
  38336. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38337. }
  38338. if m.verify_account != nil {
  38339. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  38340. }
  38341. return fields
  38342. }
  38343. // Field returns the value of a field with the given name. The second boolean
  38344. // return value indicates that this field was not set, or was not defined in the
  38345. // schema.
  38346. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  38347. switch name {
  38348. case whatsappchannel.FieldCreatedAt:
  38349. return m.CreatedAt()
  38350. case whatsappchannel.FieldUpdatedAt:
  38351. return m.UpdatedAt()
  38352. case whatsappchannel.FieldStatus:
  38353. return m.Status()
  38354. case whatsappchannel.FieldDeletedAt:
  38355. return m.DeletedAt()
  38356. case whatsappchannel.FieldAk:
  38357. return m.Ak()
  38358. case whatsappchannel.FieldSk:
  38359. return m.Sk()
  38360. case whatsappchannel.FieldWaID:
  38361. return m.WaID()
  38362. case whatsappchannel.FieldWaName:
  38363. return m.WaName()
  38364. case whatsappchannel.FieldWabaID:
  38365. return m.WabaID()
  38366. case whatsappchannel.FieldBusinessID:
  38367. return m.BusinessID()
  38368. case whatsappchannel.FieldOrganizationID:
  38369. return m.OrganizationID()
  38370. case whatsappchannel.FieldVerifyAccount:
  38371. return m.VerifyAccount()
  38372. }
  38373. return nil, false
  38374. }
  38375. // OldField returns the old value of the field from the database. An error is
  38376. // returned if the mutation operation is not UpdateOne, or the query to the
  38377. // database failed.
  38378. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38379. switch name {
  38380. case whatsappchannel.FieldCreatedAt:
  38381. return m.OldCreatedAt(ctx)
  38382. case whatsappchannel.FieldUpdatedAt:
  38383. return m.OldUpdatedAt(ctx)
  38384. case whatsappchannel.FieldStatus:
  38385. return m.OldStatus(ctx)
  38386. case whatsappchannel.FieldDeletedAt:
  38387. return m.OldDeletedAt(ctx)
  38388. case whatsappchannel.FieldAk:
  38389. return m.OldAk(ctx)
  38390. case whatsappchannel.FieldSk:
  38391. return m.OldSk(ctx)
  38392. case whatsappchannel.FieldWaID:
  38393. return m.OldWaID(ctx)
  38394. case whatsappchannel.FieldWaName:
  38395. return m.OldWaName(ctx)
  38396. case whatsappchannel.FieldWabaID:
  38397. return m.OldWabaID(ctx)
  38398. case whatsappchannel.FieldBusinessID:
  38399. return m.OldBusinessID(ctx)
  38400. case whatsappchannel.FieldOrganizationID:
  38401. return m.OldOrganizationID(ctx)
  38402. case whatsappchannel.FieldVerifyAccount:
  38403. return m.OldVerifyAccount(ctx)
  38404. }
  38405. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  38406. }
  38407. // SetField sets the value of a field with the given name. It returns an error if
  38408. // the field is not defined in the schema, or if the type mismatched the field
  38409. // type.
  38410. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  38411. switch name {
  38412. case whatsappchannel.FieldCreatedAt:
  38413. v, ok := value.(time.Time)
  38414. if !ok {
  38415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38416. }
  38417. m.SetCreatedAt(v)
  38418. return nil
  38419. case whatsappchannel.FieldUpdatedAt:
  38420. v, ok := value.(time.Time)
  38421. if !ok {
  38422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38423. }
  38424. m.SetUpdatedAt(v)
  38425. return nil
  38426. case whatsappchannel.FieldStatus:
  38427. v, ok := value.(uint8)
  38428. if !ok {
  38429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38430. }
  38431. m.SetStatus(v)
  38432. return nil
  38433. case whatsappchannel.FieldDeletedAt:
  38434. v, ok := value.(time.Time)
  38435. if !ok {
  38436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38437. }
  38438. m.SetDeletedAt(v)
  38439. return nil
  38440. case whatsappchannel.FieldAk:
  38441. v, ok := value.(string)
  38442. if !ok {
  38443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38444. }
  38445. m.SetAk(v)
  38446. return nil
  38447. case whatsappchannel.FieldSk:
  38448. v, ok := value.(string)
  38449. if !ok {
  38450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38451. }
  38452. m.SetSk(v)
  38453. return nil
  38454. case whatsappchannel.FieldWaID:
  38455. v, ok := value.(string)
  38456. if !ok {
  38457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38458. }
  38459. m.SetWaID(v)
  38460. return nil
  38461. case whatsappchannel.FieldWaName:
  38462. v, ok := value.(string)
  38463. if !ok {
  38464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38465. }
  38466. m.SetWaName(v)
  38467. return nil
  38468. case whatsappchannel.FieldWabaID:
  38469. v, ok := value.(uint64)
  38470. if !ok {
  38471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38472. }
  38473. m.SetWabaID(v)
  38474. return nil
  38475. case whatsappchannel.FieldBusinessID:
  38476. v, ok := value.(uint64)
  38477. if !ok {
  38478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38479. }
  38480. m.SetBusinessID(v)
  38481. return nil
  38482. case whatsappchannel.FieldOrganizationID:
  38483. v, ok := value.(uint64)
  38484. if !ok {
  38485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38486. }
  38487. m.SetOrganizationID(v)
  38488. return nil
  38489. case whatsappchannel.FieldVerifyAccount:
  38490. v, ok := value.(string)
  38491. if !ok {
  38492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38493. }
  38494. m.SetVerifyAccount(v)
  38495. return nil
  38496. }
  38497. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38498. }
  38499. // AddedFields returns all numeric fields that were incremented/decremented during
  38500. // this mutation.
  38501. func (m *WhatsappChannelMutation) AddedFields() []string {
  38502. var fields []string
  38503. if m.addstatus != nil {
  38504. fields = append(fields, whatsappchannel.FieldStatus)
  38505. }
  38506. if m.addwaba_id != nil {
  38507. fields = append(fields, whatsappchannel.FieldWabaID)
  38508. }
  38509. if m.addbusiness_id != nil {
  38510. fields = append(fields, whatsappchannel.FieldBusinessID)
  38511. }
  38512. if m.addorganization_id != nil {
  38513. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38514. }
  38515. return fields
  38516. }
  38517. // AddedField returns the numeric value that was incremented/decremented on a field
  38518. // with the given name. The second boolean return value indicates that this field
  38519. // was not set, or was not defined in the schema.
  38520. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  38521. switch name {
  38522. case whatsappchannel.FieldStatus:
  38523. return m.AddedStatus()
  38524. case whatsappchannel.FieldWabaID:
  38525. return m.AddedWabaID()
  38526. case whatsappchannel.FieldBusinessID:
  38527. return m.AddedBusinessID()
  38528. case whatsappchannel.FieldOrganizationID:
  38529. return m.AddedOrganizationID()
  38530. }
  38531. return nil, false
  38532. }
  38533. // AddField adds the value to the field with the given name. It returns an error if
  38534. // the field is not defined in the schema, or if the type mismatched the field
  38535. // type.
  38536. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  38537. switch name {
  38538. case whatsappchannel.FieldStatus:
  38539. v, ok := value.(int8)
  38540. if !ok {
  38541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38542. }
  38543. m.AddStatus(v)
  38544. return nil
  38545. case whatsappchannel.FieldWabaID:
  38546. v, ok := value.(int64)
  38547. if !ok {
  38548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38549. }
  38550. m.AddWabaID(v)
  38551. return nil
  38552. case whatsappchannel.FieldBusinessID:
  38553. v, ok := value.(int64)
  38554. if !ok {
  38555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38556. }
  38557. m.AddBusinessID(v)
  38558. return nil
  38559. case whatsappchannel.FieldOrganizationID:
  38560. v, ok := value.(int64)
  38561. if !ok {
  38562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38563. }
  38564. m.AddOrganizationID(v)
  38565. return nil
  38566. }
  38567. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  38568. }
  38569. // ClearedFields returns all nullable fields that were cleared during this
  38570. // mutation.
  38571. func (m *WhatsappChannelMutation) ClearedFields() []string {
  38572. var fields []string
  38573. if m.FieldCleared(whatsappchannel.FieldStatus) {
  38574. fields = append(fields, whatsappchannel.FieldStatus)
  38575. }
  38576. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  38577. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38578. }
  38579. if m.FieldCleared(whatsappchannel.FieldAk) {
  38580. fields = append(fields, whatsappchannel.FieldAk)
  38581. }
  38582. if m.FieldCleared(whatsappchannel.FieldWaID) {
  38583. fields = append(fields, whatsappchannel.FieldWaID)
  38584. }
  38585. if m.FieldCleared(whatsappchannel.FieldWaName) {
  38586. fields = append(fields, whatsappchannel.FieldWaName)
  38587. }
  38588. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  38589. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38590. }
  38591. return fields
  38592. }
  38593. // FieldCleared returns a boolean indicating if a field with the given name was
  38594. // cleared in this mutation.
  38595. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  38596. _, ok := m.clearedFields[name]
  38597. return ok
  38598. }
  38599. // ClearField clears the value of the field with the given name. It returns an
  38600. // error if the field is not defined in the schema.
  38601. func (m *WhatsappChannelMutation) ClearField(name string) error {
  38602. switch name {
  38603. case whatsappchannel.FieldStatus:
  38604. m.ClearStatus()
  38605. return nil
  38606. case whatsappchannel.FieldDeletedAt:
  38607. m.ClearDeletedAt()
  38608. return nil
  38609. case whatsappchannel.FieldAk:
  38610. m.ClearAk()
  38611. return nil
  38612. case whatsappchannel.FieldWaID:
  38613. m.ClearWaID()
  38614. return nil
  38615. case whatsappchannel.FieldWaName:
  38616. m.ClearWaName()
  38617. return nil
  38618. case whatsappchannel.FieldOrganizationID:
  38619. m.ClearOrganizationID()
  38620. return nil
  38621. }
  38622. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  38623. }
  38624. // ResetField resets all changes in the mutation for the field with the given name.
  38625. // It returns an error if the field is not defined in the schema.
  38626. func (m *WhatsappChannelMutation) ResetField(name string) error {
  38627. switch name {
  38628. case whatsappchannel.FieldCreatedAt:
  38629. m.ResetCreatedAt()
  38630. return nil
  38631. case whatsappchannel.FieldUpdatedAt:
  38632. m.ResetUpdatedAt()
  38633. return nil
  38634. case whatsappchannel.FieldStatus:
  38635. m.ResetStatus()
  38636. return nil
  38637. case whatsappchannel.FieldDeletedAt:
  38638. m.ResetDeletedAt()
  38639. return nil
  38640. case whatsappchannel.FieldAk:
  38641. m.ResetAk()
  38642. return nil
  38643. case whatsappchannel.FieldSk:
  38644. m.ResetSk()
  38645. return nil
  38646. case whatsappchannel.FieldWaID:
  38647. m.ResetWaID()
  38648. return nil
  38649. case whatsappchannel.FieldWaName:
  38650. m.ResetWaName()
  38651. return nil
  38652. case whatsappchannel.FieldWabaID:
  38653. m.ResetWabaID()
  38654. return nil
  38655. case whatsappchannel.FieldBusinessID:
  38656. m.ResetBusinessID()
  38657. return nil
  38658. case whatsappchannel.FieldOrganizationID:
  38659. m.ResetOrganizationID()
  38660. return nil
  38661. case whatsappchannel.FieldVerifyAccount:
  38662. m.ResetVerifyAccount()
  38663. return nil
  38664. }
  38665. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38666. }
  38667. // AddedEdges returns all edge names that were set/added in this mutation.
  38668. func (m *WhatsappChannelMutation) AddedEdges() []string {
  38669. edges := make([]string, 0, 0)
  38670. return edges
  38671. }
  38672. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38673. // name in this mutation.
  38674. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  38675. return nil
  38676. }
  38677. // RemovedEdges returns all edge names that were removed in this mutation.
  38678. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  38679. edges := make([]string, 0, 0)
  38680. return edges
  38681. }
  38682. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38683. // the given name in this mutation.
  38684. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  38685. return nil
  38686. }
  38687. // ClearedEdges returns all edge names that were cleared in this mutation.
  38688. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  38689. edges := make([]string, 0, 0)
  38690. return edges
  38691. }
  38692. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38693. // was cleared in this mutation.
  38694. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  38695. return false
  38696. }
  38697. // ClearEdge clears the value of the edge with the given name. It returns an error
  38698. // if that edge is not defined in the schema.
  38699. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  38700. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  38701. }
  38702. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38703. // It returns an error if the edge is not defined in the schema.
  38704. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  38705. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  38706. }
  38707. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  38708. type WorkExperienceMutation struct {
  38709. config
  38710. op Op
  38711. typ string
  38712. id *uint64
  38713. created_at *time.Time
  38714. updated_at *time.Time
  38715. deleted_at *time.Time
  38716. start_date *time.Time
  38717. end_date *time.Time
  38718. company *string
  38719. experience *string
  38720. organization_id *uint64
  38721. addorganization_id *int64
  38722. clearedFields map[string]struct{}
  38723. employee *uint64
  38724. clearedemployee bool
  38725. done bool
  38726. oldValue func(context.Context) (*WorkExperience, error)
  38727. predicates []predicate.WorkExperience
  38728. }
  38729. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  38730. // workexperienceOption allows management of the mutation configuration using functional options.
  38731. type workexperienceOption func(*WorkExperienceMutation)
  38732. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  38733. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  38734. m := &WorkExperienceMutation{
  38735. config: c,
  38736. op: op,
  38737. typ: TypeWorkExperience,
  38738. clearedFields: make(map[string]struct{}),
  38739. }
  38740. for _, opt := range opts {
  38741. opt(m)
  38742. }
  38743. return m
  38744. }
  38745. // withWorkExperienceID sets the ID field of the mutation.
  38746. func withWorkExperienceID(id uint64) workexperienceOption {
  38747. return func(m *WorkExperienceMutation) {
  38748. var (
  38749. err error
  38750. once sync.Once
  38751. value *WorkExperience
  38752. )
  38753. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  38754. once.Do(func() {
  38755. if m.done {
  38756. err = errors.New("querying old values post mutation is not allowed")
  38757. } else {
  38758. value, err = m.Client().WorkExperience.Get(ctx, id)
  38759. }
  38760. })
  38761. return value, err
  38762. }
  38763. m.id = &id
  38764. }
  38765. }
  38766. // withWorkExperience sets the old WorkExperience of the mutation.
  38767. func withWorkExperience(node *WorkExperience) workexperienceOption {
  38768. return func(m *WorkExperienceMutation) {
  38769. m.oldValue = func(context.Context) (*WorkExperience, error) {
  38770. return node, nil
  38771. }
  38772. m.id = &node.ID
  38773. }
  38774. }
  38775. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38776. // executed in a transaction (ent.Tx), a transactional client is returned.
  38777. func (m WorkExperienceMutation) Client() *Client {
  38778. client := &Client{config: m.config}
  38779. client.init()
  38780. return client
  38781. }
  38782. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38783. // it returns an error otherwise.
  38784. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  38785. if _, ok := m.driver.(*txDriver); !ok {
  38786. return nil, errors.New("ent: mutation is not running in a transaction")
  38787. }
  38788. tx := &Tx{config: m.config}
  38789. tx.init()
  38790. return tx, nil
  38791. }
  38792. // SetID sets the value of the id field. Note that this
  38793. // operation is only accepted on creation of WorkExperience entities.
  38794. func (m *WorkExperienceMutation) SetID(id uint64) {
  38795. m.id = &id
  38796. }
  38797. // ID returns the ID value in the mutation. Note that the ID is only available
  38798. // if it was provided to the builder or after it was returned from the database.
  38799. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  38800. if m.id == nil {
  38801. return
  38802. }
  38803. return *m.id, true
  38804. }
  38805. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38806. // That means, if the mutation is applied within a transaction with an isolation level such
  38807. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38808. // or updated by the mutation.
  38809. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  38810. switch {
  38811. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38812. id, exists := m.ID()
  38813. if exists {
  38814. return []uint64{id}, nil
  38815. }
  38816. fallthrough
  38817. case m.op.Is(OpUpdate | OpDelete):
  38818. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  38819. default:
  38820. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38821. }
  38822. }
  38823. // SetCreatedAt sets the "created_at" field.
  38824. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  38825. m.created_at = &t
  38826. }
  38827. // CreatedAt returns the value of the "created_at" field in the mutation.
  38828. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  38829. v := m.created_at
  38830. if v == nil {
  38831. return
  38832. }
  38833. return *v, true
  38834. }
  38835. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  38836. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38838. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38839. if !m.op.Is(OpUpdateOne) {
  38840. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38841. }
  38842. if m.id == nil || m.oldValue == nil {
  38843. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38844. }
  38845. oldValue, err := m.oldValue(ctx)
  38846. if err != nil {
  38847. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38848. }
  38849. return oldValue.CreatedAt, nil
  38850. }
  38851. // ResetCreatedAt resets all changes to the "created_at" field.
  38852. func (m *WorkExperienceMutation) ResetCreatedAt() {
  38853. m.created_at = nil
  38854. }
  38855. // SetUpdatedAt sets the "updated_at" field.
  38856. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  38857. m.updated_at = &t
  38858. }
  38859. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38860. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  38861. v := m.updated_at
  38862. if v == nil {
  38863. return
  38864. }
  38865. return *v, true
  38866. }
  38867. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  38868. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38870. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38871. if !m.op.Is(OpUpdateOne) {
  38872. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38873. }
  38874. if m.id == nil || m.oldValue == nil {
  38875. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38876. }
  38877. oldValue, err := m.oldValue(ctx)
  38878. if err != nil {
  38879. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38880. }
  38881. return oldValue.UpdatedAt, nil
  38882. }
  38883. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38884. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  38885. m.updated_at = nil
  38886. }
  38887. // SetDeletedAt sets the "deleted_at" field.
  38888. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  38889. m.deleted_at = &t
  38890. }
  38891. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38892. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  38893. v := m.deleted_at
  38894. if v == nil {
  38895. return
  38896. }
  38897. return *v, true
  38898. }
  38899. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  38900. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38902. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38903. if !m.op.Is(OpUpdateOne) {
  38904. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38905. }
  38906. if m.id == nil || m.oldValue == nil {
  38907. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38908. }
  38909. oldValue, err := m.oldValue(ctx)
  38910. if err != nil {
  38911. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38912. }
  38913. return oldValue.DeletedAt, nil
  38914. }
  38915. // ClearDeletedAt clears the value of the "deleted_at" field.
  38916. func (m *WorkExperienceMutation) ClearDeletedAt() {
  38917. m.deleted_at = nil
  38918. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  38919. }
  38920. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38921. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  38922. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  38923. return ok
  38924. }
  38925. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38926. func (m *WorkExperienceMutation) ResetDeletedAt() {
  38927. m.deleted_at = nil
  38928. delete(m.clearedFields, workexperience.FieldDeletedAt)
  38929. }
  38930. // SetEmployeeID sets the "employee_id" field.
  38931. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  38932. m.employee = &u
  38933. }
  38934. // EmployeeID returns the value of the "employee_id" field in the mutation.
  38935. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  38936. v := m.employee
  38937. if v == nil {
  38938. return
  38939. }
  38940. return *v, true
  38941. }
  38942. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  38943. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38945. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  38946. if !m.op.Is(OpUpdateOne) {
  38947. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  38948. }
  38949. if m.id == nil || m.oldValue == nil {
  38950. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  38951. }
  38952. oldValue, err := m.oldValue(ctx)
  38953. if err != nil {
  38954. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  38955. }
  38956. return oldValue.EmployeeID, nil
  38957. }
  38958. // ResetEmployeeID resets all changes to the "employee_id" field.
  38959. func (m *WorkExperienceMutation) ResetEmployeeID() {
  38960. m.employee = nil
  38961. }
  38962. // SetStartDate sets the "start_date" field.
  38963. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  38964. m.start_date = &t
  38965. }
  38966. // StartDate returns the value of the "start_date" field in the mutation.
  38967. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  38968. v := m.start_date
  38969. if v == nil {
  38970. return
  38971. }
  38972. return *v, true
  38973. }
  38974. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  38975. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38977. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  38978. if !m.op.Is(OpUpdateOne) {
  38979. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  38980. }
  38981. if m.id == nil || m.oldValue == nil {
  38982. return v, errors.New("OldStartDate requires an ID field in the mutation")
  38983. }
  38984. oldValue, err := m.oldValue(ctx)
  38985. if err != nil {
  38986. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  38987. }
  38988. return oldValue.StartDate, nil
  38989. }
  38990. // ResetStartDate resets all changes to the "start_date" field.
  38991. func (m *WorkExperienceMutation) ResetStartDate() {
  38992. m.start_date = nil
  38993. }
  38994. // SetEndDate sets the "end_date" field.
  38995. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  38996. m.end_date = &t
  38997. }
  38998. // EndDate returns the value of the "end_date" field in the mutation.
  38999. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  39000. v := m.end_date
  39001. if v == nil {
  39002. return
  39003. }
  39004. return *v, true
  39005. }
  39006. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  39007. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39009. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  39010. if !m.op.Is(OpUpdateOne) {
  39011. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  39012. }
  39013. if m.id == nil || m.oldValue == nil {
  39014. return v, errors.New("OldEndDate requires an ID field in the mutation")
  39015. }
  39016. oldValue, err := m.oldValue(ctx)
  39017. if err != nil {
  39018. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  39019. }
  39020. return oldValue.EndDate, nil
  39021. }
  39022. // ResetEndDate resets all changes to the "end_date" field.
  39023. func (m *WorkExperienceMutation) ResetEndDate() {
  39024. m.end_date = nil
  39025. }
  39026. // SetCompany sets the "company" field.
  39027. func (m *WorkExperienceMutation) SetCompany(s string) {
  39028. m.company = &s
  39029. }
  39030. // Company returns the value of the "company" field in the mutation.
  39031. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  39032. v := m.company
  39033. if v == nil {
  39034. return
  39035. }
  39036. return *v, true
  39037. }
  39038. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  39039. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39041. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  39042. if !m.op.Is(OpUpdateOne) {
  39043. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39044. }
  39045. if m.id == nil || m.oldValue == nil {
  39046. return v, errors.New("OldCompany requires an ID field in the mutation")
  39047. }
  39048. oldValue, err := m.oldValue(ctx)
  39049. if err != nil {
  39050. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39051. }
  39052. return oldValue.Company, nil
  39053. }
  39054. // ResetCompany resets all changes to the "company" field.
  39055. func (m *WorkExperienceMutation) ResetCompany() {
  39056. m.company = nil
  39057. }
  39058. // SetExperience sets the "experience" field.
  39059. func (m *WorkExperienceMutation) SetExperience(s string) {
  39060. m.experience = &s
  39061. }
  39062. // Experience returns the value of the "experience" field in the mutation.
  39063. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  39064. v := m.experience
  39065. if v == nil {
  39066. return
  39067. }
  39068. return *v, true
  39069. }
  39070. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  39071. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39073. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  39074. if !m.op.Is(OpUpdateOne) {
  39075. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  39076. }
  39077. if m.id == nil || m.oldValue == nil {
  39078. return v, errors.New("OldExperience requires an ID field in the mutation")
  39079. }
  39080. oldValue, err := m.oldValue(ctx)
  39081. if err != nil {
  39082. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  39083. }
  39084. return oldValue.Experience, nil
  39085. }
  39086. // ResetExperience resets all changes to the "experience" field.
  39087. func (m *WorkExperienceMutation) ResetExperience() {
  39088. m.experience = nil
  39089. }
  39090. // SetOrganizationID sets the "organization_id" field.
  39091. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  39092. m.organization_id = &u
  39093. m.addorganization_id = nil
  39094. }
  39095. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39096. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  39097. v := m.organization_id
  39098. if v == nil {
  39099. return
  39100. }
  39101. return *v, true
  39102. }
  39103. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  39104. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39106. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39107. if !m.op.Is(OpUpdateOne) {
  39108. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39109. }
  39110. if m.id == nil || m.oldValue == nil {
  39111. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39112. }
  39113. oldValue, err := m.oldValue(ctx)
  39114. if err != nil {
  39115. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39116. }
  39117. return oldValue.OrganizationID, nil
  39118. }
  39119. // AddOrganizationID adds u to the "organization_id" field.
  39120. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  39121. if m.addorganization_id != nil {
  39122. *m.addorganization_id += u
  39123. } else {
  39124. m.addorganization_id = &u
  39125. }
  39126. }
  39127. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39128. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  39129. v := m.addorganization_id
  39130. if v == nil {
  39131. return
  39132. }
  39133. return *v, true
  39134. }
  39135. // ResetOrganizationID resets all changes to the "organization_id" field.
  39136. func (m *WorkExperienceMutation) ResetOrganizationID() {
  39137. m.organization_id = nil
  39138. m.addorganization_id = nil
  39139. }
  39140. // ClearEmployee clears the "employee" edge to the Employee entity.
  39141. func (m *WorkExperienceMutation) ClearEmployee() {
  39142. m.clearedemployee = true
  39143. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  39144. }
  39145. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  39146. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  39147. return m.clearedemployee
  39148. }
  39149. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  39150. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39151. // EmployeeID instead. It exists only for internal usage by the builders.
  39152. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  39153. if id := m.employee; id != nil {
  39154. ids = append(ids, *id)
  39155. }
  39156. return
  39157. }
  39158. // ResetEmployee resets all changes to the "employee" edge.
  39159. func (m *WorkExperienceMutation) ResetEmployee() {
  39160. m.employee = nil
  39161. m.clearedemployee = false
  39162. }
  39163. // Where appends a list predicates to the WorkExperienceMutation builder.
  39164. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  39165. m.predicates = append(m.predicates, ps...)
  39166. }
  39167. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  39168. // users can use type-assertion to append predicates that do not depend on any generated package.
  39169. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  39170. p := make([]predicate.WorkExperience, len(ps))
  39171. for i := range ps {
  39172. p[i] = ps[i]
  39173. }
  39174. m.Where(p...)
  39175. }
  39176. // Op returns the operation name.
  39177. func (m *WorkExperienceMutation) Op() Op {
  39178. return m.op
  39179. }
  39180. // SetOp allows setting the mutation operation.
  39181. func (m *WorkExperienceMutation) SetOp(op Op) {
  39182. m.op = op
  39183. }
  39184. // Type returns the node type of this mutation (WorkExperience).
  39185. func (m *WorkExperienceMutation) Type() string {
  39186. return m.typ
  39187. }
  39188. // Fields returns all fields that were changed during this mutation. Note that in
  39189. // order to get all numeric fields that were incremented/decremented, call
  39190. // AddedFields().
  39191. func (m *WorkExperienceMutation) Fields() []string {
  39192. fields := make([]string, 0, 9)
  39193. if m.created_at != nil {
  39194. fields = append(fields, workexperience.FieldCreatedAt)
  39195. }
  39196. if m.updated_at != nil {
  39197. fields = append(fields, workexperience.FieldUpdatedAt)
  39198. }
  39199. if m.deleted_at != nil {
  39200. fields = append(fields, workexperience.FieldDeletedAt)
  39201. }
  39202. if m.employee != nil {
  39203. fields = append(fields, workexperience.FieldEmployeeID)
  39204. }
  39205. if m.start_date != nil {
  39206. fields = append(fields, workexperience.FieldStartDate)
  39207. }
  39208. if m.end_date != nil {
  39209. fields = append(fields, workexperience.FieldEndDate)
  39210. }
  39211. if m.company != nil {
  39212. fields = append(fields, workexperience.FieldCompany)
  39213. }
  39214. if m.experience != nil {
  39215. fields = append(fields, workexperience.FieldExperience)
  39216. }
  39217. if m.organization_id != nil {
  39218. fields = append(fields, workexperience.FieldOrganizationID)
  39219. }
  39220. return fields
  39221. }
  39222. // Field returns the value of a field with the given name. The second boolean
  39223. // return value indicates that this field was not set, or was not defined in the
  39224. // schema.
  39225. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  39226. switch name {
  39227. case workexperience.FieldCreatedAt:
  39228. return m.CreatedAt()
  39229. case workexperience.FieldUpdatedAt:
  39230. return m.UpdatedAt()
  39231. case workexperience.FieldDeletedAt:
  39232. return m.DeletedAt()
  39233. case workexperience.FieldEmployeeID:
  39234. return m.EmployeeID()
  39235. case workexperience.FieldStartDate:
  39236. return m.StartDate()
  39237. case workexperience.FieldEndDate:
  39238. return m.EndDate()
  39239. case workexperience.FieldCompany:
  39240. return m.Company()
  39241. case workexperience.FieldExperience:
  39242. return m.Experience()
  39243. case workexperience.FieldOrganizationID:
  39244. return m.OrganizationID()
  39245. }
  39246. return nil, false
  39247. }
  39248. // OldField returns the old value of the field from the database. An error is
  39249. // returned if the mutation operation is not UpdateOne, or the query to the
  39250. // database failed.
  39251. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39252. switch name {
  39253. case workexperience.FieldCreatedAt:
  39254. return m.OldCreatedAt(ctx)
  39255. case workexperience.FieldUpdatedAt:
  39256. return m.OldUpdatedAt(ctx)
  39257. case workexperience.FieldDeletedAt:
  39258. return m.OldDeletedAt(ctx)
  39259. case workexperience.FieldEmployeeID:
  39260. return m.OldEmployeeID(ctx)
  39261. case workexperience.FieldStartDate:
  39262. return m.OldStartDate(ctx)
  39263. case workexperience.FieldEndDate:
  39264. return m.OldEndDate(ctx)
  39265. case workexperience.FieldCompany:
  39266. return m.OldCompany(ctx)
  39267. case workexperience.FieldExperience:
  39268. return m.OldExperience(ctx)
  39269. case workexperience.FieldOrganizationID:
  39270. return m.OldOrganizationID(ctx)
  39271. }
  39272. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  39273. }
  39274. // SetField sets the value of a field with the given name. It returns an error if
  39275. // the field is not defined in the schema, or if the type mismatched the field
  39276. // type.
  39277. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  39278. switch name {
  39279. case workexperience.FieldCreatedAt:
  39280. v, ok := value.(time.Time)
  39281. if !ok {
  39282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39283. }
  39284. m.SetCreatedAt(v)
  39285. return nil
  39286. case workexperience.FieldUpdatedAt:
  39287. v, ok := value.(time.Time)
  39288. if !ok {
  39289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39290. }
  39291. m.SetUpdatedAt(v)
  39292. return nil
  39293. case workexperience.FieldDeletedAt:
  39294. v, ok := value.(time.Time)
  39295. if !ok {
  39296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39297. }
  39298. m.SetDeletedAt(v)
  39299. return nil
  39300. case workexperience.FieldEmployeeID:
  39301. v, ok := value.(uint64)
  39302. if !ok {
  39303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39304. }
  39305. m.SetEmployeeID(v)
  39306. return nil
  39307. case workexperience.FieldStartDate:
  39308. v, ok := value.(time.Time)
  39309. if !ok {
  39310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39311. }
  39312. m.SetStartDate(v)
  39313. return nil
  39314. case workexperience.FieldEndDate:
  39315. v, ok := value.(time.Time)
  39316. if !ok {
  39317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39318. }
  39319. m.SetEndDate(v)
  39320. return nil
  39321. case workexperience.FieldCompany:
  39322. v, ok := value.(string)
  39323. if !ok {
  39324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39325. }
  39326. m.SetCompany(v)
  39327. return nil
  39328. case workexperience.FieldExperience:
  39329. v, ok := value.(string)
  39330. if !ok {
  39331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39332. }
  39333. m.SetExperience(v)
  39334. return nil
  39335. case workexperience.FieldOrganizationID:
  39336. v, ok := value.(uint64)
  39337. if !ok {
  39338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39339. }
  39340. m.SetOrganizationID(v)
  39341. return nil
  39342. }
  39343. return fmt.Errorf("unknown WorkExperience field %s", name)
  39344. }
  39345. // AddedFields returns all numeric fields that were incremented/decremented during
  39346. // this mutation.
  39347. func (m *WorkExperienceMutation) AddedFields() []string {
  39348. var fields []string
  39349. if m.addorganization_id != nil {
  39350. fields = append(fields, workexperience.FieldOrganizationID)
  39351. }
  39352. return fields
  39353. }
  39354. // AddedField returns the numeric value that was incremented/decremented on a field
  39355. // with the given name. The second boolean return value indicates that this field
  39356. // was not set, or was not defined in the schema.
  39357. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  39358. switch name {
  39359. case workexperience.FieldOrganizationID:
  39360. return m.AddedOrganizationID()
  39361. }
  39362. return nil, false
  39363. }
  39364. // AddField adds the value to the field with the given name. It returns an error if
  39365. // the field is not defined in the schema, or if the type mismatched the field
  39366. // type.
  39367. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  39368. switch name {
  39369. case workexperience.FieldOrganizationID:
  39370. v, ok := value.(int64)
  39371. if !ok {
  39372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39373. }
  39374. m.AddOrganizationID(v)
  39375. return nil
  39376. }
  39377. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  39378. }
  39379. // ClearedFields returns all nullable fields that were cleared during this
  39380. // mutation.
  39381. func (m *WorkExperienceMutation) ClearedFields() []string {
  39382. var fields []string
  39383. if m.FieldCleared(workexperience.FieldDeletedAt) {
  39384. fields = append(fields, workexperience.FieldDeletedAt)
  39385. }
  39386. return fields
  39387. }
  39388. // FieldCleared returns a boolean indicating if a field with the given name was
  39389. // cleared in this mutation.
  39390. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  39391. _, ok := m.clearedFields[name]
  39392. return ok
  39393. }
  39394. // ClearField clears the value of the field with the given name. It returns an
  39395. // error if the field is not defined in the schema.
  39396. func (m *WorkExperienceMutation) ClearField(name string) error {
  39397. switch name {
  39398. case workexperience.FieldDeletedAt:
  39399. m.ClearDeletedAt()
  39400. return nil
  39401. }
  39402. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  39403. }
  39404. // ResetField resets all changes in the mutation for the field with the given name.
  39405. // It returns an error if the field is not defined in the schema.
  39406. func (m *WorkExperienceMutation) ResetField(name string) error {
  39407. switch name {
  39408. case workexperience.FieldCreatedAt:
  39409. m.ResetCreatedAt()
  39410. return nil
  39411. case workexperience.FieldUpdatedAt:
  39412. m.ResetUpdatedAt()
  39413. return nil
  39414. case workexperience.FieldDeletedAt:
  39415. m.ResetDeletedAt()
  39416. return nil
  39417. case workexperience.FieldEmployeeID:
  39418. m.ResetEmployeeID()
  39419. return nil
  39420. case workexperience.FieldStartDate:
  39421. m.ResetStartDate()
  39422. return nil
  39423. case workexperience.FieldEndDate:
  39424. m.ResetEndDate()
  39425. return nil
  39426. case workexperience.FieldCompany:
  39427. m.ResetCompany()
  39428. return nil
  39429. case workexperience.FieldExperience:
  39430. m.ResetExperience()
  39431. return nil
  39432. case workexperience.FieldOrganizationID:
  39433. m.ResetOrganizationID()
  39434. return nil
  39435. }
  39436. return fmt.Errorf("unknown WorkExperience field %s", name)
  39437. }
  39438. // AddedEdges returns all edge names that were set/added in this mutation.
  39439. func (m *WorkExperienceMutation) AddedEdges() []string {
  39440. edges := make([]string, 0, 1)
  39441. if m.employee != nil {
  39442. edges = append(edges, workexperience.EdgeEmployee)
  39443. }
  39444. return edges
  39445. }
  39446. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39447. // name in this mutation.
  39448. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  39449. switch name {
  39450. case workexperience.EdgeEmployee:
  39451. if id := m.employee; id != nil {
  39452. return []ent.Value{*id}
  39453. }
  39454. }
  39455. return nil
  39456. }
  39457. // RemovedEdges returns all edge names that were removed in this mutation.
  39458. func (m *WorkExperienceMutation) RemovedEdges() []string {
  39459. edges := make([]string, 0, 1)
  39460. return edges
  39461. }
  39462. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39463. // the given name in this mutation.
  39464. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  39465. return nil
  39466. }
  39467. // ClearedEdges returns all edge names that were cleared in this mutation.
  39468. func (m *WorkExperienceMutation) ClearedEdges() []string {
  39469. edges := make([]string, 0, 1)
  39470. if m.clearedemployee {
  39471. edges = append(edges, workexperience.EdgeEmployee)
  39472. }
  39473. return edges
  39474. }
  39475. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39476. // was cleared in this mutation.
  39477. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  39478. switch name {
  39479. case workexperience.EdgeEmployee:
  39480. return m.clearedemployee
  39481. }
  39482. return false
  39483. }
  39484. // ClearEdge clears the value of the edge with the given name. It returns an error
  39485. // if that edge is not defined in the schema.
  39486. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  39487. switch name {
  39488. case workexperience.EdgeEmployee:
  39489. m.ClearEmployee()
  39490. return nil
  39491. }
  39492. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  39493. }
  39494. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39495. // It returns an error if the edge is not defined in the schema.
  39496. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  39497. switch name {
  39498. case workexperience.EdgeEmployee:
  39499. m.ResetEmployee()
  39500. return nil
  39501. }
  39502. return fmt.Errorf("unknown WorkExperience edge %s", name)
  39503. }
  39504. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  39505. type WpChatroomMutation struct {
  39506. config
  39507. op Op
  39508. typ string
  39509. id *uint64
  39510. created_at *time.Time
  39511. updated_at *time.Time
  39512. status *uint8
  39513. addstatus *int8
  39514. wx_wxid *string
  39515. chatroom_id *string
  39516. nickname *string
  39517. owner *string
  39518. avatar *string
  39519. member_list *[]string
  39520. appendmember_list []string
  39521. clearedFields map[string]struct{}
  39522. done bool
  39523. oldValue func(context.Context) (*WpChatroom, error)
  39524. predicates []predicate.WpChatroom
  39525. }
  39526. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  39527. // wpchatroomOption allows management of the mutation configuration using functional options.
  39528. type wpchatroomOption func(*WpChatroomMutation)
  39529. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  39530. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  39531. m := &WpChatroomMutation{
  39532. config: c,
  39533. op: op,
  39534. typ: TypeWpChatroom,
  39535. clearedFields: make(map[string]struct{}),
  39536. }
  39537. for _, opt := range opts {
  39538. opt(m)
  39539. }
  39540. return m
  39541. }
  39542. // withWpChatroomID sets the ID field of the mutation.
  39543. func withWpChatroomID(id uint64) wpchatroomOption {
  39544. return func(m *WpChatroomMutation) {
  39545. var (
  39546. err error
  39547. once sync.Once
  39548. value *WpChatroom
  39549. )
  39550. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  39551. once.Do(func() {
  39552. if m.done {
  39553. err = errors.New("querying old values post mutation is not allowed")
  39554. } else {
  39555. value, err = m.Client().WpChatroom.Get(ctx, id)
  39556. }
  39557. })
  39558. return value, err
  39559. }
  39560. m.id = &id
  39561. }
  39562. }
  39563. // withWpChatroom sets the old WpChatroom of the mutation.
  39564. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  39565. return func(m *WpChatroomMutation) {
  39566. m.oldValue = func(context.Context) (*WpChatroom, error) {
  39567. return node, nil
  39568. }
  39569. m.id = &node.ID
  39570. }
  39571. }
  39572. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39573. // executed in a transaction (ent.Tx), a transactional client is returned.
  39574. func (m WpChatroomMutation) Client() *Client {
  39575. client := &Client{config: m.config}
  39576. client.init()
  39577. return client
  39578. }
  39579. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39580. // it returns an error otherwise.
  39581. func (m WpChatroomMutation) Tx() (*Tx, error) {
  39582. if _, ok := m.driver.(*txDriver); !ok {
  39583. return nil, errors.New("ent: mutation is not running in a transaction")
  39584. }
  39585. tx := &Tx{config: m.config}
  39586. tx.init()
  39587. return tx, nil
  39588. }
  39589. // SetID sets the value of the id field. Note that this
  39590. // operation is only accepted on creation of WpChatroom entities.
  39591. func (m *WpChatroomMutation) SetID(id uint64) {
  39592. m.id = &id
  39593. }
  39594. // ID returns the ID value in the mutation. Note that the ID is only available
  39595. // if it was provided to the builder or after it was returned from the database.
  39596. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  39597. if m.id == nil {
  39598. return
  39599. }
  39600. return *m.id, true
  39601. }
  39602. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39603. // That means, if the mutation is applied within a transaction with an isolation level such
  39604. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39605. // or updated by the mutation.
  39606. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  39607. switch {
  39608. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39609. id, exists := m.ID()
  39610. if exists {
  39611. return []uint64{id}, nil
  39612. }
  39613. fallthrough
  39614. case m.op.Is(OpUpdate | OpDelete):
  39615. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  39616. default:
  39617. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39618. }
  39619. }
  39620. // SetCreatedAt sets the "created_at" field.
  39621. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  39622. m.created_at = &t
  39623. }
  39624. // CreatedAt returns the value of the "created_at" field in the mutation.
  39625. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  39626. v := m.created_at
  39627. if v == nil {
  39628. return
  39629. }
  39630. return *v, true
  39631. }
  39632. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  39633. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39635. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39636. if !m.op.Is(OpUpdateOne) {
  39637. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39638. }
  39639. if m.id == nil || m.oldValue == nil {
  39640. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39641. }
  39642. oldValue, err := m.oldValue(ctx)
  39643. if err != nil {
  39644. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39645. }
  39646. return oldValue.CreatedAt, nil
  39647. }
  39648. // ResetCreatedAt resets all changes to the "created_at" field.
  39649. func (m *WpChatroomMutation) ResetCreatedAt() {
  39650. m.created_at = nil
  39651. }
  39652. // SetUpdatedAt sets the "updated_at" field.
  39653. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  39654. m.updated_at = &t
  39655. }
  39656. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39657. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  39658. v := m.updated_at
  39659. if v == nil {
  39660. return
  39661. }
  39662. return *v, true
  39663. }
  39664. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  39665. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39667. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39668. if !m.op.Is(OpUpdateOne) {
  39669. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39670. }
  39671. if m.id == nil || m.oldValue == nil {
  39672. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39673. }
  39674. oldValue, err := m.oldValue(ctx)
  39675. if err != nil {
  39676. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39677. }
  39678. return oldValue.UpdatedAt, nil
  39679. }
  39680. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39681. func (m *WpChatroomMutation) ResetUpdatedAt() {
  39682. m.updated_at = nil
  39683. }
  39684. // SetStatus sets the "status" field.
  39685. func (m *WpChatroomMutation) SetStatus(u uint8) {
  39686. m.status = &u
  39687. m.addstatus = nil
  39688. }
  39689. // Status returns the value of the "status" field in the mutation.
  39690. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  39691. v := m.status
  39692. if v == nil {
  39693. return
  39694. }
  39695. return *v, true
  39696. }
  39697. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  39698. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39700. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39701. if !m.op.Is(OpUpdateOne) {
  39702. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39703. }
  39704. if m.id == nil || m.oldValue == nil {
  39705. return v, errors.New("OldStatus requires an ID field in the mutation")
  39706. }
  39707. oldValue, err := m.oldValue(ctx)
  39708. if err != nil {
  39709. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39710. }
  39711. return oldValue.Status, nil
  39712. }
  39713. // AddStatus adds u to the "status" field.
  39714. func (m *WpChatroomMutation) AddStatus(u int8) {
  39715. if m.addstatus != nil {
  39716. *m.addstatus += u
  39717. } else {
  39718. m.addstatus = &u
  39719. }
  39720. }
  39721. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39722. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  39723. v := m.addstatus
  39724. if v == nil {
  39725. return
  39726. }
  39727. return *v, true
  39728. }
  39729. // ClearStatus clears the value of the "status" field.
  39730. func (m *WpChatroomMutation) ClearStatus() {
  39731. m.status = nil
  39732. m.addstatus = nil
  39733. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  39734. }
  39735. // StatusCleared returns if the "status" field was cleared in this mutation.
  39736. func (m *WpChatroomMutation) StatusCleared() bool {
  39737. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  39738. return ok
  39739. }
  39740. // ResetStatus resets all changes to the "status" field.
  39741. func (m *WpChatroomMutation) ResetStatus() {
  39742. m.status = nil
  39743. m.addstatus = nil
  39744. delete(m.clearedFields, wpchatroom.FieldStatus)
  39745. }
  39746. // SetWxWxid sets the "wx_wxid" field.
  39747. func (m *WpChatroomMutation) SetWxWxid(s string) {
  39748. m.wx_wxid = &s
  39749. }
  39750. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  39751. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  39752. v := m.wx_wxid
  39753. if v == nil {
  39754. return
  39755. }
  39756. return *v, true
  39757. }
  39758. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  39759. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39761. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  39762. if !m.op.Is(OpUpdateOne) {
  39763. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  39764. }
  39765. if m.id == nil || m.oldValue == nil {
  39766. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  39767. }
  39768. oldValue, err := m.oldValue(ctx)
  39769. if err != nil {
  39770. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  39771. }
  39772. return oldValue.WxWxid, nil
  39773. }
  39774. // ResetWxWxid resets all changes to the "wx_wxid" field.
  39775. func (m *WpChatroomMutation) ResetWxWxid() {
  39776. m.wx_wxid = nil
  39777. }
  39778. // SetChatroomID sets the "chatroom_id" field.
  39779. func (m *WpChatroomMutation) SetChatroomID(s string) {
  39780. m.chatroom_id = &s
  39781. }
  39782. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  39783. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  39784. v := m.chatroom_id
  39785. if v == nil {
  39786. return
  39787. }
  39788. return *v, true
  39789. }
  39790. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  39791. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39793. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  39794. if !m.op.Is(OpUpdateOne) {
  39795. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  39796. }
  39797. if m.id == nil || m.oldValue == nil {
  39798. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  39799. }
  39800. oldValue, err := m.oldValue(ctx)
  39801. if err != nil {
  39802. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  39803. }
  39804. return oldValue.ChatroomID, nil
  39805. }
  39806. // ResetChatroomID resets all changes to the "chatroom_id" field.
  39807. func (m *WpChatroomMutation) ResetChatroomID() {
  39808. m.chatroom_id = nil
  39809. }
  39810. // SetNickname sets the "nickname" field.
  39811. func (m *WpChatroomMutation) SetNickname(s string) {
  39812. m.nickname = &s
  39813. }
  39814. // Nickname returns the value of the "nickname" field in the mutation.
  39815. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  39816. v := m.nickname
  39817. if v == nil {
  39818. return
  39819. }
  39820. return *v, true
  39821. }
  39822. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  39823. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39825. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  39826. if !m.op.Is(OpUpdateOne) {
  39827. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39828. }
  39829. if m.id == nil || m.oldValue == nil {
  39830. return v, errors.New("OldNickname requires an ID field in the mutation")
  39831. }
  39832. oldValue, err := m.oldValue(ctx)
  39833. if err != nil {
  39834. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39835. }
  39836. return oldValue.Nickname, nil
  39837. }
  39838. // ResetNickname resets all changes to the "nickname" field.
  39839. func (m *WpChatroomMutation) ResetNickname() {
  39840. m.nickname = nil
  39841. }
  39842. // SetOwner sets the "owner" field.
  39843. func (m *WpChatroomMutation) SetOwner(s string) {
  39844. m.owner = &s
  39845. }
  39846. // Owner returns the value of the "owner" field in the mutation.
  39847. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  39848. v := m.owner
  39849. if v == nil {
  39850. return
  39851. }
  39852. return *v, true
  39853. }
  39854. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  39855. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39857. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  39858. if !m.op.Is(OpUpdateOne) {
  39859. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  39860. }
  39861. if m.id == nil || m.oldValue == nil {
  39862. return v, errors.New("OldOwner requires an ID field in the mutation")
  39863. }
  39864. oldValue, err := m.oldValue(ctx)
  39865. if err != nil {
  39866. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  39867. }
  39868. return oldValue.Owner, nil
  39869. }
  39870. // ResetOwner resets all changes to the "owner" field.
  39871. func (m *WpChatroomMutation) ResetOwner() {
  39872. m.owner = nil
  39873. }
  39874. // SetAvatar sets the "avatar" field.
  39875. func (m *WpChatroomMutation) SetAvatar(s string) {
  39876. m.avatar = &s
  39877. }
  39878. // Avatar returns the value of the "avatar" field in the mutation.
  39879. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  39880. v := m.avatar
  39881. if v == nil {
  39882. return
  39883. }
  39884. return *v, true
  39885. }
  39886. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  39887. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39889. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39890. if !m.op.Is(OpUpdateOne) {
  39891. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39892. }
  39893. if m.id == nil || m.oldValue == nil {
  39894. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39895. }
  39896. oldValue, err := m.oldValue(ctx)
  39897. if err != nil {
  39898. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39899. }
  39900. return oldValue.Avatar, nil
  39901. }
  39902. // ResetAvatar resets all changes to the "avatar" field.
  39903. func (m *WpChatroomMutation) ResetAvatar() {
  39904. m.avatar = nil
  39905. }
  39906. // SetMemberList sets the "member_list" field.
  39907. func (m *WpChatroomMutation) SetMemberList(s []string) {
  39908. m.member_list = &s
  39909. m.appendmember_list = nil
  39910. }
  39911. // MemberList returns the value of the "member_list" field in the mutation.
  39912. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  39913. v := m.member_list
  39914. if v == nil {
  39915. return
  39916. }
  39917. return *v, true
  39918. }
  39919. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  39920. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39922. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  39923. if !m.op.Is(OpUpdateOne) {
  39924. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  39925. }
  39926. if m.id == nil || m.oldValue == nil {
  39927. return v, errors.New("OldMemberList requires an ID field in the mutation")
  39928. }
  39929. oldValue, err := m.oldValue(ctx)
  39930. if err != nil {
  39931. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  39932. }
  39933. return oldValue.MemberList, nil
  39934. }
  39935. // AppendMemberList adds s to the "member_list" field.
  39936. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  39937. m.appendmember_list = append(m.appendmember_list, s...)
  39938. }
  39939. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  39940. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  39941. if len(m.appendmember_list) == 0 {
  39942. return nil, false
  39943. }
  39944. return m.appendmember_list, true
  39945. }
  39946. // ResetMemberList resets all changes to the "member_list" field.
  39947. func (m *WpChatroomMutation) ResetMemberList() {
  39948. m.member_list = nil
  39949. m.appendmember_list = nil
  39950. }
  39951. // Where appends a list predicates to the WpChatroomMutation builder.
  39952. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  39953. m.predicates = append(m.predicates, ps...)
  39954. }
  39955. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  39956. // users can use type-assertion to append predicates that do not depend on any generated package.
  39957. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  39958. p := make([]predicate.WpChatroom, len(ps))
  39959. for i := range ps {
  39960. p[i] = ps[i]
  39961. }
  39962. m.Where(p...)
  39963. }
  39964. // Op returns the operation name.
  39965. func (m *WpChatroomMutation) Op() Op {
  39966. return m.op
  39967. }
  39968. // SetOp allows setting the mutation operation.
  39969. func (m *WpChatroomMutation) SetOp(op Op) {
  39970. m.op = op
  39971. }
  39972. // Type returns the node type of this mutation (WpChatroom).
  39973. func (m *WpChatroomMutation) Type() string {
  39974. return m.typ
  39975. }
  39976. // Fields returns all fields that were changed during this mutation. Note that in
  39977. // order to get all numeric fields that were incremented/decremented, call
  39978. // AddedFields().
  39979. func (m *WpChatroomMutation) Fields() []string {
  39980. fields := make([]string, 0, 9)
  39981. if m.created_at != nil {
  39982. fields = append(fields, wpchatroom.FieldCreatedAt)
  39983. }
  39984. if m.updated_at != nil {
  39985. fields = append(fields, wpchatroom.FieldUpdatedAt)
  39986. }
  39987. if m.status != nil {
  39988. fields = append(fields, wpchatroom.FieldStatus)
  39989. }
  39990. if m.wx_wxid != nil {
  39991. fields = append(fields, wpchatroom.FieldWxWxid)
  39992. }
  39993. if m.chatroom_id != nil {
  39994. fields = append(fields, wpchatroom.FieldChatroomID)
  39995. }
  39996. if m.nickname != nil {
  39997. fields = append(fields, wpchatroom.FieldNickname)
  39998. }
  39999. if m.owner != nil {
  40000. fields = append(fields, wpchatroom.FieldOwner)
  40001. }
  40002. if m.avatar != nil {
  40003. fields = append(fields, wpchatroom.FieldAvatar)
  40004. }
  40005. if m.member_list != nil {
  40006. fields = append(fields, wpchatroom.FieldMemberList)
  40007. }
  40008. return fields
  40009. }
  40010. // Field returns the value of a field with the given name. The second boolean
  40011. // return value indicates that this field was not set, or was not defined in the
  40012. // schema.
  40013. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  40014. switch name {
  40015. case wpchatroom.FieldCreatedAt:
  40016. return m.CreatedAt()
  40017. case wpchatroom.FieldUpdatedAt:
  40018. return m.UpdatedAt()
  40019. case wpchatroom.FieldStatus:
  40020. return m.Status()
  40021. case wpchatroom.FieldWxWxid:
  40022. return m.WxWxid()
  40023. case wpchatroom.FieldChatroomID:
  40024. return m.ChatroomID()
  40025. case wpchatroom.FieldNickname:
  40026. return m.Nickname()
  40027. case wpchatroom.FieldOwner:
  40028. return m.Owner()
  40029. case wpchatroom.FieldAvatar:
  40030. return m.Avatar()
  40031. case wpchatroom.FieldMemberList:
  40032. return m.MemberList()
  40033. }
  40034. return nil, false
  40035. }
  40036. // OldField returns the old value of the field from the database. An error is
  40037. // returned if the mutation operation is not UpdateOne, or the query to the
  40038. // database failed.
  40039. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40040. switch name {
  40041. case wpchatroom.FieldCreatedAt:
  40042. return m.OldCreatedAt(ctx)
  40043. case wpchatroom.FieldUpdatedAt:
  40044. return m.OldUpdatedAt(ctx)
  40045. case wpchatroom.FieldStatus:
  40046. return m.OldStatus(ctx)
  40047. case wpchatroom.FieldWxWxid:
  40048. return m.OldWxWxid(ctx)
  40049. case wpchatroom.FieldChatroomID:
  40050. return m.OldChatroomID(ctx)
  40051. case wpchatroom.FieldNickname:
  40052. return m.OldNickname(ctx)
  40053. case wpchatroom.FieldOwner:
  40054. return m.OldOwner(ctx)
  40055. case wpchatroom.FieldAvatar:
  40056. return m.OldAvatar(ctx)
  40057. case wpchatroom.FieldMemberList:
  40058. return m.OldMemberList(ctx)
  40059. }
  40060. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  40061. }
  40062. // SetField sets the value of a field with the given name. It returns an error if
  40063. // the field is not defined in the schema, or if the type mismatched the field
  40064. // type.
  40065. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  40066. switch name {
  40067. case wpchatroom.FieldCreatedAt:
  40068. v, ok := value.(time.Time)
  40069. if !ok {
  40070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40071. }
  40072. m.SetCreatedAt(v)
  40073. return nil
  40074. case wpchatroom.FieldUpdatedAt:
  40075. v, ok := value.(time.Time)
  40076. if !ok {
  40077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40078. }
  40079. m.SetUpdatedAt(v)
  40080. return nil
  40081. case wpchatroom.FieldStatus:
  40082. v, ok := value.(uint8)
  40083. if !ok {
  40084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40085. }
  40086. m.SetStatus(v)
  40087. return nil
  40088. case wpchatroom.FieldWxWxid:
  40089. v, ok := value.(string)
  40090. if !ok {
  40091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40092. }
  40093. m.SetWxWxid(v)
  40094. return nil
  40095. case wpchatroom.FieldChatroomID:
  40096. v, ok := value.(string)
  40097. if !ok {
  40098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40099. }
  40100. m.SetChatroomID(v)
  40101. return nil
  40102. case wpchatroom.FieldNickname:
  40103. v, ok := value.(string)
  40104. if !ok {
  40105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40106. }
  40107. m.SetNickname(v)
  40108. return nil
  40109. case wpchatroom.FieldOwner:
  40110. v, ok := value.(string)
  40111. if !ok {
  40112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40113. }
  40114. m.SetOwner(v)
  40115. return nil
  40116. case wpchatroom.FieldAvatar:
  40117. v, ok := value.(string)
  40118. if !ok {
  40119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40120. }
  40121. m.SetAvatar(v)
  40122. return nil
  40123. case wpchatroom.FieldMemberList:
  40124. v, ok := value.([]string)
  40125. if !ok {
  40126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40127. }
  40128. m.SetMemberList(v)
  40129. return nil
  40130. }
  40131. return fmt.Errorf("unknown WpChatroom field %s", name)
  40132. }
  40133. // AddedFields returns all numeric fields that were incremented/decremented during
  40134. // this mutation.
  40135. func (m *WpChatroomMutation) AddedFields() []string {
  40136. var fields []string
  40137. if m.addstatus != nil {
  40138. fields = append(fields, wpchatroom.FieldStatus)
  40139. }
  40140. return fields
  40141. }
  40142. // AddedField returns the numeric value that was incremented/decremented on a field
  40143. // with the given name. The second boolean return value indicates that this field
  40144. // was not set, or was not defined in the schema.
  40145. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  40146. switch name {
  40147. case wpchatroom.FieldStatus:
  40148. return m.AddedStatus()
  40149. }
  40150. return nil, false
  40151. }
  40152. // AddField adds the value to the field with the given name. It returns an error if
  40153. // the field is not defined in the schema, or if the type mismatched the field
  40154. // type.
  40155. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  40156. switch name {
  40157. case wpchatroom.FieldStatus:
  40158. v, ok := value.(int8)
  40159. if !ok {
  40160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40161. }
  40162. m.AddStatus(v)
  40163. return nil
  40164. }
  40165. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  40166. }
  40167. // ClearedFields returns all nullable fields that were cleared during this
  40168. // mutation.
  40169. func (m *WpChatroomMutation) ClearedFields() []string {
  40170. var fields []string
  40171. if m.FieldCleared(wpchatroom.FieldStatus) {
  40172. fields = append(fields, wpchatroom.FieldStatus)
  40173. }
  40174. return fields
  40175. }
  40176. // FieldCleared returns a boolean indicating if a field with the given name was
  40177. // cleared in this mutation.
  40178. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  40179. _, ok := m.clearedFields[name]
  40180. return ok
  40181. }
  40182. // ClearField clears the value of the field with the given name. It returns an
  40183. // error if the field is not defined in the schema.
  40184. func (m *WpChatroomMutation) ClearField(name string) error {
  40185. switch name {
  40186. case wpchatroom.FieldStatus:
  40187. m.ClearStatus()
  40188. return nil
  40189. }
  40190. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  40191. }
  40192. // ResetField resets all changes in the mutation for the field with the given name.
  40193. // It returns an error if the field is not defined in the schema.
  40194. func (m *WpChatroomMutation) ResetField(name string) error {
  40195. switch name {
  40196. case wpchatroom.FieldCreatedAt:
  40197. m.ResetCreatedAt()
  40198. return nil
  40199. case wpchatroom.FieldUpdatedAt:
  40200. m.ResetUpdatedAt()
  40201. return nil
  40202. case wpchatroom.FieldStatus:
  40203. m.ResetStatus()
  40204. return nil
  40205. case wpchatroom.FieldWxWxid:
  40206. m.ResetWxWxid()
  40207. return nil
  40208. case wpchatroom.FieldChatroomID:
  40209. m.ResetChatroomID()
  40210. return nil
  40211. case wpchatroom.FieldNickname:
  40212. m.ResetNickname()
  40213. return nil
  40214. case wpchatroom.FieldOwner:
  40215. m.ResetOwner()
  40216. return nil
  40217. case wpchatroom.FieldAvatar:
  40218. m.ResetAvatar()
  40219. return nil
  40220. case wpchatroom.FieldMemberList:
  40221. m.ResetMemberList()
  40222. return nil
  40223. }
  40224. return fmt.Errorf("unknown WpChatroom field %s", name)
  40225. }
  40226. // AddedEdges returns all edge names that were set/added in this mutation.
  40227. func (m *WpChatroomMutation) AddedEdges() []string {
  40228. edges := make([]string, 0, 0)
  40229. return edges
  40230. }
  40231. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40232. // name in this mutation.
  40233. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  40234. return nil
  40235. }
  40236. // RemovedEdges returns all edge names that were removed in this mutation.
  40237. func (m *WpChatroomMutation) RemovedEdges() []string {
  40238. edges := make([]string, 0, 0)
  40239. return edges
  40240. }
  40241. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40242. // the given name in this mutation.
  40243. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  40244. return nil
  40245. }
  40246. // ClearedEdges returns all edge names that were cleared in this mutation.
  40247. func (m *WpChatroomMutation) ClearedEdges() []string {
  40248. edges := make([]string, 0, 0)
  40249. return edges
  40250. }
  40251. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40252. // was cleared in this mutation.
  40253. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  40254. return false
  40255. }
  40256. // ClearEdge clears the value of the edge with the given name. It returns an error
  40257. // if that edge is not defined in the schema.
  40258. func (m *WpChatroomMutation) ClearEdge(name string) error {
  40259. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  40260. }
  40261. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40262. // It returns an error if the edge is not defined in the schema.
  40263. func (m *WpChatroomMutation) ResetEdge(name string) error {
  40264. return fmt.Errorf("unknown WpChatroom edge %s", name)
  40265. }
  40266. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  40267. type WpChatroomMemberMutation struct {
  40268. config
  40269. op Op
  40270. typ string
  40271. id *uint64
  40272. created_at *time.Time
  40273. updated_at *time.Time
  40274. status *uint8
  40275. addstatus *int8
  40276. wx_wxid *string
  40277. wxid *string
  40278. nickname *string
  40279. avatar *string
  40280. clearedFields map[string]struct{}
  40281. done bool
  40282. oldValue func(context.Context) (*WpChatroomMember, error)
  40283. predicates []predicate.WpChatroomMember
  40284. }
  40285. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  40286. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  40287. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  40288. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  40289. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  40290. m := &WpChatroomMemberMutation{
  40291. config: c,
  40292. op: op,
  40293. typ: TypeWpChatroomMember,
  40294. clearedFields: make(map[string]struct{}),
  40295. }
  40296. for _, opt := range opts {
  40297. opt(m)
  40298. }
  40299. return m
  40300. }
  40301. // withWpChatroomMemberID sets the ID field of the mutation.
  40302. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  40303. return func(m *WpChatroomMemberMutation) {
  40304. var (
  40305. err error
  40306. once sync.Once
  40307. value *WpChatroomMember
  40308. )
  40309. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  40310. once.Do(func() {
  40311. if m.done {
  40312. err = errors.New("querying old values post mutation is not allowed")
  40313. } else {
  40314. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  40315. }
  40316. })
  40317. return value, err
  40318. }
  40319. m.id = &id
  40320. }
  40321. }
  40322. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  40323. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  40324. return func(m *WpChatroomMemberMutation) {
  40325. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  40326. return node, nil
  40327. }
  40328. m.id = &node.ID
  40329. }
  40330. }
  40331. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40332. // executed in a transaction (ent.Tx), a transactional client is returned.
  40333. func (m WpChatroomMemberMutation) Client() *Client {
  40334. client := &Client{config: m.config}
  40335. client.init()
  40336. return client
  40337. }
  40338. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40339. // it returns an error otherwise.
  40340. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  40341. if _, ok := m.driver.(*txDriver); !ok {
  40342. return nil, errors.New("ent: mutation is not running in a transaction")
  40343. }
  40344. tx := &Tx{config: m.config}
  40345. tx.init()
  40346. return tx, nil
  40347. }
  40348. // SetID sets the value of the id field. Note that this
  40349. // operation is only accepted on creation of WpChatroomMember entities.
  40350. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  40351. m.id = &id
  40352. }
  40353. // ID returns the ID value in the mutation. Note that the ID is only available
  40354. // if it was provided to the builder or after it was returned from the database.
  40355. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  40356. if m.id == nil {
  40357. return
  40358. }
  40359. return *m.id, true
  40360. }
  40361. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40362. // That means, if the mutation is applied within a transaction with an isolation level such
  40363. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40364. // or updated by the mutation.
  40365. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  40366. switch {
  40367. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40368. id, exists := m.ID()
  40369. if exists {
  40370. return []uint64{id}, nil
  40371. }
  40372. fallthrough
  40373. case m.op.Is(OpUpdate | OpDelete):
  40374. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  40375. default:
  40376. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40377. }
  40378. }
  40379. // SetCreatedAt sets the "created_at" field.
  40380. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  40381. m.created_at = &t
  40382. }
  40383. // CreatedAt returns the value of the "created_at" field in the mutation.
  40384. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  40385. v := m.created_at
  40386. if v == nil {
  40387. return
  40388. }
  40389. return *v, true
  40390. }
  40391. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  40392. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40394. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40395. if !m.op.Is(OpUpdateOne) {
  40396. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40397. }
  40398. if m.id == nil || m.oldValue == nil {
  40399. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40400. }
  40401. oldValue, err := m.oldValue(ctx)
  40402. if err != nil {
  40403. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40404. }
  40405. return oldValue.CreatedAt, nil
  40406. }
  40407. // ResetCreatedAt resets all changes to the "created_at" field.
  40408. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  40409. m.created_at = nil
  40410. }
  40411. // SetUpdatedAt sets the "updated_at" field.
  40412. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  40413. m.updated_at = &t
  40414. }
  40415. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40416. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  40417. v := m.updated_at
  40418. if v == nil {
  40419. return
  40420. }
  40421. return *v, true
  40422. }
  40423. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  40424. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40426. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40427. if !m.op.Is(OpUpdateOne) {
  40428. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40429. }
  40430. if m.id == nil || m.oldValue == nil {
  40431. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40432. }
  40433. oldValue, err := m.oldValue(ctx)
  40434. if err != nil {
  40435. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40436. }
  40437. return oldValue.UpdatedAt, nil
  40438. }
  40439. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40440. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  40441. m.updated_at = nil
  40442. }
  40443. // SetStatus sets the "status" field.
  40444. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  40445. m.status = &u
  40446. m.addstatus = nil
  40447. }
  40448. // Status returns the value of the "status" field in the mutation.
  40449. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  40450. v := m.status
  40451. if v == nil {
  40452. return
  40453. }
  40454. return *v, true
  40455. }
  40456. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  40457. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40459. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40460. if !m.op.Is(OpUpdateOne) {
  40461. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40462. }
  40463. if m.id == nil || m.oldValue == nil {
  40464. return v, errors.New("OldStatus requires an ID field in the mutation")
  40465. }
  40466. oldValue, err := m.oldValue(ctx)
  40467. if err != nil {
  40468. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40469. }
  40470. return oldValue.Status, nil
  40471. }
  40472. // AddStatus adds u to the "status" field.
  40473. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  40474. if m.addstatus != nil {
  40475. *m.addstatus += u
  40476. } else {
  40477. m.addstatus = &u
  40478. }
  40479. }
  40480. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40481. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  40482. v := m.addstatus
  40483. if v == nil {
  40484. return
  40485. }
  40486. return *v, true
  40487. }
  40488. // ClearStatus clears the value of the "status" field.
  40489. func (m *WpChatroomMemberMutation) ClearStatus() {
  40490. m.status = nil
  40491. m.addstatus = nil
  40492. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  40493. }
  40494. // StatusCleared returns if the "status" field was cleared in this mutation.
  40495. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  40496. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  40497. return ok
  40498. }
  40499. // ResetStatus resets all changes to the "status" field.
  40500. func (m *WpChatroomMemberMutation) ResetStatus() {
  40501. m.status = nil
  40502. m.addstatus = nil
  40503. delete(m.clearedFields, wpchatroommember.FieldStatus)
  40504. }
  40505. // SetWxWxid sets the "wx_wxid" field.
  40506. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  40507. m.wx_wxid = &s
  40508. }
  40509. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  40510. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  40511. v := m.wx_wxid
  40512. if v == nil {
  40513. return
  40514. }
  40515. return *v, true
  40516. }
  40517. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  40518. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40520. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  40521. if !m.op.Is(OpUpdateOne) {
  40522. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  40523. }
  40524. if m.id == nil || m.oldValue == nil {
  40525. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  40526. }
  40527. oldValue, err := m.oldValue(ctx)
  40528. if err != nil {
  40529. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  40530. }
  40531. return oldValue.WxWxid, nil
  40532. }
  40533. // ResetWxWxid resets all changes to the "wx_wxid" field.
  40534. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  40535. m.wx_wxid = nil
  40536. }
  40537. // SetWxid sets the "wxid" field.
  40538. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  40539. m.wxid = &s
  40540. }
  40541. // Wxid returns the value of the "wxid" field in the mutation.
  40542. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  40543. v := m.wxid
  40544. if v == nil {
  40545. return
  40546. }
  40547. return *v, true
  40548. }
  40549. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  40550. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40552. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  40553. if !m.op.Is(OpUpdateOne) {
  40554. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40555. }
  40556. if m.id == nil || m.oldValue == nil {
  40557. return v, errors.New("OldWxid requires an ID field in the mutation")
  40558. }
  40559. oldValue, err := m.oldValue(ctx)
  40560. if err != nil {
  40561. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40562. }
  40563. return oldValue.Wxid, nil
  40564. }
  40565. // ResetWxid resets all changes to the "wxid" field.
  40566. func (m *WpChatroomMemberMutation) ResetWxid() {
  40567. m.wxid = nil
  40568. }
  40569. // SetNickname sets the "nickname" field.
  40570. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  40571. m.nickname = &s
  40572. }
  40573. // Nickname returns the value of the "nickname" field in the mutation.
  40574. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  40575. v := m.nickname
  40576. if v == nil {
  40577. return
  40578. }
  40579. return *v, true
  40580. }
  40581. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  40582. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40584. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  40585. if !m.op.Is(OpUpdateOne) {
  40586. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40587. }
  40588. if m.id == nil || m.oldValue == nil {
  40589. return v, errors.New("OldNickname requires an ID field in the mutation")
  40590. }
  40591. oldValue, err := m.oldValue(ctx)
  40592. if err != nil {
  40593. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40594. }
  40595. return oldValue.Nickname, nil
  40596. }
  40597. // ResetNickname resets all changes to the "nickname" field.
  40598. func (m *WpChatroomMemberMutation) ResetNickname() {
  40599. m.nickname = nil
  40600. }
  40601. // SetAvatar sets the "avatar" field.
  40602. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  40603. m.avatar = &s
  40604. }
  40605. // Avatar returns the value of the "avatar" field in the mutation.
  40606. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  40607. v := m.avatar
  40608. if v == nil {
  40609. return
  40610. }
  40611. return *v, true
  40612. }
  40613. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  40614. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40616. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40617. if !m.op.Is(OpUpdateOne) {
  40618. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40619. }
  40620. if m.id == nil || m.oldValue == nil {
  40621. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40622. }
  40623. oldValue, err := m.oldValue(ctx)
  40624. if err != nil {
  40625. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40626. }
  40627. return oldValue.Avatar, nil
  40628. }
  40629. // ResetAvatar resets all changes to the "avatar" field.
  40630. func (m *WpChatroomMemberMutation) ResetAvatar() {
  40631. m.avatar = nil
  40632. }
  40633. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  40634. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  40635. m.predicates = append(m.predicates, ps...)
  40636. }
  40637. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  40638. // users can use type-assertion to append predicates that do not depend on any generated package.
  40639. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  40640. p := make([]predicate.WpChatroomMember, len(ps))
  40641. for i := range ps {
  40642. p[i] = ps[i]
  40643. }
  40644. m.Where(p...)
  40645. }
  40646. // Op returns the operation name.
  40647. func (m *WpChatroomMemberMutation) Op() Op {
  40648. return m.op
  40649. }
  40650. // SetOp allows setting the mutation operation.
  40651. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  40652. m.op = op
  40653. }
  40654. // Type returns the node type of this mutation (WpChatroomMember).
  40655. func (m *WpChatroomMemberMutation) Type() string {
  40656. return m.typ
  40657. }
  40658. // Fields returns all fields that were changed during this mutation. Note that in
  40659. // order to get all numeric fields that were incremented/decremented, call
  40660. // AddedFields().
  40661. func (m *WpChatroomMemberMutation) Fields() []string {
  40662. fields := make([]string, 0, 7)
  40663. if m.created_at != nil {
  40664. fields = append(fields, wpchatroommember.FieldCreatedAt)
  40665. }
  40666. if m.updated_at != nil {
  40667. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  40668. }
  40669. if m.status != nil {
  40670. fields = append(fields, wpchatroommember.FieldStatus)
  40671. }
  40672. if m.wx_wxid != nil {
  40673. fields = append(fields, wpchatroommember.FieldWxWxid)
  40674. }
  40675. if m.wxid != nil {
  40676. fields = append(fields, wpchatroommember.FieldWxid)
  40677. }
  40678. if m.nickname != nil {
  40679. fields = append(fields, wpchatroommember.FieldNickname)
  40680. }
  40681. if m.avatar != nil {
  40682. fields = append(fields, wpchatroommember.FieldAvatar)
  40683. }
  40684. return fields
  40685. }
  40686. // Field returns the value of a field with the given name. The second boolean
  40687. // return value indicates that this field was not set, or was not defined in the
  40688. // schema.
  40689. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  40690. switch name {
  40691. case wpchatroommember.FieldCreatedAt:
  40692. return m.CreatedAt()
  40693. case wpchatroommember.FieldUpdatedAt:
  40694. return m.UpdatedAt()
  40695. case wpchatroommember.FieldStatus:
  40696. return m.Status()
  40697. case wpchatroommember.FieldWxWxid:
  40698. return m.WxWxid()
  40699. case wpchatroommember.FieldWxid:
  40700. return m.Wxid()
  40701. case wpchatroommember.FieldNickname:
  40702. return m.Nickname()
  40703. case wpchatroommember.FieldAvatar:
  40704. return m.Avatar()
  40705. }
  40706. return nil, false
  40707. }
  40708. // OldField returns the old value of the field from the database. An error is
  40709. // returned if the mutation operation is not UpdateOne, or the query to the
  40710. // database failed.
  40711. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40712. switch name {
  40713. case wpchatroommember.FieldCreatedAt:
  40714. return m.OldCreatedAt(ctx)
  40715. case wpchatroommember.FieldUpdatedAt:
  40716. return m.OldUpdatedAt(ctx)
  40717. case wpchatroommember.FieldStatus:
  40718. return m.OldStatus(ctx)
  40719. case wpchatroommember.FieldWxWxid:
  40720. return m.OldWxWxid(ctx)
  40721. case wpchatroommember.FieldWxid:
  40722. return m.OldWxid(ctx)
  40723. case wpchatroommember.FieldNickname:
  40724. return m.OldNickname(ctx)
  40725. case wpchatroommember.FieldAvatar:
  40726. return m.OldAvatar(ctx)
  40727. }
  40728. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  40729. }
  40730. // SetField sets the value of a field with the given name. It returns an error if
  40731. // the field is not defined in the schema, or if the type mismatched the field
  40732. // type.
  40733. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  40734. switch name {
  40735. case wpchatroommember.FieldCreatedAt:
  40736. v, ok := value.(time.Time)
  40737. if !ok {
  40738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40739. }
  40740. m.SetCreatedAt(v)
  40741. return nil
  40742. case wpchatroommember.FieldUpdatedAt:
  40743. v, ok := value.(time.Time)
  40744. if !ok {
  40745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40746. }
  40747. m.SetUpdatedAt(v)
  40748. return nil
  40749. case wpchatroommember.FieldStatus:
  40750. v, ok := value.(uint8)
  40751. if !ok {
  40752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40753. }
  40754. m.SetStatus(v)
  40755. return nil
  40756. case wpchatroommember.FieldWxWxid:
  40757. v, ok := value.(string)
  40758. if !ok {
  40759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40760. }
  40761. m.SetWxWxid(v)
  40762. return nil
  40763. case wpchatroommember.FieldWxid:
  40764. v, ok := value.(string)
  40765. if !ok {
  40766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40767. }
  40768. m.SetWxid(v)
  40769. return nil
  40770. case wpchatroommember.FieldNickname:
  40771. v, ok := value.(string)
  40772. if !ok {
  40773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40774. }
  40775. m.SetNickname(v)
  40776. return nil
  40777. case wpchatroommember.FieldAvatar:
  40778. v, ok := value.(string)
  40779. if !ok {
  40780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40781. }
  40782. m.SetAvatar(v)
  40783. return nil
  40784. }
  40785. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  40786. }
  40787. // AddedFields returns all numeric fields that were incremented/decremented during
  40788. // this mutation.
  40789. func (m *WpChatroomMemberMutation) AddedFields() []string {
  40790. var fields []string
  40791. if m.addstatus != nil {
  40792. fields = append(fields, wpchatroommember.FieldStatus)
  40793. }
  40794. return fields
  40795. }
  40796. // AddedField returns the numeric value that was incremented/decremented on a field
  40797. // with the given name. The second boolean return value indicates that this field
  40798. // was not set, or was not defined in the schema.
  40799. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  40800. switch name {
  40801. case wpchatroommember.FieldStatus:
  40802. return m.AddedStatus()
  40803. }
  40804. return nil, false
  40805. }
  40806. // AddField adds the value to the field with the given name. It returns an error if
  40807. // the field is not defined in the schema, or if the type mismatched the field
  40808. // type.
  40809. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  40810. switch name {
  40811. case wpchatroommember.FieldStatus:
  40812. v, ok := value.(int8)
  40813. if !ok {
  40814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40815. }
  40816. m.AddStatus(v)
  40817. return nil
  40818. }
  40819. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  40820. }
  40821. // ClearedFields returns all nullable fields that were cleared during this
  40822. // mutation.
  40823. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  40824. var fields []string
  40825. if m.FieldCleared(wpchatroommember.FieldStatus) {
  40826. fields = append(fields, wpchatroommember.FieldStatus)
  40827. }
  40828. return fields
  40829. }
  40830. // FieldCleared returns a boolean indicating if a field with the given name was
  40831. // cleared in this mutation.
  40832. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  40833. _, ok := m.clearedFields[name]
  40834. return ok
  40835. }
  40836. // ClearField clears the value of the field with the given name. It returns an
  40837. // error if the field is not defined in the schema.
  40838. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  40839. switch name {
  40840. case wpchatroommember.FieldStatus:
  40841. m.ClearStatus()
  40842. return nil
  40843. }
  40844. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  40845. }
  40846. // ResetField resets all changes in the mutation for the field with the given name.
  40847. // It returns an error if the field is not defined in the schema.
  40848. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  40849. switch name {
  40850. case wpchatroommember.FieldCreatedAt:
  40851. m.ResetCreatedAt()
  40852. return nil
  40853. case wpchatroommember.FieldUpdatedAt:
  40854. m.ResetUpdatedAt()
  40855. return nil
  40856. case wpchatroommember.FieldStatus:
  40857. m.ResetStatus()
  40858. return nil
  40859. case wpchatroommember.FieldWxWxid:
  40860. m.ResetWxWxid()
  40861. return nil
  40862. case wpchatroommember.FieldWxid:
  40863. m.ResetWxid()
  40864. return nil
  40865. case wpchatroommember.FieldNickname:
  40866. m.ResetNickname()
  40867. return nil
  40868. case wpchatroommember.FieldAvatar:
  40869. m.ResetAvatar()
  40870. return nil
  40871. }
  40872. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  40873. }
  40874. // AddedEdges returns all edge names that were set/added in this mutation.
  40875. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  40876. edges := make([]string, 0, 0)
  40877. return edges
  40878. }
  40879. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40880. // name in this mutation.
  40881. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  40882. return nil
  40883. }
  40884. // RemovedEdges returns all edge names that were removed in this mutation.
  40885. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  40886. edges := make([]string, 0, 0)
  40887. return edges
  40888. }
  40889. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40890. // the given name in this mutation.
  40891. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  40892. return nil
  40893. }
  40894. // ClearedEdges returns all edge names that were cleared in this mutation.
  40895. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  40896. edges := make([]string, 0, 0)
  40897. return edges
  40898. }
  40899. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40900. // was cleared in this mutation.
  40901. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  40902. return false
  40903. }
  40904. // ClearEdge clears the value of the edge with the given name. It returns an error
  40905. // if that edge is not defined in the schema.
  40906. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  40907. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  40908. }
  40909. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40910. // It returns an error if the edge is not defined in the schema.
  40911. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  40912. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  40913. }
  40914. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  40915. type WxMutation struct {
  40916. config
  40917. op Op
  40918. typ string
  40919. id *uint64
  40920. created_at *time.Time
  40921. updated_at *time.Time
  40922. status *uint8
  40923. addstatus *int8
  40924. deleted_at *time.Time
  40925. port *string
  40926. process_id *string
  40927. callback *string
  40928. wxid *string
  40929. account *string
  40930. nickname *string
  40931. tel *string
  40932. head_big *string
  40933. organization_id *uint64
  40934. addorganization_id *int64
  40935. api_base *string
  40936. api_key *string
  40937. allow_list *[]string
  40938. appendallow_list []string
  40939. group_allow_list *[]string
  40940. appendgroup_allow_list []string
  40941. block_list *[]string
  40942. appendblock_list []string
  40943. group_block_list *[]string
  40944. appendgroup_block_list []string
  40945. ctype *uint64
  40946. addctype *int64
  40947. clearedFields map[string]struct{}
  40948. server *uint64
  40949. clearedserver bool
  40950. agent *uint64
  40951. clearedagent bool
  40952. done bool
  40953. oldValue func(context.Context) (*Wx, error)
  40954. predicates []predicate.Wx
  40955. }
  40956. var _ ent.Mutation = (*WxMutation)(nil)
  40957. // wxOption allows management of the mutation configuration using functional options.
  40958. type wxOption func(*WxMutation)
  40959. // newWxMutation creates new mutation for the Wx entity.
  40960. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  40961. m := &WxMutation{
  40962. config: c,
  40963. op: op,
  40964. typ: TypeWx,
  40965. clearedFields: make(map[string]struct{}),
  40966. }
  40967. for _, opt := range opts {
  40968. opt(m)
  40969. }
  40970. return m
  40971. }
  40972. // withWxID sets the ID field of the mutation.
  40973. func withWxID(id uint64) wxOption {
  40974. return func(m *WxMutation) {
  40975. var (
  40976. err error
  40977. once sync.Once
  40978. value *Wx
  40979. )
  40980. m.oldValue = func(ctx context.Context) (*Wx, error) {
  40981. once.Do(func() {
  40982. if m.done {
  40983. err = errors.New("querying old values post mutation is not allowed")
  40984. } else {
  40985. value, err = m.Client().Wx.Get(ctx, id)
  40986. }
  40987. })
  40988. return value, err
  40989. }
  40990. m.id = &id
  40991. }
  40992. }
  40993. // withWx sets the old Wx of the mutation.
  40994. func withWx(node *Wx) wxOption {
  40995. return func(m *WxMutation) {
  40996. m.oldValue = func(context.Context) (*Wx, error) {
  40997. return node, nil
  40998. }
  40999. m.id = &node.ID
  41000. }
  41001. }
  41002. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41003. // executed in a transaction (ent.Tx), a transactional client is returned.
  41004. func (m WxMutation) Client() *Client {
  41005. client := &Client{config: m.config}
  41006. client.init()
  41007. return client
  41008. }
  41009. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41010. // it returns an error otherwise.
  41011. func (m WxMutation) Tx() (*Tx, error) {
  41012. if _, ok := m.driver.(*txDriver); !ok {
  41013. return nil, errors.New("ent: mutation is not running in a transaction")
  41014. }
  41015. tx := &Tx{config: m.config}
  41016. tx.init()
  41017. return tx, nil
  41018. }
  41019. // SetID sets the value of the id field. Note that this
  41020. // operation is only accepted on creation of Wx entities.
  41021. func (m *WxMutation) SetID(id uint64) {
  41022. m.id = &id
  41023. }
  41024. // ID returns the ID value in the mutation. Note that the ID is only available
  41025. // if it was provided to the builder or after it was returned from the database.
  41026. func (m *WxMutation) ID() (id uint64, exists bool) {
  41027. if m.id == nil {
  41028. return
  41029. }
  41030. return *m.id, true
  41031. }
  41032. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41033. // That means, if the mutation is applied within a transaction with an isolation level such
  41034. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41035. // or updated by the mutation.
  41036. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  41037. switch {
  41038. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41039. id, exists := m.ID()
  41040. if exists {
  41041. return []uint64{id}, nil
  41042. }
  41043. fallthrough
  41044. case m.op.Is(OpUpdate | OpDelete):
  41045. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  41046. default:
  41047. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41048. }
  41049. }
  41050. // SetCreatedAt sets the "created_at" field.
  41051. func (m *WxMutation) SetCreatedAt(t time.Time) {
  41052. m.created_at = &t
  41053. }
  41054. // CreatedAt returns the value of the "created_at" field in the mutation.
  41055. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  41056. v := m.created_at
  41057. if v == nil {
  41058. return
  41059. }
  41060. return *v, true
  41061. }
  41062. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  41063. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41065. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41066. if !m.op.Is(OpUpdateOne) {
  41067. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41068. }
  41069. if m.id == nil || m.oldValue == nil {
  41070. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41071. }
  41072. oldValue, err := m.oldValue(ctx)
  41073. if err != nil {
  41074. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41075. }
  41076. return oldValue.CreatedAt, nil
  41077. }
  41078. // ResetCreatedAt resets all changes to the "created_at" field.
  41079. func (m *WxMutation) ResetCreatedAt() {
  41080. m.created_at = nil
  41081. }
  41082. // SetUpdatedAt sets the "updated_at" field.
  41083. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  41084. m.updated_at = &t
  41085. }
  41086. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41087. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  41088. v := m.updated_at
  41089. if v == nil {
  41090. return
  41091. }
  41092. return *v, true
  41093. }
  41094. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  41095. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41097. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41098. if !m.op.Is(OpUpdateOne) {
  41099. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41100. }
  41101. if m.id == nil || m.oldValue == nil {
  41102. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41103. }
  41104. oldValue, err := m.oldValue(ctx)
  41105. if err != nil {
  41106. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41107. }
  41108. return oldValue.UpdatedAt, nil
  41109. }
  41110. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41111. func (m *WxMutation) ResetUpdatedAt() {
  41112. m.updated_at = nil
  41113. }
  41114. // SetStatus sets the "status" field.
  41115. func (m *WxMutation) SetStatus(u uint8) {
  41116. m.status = &u
  41117. m.addstatus = nil
  41118. }
  41119. // Status returns the value of the "status" field in the mutation.
  41120. func (m *WxMutation) Status() (r uint8, exists bool) {
  41121. v := m.status
  41122. if v == nil {
  41123. return
  41124. }
  41125. return *v, true
  41126. }
  41127. // OldStatus returns the old "status" field's value of the Wx entity.
  41128. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41130. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41131. if !m.op.Is(OpUpdateOne) {
  41132. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41133. }
  41134. if m.id == nil || m.oldValue == nil {
  41135. return v, errors.New("OldStatus requires an ID field in the mutation")
  41136. }
  41137. oldValue, err := m.oldValue(ctx)
  41138. if err != nil {
  41139. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41140. }
  41141. return oldValue.Status, nil
  41142. }
  41143. // AddStatus adds u to the "status" field.
  41144. func (m *WxMutation) AddStatus(u int8) {
  41145. if m.addstatus != nil {
  41146. *m.addstatus += u
  41147. } else {
  41148. m.addstatus = &u
  41149. }
  41150. }
  41151. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41152. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  41153. v := m.addstatus
  41154. if v == nil {
  41155. return
  41156. }
  41157. return *v, true
  41158. }
  41159. // ClearStatus clears the value of the "status" field.
  41160. func (m *WxMutation) ClearStatus() {
  41161. m.status = nil
  41162. m.addstatus = nil
  41163. m.clearedFields[wx.FieldStatus] = struct{}{}
  41164. }
  41165. // StatusCleared returns if the "status" field was cleared in this mutation.
  41166. func (m *WxMutation) StatusCleared() bool {
  41167. _, ok := m.clearedFields[wx.FieldStatus]
  41168. return ok
  41169. }
  41170. // ResetStatus resets all changes to the "status" field.
  41171. func (m *WxMutation) ResetStatus() {
  41172. m.status = nil
  41173. m.addstatus = nil
  41174. delete(m.clearedFields, wx.FieldStatus)
  41175. }
  41176. // SetDeletedAt sets the "deleted_at" field.
  41177. func (m *WxMutation) SetDeletedAt(t time.Time) {
  41178. m.deleted_at = &t
  41179. }
  41180. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41181. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  41182. v := m.deleted_at
  41183. if v == nil {
  41184. return
  41185. }
  41186. return *v, true
  41187. }
  41188. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  41189. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41191. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41192. if !m.op.Is(OpUpdateOne) {
  41193. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41194. }
  41195. if m.id == nil || m.oldValue == nil {
  41196. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41197. }
  41198. oldValue, err := m.oldValue(ctx)
  41199. if err != nil {
  41200. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41201. }
  41202. return oldValue.DeletedAt, nil
  41203. }
  41204. // ClearDeletedAt clears the value of the "deleted_at" field.
  41205. func (m *WxMutation) ClearDeletedAt() {
  41206. m.deleted_at = nil
  41207. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  41208. }
  41209. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41210. func (m *WxMutation) DeletedAtCleared() bool {
  41211. _, ok := m.clearedFields[wx.FieldDeletedAt]
  41212. return ok
  41213. }
  41214. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41215. func (m *WxMutation) ResetDeletedAt() {
  41216. m.deleted_at = nil
  41217. delete(m.clearedFields, wx.FieldDeletedAt)
  41218. }
  41219. // SetServerID sets the "server_id" field.
  41220. func (m *WxMutation) SetServerID(u uint64) {
  41221. m.server = &u
  41222. }
  41223. // ServerID returns the value of the "server_id" field in the mutation.
  41224. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  41225. v := m.server
  41226. if v == nil {
  41227. return
  41228. }
  41229. return *v, true
  41230. }
  41231. // OldServerID returns the old "server_id" field's value of the Wx entity.
  41232. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41234. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  41235. if !m.op.Is(OpUpdateOne) {
  41236. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  41237. }
  41238. if m.id == nil || m.oldValue == nil {
  41239. return v, errors.New("OldServerID requires an ID field in the mutation")
  41240. }
  41241. oldValue, err := m.oldValue(ctx)
  41242. if err != nil {
  41243. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  41244. }
  41245. return oldValue.ServerID, nil
  41246. }
  41247. // ClearServerID clears the value of the "server_id" field.
  41248. func (m *WxMutation) ClearServerID() {
  41249. m.server = nil
  41250. m.clearedFields[wx.FieldServerID] = struct{}{}
  41251. }
  41252. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  41253. func (m *WxMutation) ServerIDCleared() bool {
  41254. _, ok := m.clearedFields[wx.FieldServerID]
  41255. return ok
  41256. }
  41257. // ResetServerID resets all changes to the "server_id" field.
  41258. func (m *WxMutation) ResetServerID() {
  41259. m.server = nil
  41260. delete(m.clearedFields, wx.FieldServerID)
  41261. }
  41262. // SetPort sets the "port" field.
  41263. func (m *WxMutation) SetPort(s string) {
  41264. m.port = &s
  41265. }
  41266. // Port returns the value of the "port" field in the mutation.
  41267. func (m *WxMutation) Port() (r string, exists bool) {
  41268. v := m.port
  41269. if v == nil {
  41270. return
  41271. }
  41272. return *v, true
  41273. }
  41274. // OldPort returns the old "port" field's value of the Wx entity.
  41275. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41277. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  41278. if !m.op.Is(OpUpdateOne) {
  41279. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  41280. }
  41281. if m.id == nil || m.oldValue == nil {
  41282. return v, errors.New("OldPort requires an ID field in the mutation")
  41283. }
  41284. oldValue, err := m.oldValue(ctx)
  41285. if err != nil {
  41286. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  41287. }
  41288. return oldValue.Port, nil
  41289. }
  41290. // ResetPort resets all changes to the "port" field.
  41291. func (m *WxMutation) ResetPort() {
  41292. m.port = nil
  41293. }
  41294. // SetProcessID sets the "process_id" field.
  41295. func (m *WxMutation) SetProcessID(s string) {
  41296. m.process_id = &s
  41297. }
  41298. // ProcessID returns the value of the "process_id" field in the mutation.
  41299. func (m *WxMutation) ProcessID() (r string, exists bool) {
  41300. v := m.process_id
  41301. if v == nil {
  41302. return
  41303. }
  41304. return *v, true
  41305. }
  41306. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  41307. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41309. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  41310. if !m.op.Is(OpUpdateOne) {
  41311. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  41312. }
  41313. if m.id == nil || m.oldValue == nil {
  41314. return v, errors.New("OldProcessID requires an ID field in the mutation")
  41315. }
  41316. oldValue, err := m.oldValue(ctx)
  41317. if err != nil {
  41318. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  41319. }
  41320. return oldValue.ProcessID, nil
  41321. }
  41322. // ResetProcessID resets all changes to the "process_id" field.
  41323. func (m *WxMutation) ResetProcessID() {
  41324. m.process_id = nil
  41325. }
  41326. // SetCallback sets the "callback" field.
  41327. func (m *WxMutation) SetCallback(s string) {
  41328. m.callback = &s
  41329. }
  41330. // Callback returns the value of the "callback" field in the mutation.
  41331. func (m *WxMutation) Callback() (r string, exists bool) {
  41332. v := m.callback
  41333. if v == nil {
  41334. return
  41335. }
  41336. return *v, true
  41337. }
  41338. // OldCallback returns the old "callback" field's value of the Wx entity.
  41339. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41341. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  41342. if !m.op.Is(OpUpdateOne) {
  41343. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  41344. }
  41345. if m.id == nil || m.oldValue == nil {
  41346. return v, errors.New("OldCallback requires an ID field in the mutation")
  41347. }
  41348. oldValue, err := m.oldValue(ctx)
  41349. if err != nil {
  41350. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  41351. }
  41352. return oldValue.Callback, nil
  41353. }
  41354. // ResetCallback resets all changes to the "callback" field.
  41355. func (m *WxMutation) ResetCallback() {
  41356. m.callback = nil
  41357. }
  41358. // SetWxid sets the "wxid" field.
  41359. func (m *WxMutation) SetWxid(s string) {
  41360. m.wxid = &s
  41361. }
  41362. // Wxid returns the value of the "wxid" field in the mutation.
  41363. func (m *WxMutation) Wxid() (r string, exists bool) {
  41364. v := m.wxid
  41365. if v == nil {
  41366. return
  41367. }
  41368. return *v, true
  41369. }
  41370. // OldWxid returns the old "wxid" field's value of the Wx entity.
  41371. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41373. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  41374. if !m.op.Is(OpUpdateOne) {
  41375. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41376. }
  41377. if m.id == nil || m.oldValue == nil {
  41378. return v, errors.New("OldWxid requires an ID field in the mutation")
  41379. }
  41380. oldValue, err := m.oldValue(ctx)
  41381. if err != nil {
  41382. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41383. }
  41384. return oldValue.Wxid, nil
  41385. }
  41386. // ResetWxid resets all changes to the "wxid" field.
  41387. func (m *WxMutation) ResetWxid() {
  41388. m.wxid = nil
  41389. }
  41390. // SetAccount sets the "account" field.
  41391. func (m *WxMutation) SetAccount(s string) {
  41392. m.account = &s
  41393. }
  41394. // Account returns the value of the "account" field in the mutation.
  41395. func (m *WxMutation) Account() (r string, exists bool) {
  41396. v := m.account
  41397. if v == nil {
  41398. return
  41399. }
  41400. return *v, true
  41401. }
  41402. // OldAccount returns the old "account" field's value of the Wx entity.
  41403. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41405. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  41406. if !m.op.Is(OpUpdateOne) {
  41407. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41408. }
  41409. if m.id == nil || m.oldValue == nil {
  41410. return v, errors.New("OldAccount requires an ID field in the mutation")
  41411. }
  41412. oldValue, err := m.oldValue(ctx)
  41413. if err != nil {
  41414. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41415. }
  41416. return oldValue.Account, nil
  41417. }
  41418. // ResetAccount resets all changes to the "account" field.
  41419. func (m *WxMutation) ResetAccount() {
  41420. m.account = nil
  41421. }
  41422. // SetNickname sets the "nickname" field.
  41423. func (m *WxMutation) SetNickname(s string) {
  41424. m.nickname = &s
  41425. }
  41426. // Nickname returns the value of the "nickname" field in the mutation.
  41427. func (m *WxMutation) Nickname() (r string, exists bool) {
  41428. v := m.nickname
  41429. if v == nil {
  41430. return
  41431. }
  41432. return *v, true
  41433. }
  41434. // OldNickname returns the old "nickname" field's value of the Wx entity.
  41435. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41437. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  41438. if !m.op.Is(OpUpdateOne) {
  41439. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41440. }
  41441. if m.id == nil || m.oldValue == nil {
  41442. return v, errors.New("OldNickname requires an ID field in the mutation")
  41443. }
  41444. oldValue, err := m.oldValue(ctx)
  41445. if err != nil {
  41446. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41447. }
  41448. return oldValue.Nickname, nil
  41449. }
  41450. // ResetNickname resets all changes to the "nickname" field.
  41451. func (m *WxMutation) ResetNickname() {
  41452. m.nickname = nil
  41453. }
  41454. // SetTel sets the "tel" field.
  41455. func (m *WxMutation) SetTel(s string) {
  41456. m.tel = &s
  41457. }
  41458. // Tel returns the value of the "tel" field in the mutation.
  41459. func (m *WxMutation) Tel() (r string, exists bool) {
  41460. v := m.tel
  41461. if v == nil {
  41462. return
  41463. }
  41464. return *v, true
  41465. }
  41466. // OldTel returns the old "tel" field's value of the Wx entity.
  41467. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41469. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  41470. if !m.op.Is(OpUpdateOne) {
  41471. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  41472. }
  41473. if m.id == nil || m.oldValue == nil {
  41474. return v, errors.New("OldTel requires an ID field in the mutation")
  41475. }
  41476. oldValue, err := m.oldValue(ctx)
  41477. if err != nil {
  41478. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  41479. }
  41480. return oldValue.Tel, nil
  41481. }
  41482. // ResetTel resets all changes to the "tel" field.
  41483. func (m *WxMutation) ResetTel() {
  41484. m.tel = nil
  41485. }
  41486. // SetHeadBig sets the "head_big" field.
  41487. func (m *WxMutation) SetHeadBig(s string) {
  41488. m.head_big = &s
  41489. }
  41490. // HeadBig returns the value of the "head_big" field in the mutation.
  41491. func (m *WxMutation) HeadBig() (r string, exists bool) {
  41492. v := m.head_big
  41493. if v == nil {
  41494. return
  41495. }
  41496. return *v, true
  41497. }
  41498. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  41499. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41501. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  41502. if !m.op.Is(OpUpdateOne) {
  41503. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  41504. }
  41505. if m.id == nil || m.oldValue == nil {
  41506. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  41507. }
  41508. oldValue, err := m.oldValue(ctx)
  41509. if err != nil {
  41510. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  41511. }
  41512. return oldValue.HeadBig, nil
  41513. }
  41514. // ResetHeadBig resets all changes to the "head_big" field.
  41515. func (m *WxMutation) ResetHeadBig() {
  41516. m.head_big = nil
  41517. }
  41518. // SetOrganizationID sets the "organization_id" field.
  41519. func (m *WxMutation) SetOrganizationID(u uint64) {
  41520. m.organization_id = &u
  41521. m.addorganization_id = nil
  41522. }
  41523. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41524. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  41525. v := m.organization_id
  41526. if v == nil {
  41527. return
  41528. }
  41529. return *v, true
  41530. }
  41531. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  41532. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41534. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41535. if !m.op.Is(OpUpdateOne) {
  41536. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41537. }
  41538. if m.id == nil || m.oldValue == nil {
  41539. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41540. }
  41541. oldValue, err := m.oldValue(ctx)
  41542. if err != nil {
  41543. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41544. }
  41545. return oldValue.OrganizationID, nil
  41546. }
  41547. // AddOrganizationID adds u to the "organization_id" field.
  41548. func (m *WxMutation) AddOrganizationID(u int64) {
  41549. if m.addorganization_id != nil {
  41550. *m.addorganization_id += u
  41551. } else {
  41552. m.addorganization_id = &u
  41553. }
  41554. }
  41555. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41556. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  41557. v := m.addorganization_id
  41558. if v == nil {
  41559. return
  41560. }
  41561. return *v, true
  41562. }
  41563. // ClearOrganizationID clears the value of the "organization_id" field.
  41564. func (m *WxMutation) ClearOrganizationID() {
  41565. m.organization_id = nil
  41566. m.addorganization_id = nil
  41567. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  41568. }
  41569. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41570. func (m *WxMutation) OrganizationIDCleared() bool {
  41571. _, ok := m.clearedFields[wx.FieldOrganizationID]
  41572. return ok
  41573. }
  41574. // ResetOrganizationID resets all changes to the "organization_id" field.
  41575. func (m *WxMutation) ResetOrganizationID() {
  41576. m.organization_id = nil
  41577. m.addorganization_id = nil
  41578. delete(m.clearedFields, wx.FieldOrganizationID)
  41579. }
  41580. // SetAgentID sets the "agent_id" field.
  41581. func (m *WxMutation) SetAgentID(u uint64) {
  41582. m.agent = &u
  41583. }
  41584. // AgentID returns the value of the "agent_id" field in the mutation.
  41585. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  41586. v := m.agent
  41587. if v == nil {
  41588. return
  41589. }
  41590. return *v, true
  41591. }
  41592. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  41593. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41595. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  41596. if !m.op.Is(OpUpdateOne) {
  41597. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  41598. }
  41599. if m.id == nil || m.oldValue == nil {
  41600. return v, errors.New("OldAgentID requires an ID field in the mutation")
  41601. }
  41602. oldValue, err := m.oldValue(ctx)
  41603. if err != nil {
  41604. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  41605. }
  41606. return oldValue.AgentID, nil
  41607. }
  41608. // ResetAgentID resets all changes to the "agent_id" field.
  41609. func (m *WxMutation) ResetAgentID() {
  41610. m.agent = nil
  41611. }
  41612. // SetAPIBase sets the "api_base" field.
  41613. func (m *WxMutation) SetAPIBase(s string) {
  41614. m.api_base = &s
  41615. }
  41616. // APIBase returns the value of the "api_base" field in the mutation.
  41617. func (m *WxMutation) APIBase() (r string, exists bool) {
  41618. v := m.api_base
  41619. if v == nil {
  41620. return
  41621. }
  41622. return *v, true
  41623. }
  41624. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  41625. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41627. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  41628. if !m.op.Is(OpUpdateOne) {
  41629. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  41630. }
  41631. if m.id == nil || m.oldValue == nil {
  41632. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  41633. }
  41634. oldValue, err := m.oldValue(ctx)
  41635. if err != nil {
  41636. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  41637. }
  41638. return oldValue.APIBase, nil
  41639. }
  41640. // ClearAPIBase clears the value of the "api_base" field.
  41641. func (m *WxMutation) ClearAPIBase() {
  41642. m.api_base = nil
  41643. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  41644. }
  41645. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  41646. func (m *WxMutation) APIBaseCleared() bool {
  41647. _, ok := m.clearedFields[wx.FieldAPIBase]
  41648. return ok
  41649. }
  41650. // ResetAPIBase resets all changes to the "api_base" field.
  41651. func (m *WxMutation) ResetAPIBase() {
  41652. m.api_base = nil
  41653. delete(m.clearedFields, wx.FieldAPIBase)
  41654. }
  41655. // SetAPIKey sets the "api_key" field.
  41656. func (m *WxMutation) SetAPIKey(s string) {
  41657. m.api_key = &s
  41658. }
  41659. // APIKey returns the value of the "api_key" field in the mutation.
  41660. func (m *WxMutation) APIKey() (r string, exists bool) {
  41661. v := m.api_key
  41662. if v == nil {
  41663. return
  41664. }
  41665. return *v, true
  41666. }
  41667. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  41668. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41670. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  41671. if !m.op.Is(OpUpdateOne) {
  41672. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  41673. }
  41674. if m.id == nil || m.oldValue == nil {
  41675. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  41676. }
  41677. oldValue, err := m.oldValue(ctx)
  41678. if err != nil {
  41679. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  41680. }
  41681. return oldValue.APIKey, nil
  41682. }
  41683. // ClearAPIKey clears the value of the "api_key" field.
  41684. func (m *WxMutation) ClearAPIKey() {
  41685. m.api_key = nil
  41686. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  41687. }
  41688. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  41689. func (m *WxMutation) APIKeyCleared() bool {
  41690. _, ok := m.clearedFields[wx.FieldAPIKey]
  41691. return ok
  41692. }
  41693. // ResetAPIKey resets all changes to the "api_key" field.
  41694. func (m *WxMutation) ResetAPIKey() {
  41695. m.api_key = nil
  41696. delete(m.clearedFields, wx.FieldAPIKey)
  41697. }
  41698. // SetAllowList sets the "allow_list" field.
  41699. func (m *WxMutation) SetAllowList(s []string) {
  41700. m.allow_list = &s
  41701. m.appendallow_list = nil
  41702. }
  41703. // AllowList returns the value of the "allow_list" field in the mutation.
  41704. func (m *WxMutation) AllowList() (r []string, exists bool) {
  41705. v := m.allow_list
  41706. if v == nil {
  41707. return
  41708. }
  41709. return *v, true
  41710. }
  41711. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  41712. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41714. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  41715. if !m.op.Is(OpUpdateOne) {
  41716. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  41717. }
  41718. if m.id == nil || m.oldValue == nil {
  41719. return v, errors.New("OldAllowList requires an ID field in the mutation")
  41720. }
  41721. oldValue, err := m.oldValue(ctx)
  41722. if err != nil {
  41723. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  41724. }
  41725. return oldValue.AllowList, nil
  41726. }
  41727. // AppendAllowList adds s to the "allow_list" field.
  41728. func (m *WxMutation) AppendAllowList(s []string) {
  41729. m.appendallow_list = append(m.appendallow_list, s...)
  41730. }
  41731. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  41732. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  41733. if len(m.appendallow_list) == 0 {
  41734. return nil, false
  41735. }
  41736. return m.appendallow_list, true
  41737. }
  41738. // ResetAllowList resets all changes to the "allow_list" field.
  41739. func (m *WxMutation) ResetAllowList() {
  41740. m.allow_list = nil
  41741. m.appendallow_list = nil
  41742. }
  41743. // SetGroupAllowList sets the "group_allow_list" field.
  41744. func (m *WxMutation) SetGroupAllowList(s []string) {
  41745. m.group_allow_list = &s
  41746. m.appendgroup_allow_list = nil
  41747. }
  41748. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  41749. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  41750. v := m.group_allow_list
  41751. if v == nil {
  41752. return
  41753. }
  41754. return *v, true
  41755. }
  41756. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  41757. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41759. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  41760. if !m.op.Is(OpUpdateOne) {
  41761. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  41762. }
  41763. if m.id == nil || m.oldValue == nil {
  41764. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  41765. }
  41766. oldValue, err := m.oldValue(ctx)
  41767. if err != nil {
  41768. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  41769. }
  41770. return oldValue.GroupAllowList, nil
  41771. }
  41772. // AppendGroupAllowList adds s to the "group_allow_list" field.
  41773. func (m *WxMutation) AppendGroupAllowList(s []string) {
  41774. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  41775. }
  41776. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  41777. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  41778. if len(m.appendgroup_allow_list) == 0 {
  41779. return nil, false
  41780. }
  41781. return m.appendgroup_allow_list, true
  41782. }
  41783. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  41784. func (m *WxMutation) ResetGroupAllowList() {
  41785. m.group_allow_list = nil
  41786. m.appendgroup_allow_list = nil
  41787. }
  41788. // SetBlockList sets the "block_list" field.
  41789. func (m *WxMutation) SetBlockList(s []string) {
  41790. m.block_list = &s
  41791. m.appendblock_list = nil
  41792. }
  41793. // BlockList returns the value of the "block_list" field in the mutation.
  41794. func (m *WxMutation) BlockList() (r []string, exists bool) {
  41795. v := m.block_list
  41796. if v == nil {
  41797. return
  41798. }
  41799. return *v, true
  41800. }
  41801. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  41802. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41804. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  41805. if !m.op.Is(OpUpdateOne) {
  41806. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  41807. }
  41808. if m.id == nil || m.oldValue == nil {
  41809. return v, errors.New("OldBlockList requires an ID field in the mutation")
  41810. }
  41811. oldValue, err := m.oldValue(ctx)
  41812. if err != nil {
  41813. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  41814. }
  41815. return oldValue.BlockList, nil
  41816. }
  41817. // AppendBlockList adds s to the "block_list" field.
  41818. func (m *WxMutation) AppendBlockList(s []string) {
  41819. m.appendblock_list = append(m.appendblock_list, s...)
  41820. }
  41821. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  41822. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  41823. if len(m.appendblock_list) == 0 {
  41824. return nil, false
  41825. }
  41826. return m.appendblock_list, true
  41827. }
  41828. // ResetBlockList resets all changes to the "block_list" field.
  41829. func (m *WxMutation) ResetBlockList() {
  41830. m.block_list = nil
  41831. m.appendblock_list = nil
  41832. }
  41833. // SetGroupBlockList sets the "group_block_list" field.
  41834. func (m *WxMutation) SetGroupBlockList(s []string) {
  41835. m.group_block_list = &s
  41836. m.appendgroup_block_list = nil
  41837. }
  41838. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  41839. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  41840. v := m.group_block_list
  41841. if v == nil {
  41842. return
  41843. }
  41844. return *v, true
  41845. }
  41846. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  41847. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41849. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  41850. if !m.op.Is(OpUpdateOne) {
  41851. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  41852. }
  41853. if m.id == nil || m.oldValue == nil {
  41854. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  41855. }
  41856. oldValue, err := m.oldValue(ctx)
  41857. if err != nil {
  41858. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  41859. }
  41860. return oldValue.GroupBlockList, nil
  41861. }
  41862. // AppendGroupBlockList adds s to the "group_block_list" field.
  41863. func (m *WxMutation) AppendGroupBlockList(s []string) {
  41864. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  41865. }
  41866. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  41867. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  41868. if len(m.appendgroup_block_list) == 0 {
  41869. return nil, false
  41870. }
  41871. return m.appendgroup_block_list, true
  41872. }
  41873. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  41874. func (m *WxMutation) ResetGroupBlockList() {
  41875. m.group_block_list = nil
  41876. m.appendgroup_block_list = nil
  41877. }
  41878. // SetCtype sets the "ctype" field.
  41879. func (m *WxMutation) SetCtype(u uint64) {
  41880. m.ctype = &u
  41881. m.addctype = nil
  41882. }
  41883. // Ctype returns the value of the "ctype" field in the mutation.
  41884. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  41885. v := m.ctype
  41886. if v == nil {
  41887. return
  41888. }
  41889. return *v, true
  41890. }
  41891. // OldCtype returns the old "ctype" field's value of the Wx entity.
  41892. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41894. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  41895. if !m.op.Is(OpUpdateOne) {
  41896. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  41897. }
  41898. if m.id == nil || m.oldValue == nil {
  41899. return v, errors.New("OldCtype requires an ID field in the mutation")
  41900. }
  41901. oldValue, err := m.oldValue(ctx)
  41902. if err != nil {
  41903. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  41904. }
  41905. return oldValue.Ctype, nil
  41906. }
  41907. // AddCtype adds u to the "ctype" field.
  41908. func (m *WxMutation) AddCtype(u int64) {
  41909. if m.addctype != nil {
  41910. *m.addctype += u
  41911. } else {
  41912. m.addctype = &u
  41913. }
  41914. }
  41915. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  41916. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  41917. v := m.addctype
  41918. if v == nil {
  41919. return
  41920. }
  41921. return *v, true
  41922. }
  41923. // ClearCtype clears the value of the "ctype" field.
  41924. func (m *WxMutation) ClearCtype() {
  41925. m.ctype = nil
  41926. m.addctype = nil
  41927. m.clearedFields[wx.FieldCtype] = struct{}{}
  41928. }
  41929. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  41930. func (m *WxMutation) CtypeCleared() bool {
  41931. _, ok := m.clearedFields[wx.FieldCtype]
  41932. return ok
  41933. }
  41934. // ResetCtype resets all changes to the "ctype" field.
  41935. func (m *WxMutation) ResetCtype() {
  41936. m.ctype = nil
  41937. m.addctype = nil
  41938. delete(m.clearedFields, wx.FieldCtype)
  41939. }
  41940. // ClearServer clears the "server" edge to the Server entity.
  41941. func (m *WxMutation) ClearServer() {
  41942. m.clearedserver = true
  41943. m.clearedFields[wx.FieldServerID] = struct{}{}
  41944. }
  41945. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  41946. func (m *WxMutation) ServerCleared() bool {
  41947. return m.ServerIDCleared() || m.clearedserver
  41948. }
  41949. // ServerIDs returns the "server" edge IDs in the mutation.
  41950. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  41951. // ServerID instead. It exists only for internal usage by the builders.
  41952. func (m *WxMutation) ServerIDs() (ids []uint64) {
  41953. if id := m.server; id != nil {
  41954. ids = append(ids, *id)
  41955. }
  41956. return
  41957. }
  41958. // ResetServer resets all changes to the "server" edge.
  41959. func (m *WxMutation) ResetServer() {
  41960. m.server = nil
  41961. m.clearedserver = false
  41962. }
  41963. // ClearAgent clears the "agent" edge to the Agent entity.
  41964. func (m *WxMutation) ClearAgent() {
  41965. m.clearedagent = true
  41966. m.clearedFields[wx.FieldAgentID] = struct{}{}
  41967. }
  41968. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  41969. func (m *WxMutation) AgentCleared() bool {
  41970. return m.clearedagent
  41971. }
  41972. // AgentIDs returns the "agent" edge IDs in the mutation.
  41973. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  41974. // AgentID instead. It exists only for internal usage by the builders.
  41975. func (m *WxMutation) AgentIDs() (ids []uint64) {
  41976. if id := m.agent; id != nil {
  41977. ids = append(ids, *id)
  41978. }
  41979. return
  41980. }
  41981. // ResetAgent resets all changes to the "agent" edge.
  41982. func (m *WxMutation) ResetAgent() {
  41983. m.agent = nil
  41984. m.clearedagent = false
  41985. }
  41986. // Where appends a list predicates to the WxMutation builder.
  41987. func (m *WxMutation) Where(ps ...predicate.Wx) {
  41988. m.predicates = append(m.predicates, ps...)
  41989. }
  41990. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  41991. // users can use type-assertion to append predicates that do not depend on any generated package.
  41992. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  41993. p := make([]predicate.Wx, len(ps))
  41994. for i := range ps {
  41995. p[i] = ps[i]
  41996. }
  41997. m.Where(p...)
  41998. }
  41999. // Op returns the operation name.
  42000. func (m *WxMutation) Op() Op {
  42001. return m.op
  42002. }
  42003. // SetOp allows setting the mutation operation.
  42004. func (m *WxMutation) SetOp(op Op) {
  42005. m.op = op
  42006. }
  42007. // Type returns the node type of this mutation (Wx).
  42008. func (m *WxMutation) Type() string {
  42009. return m.typ
  42010. }
  42011. // Fields returns all fields that were changed during this mutation. Note that in
  42012. // order to get all numeric fields that were incremented/decremented, call
  42013. // AddedFields().
  42014. func (m *WxMutation) Fields() []string {
  42015. fields := make([]string, 0, 22)
  42016. if m.created_at != nil {
  42017. fields = append(fields, wx.FieldCreatedAt)
  42018. }
  42019. if m.updated_at != nil {
  42020. fields = append(fields, wx.FieldUpdatedAt)
  42021. }
  42022. if m.status != nil {
  42023. fields = append(fields, wx.FieldStatus)
  42024. }
  42025. if m.deleted_at != nil {
  42026. fields = append(fields, wx.FieldDeletedAt)
  42027. }
  42028. if m.server != nil {
  42029. fields = append(fields, wx.FieldServerID)
  42030. }
  42031. if m.port != nil {
  42032. fields = append(fields, wx.FieldPort)
  42033. }
  42034. if m.process_id != nil {
  42035. fields = append(fields, wx.FieldProcessID)
  42036. }
  42037. if m.callback != nil {
  42038. fields = append(fields, wx.FieldCallback)
  42039. }
  42040. if m.wxid != nil {
  42041. fields = append(fields, wx.FieldWxid)
  42042. }
  42043. if m.account != nil {
  42044. fields = append(fields, wx.FieldAccount)
  42045. }
  42046. if m.nickname != nil {
  42047. fields = append(fields, wx.FieldNickname)
  42048. }
  42049. if m.tel != nil {
  42050. fields = append(fields, wx.FieldTel)
  42051. }
  42052. if m.head_big != nil {
  42053. fields = append(fields, wx.FieldHeadBig)
  42054. }
  42055. if m.organization_id != nil {
  42056. fields = append(fields, wx.FieldOrganizationID)
  42057. }
  42058. if m.agent != nil {
  42059. fields = append(fields, wx.FieldAgentID)
  42060. }
  42061. if m.api_base != nil {
  42062. fields = append(fields, wx.FieldAPIBase)
  42063. }
  42064. if m.api_key != nil {
  42065. fields = append(fields, wx.FieldAPIKey)
  42066. }
  42067. if m.allow_list != nil {
  42068. fields = append(fields, wx.FieldAllowList)
  42069. }
  42070. if m.group_allow_list != nil {
  42071. fields = append(fields, wx.FieldGroupAllowList)
  42072. }
  42073. if m.block_list != nil {
  42074. fields = append(fields, wx.FieldBlockList)
  42075. }
  42076. if m.group_block_list != nil {
  42077. fields = append(fields, wx.FieldGroupBlockList)
  42078. }
  42079. if m.ctype != nil {
  42080. fields = append(fields, wx.FieldCtype)
  42081. }
  42082. return fields
  42083. }
  42084. // Field returns the value of a field with the given name. The second boolean
  42085. // return value indicates that this field was not set, or was not defined in the
  42086. // schema.
  42087. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  42088. switch name {
  42089. case wx.FieldCreatedAt:
  42090. return m.CreatedAt()
  42091. case wx.FieldUpdatedAt:
  42092. return m.UpdatedAt()
  42093. case wx.FieldStatus:
  42094. return m.Status()
  42095. case wx.FieldDeletedAt:
  42096. return m.DeletedAt()
  42097. case wx.FieldServerID:
  42098. return m.ServerID()
  42099. case wx.FieldPort:
  42100. return m.Port()
  42101. case wx.FieldProcessID:
  42102. return m.ProcessID()
  42103. case wx.FieldCallback:
  42104. return m.Callback()
  42105. case wx.FieldWxid:
  42106. return m.Wxid()
  42107. case wx.FieldAccount:
  42108. return m.Account()
  42109. case wx.FieldNickname:
  42110. return m.Nickname()
  42111. case wx.FieldTel:
  42112. return m.Tel()
  42113. case wx.FieldHeadBig:
  42114. return m.HeadBig()
  42115. case wx.FieldOrganizationID:
  42116. return m.OrganizationID()
  42117. case wx.FieldAgentID:
  42118. return m.AgentID()
  42119. case wx.FieldAPIBase:
  42120. return m.APIBase()
  42121. case wx.FieldAPIKey:
  42122. return m.APIKey()
  42123. case wx.FieldAllowList:
  42124. return m.AllowList()
  42125. case wx.FieldGroupAllowList:
  42126. return m.GroupAllowList()
  42127. case wx.FieldBlockList:
  42128. return m.BlockList()
  42129. case wx.FieldGroupBlockList:
  42130. return m.GroupBlockList()
  42131. case wx.FieldCtype:
  42132. return m.Ctype()
  42133. }
  42134. return nil, false
  42135. }
  42136. // OldField returns the old value of the field from the database. An error is
  42137. // returned if the mutation operation is not UpdateOne, or the query to the
  42138. // database failed.
  42139. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42140. switch name {
  42141. case wx.FieldCreatedAt:
  42142. return m.OldCreatedAt(ctx)
  42143. case wx.FieldUpdatedAt:
  42144. return m.OldUpdatedAt(ctx)
  42145. case wx.FieldStatus:
  42146. return m.OldStatus(ctx)
  42147. case wx.FieldDeletedAt:
  42148. return m.OldDeletedAt(ctx)
  42149. case wx.FieldServerID:
  42150. return m.OldServerID(ctx)
  42151. case wx.FieldPort:
  42152. return m.OldPort(ctx)
  42153. case wx.FieldProcessID:
  42154. return m.OldProcessID(ctx)
  42155. case wx.FieldCallback:
  42156. return m.OldCallback(ctx)
  42157. case wx.FieldWxid:
  42158. return m.OldWxid(ctx)
  42159. case wx.FieldAccount:
  42160. return m.OldAccount(ctx)
  42161. case wx.FieldNickname:
  42162. return m.OldNickname(ctx)
  42163. case wx.FieldTel:
  42164. return m.OldTel(ctx)
  42165. case wx.FieldHeadBig:
  42166. return m.OldHeadBig(ctx)
  42167. case wx.FieldOrganizationID:
  42168. return m.OldOrganizationID(ctx)
  42169. case wx.FieldAgentID:
  42170. return m.OldAgentID(ctx)
  42171. case wx.FieldAPIBase:
  42172. return m.OldAPIBase(ctx)
  42173. case wx.FieldAPIKey:
  42174. return m.OldAPIKey(ctx)
  42175. case wx.FieldAllowList:
  42176. return m.OldAllowList(ctx)
  42177. case wx.FieldGroupAllowList:
  42178. return m.OldGroupAllowList(ctx)
  42179. case wx.FieldBlockList:
  42180. return m.OldBlockList(ctx)
  42181. case wx.FieldGroupBlockList:
  42182. return m.OldGroupBlockList(ctx)
  42183. case wx.FieldCtype:
  42184. return m.OldCtype(ctx)
  42185. }
  42186. return nil, fmt.Errorf("unknown Wx field %s", name)
  42187. }
  42188. // SetField sets the value of a field with the given name. It returns an error if
  42189. // the field is not defined in the schema, or if the type mismatched the field
  42190. // type.
  42191. func (m *WxMutation) SetField(name string, value ent.Value) error {
  42192. switch name {
  42193. case wx.FieldCreatedAt:
  42194. v, ok := value.(time.Time)
  42195. if !ok {
  42196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42197. }
  42198. m.SetCreatedAt(v)
  42199. return nil
  42200. case wx.FieldUpdatedAt:
  42201. v, ok := value.(time.Time)
  42202. if !ok {
  42203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42204. }
  42205. m.SetUpdatedAt(v)
  42206. return nil
  42207. case wx.FieldStatus:
  42208. v, ok := value.(uint8)
  42209. if !ok {
  42210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42211. }
  42212. m.SetStatus(v)
  42213. return nil
  42214. case wx.FieldDeletedAt:
  42215. v, ok := value.(time.Time)
  42216. if !ok {
  42217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42218. }
  42219. m.SetDeletedAt(v)
  42220. return nil
  42221. case wx.FieldServerID:
  42222. v, ok := value.(uint64)
  42223. if !ok {
  42224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42225. }
  42226. m.SetServerID(v)
  42227. return nil
  42228. case wx.FieldPort:
  42229. v, ok := value.(string)
  42230. if !ok {
  42231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42232. }
  42233. m.SetPort(v)
  42234. return nil
  42235. case wx.FieldProcessID:
  42236. v, ok := value.(string)
  42237. if !ok {
  42238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42239. }
  42240. m.SetProcessID(v)
  42241. return nil
  42242. case wx.FieldCallback:
  42243. v, ok := value.(string)
  42244. if !ok {
  42245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42246. }
  42247. m.SetCallback(v)
  42248. return nil
  42249. case wx.FieldWxid:
  42250. v, ok := value.(string)
  42251. if !ok {
  42252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42253. }
  42254. m.SetWxid(v)
  42255. return nil
  42256. case wx.FieldAccount:
  42257. v, ok := value.(string)
  42258. if !ok {
  42259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42260. }
  42261. m.SetAccount(v)
  42262. return nil
  42263. case wx.FieldNickname:
  42264. v, ok := value.(string)
  42265. if !ok {
  42266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42267. }
  42268. m.SetNickname(v)
  42269. return nil
  42270. case wx.FieldTel:
  42271. v, ok := value.(string)
  42272. if !ok {
  42273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42274. }
  42275. m.SetTel(v)
  42276. return nil
  42277. case wx.FieldHeadBig:
  42278. v, ok := value.(string)
  42279. if !ok {
  42280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42281. }
  42282. m.SetHeadBig(v)
  42283. return nil
  42284. case wx.FieldOrganizationID:
  42285. v, ok := value.(uint64)
  42286. if !ok {
  42287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42288. }
  42289. m.SetOrganizationID(v)
  42290. return nil
  42291. case wx.FieldAgentID:
  42292. v, ok := value.(uint64)
  42293. if !ok {
  42294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42295. }
  42296. m.SetAgentID(v)
  42297. return nil
  42298. case wx.FieldAPIBase:
  42299. v, ok := value.(string)
  42300. if !ok {
  42301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42302. }
  42303. m.SetAPIBase(v)
  42304. return nil
  42305. case wx.FieldAPIKey:
  42306. v, ok := value.(string)
  42307. if !ok {
  42308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42309. }
  42310. m.SetAPIKey(v)
  42311. return nil
  42312. case wx.FieldAllowList:
  42313. v, ok := value.([]string)
  42314. if !ok {
  42315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42316. }
  42317. m.SetAllowList(v)
  42318. return nil
  42319. case wx.FieldGroupAllowList:
  42320. v, ok := value.([]string)
  42321. if !ok {
  42322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42323. }
  42324. m.SetGroupAllowList(v)
  42325. return nil
  42326. case wx.FieldBlockList:
  42327. v, ok := value.([]string)
  42328. if !ok {
  42329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42330. }
  42331. m.SetBlockList(v)
  42332. return nil
  42333. case wx.FieldGroupBlockList:
  42334. v, ok := value.([]string)
  42335. if !ok {
  42336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42337. }
  42338. m.SetGroupBlockList(v)
  42339. return nil
  42340. case wx.FieldCtype:
  42341. v, ok := value.(uint64)
  42342. if !ok {
  42343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42344. }
  42345. m.SetCtype(v)
  42346. return nil
  42347. }
  42348. return fmt.Errorf("unknown Wx field %s", name)
  42349. }
  42350. // AddedFields returns all numeric fields that were incremented/decremented during
  42351. // this mutation.
  42352. func (m *WxMutation) AddedFields() []string {
  42353. var fields []string
  42354. if m.addstatus != nil {
  42355. fields = append(fields, wx.FieldStatus)
  42356. }
  42357. if m.addorganization_id != nil {
  42358. fields = append(fields, wx.FieldOrganizationID)
  42359. }
  42360. if m.addctype != nil {
  42361. fields = append(fields, wx.FieldCtype)
  42362. }
  42363. return fields
  42364. }
  42365. // AddedField returns the numeric value that was incremented/decremented on a field
  42366. // with the given name. The second boolean return value indicates that this field
  42367. // was not set, or was not defined in the schema.
  42368. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  42369. switch name {
  42370. case wx.FieldStatus:
  42371. return m.AddedStatus()
  42372. case wx.FieldOrganizationID:
  42373. return m.AddedOrganizationID()
  42374. case wx.FieldCtype:
  42375. return m.AddedCtype()
  42376. }
  42377. return nil, false
  42378. }
  42379. // AddField adds the value to the field with the given name. It returns an error if
  42380. // the field is not defined in the schema, or if the type mismatched the field
  42381. // type.
  42382. func (m *WxMutation) AddField(name string, value ent.Value) error {
  42383. switch name {
  42384. case wx.FieldStatus:
  42385. v, ok := value.(int8)
  42386. if !ok {
  42387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42388. }
  42389. m.AddStatus(v)
  42390. return nil
  42391. case wx.FieldOrganizationID:
  42392. v, ok := value.(int64)
  42393. if !ok {
  42394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42395. }
  42396. m.AddOrganizationID(v)
  42397. return nil
  42398. case wx.FieldCtype:
  42399. v, ok := value.(int64)
  42400. if !ok {
  42401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42402. }
  42403. m.AddCtype(v)
  42404. return nil
  42405. }
  42406. return fmt.Errorf("unknown Wx numeric field %s", name)
  42407. }
  42408. // ClearedFields returns all nullable fields that were cleared during this
  42409. // mutation.
  42410. func (m *WxMutation) ClearedFields() []string {
  42411. var fields []string
  42412. if m.FieldCleared(wx.FieldStatus) {
  42413. fields = append(fields, wx.FieldStatus)
  42414. }
  42415. if m.FieldCleared(wx.FieldDeletedAt) {
  42416. fields = append(fields, wx.FieldDeletedAt)
  42417. }
  42418. if m.FieldCleared(wx.FieldServerID) {
  42419. fields = append(fields, wx.FieldServerID)
  42420. }
  42421. if m.FieldCleared(wx.FieldOrganizationID) {
  42422. fields = append(fields, wx.FieldOrganizationID)
  42423. }
  42424. if m.FieldCleared(wx.FieldAPIBase) {
  42425. fields = append(fields, wx.FieldAPIBase)
  42426. }
  42427. if m.FieldCleared(wx.FieldAPIKey) {
  42428. fields = append(fields, wx.FieldAPIKey)
  42429. }
  42430. if m.FieldCleared(wx.FieldCtype) {
  42431. fields = append(fields, wx.FieldCtype)
  42432. }
  42433. return fields
  42434. }
  42435. // FieldCleared returns a boolean indicating if a field with the given name was
  42436. // cleared in this mutation.
  42437. func (m *WxMutation) FieldCleared(name string) bool {
  42438. _, ok := m.clearedFields[name]
  42439. return ok
  42440. }
  42441. // ClearField clears the value of the field with the given name. It returns an
  42442. // error if the field is not defined in the schema.
  42443. func (m *WxMutation) ClearField(name string) error {
  42444. switch name {
  42445. case wx.FieldStatus:
  42446. m.ClearStatus()
  42447. return nil
  42448. case wx.FieldDeletedAt:
  42449. m.ClearDeletedAt()
  42450. return nil
  42451. case wx.FieldServerID:
  42452. m.ClearServerID()
  42453. return nil
  42454. case wx.FieldOrganizationID:
  42455. m.ClearOrganizationID()
  42456. return nil
  42457. case wx.FieldAPIBase:
  42458. m.ClearAPIBase()
  42459. return nil
  42460. case wx.FieldAPIKey:
  42461. m.ClearAPIKey()
  42462. return nil
  42463. case wx.FieldCtype:
  42464. m.ClearCtype()
  42465. return nil
  42466. }
  42467. return fmt.Errorf("unknown Wx nullable field %s", name)
  42468. }
  42469. // ResetField resets all changes in the mutation for the field with the given name.
  42470. // It returns an error if the field is not defined in the schema.
  42471. func (m *WxMutation) ResetField(name string) error {
  42472. switch name {
  42473. case wx.FieldCreatedAt:
  42474. m.ResetCreatedAt()
  42475. return nil
  42476. case wx.FieldUpdatedAt:
  42477. m.ResetUpdatedAt()
  42478. return nil
  42479. case wx.FieldStatus:
  42480. m.ResetStatus()
  42481. return nil
  42482. case wx.FieldDeletedAt:
  42483. m.ResetDeletedAt()
  42484. return nil
  42485. case wx.FieldServerID:
  42486. m.ResetServerID()
  42487. return nil
  42488. case wx.FieldPort:
  42489. m.ResetPort()
  42490. return nil
  42491. case wx.FieldProcessID:
  42492. m.ResetProcessID()
  42493. return nil
  42494. case wx.FieldCallback:
  42495. m.ResetCallback()
  42496. return nil
  42497. case wx.FieldWxid:
  42498. m.ResetWxid()
  42499. return nil
  42500. case wx.FieldAccount:
  42501. m.ResetAccount()
  42502. return nil
  42503. case wx.FieldNickname:
  42504. m.ResetNickname()
  42505. return nil
  42506. case wx.FieldTel:
  42507. m.ResetTel()
  42508. return nil
  42509. case wx.FieldHeadBig:
  42510. m.ResetHeadBig()
  42511. return nil
  42512. case wx.FieldOrganizationID:
  42513. m.ResetOrganizationID()
  42514. return nil
  42515. case wx.FieldAgentID:
  42516. m.ResetAgentID()
  42517. return nil
  42518. case wx.FieldAPIBase:
  42519. m.ResetAPIBase()
  42520. return nil
  42521. case wx.FieldAPIKey:
  42522. m.ResetAPIKey()
  42523. return nil
  42524. case wx.FieldAllowList:
  42525. m.ResetAllowList()
  42526. return nil
  42527. case wx.FieldGroupAllowList:
  42528. m.ResetGroupAllowList()
  42529. return nil
  42530. case wx.FieldBlockList:
  42531. m.ResetBlockList()
  42532. return nil
  42533. case wx.FieldGroupBlockList:
  42534. m.ResetGroupBlockList()
  42535. return nil
  42536. case wx.FieldCtype:
  42537. m.ResetCtype()
  42538. return nil
  42539. }
  42540. return fmt.Errorf("unknown Wx field %s", name)
  42541. }
  42542. // AddedEdges returns all edge names that were set/added in this mutation.
  42543. func (m *WxMutation) AddedEdges() []string {
  42544. edges := make([]string, 0, 2)
  42545. if m.server != nil {
  42546. edges = append(edges, wx.EdgeServer)
  42547. }
  42548. if m.agent != nil {
  42549. edges = append(edges, wx.EdgeAgent)
  42550. }
  42551. return edges
  42552. }
  42553. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42554. // name in this mutation.
  42555. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  42556. switch name {
  42557. case wx.EdgeServer:
  42558. if id := m.server; id != nil {
  42559. return []ent.Value{*id}
  42560. }
  42561. case wx.EdgeAgent:
  42562. if id := m.agent; id != nil {
  42563. return []ent.Value{*id}
  42564. }
  42565. }
  42566. return nil
  42567. }
  42568. // RemovedEdges returns all edge names that were removed in this mutation.
  42569. func (m *WxMutation) RemovedEdges() []string {
  42570. edges := make([]string, 0, 2)
  42571. return edges
  42572. }
  42573. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42574. // the given name in this mutation.
  42575. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  42576. return nil
  42577. }
  42578. // ClearedEdges returns all edge names that were cleared in this mutation.
  42579. func (m *WxMutation) ClearedEdges() []string {
  42580. edges := make([]string, 0, 2)
  42581. if m.clearedserver {
  42582. edges = append(edges, wx.EdgeServer)
  42583. }
  42584. if m.clearedagent {
  42585. edges = append(edges, wx.EdgeAgent)
  42586. }
  42587. return edges
  42588. }
  42589. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42590. // was cleared in this mutation.
  42591. func (m *WxMutation) EdgeCleared(name string) bool {
  42592. switch name {
  42593. case wx.EdgeServer:
  42594. return m.clearedserver
  42595. case wx.EdgeAgent:
  42596. return m.clearedagent
  42597. }
  42598. return false
  42599. }
  42600. // ClearEdge clears the value of the edge with the given name. It returns an error
  42601. // if that edge is not defined in the schema.
  42602. func (m *WxMutation) ClearEdge(name string) error {
  42603. switch name {
  42604. case wx.EdgeServer:
  42605. m.ClearServer()
  42606. return nil
  42607. case wx.EdgeAgent:
  42608. m.ClearAgent()
  42609. return nil
  42610. }
  42611. return fmt.Errorf("unknown Wx unique edge %s", name)
  42612. }
  42613. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42614. // It returns an error if the edge is not defined in the schema.
  42615. func (m *WxMutation) ResetEdge(name string) error {
  42616. switch name {
  42617. case wx.EdgeServer:
  42618. m.ResetServer()
  42619. return nil
  42620. case wx.EdgeAgent:
  42621. m.ResetAgent()
  42622. return nil
  42623. }
  42624. return fmt.Errorf("unknown Wx edge %s", name)
  42625. }
  42626. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  42627. type WxCardMutation struct {
  42628. config
  42629. op Op
  42630. typ string
  42631. id *uint64
  42632. created_at *time.Time
  42633. updated_at *time.Time
  42634. deleted_at *time.Time
  42635. user_id *uint64
  42636. adduser_id *int64
  42637. wx_user_id *uint64
  42638. addwx_user_id *int64
  42639. avatar *string
  42640. logo *string
  42641. name *string
  42642. company *string
  42643. address *string
  42644. phone *string
  42645. official_account *string
  42646. wechat_account *string
  42647. email *string
  42648. api_base *string
  42649. api_key *string
  42650. ai_info *string
  42651. intro *string
  42652. clearedFields map[string]struct{}
  42653. done bool
  42654. oldValue func(context.Context) (*WxCard, error)
  42655. predicates []predicate.WxCard
  42656. }
  42657. var _ ent.Mutation = (*WxCardMutation)(nil)
  42658. // wxcardOption allows management of the mutation configuration using functional options.
  42659. type wxcardOption func(*WxCardMutation)
  42660. // newWxCardMutation creates new mutation for the WxCard entity.
  42661. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  42662. m := &WxCardMutation{
  42663. config: c,
  42664. op: op,
  42665. typ: TypeWxCard,
  42666. clearedFields: make(map[string]struct{}),
  42667. }
  42668. for _, opt := range opts {
  42669. opt(m)
  42670. }
  42671. return m
  42672. }
  42673. // withWxCardID sets the ID field of the mutation.
  42674. func withWxCardID(id uint64) wxcardOption {
  42675. return func(m *WxCardMutation) {
  42676. var (
  42677. err error
  42678. once sync.Once
  42679. value *WxCard
  42680. )
  42681. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  42682. once.Do(func() {
  42683. if m.done {
  42684. err = errors.New("querying old values post mutation is not allowed")
  42685. } else {
  42686. value, err = m.Client().WxCard.Get(ctx, id)
  42687. }
  42688. })
  42689. return value, err
  42690. }
  42691. m.id = &id
  42692. }
  42693. }
  42694. // withWxCard sets the old WxCard of the mutation.
  42695. func withWxCard(node *WxCard) wxcardOption {
  42696. return func(m *WxCardMutation) {
  42697. m.oldValue = func(context.Context) (*WxCard, error) {
  42698. return node, nil
  42699. }
  42700. m.id = &node.ID
  42701. }
  42702. }
  42703. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42704. // executed in a transaction (ent.Tx), a transactional client is returned.
  42705. func (m WxCardMutation) Client() *Client {
  42706. client := &Client{config: m.config}
  42707. client.init()
  42708. return client
  42709. }
  42710. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42711. // it returns an error otherwise.
  42712. func (m WxCardMutation) Tx() (*Tx, error) {
  42713. if _, ok := m.driver.(*txDriver); !ok {
  42714. return nil, errors.New("ent: mutation is not running in a transaction")
  42715. }
  42716. tx := &Tx{config: m.config}
  42717. tx.init()
  42718. return tx, nil
  42719. }
  42720. // SetID sets the value of the id field. Note that this
  42721. // operation is only accepted on creation of WxCard entities.
  42722. func (m *WxCardMutation) SetID(id uint64) {
  42723. m.id = &id
  42724. }
  42725. // ID returns the ID value in the mutation. Note that the ID is only available
  42726. // if it was provided to the builder or after it was returned from the database.
  42727. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  42728. if m.id == nil {
  42729. return
  42730. }
  42731. return *m.id, true
  42732. }
  42733. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42734. // That means, if the mutation is applied within a transaction with an isolation level such
  42735. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42736. // or updated by the mutation.
  42737. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  42738. switch {
  42739. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42740. id, exists := m.ID()
  42741. if exists {
  42742. return []uint64{id}, nil
  42743. }
  42744. fallthrough
  42745. case m.op.Is(OpUpdate | OpDelete):
  42746. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  42747. default:
  42748. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42749. }
  42750. }
  42751. // SetCreatedAt sets the "created_at" field.
  42752. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  42753. m.created_at = &t
  42754. }
  42755. // CreatedAt returns the value of the "created_at" field in the mutation.
  42756. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  42757. v := m.created_at
  42758. if v == nil {
  42759. return
  42760. }
  42761. return *v, true
  42762. }
  42763. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  42764. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42766. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42767. if !m.op.Is(OpUpdateOne) {
  42768. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42769. }
  42770. if m.id == nil || m.oldValue == nil {
  42771. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42772. }
  42773. oldValue, err := m.oldValue(ctx)
  42774. if err != nil {
  42775. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42776. }
  42777. return oldValue.CreatedAt, nil
  42778. }
  42779. // ResetCreatedAt resets all changes to the "created_at" field.
  42780. func (m *WxCardMutation) ResetCreatedAt() {
  42781. m.created_at = nil
  42782. }
  42783. // SetUpdatedAt sets the "updated_at" field.
  42784. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  42785. m.updated_at = &t
  42786. }
  42787. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42788. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  42789. v := m.updated_at
  42790. if v == nil {
  42791. return
  42792. }
  42793. return *v, true
  42794. }
  42795. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  42796. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42798. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42799. if !m.op.Is(OpUpdateOne) {
  42800. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42801. }
  42802. if m.id == nil || m.oldValue == nil {
  42803. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42804. }
  42805. oldValue, err := m.oldValue(ctx)
  42806. if err != nil {
  42807. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42808. }
  42809. return oldValue.UpdatedAt, nil
  42810. }
  42811. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42812. func (m *WxCardMutation) ResetUpdatedAt() {
  42813. m.updated_at = nil
  42814. }
  42815. // SetDeletedAt sets the "deleted_at" field.
  42816. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  42817. m.deleted_at = &t
  42818. }
  42819. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42820. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  42821. v := m.deleted_at
  42822. if v == nil {
  42823. return
  42824. }
  42825. return *v, true
  42826. }
  42827. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  42828. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42830. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42831. if !m.op.Is(OpUpdateOne) {
  42832. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42833. }
  42834. if m.id == nil || m.oldValue == nil {
  42835. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42836. }
  42837. oldValue, err := m.oldValue(ctx)
  42838. if err != nil {
  42839. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42840. }
  42841. return oldValue.DeletedAt, nil
  42842. }
  42843. // ClearDeletedAt clears the value of the "deleted_at" field.
  42844. func (m *WxCardMutation) ClearDeletedAt() {
  42845. m.deleted_at = nil
  42846. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  42847. }
  42848. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42849. func (m *WxCardMutation) DeletedAtCleared() bool {
  42850. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  42851. return ok
  42852. }
  42853. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42854. func (m *WxCardMutation) ResetDeletedAt() {
  42855. m.deleted_at = nil
  42856. delete(m.clearedFields, wxcard.FieldDeletedAt)
  42857. }
  42858. // SetUserID sets the "user_id" field.
  42859. func (m *WxCardMutation) SetUserID(u uint64) {
  42860. m.user_id = &u
  42861. m.adduser_id = nil
  42862. }
  42863. // UserID returns the value of the "user_id" field in the mutation.
  42864. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  42865. v := m.user_id
  42866. if v == nil {
  42867. return
  42868. }
  42869. return *v, true
  42870. }
  42871. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  42872. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42874. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  42875. if !m.op.Is(OpUpdateOne) {
  42876. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  42877. }
  42878. if m.id == nil || m.oldValue == nil {
  42879. return v, errors.New("OldUserID requires an ID field in the mutation")
  42880. }
  42881. oldValue, err := m.oldValue(ctx)
  42882. if err != nil {
  42883. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  42884. }
  42885. return oldValue.UserID, nil
  42886. }
  42887. // AddUserID adds u to the "user_id" field.
  42888. func (m *WxCardMutation) AddUserID(u int64) {
  42889. if m.adduser_id != nil {
  42890. *m.adduser_id += u
  42891. } else {
  42892. m.adduser_id = &u
  42893. }
  42894. }
  42895. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  42896. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  42897. v := m.adduser_id
  42898. if v == nil {
  42899. return
  42900. }
  42901. return *v, true
  42902. }
  42903. // ClearUserID clears the value of the "user_id" field.
  42904. func (m *WxCardMutation) ClearUserID() {
  42905. m.user_id = nil
  42906. m.adduser_id = nil
  42907. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  42908. }
  42909. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  42910. func (m *WxCardMutation) UserIDCleared() bool {
  42911. _, ok := m.clearedFields[wxcard.FieldUserID]
  42912. return ok
  42913. }
  42914. // ResetUserID resets all changes to the "user_id" field.
  42915. func (m *WxCardMutation) ResetUserID() {
  42916. m.user_id = nil
  42917. m.adduser_id = nil
  42918. delete(m.clearedFields, wxcard.FieldUserID)
  42919. }
  42920. // SetWxUserID sets the "wx_user_id" field.
  42921. func (m *WxCardMutation) SetWxUserID(u uint64) {
  42922. m.wx_user_id = &u
  42923. m.addwx_user_id = nil
  42924. }
  42925. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  42926. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  42927. v := m.wx_user_id
  42928. if v == nil {
  42929. return
  42930. }
  42931. return *v, true
  42932. }
  42933. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  42934. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42936. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  42937. if !m.op.Is(OpUpdateOne) {
  42938. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  42939. }
  42940. if m.id == nil || m.oldValue == nil {
  42941. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  42942. }
  42943. oldValue, err := m.oldValue(ctx)
  42944. if err != nil {
  42945. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  42946. }
  42947. return oldValue.WxUserID, nil
  42948. }
  42949. // AddWxUserID adds u to the "wx_user_id" field.
  42950. func (m *WxCardMutation) AddWxUserID(u int64) {
  42951. if m.addwx_user_id != nil {
  42952. *m.addwx_user_id += u
  42953. } else {
  42954. m.addwx_user_id = &u
  42955. }
  42956. }
  42957. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  42958. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  42959. v := m.addwx_user_id
  42960. if v == nil {
  42961. return
  42962. }
  42963. return *v, true
  42964. }
  42965. // ClearWxUserID clears the value of the "wx_user_id" field.
  42966. func (m *WxCardMutation) ClearWxUserID() {
  42967. m.wx_user_id = nil
  42968. m.addwx_user_id = nil
  42969. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  42970. }
  42971. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  42972. func (m *WxCardMutation) WxUserIDCleared() bool {
  42973. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  42974. return ok
  42975. }
  42976. // ResetWxUserID resets all changes to the "wx_user_id" field.
  42977. func (m *WxCardMutation) ResetWxUserID() {
  42978. m.wx_user_id = nil
  42979. m.addwx_user_id = nil
  42980. delete(m.clearedFields, wxcard.FieldWxUserID)
  42981. }
  42982. // SetAvatar sets the "avatar" field.
  42983. func (m *WxCardMutation) SetAvatar(s string) {
  42984. m.avatar = &s
  42985. }
  42986. // Avatar returns the value of the "avatar" field in the mutation.
  42987. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  42988. v := m.avatar
  42989. if v == nil {
  42990. return
  42991. }
  42992. return *v, true
  42993. }
  42994. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  42995. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42997. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  42998. if !m.op.Is(OpUpdateOne) {
  42999. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43000. }
  43001. if m.id == nil || m.oldValue == nil {
  43002. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43003. }
  43004. oldValue, err := m.oldValue(ctx)
  43005. if err != nil {
  43006. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43007. }
  43008. return oldValue.Avatar, nil
  43009. }
  43010. // ResetAvatar resets all changes to the "avatar" field.
  43011. func (m *WxCardMutation) ResetAvatar() {
  43012. m.avatar = nil
  43013. }
  43014. // SetLogo sets the "logo" field.
  43015. func (m *WxCardMutation) SetLogo(s string) {
  43016. m.logo = &s
  43017. }
  43018. // Logo returns the value of the "logo" field in the mutation.
  43019. func (m *WxCardMutation) Logo() (r string, exists bool) {
  43020. v := m.logo
  43021. if v == nil {
  43022. return
  43023. }
  43024. return *v, true
  43025. }
  43026. // OldLogo returns the old "logo" field's value of the WxCard entity.
  43027. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43029. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  43030. if !m.op.Is(OpUpdateOne) {
  43031. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  43032. }
  43033. if m.id == nil || m.oldValue == nil {
  43034. return v, errors.New("OldLogo requires an ID field in the mutation")
  43035. }
  43036. oldValue, err := m.oldValue(ctx)
  43037. if err != nil {
  43038. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  43039. }
  43040. return oldValue.Logo, nil
  43041. }
  43042. // ResetLogo resets all changes to the "logo" field.
  43043. func (m *WxCardMutation) ResetLogo() {
  43044. m.logo = nil
  43045. }
  43046. // SetName sets the "name" field.
  43047. func (m *WxCardMutation) SetName(s string) {
  43048. m.name = &s
  43049. }
  43050. // Name returns the value of the "name" field in the mutation.
  43051. func (m *WxCardMutation) Name() (r string, exists bool) {
  43052. v := m.name
  43053. if v == nil {
  43054. return
  43055. }
  43056. return *v, true
  43057. }
  43058. // OldName returns the old "name" field's value of the WxCard entity.
  43059. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43061. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  43062. if !m.op.Is(OpUpdateOne) {
  43063. return v, errors.New("OldName is only allowed on UpdateOne operations")
  43064. }
  43065. if m.id == nil || m.oldValue == nil {
  43066. return v, errors.New("OldName requires an ID field in the mutation")
  43067. }
  43068. oldValue, err := m.oldValue(ctx)
  43069. if err != nil {
  43070. return v, fmt.Errorf("querying old value for OldName: %w", err)
  43071. }
  43072. return oldValue.Name, nil
  43073. }
  43074. // ResetName resets all changes to the "name" field.
  43075. func (m *WxCardMutation) ResetName() {
  43076. m.name = nil
  43077. }
  43078. // SetCompany sets the "company" field.
  43079. func (m *WxCardMutation) SetCompany(s string) {
  43080. m.company = &s
  43081. }
  43082. // Company returns the value of the "company" field in the mutation.
  43083. func (m *WxCardMutation) Company() (r string, exists bool) {
  43084. v := m.company
  43085. if v == nil {
  43086. return
  43087. }
  43088. return *v, true
  43089. }
  43090. // OldCompany returns the old "company" field's value of the WxCard entity.
  43091. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43093. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  43094. if !m.op.Is(OpUpdateOne) {
  43095. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  43096. }
  43097. if m.id == nil || m.oldValue == nil {
  43098. return v, errors.New("OldCompany requires an ID field in the mutation")
  43099. }
  43100. oldValue, err := m.oldValue(ctx)
  43101. if err != nil {
  43102. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  43103. }
  43104. return oldValue.Company, nil
  43105. }
  43106. // ResetCompany resets all changes to the "company" field.
  43107. func (m *WxCardMutation) ResetCompany() {
  43108. m.company = nil
  43109. }
  43110. // SetAddress sets the "address" field.
  43111. func (m *WxCardMutation) SetAddress(s string) {
  43112. m.address = &s
  43113. }
  43114. // Address returns the value of the "address" field in the mutation.
  43115. func (m *WxCardMutation) Address() (r string, exists bool) {
  43116. v := m.address
  43117. if v == nil {
  43118. return
  43119. }
  43120. return *v, true
  43121. }
  43122. // OldAddress returns the old "address" field's value of the WxCard entity.
  43123. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43125. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  43126. if !m.op.Is(OpUpdateOne) {
  43127. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  43128. }
  43129. if m.id == nil || m.oldValue == nil {
  43130. return v, errors.New("OldAddress requires an ID field in the mutation")
  43131. }
  43132. oldValue, err := m.oldValue(ctx)
  43133. if err != nil {
  43134. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  43135. }
  43136. return oldValue.Address, nil
  43137. }
  43138. // ResetAddress resets all changes to the "address" field.
  43139. func (m *WxCardMutation) ResetAddress() {
  43140. m.address = nil
  43141. }
  43142. // SetPhone sets the "phone" field.
  43143. func (m *WxCardMutation) SetPhone(s string) {
  43144. m.phone = &s
  43145. }
  43146. // Phone returns the value of the "phone" field in the mutation.
  43147. func (m *WxCardMutation) Phone() (r string, exists bool) {
  43148. v := m.phone
  43149. if v == nil {
  43150. return
  43151. }
  43152. return *v, true
  43153. }
  43154. // OldPhone returns the old "phone" field's value of the WxCard entity.
  43155. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43157. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  43158. if !m.op.Is(OpUpdateOne) {
  43159. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43160. }
  43161. if m.id == nil || m.oldValue == nil {
  43162. return v, errors.New("OldPhone requires an ID field in the mutation")
  43163. }
  43164. oldValue, err := m.oldValue(ctx)
  43165. if err != nil {
  43166. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43167. }
  43168. return oldValue.Phone, nil
  43169. }
  43170. // ResetPhone resets all changes to the "phone" field.
  43171. func (m *WxCardMutation) ResetPhone() {
  43172. m.phone = nil
  43173. }
  43174. // SetOfficialAccount sets the "official_account" field.
  43175. func (m *WxCardMutation) SetOfficialAccount(s string) {
  43176. m.official_account = &s
  43177. }
  43178. // OfficialAccount returns the value of the "official_account" field in the mutation.
  43179. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  43180. v := m.official_account
  43181. if v == nil {
  43182. return
  43183. }
  43184. return *v, true
  43185. }
  43186. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  43187. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43189. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  43190. if !m.op.Is(OpUpdateOne) {
  43191. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  43192. }
  43193. if m.id == nil || m.oldValue == nil {
  43194. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  43195. }
  43196. oldValue, err := m.oldValue(ctx)
  43197. if err != nil {
  43198. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  43199. }
  43200. return oldValue.OfficialAccount, nil
  43201. }
  43202. // ResetOfficialAccount resets all changes to the "official_account" field.
  43203. func (m *WxCardMutation) ResetOfficialAccount() {
  43204. m.official_account = nil
  43205. }
  43206. // SetWechatAccount sets the "wechat_account" field.
  43207. func (m *WxCardMutation) SetWechatAccount(s string) {
  43208. m.wechat_account = &s
  43209. }
  43210. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  43211. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  43212. v := m.wechat_account
  43213. if v == nil {
  43214. return
  43215. }
  43216. return *v, true
  43217. }
  43218. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  43219. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43221. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  43222. if !m.op.Is(OpUpdateOne) {
  43223. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  43224. }
  43225. if m.id == nil || m.oldValue == nil {
  43226. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  43227. }
  43228. oldValue, err := m.oldValue(ctx)
  43229. if err != nil {
  43230. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  43231. }
  43232. return oldValue.WechatAccount, nil
  43233. }
  43234. // ResetWechatAccount resets all changes to the "wechat_account" field.
  43235. func (m *WxCardMutation) ResetWechatAccount() {
  43236. m.wechat_account = nil
  43237. }
  43238. // SetEmail sets the "email" field.
  43239. func (m *WxCardMutation) SetEmail(s string) {
  43240. m.email = &s
  43241. }
  43242. // Email returns the value of the "email" field in the mutation.
  43243. func (m *WxCardMutation) Email() (r string, exists bool) {
  43244. v := m.email
  43245. if v == nil {
  43246. return
  43247. }
  43248. return *v, true
  43249. }
  43250. // OldEmail returns the old "email" field's value of the WxCard entity.
  43251. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43253. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  43254. if !m.op.Is(OpUpdateOne) {
  43255. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  43256. }
  43257. if m.id == nil || m.oldValue == nil {
  43258. return v, errors.New("OldEmail requires an ID field in the mutation")
  43259. }
  43260. oldValue, err := m.oldValue(ctx)
  43261. if err != nil {
  43262. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  43263. }
  43264. return oldValue.Email, nil
  43265. }
  43266. // ClearEmail clears the value of the "email" field.
  43267. func (m *WxCardMutation) ClearEmail() {
  43268. m.email = nil
  43269. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  43270. }
  43271. // EmailCleared returns if the "email" field was cleared in this mutation.
  43272. func (m *WxCardMutation) EmailCleared() bool {
  43273. _, ok := m.clearedFields[wxcard.FieldEmail]
  43274. return ok
  43275. }
  43276. // ResetEmail resets all changes to the "email" field.
  43277. func (m *WxCardMutation) ResetEmail() {
  43278. m.email = nil
  43279. delete(m.clearedFields, wxcard.FieldEmail)
  43280. }
  43281. // SetAPIBase sets the "api_base" field.
  43282. func (m *WxCardMutation) SetAPIBase(s string) {
  43283. m.api_base = &s
  43284. }
  43285. // APIBase returns the value of the "api_base" field in the mutation.
  43286. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  43287. v := m.api_base
  43288. if v == nil {
  43289. return
  43290. }
  43291. return *v, true
  43292. }
  43293. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  43294. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43296. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  43297. if !m.op.Is(OpUpdateOne) {
  43298. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43299. }
  43300. if m.id == nil || m.oldValue == nil {
  43301. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  43302. }
  43303. oldValue, err := m.oldValue(ctx)
  43304. if err != nil {
  43305. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  43306. }
  43307. return oldValue.APIBase, nil
  43308. }
  43309. // ClearAPIBase clears the value of the "api_base" field.
  43310. func (m *WxCardMutation) ClearAPIBase() {
  43311. m.api_base = nil
  43312. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  43313. }
  43314. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43315. func (m *WxCardMutation) APIBaseCleared() bool {
  43316. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  43317. return ok
  43318. }
  43319. // ResetAPIBase resets all changes to the "api_base" field.
  43320. func (m *WxCardMutation) ResetAPIBase() {
  43321. m.api_base = nil
  43322. delete(m.clearedFields, wxcard.FieldAPIBase)
  43323. }
  43324. // SetAPIKey sets the "api_key" field.
  43325. func (m *WxCardMutation) SetAPIKey(s string) {
  43326. m.api_key = &s
  43327. }
  43328. // APIKey returns the value of the "api_key" field in the mutation.
  43329. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  43330. v := m.api_key
  43331. if v == nil {
  43332. return
  43333. }
  43334. return *v, true
  43335. }
  43336. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  43337. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43339. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43340. if !m.op.Is(OpUpdateOne) {
  43341. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43342. }
  43343. if m.id == nil || m.oldValue == nil {
  43344. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43345. }
  43346. oldValue, err := m.oldValue(ctx)
  43347. if err != nil {
  43348. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43349. }
  43350. return oldValue.APIKey, nil
  43351. }
  43352. // ClearAPIKey clears the value of the "api_key" field.
  43353. func (m *WxCardMutation) ClearAPIKey() {
  43354. m.api_key = nil
  43355. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  43356. }
  43357. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43358. func (m *WxCardMutation) APIKeyCleared() bool {
  43359. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  43360. return ok
  43361. }
  43362. // ResetAPIKey resets all changes to the "api_key" field.
  43363. func (m *WxCardMutation) ResetAPIKey() {
  43364. m.api_key = nil
  43365. delete(m.clearedFields, wxcard.FieldAPIKey)
  43366. }
  43367. // SetAiInfo sets the "ai_info" field.
  43368. func (m *WxCardMutation) SetAiInfo(s string) {
  43369. m.ai_info = &s
  43370. }
  43371. // AiInfo returns the value of the "ai_info" field in the mutation.
  43372. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  43373. v := m.ai_info
  43374. if v == nil {
  43375. return
  43376. }
  43377. return *v, true
  43378. }
  43379. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  43380. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43382. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  43383. if !m.op.Is(OpUpdateOne) {
  43384. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  43385. }
  43386. if m.id == nil || m.oldValue == nil {
  43387. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  43388. }
  43389. oldValue, err := m.oldValue(ctx)
  43390. if err != nil {
  43391. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  43392. }
  43393. return oldValue.AiInfo, nil
  43394. }
  43395. // ClearAiInfo clears the value of the "ai_info" field.
  43396. func (m *WxCardMutation) ClearAiInfo() {
  43397. m.ai_info = nil
  43398. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  43399. }
  43400. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  43401. func (m *WxCardMutation) AiInfoCleared() bool {
  43402. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  43403. return ok
  43404. }
  43405. // ResetAiInfo resets all changes to the "ai_info" field.
  43406. func (m *WxCardMutation) ResetAiInfo() {
  43407. m.ai_info = nil
  43408. delete(m.clearedFields, wxcard.FieldAiInfo)
  43409. }
  43410. // SetIntro sets the "intro" field.
  43411. func (m *WxCardMutation) SetIntro(s string) {
  43412. m.intro = &s
  43413. }
  43414. // Intro returns the value of the "intro" field in the mutation.
  43415. func (m *WxCardMutation) Intro() (r string, exists bool) {
  43416. v := m.intro
  43417. if v == nil {
  43418. return
  43419. }
  43420. return *v, true
  43421. }
  43422. // OldIntro returns the old "intro" field's value of the WxCard entity.
  43423. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43425. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  43426. if !m.op.Is(OpUpdateOne) {
  43427. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  43428. }
  43429. if m.id == nil || m.oldValue == nil {
  43430. return v, errors.New("OldIntro requires an ID field in the mutation")
  43431. }
  43432. oldValue, err := m.oldValue(ctx)
  43433. if err != nil {
  43434. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  43435. }
  43436. return oldValue.Intro, nil
  43437. }
  43438. // ClearIntro clears the value of the "intro" field.
  43439. func (m *WxCardMutation) ClearIntro() {
  43440. m.intro = nil
  43441. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  43442. }
  43443. // IntroCleared returns if the "intro" field was cleared in this mutation.
  43444. func (m *WxCardMutation) IntroCleared() bool {
  43445. _, ok := m.clearedFields[wxcard.FieldIntro]
  43446. return ok
  43447. }
  43448. // ResetIntro resets all changes to the "intro" field.
  43449. func (m *WxCardMutation) ResetIntro() {
  43450. m.intro = nil
  43451. delete(m.clearedFields, wxcard.FieldIntro)
  43452. }
  43453. // Where appends a list predicates to the WxCardMutation builder.
  43454. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  43455. m.predicates = append(m.predicates, ps...)
  43456. }
  43457. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  43458. // users can use type-assertion to append predicates that do not depend on any generated package.
  43459. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  43460. p := make([]predicate.WxCard, len(ps))
  43461. for i := range ps {
  43462. p[i] = ps[i]
  43463. }
  43464. m.Where(p...)
  43465. }
  43466. // Op returns the operation name.
  43467. func (m *WxCardMutation) Op() Op {
  43468. return m.op
  43469. }
  43470. // SetOp allows setting the mutation operation.
  43471. func (m *WxCardMutation) SetOp(op Op) {
  43472. m.op = op
  43473. }
  43474. // Type returns the node type of this mutation (WxCard).
  43475. func (m *WxCardMutation) Type() string {
  43476. return m.typ
  43477. }
  43478. // Fields returns all fields that were changed during this mutation. Note that in
  43479. // order to get all numeric fields that were incremented/decremented, call
  43480. // AddedFields().
  43481. func (m *WxCardMutation) Fields() []string {
  43482. fields := make([]string, 0, 18)
  43483. if m.created_at != nil {
  43484. fields = append(fields, wxcard.FieldCreatedAt)
  43485. }
  43486. if m.updated_at != nil {
  43487. fields = append(fields, wxcard.FieldUpdatedAt)
  43488. }
  43489. if m.deleted_at != nil {
  43490. fields = append(fields, wxcard.FieldDeletedAt)
  43491. }
  43492. if m.user_id != nil {
  43493. fields = append(fields, wxcard.FieldUserID)
  43494. }
  43495. if m.wx_user_id != nil {
  43496. fields = append(fields, wxcard.FieldWxUserID)
  43497. }
  43498. if m.avatar != nil {
  43499. fields = append(fields, wxcard.FieldAvatar)
  43500. }
  43501. if m.logo != nil {
  43502. fields = append(fields, wxcard.FieldLogo)
  43503. }
  43504. if m.name != nil {
  43505. fields = append(fields, wxcard.FieldName)
  43506. }
  43507. if m.company != nil {
  43508. fields = append(fields, wxcard.FieldCompany)
  43509. }
  43510. if m.address != nil {
  43511. fields = append(fields, wxcard.FieldAddress)
  43512. }
  43513. if m.phone != nil {
  43514. fields = append(fields, wxcard.FieldPhone)
  43515. }
  43516. if m.official_account != nil {
  43517. fields = append(fields, wxcard.FieldOfficialAccount)
  43518. }
  43519. if m.wechat_account != nil {
  43520. fields = append(fields, wxcard.FieldWechatAccount)
  43521. }
  43522. if m.email != nil {
  43523. fields = append(fields, wxcard.FieldEmail)
  43524. }
  43525. if m.api_base != nil {
  43526. fields = append(fields, wxcard.FieldAPIBase)
  43527. }
  43528. if m.api_key != nil {
  43529. fields = append(fields, wxcard.FieldAPIKey)
  43530. }
  43531. if m.ai_info != nil {
  43532. fields = append(fields, wxcard.FieldAiInfo)
  43533. }
  43534. if m.intro != nil {
  43535. fields = append(fields, wxcard.FieldIntro)
  43536. }
  43537. return fields
  43538. }
  43539. // Field returns the value of a field with the given name. The second boolean
  43540. // return value indicates that this field was not set, or was not defined in the
  43541. // schema.
  43542. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  43543. switch name {
  43544. case wxcard.FieldCreatedAt:
  43545. return m.CreatedAt()
  43546. case wxcard.FieldUpdatedAt:
  43547. return m.UpdatedAt()
  43548. case wxcard.FieldDeletedAt:
  43549. return m.DeletedAt()
  43550. case wxcard.FieldUserID:
  43551. return m.UserID()
  43552. case wxcard.FieldWxUserID:
  43553. return m.WxUserID()
  43554. case wxcard.FieldAvatar:
  43555. return m.Avatar()
  43556. case wxcard.FieldLogo:
  43557. return m.Logo()
  43558. case wxcard.FieldName:
  43559. return m.Name()
  43560. case wxcard.FieldCompany:
  43561. return m.Company()
  43562. case wxcard.FieldAddress:
  43563. return m.Address()
  43564. case wxcard.FieldPhone:
  43565. return m.Phone()
  43566. case wxcard.FieldOfficialAccount:
  43567. return m.OfficialAccount()
  43568. case wxcard.FieldWechatAccount:
  43569. return m.WechatAccount()
  43570. case wxcard.FieldEmail:
  43571. return m.Email()
  43572. case wxcard.FieldAPIBase:
  43573. return m.APIBase()
  43574. case wxcard.FieldAPIKey:
  43575. return m.APIKey()
  43576. case wxcard.FieldAiInfo:
  43577. return m.AiInfo()
  43578. case wxcard.FieldIntro:
  43579. return m.Intro()
  43580. }
  43581. return nil, false
  43582. }
  43583. // OldField returns the old value of the field from the database. An error is
  43584. // returned if the mutation operation is not UpdateOne, or the query to the
  43585. // database failed.
  43586. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43587. switch name {
  43588. case wxcard.FieldCreatedAt:
  43589. return m.OldCreatedAt(ctx)
  43590. case wxcard.FieldUpdatedAt:
  43591. return m.OldUpdatedAt(ctx)
  43592. case wxcard.FieldDeletedAt:
  43593. return m.OldDeletedAt(ctx)
  43594. case wxcard.FieldUserID:
  43595. return m.OldUserID(ctx)
  43596. case wxcard.FieldWxUserID:
  43597. return m.OldWxUserID(ctx)
  43598. case wxcard.FieldAvatar:
  43599. return m.OldAvatar(ctx)
  43600. case wxcard.FieldLogo:
  43601. return m.OldLogo(ctx)
  43602. case wxcard.FieldName:
  43603. return m.OldName(ctx)
  43604. case wxcard.FieldCompany:
  43605. return m.OldCompany(ctx)
  43606. case wxcard.FieldAddress:
  43607. return m.OldAddress(ctx)
  43608. case wxcard.FieldPhone:
  43609. return m.OldPhone(ctx)
  43610. case wxcard.FieldOfficialAccount:
  43611. return m.OldOfficialAccount(ctx)
  43612. case wxcard.FieldWechatAccount:
  43613. return m.OldWechatAccount(ctx)
  43614. case wxcard.FieldEmail:
  43615. return m.OldEmail(ctx)
  43616. case wxcard.FieldAPIBase:
  43617. return m.OldAPIBase(ctx)
  43618. case wxcard.FieldAPIKey:
  43619. return m.OldAPIKey(ctx)
  43620. case wxcard.FieldAiInfo:
  43621. return m.OldAiInfo(ctx)
  43622. case wxcard.FieldIntro:
  43623. return m.OldIntro(ctx)
  43624. }
  43625. return nil, fmt.Errorf("unknown WxCard field %s", name)
  43626. }
  43627. // SetField sets the value of a field with the given name. It returns an error if
  43628. // the field is not defined in the schema, or if the type mismatched the field
  43629. // type.
  43630. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  43631. switch name {
  43632. case wxcard.FieldCreatedAt:
  43633. v, ok := value.(time.Time)
  43634. if !ok {
  43635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43636. }
  43637. m.SetCreatedAt(v)
  43638. return nil
  43639. case wxcard.FieldUpdatedAt:
  43640. v, ok := value.(time.Time)
  43641. if !ok {
  43642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43643. }
  43644. m.SetUpdatedAt(v)
  43645. return nil
  43646. case wxcard.FieldDeletedAt:
  43647. v, ok := value.(time.Time)
  43648. if !ok {
  43649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43650. }
  43651. m.SetDeletedAt(v)
  43652. return nil
  43653. case wxcard.FieldUserID:
  43654. v, ok := value.(uint64)
  43655. if !ok {
  43656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43657. }
  43658. m.SetUserID(v)
  43659. return nil
  43660. case wxcard.FieldWxUserID:
  43661. v, ok := value.(uint64)
  43662. if !ok {
  43663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43664. }
  43665. m.SetWxUserID(v)
  43666. return nil
  43667. case wxcard.FieldAvatar:
  43668. v, ok := value.(string)
  43669. if !ok {
  43670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43671. }
  43672. m.SetAvatar(v)
  43673. return nil
  43674. case wxcard.FieldLogo:
  43675. v, ok := value.(string)
  43676. if !ok {
  43677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43678. }
  43679. m.SetLogo(v)
  43680. return nil
  43681. case wxcard.FieldName:
  43682. v, ok := value.(string)
  43683. if !ok {
  43684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43685. }
  43686. m.SetName(v)
  43687. return nil
  43688. case wxcard.FieldCompany:
  43689. v, ok := value.(string)
  43690. if !ok {
  43691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43692. }
  43693. m.SetCompany(v)
  43694. return nil
  43695. case wxcard.FieldAddress:
  43696. v, ok := value.(string)
  43697. if !ok {
  43698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43699. }
  43700. m.SetAddress(v)
  43701. return nil
  43702. case wxcard.FieldPhone:
  43703. v, ok := value.(string)
  43704. if !ok {
  43705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43706. }
  43707. m.SetPhone(v)
  43708. return nil
  43709. case wxcard.FieldOfficialAccount:
  43710. v, ok := value.(string)
  43711. if !ok {
  43712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43713. }
  43714. m.SetOfficialAccount(v)
  43715. return nil
  43716. case wxcard.FieldWechatAccount:
  43717. v, ok := value.(string)
  43718. if !ok {
  43719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43720. }
  43721. m.SetWechatAccount(v)
  43722. return nil
  43723. case wxcard.FieldEmail:
  43724. v, ok := value.(string)
  43725. if !ok {
  43726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43727. }
  43728. m.SetEmail(v)
  43729. return nil
  43730. case wxcard.FieldAPIBase:
  43731. v, ok := value.(string)
  43732. if !ok {
  43733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43734. }
  43735. m.SetAPIBase(v)
  43736. return nil
  43737. case wxcard.FieldAPIKey:
  43738. v, ok := value.(string)
  43739. if !ok {
  43740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43741. }
  43742. m.SetAPIKey(v)
  43743. return nil
  43744. case wxcard.FieldAiInfo:
  43745. v, ok := value.(string)
  43746. if !ok {
  43747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43748. }
  43749. m.SetAiInfo(v)
  43750. return nil
  43751. case wxcard.FieldIntro:
  43752. v, ok := value.(string)
  43753. if !ok {
  43754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43755. }
  43756. m.SetIntro(v)
  43757. return nil
  43758. }
  43759. return fmt.Errorf("unknown WxCard field %s", name)
  43760. }
  43761. // AddedFields returns all numeric fields that were incremented/decremented during
  43762. // this mutation.
  43763. func (m *WxCardMutation) AddedFields() []string {
  43764. var fields []string
  43765. if m.adduser_id != nil {
  43766. fields = append(fields, wxcard.FieldUserID)
  43767. }
  43768. if m.addwx_user_id != nil {
  43769. fields = append(fields, wxcard.FieldWxUserID)
  43770. }
  43771. return fields
  43772. }
  43773. // AddedField returns the numeric value that was incremented/decremented on a field
  43774. // with the given name. The second boolean return value indicates that this field
  43775. // was not set, or was not defined in the schema.
  43776. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  43777. switch name {
  43778. case wxcard.FieldUserID:
  43779. return m.AddedUserID()
  43780. case wxcard.FieldWxUserID:
  43781. return m.AddedWxUserID()
  43782. }
  43783. return nil, false
  43784. }
  43785. // AddField adds the value to the field with the given name. It returns an error if
  43786. // the field is not defined in the schema, or if the type mismatched the field
  43787. // type.
  43788. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  43789. switch name {
  43790. case wxcard.FieldUserID:
  43791. v, ok := value.(int64)
  43792. if !ok {
  43793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43794. }
  43795. m.AddUserID(v)
  43796. return nil
  43797. case wxcard.FieldWxUserID:
  43798. v, ok := value.(int64)
  43799. if !ok {
  43800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43801. }
  43802. m.AddWxUserID(v)
  43803. return nil
  43804. }
  43805. return fmt.Errorf("unknown WxCard numeric field %s", name)
  43806. }
  43807. // ClearedFields returns all nullable fields that were cleared during this
  43808. // mutation.
  43809. func (m *WxCardMutation) ClearedFields() []string {
  43810. var fields []string
  43811. if m.FieldCleared(wxcard.FieldDeletedAt) {
  43812. fields = append(fields, wxcard.FieldDeletedAt)
  43813. }
  43814. if m.FieldCleared(wxcard.FieldUserID) {
  43815. fields = append(fields, wxcard.FieldUserID)
  43816. }
  43817. if m.FieldCleared(wxcard.FieldWxUserID) {
  43818. fields = append(fields, wxcard.FieldWxUserID)
  43819. }
  43820. if m.FieldCleared(wxcard.FieldEmail) {
  43821. fields = append(fields, wxcard.FieldEmail)
  43822. }
  43823. if m.FieldCleared(wxcard.FieldAPIBase) {
  43824. fields = append(fields, wxcard.FieldAPIBase)
  43825. }
  43826. if m.FieldCleared(wxcard.FieldAPIKey) {
  43827. fields = append(fields, wxcard.FieldAPIKey)
  43828. }
  43829. if m.FieldCleared(wxcard.FieldAiInfo) {
  43830. fields = append(fields, wxcard.FieldAiInfo)
  43831. }
  43832. if m.FieldCleared(wxcard.FieldIntro) {
  43833. fields = append(fields, wxcard.FieldIntro)
  43834. }
  43835. return fields
  43836. }
  43837. // FieldCleared returns a boolean indicating if a field with the given name was
  43838. // cleared in this mutation.
  43839. func (m *WxCardMutation) FieldCleared(name string) bool {
  43840. _, ok := m.clearedFields[name]
  43841. return ok
  43842. }
  43843. // ClearField clears the value of the field with the given name. It returns an
  43844. // error if the field is not defined in the schema.
  43845. func (m *WxCardMutation) ClearField(name string) error {
  43846. switch name {
  43847. case wxcard.FieldDeletedAt:
  43848. m.ClearDeletedAt()
  43849. return nil
  43850. case wxcard.FieldUserID:
  43851. m.ClearUserID()
  43852. return nil
  43853. case wxcard.FieldWxUserID:
  43854. m.ClearWxUserID()
  43855. return nil
  43856. case wxcard.FieldEmail:
  43857. m.ClearEmail()
  43858. return nil
  43859. case wxcard.FieldAPIBase:
  43860. m.ClearAPIBase()
  43861. return nil
  43862. case wxcard.FieldAPIKey:
  43863. m.ClearAPIKey()
  43864. return nil
  43865. case wxcard.FieldAiInfo:
  43866. m.ClearAiInfo()
  43867. return nil
  43868. case wxcard.FieldIntro:
  43869. m.ClearIntro()
  43870. return nil
  43871. }
  43872. return fmt.Errorf("unknown WxCard nullable field %s", name)
  43873. }
  43874. // ResetField resets all changes in the mutation for the field with the given name.
  43875. // It returns an error if the field is not defined in the schema.
  43876. func (m *WxCardMutation) ResetField(name string) error {
  43877. switch name {
  43878. case wxcard.FieldCreatedAt:
  43879. m.ResetCreatedAt()
  43880. return nil
  43881. case wxcard.FieldUpdatedAt:
  43882. m.ResetUpdatedAt()
  43883. return nil
  43884. case wxcard.FieldDeletedAt:
  43885. m.ResetDeletedAt()
  43886. return nil
  43887. case wxcard.FieldUserID:
  43888. m.ResetUserID()
  43889. return nil
  43890. case wxcard.FieldWxUserID:
  43891. m.ResetWxUserID()
  43892. return nil
  43893. case wxcard.FieldAvatar:
  43894. m.ResetAvatar()
  43895. return nil
  43896. case wxcard.FieldLogo:
  43897. m.ResetLogo()
  43898. return nil
  43899. case wxcard.FieldName:
  43900. m.ResetName()
  43901. return nil
  43902. case wxcard.FieldCompany:
  43903. m.ResetCompany()
  43904. return nil
  43905. case wxcard.FieldAddress:
  43906. m.ResetAddress()
  43907. return nil
  43908. case wxcard.FieldPhone:
  43909. m.ResetPhone()
  43910. return nil
  43911. case wxcard.FieldOfficialAccount:
  43912. m.ResetOfficialAccount()
  43913. return nil
  43914. case wxcard.FieldWechatAccount:
  43915. m.ResetWechatAccount()
  43916. return nil
  43917. case wxcard.FieldEmail:
  43918. m.ResetEmail()
  43919. return nil
  43920. case wxcard.FieldAPIBase:
  43921. m.ResetAPIBase()
  43922. return nil
  43923. case wxcard.FieldAPIKey:
  43924. m.ResetAPIKey()
  43925. return nil
  43926. case wxcard.FieldAiInfo:
  43927. m.ResetAiInfo()
  43928. return nil
  43929. case wxcard.FieldIntro:
  43930. m.ResetIntro()
  43931. return nil
  43932. }
  43933. return fmt.Errorf("unknown WxCard field %s", name)
  43934. }
  43935. // AddedEdges returns all edge names that were set/added in this mutation.
  43936. func (m *WxCardMutation) AddedEdges() []string {
  43937. edges := make([]string, 0, 0)
  43938. return edges
  43939. }
  43940. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43941. // name in this mutation.
  43942. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  43943. return nil
  43944. }
  43945. // RemovedEdges returns all edge names that were removed in this mutation.
  43946. func (m *WxCardMutation) RemovedEdges() []string {
  43947. edges := make([]string, 0, 0)
  43948. return edges
  43949. }
  43950. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43951. // the given name in this mutation.
  43952. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  43953. return nil
  43954. }
  43955. // ClearedEdges returns all edge names that were cleared in this mutation.
  43956. func (m *WxCardMutation) ClearedEdges() []string {
  43957. edges := make([]string, 0, 0)
  43958. return edges
  43959. }
  43960. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43961. // was cleared in this mutation.
  43962. func (m *WxCardMutation) EdgeCleared(name string) bool {
  43963. return false
  43964. }
  43965. // ClearEdge clears the value of the edge with the given name. It returns an error
  43966. // if that edge is not defined in the schema.
  43967. func (m *WxCardMutation) ClearEdge(name string) error {
  43968. return fmt.Errorf("unknown WxCard unique edge %s", name)
  43969. }
  43970. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43971. // It returns an error if the edge is not defined in the schema.
  43972. func (m *WxCardMutation) ResetEdge(name string) error {
  43973. return fmt.Errorf("unknown WxCard edge %s", name)
  43974. }
  43975. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  43976. type WxCardUserMutation struct {
  43977. config
  43978. op Op
  43979. typ string
  43980. id *uint64
  43981. created_at *time.Time
  43982. updated_at *time.Time
  43983. deleted_at *time.Time
  43984. wxid *string
  43985. account *string
  43986. avatar *string
  43987. nickname *string
  43988. remark *string
  43989. phone *string
  43990. open_id *string
  43991. union_id *string
  43992. session_key *string
  43993. is_vip *int
  43994. addis_vip *int
  43995. clearedFields map[string]struct{}
  43996. done bool
  43997. oldValue func(context.Context) (*WxCardUser, error)
  43998. predicates []predicate.WxCardUser
  43999. }
  44000. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  44001. // wxcarduserOption allows management of the mutation configuration using functional options.
  44002. type wxcarduserOption func(*WxCardUserMutation)
  44003. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  44004. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  44005. m := &WxCardUserMutation{
  44006. config: c,
  44007. op: op,
  44008. typ: TypeWxCardUser,
  44009. clearedFields: make(map[string]struct{}),
  44010. }
  44011. for _, opt := range opts {
  44012. opt(m)
  44013. }
  44014. return m
  44015. }
  44016. // withWxCardUserID sets the ID field of the mutation.
  44017. func withWxCardUserID(id uint64) wxcarduserOption {
  44018. return func(m *WxCardUserMutation) {
  44019. var (
  44020. err error
  44021. once sync.Once
  44022. value *WxCardUser
  44023. )
  44024. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  44025. once.Do(func() {
  44026. if m.done {
  44027. err = errors.New("querying old values post mutation is not allowed")
  44028. } else {
  44029. value, err = m.Client().WxCardUser.Get(ctx, id)
  44030. }
  44031. })
  44032. return value, err
  44033. }
  44034. m.id = &id
  44035. }
  44036. }
  44037. // withWxCardUser sets the old WxCardUser of the mutation.
  44038. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  44039. return func(m *WxCardUserMutation) {
  44040. m.oldValue = func(context.Context) (*WxCardUser, error) {
  44041. return node, nil
  44042. }
  44043. m.id = &node.ID
  44044. }
  44045. }
  44046. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44047. // executed in a transaction (ent.Tx), a transactional client is returned.
  44048. func (m WxCardUserMutation) Client() *Client {
  44049. client := &Client{config: m.config}
  44050. client.init()
  44051. return client
  44052. }
  44053. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44054. // it returns an error otherwise.
  44055. func (m WxCardUserMutation) Tx() (*Tx, error) {
  44056. if _, ok := m.driver.(*txDriver); !ok {
  44057. return nil, errors.New("ent: mutation is not running in a transaction")
  44058. }
  44059. tx := &Tx{config: m.config}
  44060. tx.init()
  44061. return tx, nil
  44062. }
  44063. // SetID sets the value of the id field. Note that this
  44064. // operation is only accepted on creation of WxCardUser entities.
  44065. func (m *WxCardUserMutation) SetID(id uint64) {
  44066. m.id = &id
  44067. }
  44068. // ID returns the ID value in the mutation. Note that the ID is only available
  44069. // if it was provided to the builder or after it was returned from the database.
  44070. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  44071. if m.id == nil {
  44072. return
  44073. }
  44074. return *m.id, true
  44075. }
  44076. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44077. // That means, if the mutation is applied within a transaction with an isolation level such
  44078. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44079. // or updated by the mutation.
  44080. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  44081. switch {
  44082. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44083. id, exists := m.ID()
  44084. if exists {
  44085. return []uint64{id}, nil
  44086. }
  44087. fallthrough
  44088. case m.op.Is(OpUpdate | OpDelete):
  44089. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  44090. default:
  44091. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44092. }
  44093. }
  44094. // SetCreatedAt sets the "created_at" field.
  44095. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  44096. m.created_at = &t
  44097. }
  44098. // CreatedAt returns the value of the "created_at" field in the mutation.
  44099. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  44100. v := m.created_at
  44101. if v == nil {
  44102. return
  44103. }
  44104. return *v, true
  44105. }
  44106. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  44107. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44109. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44110. if !m.op.Is(OpUpdateOne) {
  44111. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44112. }
  44113. if m.id == nil || m.oldValue == nil {
  44114. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44115. }
  44116. oldValue, err := m.oldValue(ctx)
  44117. if err != nil {
  44118. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44119. }
  44120. return oldValue.CreatedAt, nil
  44121. }
  44122. // ResetCreatedAt resets all changes to the "created_at" field.
  44123. func (m *WxCardUserMutation) ResetCreatedAt() {
  44124. m.created_at = nil
  44125. }
  44126. // SetUpdatedAt sets the "updated_at" field.
  44127. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  44128. m.updated_at = &t
  44129. }
  44130. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44131. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  44132. v := m.updated_at
  44133. if v == nil {
  44134. return
  44135. }
  44136. return *v, true
  44137. }
  44138. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  44139. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44141. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44142. if !m.op.Is(OpUpdateOne) {
  44143. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44144. }
  44145. if m.id == nil || m.oldValue == nil {
  44146. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44147. }
  44148. oldValue, err := m.oldValue(ctx)
  44149. if err != nil {
  44150. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44151. }
  44152. return oldValue.UpdatedAt, nil
  44153. }
  44154. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44155. func (m *WxCardUserMutation) ResetUpdatedAt() {
  44156. m.updated_at = nil
  44157. }
  44158. // SetDeletedAt sets the "deleted_at" field.
  44159. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  44160. m.deleted_at = &t
  44161. }
  44162. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44163. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  44164. v := m.deleted_at
  44165. if v == nil {
  44166. return
  44167. }
  44168. return *v, true
  44169. }
  44170. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  44171. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44173. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44174. if !m.op.Is(OpUpdateOne) {
  44175. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44176. }
  44177. if m.id == nil || m.oldValue == nil {
  44178. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44179. }
  44180. oldValue, err := m.oldValue(ctx)
  44181. if err != nil {
  44182. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44183. }
  44184. return oldValue.DeletedAt, nil
  44185. }
  44186. // ClearDeletedAt clears the value of the "deleted_at" field.
  44187. func (m *WxCardUserMutation) ClearDeletedAt() {
  44188. m.deleted_at = nil
  44189. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  44190. }
  44191. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44192. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  44193. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  44194. return ok
  44195. }
  44196. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44197. func (m *WxCardUserMutation) ResetDeletedAt() {
  44198. m.deleted_at = nil
  44199. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  44200. }
  44201. // SetWxid sets the "wxid" field.
  44202. func (m *WxCardUserMutation) SetWxid(s string) {
  44203. m.wxid = &s
  44204. }
  44205. // Wxid returns the value of the "wxid" field in the mutation.
  44206. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  44207. v := m.wxid
  44208. if v == nil {
  44209. return
  44210. }
  44211. return *v, true
  44212. }
  44213. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  44214. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44216. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  44217. if !m.op.Is(OpUpdateOne) {
  44218. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  44219. }
  44220. if m.id == nil || m.oldValue == nil {
  44221. return v, errors.New("OldWxid requires an ID field in the mutation")
  44222. }
  44223. oldValue, err := m.oldValue(ctx)
  44224. if err != nil {
  44225. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  44226. }
  44227. return oldValue.Wxid, nil
  44228. }
  44229. // ResetWxid resets all changes to the "wxid" field.
  44230. func (m *WxCardUserMutation) ResetWxid() {
  44231. m.wxid = nil
  44232. }
  44233. // SetAccount sets the "account" field.
  44234. func (m *WxCardUserMutation) SetAccount(s string) {
  44235. m.account = &s
  44236. }
  44237. // Account returns the value of the "account" field in the mutation.
  44238. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  44239. v := m.account
  44240. if v == nil {
  44241. return
  44242. }
  44243. return *v, true
  44244. }
  44245. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  44246. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44248. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  44249. if !m.op.Is(OpUpdateOne) {
  44250. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  44251. }
  44252. if m.id == nil || m.oldValue == nil {
  44253. return v, errors.New("OldAccount requires an ID field in the mutation")
  44254. }
  44255. oldValue, err := m.oldValue(ctx)
  44256. if err != nil {
  44257. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  44258. }
  44259. return oldValue.Account, nil
  44260. }
  44261. // ResetAccount resets all changes to the "account" field.
  44262. func (m *WxCardUserMutation) ResetAccount() {
  44263. m.account = nil
  44264. }
  44265. // SetAvatar sets the "avatar" field.
  44266. func (m *WxCardUserMutation) SetAvatar(s string) {
  44267. m.avatar = &s
  44268. }
  44269. // Avatar returns the value of the "avatar" field in the mutation.
  44270. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  44271. v := m.avatar
  44272. if v == nil {
  44273. return
  44274. }
  44275. return *v, true
  44276. }
  44277. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  44278. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44280. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44281. if !m.op.Is(OpUpdateOne) {
  44282. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44283. }
  44284. if m.id == nil || m.oldValue == nil {
  44285. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44286. }
  44287. oldValue, err := m.oldValue(ctx)
  44288. if err != nil {
  44289. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44290. }
  44291. return oldValue.Avatar, nil
  44292. }
  44293. // ResetAvatar resets all changes to the "avatar" field.
  44294. func (m *WxCardUserMutation) ResetAvatar() {
  44295. m.avatar = nil
  44296. }
  44297. // SetNickname sets the "nickname" field.
  44298. func (m *WxCardUserMutation) SetNickname(s string) {
  44299. m.nickname = &s
  44300. }
  44301. // Nickname returns the value of the "nickname" field in the mutation.
  44302. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  44303. v := m.nickname
  44304. if v == nil {
  44305. return
  44306. }
  44307. return *v, true
  44308. }
  44309. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  44310. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44312. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  44313. if !m.op.Is(OpUpdateOne) {
  44314. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44315. }
  44316. if m.id == nil || m.oldValue == nil {
  44317. return v, errors.New("OldNickname requires an ID field in the mutation")
  44318. }
  44319. oldValue, err := m.oldValue(ctx)
  44320. if err != nil {
  44321. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44322. }
  44323. return oldValue.Nickname, nil
  44324. }
  44325. // ResetNickname resets all changes to the "nickname" field.
  44326. func (m *WxCardUserMutation) ResetNickname() {
  44327. m.nickname = nil
  44328. }
  44329. // SetRemark sets the "remark" field.
  44330. func (m *WxCardUserMutation) SetRemark(s string) {
  44331. m.remark = &s
  44332. }
  44333. // Remark returns the value of the "remark" field in the mutation.
  44334. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  44335. v := m.remark
  44336. if v == nil {
  44337. return
  44338. }
  44339. return *v, true
  44340. }
  44341. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  44342. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44344. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  44345. if !m.op.Is(OpUpdateOne) {
  44346. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  44347. }
  44348. if m.id == nil || m.oldValue == nil {
  44349. return v, errors.New("OldRemark requires an ID field in the mutation")
  44350. }
  44351. oldValue, err := m.oldValue(ctx)
  44352. if err != nil {
  44353. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  44354. }
  44355. return oldValue.Remark, nil
  44356. }
  44357. // ResetRemark resets all changes to the "remark" field.
  44358. func (m *WxCardUserMutation) ResetRemark() {
  44359. m.remark = nil
  44360. }
  44361. // SetPhone sets the "phone" field.
  44362. func (m *WxCardUserMutation) SetPhone(s string) {
  44363. m.phone = &s
  44364. }
  44365. // Phone returns the value of the "phone" field in the mutation.
  44366. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  44367. v := m.phone
  44368. if v == nil {
  44369. return
  44370. }
  44371. return *v, true
  44372. }
  44373. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  44374. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44376. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  44377. if !m.op.Is(OpUpdateOne) {
  44378. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  44379. }
  44380. if m.id == nil || m.oldValue == nil {
  44381. return v, errors.New("OldPhone requires an ID field in the mutation")
  44382. }
  44383. oldValue, err := m.oldValue(ctx)
  44384. if err != nil {
  44385. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  44386. }
  44387. return oldValue.Phone, nil
  44388. }
  44389. // ResetPhone resets all changes to the "phone" field.
  44390. func (m *WxCardUserMutation) ResetPhone() {
  44391. m.phone = nil
  44392. }
  44393. // SetOpenID sets the "open_id" field.
  44394. func (m *WxCardUserMutation) SetOpenID(s string) {
  44395. m.open_id = &s
  44396. }
  44397. // OpenID returns the value of the "open_id" field in the mutation.
  44398. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  44399. v := m.open_id
  44400. if v == nil {
  44401. return
  44402. }
  44403. return *v, true
  44404. }
  44405. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  44406. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44408. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  44409. if !m.op.Is(OpUpdateOne) {
  44410. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  44411. }
  44412. if m.id == nil || m.oldValue == nil {
  44413. return v, errors.New("OldOpenID requires an ID field in the mutation")
  44414. }
  44415. oldValue, err := m.oldValue(ctx)
  44416. if err != nil {
  44417. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  44418. }
  44419. return oldValue.OpenID, nil
  44420. }
  44421. // ResetOpenID resets all changes to the "open_id" field.
  44422. func (m *WxCardUserMutation) ResetOpenID() {
  44423. m.open_id = nil
  44424. }
  44425. // SetUnionID sets the "union_id" field.
  44426. func (m *WxCardUserMutation) SetUnionID(s string) {
  44427. m.union_id = &s
  44428. }
  44429. // UnionID returns the value of the "union_id" field in the mutation.
  44430. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  44431. v := m.union_id
  44432. if v == nil {
  44433. return
  44434. }
  44435. return *v, true
  44436. }
  44437. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  44438. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44440. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  44441. if !m.op.Is(OpUpdateOne) {
  44442. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  44443. }
  44444. if m.id == nil || m.oldValue == nil {
  44445. return v, errors.New("OldUnionID requires an ID field in the mutation")
  44446. }
  44447. oldValue, err := m.oldValue(ctx)
  44448. if err != nil {
  44449. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  44450. }
  44451. return oldValue.UnionID, nil
  44452. }
  44453. // ResetUnionID resets all changes to the "union_id" field.
  44454. func (m *WxCardUserMutation) ResetUnionID() {
  44455. m.union_id = nil
  44456. }
  44457. // SetSessionKey sets the "session_key" field.
  44458. func (m *WxCardUserMutation) SetSessionKey(s string) {
  44459. m.session_key = &s
  44460. }
  44461. // SessionKey returns the value of the "session_key" field in the mutation.
  44462. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  44463. v := m.session_key
  44464. if v == nil {
  44465. return
  44466. }
  44467. return *v, true
  44468. }
  44469. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  44470. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44472. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  44473. if !m.op.Is(OpUpdateOne) {
  44474. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  44475. }
  44476. if m.id == nil || m.oldValue == nil {
  44477. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  44478. }
  44479. oldValue, err := m.oldValue(ctx)
  44480. if err != nil {
  44481. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  44482. }
  44483. return oldValue.SessionKey, nil
  44484. }
  44485. // ResetSessionKey resets all changes to the "session_key" field.
  44486. func (m *WxCardUserMutation) ResetSessionKey() {
  44487. m.session_key = nil
  44488. }
  44489. // SetIsVip sets the "is_vip" field.
  44490. func (m *WxCardUserMutation) SetIsVip(i int) {
  44491. m.is_vip = &i
  44492. m.addis_vip = nil
  44493. }
  44494. // IsVip returns the value of the "is_vip" field in the mutation.
  44495. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  44496. v := m.is_vip
  44497. if v == nil {
  44498. return
  44499. }
  44500. return *v, true
  44501. }
  44502. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  44503. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44505. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  44506. if !m.op.Is(OpUpdateOne) {
  44507. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  44508. }
  44509. if m.id == nil || m.oldValue == nil {
  44510. return v, errors.New("OldIsVip requires an ID field in the mutation")
  44511. }
  44512. oldValue, err := m.oldValue(ctx)
  44513. if err != nil {
  44514. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  44515. }
  44516. return oldValue.IsVip, nil
  44517. }
  44518. // AddIsVip adds i to the "is_vip" field.
  44519. func (m *WxCardUserMutation) AddIsVip(i int) {
  44520. if m.addis_vip != nil {
  44521. *m.addis_vip += i
  44522. } else {
  44523. m.addis_vip = &i
  44524. }
  44525. }
  44526. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  44527. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  44528. v := m.addis_vip
  44529. if v == nil {
  44530. return
  44531. }
  44532. return *v, true
  44533. }
  44534. // ResetIsVip resets all changes to the "is_vip" field.
  44535. func (m *WxCardUserMutation) ResetIsVip() {
  44536. m.is_vip = nil
  44537. m.addis_vip = nil
  44538. }
  44539. // Where appends a list predicates to the WxCardUserMutation builder.
  44540. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  44541. m.predicates = append(m.predicates, ps...)
  44542. }
  44543. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  44544. // users can use type-assertion to append predicates that do not depend on any generated package.
  44545. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  44546. p := make([]predicate.WxCardUser, len(ps))
  44547. for i := range ps {
  44548. p[i] = ps[i]
  44549. }
  44550. m.Where(p...)
  44551. }
  44552. // Op returns the operation name.
  44553. func (m *WxCardUserMutation) Op() Op {
  44554. return m.op
  44555. }
  44556. // SetOp allows setting the mutation operation.
  44557. func (m *WxCardUserMutation) SetOp(op Op) {
  44558. m.op = op
  44559. }
  44560. // Type returns the node type of this mutation (WxCardUser).
  44561. func (m *WxCardUserMutation) Type() string {
  44562. return m.typ
  44563. }
  44564. // Fields returns all fields that were changed during this mutation. Note that in
  44565. // order to get all numeric fields that were incremented/decremented, call
  44566. // AddedFields().
  44567. func (m *WxCardUserMutation) Fields() []string {
  44568. fields := make([]string, 0, 13)
  44569. if m.created_at != nil {
  44570. fields = append(fields, wxcarduser.FieldCreatedAt)
  44571. }
  44572. if m.updated_at != nil {
  44573. fields = append(fields, wxcarduser.FieldUpdatedAt)
  44574. }
  44575. if m.deleted_at != nil {
  44576. fields = append(fields, wxcarduser.FieldDeletedAt)
  44577. }
  44578. if m.wxid != nil {
  44579. fields = append(fields, wxcarduser.FieldWxid)
  44580. }
  44581. if m.account != nil {
  44582. fields = append(fields, wxcarduser.FieldAccount)
  44583. }
  44584. if m.avatar != nil {
  44585. fields = append(fields, wxcarduser.FieldAvatar)
  44586. }
  44587. if m.nickname != nil {
  44588. fields = append(fields, wxcarduser.FieldNickname)
  44589. }
  44590. if m.remark != nil {
  44591. fields = append(fields, wxcarduser.FieldRemark)
  44592. }
  44593. if m.phone != nil {
  44594. fields = append(fields, wxcarduser.FieldPhone)
  44595. }
  44596. if m.open_id != nil {
  44597. fields = append(fields, wxcarduser.FieldOpenID)
  44598. }
  44599. if m.union_id != nil {
  44600. fields = append(fields, wxcarduser.FieldUnionID)
  44601. }
  44602. if m.session_key != nil {
  44603. fields = append(fields, wxcarduser.FieldSessionKey)
  44604. }
  44605. if m.is_vip != nil {
  44606. fields = append(fields, wxcarduser.FieldIsVip)
  44607. }
  44608. return fields
  44609. }
  44610. // Field returns the value of a field with the given name. The second boolean
  44611. // return value indicates that this field was not set, or was not defined in the
  44612. // schema.
  44613. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  44614. switch name {
  44615. case wxcarduser.FieldCreatedAt:
  44616. return m.CreatedAt()
  44617. case wxcarduser.FieldUpdatedAt:
  44618. return m.UpdatedAt()
  44619. case wxcarduser.FieldDeletedAt:
  44620. return m.DeletedAt()
  44621. case wxcarduser.FieldWxid:
  44622. return m.Wxid()
  44623. case wxcarduser.FieldAccount:
  44624. return m.Account()
  44625. case wxcarduser.FieldAvatar:
  44626. return m.Avatar()
  44627. case wxcarduser.FieldNickname:
  44628. return m.Nickname()
  44629. case wxcarduser.FieldRemark:
  44630. return m.Remark()
  44631. case wxcarduser.FieldPhone:
  44632. return m.Phone()
  44633. case wxcarduser.FieldOpenID:
  44634. return m.OpenID()
  44635. case wxcarduser.FieldUnionID:
  44636. return m.UnionID()
  44637. case wxcarduser.FieldSessionKey:
  44638. return m.SessionKey()
  44639. case wxcarduser.FieldIsVip:
  44640. return m.IsVip()
  44641. }
  44642. return nil, false
  44643. }
  44644. // OldField returns the old value of the field from the database. An error is
  44645. // returned if the mutation operation is not UpdateOne, or the query to the
  44646. // database failed.
  44647. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44648. switch name {
  44649. case wxcarduser.FieldCreatedAt:
  44650. return m.OldCreatedAt(ctx)
  44651. case wxcarduser.FieldUpdatedAt:
  44652. return m.OldUpdatedAt(ctx)
  44653. case wxcarduser.FieldDeletedAt:
  44654. return m.OldDeletedAt(ctx)
  44655. case wxcarduser.FieldWxid:
  44656. return m.OldWxid(ctx)
  44657. case wxcarduser.FieldAccount:
  44658. return m.OldAccount(ctx)
  44659. case wxcarduser.FieldAvatar:
  44660. return m.OldAvatar(ctx)
  44661. case wxcarduser.FieldNickname:
  44662. return m.OldNickname(ctx)
  44663. case wxcarduser.FieldRemark:
  44664. return m.OldRemark(ctx)
  44665. case wxcarduser.FieldPhone:
  44666. return m.OldPhone(ctx)
  44667. case wxcarduser.FieldOpenID:
  44668. return m.OldOpenID(ctx)
  44669. case wxcarduser.FieldUnionID:
  44670. return m.OldUnionID(ctx)
  44671. case wxcarduser.FieldSessionKey:
  44672. return m.OldSessionKey(ctx)
  44673. case wxcarduser.FieldIsVip:
  44674. return m.OldIsVip(ctx)
  44675. }
  44676. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  44677. }
  44678. // SetField sets the value of a field with the given name. It returns an error if
  44679. // the field is not defined in the schema, or if the type mismatched the field
  44680. // type.
  44681. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  44682. switch name {
  44683. case wxcarduser.FieldCreatedAt:
  44684. v, ok := value.(time.Time)
  44685. if !ok {
  44686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44687. }
  44688. m.SetCreatedAt(v)
  44689. return nil
  44690. case wxcarduser.FieldUpdatedAt:
  44691. v, ok := value.(time.Time)
  44692. if !ok {
  44693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44694. }
  44695. m.SetUpdatedAt(v)
  44696. return nil
  44697. case wxcarduser.FieldDeletedAt:
  44698. v, ok := value.(time.Time)
  44699. if !ok {
  44700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44701. }
  44702. m.SetDeletedAt(v)
  44703. return nil
  44704. case wxcarduser.FieldWxid:
  44705. v, ok := value.(string)
  44706. if !ok {
  44707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44708. }
  44709. m.SetWxid(v)
  44710. return nil
  44711. case wxcarduser.FieldAccount:
  44712. v, ok := value.(string)
  44713. if !ok {
  44714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44715. }
  44716. m.SetAccount(v)
  44717. return nil
  44718. case wxcarduser.FieldAvatar:
  44719. v, ok := value.(string)
  44720. if !ok {
  44721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44722. }
  44723. m.SetAvatar(v)
  44724. return nil
  44725. case wxcarduser.FieldNickname:
  44726. v, ok := value.(string)
  44727. if !ok {
  44728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44729. }
  44730. m.SetNickname(v)
  44731. return nil
  44732. case wxcarduser.FieldRemark:
  44733. v, ok := value.(string)
  44734. if !ok {
  44735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44736. }
  44737. m.SetRemark(v)
  44738. return nil
  44739. case wxcarduser.FieldPhone:
  44740. v, ok := value.(string)
  44741. if !ok {
  44742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44743. }
  44744. m.SetPhone(v)
  44745. return nil
  44746. case wxcarduser.FieldOpenID:
  44747. v, ok := value.(string)
  44748. if !ok {
  44749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44750. }
  44751. m.SetOpenID(v)
  44752. return nil
  44753. case wxcarduser.FieldUnionID:
  44754. v, ok := value.(string)
  44755. if !ok {
  44756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44757. }
  44758. m.SetUnionID(v)
  44759. return nil
  44760. case wxcarduser.FieldSessionKey:
  44761. v, ok := value.(string)
  44762. if !ok {
  44763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44764. }
  44765. m.SetSessionKey(v)
  44766. return nil
  44767. case wxcarduser.FieldIsVip:
  44768. v, ok := value.(int)
  44769. if !ok {
  44770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44771. }
  44772. m.SetIsVip(v)
  44773. return nil
  44774. }
  44775. return fmt.Errorf("unknown WxCardUser field %s", name)
  44776. }
  44777. // AddedFields returns all numeric fields that were incremented/decremented during
  44778. // this mutation.
  44779. func (m *WxCardUserMutation) AddedFields() []string {
  44780. var fields []string
  44781. if m.addis_vip != nil {
  44782. fields = append(fields, wxcarduser.FieldIsVip)
  44783. }
  44784. return fields
  44785. }
  44786. // AddedField returns the numeric value that was incremented/decremented on a field
  44787. // with the given name. The second boolean return value indicates that this field
  44788. // was not set, or was not defined in the schema.
  44789. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  44790. switch name {
  44791. case wxcarduser.FieldIsVip:
  44792. return m.AddedIsVip()
  44793. }
  44794. return nil, false
  44795. }
  44796. // AddField adds the value to the field with the given name. It returns an error if
  44797. // the field is not defined in the schema, or if the type mismatched the field
  44798. // type.
  44799. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  44800. switch name {
  44801. case wxcarduser.FieldIsVip:
  44802. v, ok := value.(int)
  44803. if !ok {
  44804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44805. }
  44806. m.AddIsVip(v)
  44807. return nil
  44808. }
  44809. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  44810. }
  44811. // ClearedFields returns all nullable fields that were cleared during this
  44812. // mutation.
  44813. func (m *WxCardUserMutation) ClearedFields() []string {
  44814. var fields []string
  44815. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  44816. fields = append(fields, wxcarduser.FieldDeletedAt)
  44817. }
  44818. return fields
  44819. }
  44820. // FieldCleared returns a boolean indicating if a field with the given name was
  44821. // cleared in this mutation.
  44822. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  44823. _, ok := m.clearedFields[name]
  44824. return ok
  44825. }
  44826. // ClearField clears the value of the field with the given name. It returns an
  44827. // error if the field is not defined in the schema.
  44828. func (m *WxCardUserMutation) ClearField(name string) error {
  44829. switch name {
  44830. case wxcarduser.FieldDeletedAt:
  44831. m.ClearDeletedAt()
  44832. return nil
  44833. }
  44834. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  44835. }
  44836. // ResetField resets all changes in the mutation for the field with the given name.
  44837. // It returns an error if the field is not defined in the schema.
  44838. func (m *WxCardUserMutation) ResetField(name string) error {
  44839. switch name {
  44840. case wxcarduser.FieldCreatedAt:
  44841. m.ResetCreatedAt()
  44842. return nil
  44843. case wxcarduser.FieldUpdatedAt:
  44844. m.ResetUpdatedAt()
  44845. return nil
  44846. case wxcarduser.FieldDeletedAt:
  44847. m.ResetDeletedAt()
  44848. return nil
  44849. case wxcarduser.FieldWxid:
  44850. m.ResetWxid()
  44851. return nil
  44852. case wxcarduser.FieldAccount:
  44853. m.ResetAccount()
  44854. return nil
  44855. case wxcarduser.FieldAvatar:
  44856. m.ResetAvatar()
  44857. return nil
  44858. case wxcarduser.FieldNickname:
  44859. m.ResetNickname()
  44860. return nil
  44861. case wxcarduser.FieldRemark:
  44862. m.ResetRemark()
  44863. return nil
  44864. case wxcarduser.FieldPhone:
  44865. m.ResetPhone()
  44866. return nil
  44867. case wxcarduser.FieldOpenID:
  44868. m.ResetOpenID()
  44869. return nil
  44870. case wxcarduser.FieldUnionID:
  44871. m.ResetUnionID()
  44872. return nil
  44873. case wxcarduser.FieldSessionKey:
  44874. m.ResetSessionKey()
  44875. return nil
  44876. case wxcarduser.FieldIsVip:
  44877. m.ResetIsVip()
  44878. return nil
  44879. }
  44880. return fmt.Errorf("unknown WxCardUser field %s", name)
  44881. }
  44882. // AddedEdges returns all edge names that were set/added in this mutation.
  44883. func (m *WxCardUserMutation) AddedEdges() []string {
  44884. edges := make([]string, 0, 0)
  44885. return edges
  44886. }
  44887. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44888. // name in this mutation.
  44889. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  44890. return nil
  44891. }
  44892. // RemovedEdges returns all edge names that were removed in this mutation.
  44893. func (m *WxCardUserMutation) RemovedEdges() []string {
  44894. edges := make([]string, 0, 0)
  44895. return edges
  44896. }
  44897. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44898. // the given name in this mutation.
  44899. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  44900. return nil
  44901. }
  44902. // ClearedEdges returns all edge names that were cleared in this mutation.
  44903. func (m *WxCardUserMutation) ClearedEdges() []string {
  44904. edges := make([]string, 0, 0)
  44905. return edges
  44906. }
  44907. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44908. // was cleared in this mutation.
  44909. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  44910. return false
  44911. }
  44912. // ClearEdge clears the value of the edge with the given name. It returns an error
  44913. // if that edge is not defined in the schema.
  44914. func (m *WxCardUserMutation) ClearEdge(name string) error {
  44915. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  44916. }
  44917. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44918. // It returns an error if the edge is not defined in the schema.
  44919. func (m *WxCardUserMutation) ResetEdge(name string) error {
  44920. return fmt.Errorf("unknown WxCardUser edge %s", name)
  44921. }
  44922. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  44923. type WxCardVisitMutation struct {
  44924. config
  44925. op Op
  44926. typ string
  44927. id *uint64
  44928. created_at *time.Time
  44929. updated_at *time.Time
  44930. deleted_at *time.Time
  44931. user_id *uint64
  44932. adduser_id *int64
  44933. bot_id *uint64
  44934. addbot_id *int64
  44935. bot_type *uint8
  44936. addbot_type *int8
  44937. clearedFields map[string]struct{}
  44938. done bool
  44939. oldValue func(context.Context) (*WxCardVisit, error)
  44940. predicates []predicate.WxCardVisit
  44941. }
  44942. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  44943. // wxcardvisitOption allows management of the mutation configuration using functional options.
  44944. type wxcardvisitOption func(*WxCardVisitMutation)
  44945. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  44946. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  44947. m := &WxCardVisitMutation{
  44948. config: c,
  44949. op: op,
  44950. typ: TypeWxCardVisit,
  44951. clearedFields: make(map[string]struct{}),
  44952. }
  44953. for _, opt := range opts {
  44954. opt(m)
  44955. }
  44956. return m
  44957. }
  44958. // withWxCardVisitID sets the ID field of the mutation.
  44959. func withWxCardVisitID(id uint64) wxcardvisitOption {
  44960. return func(m *WxCardVisitMutation) {
  44961. var (
  44962. err error
  44963. once sync.Once
  44964. value *WxCardVisit
  44965. )
  44966. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  44967. once.Do(func() {
  44968. if m.done {
  44969. err = errors.New("querying old values post mutation is not allowed")
  44970. } else {
  44971. value, err = m.Client().WxCardVisit.Get(ctx, id)
  44972. }
  44973. })
  44974. return value, err
  44975. }
  44976. m.id = &id
  44977. }
  44978. }
  44979. // withWxCardVisit sets the old WxCardVisit of the mutation.
  44980. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  44981. return func(m *WxCardVisitMutation) {
  44982. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  44983. return node, nil
  44984. }
  44985. m.id = &node.ID
  44986. }
  44987. }
  44988. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44989. // executed in a transaction (ent.Tx), a transactional client is returned.
  44990. func (m WxCardVisitMutation) Client() *Client {
  44991. client := &Client{config: m.config}
  44992. client.init()
  44993. return client
  44994. }
  44995. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44996. // it returns an error otherwise.
  44997. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  44998. if _, ok := m.driver.(*txDriver); !ok {
  44999. return nil, errors.New("ent: mutation is not running in a transaction")
  45000. }
  45001. tx := &Tx{config: m.config}
  45002. tx.init()
  45003. return tx, nil
  45004. }
  45005. // SetID sets the value of the id field. Note that this
  45006. // operation is only accepted on creation of WxCardVisit entities.
  45007. func (m *WxCardVisitMutation) SetID(id uint64) {
  45008. m.id = &id
  45009. }
  45010. // ID returns the ID value in the mutation. Note that the ID is only available
  45011. // if it was provided to the builder or after it was returned from the database.
  45012. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  45013. if m.id == nil {
  45014. return
  45015. }
  45016. return *m.id, true
  45017. }
  45018. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45019. // That means, if the mutation is applied within a transaction with an isolation level such
  45020. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45021. // or updated by the mutation.
  45022. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  45023. switch {
  45024. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45025. id, exists := m.ID()
  45026. if exists {
  45027. return []uint64{id}, nil
  45028. }
  45029. fallthrough
  45030. case m.op.Is(OpUpdate | OpDelete):
  45031. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  45032. default:
  45033. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45034. }
  45035. }
  45036. // SetCreatedAt sets the "created_at" field.
  45037. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  45038. m.created_at = &t
  45039. }
  45040. // CreatedAt returns the value of the "created_at" field in the mutation.
  45041. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  45042. v := m.created_at
  45043. if v == nil {
  45044. return
  45045. }
  45046. return *v, true
  45047. }
  45048. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  45049. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45051. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45052. if !m.op.Is(OpUpdateOne) {
  45053. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45054. }
  45055. if m.id == nil || m.oldValue == nil {
  45056. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45057. }
  45058. oldValue, err := m.oldValue(ctx)
  45059. if err != nil {
  45060. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45061. }
  45062. return oldValue.CreatedAt, nil
  45063. }
  45064. // ResetCreatedAt resets all changes to the "created_at" field.
  45065. func (m *WxCardVisitMutation) ResetCreatedAt() {
  45066. m.created_at = nil
  45067. }
  45068. // SetUpdatedAt sets the "updated_at" field.
  45069. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  45070. m.updated_at = &t
  45071. }
  45072. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45073. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  45074. v := m.updated_at
  45075. if v == nil {
  45076. return
  45077. }
  45078. return *v, true
  45079. }
  45080. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  45081. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45083. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45084. if !m.op.Is(OpUpdateOne) {
  45085. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45086. }
  45087. if m.id == nil || m.oldValue == nil {
  45088. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45089. }
  45090. oldValue, err := m.oldValue(ctx)
  45091. if err != nil {
  45092. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45093. }
  45094. return oldValue.UpdatedAt, nil
  45095. }
  45096. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45097. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  45098. m.updated_at = nil
  45099. }
  45100. // SetDeletedAt sets the "deleted_at" field.
  45101. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  45102. m.deleted_at = &t
  45103. }
  45104. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45105. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  45106. v := m.deleted_at
  45107. if v == nil {
  45108. return
  45109. }
  45110. return *v, true
  45111. }
  45112. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  45113. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45115. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45116. if !m.op.Is(OpUpdateOne) {
  45117. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45118. }
  45119. if m.id == nil || m.oldValue == nil {
  45120. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45121. }
  45122. oldValue, err := m.oldValue(ctx)
  45123. if err != nil {
  45124. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45125. }
  45126. return oldValue.DeletedAt, nil
  45127. }
  45128. // ClearDeletedAt clears the value of the "deleted_at" field.
  45129. func (m *WxCardVisitMutation) ClearDeletedAt() {
  45130. m.deleted_at = nil
  45131. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  45132. }
  45133. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45134. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  45135. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  45136. return ok
  45137. }
  45138. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45139. func (m *WxCardVisitMutation) ResetDeletedAt() {
  45140. m.deleted_at = nil
  45141. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  45142. }
  45143. // SetUserID sets the "user_id" field.
  45144. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  45145. m.user_id = &u
  45146. m.adduser_id = nil
  45147. }
  45148. // UserID returns the value of the "user_id" field in the mutation.
  45149. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  45150. v := m.user_id
  45151. if v == nil {
  45152. return
  45153. }
  45154. return *v, true
  45155. }
  45156. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  45157. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45159. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  45160. if !m.op.Is(OpUpdateOne) {
  45161. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  45162. }
  45163. if m.id == nil || m.oldValue == nil {
  45164. return v, errors.New("OldUserID requires an ID field in the mutation")
  45165. }
  45166. oldValue, err := m.oldValue(ctx)
  45167. if err != nil {
  45168. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  45169. }
  45170. return oldValue.UserID, nil
  45171. }
  45172. // AddUserID adds u to the "user_id" field.
  45173. func (m *WxCardVisitMutation) AddUserID(u int64) {
  45174. if m.adduser_id != nil {
  45175. *m.adduser_id += u
  45176. } else {
  45177. m.adduser_id = &u
  45178. }
  45179. }
  45180. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  45181. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  45182. v := m.adduser_id
  45183. if v == nil {
  45184. return
  45185. }
  45186. return *v, true
  45187. }
  45188. // ClearUserID clears the value of the "user_id" field.
  45189. func (m *WxCardVisitMutation) ClearUserID() {
  45190. m.user_id = nil
  45191. m.adduser_id = nil
  45192. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  45193. }
  45194. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  45195. func (m *WxCardVisitMutation) UserIDCleared() bool {
  45196. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  45197. return ok
  45198. }
  45199. // ResetUserID resets all changes to the "user_id" field.
  45200. func (m *WxCardVisitMutation) ResetUserID() {
  45201. m.user_id = nil
  45202. m.adduser_id = nil
  45203. delete(m.clearedFields, wxcardvisit.FieldUserID)
  45204. }
  45205. // SetBotID sets the "bot_id" field.
  45206. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  45207. m.bot_id = &u
  45208. m.addbot_id = nil
  45209. }
  45210. // BotID returns the value of the "bot_id" field in the mutation.
  45211. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  45212. v := m.bot_id
  45213. if v == nil {
  45214. return
  45215. }
  45216. return *v, true
  45217. }
  45218. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  45219. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45221. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  45222. if !m.op.Is(OpUpdateOne) {
  45223. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  45224. }
  45225. if m.id == nil || m.oldValue == nil {
  45226. return v, errors.New("OldBotID requires an ID field in the mutation")
  45227. }
  45228. oldValue, err := m.oldValue(ctx)
  45229. if err != nil {
  45230. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  45231. }
  45232. return oldValue.BotID, nil
  45233. }
  45234. // AddBotID adds u to the "bot_id" field.
  45235. func (m *WxCardVisitMutation) AddBotID(u int64) {
  45236. if m.addbot_id != nil {
  45237. *m.addbot_id += u
  45238. } else {
  45239. m.addbot_id = &u
  45240. }
  45241. }
  45242. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  45243. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  45244. v := m.addbot_id
  45245. if v == nil {
  45246. return
  45247. }
  45248. return *v, true
  45249. }
  45250. // ResetBotID resets all changes to the "bot_id" field.
  45251. func (m *WxCardVisitMutation) ResetBotID() {
  45252. m.bot_id = nil
  45253. m.addbot_id = nil
  45254. }
  45255. // SetBotType sets the "bot_type" field.
  45256. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  45257. m.bot_type = &u
  45258. m.addbot_type = nil
  45259. }
  45260. // BotType returns the value of the "bot_type" field in the mutation.
  45261. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  45262. v := m.bot_type
  45263. if v == nil {
  45264. return
  45265. }
  45266. return *v, true
  45267. }
  45268. // OldBotType returns the old "bot_type" 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) OldBotType(ctx context.Context) (v uint8, err error) {
  45272. if !m.op.Is(OpUpdateOne) {
  45273. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  45274. }
  45275. if m.id == nil || m.oldValue == nil {
  45276. return v, errors.New("OldBotType 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 OldBotType: %w", err)
  45281. }
  45282. return oldValue.BotType, nil
  45283. }
  45284. // AddBotType adds u to the "bot_type" field.
  45285. func (m *WxCardVisitMutation) AddBotType(u int8) {
  45286. if m.addbot_type != nil {
  45287. *m.addbot_type += u
  45288. } else {
  45289. m.addbot_type = &u
  45290. }
  45291. }
  45292. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  45293. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  45294. v := m.addbot_type
  45295. if v == nil {
  45296. return
  45297. }
  45298. return *v, true
  45299. }
  45300. // ResetBotType resets all changes to the "bot_type" field.
  45301. func (m *WxCardVisitMutation) ResetBotType() {
  45302. m.bot_type = nil
  45303. m.addbot_type = nil
  45304. }
  45305. // Where appends a list predicates to the WxCardVisitMutation builder.
  45306. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  45307. m.predicates = append(m.predicates, ps...)
  45308. }
  45309. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  45310. // users can use type-assertion to append predicates that do not depend on any generated package.
  45311. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  45312. p := make([]predicate.WxCardVisit, len(ps))
  45313. for i := range ps {
  45314. p[i] = ps[i]
  45315. }
  45316. m.Where(p...)
  45317. }
  45318. // Op returns the operation name.
  45319. func (m *WxCardVisitMutation) Op() Op {
  45320. return m.op
  45321. }
  45322. // SetOp allows setting the mutation operation.
  45323. func (m *WxCardVisitMutation) SetOp(op Op) {
  45324. m.op = op
  45325. }
  45326. // Type returns the node type of this mutation (WxCardVisit).
  45327. func (m *WxCardVisitMutation) Type() string {
  45328. return m.typ
  45329. }
  45330. // Fields returns all fields that were changed during this mutation. Note that in
  45331. // order to get all numeric fields that were incremented/decremented, call
  45332. // AddedFields().
  45333. func (m *WxCardVisitMutation) Fields() []string {
  45334. fields := make([]string, 0, 6)
  45335. if m.created_at != nil {
  45336. fields = append(fields, wxcardvisit.FieldCreatedAt)
  45337. }
  45338. if m.updated_at != nil {
  45339. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  45340. }
  45341. if m.deleted_at != nil {
  45342. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45343. }
  45344. if m.user_id != nil {
  45345. fields = append(fields, wxcardvisit.FieldUserID)
  45346. }
  45347. if m.bot_id != nil {
  45348. fields = append(fields, wxcardvisit.FieldBotID)
  45349. }
  45350. if m.bot_type != nil {
  45351. fields = append(fields, wxcardvisit.FieldBotType)
  45352. }
  45353. return fields
  45354. }
  45355. // Field returns the value of a field with the given name. The second boolean
  45356. // return value indicates that this field was not set, or was not defined in the
  45357. // schema.
  45358. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  45359. switch name {
  45360. case wxcardvisit.FieldCreatedAt:
  45361. return m.CreatedAt()
  45362. case wxcardvisit.FieldUpdatedAt:
  45363. return m.UpdatedAt()
  45364. case wxcardvisit.FieldDeletedAt:
  45365. return m.DeletedAt()
  45366. case wxcardvisit.FieldUserID:
  45367. return m.UserID()
  45368. case wxcardvisit.FieldBotID:
  45369. return m.BotID()
  45370. case wxcardvisit.FieldBotType:
  45371. return m.BotType()
  45372. }
  45373. return nil, false
  45374. }
  45375. // OldField returns the old value of the field from the database. An error is
  45376. // returned if the mutation operation is not UpdateOne, or the query to the
  45377. // database failed.
  45378. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45379. switch name {
  45380. case wxcardvisit.FieldCreatedAt:
  45381. return m.OldCreatedAt(ctx)
  45382. case wxcardvisit.FieldUpdatedAt:
  45383. return m.OldUpdatedAt(ctx)
  45384. case wxcardvisit.FieldDeletedAt:
  45385. return m.OldDeletedAt(ctx)
  45386. case wxcardvisit.FieldUserID:
  45387. return m.OldUserID(ctx)
  45388. case wxcardvisit.FieldBotID:
  45389. return m.OldBotID(ctx)
  45390. case wxcardvisit.FieldBotType:
  45391. return m.OldBotType(ctx)
  45392. }
  45393. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  45394. }
  45395. // SetField sets the value of a field with the given name. It returns an error if
  45396. // the field is not defined in the schema, or if the type mismatched the field
  45397. // type.
  45398. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  45399. switch name {
  45400. case wxcardvisit.FieldCreatedAt:
  45401. v, ok := value.(time.Time)
  45402. if !ok {
  45403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45404. }
  45405. m.SetCreatedAt(v)
  45406. return nil
  45407. case wxcardvisit.FieldUpdatedAt:
  45408. v, ok := value.(time.Time)
  45409. if !ok {
  45410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45411. }
  45412. m.SetUpdatedAt(v)
  45413. return nil
  45414. case wxcardvisit.FieldDeletedAt:
  45415. v, ok := value.(time.Time)
  45416. if !ok {
  45417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45418. }
  45419. m.SetDeletedAt(v)
  45420. return nil
  45421. case wxcardvisit.FieldUserID:
  45422. v, ok := value.(uint64)
  45423. if !ok {
  45424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45425. }
  45426. m.SetUserID(v)
  45427. return nil
  45428. case wxcardvisit.FieldBotID:
  45429. v, ok := value.(uint64)
  45430. if !ok {
  45431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45432. }
  45433. m.SetBotID(v)
  45434. return nil
  45435. case wxcardvisit.FieldBotType:
  45436. v, ok := value.(uint8)
  45437. if !ok {
  45438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45439. }
  45440. m.SetBotType(v)
  45441. return nil
  45442. }
  45443. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45444. }
  45445. // AddedFields returns all numeric fields that were incremented/decremented during
  45446. // this mutation.
  45447. func (m *WxCardVisitMutation) AddedFields() []string {
  45448. var fields []string
  45449. if m.adduser_id != nil {
  45450. fields = append(fields, wxcardvisit.FieldUserID)
  45451. }
  45452. if m.addbot_id != nil {
  45453. fields = append(fields, wxcardvisit.FieldBotID)
  45454. }
  45455. if m.addbot_type != nil {
  45456. fields = append(fields, wxcardvisit.FieldBotType)
  45457. }
  45458. return fields
  45459. }
  45460. // AddedField returns the numeric value that was incremented/decremented on a field
  45461. // with the given name. The second boolean return value indicates that this field
  45462. // was not set, or was not defined in the schema.
  45463. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  45464. switch name {
  45465. case wxcardvisit.FieldUserID:
  45466. return m.AddedUserID()
  45467. case wxcardvisit.FieldBotID:
  45468. return m.AddedBotID()
  45469. case wxcardvisit.FieldBotType:
  45470. return m.AddedBotType()
  45471. }
  45472. return nil, false
  45473. }
  45474. // AddField adds the value to the field with the given name. It returns an error if
  45475. // the field is not defined in the schema, or if the type mismatched the field
  45476. // type.
  45477. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  45478. switch name {
  45479. case wxcardvisit.FieldUserID:
  45480. v, ok := value.(int64)
  45481. if !ok {
  45482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45483. }
  45484. m.AddUserID(v)
  45485. return nil
  45486. case wxcardvisit.FieldBotID:
  45487. v, ok := value.(int64)
  45488. if !ok {
  45489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45490. }
  45491. m.AddBotID(v)
  45492. return nil
  45493. case wxcardvisit.FieldBotType:
  45494. v, ok := value.(int8)
  45495. if !ok {
  45496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45497. }
  45498. m.AddBotType(v)
  45499. return nil
  45500. }
  45501. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  45502. }
  45503. // ClearedFields returns all nullable fields that were cleared during this
  45504. // mutation.
  45505. func (m *WxCardVisitMutation) ClearedFields() []string {
  45506. var fields []string
  45507. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  45508. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45509. }
  45510. if m.FieldCleared(wxcardvisit.FieldUserID) {
  45511. fields = append(fields, wxcardvisit.FieldUserID)
  45512. }
  45513. return fields
  45514. }
  45515. // FieldCleared returns a boolean indicating if a field with the given name was
  45516. // cleared in this mutation.
  45517. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  45518. _, ok := m.clearedFields[name]
  45519. return ok
  45520. }
  45521. // ClearField clears the value of the field with the given name. It returns an
  45522. // error if the field is not defined in the schema.
  45523. func (m *WxCardVisitMutation) ClearField(name string) error {
  45524. switch name {
  45525. case wxcardvisit.FieldDeletedAt:
  45526. m.ClearDeletedAt()
  45527. return nil
  45528. case wxcardvisit.FieldUserID:
  45529. m.ClearUserID()
  45530. return nil
  45531. }
  45532. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  45533. }
  45534. // ResetField resets all changes in the mutation for the field with the given name.
  45535. // It returns an error if the field is not defined in the schema.
  45536. func (m *WxCardVisitMutation) ResetField(name string) error {
  45537. switch name {
  45538. case wxcardvisit.FieldCreatedAt:
  45539. m.ResetCreatedAt()
  45540. return nil
  45541. case wxcardvisit.FieldUpdatedAt:
  45542. m.ResetUpdatedAt()
  45543. return nil
  45544. case wxcardvisit.FieldDeletedAt:
  45545. m.ResetDeletedAt()
  45546. return nil
  45547. case wxcardvisit.FieldUserID:
  45548. m.ResetUserID()
  45549. return nil
  45550. case wxcardvisit.FieldBotID:
  45551. m.ResetBotID()
  45552. return nil
  45553. case wxcardvisit.FieldBotType:
  45554. m.ResetBotType()
  45555. return nil
  45556. }
  45557. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45558. }
  45559. // AddedEdges returns all edge names that were set/added in this mutation.
  45560. func (m *WxCardVisitMutation) AddedEdges() []string {
  45561. edges := make([]string, 0, 0)
  45562. return edges
  45563. }
  45564. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45565. // name in this mutation.
  45566. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  45567. return nil
  45568. }
  45569. // RemovedEdges returns all edge names that were removed in this mutation.
  45570. func (m *WxCardVisitMutation) RemovedEdges() []string {
  45571. edges := make([]string, 0, 0)
  45572. return edges
  45573. }
  45574. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45575. // the given name in this mutation.
  45576. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  45577. return nil
  45578. }
  45579. // ClearedEdges returns all edge names that were cleared in this mutation.
  45580. func (m *WxCardVisitMutation) ClearedEdges() []string {
  45581. edges := make([]string, 0, 0)
  45582. return edges
  45583. }
  45584. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45585. // was cleared in this mutation.
  45586. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  45587. return false
  45588. }
  45589. // ClearEdge clears the value of the edge with the given name. It returns an error
  45590. // if that edge is not defined in the schema.
  45591. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  45592. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  45593. }
  45594. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45595. // It returns an error if the edge is not defined in the schema.
  45596. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  45597. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  45598. }