mutation.go 1.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130
  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/compapijob"
  19. "wechat-api/ent/contact"
  20. "wechat-api/ent/creditbalance"
  21. "wechat-api/ent/creditusage"
  22. "wechat-api/ent/custom_types"
  23. "wechat-api/ent/employee"
  24. "wechat-api/ent/employeeconfig"
  25. "wechat-api/ent/label"
  26. "wechat-api/ent/labelrelationship"
  27. "wechat-api/ent/labeltagging"
  28. "wechat-api/ent/message"
  29. "wechat-api/ent/messagerecords"
  30. "wechat-api/ent/msg"
  31. "wechat-api/ent/payrecharge"
  32. "wechat-api/ent/predicate"
  33. "wechat-api/ent/server"
  34. "wechat-api/ent/sopnode"
  35. "wechat-api/ent/sopstage"
  36. "wechat-api/ent/soptask"
  37. "wechat-api/ent/token"
  38. "wechat-api/ent/tutorial"
  39. "wechat-api/ent/usagedetail"
  40. "wechat-api/ent/usagestatisticday"
  41. "wechat-api/ent/usagestatistichour"
  42. "wechat-api/ent/usagestatisticmonth"
  43. "wechat-api/ent/usagetotal"
  44. "wechat-api/ent/whatsapp"
  45. "wechat-api/ent/whatsappchannel"
  46. "wechat-api/ent/workexperience"
  47. "wechat-api/ent/wpchatroom"
  48. "wechat-api/ent/wpchatroommember"
  49. "wechat-api/ent/wx"
  50. "wechat-api/ent/wxcard"
  51. "wechat-api/ent/wxcarduser"
  52. "wechat-api/ent/wxcardvisit"
  53. "entgo.io/ent"
  54. "entgo.io/ent/dialect/sql"
  55. )
  56. const (
  57. // Operation types.
  58. OpCreate = ent.OpCreate
  59. OpDelete = ent.OpDelete
  60. OpDeleteOne = ent.OpDeleteOne
  61. OpUpdate = ent.OpUpdate
  62. OpUpdateOne = ent.OpUpdateOne
  63. // Node types.
  64. TypeAgent = "Agent"
  65. TypeAgentBase = "AgentBase"
  66. TypeAliyunAvatar = "AliyunAvatar"
  67. TypeAllocAgent = "AllocAgent"
  68. TypeApiKey = "ApiKey"
  69. TypeBatchMsg = "BatchMsg"
  70. TypeCategory = "Category"
  71. TypeChatRecords = "ChatRecords"
  72. TypeChatSession = "ChatSession"
  73. TypeCompapiJob = "CompapiJob"
  74. TypeContact = "Contact"
  75. TypeCreditBalance = "CreditBalance"
  76. TypeCreditUsage = "CreditUsage"
  77. TypeEmployee = "Employee"
  78. TypeEmployeeConfig = "EmployeeConfig"
  79. TypeLabel = "Label"
  80. TypeLabelRelationship = "LabelRelationship"
  81. TypeLabelTagging = "LabelTagging"
  82. TypeMessage = "Message"
  83. TypeMessageRecords = "MessageRecords"
  84. TypeMsg = "Msg"
  85. TypePayRecharge = "PayRecharge"
  86. TypeServer = "Server"
  87. TypeSopNode = "SopNode"
  88. TypeSopStage = "SopStage"
  89. TypeSopTask = "SopTask"
  90. TypeToken = "Token"
  91. TypeTutorial = "Tutorial"
  92. TypeUsageDetail = "UsageDetail"
  93. TypeUsageStatisticDay = "UsageStatisticDay"
  94. TypeUsageStatisticHour = "UsageStatisticHour"
  95. TypeUsageStatisticMonth = "UsageStatisticMonth"
  96. TypeUsageTotal = "UsageTotal"
  97. TypeWhatsapp = "Whatsapp"
  98. TypeWhatsappChannel = "WhatsappChannel"
  99. TypeWorkExperience = "WorkExperience"
  100. TypeWpChatroom = "WpChatroom"
  101. TypeWpChatroomMember = "WpChatroomMember"
  102. TypeWx = "Wx"
  103. TypeWxCard = "WxCard"
  104. TypeWxCardUser = "WxCardUser"
  105. TypeWxCardVisit = "WxCardVisit"
  106. )
  107. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  108. type AgentMutation struct {
  109. config
  110. op Op
  111. typ string
  112. id *uint64
  113. created_at *time.Time
  114. updated_at *time.Time
  115. deleted_at *time.Time
  116. name *string
  117. role *string
  118. status *int
  119. addstatus *int
  120. background *string
  121. examples *string
  122. organization_id *uint64
  123. addorganization_id *int64
  124. dataset_id *string
  125. collection_id *string
  126. clearedFields map[string]struct{}
  127. wx_agent map[uint64]struct{}
  128. removedwx_agent map[uint64]struct{}
  129. clearedwx_agent bool
  130. token_agent map[uint64]struct{}
  131. removedtoken_agent map[uint64]struct{}
  132. clearedtoken_agent bool
  133. wa_agent map[uint64]struct{}
  134. removedwa_agent map[uint64]struct{}
  135. clearedwa_agent bool
  136. key_agent map[uint64]struct{}
  137. removedkey_agent map[uint64]struct{}
  138. clearedkey_agent bool
  139. done bool
  140. oldValue func(context.Context) (*Agent, error)
  141. predicates []predicate.Agent
  142. }
  143. var _ ent.Mutation = (*AgentMutation)(nil)
  144. // agentOption allows management of the mutation configuration using functional options.
  145. type agentOption func(*AgentMutation)
  146. // newAgentMutation creates new mutation for the Agent entity.
  147. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  148. m := &AgentMutation{
  149. config: c,
  150. op: op,
  151. typ: TypeAgent,
  152. clearedFields: make(map[string]struct{}),
  153. }
  154. for _, opt := range opts {
  155. opt(m)
  156. }
  157. return m
  158. }
  159. // withAgentID sets the ID field of the mutation.
  160. func withAgentID(id uint64) agentOption {
  161. return func(m *AgentMutation) {
  162. var (
  163. err error
  164. once sync.Once
  165. value *Agent
  166. )
  167. m.oldValue = func(ctx context.Context) (*Agent, error) {
  168. once.Do(func() {
  169. if m.done {
  170. err = errors.New("querying old values post mutation is not allowed")
  171. } else {
  172. value, err = m.Client().Agent.Get(ctx, id)
  173. }
  174. })
  175. return value, err
  176. }
  177. m.id = &id
  178. }
  179. }
  180. // withAgent sets the old Agent of the mutation.
  181. func withAgent(node *Agent) agentOption {
  182. return func(m *AgentMutation) {
  183. m.oldValue = func(context.Context) (*Agent, error) {
  184. return node, nil
  185. }
  186. m.id = &node.ID
  187. }
  188. }
  189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  190. // executed in a transaction (ent.Tx), a transactional client is returned.
  191. func (m AgentMutation) Client() *Client {
  192. client := &Client{config: m.config}
  193. client.init()
  194. return client
  195. }
  196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  197. // it returns an error otherwise.
  198. func (m AgentMutation) Tx() (*Tx, error) {
  199. if _, ok := m.driver.(*txDriver); !ok {
  200. return nil, errors.New("ent: mutation is not running in a transaction")
  201. }
  202. tx := &Tx{config: m.config}
  203. tx.init()
  204. return tx, nil
  205. }
  206. // SetID sets the value of the id field. Note that this
  207. // operation is only accepted on creation of Agent entities.
  208. func (m *AgentMutation) SetID(id uint64) {
  209. m.id = &id
  210. }
  211. // ID returns the ID value in the mutation. Note that the ID is only available
  212. // if it was provided to the builder or after it was returned from the database.
  213. func (m *AgentMutation) ID() (id uint64, exists bool) {
  214. if m.id == nil {
  215. return
  216. }
  217. return *m.id, true
  218. }
  219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  220. // That means, if the mutation is applied within a transaction with an isolation level such
  221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  222. // or updated by the mutation.
  223. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  224. switch {
  225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  226. id, exists := m.ID()
  227. if exists {
  228. return []uint64{id}, nil
  229. }
  230. fallthrough
  231. case m.op.Is(OpUpdate | OpDelete):
  232. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  233. default:
  234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  235. }
  236. }
  237. // SetCreatedAt sets the "created_at" field.
  238. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  239. m.created_at = &t
  240. }
  241. // CreatedAt returns the value of the "created_at" field in the mutation.
  242. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  243. v := m.created_at
  244. if v == nil {
  245. return
  246. }
  247. return *v, true
  248. }
  249. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  250. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  252. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  253. if !m.op.Is(OpUpdateOne) {
  254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  255. }
  256. if m.id == nil || m.oldValue == nil {
  257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  258. }
  259. oldValue, err := m.oldValue(ctx)
  260. if err != nil {
  261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  262. }
  263. return oldValue.CreatedAt, nil
  264. }
  265. // ResetCreatedAt resets all changes to the "created_at" field.
  266. func (m *AgentMutation) ResetCreatedAt() {
  267. m.created_at = nil
  268. }
  269. // SetUpdatedAt sets the "updated_at" field.
  270. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  271. m.updated_at = &t
  272. }
  273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  274. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  275. v := m.updated_at
  276. if v == nil {
  277. return
  278. }
  279. return *v, true
  280. }
  281. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  282. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  284. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  285. if !m.op.Is(OpUpdateOne) {
  286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  287. }
  288. if m.id == nil || m.oldValue == nil {
  289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  290. }
  291. oldValue, err := m.oldValue(ctx)
  292. if err != nil {
  293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  294. }
  295. return oldValue.UpdatedAt, nil
  296. }
  297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  298. func (m *AgentMutation) ResetUpdatedAt() {
  299. m.updated_at = nil
  300. }
  301. // SetDeletedAt sets the "deleted_at" field.
  302. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  303. m.deleted_at = &t
  304. }
  305. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  306. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  307. v := m.deleted_at
  308. if v == nil {
  309. return
  310. }
  311. return *v, true
  312. }
  313. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  314. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  316. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  317. if !m.op.Is(OpUpdateOne) {
  318. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  319. }
  320. if m.id == nil || m.oldValue == nil {
  321. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  322. }
  323. oldValue, err := m.oldValue(ctx)
  324. if err != nil {
  325. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  326. }
  327. return oldValue.DeletedAt, nil
  328. }
  329. // ClearDeletedAt clears the value of the "deleted_at" field.
  330. func (m *AgentMutation) ClearDeletedAt() {
  331. m.deleted_at = nil
  332. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  333. }
  334. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  335. func (m *AgentMutation) DeletedAtCleared() bool {
  336. _, ok := m.clearedFields[agent.FieldDeletedAt]
  337. return ok
  338. }
  339. // ResetDeletedAt resets all changes to the "deleted_at" field.
  340. func (m *AgentMutation) ResetDeletedAt() {
  341. m.deleted_at = nil
  342. delete(m.clearedFields, agent.FieldDeletedAt)
  343. }
  344. // SetName sets the "name" field.
  345. func (m *AgentMutation) SetName(s string) {
  346. m.name = &s
  347. }
  348. // Name returns the value of the "name" field in the mutation.
  349. func (m *AgentMutation) Name() (r string, exists bool) {
  350. v := m.name
  351. if v == nil {
  352. return
  353. }
  354. return *v, true
  355. }
  356. // OldName returns the old "name" field's value of the Agent entity.
  357. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  359. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  360. if !m.op.Is(OpUpdateOne) {
  361. return v, errors.New("OldName is only allowed on UpdateOne operations")
  362. }
  363. if m.id == nil || m.oldValue == nil {
  364. return v, errors.New("OldName requires an ID field in the mutation")
  365. }
  366. oldValue, err := m.oldValue(ctx)
  367. if err != nil {
  368. return v, fmt.Errorf("querying old value for OldName: %w", err)
  369. }
  370. return oldValue.Name, nil
  371. }
  372. // ResetName resets all changes to the "name" field.
  373. func (m *AgentMutation) ResetName() {
  374. m.name = nil
  375. }
  376. // SetRole sets the "role" field.
  377. func (m *AgentMutation) SetRole(s string) {
  378. m.role = &s
  379. }
  380. // Role returns the value of the "role" field in the mutation.
  381. func (m *AgentMutation) Role() (r string, exists bool) {
  382. v := m.role
  383. if v == nil {
  384. return
  385. }
  386. return *v, true
  387. }
  388. // OldRole returns the old "role" field's value of the Agent entity.
  389. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  391. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  392. if !m.op.Is(OpUpdateOne) {
  393. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  394. }
  395. if m.id == nil || m.oldValue == nil {
  396. return v, errors.New("OldRole requires an ID field in the mutation")
  397. }
  398. oldValue, err := m.oldValue(ctx)
  399. if err != nil {
  400. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  401. }
  402. return oldValue.Role, nil
  403. }
  404. // ResetRole resets all changes to the "role" field.
  405. func (m *AgentMutation) ResetRole() {
  406. m.role = nil
  407. }
  408. // SetStatus sets the "status" field.
  409. func (m *AgentMutation) SetStatus(i int) {
  410. m.status = &i
  411. m.addstatus = nil
  412. }
  413. // Status returns the value of the "status" field in the mutation.
  414. func (m *AgentMutation) Status() (r int, exists bool) {
  415. v := m.status
  416. if v == nil {
  417. return
  418. }
  419. return *v, true
  420. }
  421. // OldStatus returns the old "status" field's value of the Agent entity.
  422. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  424. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  425. if !m.op.Is(OpUpdateOne) {
  426. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  427. }
  428. if m.id == nil || m.oldValue == nil {
  429. return v, errors.New("OldStatus requires an ID field in the mutation")
  430. }
  431. oldValue, err := m.oldValue(ctx)
  432. if err != nil {
  433. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  434. }
  435. return oldValue.Status, nil
  436. }
  437. // AddStatus adds i to the "status" field.
  438. func (m *AgentMutation) AddStatus(i int) {
  439. if m.addstatus != nil {
  440. *m.addstatus += i
  441. } else {
  442. m.addstatus = &i
  443. }
  444. }
  445. // AddedStatus returns the value that was added to the "status" field in this mutation.
  446. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  447. v := m.addstatus
  448. if v == nil {
  449. return
  450. }
  451. return *v, true
  452. }
  453. // ClearStatus clears the value of the "status" field.
  454. func (m *AgentMutation) ClearStatus() {
  455. m.status = nil
  456. m.addstatus = nil
  457. m.clearedFields[agent.FieldStatus] = struct{}{}
  458. }
  459. // StatusCleared returns if the "status" field was cleared in this mutation.
  460. func (m *AgentMutation) StatusCleared() bool {
  461. _, ok := m.clearedFields[agent.FieldStatus]
  462. return ok
  463. }
  464. // ResetStatus resets all changes to the "status" field.
  465. func (m *AgentMutation) ResetStatus() {
  466. m.status = nil
  467. m.addstatus = nil
  468. delete(m.clearedFields, agent.FieldStatus)
  469. }
  470. // SetBackground sets the "background" field.
  471. func (m *AgentMutation) SetBackground(s string) {
  472. m.background = &s
  473. }
  474. // Background returns the value of the "background" field in the mutation.
  475. func (m *AgentMutation) Background() (r string, exists bool) {
  476. v := m.background
  477. if v == nil {
  478. return
  479. }
  480. return *v, true
  481. }
  482. // OldBackground returns the old "background" field's value of the Agent entity.
  483. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  485. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  486. if !m.op.Is(OpUpdateOne) {
  487. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  488. }
  489. if m.id == nil || m.oldValue == nil {
  490. return v, errors.New("OldBackground requires an ID field in the mutation")
  491. }
  492. oldValue, err := m.oldValue(ctx)
  493. if err != nil {
  494. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  495. }
  496. return oldValue.Background, nil
  497. }
  498. // ClearBackground clears the value of the "background" field.
  499. func (m *AgentMutation) ClearBackground() {
  500. m.background = nil
  501. m.clearedFields[agent.FieldBackground] = struct{}{}
  502. }
  503. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  504. func (m *AgentMutation) BackgroundCleared() bool {
  505. _, ok := m.clearedFields[agent.FieldBackground]
  506. return ok
  507. }
  508. // ResetBackground resets all changes to the "background" field.
  509. func (m *AgentMutation) ResetBackground() {
  510. m.background = nil
  511. delete(m.clearedFields, agent.FieldBackground)
  512. }
  513. // SetExamples sets the "examples" field.
  514. func (m *AgentMutation) SetExamples(s string) {
  515. m.examples = &s
  516. }
  517. // Examples returns the value of the "examples" field in the mutation.
  518. func (m *AgentMutation) Examples() (r string, exists bool) {
  519. v := m.examples
  520. if v == nil {
  521. return
  522. }
  523. return *v, true
  524. }
  525. // OldExamples returns the old "examples" field's value of the Agent entity.
  526. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  528. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  529. if !m.op.Is(OpUpdateOne) {
  530. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  531. }
  532. if m.id == nil || m.oldValue == nil {
  533. return v, errors.New("OldExamples requires an ID field in the mutation")
  534. }
  535. oldValue, err := m.oldValue(ctx)
  536. if err != nil {
  537. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  538. }
  539. return oldValue.Examples, nil
  540. }
  541. // ClearExamples clears the value of the "examples" field.
  542. func (m *AgentMutation) ClearExamples() {
  543. m.examples = nil
  544. m.clearedFields[agent.FieldExamples] = struct{}{}
  545. }
  546. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  547. func (m *AgentMutation) ExamplesCleared() bool {
  548. _, ok := m.clearedFields[agent.FieldExamples]
  549. return ok
  550. }
  551. // ResetExamples resets all changes to the "examples" field.
  552. func (m *AgentMutation) ResetExamples() {
  553. m.examples = nil
  554. delete(m.clearedFields, agent.FieldExamples)
  555. }
  556. // SetOrganizationID sets the "organization_id" field.
  557. func (m *AgentMutation) SetOrganizationID(u uint64) {
  558. m.organization_id = &u
  559. m.addorganization_id = nil
  560. }
  561. // OrganizationID returns the value of the "organization_id" field in the mutation.
  562. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  563. v := m.organization_id
  564. if v == nil {
  565. return
  566. }
  567. return *v, true
  568. }
  569. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  570. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  572. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  573. if !m.op.Is(OpUpdateOne) {
  574. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  575. }
  576. if m.id == nil || m.oldValue == nil {
  577. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  578. }
  579. oldValue, err := m.oldValue(ctx)
  580. if err != nil {
  581. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  582. }
  583. return oldValue.OrganizationID, nil
  584. }
  585. // AddOrganizationID adds u to the "organization_id" field.
  586. func (m *AgentMutation) AddOrganizationID(u int64) {
  587. if m.addorganization_id != nil {
  588. *m.addorganization_id += u
  589. } else {
  590. m.addorganization_id = &u
  591. }
  592. }
  593. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  594. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  595. v := m.addorganization_id
  596. if v == nil {
  597. return
  598. }
  599. return *v, true
  600. }
  601. // ResetOrganizationID resets all changes to the "organization_id" field.
  602. func (m *AgentMutation) ResetOrganizationID() {
  603. m.organization_id = nil
  604. m.addorganization_id = nil
  605. }
  606. // SetDatasetID sets the "dataset_id" field.
  607. func (m *AgentMutation) SetDatasetID(s string) {
  608. m.dataset_id = &s
  609. }
  610. // DatasetID returns the value of the "dataset_id" field in the mutation.
  611. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  612. v := m.dataset_id
  613. if v == nil {
  614. return
  615. }
  616. return *v, true
  617. }
  618. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  619. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  621. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  622. if !m.op.Is(OpUpdateOne) {
  623. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  624. }
  625. if m.id == nil || m.oldValue == nil {
  626. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  627. }
  628. oldValue, err := m.oldValue(ctx)
  629. if err != nil {
  630. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  631. }
  632. return oldValue.DatasetID, nil
  633. }
  634. // ResetDatasetID resets all changes to the "dataset_id" field.
  635. func (m *AgentMutation) ResetDatasetID() {
  636. m.dataset_id = nil
  637. }
  638. // SetCollectionID sets the "collection_id" field.
  639. func (m *AgentMutation) SetCollectionID(s string) {
  640. m.collection_id = &s
  641. }
  642. // CollectionID returns the value of the "collection_id" field in the mutation.
  643. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  644. v := m.collection_id
  645. if v == nil {
  646. return
  647. }
  648. return *v, true
  649. }
  650. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  651. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  653. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  654. if !m.op.Is(OpUpdateOne) {
  655. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  656. }
  657. if m.id == nil || m.oldValue == nil {
  658. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  659. }
  660. oldValue, err := m.oldValue(ctx)
  661. if err != nil {
  662. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  663. }
  664. return oldValue.CollectionID, nil
  665. }
  666. // ResetCollectionID resets all changes to the "collection_id" field.
  667. func (m *AgentMutation) ResetCollectionID() {
  668. m.collection_id = nil
  669. }
  670. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  671. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  672. if m.wx_agent == nil {
  673. m.wx_agent = make(map[uint64]struct{})
  674. }
  675. for i := range ids {
  676. m.wx_agent[ids[i]] = struct{}{}
  677. }
  678. }
  679. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  680. func (m *AgentMutation) ClearWxAgent() {
  681. m.clearedwx_agent = true
  682. }
  683. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  684. func (m *AgentMutation) WxAgentCleared() bool {
  685. return m.clearedwx_agent
  686. }
  687. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  688. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  689. if m.removedwx_agent == nil {
  690. m.removedwx_agent = make(map[uint64]struct{})
  691. }
  692. for i := range ids {
  693. delete(m.wx_agent, ids[i])
  694. m.removedwx_agent[ids[i]] = struct{}{}
  695. }
  696. }
  697. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  698. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  699. for id := range m.removedwx_agent {
  700. ids = append(ids, id)
  701. }
  702. return
  703. }
  704. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  705. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  706. for id := range m.wx_agent {
  707. ids = append(ids, id)
  708. }
  709. return
  710. }
  711. // ResetWxAgent resets all changes to the "wx_agent" edge.
  712. func (m *AgentMutation) ResetWxAgent() {
  713. m.wx_agent = nil
  714. m.clearedwx_agent = false
  715. m.removedwx_agent = nil
  716. }
  717. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  718. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  719. if m.token_agent == nil {
  720. m.token_agent = make(map[uint64]struct{})
  721. }
  722. for i := range ids {
  723. m.token_agent[ids[i]] = struct{}{}
  724. }
  725. }
  726. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  727. func (m *AgentMutation) ClearTokenAgent() {
  728. m.clearedtoken_agent = true
  729. }
  730. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  731. func (m *AgentMutation) TokenAgentCleared() bool {
  732. return m.clearedtoken_agent
  733. }
  734. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  735. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  736. if m.removedtoken_agent == nil {
  737. m.removedtoken_agent = make(map[uint64]struct{})
  738. }
  739. for i := range ids {
  740. delete(m.token_agent, ids[i])
  741. m.removedtoken_agent[ids[i]] = struct{}{}
  742. }
  743. }
  744. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  745. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  746. for id := range m.removedtoken_agent {
  747. ids = append(ids, id)
  748. }
  749. return
  750. }
  751. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  752. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  753. for id := range m.token_agent {
  754. ids = append(ids, id)
  755. }
  756. return
  757. }
  758. // ResetTokenAgent resets all changes to the "token_agent" edge.
  759. func (m *AgentMutation) ResetTokenAgent() {
  760. m.token_agent = nil
  761. m.clearedtoken_agent = false
  762. m.removedtoken_agent = nil
  763. }
  764. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  765. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  766. if m.wa_agent == nil {
  767. m.wa_agent = make(map[uint64]struct{})
  768. }
  769. for i := range ids {
  770. m.wa_agent[ids[i]] = struct{}{}
  771. }
  772. }
  773. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  774. func (m *AgentMutation) ClearWaAgent() {
  775. m.clearedwa_agent = true
  776. }
  777. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  778. func (m *AgentMutation) WaAgentCleared() bool {
  779. return m.clearedwa_agent
  780. }
  781. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  782. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  783. if m.removedwa_agent == nil {
  784. m.removedwa_agent = make(map[uint64]struct{})
  785. }
  786. for i := range ids {
  787. delete(m.wa_agent, ids[i])
  788. m.removedwa_agent[ids[i]] = struct{}{}
  789. }
  790. }
  791. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  792. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  793. for id := range m.removedwa_agent {
  794. ids = append(ids, id)
  795. }
  796. return
  797. }
  798. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  799. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  800. for id := range m.wa_agent {
  801. ids = append(ids, id)
  802. }
  803. return
  804. }
  805. // ResetWaAgent resets all changes to the "wa_agent" edge.
  806. func (m *AgentMutation) ResetWaAgent() {
  807. m.wa_agent = nil
  808. m.clearedwa_agent = false
  809. m.removedwa_agent = nil
  810. }
  811. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  812. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  813. if m.key_agent == nil {
  814. m.key_agent = make(map[uint64]struct{})
  815. }
  816. for i := range ids {
  817. m.key_agent[ids[i]] = struct{}{}
  818. }
  819. }
  820. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  821. func (m *AgentMutation) ClearKeyAgent() {
  822. m.clearedkey_agent = true
  823. }
  824. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  825. func (m *AgentMutation) KeyAgentCleared() bool {
  826. return m.clearedkey_agent
  827. }
  828. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  829. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  830. if m.removedkey_agent == nil {
  831. m.removedkey_agent = make(map[uint64]struct{})
  832. }
  833. for i := range ids {
  834. delete(m.key_agent, ids[i])
  835. m.removedkey_agent[ids[i]] = struct{}{}
  836. }
  837. }
  838. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  839. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  840. for id := range m.removedkey_agent {
  841. ids = append(ids, id)
  842. }
  843. return
  844. }
  845. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  846. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  847. for id := range m.key_agent {
  848. ids = append(ids, id)
  849. }
  850. return
  851. }
  852. // ResetKeyAgent resets all changes to the "key_agent" edge.
  853. func (m *AgentMutation) ResetKeyAgent() {
  854. m.key_agent = nil
  855. m.clearedkey_agent = false
  856. m.removedkey_agent = nil
  857. }
  858. // Where appends a list predicates to the AgentMutation builder.
  859. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  860. m.predicates = append(m.predicates, ps...)
  861. }
  862. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  863. // users can use type-assertion to append predicates that do not depend on any generated package.
  864. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  865. p := make([]predicate.Agent, len(ps))
  866. for i := range ps {
  867. p[i] = ps[i]
  868. }
  869. m.Where(p...)
  870. }
  871. // Op returns the operation name.
  872. func (m *AgentMutation) Op() Op {
  873. return m.op
  874. }
  875. // SetOp allows setting the mutation operation.
  876. func (m *AgentMutation) SetOp(op Op) {
  877. m.op = op
  878. }
  879. // Type returns the node type of this mutation (Agent).
  880. func (m *AgentMutation) Type() string {
  881. return m.typ
  882. }
  883. // Fields returns all fields that were changed during this mutation. Note that in
  884. // order to get all numeric fields that were incremented/decremented, call
  885. // AddedFields().
  886. func (m *AgentMutation) Fields() []string {
  887. fields := make([]string, 0, 11)
  888. if m.created_at != nil {
  889. fields = append(fields, agent.FieldCreatedAt)
  890. }
  891. if m.updated_at != nil {
  892. fields = append(fields, agent.FieldUpdatedAt)
  893. }
  894. if m.deleted_at != nil {
  895. fields = append(fields, agent.FieldDeletedAt)
  896. }
  897. if m.name != nil {
  898. fields = append(fields, agent.FieldName)
  899. }
  900. if m.role != nil {
  901. fields = append(fields, agent.FieldRole)
  902. }
  903. if m.status != nil {
  904. fields = append(fields, agent.FieldStatus)
  905. }
  906. if m.background != nil {
  907. fields = append(fields, agent.FieldBackground)
  908. }
  909. if m.examples != nil {
  910. fields = append(fields, agent.FieldExamples)
  911. }
  912. if m.organization_id != nil {
  913. fields = append(fields, agent.FieldOrganizationID)
  914. }
  915. if m.dataset_id != nil {
  916. fields = append(fields, agent.FieldDatasetID)
  917. }
  918. if m.collection_id != nil {
  919. fields = append(fields, agent.FieldCollectionID)
  920. }
  921. return fields
  922. }
  923. // Field returns the value of a field with the given name. The second boolean
  924. // return value indicates that this field was not set, or was not defined in the
  925. // schema.
  926. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  927. switch name {
  928. case agent.FieldCreatedAt:
  929. return m.CreatedAt()
  930. case agent.FieldUpdatedAt:
  931. return m.UpdatedAt()
  932. case agent.FieldDeletedAt:
  933. return m.DeletedAt()
  934. case agent.FieldName:
  935. return m.Name()
  936. case agent.FieldRole:
  937. return m.Role()
  938. case agent.FieldStatus:
  939. return m.Status()
  940. case agent.FieldBackground:
  941. return m.Background()
  942. case agent.FieldExamples:
  943. return m.Examples()
  944. case agent.FieldOrganizationID:
  945. return m.OrganizationID()
  946. case agent.FieldDatasetID:
  947. return m.DatasetID()
  948. case agent.FieldCollectionID:
  949. return m.CollectionID()
  950. }
  951. return nil, false
  952. }
  953. // OldField returns the old value of the field from the database. An error is
  954. // returned if the mutation operation is not UpdateOne, or the query to the
  955. // database failed.
  956. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  957. switch name {
  958. case agent.FieldCreatedAt:
  959. return m.OldCreatedAt(ctx)
  960. case agent.FieldUpdatedAt:
  961. return m.OldUpdatedAt(ctx)
  962. case agent.FieldDeletedAt:
  963. return m.OldDeletedAt(ctx)
  964. case agent.FieldName:
  965. return m.OldName(ctx)
  966. case agent.FieldRole:
  967. return m.OldRole(ctx)
  968. case agent.FieldStatus:
  969. return m.OldStatus(ctx)
  970. case agent.FieldBackground:
  971. return m.OldBackground(ctx)
  972. case agent.FieldExamples:
  973. return m.OldExamples(ctx)
  974. case agent.FieldOrganizationID:
  975. return m.OldOrganizationID(ctx)
  976. case agent.FieldDatasetID:
  977. return m.OldDatasetID(ctx)
  978. case agent.FieldCollectionID:
  979. return m.OldCollectionID(ctx)
  980. }
  981. return nil, fmt.Errorf("unknown Agent field %s", name)
  982. }
  983. // SetField sets the value of a field with the given name. It returns an error if
  984. // the field is not defined in the schema, or if the type mismatched the field
  985. // type.
  986. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  987. switch name {
  988. case agent.FieldCreatedAt:
  989. v, ok := value.(time.Time)
  990. if !ok {
  991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  992. }
  993. m.SetCreatedAt(v)
  994. return nil
  995. case agent.FieldUpdatedAt:
  996. v, ok := value.(time.Time)
  997. if !ok {
  998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  999. }
  1000. m.SetUpdatedAt(v)
  1001. return nil
  1002. case agent.FieldDeletedAt:
  1003. v, ok := value.(time.Time)
  1004. if !ok {
  1005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1006. }
  1007. m.SetDeletedAt(v)
  1008. return nil
  1009. case agent.FieldName:
  1010. v, ok := value.(string)
  1011. if !ok {
  1012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1013. }
  1014. m.SetName(v)
  1015. return nil
  1016. case agent.FieldRole:
  1017. v, ok := value.(string)
  1018. if !ok {
  1019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1020. }
  1021. m.SetRole(v)
  1022. return nil
  1023. case agent.FieldStatus:
  1024. v, ok := value.(int)
  1025. if !ok {
  1026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1027. }
  1028. m.SetStatus(v)
  1029. return nil
  1030. case agent.FieldBackground:
  1031. v, ok := value.(string)
  1032. if !ok {
  1033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1034. }
  1035. m.SetBackground(v)
  1036. return nil
  1037. case agent.FieldExamples:
  1038. v, ok := value.(string)
  1039. if !ok {
  1040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1041. }
  1042. m.SetExamples(v)
  1043. return nil
  1044. case agent.FieldOrganizationID:
  1045. v, ok := value.(uint64)
  1046. if !ok {
  1047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1048. }
  1049. m.SetOrganizationID(v)
  1050. return nil
  1051. case agent.FieldDatasetID:
  1052. v, ok := value.(string)
  1053. if !ok {
  1054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1055. }
  1056. m.SetDatasetID(v)
  1057. return nil
  1058. case agent.FieldCollectionID:
  1059. v, ok := value.(string)
  1060. if !ok {
  1061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1062. }
  1063. m.SetCollectionID(v)
  1064. return nil
  1065. }
  1066. return fmt.Errorf("unknown Agent field %s", name)
  1067. }
  1068. // AddedFields returns all numeric fields that were incremented/decremented during
  1069. // this mutation.
  1070. func (m *AgentMutation) AddedFields() []string {
  1071. var fields []string
  1072. if m.addstatus != nil {
  1073. fields = append(fields, agent.FieldStatus)
  1074. }
  1075. if m.addorganization_id != nil {
  1076. fields = append(fields, agent.FieldOrganizationID)
  1077. }
  1078. return fields
  1079. }
  1080. // AddedField returns the numeric value that was incremented/decremented on a field
  1081. // with the given name. The second boolean return value indicates that this field
  1082. // was not set, or was not defined in the schema.
  1083. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1084. switch name {
  1085. case agent.FieldStatus:
  1086. return m.AddedStatus()
  1087. case agent.FieldOrganizationID:
  1088. return m.AddedOrganizationID()
  1089. }
  1090. return nil, false
  1091. }
  1092. // AddField adds the value to the field with the given name. It returns an error if
  1093. // the field is not defined in the schema, or if the type mismatched the field
  1094. // type.
  1095. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1096. switch name {
  1097. case agent.FieldStatus:
  1098. v, ok := value.(int)
  1099. if !ok {
  1100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1101. }
  1102. m.AddStatus(v)
  1103. return nil
  1104. case agent.FieldOrganizationID:
  1105. v, ok := value.(int64)
  1106. if !ok {
  1107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1108. }
  1109. m.AddOrganizationID(v)
  1110. return nil
  1111. }
  1112. return fmt.Errorf("unknown Agent numeric field %s", name)
  1113. }
  1114. // ClearedFields returns all nullable fields that were cleared during this
  1115. // mutation.
  1116. func (m *AgentMutation) ClearedFields() []string {
  1117. var fields []string
  1118. if m.FieldCleared(agent.FieldDeletedAt) {
  1119. fields = append(fields, agent.FieldDeletedAt)
  1120. }
  1121. if m.FieldCleared(agent.FieldStatus) {
  1122. fields = append(fields, agent.FieldStatus)
  1123. }
  1124. if m.FieldCleared(agent.FieldBackground) {
  1125. fields = append(fields, agent.FieldBackground)
  1126. }
  1127. if m.FieldCleared(agent.FieldExamples) {
  1128. fields = append(fields, agent.FieldExamples)
  1129. }
  1130. return fields
  1131. }
  1132. // FieldCleared returns a boolean indicating if a field with the given name was
  1133. // cleared in this mutation.
  1134. func (m *AgentMutation) FieldCleared(name string) bool {
  1135. _, ok := m.clearedFields[name]
  1136. return ok
  1137. }
  1138. // ClearField clears the value of the field with the given name. It returns an
  1139. // error if the field is not defined in the schema.
  1140. func (m *AgentMutation) ClearField(name string) error {
  1141. switch name {
  1142. case agent.FieldDeletedAt:
  1143. m.ClearDeletedAt()
  1144. return nil
  1145. case agent.FieldStatus:
  1146. m.ClearStatus()
  1147. return nil
  1148. case agent.FieldBackground:
  1149. m.ClearBackground()
  1150. return nil
  1151. case agent.FieldExamples:
  1152. m.ClearExamples()
  1153. return nil
  1154. }
  1155. return fmt.Errorf("unknown Agent nullable field %s", name)
  1156. }
  1157. // ResetField resets all changes in the mutation for the field with the given name.
  1158. // It returns an error if the field is not defined in the schema.
  1159. func (m *AgentMutation) ResetField(name string) error {
  1160. switch name {
  1161. case agent.FieldCreatedAt:
  1162. m.ResetCreatedAt()
  1163. return nil
  1164. case agent.FieldUpdatedAt:
  1165. m.ResetUpdatedAt()
  1166. return nil
  1167. case agent.FieldDeletedAt:
  1168. m.ResetDeletedAt()
  1169. return nil
  1170. case agent.FieldName:
  1171. m.ResetName()
  1172. return nil
  1173. case agent.FieldRole:
  1174. m.ResetRole()
  1175. return nil
  1176. case agent.FieldStatus:
  1177. m.ResetStatus()
  1178. return nil
  1179. case agent.FieldBackground:
  1180. m.ResetBackground()
  1181. return nil
  1182. case agent.FieldExamples:
  1183. m.ResetExamples()
  1184. return nil
  1185. case agent.FieldOrganizationID:
  1186. m.ResetOrganizationID()
  1187. return nil
  1188. case agent.FieldDatasetID:
  1189. m.ResetDatasetID()
  1190. return nil
  1191. case agent.FieldCollectionID:
  1192. m.ResetCollectionID()
  1193. return nil
  1194. }
  1195. return fmt.Errorf("unknown Agent field %s", name)
  1196. }
  1197. // AddedEdges returns all edge names that were set/added in this mutation.
  1198. func (m *AgentMutation) AddedEdges() []string {
  1199. edges := make([]string, 0, 4)
  1200. if m.wx_agent != nil {
  1201. edges = append(edges, agent.EdgeWxAgent)
  1202. }
  1203. if m.token_agent != nil {
  1204. edges = append(edges, agent.EdgeTokenAgent)
  1205. }
  1206. if m.wa_agent != nil {
  1207. edges = append(edges, agent.EdgeWaAgent)
  1208. }
  1209. if m.key_agent != nil {
  1210. edges = append(edges, agent.EdgeKeyAgent)
  1211. }
  1212. return edges
  1213. }
  1214. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1215. // name in this mutation.
  1216. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1217. switch name {
  1218. case agent.EdgeWxAgent:
  1219. ids := make([]ent.Value, 0, len(m.wx_agent))
  1220. for id := range m.wx_agent {
  1221. ids = append(ids, id)
  1222. }
  1223. return ids
  1224. case agent.EdgeTokenAgent:
  1225. ids := make([]ent.Value, 0, len(m.token_agent))
  1226. for id := range m.token_agent {
  1227. ids = append(ids, id)
  1228. }
  1229. return ids
  1230. case agent.EdgeWaAgent:
  1231. ids := make([]ent.Value, 0, len(m.wa_agent))
  1232. for id := range m.wa_agent {
  1233. ids = append(ids, id)
  1234. }
  1235. return ids
  1236. case agent.EdgeKeyAgent:
  1237. ids := make([]ent.Value, 0, len(m.key_agent))
  1238. for id := range m.key_agent {
  1239. ids = append(ids, id)
  1240. }
  1241. return ids
  1242. }
  1243. return nil
  1244. }
  1245. // RemovedEdges returns all edge names that were removed in this mutation.
  1246. func (m *AgentMutation) RemovedEdges() []string {
  1247. edges := make([]string, 0, 4)
  1248. if m.removedwx_agent != nil {
  1249. edges = append(edges, agent.EdgeWxAgent)
  1250. }
  1251. if m.removedtoken_agent != nil {
  1252. edges = append(edges, agent.EdgeTokenAgent)
  1253. }
  1254. if m.removedwa_agent != nil {
  1255. edges = append(edges, agent.EdgeWaAgent)
  1256. }
  1257. if m.removedkey_agent != nil {
  1258. edges = append(edges, agent.EdgeKeyAgent)
  1259. }
  1260. return edges
  1261. }
  1262. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1263. // the given name in this mutation.
  1264. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1265. switch name {
  1266. case agent.EdgeWxAgent:
  1267. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1268. for id := range m.removedwx_agent {
  1269. ids = append(ids, id)
  1270. }
  1271. return ids
  1272. case agent.EdgeTokenAgent:
  1273. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1274. for id := range m.removedtoken_agent {
  1275. ids = append(ids, id)
  1276. }
  1277. return ids
  1278. case agent.EdgeWaAgent:
  1279. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1280. for id := range m.removedwa_agent {
  1281. ids = append(ids, id)
  1282. }
  1283. return ids
  1284. case agent.EdgeKeyAgent:
  1285. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1286. for id := range m.removedkey_agent {
  1287. ids = append(ids, id)
  1288. }
  1289. return ids
  1290. }
  1291. return nil
  1292. }
  1293. // ClearedEdges returns all edge names that were cleared in this mutation.
  1294. func (m *AgentMutation) ClearedEdges() []string {
  1295. edges := make([]string, 0, 4)
  1296. if m.clearedwx_agent {
  1297. edges = append(edges, agent.EdgeWxAgent)
  1298. }
  1299. if m.clearedtoken_agent {
  1300. edges = append(edges, agent.EdgeTokenAgent)
  1301. }
  1302. if m.clearedwa_agent {
  1303. edges = append(edges, agent.EdgeWaAgent)
  1304. }
  1305. if m.clearedkey_agent {
  1306. edges = append(edges, agent.EdgeKeyAgent)
  1307. }
  1308. return edges
  1309. }
  1310. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1311. // was cleared in this mutation.
  1312. func (m *AgentMutation) EdgeCleared(name string) bool {
  1313. switch name {
  1314. case agent.EdgeWxAgent:
  1315. return m.clearedwx_agent
  1316. case agent.EdgeTokenAgent:
  1317. return m.clearedtoken_agent
  1318. case agent.EdgeWaAgent:
  1319. return m.clearedwa_agent
  1320. case agent.EdgeKeyAgent:
  1321. return m.clearedkey_agent
  1322. }
  1323. return false
  1324. }
  1325. // ClearEdge clears the value of the edge with the given name. It returns an error
  1326. // if that edge is not defined in the schema.
  1327. func (m *AgentMutation) ClearEdge(name string) error {
  1328. switch name {
  1329. }
  1330. return fmt.Errorf("unknown Agent unique edge %s", name)
  1331. }
  1332. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1333. // It returns an error if the edge is not defined in the schema.
  1334. func (m *AgentMutation) ResetEdge(name string) error {
  1335. switch name {
  1336. case agent.EdgeWxAgent:
  1337. m.ResetWxAgent()
  1338. return nil
  1339. case agent.EdgeTokenAgent:
  1340. m.ResetTokenAgent()
  1341. return nil
  1342. case agent.EdgeWaAgent:
  1343. m.ResetWaAgent()
  1344. return nil
  1345. case agent.EdgeKeyAgent:
  1346. m.ResetKeyAgent()
  1347. return nil
  1348. }
  1349. return fmt.Errorf("unknown Agent edge %s", name)
  1350. }
  1351. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1352. type AgentBaseMutation struct {
  1353. config
  1354. op Op
  1355. typ string
  1356. id *string
  1357. q *string
  1358. a *string
  1359. chunk_index *uint64
  1360. addchunk_index *int64
  1361. indexes *[]string
  1362. appendindexes []string
  1363. dataset_id *string
  1364. collection_id *string
  1365. source_name *string
  1366. can_write *[]bool
  1367. appendcan_write []bool
  1368. is_owner *[]bool
  1369. appendis_owner []bool
  1370. clearedFields map[string]struct{}
  1371. wx_agent map[uint64]struct{}
  1372. removedwx_agent map[uint64]struct{}
  1373. clearedwx_agent bool
  1374. done bool
  1375. oldValue func(context.Context) (*AgentBase, error)
  1376. predicates []predicate.AgentBase
  1377. }
  1378. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1379. // agentbaseOption allows management of the mutation configuration using functional options.
  1380. type agentbaseOption func(*AgentBaseMutation)
  1381. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1382. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1383. m := &AgentBaseMutation{
  1384. config: c,
  1385. op: op,
  1386. typ: TypeAgentBase,
  1387. clearedFields: make(map[string]struct{}),
  1388. }
  1389. for _, opt := range opts {
  1390. opt(m)
  1391. }
  1392. return m
  1393. }
  1394. // withAgentBaseID sets the ID field of the mutation.
  1395. func withAgentBaseID(id string) agentbaseOption {
  1396. return func(m *AgentBaseMutation) {
  1397. var (
  1398. err error
  1399. once sync.Once
  1400. value *AgentBase
  1401. )
  1402. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1403. once.Do(func() {
  1404. if m.done {
  1405. err = errors.New("querying old values post mutation is not allowed")
  1406. } else {
  1407. value, err = m.Client().AgentBase.Get(ctx, id)
  1408. }
  1409. })
  1410. return value, err
  1411. }
  1412. m.id = &id
  1413. }
  1414. }
  1415. // withAgentBase sets the old AgentBase of the mutation.
  1416. func withAgentBase(node *AgentBase) agentbaseOption {
  1417. return func(m *AgentBaseMutation) {
  1418. m.oldValue = func(context.Context) (*AgentBase, error) {
  1419. return node, nil
  1420. }
  1421. m.id = &node.ID
  1422. }
  1423. }
  1424. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1425. // executed in a transaction (ent.Tx), a transactional client is returned.
  1426. func (m AgentBaseMutation) Client() *Client {
  1427. client := &Client{config: m.config}
  1428. client.init()
  1429. return client
  1430. }
  1431. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1432. // it returns an error otherwise.
  1433. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1434. if _, ok := m.driver.(*txDriver); !ok {
  1435. return nil, errors.New("ent: mutation is not running in a transaction")
  1436. }
  1437. tx := &Tx{config: m.config}
  1438. tx.init()
  1439. return tx, nil
  1440. }
  1441. // SetID sets the value of the id field. Note that this
  1442. // operation is only accepted on creation of AgentBase entities.
  1443. func (m *AgentBaseMutation) SetID(id string) {
  1444. m.id = &id
  1445. }
  1446. // ID returns the ID value in the mutation. Note that the ID is only available
  1447. // if it was provided to the builder or after it was returned from the database.
  1448. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1449. if m.id == nil {
  1450. return
  1451. }
  1452. return *m.id, true
  1453. }
  1454. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1455. // That means, if the mutation is applied within a transaction with an isolation level such
  1456. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1457. // or updated by the mutation.
  1458. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1459. switch {
  1460. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1461. id, exists := m.ID()
  1462. if exists {
  1463. return []string{id}, nil
  1464. }
  1465. fallthrough
  1466. case m.op.Is(OpUpdate | OpDelete):
  1467. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1468. default:
  1469. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1470. }
  1471. }
  1472. // SetQ sets the "q" field.
  1473. func (m *AgentBaseMutation) SetQ(s string) {
  1474. m.q = &s
  1475. }
  1476. // Q returns the value of the "q" field in the mutation.
  1477. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1478. v := m.q
  1479. if v == nil {
  1480. return
  1481. }
  1482. return *v, true
  1483. }
  1484. // OldQ returns the old "q" field's value of the AgentBase entity.
  1485. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1487. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1488. if !m.op.Is(OpUpdateOne) {
  1489. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1490. }
  1491. if m.id == nil || m.oldValue == nil {
  1492. return v, errors.New("OldQ requires an ID field in the mutation")
  1493. }
  1494. oldValue, err := m.oldValue(ctx)
  1495. if err != nil {
  1496. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1497. }
  1498. return oldValue.Q, nil
  1499. }
  1500. // ClearQ clears the value of the "q" field.
  1501. func (m *AgentBaseMutation) ClearQ() {
  1502. m.q = nil
  1503. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1504. }
  1505. // QCleared returns if the "q" field was cleared in this mutation.
  1506. func (m *AgentBaseMutation) QCleared() bool {
  1507. _, ok := m.clearedFields[agentbase.FieldQ]
  1508. return ok
  1509. }
  1510. // ResetQ resets all changes to the "q" field.
  1511. func (m *AgentBaseMutation) ResetQ() {
  1512. m.q = nil
  1513. delete(m.clearedFields, agentbase.FieldQ)
  1514. }
  1515. // SetA sets the "a" field.
  1516. func (m *AgentBaseMutation) SetA(s string) {
  1517. m.a = &s
  1518. }
  1519. // A returns the value of the "a" field in the mutation.
  1520. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1521. v := m.a
  1522. if v == nil {
  1523. return
  1524. }
  1525. return *v, true
  1526. }
  1527. // OldA returns the old "a" field's value of the AgentBase entity.
  1528. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1530. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1531. if !m.op.Is(OpUpdateOne) {
  1532. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1533. }
  1534. if m.id == nil || m.oldValue == nil {
  1535. return v, errors.New("OldA requires an ID field in the mutation")
  1536. }
  1537. oldValue, err := m.oldValue(ctx)
  1538. if err != nil {
  1539. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1540. }
  1541. return oldValue.A, nil
  1542. }
  1543. // ClearA clears the value of the "a" field.
  1544. func (m *AgentBaseMutation) ClearA() {
  1545. m.a = nil
  1546. m.clearedFields[agentbase.FieldA] = struct{}{}
  1547. }
  1548. // ACleared returns if the "a" field was cleared in this mutation.
  1549. func (m *AgentBaseMutation) ACleared() bool {
  1550. _, ok := m.clearedFields[agentbase.FieldA]
  1551. return ok
  1552. }
  1553. // ResetA resets all changes to the "a" field.
  1554. func (m *AgentBaseMutation) ResetA() {
  1555. m.a = nil
  1556. delete(m.clearedFields, agentbase.FieldA)
  1557. }
  1558. // SetChunkIndex sets the "chunk_index" field.
  1559. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1560. m.chunk_index = &u
  1561. m.addchunk_index = nil
  1562. }
  1563. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1564. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1565. v := m.chunk_index
  1566. if v == nil {
  1567. return
  1568. }
  1569. return *v, true
  1570. }
  1571. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1572. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1574. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1575. if !m.op.Is(OpUpdateOne) {
  1576. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1577. }
  1578. if m.id == nil || m.oldValue == nil {
  1579. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1580. }
  1581. oldValue, err := m.oldValue(ctx)
  1582. if err != nil {
  1583. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1584. }
  1585. return oldValue.ChunkIndex, nil
  1586. }
  1587. // AddChunkIndex adds u to the "chunk_index" field.
  1588. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1589. if m.addchunk_index != nil {
  1590. *m.addchunk_index += u
  1591. } else {
  1592. m.addchunk_index = &u
  1593. }
  1594. }
  1595. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1596. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1597. v := m.addchunk_index
  1598. if v == nil {
  1599. return
  1600. }
  1601. return *v, true
  1602. }
  1603. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1604. func (m *AgentBaseMutation) ResetChunkIndex() {
  1605. m.chunk_index = nil
  1606. m.addchunk_index = nil
  1607. }
  1608. // SetIndexes sets the "indexes" field.
  1609. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1610. m.indexes = &s
  1611. m.appendindexes = nil
  1612. }
  1613. // Indexes returns the value of the "indexes" field in the mutation.
  1614. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1615. v := m.indexes
  1616. if v == nil {
  1617. return
  1618. }
  1619. return *v, true
  1620. }
  1621. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1622. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1624. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1625. if !m.op.Is(OpUpdateOne) {
  1626. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1627. }
  1628. if m.id == nil || m.oldValue == nil {
  1629. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1630. }
  1631. oldValue, err := m.oldValue(ctx)
  1632. if err != nil {
  1633. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1634. }
  1635. return oldValue.Indexes, nil
  1636. }
  1637. // AppendIndexes adds s to the "indexes" field.
  1638. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1639. m.appendindexes = append(m.appendindexes, s...)
  1640. }
  1641. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1642. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1643. if len(m.appendindexes) == 0 {
  1644. return nil, false
  1645. }
  1646. return m.appendindexes, true
  1647. }
  1648. // ClearIndexes clears the value of the "indexes" field.
  1649. func (m *AgentBaseMutation) ClearIndexes() {
  1650. m.indexes = nil
  1651. m.appendindexes = nil
  1652. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1653. }
  1654. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1655. func (m *AgentBaseMutation) IndexesCleared() bool {
  1656. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1657. return ok
  1658. }
  1659. // ResetIndexes resets all changes to the "indexes" field.
  1660. func (m *AgentBaseMutation) ResetIndexes() {
  1661. m.indexes = nil
  1662. m.appendindexes = nil
  1663. delete(m.clearedFields, agentbase.FieldIndexes)
  1664. }
  1665. // SetDatasetID sets the "dataset_id" field.
  1666. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1667. m.dataset_id = &s
  1668. }
  1669. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1670. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1671. v := m.dataset_id
  1672. if v == nil {
  1673. return
  1674. }
  1675. return *v, true
  1676. }
  1677. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1678. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1680. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1681. if !m.op.Is(OpUpdateOne) {
  1682. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1683. }
  1684. if m.id == nil || m.oldValue == nil {
  1685. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1686. }
  1687. oldValue, err := m.oldValue(ctx)
  1688. if err != nil {
  1689. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1690. }
  1691. return oldValue.DatasetID, nil
  1692. }
  1693. // ClearDatasetID clears the value of the "dataset_id" field.
  1694. func (m *AgentBaseMutation) ClearDatasetID() {
  1695. m.dataset_id = nil
  1696. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1697. }
  1698. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1699. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1700. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1701. return ok
  1702. }
  1703. // ResetDatasetID resets all changes to the "dataset_id" field.
  1704. func (m *AgentBaseMutation) ResetDatasetID() {
  1705. m.dataset_id = nil
  1706. delete(m.clearedFields, agentbase.FieldDatasetID)
  1707. }
  1708. // SetCollectionID sets the "collection_id" field.
  1709. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1710. m.collection_id = &s
  1711. }
  1712. // CollectionID returns the value of the "collection_id" field in the mutation.
  1713. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1714. v := m.collection_id
  1715. if v == nil {
  1716. return
  1717. }
  1718. return *v, true
  1719. }
  1720. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1721. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1723. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1724. if !m.op.Is(OpUpdateOne) {
  1725. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1726. }
  1727. if m.id == nil || m.oldValue == nil {
  1728. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1729. }
  1730. oldValue, err := m.oldValue(ctx)
  1731. if err != nil {
  1732. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1733. }
  1734. return oldValue.CollectionID, nil
  1735. }
  1736. // ClearCollectionID clears the value of the "collection_id" field.
  1737. func (m *AgentBaseMutation) ClearCollectionID() {
  1738. m.collection_id = nil
  1739. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1740. }
  1741. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1742. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1743. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1744. return ok
  1745. }
  1746. // ResetCollectionID resets all changes to the "collection_id" field.
  1747. func (m *AgentBaseMutation) ResetCollectionID() {
  1748. m.collection_id = nil
  1749. delete(m.clearedFields, agentbase.FieldCollectionID)
  1750. }
  1751. // SetSourceName sets the "source_name" field.
  1752. func (m *AgentBaseMutation) SetSourceName(s string) {
  1753. m.source_name = &s
  1754. }
  1755. // SourceName returns the value of the "source_name" field in the mutation.
  1756. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1757. v := m.source_name
  1758. if v == nil {
  1759. return
  1760. }
  1761. return *v, true
  1762. }
  1763. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1764. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1766. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1767. if !m.op.Is(OpUpdateOne) {
  1768. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1769. }
  1770. if m.id == nil || m.oldValue == nil {
  1771. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1772. }
  1773. oldValue, err := m.oldValue(ctx)
  1774. if err != nil {
  1775. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1776. }
  1777. return oldValue.SourceName, nil
  1778. }
  1779. // ClearSourceName clears the value of the "source_name" field.
  1780. func (m *AgentBaseMutation) ClearSourceName() {
  1781. m.source_name = nil
  1782. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1783. }
  1784. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1785. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1786. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1787. return ok
  1788. }
  1789. // ResetSourceName resets all changes to the "source_name" field.
  1790. func (m *AgentBaseMutation) ResetSourceName() {
  1791. m.source_name = nil
  1792. delete(m.clearedFields, agentbase.FieldSourceName)
  1793. }
  1794. // SetCanWrite sets the "can_write" field.
  1795. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1796. m.can_write = &b
  1797. m.appendcan_write = nil
  1798. }
  1799. // CanWrite returns the value of the "can_write" field in the mutation.
  1800. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1801. v := m.can_write
  1802. if v == nil {
  1803. return
  1804. }
  1805. return *v, true
  1806. }
  1807. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1808. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1810. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1811. if !m.op.Is(OpUpdateOne) {
  1812. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1813. }
  1814. if m.id == nil || m.oldValue == nil {
  1815. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1816. }
  1817. oldValue, err := m.oldValue(ctx)
  1818. if err != nil {
  1819. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1820. }
  1821. return oldValue.CanWrite, nil
  1822. }
  1823. // AppendCanWrite adds b to the "can_write" field.
  1824. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1825. m.appendcan_write = append(m.appendcan_write, b...)
  1826. }
  1827. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1828. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1829. if len(m.appendcan_write) == 0 {
  1830. return nil, false
  1831. }
  1832. return m.appendcan_write, true
  1833. }
  1834. // ClearCanWrite clears the value of the "can_write" field.
  1835. func (m *AgentBaseMutation) ClearCanWrite() {
  1836. m.can_write = nil
  1837. m.appendcan_write = nil
  1838. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1839. }
  1840. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1841. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1842. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1843. return ok
  1844. }
  1845. // ResetCanWrite resets all changes to the "can_write" field.
  1846. func (m *AgentBaseMutation) ResetCanWrite() {
  1847. m.can_write = nil
  1848. m.appendcan_write = nil
  1849. delete(m.clearedFields, agentbase.FieldCanWrite)
  1850. }
  1851. // SetIsOwner sets the "is_owner" field.
  1852. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1853. m.is_owner = &b
  1854. m.appendis_owner = nil
  1855. }
  1856. // IsOwner returns the value of the "is_owner" field in the mutation.
  1857. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1858. v := m.is_owner
  1859. if v == nil {
  1860. return
  1861. }
  1862. return *v, true
  1863. }
  1864. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1865. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1867. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1868. if !m.op.Is(OpUpdateOne) {
  1869. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1870. }
  1871. if m.id == nil || m.oldValue == nil {
  1872. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1873. }
  1874. oldValue, err := m.oldValue(ctx)
  1875. if err != nil {
  1876. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1877. }
  1878. return oldValue.IsOwner, nil
  1879. }
  1880. // AppendIsOwner adds b to the "is_owner" field.
  1881. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1882. m.appendis_owner = append(m.appendis_owner, b...)
  1883. }
  1884. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1885. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1886. if len(m.appendis_owner) == 0 {
  1887. return nil, false
  1888. }
  1889. return m.appendis_owner, true
  1890. }
  1891. // ClearIsOwner clears the value of the "is_owner" field.
  1892. func (m *AgentBaseMutation) ClearIsOwner() {
  1893. m.is_owner = nil
  1894. m.appendis_owner = nil
  1895. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1896. }
  1897. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1898. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1899. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1900. return ok
  1901. }
  1902. // ResetIsOwner resets all changes to the "is_owner" field.
  1903. func (m *AgentBaseMutation) ResetIsOwner() {
  1904. m.is_owner = nil
  1905. m.appendis_owner = nil
  1906. delete(m.clearedFields, agentbase.FieldIsOwner)
  1907. }
  1908. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1909. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1910. if m.wx_agent == nil {
  1911. m.wx_agent = make(map[uint64]struct{})
  1912. }
  1913. for i := range ids {
  1914. m.wx_agent[ids[i]] = struct{}{}
  1915. }
  1916. }
  1917. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1918. func (m *AgentBaseMutation) ClearWxAgent() {
  1919. m.clearedwx_agent = true
  1920. }
  1921. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1922. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1923. return m.clearedwx_agent
  1924. }
  1925. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1926. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1927. if m.removedwx_agent == nil {
  1928. m.removedwx_agent = make(map[uint64]struct{})
  1929. }
  1930. for i := range ids {
  1931. delete(m.wx_agent, ids[i])
  1932. m.removedwx_agent[ids[i]] = struct{}{}
  1933. }
  1934. }
  1935. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1936. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1937. for id := range m.removedwx_agent {
  1938. ids = append(ids, id)
  1939. }
  1940. return
  1941. }
  1942. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1943. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1944. for id := range m.wx_agent {
  1945. ids = append(ids, id)
  1946. }
  1947. return
  1948. }
  1949. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1950. func (m *AgentBaseMutation) ResetWxAgent() {
  1951. m.wx_agent = nil
  1952. m.clearedwx_agent = false
  1953. m.removedwx_agent = nil
  1954. }
  1955. // Where appends a list predicates to the AgentBaseMutation builder.
  1956. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1957. m.predicates = append(m.predicates, ps...)
  1958. }
  1959. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1960. // users can use type-assertion to append predicates that do not depend on any generated package.
  1961. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1962. p := make([]predicate.AgentBase, len(ps))
  1963. for i := range ps {
  1964. p[i] = ps[i]
  1965. }
  1966. m.Where(p...)
  1967. }
  1968. // Op returns the operation name.
  1969. func (m *AgentBaseMutation) Op() Op {
  1970. return m.op
  1971. }
  1972. // SetOp allows setting the mutation operation.
  1973. func (m *AgentBaseMutation) SetOp(op Op) {
  1974. m.op = op
  1975. }
  1976. // Type returns the node type of this mutation (AgentBase).
  1977. func (m *AgentBaseMutation) Type() string {
  1978. return m.typ
  1979. }
  1980. // Fields returns all fields that were changed during this mutation. Note that in
  1981. // order to get all numeric fields that were incremented/decremented, call
  1982. // AddedFields().
  1983. func (m *AgentBaseMutation) Fields() []string {
  1984. fields := make([]string, 0, 9)
  1985. if m.q != nil {
  1986. fields = append(fields, agentbase.FieldQ)
  1987. }
  1988. if m.a != nil {
  1989. fields = append(fields, agentbase.FieldA)
  1990. }
  1991. if m.chunk_index != nil {
  1992. fields = append(fields, agentbase.FieldChunkIndex)
  1993. }
  1994. if m.indexes != nil {
  1995. fields = append(fields, agentbase.FieldIndexes)
  1996. }
  1997. if m.dataset_id != nil {
  1998. fields = append(fields, agentbase.FieldDatasetID)
  1999. }
  2000. if m.collection_id != nil {
  2001. fields = append(fields, agentbase.FieldCollectionID)
  2002. }
  2003. if m.source_name != nil {
  2004. fields = append(fields, agentbase.FieldSourceName)
  2005. }
  2006. if m.can_write != nil {
  2007. fields = append(fields, agentbase.FieldCanWrite)
  2008. }
  2009. if m.is_owner != nil {
  2010. fields = append(fields, agentbase.FieldIsOwner)
  2011. }
  2012. return fields
  2013. }
  2014. // Field returns the value of a field with the given name. The second boolean
  2015. // return value indicates that this field was not set, or was not defined in the
  2016. // schema.
  2017. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2018. switch name {
  2019. case agentbase.FieldQ:
  2020. return m.Q()
  2021. case agentbase.FieldA:
  2022. return m.A()
  2023. case agentbase.FieldChunkIndex:
  2024. return m.ChunkIndex()
  2025. case agentbase.FieldIndexes:
  2026. return m.Indexes()
  2027. case agentbase.FieldDatasetID:
  2028. return m.DatasetID()
  2029. case agentbase.FieldCollectionID:
  2030. return m.CollectionID()
  2031. case agentbase.FieldSourceName:
  2032. return m.SourceName()
  2033. case agentbase.FieldCanWrite:
  2034. return m.CanWrite()
  2035. case agentbase.FieldIsOwner:
  2036. return m.IsOwner()
  2037. }
  2038. return nil, false
  2039. }
  2040. // OldField returns the old value of the field from the database. An error is
  2041. // returned if the mutation operation is not UpdateOne, or the query to the
  2042. // database failed.
  2043. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2044. switch name {
  2045. case agentbase.FieldQ:
  2046. return m.OldQ(ctx)
  2047. case agentbase.FieldA:
  2048. return m.OldA(ctx)
  2049. case agentbase.FieldChunkIndex:
  2050. return m.OldChunkIndex(ctx)
  2051. case agentbase.FieldIndexes:
  2052. return m.OldIndexes(ctx)
  2053. case agentbase.FieldDatasetID:
  2054. return m.OldDatasetID(ctx)
  2055. case agentbase.FieldCollectionID:
  2056. return m.OldCollectionID(ctx)
  2057. case agentbase.FieldSourceName:
  2058. return m.OldSourceName(ctx)
  2059. case agentbase.FieldCanWrite:
  2060. return m.OldCanWrite(ctx)
  2061. case agentbase.FieldIsOwner:
  2062. return m.OldIsOwner(ctx)
  2063. }
  2064. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2065. }
  2066. // SetField sets the value of a field with the given name. It returns an error if
  2067. // the field is not defined in the schema, or if the type mismatched the field
  2068. // type.
  2069. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2070. switch name {
  2071. case agentbase.FieldQ:
  2072. v, ok := value.(string)
  2073. if !ok {
  2074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2075. }
  2076. m.SetQ(v)
  2077. return nil
  2078. case agentbase.FieldA:
  2079. v, ok := value.(string)
  2080. if !ok {
  2081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2082. }
  2083. m.SetA(v)
  2084. return nil
  2085. case agentbase.FieldChunkIndex:
  2086. v, ok := value.(uint64)
  2087. if !ok {
  2088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2089. }
  2090. m.SetChunkIndex(v)
  2091. return nil
  2092. case agentbase.FieldIndexes:
  2093. v, ok := value.([]string)
  2094. if !ok {
  2095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2096. }
  2097. m.SetIndexes(v)
  2098. return nil
  2099. case agentbase.FieldDatasetID:
  2100. v, ok := value.(string)
  2101. if !ok {
  2102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2103. }
  2104. m.SetDatasetID(v)
  2105. return nil
  2106. case agentbase.FieldCollectionID:
  2107. v, ok := value.(string)
  2108. if !ok {
  2109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2110. }
  2111. m.SetCollectionID(v)
  2112. return nil
  2113. case agentbase.FieldSourceName:
  2114. v, ok := value.(string)
  2115. if !ok {
  2116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2117. }
  2118. m.SetSourceName(v)
  2119. return nil
  2120. case agentbase.FieldCanWrite:
  2121. v, ok := value.([]bool)
  2122. if !ok {
  2123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2124. }
  2125. m.SetCanWrite(v)
  2126. return nil
  2127. case agentbase.FieldIsOwner:
  2128. v, ok := value.([]bool)
  2129. if !ok {
  2130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2131. }
  2132. m.SetIsOwner(v)
  2133. return nil
  2134. }
  2135. return fmt.Errorf("unknown AgentBase field %s", name)
  2136. }
  2137. // AddedFields returns all numeric fields that were incremented/decremented during
  2138. // this mutation.
  2139. func (m *AgentBaseMutation) AddedFields() []string {
  2140. var fields []string
  2141. if m.addchunk_index != nil {
  2142. fields = append(fields, agentbase.FieldChunkIndex)
  2143. }
  2144. return fields
  2145. }
  2146. // AddedField returns the numeric value that was incremented/decremented on a field
  2147. // with the given name. The second boolean return value indicates that this field
  2148. // was not set, or was not defined in the schema.
  2149. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2150. switch name {
  2151. case agentbase.FieldChunkIndex:
  2152. return m.AddedChunkIndex()
  2153. }
  2154. return nil, false
  2155. }
  2156. // AddField adds the value to the field with the given name. It returns an error if
  2157. // the field is not defined in the schema, or if the type mismatched the field
  2158. // type.
  2159. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2160. switch name {
  2161. case agentbase.FieldChunkIndex:
  2162. v, ok := value.(int64)
  2163. if !ok {
  2164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2165. }
  2166. m.AddChunkIndex(v)
  2167. return nil
  2168. }
  2169. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2170. }
  2171. // ClearedFields returns all nullable fields that were cleared during this
  2172. // mutation.
  2173. func (m *AgentBaseMutation) ClearedFields() []string {
  2174. var fields []string
  2175. if m.FieldCleared(agentbase.FieldQ) {
  2176. fields = append(fields, agentbase.FieldQ)
  2177. }
  2178. if m.FieldCleared(agentbase.FieldA) {
  2179. fields = append(fields, agentbase.FieldA)
  2180. }
  2181. if m.FieldCleared(agentbase.FieldIndexes) {
  2182. fields = append(fields, agentbase.FieldIndexes)
  2183. }
  2184. if m.FieldCleared(agentbase.FieldDatasetID) {
  2185. fields = append(fields, agentbase.FieldDatasetID)
  2186. }
  2187. if m.FieldCleared(agentbase.FieldCollectionID) {
  2188. fields = append(fields, agentbase.FieldCollectionID)
  2189. }
  2190. if m.FieldCleared(agentbase.FieldSourceName) {
  2191. fields = append(fields, agentbase.FieldSourceName)
  2192. }
  2193. if m.FieldCleared(agentbase.FieldCanWrite) {
  2194. fields = append(fields, agentbase.FieldCanWrite)
  2195. }
  2196. if m.FieldCleared(agentbase.FieldIsOwner) {
  2197. fields = append(fields, agentbase.FieldIsOwner)
  2198. }
  2199. return fields
  2200. }
  2201. // FieldCleared returns a boolean indicating if a field with the given name was
  2202. // cleared in this mutation.
  2203. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2204. _, ok := m.clearedFields[name]
  2205. return ok
  2206. }
  2207. // ClearField clears the value of the field with the given name. It returns an
  2208. // error if the field is not defined in the schema.
  2209. func (m *AgentBaseMutation) ClearField(name string) error {
  2210. switch name {
  2211. case agentbase.FieldQ:
  2212. m.ClearQ()
  2213. return nil
  2214. case agentbase.FieldA:
  2215. m.ClearA()
  2216. return nil
  2217. case agentbase.FieldIndexes:
  2218. m.ClearIndexes()
  2219. return nil
  2220. case agentbase.FieldDatasetID:
  2221. m.ClearDatasetID()
  2222. return nil
  2223. case agentbase.FieldCollectionID:
  2224. m.ClearCollectionID()
  2225. return nil
  2226. case agentbase.FieldSourceName:
  2227. m.ClearSourceName()
  2228. return nil
  2229. case agentbase.FieldCanWrite:
  2230. m.ClearCanWrite()
  2231. return nil
  2232. case agentbase.FieldIsOwner:
  2233. m.ClearIsOwner()
  2234. return nil
  2235. }
  2236. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2237. }
  2238. // ResetField resets all changes in the mutation for the field with the given name.
  2239. // It returns an error if the field is not defined in the schema.
  2240. func (m *AgentBaseMutation) ResetField(name string) error {
  2241. switch name {
  2242. case agentbase.FieldQ:
  2243. m.ResetQ()
  2244. return nil
  2245. case agentbase.FieldA:
  2246. m.ResetA()
  2247. return nil
  2248. case agentbase.FieldChunkIndex:
  2249. m.ResetChunkIndex()
  2250. return nil
  2251. case agentbase.FieldIndexes:
  2252. m.ResetIndexes()
  2253. return nil
  2254. case agentbase.FieldDatasetID:
  2255. m.ResetDatasetID()
  2256. return nil
  2257. case agentbase.FieldCollectionID:
  2258. m.ResetCollectionID()
  2259. return nil
  2260. case agentbase.FieldSourceName:
  2261. m.ResetSourceName()
  2262. return nil
  2263. case agentbase.FieldCanWrite:
  2264. m.ResetCanWrite()
  2265. return nil
  2266. case agentbase.FieldIsOwner:
  2267. m.ResetIsOwner()
  2268. return nil
  2269. }
  2270. return fmt.Errorf("unknown AgentBase field %s", name)
  2271. }
  2272. // AddedEdges returns all edge names that were set/added in this mutation.
  2273. func (m *AgentBaseMutation) AddedEdges() []string {
  2274. edges := make([]string, 0, 1)
  2275. if m.wx_agent != nil {
  2276. edges = append(edges, agentbase.EdgeWxAgent)
  2277. }
  2278. return edges
  2279. }
  2280. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2281. // name in this mutation.
  2282. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2283. switch name {
  2284. case agentbase.EdgeWxAgent:
  2285. ids := make([]ent.Value, 0, len(m.wx_agent))
  2286. for id := range m.wx_agent {
  2287. ids = append(ids, id)
  2288. }
  2289. return ids
  2290. }
  2291. return nil
  2292. }
  2293. // RemovedEdges returns all edge names that were removed in this mutation.
  2294. func (m *AgentBaseMutation) RemovedEdges() []string {
  2295. edges := make([]string, 0, 1)
  2296. if m.removedwx_agent != nil {
  2297. edges = append(edges, agentbase.EdgeWxAgent)
  2298. }
  2299. return edges
  2300. }
  2301. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2302. // the given name in this mutation.
  2303. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2304. switch name {
  2305. case agentbase.EdgeWxAgent:
  2306. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2307. for id := range m.removedwx_agent {
  2308. ids = append(ids, id)
  2309. }
  2310. return ids
  2311. }
  2312. return nil
  2313. }
  2314. // ClearedEdges returns all edge names that were cleared in this mutation.
  2315. func (m *AgentBaseMutation) ClearedEdges() []string {
  2316. edges := make([]string, 0, 1)
  2317. if m.clearedwx_agent {
  2318. edges = append(edges, agentbase.EdgeWxAgent)
  2319. }
  2320. return edges
  2321. }
  2322. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2323. // was cleared in this mutation.
  2324. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2325. switch name {
  2326. case agentbase.EdgeWxAgent:
  2327. return m.clearedwx_agent
  2328. }
  2329. return false
  2330. }
  2331. // ClearEdge clears the value of the edge with the given name. It returns an error
  2332. // if that edge is not defined in the schema.
  2333. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2334. switch name {
  2335. }
  2336. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2337. }
  2338. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2339. // It returns an error if the edge is not defined in the schema.
  2340. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2341. switch name {
  2342. case agentbase.EdgeWxAgent:
  2343. m.ResetWxAgent()
  2344. return nil
  2345. }
  2346. return fmt.Errorf("unknown AgentBase edge %s", name)
  2347. }
  2348. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2349. type AliyunAvatarMutation struct {
  2350. config
  2351. op Op
  2352. typ string
  2353. id *uint64
  2354. created_at *time.Time
  2355. updated_at *time.Time
  2356. deleted_at *time.Time
  2357. user_id *uint64
  2358. adduser_id *int64
  2359. biz_id *string
  2360. access_key_id *string
  2361. access_key_secret *string
  2362. app_id *string
  2363. tenant_id *uint64
  2364. addtenant_id *int64
  2365. response *string
  2366. token *string
  2367. session_id *string
  2368. clearedFields map[string]struct{}
  2369. done bool
  2370. oldValue func(context.Context) (*AliyunAvatar, error)
  2371. predicates []predicate.AliyunAvatar
  2372. }
  2373. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2374. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2375. type aliyunavatarOption func(*AliyunAvatarMutation)
  2376. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2377. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2378. m := &AliyunAvatarMutation{
  2379. config: c,
  2380. op: op,
  2381. typ: TypeAliyunAvatar,
  2382. clearedFields: make(map[string]struct{}),
  2383. }
  2384. for _, opt := range opts {
  2385. opt(m)
  2386. }
  2387. return m
  2388. }
  2389. // withAliyunAvatarID sets the ID field of the mutation.
  2390. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2391. return func(m *AliyunAvatarMutation) {
  2392. var (
  2393. err error
  2394. once sync.Once
  2395. value *AliyunAvatar
  2396. )
  2397. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2398. once.Do(func() {
  2399. if m.done {
  2400. err = errors.New("querying old values post mutation is not allowed")
  2401. } else {
  2402. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2403. }
  2404. })
  2405. return value, err
  2406. }
  2407. m.id = &id
  2408. }
  2409. }
  2410. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2411. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2412. return func(m *AliyunAvatarMutation) {
  2413. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2414. return node, nil
  2415. }
  2416. m.id = &node.ID
  2417. }
  2418. }
  2419. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2420. // executed in a transaction (ent.Tx), a transactional client is returned.
  2421. func (m AliyunAvatarMutation) Client() *Client {
  2422. client := &Client{config: m.config}
  2423. client.init()
  2424. return client
  2425. }
  2426. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2427. // it returns an error otherwise.
  2428. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2429. if _, ok := m.driver.(*txDriver); !ok {
  2430. return nil, errors.New("ent: mutation is not running in a transaction")
  2431. }
  2432. tx := &Tx{config: m.config}
  2433. tx.init()
  2434. return tx, nil
  2435. }
  2436. // SetID sets the value of the id field. Note that this
  2437. // operation is only accepted on creation of AliyunAvatar entities.
  2438. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2439. m.id = &id
  2440. }
  2441. // ID returns the ID value in the mutation. Note that the ID is only available
  2442. // if it was provided to the builder or after it was returned from the database.
  2443. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2444. if m.id == nil {
  2445. return
  2446. }
  2447. return *m.id, true
  2448. }
  2449. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2450. // That means, if the mutation is applied within a transaction with an isolation level such
  2451. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2452. // or updated by the mutation.
  2453. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2454. switch {
  2455. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2456. id, exists := m.ID()
  2457. if exists {
  2458. return []uint64{id}, nil
  2459. }
  2460. fallthrough
  2461. case m.op.Is(OpUpdate | OpDelete):
  2462. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2463. default:
  2464. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2465. }
  2466. }
  2467. // SetCreatedAt sets the "created_at" field.
  2468. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2469. m.created_at = &t
  2470. }
  2471. // CreatedAt returns the value of the "created_at" field in the mutation.
  2472. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2473. v := m.created_at
  2474. if v == nil {
  2475. return
  2476. }
  2477. return *v, true
  2478. }
  2479. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2480. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2482. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2483. if !m.op.Is(OpUpdateOne) {
  2484. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2485. }
  2486. if m.id == nil || m.oldValue == nil {
  2487. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2488. }
  2489. oldValue, err := m.oldValue(ctx)
  2490. if err != nil {
  2491. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2492. }
  2493. return oldValue.CreatedAt, nil
  2494. }
  2495. // ResetCreatedAt resets all changes to the "created_at" field.
  2496. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2497. m.created_at = nil
  2498. }
  2499. // SetUpdatedAt sets the "updated_at" field.
  2500. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2501. m.updated_at = &t
  2502. }
  2503. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2504. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2505. v := m.updated_at
  2506. if v == nil {
  2507. return
  2508. }
  2509. return *v, true
  2510. }
  2511. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2512. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2514. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2515. if !m.op.Is(OpUpdateOne) {
  2516. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2517. }
  2518. if m.id == nil || m.oldValue == nil {
  2519. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2520. }
  2521. oldValue, err := m.oldValue(ctx)
  2522. if err != nil {
  2523. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2524. }
  2525. return oldValue.UpdatedAt, nil
  2526. }
  2527. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2528. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2529. m.updated_at = nil
  2530. }
  2531. // SetDeletedAt sets the "deleted_at" field.
  2532. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2533. m.deleted_at = &t
  2534. }
  2535. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2536. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2537. v := m.deleted_at
  2538. if v == nil {
  2539. return
  2540. }
  2541. return *v, true
  2542. }
  2543. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2544. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2546. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2547. if !m.op.Is(OpUpdateOne) {
  2548. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2549. }
  2550. if m.id == nil || m.oldValue == nil {
  2551. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2552. }
  2553. oldValue, err := m.oldValue(ctx)
  2554. if err != nil {
  2555. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2556. }
  2557. return oldValue.DeletedAt, nil
  2558. }
  2559. // ClearDeletedAt clears the value of the "deleted_at" field.
  2560. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2561. m.deleted_at = nil
  2562. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2563. }
  2564. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2565. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2566. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2567. return ok
  2568. }
  2569. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2570. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2571. m.deleted_at = nil
  2572. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2573. }
  2574. // SetUserID sets the "user_id" field.
  2575. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2576. m.user_id = &u
  2577. m.adduser_id = nil
  2578. }
  2579. // UserID returns the value of the "user_id" field in the mutation.
  2580. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2581. v := m.user_id
  2582. if v == nil {
  2583. return
  2584. }
  2585. return *v, true
  2586. }
  2587. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2588. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2590. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2591. if !m.op.Is(OpUpdateOne) {
  2592. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2593. }
  2594. if m.id == nil || m.oldValue == nil {
  2595. return v, errors.New("OldUserID requires an ID field in the mutation")
  2596. }
  2597. oldValue, err := m.oldValue(ctx)
  2598. if err != nil {
  2599. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2600. }
  2601. return oldValue.UserID, nil
  2602. }
  2603. // AddUserID adds u to the "user_id" field.
  2604. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2605. if m.adduser_id != nil {
  2606. *m.adduser_id += u
  2607. } else {
  2608. m.adduser_id = &u
  2609. }
  2610. }
  2611. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2612. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2613. v := m.adduser_id
  2614. if v == nil {
  2615. return
  2616. }
  2617. return *v, true
  2618. }
  2619. // ResetUserID resets all changes to the "user_id" field.
  2620. func (m *AliyunAvatarMutation) ResetUserID() {
  2621. m.user_id = nil
  2622. m.adduser_id = nil
  2623. }
  2624. // SetBizID sets the "biz_id" field.
  2625. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2626. m.biz_id = &s
  2627. }
  2628. // BizID returns the value of the "biz_id" field in the mutation.
  2629. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2630. v := m.biz_id
  2631. if v == nil {
  2632. return
  2633. }
  2634. return *v, true
  2635. }
  2636. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2637. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2639. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2640. if !m.op.Is(OpUpdateOne) {
  2641. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2642. }
  2643. if m.id == nil || m.oldValue == nil {
  2644. return v, errors.New("OldBizID requires an ID field in the mutation")
  2645. }
  2646. oldValue, err := m.oldValue(ctx)
  2647. if err != nil {
  2648. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2649. }
  2650. return oldValue.BizID, nil
  2651. }
  2652. // ResetBizID resets all changes to the "biz_id" field.
  2653. func (m *AliyunAvatarMutation) ResetBizID() {
  2654. m.biz_id = nil
  2655. }
  2656. // SetAccessKeyID sets the "access_key_id" field.
  2657. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2658. m.access_key_id = &s
  2659. }
  2660. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2661. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2662. v := m.access_key_id
  2663. if v == nil {
  2664. return
  2665. }
  2666. return *v, true
  2667. }
  2668. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2669. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2671. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2672. if !m.op.Is(OpUpdateOne) {
  2673. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2674. }
  2675. if m.id == nil || m.oldValue == nil {
  2676. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2677. }
  2678. oldValue, err := m.oldValue(ctx)
  2679. if err != nil {
  2680. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2681. }
  2682. return oldValue.AccessKeyID, nil
  2683. }
  2684. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2685. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2686. m.access_key_id = nil
  2687. }
  2688. // SetAccessKeySecret sets the "access_key_secret" field.
  2689. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2690. m.access_key_secret = &s
  2691. }
  2692. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2693. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2694. v := m.access_key_secret
  2695. if v == nil {
  2696. return
  2697. }
  2698. return *v, true
  2699. }
  2700. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2701. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2703. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2704. if !m.op.Is(OpUpdateOne) {
  2705. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2706. }
  2707. if m.id == nil || m.oldValue == nil {
  2708. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2709. }
  2710. oldValue, err := m.oldValue(ctx)
  2711. if err != nil {
  2712. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2713. }
  2714. return oldValue.AccessKeySecret, nil
  2715. }
  2716. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2717. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2718. m.access_key_secret = nil
  2719. }
  2720. // SetAppID sets the "app_id" field.
  2721. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2722. m.app_id = &s
  2723. }
  2724. // AppID returns the value of the "app_id" field in the mutation.
  2725. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2726. v := m.app_id
  2727. if v == nil {
  2728. return
  2729. }
  2730. return *v, true
  2731. }
  2732. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2733. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2735. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2736. if !m.op.Is(OpUpdateOne) {
  2737. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2738. }
  2739. if m.id == nil || m.oldValue == nil {
  2740. return v, errors.New("OldAppID requires an ID field in the mutation")
  2741. }
  2742. oldValue, err := m.oldValue(ctx)
  2743. if err != nil {
  2744. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2745. }
  2746. return oldValue.AppID, nil
  2747. }
  2748. // ClearAppID clears the value of the "app_id" field.
  2749. func (m *AliyunAvatarMutation) ClearAppID() {
  2750. m.app_id = nil
  2751. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2752. }
  2753. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2754. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2755. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2756. return ok
  2757. }
  2758. // ResetAppID resets all changes to the "app_id" field.
  2759. func (m *AliyunAvatarMutation) ResetAppID() {
  2760. m.app_id = nil
  2761. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2762. }
  2763. // SetTenantID sets the "tenant_id" field.
  2764. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2765. m.tenant_id = &u
  2766. m.addtenant_id = nil
  2767. }
  2768. // TenantID returns the value of the "tenant_id" field in the mutation.
  2769. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2770. v := m.tenant_id
  2771. if v == nil {
  2772. return
  2773. }
  2774. return *v, true
  2775. }
  2776. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2777. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2779. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2780. if !m.op.Is(OpUpdateOne) {
  2781. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2782. }
  2783. if m.id == nil || m.oldValue == nil {
  2784. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2785. }
  2786. oldValue, err := m.oldValue(ctx)
  2787. if err != nil {
  2788. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2789. }
  2790. return oldValue.TenantID, nil
  2791. }
  2792. // AddTenantID adds u to the "tenant_id" field.
  2793. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2794. if m.addtenant_id != nil {
  2795. *m.addtenant_id += u
  2796. } else {
  2797. m.addtenant_id = &u
  2798. }
  2799. }
  2800. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2801. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2802. v := m.addtenant_id
  2803. if v == nil {
  2804. return
  2805. }
  2806. return *v, true
  2807. }
  2808. // ResetTenantID resets all changes to the "tenant_id" field.
  2809. func (m *AliyunAvatarMutation) ResetTenantID() {
  2810. m.tenant_id = nil
  2811. m.addtenant_id = nil
  2812. }
  2813. // SetResponse sets the "response" field.
  2814. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2815. m.response = &s
  2816. }
  2817. // Response returns the value of the "response" field in the mutation.
  2818. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2819. v := m.response
  2820. if v == nil {
  2821. return
  2822. }
  2823. return *v, true
  2824. }
  2825. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2826. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2828. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2829. if !m.op.Is(OpUpdateOne) {
  2830. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2831. }
  2832. if m.id == nil || m.oldValue == nil {
  2833. return v, errors.New("OldResponse requires an ID field in the mutation")
  2834. }
  2835. oldValue, err := m.oldValue(ctx)
  2836. if err != nil {
  2837. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2838. }
  2839. return oldValue.Response, nil
  2840. }
  2841. // ResetResponse resets all changes to the "response" field.
  2842. func (m *AliyunAvatarMutation) ResetResponse() {
  2843. m.response = nil
  2844. }
  2845. // SetToken sets the "token" field.
  2846. func (m *AliyunAvatarMutation) SetToken(s string) {
  2847. m.token = &s
  2848. }
  2849. // Token returns the value of the "token" field in the mutation.
  2850. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2851. v := m.token
  2852. if v == nil {
  2853. return
  2854. }
  2855. return *v, true
  2856. }
  2857. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2858. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2860. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2861. if !m.op.Is(OpUpdateOne) {
  2862. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2863. }
  2864. if m.id == nil || m.oldValue == nil {
  2865. return v, errors.New("OldToken requires an ID field in the mutation")
  2866. }
  2867. oldValue, err := m.oldValue(ctx)
  2868. if err != nil {
  2869. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2870. }
  2871. return oldValue.Token, nil
  2872. }
  2873. // ResetToken resets all changes to the "token" field.
  2874. func (m *AliyunAvatarMutation) ResetToken() {
  2875. m.token = nil
  2876. }
  2877. // SetSessionID sets the "session_id" field.
  2878. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2879. m.session_id = &s
  2880. }
  2881. // SessionID returns the value of the "session_id" field in the mutation.
  2882. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2883. v := m.session_id
  2884. if v == nil {
  2885. return
  2886. }
  2887. return *v, true
  2888. }
  2889. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2890. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2892. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2893. if !m.op.Is(OpUpdateOne) {
  2894. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2895. }
  2896. if m.id == nil || m.oldValue == nil {
  2897. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2898. }
  2899. oldValue, err := m.oldValue(ctx)
  2900. if err != nil {
  2901. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2902. }
  2903. return oldValue.SessionID, nil
  2904. }
  2905. // ResetSessionID resets all changes to the "session_id" field.
  2906. func (m *AliyunAvatarMutation) ResetSessionID() {
  2907. m.session_id = nil
  2908. }
  2909. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2910. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2911. m.predicates = append(m.predicates, ps...)
  2912. }
  2913. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2914. // users can use type-assertion to append predicates that do not depend on any generated package.
  2915. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2916. p := make([]predicate.AliyunAvatar, len(ps))
  2917. for i := range ps {
  2918. p[i] = ps[i]
  2919. }
  2920. m.Where(p...)
  2921. }
  2922. // Op returns the operation name.
  2923. func (m *AliyunAvatarMutation) Op() Op {
  2924. return m.op
  2925. }
  2926. // SetOp allows setting the mutation operation.
  2927. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2928. m.op = op
  2929. }
  2930. // Type returns the node type of this mutation (AliyunAvatar).
  2931. func (m *AliyunAvatarMutation) Type() string {
  2932. return m.typ
  2933. }
  2934. // Fields returns all fields that were changed during this mutation. Note that in
  2935. // order to get all numeric fields that were incremented/decremented, call
  2936. // AddedFields().
  2937. func (m *AliyunAvatarMutation) Fields() []string {
  2938. fields := make([]string, 0, 12)
  2939. if m.created_at != nil {
  2940. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2941. }
  2942. if m.updated_at != nil {
  2943. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2944. }
  2945. if m.deleted_at != nil {
  2946. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2947. }
  2948. if m.user_id != nil {
  2949. fields = append(fields, aliyunavatar.FieldUserID)
  2950. }
  2951. if m.biz_id != nil {
  2952. fields = append(fields, aliyunavatar.FieldBizID)
  2953. }
  2954. if m.access_key_id != nil {
  2955. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2956. }
  2957. if m.access_key_secret != nil {
  2958. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2959. }
  2960. if m.app_id != nil {
  2961. fields = append(fields, aliyunavatar.FieldAppID)
  2962. }
  2963. if m.tenant_id != nil {
  2964. fields = append(fields, aliyunavatar.FieldTenantID)
  2965. }
  2966. if m.response != nil {
  2967. fields = append(fields, aliyunavatar.FieldResponse)
  2968. }
  2969. if m.token != nil {
  2970. fields = append(fields, aliyunavatar.FieldToken)
  2971. }
  2972. if m.session_id != nil {
  2973. fields = append(fields, aliyunavatar.FieldSessionID)
  2974. }
  2975. return fields
  2976. }
  2977. // Field returns the value of a field with the given name. The second boolean
  2978. // return value indicates that this field was not set, or was not defined in the
  2979. // schema.
  2980. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2981. switch name {
  2982. case aliyunavatar.FieldCreatedAt:
  2983. return m.CreatedAt()
  2984. case aliyunavatar.FieldUpdatedAt:
  2985. return m.UpdatedAt()
  2986. case aliyunavatar.FieldDeletedAt:
  2987. return m.DeletedAt()
  2988. case aliyunavatar.FieldUserID:
  2989. return m.UserID()
  2990. case aliyunavatar.FieldBizID:
  2991. return m.BizID()
  2992. case aliyunavatar.FieldAccessKeyID:
  2993. return m.AccessKeyID()
  2994. case aliyunavatar.FieldAccessKeySecret:
  2995. return m.AccessKeySecret()
  2996. case aliyunavatar.FieldAppID:
  2997. return m.AppID()
  2998. case aliyunavatar.FieldTenantID:
  2999. return m.TenantID()
  3000. case aliyunavatar.FieldResponse:
  3001. return m.Response()
  3002. case aliyunavatar.FieldToken:
  3003. return m.Token()
  3004. case aliyunavatar.FieldSessionID:
  3005. return m.SessionID()
  3006. }
  3007. return nil, false
  3008. }
  3009. // OldField returns the old value of the field from the database. An error is
  3010. // returned if the mutation operation is not UpdateOne, or the query to the
  3011. // database failed.
  3012. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3013. switch name {
  3014. case aliyunavatar.FieldCreatedAt:
  3015. return m.OldCreatedAt(ctx)
  3016. case aliyunavatar.FieldUpdatedAt:
  3017. return m.OldUpdatedAt(ctx)
  3018. case aliyunavatar.FieldDeletedAt:
  3019. return m.OldDeletedAt(ctx)
  3020. case aliyunavatar.FieldUserID:
  3021. return m.OldUserID(ctx)
  3022. case aliyunavatar.FieldBizID:
  3023. return m.OldBizID(ctx)
  3024. case aliyunavatar.FieldAccessKeyID:
  3025. return m.OldAccessKeyID(ctx)
  3026. case aliyunavatar.FieldAccessKeySecret:
  3027. return m.OldAccessKeySecret(ctx)
  3028. case aliyunavatar.FieldAppID:
  3029. return m.OldAppID(ctx)
  3030. case aliyunavatar.FieldTenantID:
  3031. return m.OldTenantID(ctx)
  3032. case aliyunavatar.FieldResponse:
  3033. return m.OldResponse(ctx)
  3034. case aliyunavatar.FieldToken:
  3035. return m.OldToken(ctx)
  3036. case aliyunavatar.FieldSessionID:
  3037. return m.OldSessionID(ctx)
  3038. }
  3039. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3040. }
  3041. // SetField sets the value of a field with the given name. It returns an error if
  3042. // the field is not defined in the schema, or if the type mismatched the field
  3043. // type.
  3044. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3045. switch name {
  3046. case aliyunavatar.FieldCreatedAt:
  3047. v, ok := value.(time.Time)
  3048. if !ok {
  3049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3050. }
  3051. m.SetCreatedAt(v)
  3052. return nil
  3053. case aliyunavatar.FieldUpdatedAt:
  3054. v, ok := value.(time.Time)
  3055. if !ok {
  3056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3057. }
  3058. m.SetUpdatedAt(v)
  3059. return nil
  3060. case aliyunavatar.FieldDeletedAt:
  3061. v, ok := value.(time.Time)
  3062. if !ok {
  3063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3064. }
  3065. m.SetDeletedAt(v)
  3066. return nil
  3067. case aliyunavatar.FieldUserID:
  3068. v, ok := value.(uint64)
  3069. if !ok {
  3070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3071. }
  3072. m.SetUserID(v)
  3073. return nil
  3074. case aliyunavatar.FieldBizID:
  3075. v, ok := value.(string)
  3076. if !ok {
  3077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3078. }
  3079. m.SetBizID(v)
  3080. return nil
  3081. case aliyunavatar.FieldAccessKeyID:
  3082. v, ok := value.(string)
  3083. if !ok {
  3084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3085. }
  3086. m.SetAccessKeyID(v)
  3087. return nil
  3088. case aliyunavatar.FieldAccessKeySecret:
  3089. v, ok := value.(string)
  3090. if !ok {
  3091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3092. }
  3093. m.SetAccessKeySecret(v)
  3094. return nil
  3095. case aliyunavatar.FieldAppID:
  3096. v, ok := value.(string)
  3097. if !ok {
  3098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3099. }
  3100. m.SetAppID(v)
  3101. return nil
  3102. case aliyunavatar.FieldTenantID:
  3103. v, ok := value.(uint64)
  3104. if !ok {
  3105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3106. }
  3107. m.SetTenantID(v)
  3108. return nil
  3109. case aliyunavatar.FieldResponse:
  3110. v, ok := value.(string)
  3111. if !ok {
  3112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3113. }
  3114. m.SetResponse(v)
  3115. return nil
  3116. case aliyunavatar.FieldToken:
  3117. v, ok := value.(string)
  3118. if !ok {
  3119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3120. }
  3121. m.SetToken(v)
  3122. return nil
  3123. case aliyunavatar.FieldSessionID:
  3124. v, ok := value.(string)
  3125. if !ok {
  3126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3127. }
  3128. m.SetSessionID(v)
  3129. return nil
  3130. }
  3131. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3132. }
  3133. // AddedFields returns all numeric fields that were incremented/decremented during
  3134. // this mutation.
  3135. func (m *AliyunAvatarMutation) AddedFields() []string {
  3136. var fields []string
  3137. if m.adduser_id != nil {
  3138. fields = append(fields, aliyunavatar.FieldUserID)
  3139. }
  3140. if m.addtenant_id != nil {
  3141. fields = append(fields, aliyunavatar.FieldTenantID)
  3142. }
  3143. return fields
  3144. }
  3145. // AddedField returns the numeric value that was incremented/decremented on a field
  3146. // with the given name. The second boolean return value indicates that this field
  3147. // was not set, or was not defined in the schema.
  3148. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3149. switch name {
  3150. case aliyunavatar.FieldUserID:
  3151. return m.AddedUserID()
  3152. case aliyunavatar.FieldTenantID:
  3153. return m.AddedTenantID()
  3154. }
  3155. return nil, false
  3156. }
  3157. // AddField adds the value to the field with the given name. It returns an error if
  3158. // the field is not defined in the schema, or if the type mismatched the field
  3159. // type.
  3160. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3161. switch name {
  3162. case aliyunavatar.FieldUserID:
  3163. v, ok := value.(int64)
  3164. if !ok {
  3165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3166. }
  3167. m.AddUserID(v)
  3168. return nil
  3169. case aliyunavatar.FieldTenantID:
  3170. v, ok := value.(int64)
  3171. if !ok {
  3172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3173. }
  3174. m.AddTenantID(v)
  3175. return nil
  3176. }
  3177. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3178. }
  3179. // ClearedFields returns all nullable fields that were cleared during this
  3180. // mutation.
  3181. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3182. var fields []string
  3183. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3184. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3185. }
  3186. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3187. fields = append(fields, aliyunavatar.FieldAppID)
  3188. }
  3189. return fields
  3190. }
  3191. // FieldCleared returns a boolean indicating if a field with the given name was
  3192. // cleared in this mutation.
  3193. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3194. _, ok := m.clearedFields[name]
  3195. return ok
  3196. }
  3197. // ClearField clears the value of the field with the given name. It returns an
  3198. // error if the field is not defined in the schema.
  3199. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3200. switch name {
  3201. case aliyunavatar.FieldDeletedAt:
  3202. m.ClearDeletedAt()
  3203. return nil
  3204. case aliyunavatar.FieldAppID:
  3205. m.ClearAppID()
  3206. return nil
  3207. }
  3208. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3209. }
  3210. // ResetField resets all changes in the mutation for the field with the given name.
  3211. // It returns an error if the field is not defined in the schema.
  3212. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3213. switch name {
  3214. case aliyunavatar.FieldCreatedAt:
  3215. m.ResetCreatedAt()
  3216. return nil
  3217. case aliyunavatar.FieldUpdatedAt:
  3218. m.ResetUpdatedAt()
  3219. return nil
  3220. case aliyunavatar.FieldDeletedAt:
  3221. m.ResetDeletedAt()
  3222. return nil
  3223. case aliyunavatar.FieldUserID:
  3224. m.ResetUserID()
  3225. return nil
  3226. case aliyunavatar.FieldBizID:
  3227. m.ResetBizID()
  3228. return nil
  3229. case aliyunavatar.FieldAccessKeyID:
  3230. m.ResetAccessKeyID()
  3231. return nil
  3232. case aliyunavatar.FieldAccessKeySecret:
  3233. m.ResetAccessKeySecret()
  3234. return nil
  3235. case aliyunavatar.FieldAppID:
  3236. m.ResetAppID()
  3237. return nil
  3238. case aliyunavatar.FieldTenantID:
  3239. m.ResetTenantID()
  3240. return nil
  3241. case aliyunavatar.FieldResponse:
  3242. m.ResetResponse()
  3243. return nil
  3244. case aliyunavatar.FieldToken:
  3245. m.ResetToken()
  3246. return nil
  3247. case aliyunavatar.FieldSessionID:
  3248. m.ResetSessionID()
  3249. return nil
  3250. }
  3251. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3252. }
  3253. // AddedEdges returns all edge names that were set/added in this mutation.
  3254. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3255. edges := make([]string, 0, 0)
  3256. return edges
  3257. }
  3258. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3259. // name in this mutation.
  3260. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3261. return nil
  3262. }
  3263. // RemovedEdges returns all edge names that were removed in this mutation.
  3264. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3265. edges := make([]string, 0, 0)
  3266. return edges
  3267. }
  3268. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3269. // the given name in this mutation.
  3270. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3271. return nil
  3272. }
  3273. // ClearedEdges returns all edge names that were cleared in this mutation.
  3274. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3275. edges := make([]string, 0, 0)
  3276. return edges
  3277. }
  3278. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3279. // was cleared in this mutation.
  3280. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3281. return false
  3282. }
  3283. // ClearEdge clears the value of the edge with the given name. It returns an error
  3284. // if that edge is not defined in the schema.
  3285. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3286. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3287. }
  3288. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3289. // It returns an error if the edge is not defined in the schema.
  3290. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3291. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3292. }
  3293. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3294. type AllocAgentMutation struct {
  3295. config
  3296. op Op
  3297. typ string
  3298. id *uint64
  3299. created_at *time.Time
  3300. updated_at *time.Time
  3301. deleted_at *time.Time
  3302. user_id *string
  3303. organization_id *uint64
  3304. addorganization_id *int64
  3305. agents *[]uint64
  3306. appendagents []uint64
  3307. status *int
  3308. addstatus *int
  3309. clearedFields map[string]struct{}
  3310. done bool
  3311. oldValue func(context.Context) (*AllocAgent, error)
  3312. predicates []predicate.AllocAgent
  3313. }
  3314. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3315. // allocagentOption allows management of the mutation configuration using functional options.
  3316. type allocagentOption func(*AllocAgentMutation)
  3317. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3318. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3319. m := &AllocAgentMutation{
  3320. config: c,
  3321. op: op,
  3322. typ: TypeAllocAgent,
  3323. clearedFields: make(map[string]struct{}),
  3324. }
  3325. for _, opt := range opts {
  3326. opt(m)
  3327. }
  3328. return m
  3329. }
  3330. // withAllocAgentID sets the ID field of the mutation.
  3331. func withAllocAgentID(id uint64) allocagentOption {
  3332. return func(m *AllocAgentMutation) {
  3333. var (
  3334. err error
  3335. once sync.Once
  3336. value *AllocAgent
  3337. )
  3338. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3339. once.Do(func() {
  3340. if m.done {
  3341. err = errors.New("querying old values post mutation is not allowed")
  3342. } else {
  3343. value, err = m.Client().AllocAgent.Get(ctx, id)
  3344. }
  3345. })
  3346. return value, err
  3347. }
  3348. m.id = &id
  3349. }
  3350. }
  3351. // withAllocAgent sets the old AllocAgent of the mutation.
  3352. func withAllocAgent(node *AllocAgent) allocagentOption {
  3353. return func(m *AllocAgentMutation) {
  3354. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3355. return node, nil
  3356. }
  3357. m.id = &node.ID
  3358. }
  3359. }
  3360. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3361. // executed in a transaction (ent.Tx), a transactional client is returned.
  3362. func (m AllocAgentMutation) Client() *Client {
  3363. client := &Client{config: m.config}
  3364. client.init()
  3365. return client
  3366. }
  3367. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3368. // it returns an error otherwise.
  3369. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3370. if _, ok := m.driver.(*txDriver); !ok {
  3371. return nil, errors.New("ent: mutation is not running in a transaction")
  3372. }
  3373. tx := &Tx{config: m.config}
  3374. tx.init()
  3375. return tx, nil
  3376. }
  3377. // SetID sets the value of the id field. Note that this
  3378. // operation is only accepted on creation of AllocAgent entities.
  3379. func (m *AllocAgentMutation) SetID(id uint64) {
  3380. m.id = &id
  3381. }
  3382. // ID returns the ID value in the mutation. Note that the ID is only available
  3383. // if it was provided to the builder or after it was returned from the database.
  3384. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3385. if m.id == nil {
  3386. return
  3387. }
  3388. return *m.id, true
  3389. }
  3390. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3391. // That means, if the mutation is applied within a transaction with an isolation level such
  3392. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3393. // or updated by the mutation.
  3394. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3395. switch {
  3396. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3397. id, exists := m.ID()
  3398. if exists {
  3399. return []uint64{id}, nil
  3400. }
  3401. fallthrough
  3402. case m.op.Is(OpUpdate | OpDelete):
  3403. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3404. default:
  3405. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3406. }
  3407. }
  3408. // SetCreatedAt sets the "created_at" field.
  3409. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3410. m.created_at = &t
  3411. }
  3412. // CreatedAt returns the value of the "created_at" field in the mutation.
  3413. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3414. v := m.created_at
  3415. if v == nil {
  3416. return
  3417. }
  3418. return *v, true
  3419. }
  3420. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3421. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3423. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3424. if !m.op.Is(OpUpdateOne) {
  3425. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3426. }
  3427. if m.id == nil || m.oldValue == nil {
  3428. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3429. }
  3430. oldValue, err := m.oldValue(ctx)
  3431. if err != nil {
  3432. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3433. }
  3434. return oldValue.CreatedAt, nil
  3435. }
  3436. // ResetCreatedAt resets all changes to the "created_at" field.
  3437. func (m *AllocAgentMutation) ResetCreatedAt() {
  3438. m.created_at = nil
  3439. }
  3440. // SetUpdatedAt sets the "updated_at" field.
  3441. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3442. m.updated_at = &t
  3443. }
  3444. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3445. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3446. v := m.updated_at
  3447. if v == nil {
  3448. return
  3449. }
  3450. return *v, true
  3451. }
  3452. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3453. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3455. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3456. if !m.op.Is(OpUpdateOne) {
  3457. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3458. }
  3459. if m.id == nil || m.oldValue == nil {
  3460. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3461. }
  3462. oldValue, err := m.oldValue(ctx)
  3463. if err != nil {
  3464. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3465. }
  3466. return oldValue.UpdatedAt, nil
  3467. }
  3468. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3469. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3470. m.updated_at = nil
  3471. }
  3472. // SetDeletedAt sets the "deleted_at" field.
  3473. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3474. m.deleted_at = &t
  3475. }
  3476. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3477. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3478. v := m.deleted_at
  3479. if v == nil {
  3480. return
  3481. }
  3482. return *v, true
  3483. }
  3484. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3485. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3487. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3488. if !m.op.Is(OpUpdateOne) {
  3489. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3490. }
  3491. if m.id == nil || m.oldValue == nil {
  3492. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3493. }
  3494. oldValue, err := m.oldValue(ctx)
  3495. if err != nil {
  3496. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3497. }
  3498. return oldValue.DeletedAt, nil
  3499. }
  3500. // ClearDeletedAt clears the value of the "deleted_at" field.
  3501. func (m *AllocAgentMutation) ClearDeletedAt() {
  3502. m.deleted_at = nil
  3503. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3504. }
  3505. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3506. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3507. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3508. return ok
  3509. }
  3510. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3511. func (m *AllocAgentMutation) ResetDeletedAt() {
  3512. m.deleted_at = nil
  3513. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3514. }
  3515. // SetUserID sets the "user_id" field.
  3516. func (m *AllocAgentMutation) SetUserID(s string) {
  3517. m.user_id = &s
  3518. }
  3519. // UserID returns the value of the "user_id" field in the mutation.
  3520. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3521. v := m.user_id
  3522. if v == nil {
  3523. return
  3524. }
  3525. return *v, true
  3526. }
  3527. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3528. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3530. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3531. if !m.op.Is(OpUpdateOne) {
  3532. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3533. }
  3534. if m.id == nil || m.oldValue == nil {
  3535. return v, errors.New("OldUserID requires an ID field in the mutation")
  3536. }
  3537. oldValue, err := m.oldValue(ctx)
  3538. if err != nil {
  3539. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3540. }
  3541. return oldValue.UserID, nil
  3542. }
  3543. // ClearUserID clears the value of the "user_id" field.
  3544. func (m *AllocAgentMutation) ClearUserID() {
  3545. m.user_id = nil
  3546. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3547. }
  3548. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3549. func (m *AllocAgentMutation) UserIDCleared() bool {
  3550. _, ok := m.clearedFields[allocagent.FieldUserID]
  3551. return ok
  3552. }
  3553. // ResetUserID resets all changes to the "user_id" field.
  3554. func (m *AllocAgentMutation) ResetUserID() {
  3555. m.user_id = nil
  3556. delete(m.clearedFields, allocagent.FieldUserID)
  3557. }
  3558. // SetOrganizationID sets the "organization_id" field.
  3559. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3560. m.organization_id = &u
  3561. m.addorganization_id = nil
  3562. }
  3563. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3564. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3565. v := m.organization_id
  3566. if v == nil {
  3567. return
  3568. }
  3569. return *v, true
  3570. }
  3571. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3572. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3574. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3575. if !m.op.Is(OpUpdateOne) {
  3576. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3577. }
  3578. if m.id == nil || m.oldValue == nil {
  3579. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3580. }
  3581. oldValue, err := m.oldValue(ctx)
  3582. if err != nil {
  3583. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3584. }
  3585. return oldValue.OrganizationID, nil
  3586. }
  3587. // AddOrganizationID adds u to the "organization_id" field.
  3588. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3589. if m.addorganization_id != nil {
  3590. *m.addorganization_id += u
  3591. } else {
  3592. m.addorganization_id = &u
  3593. }
  3594. }
  3595. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3596. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3597. v := m.addorganization_id
  3598. if v == nil {
  3599. return
  3600. }
  3601. return *v, true
  3602. }
  3603. // ClearOrganizationID clears the value of the "organization_id" field.
  3604. func (m *AllocAgentMutation) ClearOrganizationID() {
  3605. m.organization_id = nil
  3606. m.addorganization_id = nil
  3607. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3608. }
  3609. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3610. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3611. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3612. return ok
  3613. }
  3614. // ResetOrganizationID resets all changes to the "organization_id" field.
  3615. func (m *AllocAgentMutation) ResetOrganizationID() {
  3616. m.organization_id = nil
  3617. m.addorganization_id = nil
  3618. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3619. }
  3620. // SetAgents sets the "agents" field.
  3621. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3622. m.agents = &u
  3623. m.appendagents = nil
  3624. }
  3625. // Agents returns the value of the "agents" field in the mutation.
  3626. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3627. v := m.agents
  3628. if v == nil {
  3629. return
  3630. }
  3631. return *v, true
  3632. }
  3633. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3634. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3636. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3637. if !m.op.Is(OpUpdateOne) {
  3638. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3639. }
  3640. if m.id == nil || m.oldValue == nil {
  3641. return v, errors.New("OldAgents requires an ID field in the mutation")
  3642. }
  3643. oldValue, err := m.oldValue(ctx)
  3644. if err != nil {
  3645. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3646. }
  3647. return oldValue.Agents, nil
  3648. }
  3649. // AppendAgents adds u to the "agents" field.
  3650. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3651. m.appendagents = append(m.appendagents, u...)
  3652. }
  3653. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3654. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3655. if len(m.appendagents) == 0 {
  3656. return nil, false
  3657. }
  3658. return m.appendagents, true
  3659. }
  3660. // ResetAgents resets all changes to the "agents" field.
  3661. func (m *AllocAgentMutation) ResetAgents() {
  3662. m.agents = nil
  3663. m.appendagents = nil
  3664. }
  3665. // SetStatus sets the "status" field.
  3666. func (m *AllocAgentMutation) SetStatus(i int) {
  3667. m.status = &i
  3668. m.addstatus = nil
  3669. }
  3670. // Status returns the value of the "status" field in the mutation.
  3671. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3672. v := m.status
  3673. if v == nil {
  3674. return
  3675. }
  3676. return *v, true
  3677. }
  3678. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3679. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3681. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3682. if !m.op.Is(OpUpdateOne) {
  3683. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3684. }
  3685. if m.id == nil || m.oldValue == nil {
  3686. return v, errors.New("OldStatus requires an ID field in the mutation")
  3687. }
  3688. oldValue, err := m.oldValue(ctx)
  3689. if err != nil {
  3690. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3691. }
  3692. return oldValue.Status, nil
  3693. }
  3694. // AddStatus adds i to the "status" field.
  3695. func (m *AllocAgentMutation) AddStatus(i int) {
  3696. if m.addstatus != nil {
  3697. *m.addstatus += i
  3698. } else {
  3699. m.addstatus = &i
  3700. }
  3701. }
  3702. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3703. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3704. v := m.addstatus
  3705. if v == nil {
  3706. return
  3707. }
  3708. return *v, true
  3709. }
  3710. // ClearStatus clears the value of the "status" field.
  3711. func (m *AllocAgentMutation) ClearStatus() {
  3712. m.status = nil
  3713. m.addstatus = nil
  3714. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3715. }
  3716. // StatusCleared returns if the "status" field was cleared in this mutation.
  3717. func (m *AllocAgentMutation) StatusCleared() bool {
  3718. _, ok := m.clearedFields[allocagent.FieldStatus]
  3719. return ok
  3720. }
  3721. // ResetStatus resets all changes to the "status" field.
  3722. func (m *AllocAgentMutation) ResetStatus() {
  3723. m.status = nil
  3724. m.addstatus = nil
  3725. delete(m.clearedFields, allocagent.FieldStatus)
  3726. }
  3727. // Where appends a list predicates to the AllocAgentMutation builder.
  3728. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3729. m.predicates = append(m.predicates, ps...)
  3730. }
  3731. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3732. // users can use type-assertion to append predicates that do not depend on any generated package.
  3733. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3734. p := make([]predicate.AllocAgent, len(ps))
  3735. for i := range ps {
  3736. p[i] = ps[i]
  3737. }
  3738. m.Where(p...)
  3739. }
  3740. // Op returns the operation name.
  3741. func (m *AllocAgentMutation) Op() Op {
  3742. return m.op
  3743. }
  3744. // SetOp allows setting the mutation operation.
  3745. func (m *AllocAgentMutation) SetOp(op Op) {
  3746. m.op = op
  3747. }
  3748. // Type returns the node type of this mutation (AllocAgent).
  3749. func (m *AllocAgentMutation) Type() string {
  3750. return m.typ
  3751. }
  3752. // Fields returns all fields that were changed during this mutation. Note that in
  3753. // order to get all numeric fields that were incremented/decremented, call
  3754. // AddedFields().
  3755. func (m *AllocAgentMutation) Fields() []string {
  3756. fields := make([]string, 0, 7)
  3757. if m.created_at != nil {
  3758. fields = append(fields, allocagent.FieldCreatedAt)
  3759. }
  3760. if m.updated_at != nil {
  3761. fields = append(fields, allocagent.FieldUpdatedAt)
  3762. }
  3763. if m.deleted_at != nil {
  3764. fields = append(fields, allocagent.FieldDeletedAt)
  3765. }
  3766. if m.user_id != nil {
  3767. fields = append(fields, allocagent.FieldUserID)
  3768. }
  3769. if m.organization_id != nil {
  3770. fields = append(fields, allocagent.FieldOrganizationID)
  3771. }
  3772. if m.agents != nil {
  3773. fields = append(fields, allocagent.FieldAgents)
  3774. }
  3775. if m.status != nil {
  3776. fields = append(fields, allocagent.FieldStatus)
  3777. }
  3778. return fields
  3779. }
  3780. // Field returns the value of a field with the given name. The second boolean
  3781. // return value indicates that this field was not set, or was not defined in the
  3782. // schema.
  3783. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3784. switch name {
  3785. case allocagent.FieldCreatedAt:
  3786. return m.CreatedAt()
  3787. case allocagent.FieldUpdatedAt:
  3788. return m.UpdatedAt()
  3789. case allocagent.FieldDeletedAt:
  3790. return m.DeletedAt()
  3791. case allocagent.FieldUserID:
  3792. return m.UserID()
  3793. case allocagent.FieldOrganizationID:
  3794. return m.OrganizationID()
  3795. case allocagent.FieldAgents:
  3796. return m.Agents()
  3797. case allocagent.FieldStatus:
  3798. return m.Status()
  3799. }
  3800. return nil, false
  3801. }
  3802. // OldField returns the old value of the field from the database. An error is
  3803. // returned if the mutation operation is not UpdateOne, or the query to the
  3804. // database failed.
  3805. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3806. switch name {
  3807. case allocagent.FieldCreatedAt:
  3808. return m.OldCreatedAt(ctx)
  3809. case allocagent.FieldUpdatedAt:
  3810. return m.OldUpdatedAt(ctx)
  3811. case allocagent.FieldDeletedAt:
  3812. return m.OldDeletedAt(ctx)
  3813. case allocagent.FieldUserID:
  3814. return m.OldUserID(ctx)
  3815. case allocagent.FieldOrganizationID:
  3816. return m.OldOrganizationID(ctx)
  3817. case allocagent.FieldAgents:
  3818. return m.OldAgents(ctx)
  3819. case allocagent.FieldStatus:
  3820. return m.OldStatus(ctx)
  3821. }
  3822. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3823. }
  3824. // SetField sets the value of a field with the given name. It returns an error if
  3825. // the field is not defined in the schema, or if the type mismatched the field
  3826. // type.
  3827. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3828. switch name {
  3829. case allocagent.FieldCreatedAt:
  3830. v, ok := value.(time.Time)
  3831. if !ok {
  3832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3833. }
  3834. m.SetCreatedAt(v)
  3835. return nil
  3836. case allocagent.FieldUpdatedAt:
  3837. v, ok := value.(time.Time)
  3838. if !ok {
  3839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3840. }
  3841. m.SetUpdatedAt(v)
  3842. return nil
  3843. case allocagent.FieldDeletedAt:
  3844. v, ok := value.(time.Time)
  3845. if !ok {
  3846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3847. }
  3848. m.SetDeletedAt(v)
  3849. return nil
  3850. case allocagent.FieldUserID:
  3851. v, ok := value.(string)
  3852. if !ok {
  3853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3854. }
  3855. m.SetUserID(v)
  3856. return nil
  3857. case allocagent.FieldOrganizationID:
  3858. v, ok := value.(uint64)
  3859. if !ok {
  3860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3861. }
  3862. m.SetOrganizationID(v)
  3863. return nil
  3864. case allocagent.FieldAgents:
  3865. v, ok := value.([]uint64)
  3866. if !ok {
  3867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3868. }
  3869. m.SetAgents(v)
  3870. return nil
  3871. case allocagent.FieldStatus:
  3872. v, ok := value.(int)
  3873. if !ok {
  3874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3875. }
  3876. m.SetStatus(v)
  3877. return nil
  3878. }
  3879. return fmt.Errorf("unknown AllocAgent field %s", name)
  3880. }
  3881. // AddedFields returns all numeric fields that were incremented/decremented during
  3882. // this mutation.
  3883. func (m *AllocAgentMutation) AddedFields() []string {
  3884. var fields []string
  3885. if m.addorganization_id != nil {
  3886. fields = append(fields, allocagent.FieldOrganizationID)
  3887. }
  3888. if m.addstatus != nil {
  3889. fields = append(fields, allocagent.FieldStatus)
  3890. }
  3891. return fields
  3892. }
  3893. // AddedField returns the numeric value that was incremented/decremented on a field
  3894. // with the given name. The second boolean return value indicates that this field
  3895. // was not set, or was not defined in the schema.
  3896. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3897. switch name {
  3898. case allocagent.FieldOrganizationID:
  3899. return m.AddedOrganizationID()
  3900. case allocagent.FieldStatus:
  3901. return m.AddedStatus()
  3902. }
  3903. return nil, false
  3904. }
  3905. // AddField adds the value to the field with the given name. It returns an error if
  3906. // the field is not defined in the schema, or if the type mismatched the field
  3907. // type.
  3908. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3909. switch name {
  3910. case allocagent.FieldOrganizationID:
  3911. v, ok := value.(int64)
  3912. if !ok {
  3913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3914. }
  3915. m.AddOrganizationID(v)
  3916. return nil
  3917. case allocagent.FieldStatus:
  3918. v, ok := value.(int)
  3919. if !ok {
  3920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3921. }
  3922. m.AddStatus(v)
  3923. return nil
  3924. }
  3925. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3926. }
  3927. // ClearedFields returns all nullable fields that were cleared during this
  3928. // mutation.
  3929. func (m *AllocAgentMutation) ClearedFields() []string {
  3930. var fields []string
  3931. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3932. fields = append(fields, allocagent.FieldDeletedAt)
  3933. }
  3934. if m.FieldCleared(allocagent.FieldUserID) {
  3935. fields = append(fields, allocagent.FieldUserID)
  3936. }
  3937. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3938. fields = append(fields, allocagent.FieldOrganizationID)
  3939. }
  3940. if m.FieldCleared(allocagent.FieldStatus) {
  3941. fields = append(fields, allocagent.FieldStatus)
  3942. }
  3943. return fields
  3944. }
  3945. // FieldCleared returns a boolean indicating if a field with the given name was
  3946. // cleared in this mutation.
  3947. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3948. _, ok := m.clearedFields[name]
  3949. return ok
  3950. }
  3951. // ClearField clears the value of the field with the given name. It returns an
  3952. // error if the field is not defined in the schema.
  3953. func (m *AllocAgentMutation) ClearField(name string) error {
  3954. switch name {
  3955. case allocagent.FieldDeletedAt:
  3956. m.ClearDeletedAt()
  3957. return nil
  3958. case allocagent.FieldUserID:
  3959. m.ClearUserID()
  3960. return nil
  3961. case allocagent.FieldOrganizationID:
  3962. m.ClearOrganizationID()
  3963. return nil
  3964. case allocagent.FieldStatus:
  3965. m.ClearStatus()
  3966. return nil
  3967. }
  3968. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3969. }
  3970. // ResetField resets all changes in the mutation for the field with the given name.
  3971. // It returns an error if the field is not defined in the schema.
  3972. func (m *AllocAgentMutation) ResetField(name string) error {
  3973. switch name {
  3974. case allocagent.FieldCreatedAt:
  3975. m.ResetCreatedAt()
  3976. return nil
  3977. case allocagent.FieldUpdatedAt:
  3978. m.ResetUpdatedAt()
  3979. return nil
  3980. case allocagent.FieldDeletedAt:
  3981. m.ResetDeletedAt()
  3982. return nil
  3983. case allocagent.FieldUserID:
  3984. m.ResetUserID()
  3985. return nil
  3986. case allocagent.FieldOrganizationID:
  3987. m.ResetOrganizationID()
  3988. return nil
  3989. case allocagent.FieldAgents:
  3990. m.ResetAgents()
  3991. return nil
  3992. case allocagent.FieldStatus:
  3993. m.ResetStatus()
  3994. return nil
  3995. }
  3996. return fmt.Errorf("unknown AllocAgent field %s", name)
  3997. }
  3998. // AddedEdges returns all edge names that were set/added in this mutation.
  3999. func (m *AllocAgentMutation) AddedEdges() []string {
  4000. edges := make([]string, 0, 0)
  4001. return edges
  4002. }
  4003. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4004. // name in this mutation.
  4005. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4006. return nil
  4007. }
  4008. // RemovedEdges returns all edge names that were removed in this mutation.
  4009. func (m *AllocAgentMutation) RemovedEdges() []string {
  4010. edges := make([]string, 0, 0)
  4011. return edges
  4012. }
  4013. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4014. // the given name in this mutation.
  4015. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4016. return nil
  4017. }
  4018. // ClearedEdges returns all edge names that were cleared in this mutation.
  4019. func (m *AllocAgentMutation) ClearedEdges() []string {
  4020. edges := make([]string, 0, 0)
  4021. return edges
  4022. }
  4023. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4024. // was cleared in this mutation.
  4025. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4026. return false
  4027. }
  4028. // ClearEdge clears the value of the edge with the given name. It returns an error
  4029. // if that edge is not defined in the schema.
  4030. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4031. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4032. }
  4033. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4034. // It returns an error if the edge is not defined in the schema.
  4035. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4036. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4037. }
  4038. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4039. type ApiKeyMutation struct {
  4040. config
  4041. op Op
  4042. typ string
  4043. id *uint64
  4044. created_at *time.Time
  4045. updated_at *time.Time
  4046. deleted_at *time.Time
  4047. title *string
  4048. key *string
  4049. organization_id *uint64
  4050. addorganization_id *int64
  4051. custom_agent_base *string
  4052. custom_agent_key *string
  4053. openai_base *string
  4054. openai_key *string
  4055. clearedFields map[string]struct{}
  4056. agent *uint64
  4057. clearedagent bool
  4058. done bool
  4059. oldValue func(context.Context) (*ApiKey, error)
  4060. predicates []predicate.ApiKey
  4061. }
  4062. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4063. // apikeyOption allows management of the mutation configuration using functional options.
  4064. type apikeyOption func(*ApiKeyMutation)
  4065. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4066. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4067. m := &ApiKeyMutation{
  4068. config: c,
  4069. op: op,
  4070. typ: TypeApiKey,
  4071. clearedFields: make(map[string]struct{}),
  4072. }
  4073. for _, opt := range opts {
  4074. opt(m)
  4075. }
  4076. return m
  4077. }
  4078. // withApiKeyID sets the ID field of the mutation.
  4079. func withApiKeyID(id uint64) apikeyOption {
  4080. return func(m *ApiKeyMutation) {
  4081. var (
  4082. err error
  4083. once sync.Once
  4084. value *ApiKey
  4085. )
  4086. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4087. once.Do(func() {
  4088. if m.done {
  4089. err = errors.New("querying old values post mutation is not allowed")
  4090. } else {
  4091. value, err = m.Client().ApiKey.Get(ctx, id)
  4092. }
  4093. })
  4094. return value, err
  4095. }
  4096. m.id = &id
  4097. }
  4098. }
  4099. // withApiKey sets the old ApiKey of the mutation.
  4100. func withApiKey(node *ApiKey) apikeyOption {
  4101. return func(m *ApiKeyMutation) {
  4102. m.oldValue = func(context.Context) (*ApiKey, error) {
  4103. return node, nil
  4104. }
  4105. m.id = &node.ID
  4106. }
  4107. }
  4108. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4109. // executed in a transaction (ent.Tx), a transactional client is returned.
  4110. func (m ApiKeyMutation) Client() *Client {
  4111. client := &Client{config: m.config}
  4112. client.init()
  4113. return client
  4114. }
  4115. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4116. // it returns an error otherwise.
  4117. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4118. if _, ok := m.driver.(*txDriver); !ok {
  4119. return nil, errors.New("ent: mutation is not running in a transaction")
  4120. }
  4121. tx := &Tx{config: m.config}
  4122. tx.init()
  4123. return tx, nil
  4124. }
  4125. // SetID sets the value of the id field. Note that this
  4126. // operation is only accepted on creation of ApiKey entities.
  4127. func (m *ApiKeyMutation) SetID(id uint64) {
  4128. m.id = &id
  4129. }
  4130. // ID returns the ID value in the mutation. Note that the ID is only available
  4131. // if it was provided to the builder or after it was returned from the database.
  4132. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4133. if m.id == nil {
  4134. return
  4135. }
  4136. return *m.id, true
  4137. }
  4138. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4139. // That means, if the mutation is applied within a transaction with an isolation level such
  4140. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4141. // or updated by the mutation.
  4142. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4143. switch {
  4144. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4145. id, exists := m.ID()
  4146. if exists {
  4147. return []uint64{id}, nil
  4148. }
  4149. fallthrough
  4150. case m.op.Is(OpUpdate | OpDelete):
  4151. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4152. default:
  4153. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4154. }
  4155. }
  4156. // SetCreatedAt sets the "created_at" field.
  4157. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4158. m.created_at = &t
  4159. }
  4160. // CreatedAt returns the value of the "created_at" field in the mutation.
  4161. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4162. v := m.created_at
  4163. if v == nil {
  4164. return
  4165. }
  4166. return *v, true
  4167. }
  4168. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4169. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4171. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4172. if !m.op.Is(OpUpdateOne) {
  4173. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4174. }
  4175. if m.id == nil || m.oldValue == nil {
  4176. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4177. }
  4178. oldValue, err := m.oldValue(ctx)
  4179. if err != nil {
  4180. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4181. }
  4182. return oldValue.CreatedAt, nil
  4183. }
  4184. // ResetCreatedAt resets all changes to the "created_at" field.
  4185. func (m *ApiKeyMutation) ResetCreatedAt() {
  4186. m.created_at = nil
  4187. }
  4188. // SetUpdatedAt sets the "updated_at" field.
  4189. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4190. m.updated_at = &t
  4191. }
  4192. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4193. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4194. v := m.updated_at
  4195. if v == nil {
  4196. return
  4197. }
  4198. return *v, true
  4199. }
  4200. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4201. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4203. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4204. if !m.op.Is(OpUpdateOne) {
  4205. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4206. }
  4207. if m.id == nil || m.oldValue == nil {
  4208. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4209. }
  4210. oldValue, err := m.oldValue(ctx)
  4211. if err != nil {
  4212. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4213. }
  4214. return oldValue.UpdatedAt, nil
  4215. }
  4216. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4217. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4218. m.updated_at = nil
  4219. }
  4220. // SetDeletedAt sets the "deleted_at" field.
  4221. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4222. m.deleted_at = &t
  4223. }
  4224. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4225. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4226. v := m.deleted_at
  4227. if v == nil {
  4228. return
  4229. }
  4230. return *v, true
  4231. }
  4232. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4233. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4235. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4236. if !m.op.Is(OpUpdateOne) {
  4237. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4238. }
  4239. if m.id == nil || m.oldValue == nil {
  4240. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4241. }
  4242. oldValue, err := m.oldValue(ctx)
  4243. if err != nil {
  4244. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4245. }
  4246. return oldValue.DeletedAt, nil
  4247. }
  4248. // ClearDeletedAt clears the value of the "deleted_at" field.
  4249. func (m *ApiKeyMutation) ClearDeletedAt() {
  4250. m.deleted_at = nil
  4251. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4252. }
  4253. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4254. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4255. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4256. return ok
  4257. }
  4258. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4259. func (m *ApiKeyMutation) ResetDeletedAt() {
  4260. m.deleted_at = nil
  4261. delete(m.clearedFields, apikey.FieldDeletedAt)
  4262. }
  4263. // SetTitle sets the "title" field.
  4264. func (m *ApiKeyMutation) SetTitle(s string) {
  4265. m.title = &s
  4266. }
  4267. // Title returns the value of the "title" field in the mutation.
  4268. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4269. v := m.title
  4270. if v == nil {
  4271. return
  4272. }
  4273. return *v, true
  4274. }
  4275. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4276. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4278. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4279. if !m.op.Is(OpUpdateOne) {
  4280. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4281. }
  4282. if m.id == nil || m.oldValue == nil {
  4283. return v, errors.New("OldTitle requires an ID field in the mutation")
  4284. }
  4285. oldValue, err := m.oldValue(ctx)
  4286. if err != nil {
  4287. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4288. }
  4289. return oldValue.Title, nil
  4290. }
  4291. // ClearTitle clears the value of the "title" field.
  4292. func (m *ApiKeyMutation) ClearTitle() {
  4293. m.title = nil
  4294. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4295. }
  4296. // TitleCleared returns if the "title" field was cleared in this mutation.
  4297. func (m *ApiKeyMutation) TitleCleared() bool {
  4298. _, ok := m.clearedFields[apikey.FieldTitle]
  4299. return ok
  4300. }
  4301. // ResetTitle resets all changes to the "title" field.
  4302. func (m *ApiKeyMutation) ResetTitle() {
  4303. m.title = nil
  4304. delete(m.clearedFields, apikey.FieldTitle)
  4305. }
  4306. // SetKey sets the "key" field.
  4307. func (m *ApiKeyMutation) SetKey(s string) {
  4308. m.key = &s
  4309. }
  4310. // Key returns the value of the "key" field in the mutation.
  4311. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4312. v := m.key
  4313. if v == nil {
  4314. return
  4315. }
  4316. return *v, true
  4317. }
  4318. // OldKey returns the old "key" field's value of the ApiKey entity.
  4319. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4321. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4322. if !m.op.Is(OpUpdateOne) {
  4323. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4324. }
  4325. if m.id == nil || m.oldValue == nil {
  4326. return v, errors.New("OldKey requires an ID field in the mutation")
  4327. }
  4328. oldValue, err := m.oldValue(ctx)
  4329. if err != nil {
  4330. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4331. }
  4332. return oldValue.Key, nil
  4333. }
  4334. // ClearKey clears the value of the "key" field.
  4335. func (m *ApiKeyMutation) ClearKey() {
  4336. m.key = nil
  4337. m.clearedFields[apikey.FieldKey] = struct{}{}
  4338. }
  4339. // KeyCleared returns if the "key" field was cleared in this mutation.
  4340. func (m *ApiKeyMutation) KeyCleared() bool {
  4341. _, ok := m.clearedFields[apikey.FieldKey]
  4342. return ok
  4343. }
  4344. // ResetKey resets all changes to the "key" field.
  4345. func (m *ApiKeyMutation) ResetKey() {
  4346. m.key = nil
  4347. delete(m.clearedFields, apikey.FieldKey)
  4348. }
  4349. // SetOrganizationID sets the "organization_id" field.
  4350. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4351. m.organization_id = &u
  4352. m.addorganization_id = nil
  4353. }
  4354. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4355. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4356. v := m.organization_id
  4357. if v == nil {
  4358. return
  4359. }
  4360. return *v, true
  4361. }
  4362. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4363. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4365. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4366. if !m.op.Is(OpUpdateOne) {
  4367. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4368. }
  4369. if m.id == nil || m.oldValue == nil {
  4370. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4371. }
  4372. oldValue, err := m.oldValue(ctx)
  4373. if err != nil {
  4374. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4375. }
  4376. return oldValue.OrganizationID, nil
  4377. }
  4378. // AddOrganizationID adds u to the "organization_id" field.
  4379. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4380. if m.addorganization_id != nil {
  4381. *m.addorganization_id += u
  4382. } else {
  4383. m.addorganization_id = &u
  4384. }
  4385. }
  4386. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4387. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4388. v := m.addorganization_id
  4389. if v == nil {
  4390. return
  4391. }
  4392. return *v, true
  4393. }
  4394. // ResetOrganizationID resets all changes to the "organization_id" field.
  4395. func (m *ApiKeyMutation) ResetOrganizationID() {
  4396. m.organization_id = nil
  4397. m.addorganization_id = nil
  4398. }
  4399. // SetAgentID sets the "agent_id" field.
  4400. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4401. m.agent = &u
  4402. }
  4403. // AgentID returns the value of the "agent_id" field in the mutation.
  4404. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4405. v := m.agent
  4406. if v == nil {
  4407. return
  4408. }
  4409. return *v, true
  4410. }
  4411. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4412. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4414. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4415. if !m.op.Is(OpUpdateOne) {
  4416. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4417. }
  4418. if m.id == nil || m.oldValue == nil {
  4419. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4420. }
  4421. oldValue, err := m.oldValue(ctx)
  4422. if err != nil {
  4423. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4424. }
  4425. return oldValue.AgentID, nil
  4426. }
  4427. // ResetAgentID resets all changes to the "agent_id" field.
  4428. func (m *ApiKeyMutation) ResetAgentID() {
  4429. m.agent = nil
  4430. }
  4431. // SetCustomAgentBase sets the "custom_agent_base" field.
  4432. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4433. m.custom_agent_base = &s
  4434. }
  4435. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4436. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4437. v := m.custom_agent_base
  4438. if v == nil {
  4439. return
  4440. }
  4441. return *v, true
  4442. }
  4443. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4444. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4446. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4447. if !m.op.Is(OpUpdateOne) {
  4448. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4449. }
  4450. if m.id == nil || m.oldValue == nil {
  4451. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4452. }
  4453. oldValue, err := m.oldValue(ctx)
  4454. if err != nil {
  4455. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4456. }
  4457. return oldValue.CustomAgentBase, nil
  4458. }
  4459. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4460. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4461. m.custom_agent_base = nil
  4462. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4463. }
  4464. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4465. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4466. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4467. return ok
  4468. }
  4469. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4470. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4471. m.custom_agent_base = nil
  4472. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4473. }
  4474. // SetCustomAgentKey sets the "custom_agent_key" field.
  4475. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4476. m.custom_agent_key = &s
  4477. }
  4478. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4479. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4480. v := m.custom_agent_key
  4481. if v == nil {
  4482. return
  4483. }
  4484. return *v, true
  4485. }
  4486. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4487. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4489. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4490. if !m.op.Is(OpUpdateOne) {
  4491. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4492. }
  4493. if m.id == nil || m.oldValue == nil {
  4494. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4495. }
  4496. oldValue, err := m.oldValue(ctx)
  4497. if err != nil {
  4498. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4499. }
  4500. return oldValue.CustomAgentKey, nil
  4501. }
  4502. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4503. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4504. m.custom_agent_key = nil
  4505. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4506. }
  4507. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4508. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4509. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4510. return ok
  4511. }
  4512. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4513. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4514. m.custom_agent_key = nil
  4515. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4516. }
  4517. // SetOpenaiBase sets the "openai_base" field.
  4518. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4519. m.openai_base = &s
  4520. }
  4521. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4522. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4523. v := m.openai_base
  4524. if v == nil {
  4525. return
  4526. }
  4527. return *v, true
  4528. }
  4529. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4530. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4532. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4533. if !m.op.Is(OpUpdateOne) {
  4534. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4535. }
  4536. if m.id == nil || m.oldValue == nil {
  4537. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4538. }
  4539. oldValue, err := m.oldValue(ctx)
  4540. if err != nil {
  4541. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4542. }
  4543. return oldValue.OpenaiBase, nil
  4544. }
  4545. // ClearOpenaiBase clears the value of the "openai_base" field.
  4546. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4547. m.openai_base = nil
  4548. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4549. }
  4550. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4551. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4552. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4553. return ok
  4554. }
  4555. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4556. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4557. m.openai_base = nil
  4558. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4559. }
  4560. // SetOpenaiKey sets the "openai_key" field.
  4561. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4562. m.openai_key = &s
  4563. }
  4564. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4565. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4566. v := m.openai_key
  4567. if v == nil {
  4568. return
  4569. }
  4570. return *v, true
  4571. }
  4572. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4573. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4575. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4576. if !m.op.Is(OpUpdateOne) {
  4577. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4578. }
  4579. if m.id == nil || m.oldValue == nil {
  4580. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4581. }
  4582. oldValue, err := m.oldValue(ctx)
  4583. if err != nil {
  4584. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4585. }
  4586. return oldValue.OpenaiKey, nil
  4587. }
  4588. // ClearOpenaiKey clears the value of the "openai_key" field.
  4589. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4590. m.openai_key = nil
  4591. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4592. }
  4593. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4594. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4595. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4596. return ok
  4597. }
  4598. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4599. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4600. m.openai_key = nil
  4601. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4602. }
  4603. // ClearAgent clears the "agent" edge to the Agent entity.
  4604. func (m *ApiKeyMutation) ClearAgent() {
  4605. m.clearedagent = true
  4606. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4607. }
  4608. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4609. func (m *ApiKeyMutation) AgentCleared() bool {
  4610. return m.clearedagent
  4611. }
  4612. // AgentIDs returns the "agent" edge IDs in the mutation.
  4613. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4614. // AgentID instead. It exists only for internal usage by the builders.
  4615. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4616. if id := m.agent; id != nil {
  4617. ids = append(ids, *id)
  4618. }
  4619. return
  4620. }
  4621. // ResetAgent resets all changes to the "agent" edge.
  4622. func (m *ApiKeyMutation) ResetAgent() {
  4623. m.agent = nil
  4624. m.clearedagent = false
  4625. }
  4626. // Where appends a list predicates to the ApiKeyMutation builder.
  4627. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4628. m.predicates = append(m.predicates, ps...)
  4629. }
  4630. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4631. // users can use type-assertion to append predicates that do not depend on any generated package.
  4632. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4633. p := make([]predicate.ApiKey, len(ps))
  4634. for i := range ps {
  4635. p[i] = ps[i]
  4636. }
  4637. m.Where(p...)
  4638. }
  4639. // Op returns the operation name.
  4640. func (m *ApiKeyMutation) Op() Op {
  4641. return m.op
  4642. }
  4643. // SetOp allows setting the mutation operation.
  4644. func (m *ApiKeyMutation) SetOp(op Op) {
  4645. m.op = op
  4646. }
  4647. // Type returns the node type of this mutation (ApiKey).
  4648. func (m *ApiKeyMutation) Type() string {
  4649. return m.typ
  4650. }
  4651. // Fields returns all fields that were changed during this mutation. Note that in
  4652. // order to get all numeric fields that were incremented/decremented, call
  4653. // AddedFields().
  4654. func (m *ApiKeyMutation) Fields() []string {
  4655. fields := make([]string, 0, 11)
  4656. if m.created_at != nil {
  4657. fields = append(fields, apikey.FieldCreatedAt)
  4658. }
  4659. if m.updated_at != nil {
  4660. fields = append(fields, apikey.FieldUpdatedAt)
  4661. }
  4662. if m.deleted_at != nil {
  4663. fields = append(fields, apikey.FieldDeletedAt)
  4664. }
  4665. if m.title != nil {
  4666. fields = append(fields, apikey.FieldTitle)
  4667. }
  4668. if m.key != nil {
  4669. fields = append(fields, apikey.FieldKey)
  4670. }
  4671. if m.organization_id != nil {
  4672. fields = append(fields, apikey.FieldOrganizationID)
  4673. }
  4674. if m.agent != nil {
  4675. fields = append(fields, apikey.FieldAgentID)
  4676. }
  4677. if m.custom_agent_base != nil {
  4678. fields = append(fields, apikey.FieldCustomAgentBase)
  4679. }
  4680. if m.custom_agent_key != nil {
  4681. fields = append(fields, apikey.FieldCustomAgentKey)
  4682. }
  4683. if m.openai_base != nil {
  4684. fields = append(fields, apikey.FieldOpenaiBase)
  4685. }
  4686. if m.openai_key != nil {
  4687. fields = append(fields, apikey.FieldOpenaiKey)
  4688. }
  4689. return fields
  4690. }
  4691. // Field returns the value of a field with the given name. The second boolean
  4692. // return value indicates that this field was not set, or was not defined in the
  4693. // schema.
  4694. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  4695. switch name {
  4696. case apikey.FieldCreatedAt:
  4697. return m.CreatedAt()
  4698. case apikey.FieldUpdatedAt:
  4699. return m.UpdatedAt()
  4700. case apikey.FieldDeletedAt:
  4701. return m.DeletedAt()
  4702. case apikey.FieldTitle:
  4703. return m.Title()
  4704. case apikey.FieldKey:
  4705. return m.Key()
  4706. case apikey.FieldOrganizationID:
  4707. return m.OrganizationID()
  4708. case apikey.FieldAgentID:
  4709. return m.AgentID()
  4710. case apikey.FieldCustomAgentBase:
  4711. return m.CustomAgentBase()
  4712. case apikey.FieldCustomAgentKey:
  4713. return m.CustomAgentKey()
  4714. case apikey.FieldOpenaiBase:
  4715. return m.OpenaiBase()
  4716. case apikey.FieldOpenaiKey:
  4717. return m.OpenaiKey()
  4718. }
  4719. return nil, false
  4720. }
  4721. // OldField returns the old value of the field from the database. An error is
  4722. // returned if the mutation operation is not UpdateOne, or the query to the
  4723. // database failed.
  4724. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4725. switch name {
  4726. case apikey.FieldCreatedAt:
  4727. return m.OldCreatedAt(ctx)
  4728. case apikey.FieldUpdatedAt:
  4729. return m.OldUpdatedAt(ctx)
  4730. case apikey.FieldDeletedAt:
  4731. return m.OldDeletedAt(ctx)
  4732. case apikey.FieldTitle:
  4733. return m.OldTitle(ctx)
  4734. case apikey.FieldKey:
  4735. return m.OldKey(ctx)
  4736. case apikey.FieldOrganizationID:
  4737. return m.OldOrganizationID(ctx)
  4738. case apikey.FieldAgentID:
  4739. return m.OldAgentID(ctx)
  4740. case apikey.FieldCustomAgentBase:
  4741. return m.OldCustomAgentBase(ctx)
  4742. case apikey.FieldCustomAgentKey:
  4743. return m.OldCustomAgentKey(ctx)
  4744. case apikey.FieldOpenaiBase:
  4745. return m.OldOpenaiBase(ctx)
  4746. case apikey.FieldOpenaiKey:
  4747. return m.OldOpenaiKey(ctx)
  4748. }
  4749. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  4750. }
  4751. // SetField sets the value of a field with the given name. It returns an error if
  4752. // the field is not defined in the schema, or if the type mismatched the field
  4753. // type.
  4754. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  4755. switch name {
  4756. case apikey.FieldCreatedAt:
  4757. v, ok := value.(time.Time)
  4758. if !ok {
  4759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4760. }
  4761. m.SetCreatedAt(v)
  4762. return nil
  4763. case apikey.FieldUpdatedAt:
  4764. v, ok := value.(time.Time)
  4765. if !ok {
  4766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4767. }
  4768. m.SetUpdatedAt(v)
  4769. return nil
  4770. case apikey.FieldDeletedAt:
  4771. v, ok := value.(time.Time)
  4772. if !ok {
  4773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4774. }
  4775. m.SetDeletedAt(v)
  4776. return nil
  4777. case apikey.FieldTitle:
  4778. v, ok := value.(string)
  4779. if !ok {
  4780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4781. }
  4782. m.SetTitle(v)
  4783. return nil
  4784. case apikey.FieldKey:
  4785. v, ok := value.(string)
  4786. if !ok {
  4787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4788. }
  4789. m.SetKey(v)
  4790. return nil
  4791. case apikey.FieldOrganizationID:
  4792. v, ok := value.(uint64)
  4793. if !ok {
  4794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4795. }
  4796. m.SetOrganizationID(v)
  4797. return nil
  4798. case apikey.FieldAgentID:
  4799. v, ok := value.(uint64)
  4800. if !ok {
  4801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4802. }
  4803. m.SetAgentID(v)
  4804. return nil
  4805. case apikey.FieldCustomAgentBase:
  4806. v, ok := value.(string)
  4807. if !ok {
  4808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4809. }
  4810. m.SetCustomAgentBase(v)
  4811. return nil
  4812. case apikey.FieldCustomAgentKey:
  4813. v, ok := value.(string)
  4814. if !ok {
  4815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4816. }
  4817. m.SetCustomAgentKey(v)
  4818. return nil
  4819. case apikey.FieldOpenaiBase:
  4820. v, ok := value.(string)
  4821. if !ok {
  4822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4823. }
  4824. m.SetOpenaiBase(v)
  4825. return nil
  4826. case apikey.FieldOpenaiKey:
  4827. v, ok := value.(string)
  4828. if !ok {
  4829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4830. }
  4831. m.SetOpenaiKey(v)
  4832. return nil
  4833. }
  4834. return fmt.Errorf("unknown ApiKey field %s", name)
  4835. }
  4836. // AddedFields returns all numeric fields that were incremented/decremented during
  4837. // this mutation.
  4838. func (m *ApiKeyMutation) AddedFields() []string {
  4839. var fields []string
  4840. if m.addorganization_id != nil {
  4841. fields = append(fields, apikey.FieldOrganizationID)
  4842. }
  4843. return fields
  4844. }
  4845. // AddedField returns the numeric value that was incremented/decremented on a field
  4846. // with the given name. The second boolean return value indicates that this field
  4847. // was not set, or was not defined in the schema.
  4848. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  4849. switch name {
  4850. case apikey.FieldOrganizationID:
  4851. return m.AddedOrganizationID()
  4852. }
  4853. return nil, false
  4854. }
  4855. // AddField adds the value to the field with the given name. It returns an error if
  4856. // the field is not defined in the schema, or if the type mismatched the field
  4857. // type.
  4858. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  4859. switch name {
  4860. case apikey.FieldOrganizationID:
  4861. v, ok := value.(int64)
  4862. if !ok {
  4863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4864. }
  4865. m.AddOrganizationID(v)
  4866. return nil
  4867. }
  4868. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  4869. }
  4870. // ClearedFields returns all nullable fields that were cleared during this
  4871. // mutation.
  4872. func (m *ApiKeyMutation) ClearedFields() []string {
  4873. var fields []string
  4874. if m.FieldCleared(apikey.FieldDeletedAt) {
  4875. fields = append(fields, apikey.FieldDeletedAt)
  4876. }
  4877. if m.FieldCleared(apikey.FieldTitle) {
  4878. fields = append(fields, apikey.FieldTitle)
  4879. }
  4880. if m.FieldCleared(apikey.FieldKey) {
  4881. fields = append(fields, apikey.FieldKey)
  4882. }
  4883. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  4884. fields = append(fields, apikey.FieldCustomAgentBase)
  4885. }
  4886. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  4887. fields = append(fields, apikey.FieldCustomAgentKey)
  4888. }
  4889. if m.FieldCleared(apikey.FieldOpenaiBase) {
  4890. fields = append(fields, apikey.FieldOpenaiBase)
  4891. }
  4892. if m.FieldCleared(apikey.FieldOpenaiKey) {
  4893. fields = append(fields, apikey.FieldOpenaiKey)
  4894. }
  4895. return fields
  4896. }
  4897. // FieldCleared returns a boolean indicating if a field with the given name was
  4898. // cleared in this mutation.
  4899. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  4900. _, ok := m.clearedFields[name]
  4901. return ok
  4902. }
  4903. // ClearField clears the value of the field with the given name. It returns an
  4904. // error if the field is not defined in the schema.
  4905. func (m *ApiKeyMutation) ClearField(name string) error {
  4906. switch name {
  4907. case apikey.FieldDeletedAt:
  4908. m.ClearDeletedAt()
  4909. return nil
  4910. case apikey.FieldTitle:
  4911. m.ClearTitle()
  4912. return nil
  4913. case apikey.FieldKey:
  4914. m.ClearKey()
  4915. return nil
  4916. case apikey.FieldCustomAgentBase:
  4917. m.ClearCustomAgentBase()
  4918. return nil
  4919. case apikey.FieldCustomAgentKey:
  4920. m.ClearCustomAgentKey()
  4921. return nil
  4922. case apikey.FieldOpenaiBase:
  4923. m.ClearOpenaiBase()
  4924. return nil
  4925. case apikey.FieldOpenaiKey:
  4926. m.ClearOpenaiKey()
  4927. return nil
  4928. }
  4929. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  4930. }
  4931. // ResetField resets all changes in the mutation for the field with the given name.
  4932. // It returns an error if the field is not defined in the schema.
  4933. func (m *ApiKeyMutation) ResetField(name string) error {
  4934. switch name {
  4935. case apikey.FieldCreatedAt:
  4936. m.ResetCreatedAt()
  4937. return nil
  4938. case apikey.FieldUpdatedAt:
  4939. m.ResetUpdatedAt()
  4940. return nil
  4941. case apikey.FieldDeletedAt:
  4942. m.ResetDeletedAt()
  4943. return nil
  4944. case apikey.FieldTitle:
  4945. m.ResetTitle()
  4946. return nil
  4947. case apikey.FieldKey:
  4948. m.ResetKey()
  4949. return nil
  4950. case apikey.FieldOrganizationID:
  4951. m.ResetOrganizationID()
  4952. return nil
  4953. case apikey.FieldAgentID:
  4954. m.ResetAgentID()
  4955. return nil
  4956. case apikey.FieldCustomAgentBase:
  4957. m.ResetCustomAgentBase()
  4958. return nil
  4959. case apikey.FieldCustomAgentKey:
  4960. m.ResetCustomAgentKey()
  4961. return nil
  4962. case apikey.FieldOpenaiBase:
  4963. m.ResetOpenaiBase()
  4964. return nil
  4965. case apikey.FieldOpenaiKey:
  4966. m.ResetOpenaiKey()
  4967. return nil
  4968. }
  4969. return fmt.Errorf("unknown ApiKey field %s", name)
  4970. }
  4971. // AddedEdges returns all edge names that were set/added in this mutation.
  4972. func (m *ApiKeyMutation) AddedEdges() []string {
  4973. edges := make([]string, 0, 1)
  4974. if m.agent != nil {
  4975. edges = append(edges, apikey.EdgeAgent)
  4976. }
  4977. return edges
  4978. }
  4979. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4980. // name in this mutation.
  4981. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  4982. switch name {
  4983. case apikey.EdgeAgent:
  4984. if id := m.agent; id != nil {
  4985. return []ent.Value{*id}
  4986. }
  4987. }
  4988. return nil
  4989. }
  4990. // RemovedEdges returns all edge names that were removed in this mutation.
  4991. func (m *ApiKeyMutation) RemovedEdges() []string {
  4992. edges := make([]string, 0, 1)
  4993. return edges
  4994. }
  4995. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4996. // the given name in this mutation.
  4997. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  4998. return nil
  4999. }
  5000. // ClearedEdges returns all edge names that were cleared in this mutation.
  5001. func (m *ApiKeyMutation) ClearedEdges() []string {
  5002. edges := make([]string, 0, 1)
  5003. if m.clearedagent {
  5004. edges = append(edges, apikey.EdgeAgent)
  5005. }
  5006. return edges
  5007. }
  5008. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5009. // was cleared in this mutation.
  5010. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5011. switch name {
  5012. case apikey.EdgeAgent:
  5013. return m.clearedagent
  5014. }
  5015. return false
  5016. }
  5017. // ClearEdge clears the value of the edge with the given name. It returns an error
  5018. // if that edge is not defined in the schema.
  5019. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5020. switch name {
  5021. case apikey.EdgeAgent:
  5022. m.ClearAgent()
  5023. return nil
  5024. }
  5025. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5026. }
  5027. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5028. // It returns an error if the edge is not defined in the schema.
  5029. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5030. switch name {
  5031. case apikey.EdgeAgent:
  5032. m.ResetAgent()
  5033. return nil
  5034. }
  5035. return fmt.Errorf("unknown ApiKey edge %s", name)
  5036. }
  5037. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5038. type BatchMsgMutation struct {
  5039. config
  5040. op Op
  5041. typ string
  5042. id *uint64
  5043. created_at *time.Time
  5044. updated_at *time.Time
  5045. deleted_at *time.Time
  5046. status *uint8
  5047. addstatus *int8
  5048. batch_no *string
  5049. task_name *string
  5050. fromwxid *string
  5051. msg *string
  5052. tag *string
  5053. tagids *string
  5054. total *int32
  5055. addtotal *int32
  5056. success *int32
  5057. addsuccess *int32
  5058. fail *int32
  5059. addfail *int32
  5060. start_time *time.Time
  5061. stop_time *time.Time
  5062. send_time *time.Time
  5063. _type *int32
  5064. add_type *int32
  5065. organization_id *uint64
  5066. addorganization_id *int64
  5067. ctype *uint64
  5068. addctype *int64
  5069. cc *string
  5070. phone *string
  5071. template_name *string
  5072. template_code *string
  5073. lang *string
  5074. clearedFields map[string]struct{}
  5075. done bool
  5076. oldValue func(context.Context) (*BatchMsg, error)
  5077. predicates []predicate.BatchMsg
  5078. }
  5079. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5080. // batchmsgOption allows management of the mutation configuration using functional options.
  5081. type batchmsgOption func(*BatchMsgMutation)
  5082. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5083. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5084. m := &BatchMsgMutation{
  5085. config: c,
  5086. op: op,
  5087. typ: TypeBatchMsg,
  5088. clearedFields: make(map[string]struct{}),
  5089. }
  5090. for _, opt := range opts {
  5091. opt(m)
  5092. }
  5093. return m
  5094. }
  5095. // withBatchMsgID sets the ID field of the mutation.
  5096. func withBatchMsgID(id uint64) batchmsgOption {
  5097. return func(m *BatchMsgMutation) {
  5098. var (
  5099. err error
  5100. once sync.Once
  5101. value *BatchMsg
  5102. )
  5103. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5104. once.Do(func() {
  5105. if m.done {
  5106. err = errors.New("querying old values post mutation is not allowed")
  5107. } else {
  5108. value, err = m.Client().BatchMsg.Get(ctx, id)
  5109. }
  5110. })
  5111. return value, err
  5112. }
  5113. m.id = &id
  5114. }
  5115. }
  5116. // withBatchMsg sets the old BatchMsg of the mutation.
  5117. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5118. return func(m *BatchMsgMutation) {
  5119. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5120. return node, nil
  5121. }
  5122. m.id = &node.ID
  5123. }
  5124. }
  5125. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5126. // executed in a transaction (ent.Tx), a transactional client is returned.
  5127. func (m BatchMsgMutation) Client() *Client {
  5128. client := &Client{config: m.config}
  5129. client.init()
  5130. return client
  5131. }
  5132. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5133. // it returns an error otherwise.
  5134. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5135. if _, ok := m.driver.(*txDriver); !ok {
  5136. return nil, errors.New("ent: mutation is not running in a transaction")
  5137. }
  5138. tx := &Tx{config: m.config}
  5139. tx.init()
  5140. return tx, nil
  5141. }
  5142. // SetID sets the value of the id field. Note that this
  5143. // operation is only accepted on creation of BatchMsg entities.
  5144. func (m *BatchMsgMutation) SetID(id uint64) {
  5145. m.id = &id
  5146. }
  5147. // ID returns the ID value in the mutation. Note that the ID is only available
  5148. // if it was provided to the builder or after it was returned from the database.
  5149. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5150. if m.id == nil {
  5151. return
  5152. }
  5153. return *m.id, true
  5154. }
  5155. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5156. // That means, if the mutation is applied within a transaction with an isolation level such
  5157. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5158. // or updated by the mutation.
  5159. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5160. switch {
  5161. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5162. id, exists := m.ID()
  5163. if exists {
  5164. return []uint64{id}, nil
  5165. }
  5166. fallthrough
  5167. case m.op.Is(OpUpdate | OpDelete):
  5168. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5169. default:
  5170. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5171. }
  5172. }
  5173. // SetCreatedAt sets the "created_at" field.
  5174. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5175. m.created_at = &t
  5176. }
  5177. // CreatedAt returns the value of the "created_at" field in the mutation.
  5178. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5179. v := m.created_at
  5180. if v == nil {
  5181. return
  5182. }
  5183. return *v, true
  5184. }
  5185. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5186. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5188. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5189. if !m.op.Is(OpUpdateOne) {
  5190. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5191. }
  5192. if m.id == nil || m.oldValue == nil {
  5193. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5194. }
  5195. oldValue, err := m.oldValue(ctx)
  5196. if err != nil {
  5197. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5198. }
  5199. return oldValue.CreatedAt, nil
  5200. }
  5201. // ResetCreatedAt resets all changes to the "created_at" field.
  5202. func (m *BatchMsgMutation) ResetCreatedAt() {
  5203. m.created_at = nil
  5204. }
  5205. // SetUpdatedAt sets the "updated_at" field.
  5206. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5207. m.updated_at = &t
  5208. }
  5209. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5210. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5211. v := m.updated_at
  5212. if v == nil {
  5213. return
  5214. }
  5215. return *v, true
  5216. }
  5217. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5218. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5220. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5221. if !m.op.Is(OpUpdateOne) {
  5222. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5223. }
  5224. if m.id == nil || m.oldValue == nil {
  5225. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5226. }
  5227. oldValue, err := m.oldValue(ctx)
  5228. if err != nil {
  5229. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5230. }
  5231. return oldValue.UpdatedAt, nil
  5232. }
  5233. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5234. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5235. m.updated_at = nil
  5236. }
  5237. // SetDeletedAt sets the "deleted_at" field.
  5238. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5239. m.deleted_at = &t
  5240. }
  5241. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5242. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5243. v := m.deleted_at
  5244. if v == nil {
  5245. return
  5246. }
  5247. return *v, true
  5248. }
  5249. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5250. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5252. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5253. if !m.op.Is(OpUpdateOne) {
  5254. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5255. }
  5256. if m.id == nil || m.oldValue == nil {
  5257. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5258. }
  5259. oldValue, err := m.oldValue(ctx)
  5260. if err != nil {
  5261. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5262. }
  5263. return oldValue.DeletedAt, nil
  5264. }
  5265. // ClearDeletedAt clears the value of the "deleted_at" field.
  5266. func (m *BatchMsgMutation) ClearDeletedAt() {
  5267. m.deleted_at = nil
  5268. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5269. }
  5270. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5271. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5272. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5273. return ok
  5274. }
  5275. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5276. func (m *BatchMsgMutation) ResetDeletedAt() {
  5277. m.deleted_at = nil
  5278. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5279. }
  5280. // SetStatus sets the "status" field.
  5281. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5282. m.status = &u
  5283. m.addstatus = nil
  5284. }
  5285. // Status returns the value of the "status" field in the mutation.
  5286. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5287. v := m.status
  5288. if v == nil {
  5289. return
  5290. }
  5291. return *v, true
  5292. }
  5293. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5294. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5296. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5297. if !m.op.Is(OpUpdateOne) {
  5298. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5299. }
  5300. if m.id == nil || m.oldValue == nil {
  5301. return v, errors.New("OldStatus requires an ID field in the mutation")
  5302. }
  5303. oldValue, err := m.oldValue(ctx)
  5304. if err != nil {
  5305. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5306. }
  5307. return oldValue.Status, nil
  5308. }
  5309. // AddStatus adds u to the "status" field.
  5310. func (m *BatchMsgMutation) AddStatus(u int8) {
  5311. if m.addstatus != nil {
  5312. *m.addstatus += u
  5313. } else {
  5314. m.addstatus = &u
  5315. }
  5316. }
  5317. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5318. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5319. v := m.addstatus
  5320. if v == nil {
  5321. return
  5322. }
  5323. return *v, true
  5324. }
  5325. // ClearStatus clears the value of the "status" field.
  5326. func (m *BatchMsgMutation) ClearStatus() {
  5327. m.status = nil
  5328. m.addstatus = nil
  5329. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5330. }
  5331. // StatusCleared returns if the "status" field was cleared in this mutation.
  5332. func (m *BatchMsgMutation) StatusCleared() bool {
  5333. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5334. return ok
  5335. }
  5336. // ResetStatus resets all changes to the "status" field.
  5337. func (m *BatchMsgMutation) ResetStatus() {
  5338. m.status = nil
  5339. m.addstatus = nil
  5340. delete(m.clearedFields, batchmsg.FieldStatus)
  5341. }
  5342. // SetBatchNo sets the "batch_no" field.
  5343. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5344. m.batch_no = &s
  5345. }
  5346. // BatchNo returns the value of the "batch_no" field in the mutation.
  5347. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5348. v := m.batch_no
  5349. if v == nil {
  5350. return
  5351. }
  5352. return *v, true
  5353. }
  5354. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5355. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5357. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5358. if !m.op.Is(OpUpdateOne) {
  5359. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5360. }
  5361. if m.id == nil || m.oldValue == nil {
  5362. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5363. }
  5364. oldValue, err := m.oldValue(ctx)
  5365. if err != nil {
  5366. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5367. }
  5368. return oldValue.BatchNo, nil
  5369. }
  5370. // ClearBatchNo clears the value of the "batch_no" field.
  5371. func (m *BatchMsgMutation) ClearBatchNo() {
  5372. m.batch_no = nil
  5373. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5374. }
  5375. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5376. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5377. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5378. return ok
  5379. }
  5380. // ResetBatchNo resets all changes to the "batch_no" field.
  5381. func (m *BatchMsgMutation) ResetBatchNo() {
  5382. m.batch_no = nil
  5383. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5384. }
  5385. // SetTaskName sets the "task_name" field.
  5386. func (m *BatchMsgMutation) SetTaskName(s string) {
  5387. m.task_name = &s
  5388. }
  5389. // TaskName returns the value of the "task_name" field in the mutation.
  5390. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5391. v := m.task_name
  5392. if v == nil {
  5393. return
  5394. }
  5395. return *v, true
  5396. }
  5397. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5398. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5400. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5401. if !m.op.Is(OpUpdateOne) {
  5402. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5403. }
  5404. if m.id == nil || m.oldValue == nil {
  5405. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5406. }
  5407. oldValue, err := m.oldValue(ctx)
  5408. if err != nil {
  5409. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5410. }
  5411. return oldValue.TaskName, nil
  5412. }
  5413. // ClearTaskName clears the value of the "task_name" field.
  5414. func (m *BatchMsgMutation) ClearTaskName() {
  5415. m.task_name = nil
  5416. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5417. }
  5418. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5419. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5420. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5421. return ok
  5422. }
  5423. // ResetTaskName resets all changes to the "task_name" field.
  5424. func (m *BatchMsgMutation) ResetTaskName() {
  5425. m.task_name = nil
  5426. delete(m.clearedFields, batchmsg.FieldTaskName)
  5427. }
  5428. // SetFromwxid sets the "fromwxid" field.
  5429. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5430. m.fromwxid = &s
  5431. }
  5432. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5433. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5434. v := m.fromwxid
  5435. if v == nil {
  5436. return
  5437. }
  5438. return *v, true
  5439. }
  5440. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5441. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5443. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5444. if !m.op.Is(OpUpdateOne) {
  5445. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5446. }
  5447. if m.id == nil || m.oldValue == nil {
  5448. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5449. }
  5450. oldValue, err := m.oldValue(ctx)
  5451. if err != nil {
  5452. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5453. }
  5454. return oldValue.Fromwxid, nil
  5455. }
  5456. // ClearFromwxid clears the value of the "fromwxid" field.
  5457. func (m *BatchMsgMutation) ClearFromwxid() {
  5458. m.fromwxid = nil
  5459. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5460. }
  5461. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5462. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5463. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5464. return ok
  5465. }
  5466. // ResetFromwxid resets all changes to the "fromwxid" field.
  5467. func (m *BatchMsgMutation) ResetFromwxid() {
  5468. m.fromwxid = nil
  5469. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5470. }
  5471. // SetMsg sets the "msg" field.
  5472. func (m *BatchMsgMutation) SetMsg(s string) {
  5473. m.msg = &s
  5474. }
  5475. // Msg returns the value of the "msg" field in the mutation.
  5476. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5477. v := m.msg
  5478. if v == nil {
  5479. return
  5480. }
  5481. return *v, true
  5482. }
  5483. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5484. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5486. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5487. if !m.op.Is(OpUpdateOne) {
  5488. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5489. }
  5490. if m.id == nil || m.oldValue == nil {
  5491. return v, errors.New("OldMsg requires an ID field in the mutation")
  5492. }
  5493. oldValue, err := m.oldValue(ctx)
  5494. if err != nil {
  5495. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5496. }
  5497. return oldValue.Msg, nil
  5498. }
  5499. // ClearMsg clears the value of the "msg" field.
  5500. func (m *BatchMsgMutation) ClearMsg() {
  5501. m.msg = nil
  5502. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5503. }
  5504. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5505. func (m *BatchMsgMutation) MsgCleared() bool {
  5506. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5507. return ok
  5508. }
  5509. // ResetMsg resets all changes to the "msg" field.
  5510. func (m *BatchMsgMutation) ResetMsg() {
  5511. m.msg = nil
  5512. delete(m.clearedFields, batchmsg.FieldMsg)
  5513. }
  5514. // SetTag sets the "tag" field.
  5515. func (m *BatchMsgMutation) SetTag(s string) {
  5516. m.tag = &s
  5517. }
  5518. // Tag returns the value of the "tag" field in the mutation.
  5519. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5520. v := m.tag
  5521. if v == nil {
  5522. return
  5523. }
  5524. return *v, true
  5525. }
  5526. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5527. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5529. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5530. if !m.op.Is(OpUpdateOne) {
  5531. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5532. }
  5533. if m.id == nil || m.oldValue == nil {
  5534. return v, errors.New("OldTag requires an ID field in the mutation")
  5535. }
  5536. oldValue, err := m.oldValue(ctx)
  5537. if err != nil {
  5538. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5539. }
  5540. return oldValue.Tag, nil
  5541. }
  5542. // ClearTag clears the value of the "tag" field.
  5543. func (m *BatchMsgMutation) ClearTag() {
  5544. m.tag = nil
  5545. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5546. }
  5547. // TagCleared returns if the "tag" field was cleared in this mutation.
  5548. func (m *BatchMsgMutation) TagCleared() bool {
  5549. _, ok := m.clearedFields[batchmsg.FieldTag]
  5550. return ok
  5551. }
  5552. // ResetTag resets all changes to the "tag" field.
  5553. func (m *BatchMsgMutation) ResetTag() {
  5554. m.tag = nil
  5555. delete(m.clearedFields, batchmsg.FieldTag)
  5556. }
  5557. // SetTagids sets the "tagids" field.
  5558. func (m *BatchMsgMutation) SetTagids(s string) {
  5559. m.tagids = &s
  5560. }
  5561. // Tagids returns the value of the "tagids" field in the mutation.
  5562. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5563. v := m.tagids
  5564. if v == nil {
  5565. return
  5566. }
  5567. return *v, true
  5568. }
  5569. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5570. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5572. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5573. if !m.op.Is(OpUpdateOne) {
  5574. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5575. }
  5576. if m.id == nil || m.oldValue == nil {
  5577. return v, errors.New("OldTagids requires an ID field in the mutation")
  5578. }
  5579. oldValue, err := m.oldValue(ctx)
  5580. if err != nil {
  5581. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5582. }
  5583. return oldValue.Tagids, nil
  5584. }
  5585. // ClearTagids clears the value of the "tagids" field.
  5586. func (m *BatchMsgMutation) ClearTagids() {
  5587. m.tagids = nil
  5588. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5589. }
  5590. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5591. func (m *BatchMsgMutation) TagidsCleared() bool {
  5592. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5593. return ok
  5594. }
  5595. // ResetTagids resets all changes to the "tagids" field.
  5596. func (m *BatchMsgMutation) ResetTagids() {
  5597. m.tagids = nil
  5598. delete(m.clearedFields, batchmsg.FieldTagids)
  5599. }
  5600. // SetTotal sets the "total" field.
  5601. func (m *BatchMsgMutation) SetTotal(i int32) {
  5602. m.total = &i
  5603. m.addtotal = nil
  5604. }
  5605. // Total returns the value of the "total" field in the mutation.
  5606. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5607. v := m.total
  5608. if v == nil {
  5609. return
  5610. }
  5611. return *v, true
  5612. }
  5613. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5614. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5616. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5617. if !m.op.Is(OpUpdateOne) {
  5618. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5619. }
  5620. if m.id == nil || m.oldValue == nil {
  5621. return v, errors.New("OldTotal requires an ID field in the mutation")
  5622. }
  5623. oldValue, err := m.oldValue(ctx)
  5624. if err != nil {
  5625. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5626. }
  5627. return oldValue.Total, nil
  5628. }
  5629. // AddTotal adds i to the "total" field.
  5630. func (m *BatchMsgMutation) AddTotal(i int32) {
  5631. if m.addtotal != nil {
  5632. *m.addtotal += i
  5633. } else {
  5634. m.addtotal = &i
  5635. }
  5636. }
  5637. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5638. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5639. v := m.addtotal
  5640. if v == nil {
  5641. return
  5642. }
  5643. return *v, true
  5644. }
  5645. // ClearTotal clears the value of the "total" field.
  5646. func (m *BatchMsgMutation) ClearTotal() {
  5647. m.total = nil
  5648. m.addtotal = nil
  5649. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5650. }
  5651. // TotalCleared returns if the "total" field was cleared in this mutation.
  5652. func (m *BatchMsgMutation) TotalCleared() bool {
  5653. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5654. return ok
  5655. }
  5656. // ResetTotal resets all changes to the "total" field.
  5657. func (m *BatchMsgMutation) ResetTotal() {
  5658. m.total = nil
  5659. m.addtotal = nil
  5660. delete(m.clearedFields, batchmsg.FieldTotal)
  5661. }
  5662. // SetSuccess sets the "success" field.
  5663. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5664. m.success = &i
  5665. m.addsuccess = nil
  5666. }
  5667. // Success returns the value of the "success" field in the mutation.
  5668. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5669. v := m.success
  5670. if v == nil {
  5671. return
  5672. }
  5673. return *v, true
  5674. }
  5675. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5676. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5678. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  5679. if !m.op.Is(OpUpdateOne) {
  5680. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  5681. }
  5682. if m.id == nil || m.oldValue == nil {
  5683. return v, errors.New("OldSuccess requires an ID field in the mutation")
  5684. }
  5685. oldValue, err := m.oldValue(ctx)
  5686. if err != nil {
  5687. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  5688. }
  5689. return oldValue.Success, nil
  5690. }
  5691. // AddSuccess adds i to the "success" field.
  5692. func (m *BatchMsgMutation) AddSuccess(i int32) {
  5693. if m.addsuccess != nil {
  5694. *m.addsuccess += i
  5695. } else {
  5696. m.addsuccess = &i
  5697. }
  5698. }
  5699. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  5700. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  5701. v := m.addsuccess
  5702. if v == nil {
  5703. return
  5704. }
  5705. return *v, true
  5706. }
  5707. // ClearSuccess clears the value of the "success" field.
  5708. func (m *BatchMsgMutation) ClearSuccess() {
  5709. m.success = nil
  5710. m.addsuccess = nil
  5711. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  5712. }
  5713. // SuccessCleared returns if the "success" field was cleared in this mutation.
  5714. func (m *BatchMsgMutation) SuccessCleared() bool {
  5715. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  5716. return ok
  5717. }
  5718. // ResetSuccess resets all changes to the "success" field.
  5719. func (m *BatchMsgMutation) ResetSuccess() {
  5720. m.success = nil
  5721. m.addsuccess = nil
  5722. delete(m.clearedFields, batchmsg.FieldSuccess)
  5723. }
  5724. // SetFail sets the "fail" field.
  5725. func (m *BatchMsgMutation) SetFail(i int32) {
  5726. m.fail = &i
  5727. m.addfail = nil
  5728. }
  5729. // Fail returns the value of the "fail" field in the mutation.
  5730. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  5731. v := m.fail
  5732. if v == nil {
  5733. return
  5734. }
  5735. return *v, true
  5736. }
  5737. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  5738. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5740. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  5741. if !m.op.Is(OpUpdateOne) {
  5742. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  5743. }
  5744. if m.id == nil || m.oldValue == nil {
  5745. return v, errors.New("OldFail requires an ID field in the mutation")
  5746. }
  5747. oldValue, err := m.oldValue(ctx)
  5748. if err != nil {
  5749. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  5750. }
  5751. return oldValue.Fail, nil
  5752. }
  5753. // AddFail adds i to the "fail" field.
  5754. func (m *BatchMsgMutation) AddFail(i int32) {
  5755. if m.addfail != nil {
  5756. *m.addfail += i
  5757. } else {
  5758. m.addfail = &i
  5759. }
  5760. }
  5761. // AddedFail returns the value that was added to the "fail" field in this mutation.
  5762. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  5763. v := m.addfail
  5764. if v == nil {
  5765. return
  5766. }
  5767. return *v, true
  5768. }
  5769. // ClearFail clears the value of the "fail" field.
  5770. func (m *BatchMsgMutation) ClearFail() {
  5771. m.fail = nil
  5772. m.addfail = nil
  5773. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  5774. }
  5775. // FailCleared returns if the "fail" field was cleared in this mutation.
  5776. func (m *BatchMsgMutation) FailCleared() bool {
  5777. _, ok := m.clearedFields[batchmsg.FieldFail]
  5778. return ok
  5779. }
  5780. // ResetFail resets all changes to the "fail" field.
  5781. func (m *BatchMsgMutation) ResetFail() {
  5782. m.fail = nil
  5783. m.addfail = nil
  5784. delete(m.clearedFields, batchmsg.FieldFail)
  5785. }
  5786. // SetStartTime sets the "start_time" field.
  5787. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  5788. m.start_time = &t
  5789. }
  5790. // StartTime returns the value of the "start_time" field in the mutation.
  5791. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  5792. v := m.start_time
  5793. if v == nil {
  5794. return
  5795. }
  5796. return *v, true
  5797. }
  5798. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  5799. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5801. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  5802. if !m.op.Is(OpUpdateOne) {
  5803. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  5804. }
  5805. if m.id == nil || m.oldValue == nil {
  5806. return v, errors.New("OldStartTime requires an ID field in the mutation")
  5807. }
  5808. oldValue, err := m.oldValue(ctx)
  5809. if err != nil {
  5810. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  5811. }
  5812. return oldValue.StartTime, nil
  5813. }
  5814. // ClearStartTime clears the value of the "start_time" field.
  5815. func (m *BatchMsgMutation) ClearStartTime() {
  5816. m.start_time = nil
  5817. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  5818. }
  5819. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  5820. func (m *BatchMsgMutation) StartTimeCleared() bool {
  5821. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  5822. return ok
  5823. }
  5824. // ResetStartTime resets all changes to the "start_time" field.
  5825. func (m *BatchMsgMutation) ResetStartTime() {
  5826. m.start_time = nil
  5827. delete(m.clearedFields, batchmsg.FieldStartTime)
  5828. }
  5829. // SetStopTime sets the "stop_time" field.
  5830. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  5831. m.stop_time = &t
  5832. }
  5833. // StopTime returns the value of the "stop_time" field in the mutation.
  5834. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  5835. v := m.stop_time
  5836. if v == nil {
  5837. return
  5838. }
  5839. return *v, true
  5840. }
  5841. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  5842. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5844. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  5845. if !m.op.Is(OpUpdateOne) {
  5846. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  5847. }
  5848. if m.id == nil || m.oldValue == nil {
  5849. return v, errors.New("OldStopTime requires an ID field in the mutation")
  5850. }
  5851. oldValue, err := m.oldValue(ctx)
  5852. if err != nil {
  5853. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  5854. }
  5855. return oldValue.StopTime, nil
  5856. }
  5857. // ClearStopTime clears the value of the "stop_time" field.
  5858. func (m *BatchMsgMutation) ClearStopTime() {
  5859. m.stop_time = nil
  5860. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  5861. }
  5862. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  5863. func (m *BatchMsgMutation) StopTimeCleared() bool {
  5864. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  5865. return ok
  5866. }
  5867. // ResetStopTime resets all changes to the "stop_time" field.
  5868. func (m *BatchMsgMutation) ResetStopTime() {
  5869. m.stop_time = nil
  5870. delete(m.clearedFields, batchmsg.FieldStopTime)
  5871. }
  5872. // SetSendTime sets the "send_time" field.
  5873. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  5874. m.send_time = &t
  5875. }
  5876. // SendTime returns the value of the "send_time" field in the mutation.
  5877. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  5878. v := m.send_time
  5879. if v == nil {
  5880. return
  5881. }
  5882. return *v, true
  5883. }
  5884. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  5885. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5887. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  5888. if !m.op.Is(OpUpdateOne) {
  5889. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  5890. }
  5891. if m.id == nil || m.oldValue == nil {
  5892. return v, errors.New("OldSendTime requires an ID field in the mutation")
  5893. }
  5894. oldValue, err := m.oldValue(ctx)
  5895. if err != nil {
  5896. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  5897. }
  5898. return oldValue.SendTime, nil
  5899. }
  5900. // ClearSendTime clears the value of the "send_time" field.
  5901. func (m *BatchMsgMutation) ClearSendTime() {
  5902. m.send_time = nil
  5903. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  5904. }
  5905. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  5906. func (m *BatchMsgMutation) SendTimeCleared() bool {
  5907. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  5908. return ok
  5909. }
  5910. // ResetSendTime resets all changes to the "send_time" field.
  5911. func (m *BatchMsgMutation) ResetSendTime() {
  5912. m.send_time = nil
  5913. delete(m.clearedFields, batchmsg.FieldSendTime)
  5914. }
  5915. // SetType sets the "type" field.
  5916. func (m *BatchMsgMutation) SetType(i int32) {
  5917. m._type = &i
  5918. m.add_type = nil
  5919. }
  5920. // GetType returns the value of the "type" field in the mutation.
  5921. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  5922. v := m._type
  5923. if v == nil {
  5924. return
  5925. }
  5926. return *v, true
  5927. }
  5928. // OldType returns the old "type" field's value of the BatchMsg entity.
  5929. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5931. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  5932. if !m.op.Is(OpUpdateOne) {
  5933. return v, errors.New("OldType is only allowed on UpdateOne operations")
  5934. }
  5935. if m.id == nil || m.oldValue == nil {
  5936. return v, errors.New("OldType requires an ID field in the mutation")
  5937. }
  5938. oldValue, err := m.oldValue(ctx)
  5939. if err != nil {
  5940. return v, fmt.Errorf("querying old value for OldType: %w", err)
  5941. }
  5942. return oldValue.Type, nil
  5943. }
  5944. // AddType adds i to the "type" field.
  5945. func (m *BatchMsgMutation) AddType(i int32) {
  5946. if m.add_type != nil {
  5947. *m.add_type += i
  5948. } else {
  5949. m.add_type = &i
  5950. }
  5951. }
  5952. // AddedType returns the value that was added to the "type" field in this mutation.
  5953. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  5954. v := m.add_type
  5955. if v == nil {
  5956. return
  5957. }
  5958. return *v, true
  5959. }
  5960. // ClearType clears the value of the "type" field.
  5961. func (m *BatchMsgMutation) ClearType() {
  5962. m._type = nil
  5963. m.add_type = nil
  5964. m.clearedFields[batchmsg.FieldType] = struct{}{}
  5965. }
  5966. // TypeCleared returns if the "type" field was cleared in this mutation.
  5967. func (m *BatchMsgMutation) TypeCleared() bool {
  5968. _, ok := m.clearedFields[batchmsg.FieldType]
  5969. return ok
  5970. }
  5971. // ResetType resets all changes to the "type" field.
  5972. func (m *BatchMsgMutation) ResetType() {
  5973. m._type = nil
  5974. m.add_type = nil
  5975. delete(m.clearedFields, batchmsg.FieldType)
  5976. }
  5977. // SetOrganizationID sets the "organization_id" field.
  5978. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  5979. m.organization_id = &u
  5980. m.addorganization_id = nil
  5981. }
  5982. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5983. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  5984. v := m.organization_id
  5985. if v == nil {
  5986. return
  5987. }
  5988. return *v, true
  5989. }
  5990. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  5991. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5993. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5994. if !m.op.Is(OpUpdateOne) {
  5995. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5996. }
  5997. if m.id == nil || m.oldValue == nil {
  5998. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5999. }
  6000. oldValue, err := m.oldValue(ctx)
  6001. if err != nil {
  6002. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6003. }
  6004. return oldValue.OrganizationID, nil
  6005. }
  6006. // AddOrganizationID adds u to the "organization_id" field.
  6007. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6008. if m.addorganization_id != nil {
  6009. *m.addorganization_id += u
  6010. } else {
  6011. m.addorganization_id = &u
  6012. }
  6013. }
  6014. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6015. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6016. v := m.addorganization_id
  6017. if v == nil {
  6018. return
  6019. }
  6020. return *v, true
  6021. }
  6022. // ResetOrganizationID resets all changes to the "organization_id" field.
  6023. func (m *BatchMsgMutation) ResetOrganizationID() {
  6024. m.organization_id = nil
  6025. m.addorganization_id = nil
  6026. }
  6027. // SetCtype sets the "ctype" field.
  6028. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6029. m.ctype = &u
  6030. m.addctype = nil
  6031. }
  6032. // Ctype returns the value of the "ctype" field in the mutation.
  6033. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6034. v := m.ctype
  6035. if v == nil {
  6036. return
  6037. }
  6038. return *v, true
  6039. }
  6040. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6041. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6043. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6044. if !m.op.Is(OpUpdateOne) {
  6045. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6046. }
  6047. if m.id == nil || m.oldValue == nil {
  6048. return v, errors.New("OldCtype requires an ID field in the mutation")
  6049. }
  6050. oldValue, err := m.oldValue(ctx)
  6051. if err != nil {
  6052. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6053. }
  6054. return oldValue.Ctype, nil
  6055. }
  6056. // AddCtype adds u to the "ctype" field.
  6057. func (m *BatchMsgMutation) AddCtype(u int64) {
  6058. if m.addctype != nil {
  6059. *m.addctype += u
  6060. } else {
  6061. m.addctype = &u
  6062. }
  6063. }
  6064. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6065. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6066. v := m.addctype
  6067. if v == nil {
  6068. return
  6069. }
  6070. return *v, true
  6071. }
  6072. // ResetCtype resets all changes to the "ctype" field.
  6073. func (m *BatchMsgMutation) ResetCtype() {
  6074. m.ctype = nil
  6075. m.addctype = nil
  6076. }
  6077. // SetCc sets the "cc" field.
  6078. func (m *BatchMsgMutation) SetCc(s string) {
  6079. m.cc = &s
  6080. }
  6081. // Cc returns the value of the "cc" field in the mutation.
  6082. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6083. v := m.cc
  6084. if v == nil {
  6085. return
  6086. }
  6087. return *v, true
  6088. }
  6089. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6090. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6092. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6093. if !m.op.Is(OpUpdateOne) {
  6094. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6095. }
  6096. if m.id == nil || m.oldValue == nil {
  6097. return v, errors.New("OldCc requires an ID field in the mutation")
  6098. }
  6099. oldValue, err := m.oldValue(ctx)
  6100. if err != nil {
  6101. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6102. }
  6103. return oldValue.Cc, nil
  6104. }
  6105. // ClearCc clears the value of the "cc" field.
  6106. func (m *BatchMsgMutation) ClearCc() {
  6107. m.cc = nil
  6108. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6109. }
  6110. // CcCleared returns if the "cc" field was cleared in this mutation.
  6111. func (m *BatchMsgMutation) CcCleared() bool {
  6112. _, ok := m.clearedFields[batchmsg.FieldCc]
  6113. return ok
  6114. }
  6115. // ResetCc resets all changes to the "cc" field.
  6116. func (m *BatchMsgMutation) ResetCc() {
  6117. m.cc = nil
  6118. delete(m.clearedFields, batchmsg.FieldCc)
  6119. }
  6120. // SetPhone sets the "phone" field.
  6121. func (m *BatchMsgMutation) SetPhone(s string) {
  6122. m.phone = &s
  6123. }
  6124. // Phone returns the value of the "phone" field in the mutation.
  6125. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6126. v := m.phone
  6127. if v == nil {
  6128. return
  6129. }
  6130. return *v, true
  6131. }
  6132. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6133. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6135. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6136. if !m.op.Is(OpUpdateOne) {
  6137. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6138. }
  6139. if m.id == nil || m.oldValue == nil {
  6140. return v, errors.New("OldPhone requires an ID field in the mutation")
  6141. }
  6142. oldValue, err := m.oldValue(ctx)
  6143. if err != nil {
  6144. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6145. }
  6146. return oldValue.Phone, nil
  6147. }
  6148. // ClearPhone clears the value of the "phone" field.
  6149. func (m *BatchMsgMutation) ClearPhone() {
  6150. m.phone = nil
  6151. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6152. }
  6153. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6154. func (m *BatchMsgMutation) PhoneCleared() bool {
  6155. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6156. return ok
  6157. }
  6158. // ResetPhone resets all changes to the "phone" field.
  6159. func (m *BatchMsgMutation) ResetPhone() {
  6160. m.phone = nil
  6161. delete(m.clearedFields, batchmsg.FieldPhone)
  6162. }
  6163. // SetTemplateName sets the "template_name" field.
  6164. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6165. m.template_name = &s
  6166. }
  6167. // TemplateName returns the value of the "template_name" field in the mutation.
  6168. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6169. v := m.template_name
  6170. if v == nil {
  6171. return
  6172. }
  6173. return *v, true
  6174. }
  6175. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6176. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6178. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6179. if !m.op.Is(OpUpdateOne) {
  6180. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6181. }
  6182. if m.id == nil || m.oldValue == nil {
  6183. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6184. }
  6185. oldValue, err := m.oldValue(ctx)
  6186. if err != nil {
  6187. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6188. }
  6189. return oldValue.TemplateName, nil
  6190. }
  6191. // ClearTemplateName clears the value of the "template_name" field.
  6192. func (m *BatchMsgMutation) ClearTemplateName() {
  6193. m.template_name = nil
  6194. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6195. }
  6196. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6197. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6198. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6199. return ok
  6200. }
  6201. // ResetTemplateName resets all changes to the "template_name" field.
  6202. func (m *BatchMsgMutation) ResetTemplateName() {
  6203. m.template_name = nil
  6204. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6205. }
  6206. // SetTemplateCode sets the "template_code" field.
  6207. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6208. m.template_code = &s
  6209. }
  6210. // TemplateCode returns the value of the "template_code" field in the mutation.
  6211. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6212. v := m.template_code
  6213. if v == nil {
  6214. return
  6215. }
  6216. return *v, true
  6217. }
  6218. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6219. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6221. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6222. if !m.op.Is(OpUpdateOne) {
  6223. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6224. }
  6225. if m.id == nil || m.oldValue == nil {
  6226. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6227. }
  6228. oldValue, err := m.oldValue(ctx)
  6229. if err != nil {
  6230. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6231. }
  6232. return oldValue.TemplateCode, nil
  6233. }
  6234. // ClearTemplateCode clears the value of the "template_code" field.
  6235. func (m *BatchMsgMutation) ClearTemplateCode() {
  6236. m.template_code = nil
  6237. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6238. }
  6239. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6240. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6241. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6242. return ok
  6243. }
  6244. // ResetTemplateCode resets all changes to the "template_code" field.
  6245. func (m *BatchMsgMutation) ResetTemplateCode() {
  6246. m.template_code = nil
  6247. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6248. }
  6249. // SetLang sets the "lang" field.
  6250. func (m *BatchMsgMutation) SetLang(s string) {
  6251. m.lang = &s
  6252. }
  6253. // Lang returns the value of the "lang" field in the mutation.
  6254. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6255. v := m.lang
  6256. if v == nil {
  6257. return
  6258. }
  6259. return *v, true
  6260. }
  6261. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6262. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6264. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6265. if !m.op.Is(OpUpdateOne) {
  6266. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6267. }
  6268. if m.id == nil || m.oldValue == nil {
  6269. return v, errors.New("OldLang requires an ID field in the mutation")
  6270. }
  6271. oldValue, err := m.oldValue(ctx)
  6272. if err != nil {
  6273. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6274. }
  6275. return oldValue.Lang, nil
  6276. }
  6277. // ClearLang clears the value of the "lang" field.
  6278. func (m *BatchMsgMutation) ClearLang() {
  6279. m.lang = nil
  6280. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6281. }
  6282. // LangCleared returns if the "lang" field was cleared in this mutation.
  6283. func (m *BatchMsgMutation) LangCleared() bool {
  6284. _, ok := m.clearedFields[batchmsg.FieldLang]
  6285. return ok
  6286. }
  6287. // ResetLang resets all changes to the "lang" field.
  6288. func (m *BatchMsgMutation) ResetLang() {
  6289. m.lang = nil
  6290. delete(m.clearedFields, batchmsg.FieldLang)
  6291. }
  6292. // Where appends a list predicates to the BatchMsgMutation builder.
  6293. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6294. m.predicates = append(m.predicates, ps...)
  6295. }
  6296. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6297. // users can use type-assertion to append predicates that do not depend on any generated package.
  6298. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6299. p := make([]predicate.BatchMsg, len(ps))
  6300. for i := range ps {
  6301. p[i] = ps[i]
  6302. }
  6303. m.Where(p...)
  6304. }
  6305. // Op returns the operation name.
  6306. func (m *BatchMsgMutation) Op() Op {
  6307. return m.op
  6308. }
  6309. // SetOp allows setting the mutation operation.
  6310. func (m *BatchMsgMutation) SetOp(op Op) {
  6311. m.op = op
  6312. }
  6313. // Type returns the node type of this mutation (BatchMsg).
  6314. func (m *BatchMsgMutation) Type() string {
  6315. return m.typ
  6316. }
  6317. // Fields returns all fields that were changed during this mutation. Note that in
  6318. // order to get all numeric fields that were incremented/decremented, call
  6319. // AddedFields().
  6320. func (m *BatchMsgMutation) Fields() []string {
  6321. fields := make([]string, 0, 24)
  6322. if m.created_at != nil {
  6323. fields = append(fields, batchmsg.FieldCreatedAt)
  6324. }
  6325. if m.updated_at != nil {
  6326. fields = append(fields, batchmsg.FieldUpdatedAt)
  6327. }
  6328. if m.deleted_at != nil {
  6329. fields = append(fields, batchmsg.FieldDeletedAt)
  6330. }
  6331. if m.status != nil {
  6332. fields = append(fields, batchmsg.FieldStatus)
  6333. }
  6334. if m.batch_no != nil {
  6335. fields = append(fields, batchmsg.FieldBatchNo)
  6336. }
  6337. if m.task_name != nil {
  6338. fields = append(fields, batchmsg.FieldTaskName)
  6339. }
  6340. if m.fromwxid != nil {
  6341. fields = append(fields, batchmsg.FieldFromwxid)
  6342. }
  6343. if m.msg != nil {
  6344. fields = append(fields, batchmsg.FieldMsg)
  6345. }
  6346. if m.tag != nil {
  6347. fields = append(fields, batchmsg.FieldTag)
  6348. }
  6349. if m.tagids != nil {
  6350. fields = append(fields, batchmsg.FieldTagids)
  6351. }
  6352. if m.total != nil {
  6353. fields = append(fields, batchmsg.FieldTotal)
  6354. }
  6355. if m.success != nil {
  6356. fields = append(fields, batchmsg.FieldSuccess)
  6357. }
  6358. if m.fail != nil {
  6359. fields = append(fields, batchmsg.FieldFail)
  6360. }
  6361. if m.start_time != nil {
  6362. fields = append(fields, batchmsg.FieldStartTime)
  6363. }
  6364. if m.stop_time != nil {
  6365. fields = append(fields, batchmsg.FieldStopTime)
  6366. }
  6367. if m.send_time != nil {
  6368. fields = append(fields, batchmsg.FieldSendTime)
  6369. }
  6370. if m._type != nil {
  6371. fields = append(fields, batchmsg.FieldType)
  6372. }
  6373. if m.organization_id != nil {
  6374. fields = append(fields, batchmsg.FieldOrganizationID)
  6375. }
  6376. if m.ctype != nil {
  6377. fields = append(fields, batchmsg.FieldCtype)
  6378. }
  6379. if m.cc != nil {
  6380. fields = append(fields, batchmsg.FieldCc)
  6381. }
  6382. if m.phone != nil {
  6383. fields = append(fields, batchmsg.FieldPhone)
  6384. }
  6385. if m.template_name != nil {
  6386. fields = append(fields, batchmsg.FieldTemplateName)
  6387. }
  6388. if m.template_code != nil {
  6389. fields = append(fields, batchmsg.FieldTemplateCode)
  6390. }
  6391. if m.lang != nil {
  6392. fields = append(fields, batchmsg.FieldLang)
  6393. }
  6394. return fields
  6395. }
  6396. // Field returns the value of a field with the given name. The second boolean
  6397. // return value indicates that this field was not set, or was not defined in the
  6398. // schema.
  6399. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6400. switch name {
  6401. case batchmsg.FieldCreatedAt:
  6402. return m.CreatedAt()
  6403. case batchmsg.FieldUpdatedAt:
  6404. return m.UpdatedAt()
  6405. case batchmsg.FieldDeletedAt:
  6406. return m.DeletedAt()
  6407. case batchmsg.FieldStatus:
  6408. return m.Status()
  6409. case batchmsg.FieldBatchNo:
  6410. return m.BatchNo()
  6411. case batchmsg.FieldTaskName:
  6412. return m.TaskName()
  6413. case batchmsg.FieldFromwxid:
  6414. return m.Fromwxid()
  6415. case batchmsg.FieldMsg:
  6416. return m.Msg()
  6417. case batchmsg.FieldTag:
  6418. return m.Tag()
  6419. case batchmsg.FieldTagids:
  6420. return m.Tagids()
  6421. case batchmsg.FieldTotal:
  6422. return m.Total()
  6423. case batchmsg.FieldSuccess:
  6424. return m.Success()
  6425. case batchmsg.FieldFail:
  6426. return m.Fail()
  6427. case batchmsg.FieldStartTime:
  6428. return m.StartTime()
  6429. case batchmsg.FieldStopTime:
  6430. return m.StopTime()
  6431. case batchmsg.FieldSendTime:
  6432. return m.SendTime()
  6433. case batchmsg.FieldType:
  6434. return m.GetType()
  6435. case batchmsg.FieldOrganizationID:
  6436. return m.OrganizationID()
  6437. case batchmsg.FieldCtype:
  6438. return m.Ctype()
  6439. case batchmsg.FieldCc:
  6440. return m.Cc()
  6441. case batchmsg.FieldPhone:
  6442. return m.Phone()
  6443. case batchmsg.FieldTemplateName:
  6444. return m.TemplateName()
  6445. case batchmsg.FieldTemplateCode:
  6446. return m.TemplateCode()
  6447. case batchmsg.FieldLang:
  6448. return m.Lang()
  6449. }
  6450. return nil, false
  6451. }
  6452. // OldField returns the old value of the field from the database. An error is
  6453. // returned if the mutation operation is not UpdateOne, or the query to the
  6454. // database failed.
  6455. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6456. switch name {
  6457. case batchmsg.FieldCreatedAt:
  6458. return m.OldCreatedAt(ctx)
  6459. case batchmsg.FieldUpdatedAt:
  6460. return m.OldUpdatedAt(ctx)
  6461. case batchmsg.FieldDeletedAt:
  6462. return m.OldDeletedAt(ctx)
  6463. case batchmsg.FieldStatus:
  6464. return m.OldStatus(ctx)
  6465. case batchmsg.FieldBatchNo:
  6466. return m.OldBatchNo(ctx)
  6467. case batchmsg.FieldTaskName:
  6468. return m.OldTaskName(ctx)
  6469. case batchmsg.FieldFromwxid:
  6470. return m.OldFromwxid(ctx)
  6471. case batchmsg.FieldMsg:
  6472. return m.OldMsg(ctx)
  6473. case batchmsg.FieldTag:
  6474. return m.OldTag(ctx)
  6475. case batchmsg.FieldTagids:
  6476. return m.OldTagids(ctx)
  6477. case batchmsg.FieldTotal:
  6478. return m.OldTotal(ctx)
  6479. case batchmsg.FieldSuccess:
  6480. return m.OldSuccess(ctx)
  6481. case batchmsg.FieldFail:
  6482. return m.OldFail(ctx)
  6483. case batchmsg.FieldStartTime:
  6484. return m.OldStartTime(ctx)
  6485. case batchmsg.FieldStopTime:
  6486. return m.OldStopTime(ctx)
  6487. case batchmsg.FieldSendTime:
  6488. return m.OldSendTime(ctx)
  6489. case batchmsg.FieldType:
  6490. return m.OldType(ctx)
  6491. case batchmsg.FieldOrganizationID:
  6492. return m.OldOrganizationID(ctx)
  6493. case batchmsg.FieldCtype:
  6494. return m.OldCtype(ctx)
  6495. case batchmsg.FieldCc:
  6496. return m.OldCc(ctx)
  6497. case batchmsg.FieldPhone:
  6498. return m.OldPhone(ctx)
  6499. case batchmsg.FieldTemplateName:
  6500. return m.OldTemplateName(ctx)
  6501. case batchmsg.FieldTemplateCode:
  6502. return m.OldTemplateCode(ctx)
  6503. case batchmsg.FieldLang:
  6504. return m.OldLang(ctx)
  6505. }
  6506. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6507. }
  6508. // SetField sets the value of a field with the given name. It returns an error if
  6509. // the field is not defined in the schema, or if the type mismatched the field
  6510. // type.
  6511. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6512. switch name {
  6513. case batchmsg.FieldCreatedAt:
  6514. v, ok := value.(time.Time)
  6515. if !ok {
  6516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6517. }
  6518. m.SetCreatedAt(v)
  6519. return nil
  6520. case batchmsg.FieldUpdatedAt:
  6521. v, ok := value.(time.Time)
  6522. if !ok {
  6523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6524. }
  6525. m.SetUpdatedAt(v)
  6526. return nil
  6527. case batchmsg.FieldDeletedAt:
  6528. v, ok := value.(time.Time)
  6529. if !ok {
  6530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6531. }
  6532. m.SetDeletedAt(v)
  6533. return nil
  6534. case batchmsg.FieldStatus:
  6535. v, ok := value.(uint8)
  6536. if !ok {
  6537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6538. }
  6539. m.SetStatus(v)
  6540. return nil
  6541. case batchmsg.FieldBatchNo:
  6542. v, ok := value.(string)
  6543. if !ok {
  6544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6545. }
  6546. m.SetBatchNo(v)
  6547. return nil
  6548. case batchmsg.FieldTaskName:
  6549. v, ok := value.(string)
  6550. if !ok {
  6551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6552. }
  6553. m.SetTaskName(v)
  6554. return nil
  6555. case batchmsg.FieldFromwxid:
  6556. v, ok := value.(string)
  6557. if !ok {
  6558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6559. }
  6560. m.SetFromwxid(v)
  6561. return nil
  6562. case batchmsg.FieldMsg:
  6563. v, ok := value.(string)
  6564. if !ok {
  6565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6566. }
  6567. m.SetMsg(v)
  6568. return nil
  6569. case batchmsg.FieldTag:
  6570. v, ok := value.(string)
  6571. if !ok {
  6572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6573. }
  6574. m.SetTag(v)
  6575. return nil
  6576. case batchmsg.FieldTagids:
  6577. v, ok := value.(string)
  6578. if !ok {
  6579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6580. }
  6581. m.SetTagids(v)
  6582. return nil
  6583. case batchmsg.FieldTotal:
  6584. v, ok := value.(int32)
  6585. if !ok {
  6586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6587. }
  6588. m.SetTotal(v)
  6589. return nil
  6590. case batchmsg.FieldSuccess:
  6591. v, ok := value.(int32)
  6592. if !ok {
  6593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6594. }
  6595. m.SetSuccess(v)
  6596. return nil
  6597. case batchmsg.FieldFail:
  6598. v, ok := value.(int32)
  6599. if !ok {
  6600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6601. }
  6602. m.SetFail(v)
  6603. return nil
  6604. case batchmsg.FieldStartTime:
  6605. v, ok := value.(time.Time)
  6606. if !ok {
  6607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6608. }
  6609. m.SetStartTime(v)
  6610. return nil
  6611. case batchmsg.FieldStopTime:
  6612. v, ok := value.(time.Time)
  6613. if !ok {
  6614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6615. }
  6616. m.SetStopTime(v)
  6617. return nil
  6618. case batchmsg.FieldSendTime:
  6619. v, ok := value.(time.Time)
  6620. if !ok {
  6621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6622. }
  6623. m.SetSendTime(v)
  6624. return nil
  6625. case batchmsg.FieldType:
  6626. v, ok := value.(int32)
  6627. if !ok {
  6628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6629. }
  6630. m.SetType(v)
  6631. return nil
  6632. case batchmsg.FieldOrganizationID:
  6633. v, ok := value.(uint64)
  6634. if !ok {
  6635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6636. }
  6637. m.SetOrganizationID(v)
  6638. return nil
  6639. case batchmsg.FieldCtype:
  6640. v, ok := value.(uint64)
  6641. if !ok {
  6642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6643. }
  6644. m.SetCtype(v)
  6645. return nil
  6646. case batchmsg.FieldCc:
  6647. v, ok := value.(string)
  6648. if !ok {
  6649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6650. }
  6651. m.SetCc(v)
  6652. return nil
  6653. case batchmsg.FieldPhone:
  6654. v, ok := value.(string)
  6655. if !ok {
  6656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6657. }
  6658. m.SetPhone(v)
  6659. return nil
  6660. case batchmsg.FieldTemplateName:
  6661. v, ok := value.(string)
  6662. if !ok {
  6663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6664. }
  6665. m.SetTemplateName(v)
  6666. return nil
  6667. case batchmsg.FieldTemplateCode:
  6668. v, ok := value.(string)
  6669. if !ok {
  6670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6671. }
  6672. m.SetTemplateCode(v)
  6673. return nil
  6674. case batchmsg.FieldLang:
  6675. v, ok := value.(string)
  6676. if !ok {
  6677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6678. }
  6679. m.SetLang(v)
  6680. return nil
  6681. }
  6682. return fmt.Errorf("unknown BatchMsg field %s", name)
  6683. }
  6684. // AddedFields returns all numeric fields that were incremented/decremented during
  6685. // this mutation.
  6686. func (m *BatchMsgMutation) AddedFields() []string {
  6687. var fields []string
  6688. if m.addstatus != nil {
  6689. fields = append(fields, batchmsg.FieldStatus)
  6690. }
  6691. if m.addtotal != nil {
  6692. fields = append(fields, batchmsg.FieldTotal)
  6693. }
  6694. if m.addsuccess != nil {
  6695. fields = append(fields, batchmsg.FieldSuccess)
  6696. }
  6697. if m.addfail != nil {
  6698. fields = append(fields, batchmsg.FieldFail)
  6699. }
  6700. if m.add_type != nil {
  6701. fields = append(fields, batchmsg.FieldType)
  6702. }
  6703. if m.addorganization_id != nil {
  6704. fields = append(fields, batchmsg.FieldOrganizationID)
  6705. }
  6706. if m.addctype != nil {
  6707. fields = append(fields, batchmsg.FieldCtype)
  6708. }
  6709. return fields
  6710. }
  6711. // AddedField returns the numeric value that was incremented/decremented on a field
  6712. // with the given name. The second boolean return value indicates that this field
  6713. // was not set, or was not defined in the schema.
  6714. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  6715. switch name {
  6716. case batchmsg.FieldStatus:
  6717. return m.AddedStatus()
  6718. case batchmsg.FieldTotal:
  6719. return m.AddedTotal()
  6720. case batchmsg.FieldSuccess:
  6721. return m.AddedSuccess()
  6722. case batchmsg.FieldFail:
  6723. return m.AddedFail()
  6724. case batchmsg.FieldType:
  6725. return m.AddedType()
  6726. case batchmsg.FieldOrganizationID:
  6727. return m.AddedOrganizationID()
  6728. case batchmsg.FieldCtype:
  6729. return m.AddedCtype()
  6730. }
  6731. return nil, false
  6732. }
  6733. // AddField adds the value to the field with the given name. It returns an error if
  6734. // the field is not defined in the schema, or if the type mismatched the field
  6735. // type.
  6736. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  6737. switch name {
  6738. case batchmsg.FieldStatus:
  6739. v, ok := value.(int8)
  6740. if !ok {
  6741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6742. }
  6743. m.AddStatus(v)
  6744. return nil
  6745. case batchmsg.FieldTotal:
  6746. v, ok := value.(int32)
  6747. if !ok {
  6748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6749. }
  6750. m.AddTotal(v)
  6751. return nil
  6752. case batchmsg.FieldSuccess:
  6753. v, ok := value.(int32)
  6754. if !ok {
  6755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6756. }
  6757. m.AddSuccess(v)
  6758. return nil
  6759. case batchmsg.FieldFail:
  6760. v, ok := value.(int32)
  6761. if !ok {
  6762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6763. }
  6764. m.AddFail(v)
  6765. return nil
  6766. case batchmsg.FieldType:
  6767. v, ok := value.(int32)
  6768. if !ok {
  6769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6770. }
  6771. m.AddType(v)
  6772. return nil
  6773. case batchmsg.FieldOrganizationID:
  6774. v, ok := value.(int64)
  6775. if !ok {
  6776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6777. }
  6778. m.AddOrganizationID(v)
  6779. return nil
  6780. case batchmsg.FieldCtype:
  6781. v, ok := value.(int64)
  6782. if !ok {
  6783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6784. }
  6785. m.AddCtype(v)
  6786. return nil
  6787. }
  6788. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  6789. }
  6790. // ClearedFields returns all nullable fields that were cleared during this
  6791. // mutation.
  6792. func (m *BatchMsgMutation) ClearedFields() []string {
  6793. var fields []string
  6794. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  6795. fields = append(fields, batchmsg.FieldDeletedAt)
  6796. }
  6797. if m.FieldCleared(batchmsg.FieldStatus) {
  6798. fields = append(fields, batchmsg.FieldStatus)
  6799. }
  6800. if m.FieldCleared(batchmsg.FieldBatchNo) {
  6801. fields = append(fields, batchmsg.FieldBatchNo)
  6802. }
  6803. if m.FieldCleared(batchmsg.FieldTaskName) {
  6804. fields = append(fields, batchmsg.FieldTaskName)
  6805. }
  6806. if m.FieldCleared(batchmsg.FieldFromwxid) {
  6807. fields = append(fields, batchmsg.FieldFromwxid)
  6808. }
  6809. if m.FieldCleared(batchmsg.FieldMsg) {
  6810. fields = append(fields, batchmsg.FieldMsg)
  6811. }
  6812. if m.FieldCleared(batchmsg.FieldTag) {
  6813. fields = append(fields, batchmsg.FieldTag)
  6814. }
  6815. if m.FieldCleared(batchmsg.FieldTagids) {
  6816. fields = append(fields, batchmsg.FieldTagids)
  6817. }
  6818. if m.FieldCleared(batchmsg.FieldTotal) {
  6819. fields = append(fields, batchmsg.FieldTotal)
  6820. }
  6821. if m.FieldCleared(batchmsg.FieldSuccess) {
  6822. fields = append(fields, batchmsg.FieldSuccess)
  6823. }
  6824. if m.FieldCleared(batchmsg.FieldFail) {
  6825. fields = append(fields, batchmsg.FieldFail)
  6826. }
  6827. if m.FieldCleared(batchmsg.FieldStartTime) {
  6828. fields = append(fields, batchmsg.FieldStartTime)
  6829. }
  6830. if m.FieldCleared(batchmsg.FieldStopTime) {
  6831. fields = append(fields, batchmsg.FieldStopTime)
  6832. }
  6833. if m.FieldCleared(batchmsg.FieldSendTime) {
  6834. fields = append(fields, batchmsg.FieldSendTime)
  6835. }
  6836. if m.FieldCleared(batchmsg.FieldType) {
  6837. fields = append(fields, batchmsg.FieldType)
  6838. }
  6839. if m.FieldCleared(batchmsg.FieldCc) {
  6840. fields = append(fields, batchmsg.FieldCc)
  6841. }
  6842. if m.FieldCleared(batchmsg.FieldPhone) {
  6843. fields = append(fields, batchmsg.FieldPhone)
  6844. }
  6845. if m.FieldCleared(batchmsg.FieldTemplateName) {
  6846. fields = append(fields, batchmsg.FieldTemplateName)
  6847. }
  6848. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  6849. fields = append(fields, batchmsg.FieldTemplateCode)
  6850. }
  6851. if m.FieldCleared(batchmsg.FieldLang) {
  6852. fields = append(fields, batchmsg.FieldLang)
  6853. }
  6854. return fields
  6855. }
  6856. // FieldCleared returns a boolean indicating if a field with the given name was
  6857. // cleared in this mutation.
  6858. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  6859. _, ok := m.clearedFields[name]
  6860. return ok
  6861. }
  6862. // ClearField clears the value of the field with the given name. It returns an
  6863. // error if the field is not defined in the schema.
  6864. func (m *BatchMsgMutation) ClearField(name string) error {
  6865. switch name {
  6866. case batchmsg.FieldDeletedAt:
  6867. m.ClearDeletedAt()
  6868. return nil
  6869. case batchmsg.FieldStatus:
  6870. m.ClearStatus()
  6871. return nil
  6872. case batchmsg.FieldBatchNo:
  6873. m.ClearBatchNo()
  6874. return nil
  6875. case batchmsg.FieldTaskName:
  6876. m.ClearTaskName()
  6877. return nil
  6878. case batchmsg.FieldFromwxid:
  6879. m.ClearFromwxid()
  6880. return nil
  6881. case batchmsg.FieldMsg:
  6882. m.ClearMsg()
  6883. return nil
  6884. case batchmsg.FieldTag:
  6885. m.ClearTag()
  6886. return nil
  6887. case batchmsg.FieldTagids:
  6888. m.ClearTagids()
  6889. return nil
  6890. case batchmsg.FieldTotal:
  6891. m.ClearTotal()
  6892. return nil
  6893. case batchmsg.FieldSuccess:
  6894. m.ClearSuccess()
  6895. return nil
  6896. case batchmsg.FieldFail:
  6897. m.ClearFail()
  6898. return nil
  6899. case batchmsg.FieldStartTime:
  6900. m.ClearStartTime()
  6901. return nil
  6902. case batchmsg.FieldStopTime:
  6903. m.ClearStopTime()
  6904. return nil
  6905. case batchmsg.FieldSendTime:
  6906. m.ClearSendTime()
  6907. return nil
  6908. case batchmsg.FieldType:
  6909. m.ClearType()
  6910. return nil
  6911. case batchmsg.FieldCc:
  6912. m.ClearCc()
  6913. return nil
  6914. case batchmsg.FieldPhone:
  6915. m.ClearPhone()
  6916. return nil
  6917. case batchmsg.FieldTemplateName:
  6918. m.ClearTemplateName()
  6919. return nil
  6920. case batchmsg.FieldTemplateCode:
  6921. m.ClearTemplateCode()
  6922. return nil
  6923. case batchmsg.FieldLang:
  6924. m.ClearLang()
  6925. return nil
  6926. }
  6927. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  6928. }
  6929. // ResetField resets all changes in the mutation for the field with the given name.
  6930. // It returns an error if the field is not defined in the schema.
  6931. func (m *BatchMsgMutation) ResetField(name string) error {
  6932. switch name {
  6933. case batchmsg.FieldCreatedAt:
  6934. m.ResetCreatedAt()
  6935. return nil
  6936. case batchmsg.FieldUpdatedAt:
  6937. m.ResetUpdatedAt()
  6938. return nil
  6939. case batchmsg.FieldDeletedAt:
  6940. m.ResetDeletedAt()
  6941. return nil
  6942. case batchmsg.FieldStatus:
  6943. m.ResetStatus()
  6944. return nil
  6945. case batchmsg.FieldBatchNo:
  6946. m.ResetBatchNo()
  6947. return nil
  6948. case batchmsg.FieldTaskName:
  6949. m.ResetTaskName()
  6950. return nil
  6951. case batchmsg.FieldFromwxid:
  6952. m.ResetFromwxid()
  6953. return nil
  6954. case batchmsg.FieldMsg:
  6955. m.ResetMsg()
  6956. return nil
  6957. case batchmsg.FieldTag:
  6958. m.ResetTag()
  6959. return nil
  6960. case batchmsg.FieldTagids:
  6961. m.ResetTagids()
  6962. return nil
  6963. case batchmsg.FieldTotal:
  6964. m.ResetTotal()
  6965. return nil
  6966. case batchmsg.FieldSuccess:
  6967. m.ResetSuccess()
  6968. return nil
  6969. case batchmsg.FieldFail:
  6970. m.ResetFail()
  6971. return nil
  6972. case batchmsg.FieldStartTime:
  6973. m.ResetStartTime()
  6974. return nil
  6975. case batchmsg.FieldStopTime:
  6976. m.ResetStopTime()
  6977. return nil
  6978. case batchmsg.FieldSendTime:
  6979. m.ResetSendTime()
  6980. return nil
  6981. case batchmsg.FieldType:
  6982. m.ResetType()
  6983. return nil
  6984. case batchmsg.FieldOrganizationID:
  6985. m.ResetOrganizationID()
  6986. return nil
  6987. case batchmsg.FieldCtype:
  6988. m.ResetCtype()
  6989. return nil
  6990. case batchmsg.FieldCc:
  6991. m.ResetCc()
  6992. return nil
  6993. case batchmsg.FieldPhone:
  6994. m.ResetPhone()
  6995. return nil
  6996. case batchmsg.FieldTemplateName:
  6997. m.ResetTemplateName()
  6998. return nil
  6999. case batchmsg.FieldTemplateCode:
  7000. m.ResetTemplateCode()
  7001. return nil
  7002. case batchmsg.FieldLang:
  7003. m.ResetLang()
  7004. return nil
  7005. }
  7006. return fmt.Errorf("unknown BatchMsg field %s", name)
  7007. }
  7008. // AddedEdges returns all edge names that were set/added in this mutation.
  7009. func (m *BatchMsgMutation) AddedEdges() []string {
  7010. edges := make([]string, 0, 0)
  7011. return edges
  7012. }
  7013. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7014. // name in this mutation.
  7015. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7016. return nil
  7017. }
  7018. // RemovedEdges returns all edge names that were removed in this mutation.
  7019. func (m *BatchMsgMutation) RemovedEdges() []string {
  7020. edges := make([]string, 0, 0)
  7021. return edges
  7022. }
  7023. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7024. // the given name in this mutation.
  7025. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7026. return nil
  7027. }
  7028. // ClearedEdges returns all edge names that were cleared in this mutation.
  7029. func (m *BatchMsgMutation) ClearedEdges() []string {
  7030. edges := make([]string, 0, 0)
  7031. return edges
  7032. }
  7033. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7034. // was cleared in this mutation.
  7035. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7036. return false
  7037. }
  7038. // ClearEdge clears the value of the edge with the given name. It returns an error
  7039. // if that edge is not defined in the schema.
  7040. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7041. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7042. }
  7043. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7044. // It returns an error if the edge is not defined in the schema.
  7045. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7046. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7047. }
  7048. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7049. type CategoryMutation struct {
  7050. config
  7051. op Op
  7052. typ string
  7053. id *uint64
  7054. created_at *time.Time
  7055. updated_at *time.Time
  7056. deleted_at *time.Time
  7057. name *string
  7058. organization_id *uint64
  7059. addorganization_id *int64
  7060. clearedFields map[string]struct{}
  7061. done bool
  7062. oldValue func(context.Context) (*Category, error)
  7063. predicates []predicate.Category
  7064. }
  7065. var _ ent.Mutation = (*CategoryMutation)(nil)
  7066. // categoryOption allows management of the mutation configuration using functional options.
  7067. type categoryOption func(*CategoryMutation)
  7068. // newCategoryMutation creates new mutation for the Category entity.
  7069. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7070. m := &CategoryMutation{
  7071. config: c,
  7072. op: op,
  7073. typ: TypeCategory,
  7074. clearedFields: make(map[string]struct{}),
  7075. }
  7076. for _, opt := range opts {
  7077. opt(m)
  7078. }
  7079. return m
  7080. }
  7081. // withCategoryID sets the ID field of the mutation.
  7082. func withCategoryID(id uint64) categoryOption {
  7083. return func(m *CategoryMutation) {
  7084. var (
  7085. err error
  7086. once sync.Once
  7087. value *Category
  7088. )
  7089. m.oldValue = func(ctx context.Context) (*Category, error) {
  7090. once.Do(func() {
  7091. if m.done {
  7092. err = errors.New("querying old values post mutation is not allowed")
  7093. } else {
  7094. value, err = m.Client().Category.Get(ctx, id)
  7095. }
  7096. })
  7097. return value, err
  7098. }
  7099. m.id = &id
  7100. }
  7101. }
  7102. // withCategory sets the old Category of the mutation.
  7103. func withCategory(node *Category) categoryOption {
  7104. return func(m *CategoryMutation) {
  7105. m.oldValue = func(context.Context) (*Category, error) {
  7106. return node, nil
  7107. }
  7108. m.id = &node.ID
  7109. }
  7110. }
  7111. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7112. // executed in a transaction (ent.Tx), a transactional client is returned.
  7113. func (m CategoryMutation) Client() *Client {
  7114. client := &Client{config: m.config}
  7115. client.init()
  7116. return client
  7117. }
  7118. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7119. // it returns an error otherwise.
  7120. func (m CategoryMutation) Tx() (*Tx, error) {
  7121. if _, ok := m.driver.(*txDriver); !ok {
  7122. return nil, errors.New("ent: mutation is not running in a transaction")
  7123. }
  7124. tx := &Tx{config: m.config}
  7125. tx.init()
  7126. return tx, nil
  7127. }
  7128. // SetID sets the value of the id field. Note that this
  7129. // operation is only accepted on creation of Category entities.
  7130. func (m *CategoryMutation) SetID(id uint64) {
  7131. m.id = &id
  7132. }
  7133. // ID returns the ID value in the mutation. Note that the ID is only available
  7134. // if it was provided to the builder or after it was returned from the database.
  7135. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7136. if m.id == nil {
  7137. return
  7138. }
  7139. return *m.id, true
  7140. }
  7141. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7142. // That means, if the mutation is applied within a transaction with an isolation level such
  7143. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7144. // or updated by the mutation.
  7145. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7146. switch {
  7147. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7148. id, exists := m.ID()
  7149. if exists {
  7150. return []uint64{id}, nil
  7151. }
  7152. fallthrough
  7153. case m.op.Is(OpUpdate | OpDelete):
  7154. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7155. default:
  7156. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7157. }
  7158. }
  7159. // SetCreatedAt sets the "created_at" field.
  7160. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7161. m.created_at = &t
  7162. }
  7163. // CreatedAt returns the value of the "created_at" field in the mutation.
  7164. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7165. v := m.created_at
  7166. if v == nil {
  7167. return
  7168. }
  7169. return *v, true
  7170. }
  7171. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7172. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7174. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7175. if !m.op.Is(OpUpdateOne) {
  7176. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7177. }
  7178. if m.id == nil || m.oldValue == nil {
  7179. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7180. }
  7181. oldValue, err := m.oldValue(ctx)
  7182. if err != nil {
  7183. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7184. }
  7185. return oldValue.CreatedAt, nil
  7186. }
  7187. // ResetCreatedAt resets all changes to the "created_at" field.
  7188. func (m *CategoryMutation) ResetCreatedAt() {
  7189. m.created_at = nil
  7190. }
  7191. // SetUpdatedAt sets the "updated_at" field.
  7192. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7193. m.updated_at = &t
  7194. }
  7195. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7196. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7197. v := m.updated_at
  7198. if v == nil {
  7199. return
  7200. }
  7201. return *v, true
  7202. }
  7203. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7204. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7206. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7207. if !m.op.Is(OpUpdateOne) {
  7208. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7209. }
  7210. if m.id == nil || m.oldValue == nil {
  7211. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7212. }
  7213. oldValue, err := m.oldValue(ctx)
  7214. if err != nil {
  7215. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7216. }
  7217. return oldValue.UpdatedAt, nil
  7218. }
  7219. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7220. func (m *CategoryMutation) ResetUpdatedAt() {
  7221. m.updated_at = nil
  7222. }
  7223. // SetDeletedAt sets the "deleted_at" field.
  7224. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7225. m.deleted_at = &t
  7226. }
  7227. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7228. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7229. v := m.deleted_at
  7230. if v == nil {
  7231. return
  7232. }
  7233. return *v, true
  7234. }
  7235. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7236. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7238. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7239. if !m.op.Is(OpUpdateOne) {
  7240. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7241. }
  7242. if m.id == nil || m.oldValue == nil {
  7243. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7244. }
  7245. oldValue, err := m.oldValue(ctx)
  7246. if err != nil {
  7247. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7248. }
  7249. return oldValue.DeletedAt, nil
  7250. }
  7251. // ClearDeletedAt clears the value of the "deleted_at" field.
  7252. func (m *CategoryMutation) ClearDeletedAt() {
  7253. m.deleted_at = nil
  7254. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7255. }
  7256. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7257. func (m *CategoryMutation) DeletedAtCleared() bool {
  7258. _, ok := m.clearedFields[category.FieldDeletedAt]
  7259. return ok
  7260. }
  7261. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7262. func (m *CategoryMutation) ResetDeletedAt() {
  7263. m.deleted_at = nil
  7264. delete(m.clearedFields, category.FieldDeletedAt)
  7265. }
  7266. // SetName sets the "name" field.
  7267. func (m *CategoryMutation) SetName(s string) {
  7268. m.name = &s
  7269. }
  7270. // Name returns the value of the "name" field in the mutation.
  7271. func (m *CategoryMutation) Name() (r string, exists bool) {
  7272. v := m.name
  7273. if v == nil {
  7274. return
  7275. }
  7276. return *v, true
  7277. }
  7278. // OldName returns the old "name" field's value of the Category entity.
  7279. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7281. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7282. if !m.op.Is(OpUpdateOne) {
  7283. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7284. }
  7285. if m.id == nil || m.oldValue == nil {
  7286. return v, errors.New("OldName requires an ID field in the mutation")
  7287. }
  7288. oldValue, err := m.oldValue(ctx)
  7289. if err != nil {
  7290. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7291. }
  7292. return oldValue.Name, nil
  7293. }
  7294. // ResetName resets all changes to the "name" field.
  7295. func (m *CategoryMutation) ResetName() {
  7296. m.name = nil
  7297. }
  7298. // SetOrganizationID sets the "organization_id" field.
  7299. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7300. m.organization_id = &u
  7301. m.addorganization_id = nil
  7302. }
  7303. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7304. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7305. v := m.organization_id
  7306. if v == nil {
  7307. return
  7308. }
  7309. return *v, true
  7310. }
  7311. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7312. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7314. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7315. if !m.op.Is(OpUpdateOne) {
  7316. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7317. }
  7318. if m.id == nil || m.oldValue == nil {
  7319. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7320. }
  7321. oldValue, err := m.oldValue(ctx)
  7322. if err != nil {
  7323. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7324. }
  7325. return oldValue.OrganizationID, nil
  7326. }
  7327. // AddOrganizationID adds u to the "organization_id" field.
  7328. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7329. if m.addorganization_id != nil {
  7330. *m.addorganization_id += u
  7331. } else {
  7332. m.addorganization_id = &u
  7333. }
  7334. }
  7335. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7336. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7337. v := m.addorganization_id
  7338. if v == nil {
  7339. return
  7340. }
  7341. return *v, true
  7342. }
  7343. // ResetOrganizationID resets all changes to the "organization_id" field.
  7344. func (m *CategoryMutation) ResetOrganizationID() {
  7345. m.organization_id = nil
  7346. m.addorganization_id = nil
  7347. }
  7348. // Where appends a list predicates to the CategoryMutation builder.
  7349. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7350. m.predicates = append(m.predicates, ps...)
  7351. }
  7352. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7353. // users can use type-assertion to append predicates that do not depend on any generated package.
  7354. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7355. p := make([]predicate.Category, len(ps))
  7356. for i := range ps {
  7357. p[i] = ps[i]
  7358. }
  7359. m.Where(p...)
  7360. }
  7361. // Op returns the operation name.
  7362. func (m *CategoryMutation) Op() Op {
  7363. return m.op
  7364. }
  7365. // SetOp allows setting the mutation operation.
  7366. func (m *CategoryMutation) SetOp(op Op) {
  7367. m.op = op
  7368. }
  7369. // Type returns the node type of this mutation (Category).
  7370. func (m *CategoryMutation) Type() string {
  7371. return m.typ
  7372. }
  7373. // Fields returns all fields that were changed during this mutation. Note that in
  7374. // order to get all numeric fields that were incremented/decremented, call
  7375. // AddedFields().
  7376. func (m *CategoryMutation) Fields() []string {
  7377. fields := make([]string, 0, 5)
  7378. if m.created_at != nil {
  7379. fields = append(fields, category.FieldCreatedAt)
  7380. }
  7381. if m.updated_at != nil {
  7382. fields = append(fields, category.FieldUpdatedAt)
  7383. }
  7384. if m.deleted_at != nil {
  7385. fields = append(fields, category.FieldDeletedAt)
  7386. }
  7387. if m.name != nil {
  7388. fields = append(fields, category.FieldName)
  7389. }
  7390. if m.organization_id != nil {
  7391. fields = append(fields, category.FieldOrganizationID)
  7392. }
  7393. return fields
  7394. }
  7395. // Field returns the value of a field with the given name. The second boolean
  7396. // return value indicates that this field was not set, or was not defined in the
  7397. // schema.
  7398. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7399. switch name {
  7400. case category.FieldCreatedAt:
  7401. return m.CreatedAt()
  7402. case category.FieldUpdatedAt:
  7403. return m.UpdatedAt()
  7404. case category.FieldDeletedAt:
  7405. return m.DeletedAt()
  7406. case category.FieldName:
  7407. return m.Name()
  7408. case category.FieldOrganizationID:
  7409. return m.OrganizationID()
  7410. }
  7411. return nil, false
  7412. }
  7413. // OldField returns the old value of the field from the database. An error is
  7414. // returned if the mutation operation is not UpdateOne, or the query to the
  7415. // database failed.
  7416. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7417. switch name {
  7418. case category.FieldCreatedAt:
  7419. return m.OldCreatedAt(ctx)
  7420. case category.FieldUpdatedAt:
  7421. return m.OldUpdatedAt(ctx)
  7422. case category.FieldDeletedAt:
  7423. return m.OldDeletedAt(ctx)
  7424. case category.FieldName:
  7425. return m.OldName(ctx)
  7426. case category.FieldOrganizationID:
  7427. return m.OldOrganizationID(ctx)
  7428. }
  7429. return nil, fmt.Errorf("unknown Category field %s", name)
  7430. }
  7431. // SetField sets the value of a field with the given name. It returns an error if
  7432. // the field is not defined in the schema, or if the type mismatched the field
  7433. // type.
  7434. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7435. switch name {
  7436. case category.FieldCreatedAt:
  7437. v, ok := value.(time.Time)
  7438. if !ok {
  7439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7440. }
  7441. m.SetCreatedAt(v)
  7442. return nil
  7443. case category.FieldUpdatedAt:
  7444. v, ok := value.(time.Time)
  7445. if !ok {
  7446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7447. }
  7448. m.SetUpdatedAt(v)
  7449. return nil
  7450. case category.FieldDeletedAt:
  7451. v, ok := value.(time.Time)
  7452. if !ok {
  7453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7454. }
  7455. m.SetDeletedAt(v)
  7456. return nil
  7457. case category.FieldName:
  7458. v, ok := value.(string)
  7459. if !ok {
  7460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7461. }
  7462. m.SetName(v)
  7463. return nil
  7464. case category.FieldOrganizationID:
  7465. v, ok := value.(uint64)
  7466. if !ok {
  7467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7468. }
  7469. m.SetOrganizationID(v)
  7470. return nil
  7471. }
  7472. return fmt.Errorf("unknown Category field %s", name)
  7473. }
  7474. // AddedFields returns all numeric fields that were incremented/decremented during
  7475. // this mutation.
  7476. func (m *CategoryMutation) AddedFields() []string {
  7477. var fields []string
  7478. if m.addorganization_id != nil {
  7479. fields = append(fields, category.FieldOrganizationID)
  7480. }
  7481. return fields
  7482. }
  7483. // AddedField returns the numeric value that was incremented/decremented on a field
  7484. // with the given name. The second boolean return value indicates that this field
  7485. // was not set, or was not defined in the schema.
  7486. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7487. switch name {
  7488. case category.FieldOrganizationID:
  7489. return m.AddedOrganizationID()
  7490. }
  7491. return nil, false
  7492. }
  7493. // AddField adds the value to the field with the given name. It returns an error if
  7494. // the field is not defined in the schema, or if the type mismatched the field
  7495. // type.
  7496. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7497. switch name {
  7498. case category.FieldOrganizationID:
  7499. v, ok := value.(int64)
  7500. if !ok {
  7501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7502. }
  7503. m.AddOrganizationID(v)
  7504. return nil
  7505. }
  7506. return fmt.Errorf("unknown Category numeric field %s", name)
  7507. }
  7508. // ClearedFields returns all nullable fields that were cleared during this
  7509. // mutation.
  7510. func (m *CategoryMutation) ClearedFields() []string {
  7511. var fields []string
  7512. if m.FieldCleared(category.FieldDeletedAt) {
  7513. fields = append(fields, category.FieldDeletedAt)
  7514. }
  7515. return fields
  7516. }
  7517. // FieldCleared returns a boolean indicating if a field with the given name was
  7518. // cleared in this mutation.
  7519. func (m *CategoryMutation) FieldCleared(name string) bool {
  7520. _, ok := m.clearedFields[name]
  7521. return ok
  7522. }
  7523. // ClearField clears the value of the field with the given name. It returns an
  7524. // error if the field is not defined in the schema.
  7525. func (m *CategoryMutation) ClearField(name string) error {
  7526. switch name {
  7527. case category.FieldDeletedAt:
  7528. m.ClearDeletedAt()
  7529. return nil
  7530. }
  7531. return fmt.Errorf("unknown Category nullable field %s", name)
  7532. }
  7533. // ResetField resets all changes in the mutation for the field with the given name.
  7534. // It returns an error if the field is not defined in the schema.
  7535. func (m *CategoryMutation) ResetField(name string) error {
  7536. switch name {
  7537. case category.FieldCreatedAt:
  7538. m.ResetCreatedAt()
  7539. return nil
  7540. case category.FieldUpdatedAt:
  7541. m.ResetUpdatedAt()
  7542. return nil
  7543. case category.FieldDeletedAt:
  7544. m.ResetDeletedAt()
  7545. return nil
  7546. case category.FieldName:
  7547. m.ResetName()
  7548. return nil
  7549. case category.FieldOrganizationID:
  7550. m.ResetOrganizationID()
  7551. return nil
  7552. }
  7553. return fmt.Errorf("unknown Category field %s", name)
  7554. }
  7555. // AddedEdges returns all edge names that were set/added in this mutation.
  7556. func (m *CategoryMutation) AddedEdges() []string {
  7557. edges := make([]string, 0, 0)
  7558. return edges
  7559. }
  7560. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7561. // name in this mutation.
  7562. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7563. return nil
  7564. }
  7565. // RemovedEdges returns all edge names that were removed in this mutation.
  7566. func (m *CategoryMutation) RemovedEdges() []string {
  7567. edges := make([]string, 0, 0)
  7568. return edges
  7569. }
  7570. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7571. // the given name in this mutation.
  7572. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7573. return nil
  7574. }
  7575. // ClearedEdges returns all edge names that were cleared in this mutation.
  7576. func (m *CategoryMutation) ClearedEdges() []string {
  7577. edges := make([]string, 0, 0)
  7578. return edges
  7579. }
  7580. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7581. // was cleared in this mutation.
  7582. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7583. return false
  7584. }
  7585. // ClearEdge clears the value of the edge with the given name. It returns an error
  7586. // if that edge is not defined in the schema.
  7587. func (m *CategoryMutation) ClearEdge(name string) error {
  7588. return fmt.Errorf("unknown Category unique edge %s", name)
  7589. }
  7590. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7591. // It returns an error if the edge is not defined in the schema.
  7592. func (m *CategoryMutation) ResetEdge(name string) error {
  7593. return fmt.Errorf("unknown Category edge %s", name)
  7594. }
  7595. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7596. type ChatRecordsMutation struct {
  7597. config
  7598. op Op
  7599. typ string
  7600. id *uint64
  7601. created_at *time.Time
  7602. updated_at *time.Time
  7603. deleted_at *time.Time
  7604. content *string
  7605. content_type *uint8
  7606. addcontent_type *int8
  7607. session_id *uint64
  7608. addsession_id *int64
  7609. user_id *uint64
  7610. adduser_id *int64
  7611. bot_id *uint64
  7612. addbot_id *int64
  7613. bot_type *uint8
  7614. addbot_type *int8
  7615. clearedFields map[string]struct{}
  7616. done bool
  7617. oldValue func(context.Context) (*ChatRecords, error)
  7618. predicates []predicate.ChatRecords
  7619. }
  7620. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7621. // chatrecordsOption allows management of the mutation configuration using functional options.
  7622. type chatrecordsOption func(*ChatRecordsMutation)
  7623. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7624. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7625. m := &ChatRecordsMutation{
  7626. config: c,
  7627. op: op,
  7628. typ: TypeChatRecords,
  7629. clearedFields: make(map[string]struct{}),
  7630. }
  7631. for _, opt := range opts {
  7632. opt(m)
  7633. }
  7634. return m
  7635. }
  7636. // withChatRecordsID sets the ID field of the mutation.
  7637. func withChatRecordsID(id uint64) chatrecordsOption {
  7638. return func(m *ChatRecordsMutation) {
  7639. var (
  7640. err error
  7641. once sync.Once
  7642. value *ChatRecords
  7643. )
  7644. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7645. once.Do(func() {
  7646. if m.done {
  7647. err = errors.New("querying old values post mutation is not allowed")
  7648. } else {
  7649. value, err = m.Client().ChatRecords.Get(ctx, id)
  7650. }
  7651. })
  7652. return value, err
  7653. }
  7654. m.id = &id
  7655. }
  7656. }
  7657. // withChatRecords sets the old ChatRecords of the mutation.
  7658. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7659. return func(m *ChatRecordsMutation) {
  7660. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7661. return node, nil
  7662. }
  7663. m.id = &node.ID
  7664. }
  7665. }
  7666. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7667. // executed in a transaction (ent.Tx), a transactional client is returned.
  7668. func (m ChatRecordsMutation) Client() *Client {
  7669. client := &Client{config: m.config}
  7670. client.init()
  7671. return client
  7672. }
  7673. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7674. // it returns an error otherwise.
  7675. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7676. if _, ok := m.driver.(*txDriver); !ok {
  7677. return nil, errors.New("ent: mutation is not running in a transaction")
  7678. }
  7679. tx := &Tx{config: m.config}
  7680. tx.init()
  7681. return tx, nil
  7682. }
  7683. // SetID sets the value of the id field. Note that this
  7684. // operation is only accepted on creation of ChatRecords entities.
  7685. func (m *ChatRecordsMutation) SetID(id uint64) {
  7686. m.id = &id
  7687. }
  7688. // ID returns the ID value in the mutation. Note that the ID is only available
  7689. // if it was provided to the builder or after it was returned from the database.
  7690. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  7691. if m.id == nil {
  7692. return
  7693. }
  7694. return *m.id, true
  7695. }
  7696. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7697. // That means, if the mutation is applied within a transaction with an isolation level such
  7698. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7699. // or updated by the mutation.
  7700. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7701. switch {
  7702. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7703. id, exists := m.ID()
  7704. if exists {
  7705. return []uint64{id}, nil
  7706. }
  7707. fallthrough
  7708. case m.op.Is(OpUpdate | OpDelete):
  7709. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  7710. default:
  7711. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7712. }
  7713. }
  7714. // SetCreatedAt sets the "created_at" field.
  7715. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  7716. m.created_at = &t
  7717. }
  7718. // CreatedAt returns the value of the "created_at" field in the mutation.
  7719. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7720. v := m.created_at
  7721. if v == nil {
  7722. return
  7723. }
  7724. return *v, true
  7725. }
  7726. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  7727. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7729. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7730. if !m.op.Is(OpUpdateOne) {
  7731. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7732. }
  7733. if m.id == nil || m.oldValue == nil {
  7734. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7735. }
  7736. oldValue, err := m.oldValue(ctx)
  7737. if err != nil {
  7738. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7739. }
  7740. return oldValue.CreatedAt, nil
  7741. }
  7742. // ResetCreatedAt resets all changes to the "created_at" field.
  7743. func (m *ChatRecordsMutation) ResetCreatedAt() {
  7744. m.created_at = nil
  7745. }
  7746. // SetUpdatedAt sets the "updated_at" field.
  7747. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  7748. m.updated_at = &t
  7749. }
  7750. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7751. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7752. v := m.updated_at
  7753. if v == nil {
  7754. return
  7755. }
  7756. return *v, true
  7757. }
  7758. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  7759. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7761. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7762. if !m.op.Is(OpUpdateOne) {
  7763. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7764. }
  7765. if m.id == nil || m.oldValue == nil {
  7766. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7767. }
  7768. oldValue, err := m.oldValue(ctx)
  7769. if err != nil {
  7770. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7771. }
  7772. return oldValue.UpdatedAt, nil
  7773. }
  7774. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7775. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  7776. m.updated_at = nil
  7777. }
  7778. // SetDeletedAt sets the "deleted_at" field.
  7779. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  7780. m.deleted_at = &t
  7781. }
  7782. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7783. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  7784. v := m.deleted_at
  7785. if v == nil {
  7786. return
  7787. }
  7788. return *v, true
  7789. }
  7790. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  7791. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7793. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7794. if !m.op.Is(OpUpdateOne) {
  7795. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7796. }
  7797. if m.id == nil || m.oldValue == nil {
  7798. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7799. }
  7800. oldValue, err := m.oldValue(ctx)
  7801. if err != nil {
  7802. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7803. }
  7804. return oldValue.DeletedAt, nil
  7805. }
  7806. // ClearDeletedAt clears the value of the "deleted_at" field.
  7807. func (m *ChatRecordsMutation) ClearDeletedAt() {
  7808. m.deleted_at = nil
  7809. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  7810. }
  7811. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7812. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  7813. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  7814. return ok
  7815. }
  7816. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7817. func (m *ChatRecordsMutation) ResetDeletedAt() {
  7818. m.deleted_at = nil
  7819. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  7820. }
  7821. // SetContent sets the "content" field.
  7822. func (m *ChatRecordsMutation) SetContent(s string) {
  7823. m.content = &s
  7824. }
  7825. // Content returns the value of the "content" field in the mutation.
  7826. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  7827. v := m.content
  7828. if v == nil {
  7829. return
  7830. }
  7831. return *v, true
  7832. }
  7833. // OldContent returns the old "content" field's value of the ChatRecords entity.
  7834. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7836. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  7837. if !m.op.Is(OpUpdateOne) {
  7838. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7839. }
  7840. if m.id == nil || m.oldValue == nil {
  7841. return v, errors.New("OldContent requires an ID field in the mutation")
  7842. }
  7843. oldValue, err := m.oldValue(ctx)
  7844. if err != nil {
  7845. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  7846. }
  7847. return oldValue.Content, nil
  7848. }
  7849. // ResetContent resets all changes to the "content" field.
  7850. func (m *ChatRecordsMutation) ResetContent() {
  7851. m.content = nil
  7852. }
  7853. // SetContentType sets the "content_type" field.
  7854. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  7855. m.content_type = &u
  7856. m.addcontent_type = nil
  7857. }
  7858. // ContentType returns the value of the "content_type" field in the mutation.
  7859. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  7860. v := m.content_type
  7861. if v == nil {
  7862. return
  7863. }
  7864. return *v, true
  7865. }
  7866. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  7867. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7869. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  7870. if !m.op.Is(OpUpdateOne) {
  7871. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  7872. }
  7873. if m.id == nil || m.oldValue == nil {
  7874. return v, errors.New("OldContentType requires an ID field in the mutation")
  7875. }
  7876. oldValue, err := m.oldValue(ctx)
  7877. if err != nil {
  7878. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  7879. }
  7880. return oldValue.ContentType, nil
  7881. }
  7882. // AddContentType adds u to the "content_type" field.
  7883. func (m *ChatRecordsMutation) AddContentType(u int8) {
  7884. if m.addcontent_type != nil {
  7885. *m.addcontent_type += u
  7886. } else {
  7887. m.addcontent_type = &u
  7888. }
  7889. }
  7890. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  7891. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  7892. v := m.addcontent_type
  7893. if v == nil {
  7894. return
  7895. }
  7896. return *v, true
  7897. }
  7898. // ResetContentType resets all changes to the "content_type" field.
  7899. func (m *ChatRecordsMutation) ResetContentType() {
  7900. m.content_type = nil
  7901. m.addcontent_type = nil
  7902. }
  7903. // SetSessionID sets the "session_id" field.
  7904. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  7905. m.session_id = &u
  7906. m.addsession_id = nil
  7907. }
  7908. // SessionID returns the value of the "session_id" field in the mutation.
  7909. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  7910. v := m.session_id
  7911. if v == nil {
  7912. return
  7913. }
  7914. return *v, true
  7915. }
  7916. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  7917. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7919. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  7920. if !m.op.Is(OpUpdateOne) {
  7921. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  7922. }
  7923. if m.id == nil || m.oldValue == nil {
  7924. return v, errors.New("OldSessionID requires an ID field in the mutation")
  7925. }
  7926. oldValue, err := m.oldValue(ctx)
  7927. if err != nil {
  7928. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  7929. }
  7930. return oldValue.SessionID, nil
  7931. }
  7932. // AddSessionID adds u to the "session_id" field.
  7933. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  7934. if m.addsession_id != nil {
  7935. *m.addsession_id += u
  7936. } else {
  7937. m.addsession_id = &u
  7938. }
  7939. }
  7940. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  7941. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  7942. v := m.addsession_id
  7943. if v == nil {
  7944. return
  7945. }
  7946. return *v, true
  7947. }
  7948. // ResetSessionID resets all changes to the "session_id" field.
  7949. func (m *ChatRecordsMutation) ResetSessionID() {
  7950. m.session_id = nil
  7951. m.addsession_id = nil
  7952. }
  7953. // SetUserID sets the "user_id" field.
  7954. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  7955. m.user_id = &u
  7956. m.adduser_id = nil
  7957. }
  7958. // UserID returns the value of the "user_id" field in the mutation.
  7959. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  7960. v := m.user_id
  7961. if v == nil {
  7962. return
  7963. }
  7964. return *v, true
  7965. }
  7966. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  7967. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7969. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7970. if !m.op.Is(OpUpdateOne) {
  7971. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7972. }
  7973. if m.id == nil || m.oldValue == nil {
  7974. return v, errors.New("OldUserID requires an ID field in the mutation")
  7975. }
  7976. oldValue, err := m.oldValue(ctx)
  7977. if err != nil {
  7978. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7979. }
  7980. return oldValue.UserID, nil
  7981. }
  7982. // AddUserID adds u to the "user_id" field.
  7983. func (m *ChatRecordsMutation) AddUserID(u int64) {
  7984. if m.adduser_id != nil {
  7985. *m.adduser_id += u
  7986. } else {
  7987. m.adduser_id = &u
  7988. }
  7989. }
  7990. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7991. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  7992. v := m.adduser_id
  7993. if v == nil {
  7994. return
  7995. }
  7996. return *v, true
  7997. }
  7998. // ResetUserID resets all changes to the "user_id" field.
  7999. func (m *ChatRecordsMutation) ResetUserID() {
  8000. m.user_id = nil
  8001. m.adduser_id = nil
  8002. }
  8003. // SetBotID sets the "bot_id" field.
  8004. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8005. m.bot_id = &u
  8006. m.addbot_id = nil
  8007. }
  8008. // BotID returns the value of the "bot_id" field in the mutation.
  8009. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8010. v := m.bot_id
  8011. if v == nil {
  8012. return
  8013. }
  8014. return *v, true
  8015. }
  8016. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8017. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8019. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8020. if !m.op.Is(OpUpdateOne) {
  8021. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8022. }
  8023. if m.id == nil || m.oldValue == nil {
  8024. return v, errors.New("OldBotID requires an ID field in the mutation")
  8025. }
  8026. oldValue, err := m.oldValue(ctx)
  8027. if err != nil {
  8028. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8029. }
  8030. return oldValue.BotID, nil
  8031. }
  8032. // AddBotID adds u to the "bot_id" field.
  8033. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8034. if m.addbot_id != nil {
  8035. *m.addbot_id += u
  8036. } else {
  8037. m.addbot_id = &u
  8038. }
  8039. }
  8040. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8041. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8042. v := m.addbot_id
  8043. if v == nil {
  8044. return
  8045. }
  8046. return *v, true
  8047. }
  8048. // ResetBotID resets all changes to the "bot_id" field.
  8049. func (m *ChatRecordsMutation) ResetBotID() {
  8050. m.bot_id = nil
  8051. m.addbot_id = nil
  8052. }
  8053. // SetBotType sets the "bot_type" field.
  8054. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8055. m.bot_type = &u
  8056. m.addbot_type = nil
  8057. }
  8058. // BotType returns the value of the "bot_type" field in the mutation.
  8059. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8060. v := m.bot_type
  8061. if v == nil {
  8062. return
  8063. }
  8064. return *v, true
  8065. }
  8066. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8067. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8069. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8070. if !m.op.Is(OpUpdateOne) {
  8071. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8072. }
  8073. if m.id == nil || m.oldValue == nil {
  8074. return v, errors.New("OldBotType requires an ID field in the mutation")
  8075. }
  8076. oldValue, err := m.oldValue(ctx)
  8077. if err != nil {
  8078. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8079. }
  8080. return oldValue.BotType, nil
  8081. }
  8082. // AddBotType adds u to the "bot_type" field.
  8083. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8084. if m.addbot_type != nil {
  8085. *m.addbot_type += u
  8086. } else {
  8087. m.addbot_type = &u
  8088. }
  8089. }
  8090. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8091. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8092. v := m.addbot_type
  8093. if v == nil {
  8094. return
  8095. }
  8096. return *v, true
  8097. }
  8098. // ResetBotType resets all changes to the "bot_type" field.
  8099. func (m *ChatRecordsMutation) ResetBotType() {
  8100. m.bot_type = nil
  8101. m.addbot_type = nil
  8102. }
  8103. // Where appends a list predicates to the ChatRecordsMutation builder.
  8104. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8105. m.predicates = append(m.predicates, ps...)
  8106. }
  8107. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8108. // users can use type-assertion to append predicates that do not depend on any generated package.
  8109. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8110. p := make([]predicate.ChatRecords, len(ps))
  8111. for i := range ps {
  8112. p[i] = ps[i]
  8113. }
  8114. m.Where(p...)
  8115. }
  8116. // Op returns the operation name.
  8117. func (m *ChatRecordsMutation) Op() Op {
  8118. return m.op
  8119. }
  8120. // SetOp allows setting the mutation operation.
  8121. func (m *ChatRecordsMutation) SetOp(op Op) {
  8122. m.op = op
  8123. }
  8124. // Type returns the node type of this mutation (ChatRecords).
  8125. func (m *ChatRecordsMutation) Type() string {
  8126. return m.typ
  8127. }
  8128. // Fields returns all fields that were changed during this mutation. Note that in
  8129. // order to get all numeric fields that were incremented/decremented, call
  8130. // AddedFields().
  8131. func (m *ChatRecordsMutation) Fields() []string {
  8132. fields := make([]string, 0, 9)
  8133. if m.created_at != nil {
  8134. fields = append(fields, chatrecords.FieldCreatedAt)
  8135. }
  8136. if m.updated_at != nil {
  8137. fields = append(fields, chatrecords.FieldUpdatedAt)
  8138. }
  8139. if m.deleted_at != nil {
  8140. fields = append(fields, chatrecords.FieldDeletedAt)
  8141. }
  8142. if m.content != nil {
  8143. fields = append(fields, chatrecords.FieldContent)
  8144. }
  8145. if m.content_type != nil {
  8146. fields = append(fields, chatrecords.FieldContentType)
  8147. }
  8148. if m.session_id != nil {
  8149. fields = append(fields, chatrecords.FieldSessionID)
  8150. }
  8151. if m.user_id != nil {
  8152. fields = append(fields, chatrecords.FieldUserID)
  8153. }
  8154. if m.bot_id != nil {
  8155. fields = append(fields, chatrecords.FieldBotID)
  8156. }
  8157. if m.bot_type != nil {
  8158. fields = append(fields, chatrecords.FieldBotType)
  8159. }
  8160. return fields
  8161. }
  8162. // Field returns the value of a field with the given name. The second boolean
  8163. // return value indicates that this field was not set, or was not defined in the
  8164. // schema.
  8165. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8166. switch name {
  8167. case chatrecords.FieldCreatedAt:
  8168. return m.CreatedAt()
  8169. case chatrecords.FieldUpdatedAt:
  8170. return m.UpdatedAt()
  8171. case chatrecords.FieldDeletedAt:
  8172. return m.DeletedAt()
  8173. case chatrecords.FieldContent:
  8174. return m.Content()
  8175. case chatrecords.FieldContentType:
  8176. return m.ContentType()
  8177. case chatrecords.FieldSessionID:
  8178. return m.SessionID()
  8179. case chatrecords.FieldUserID:
  8180. return m.UserID()
  8181. case chatrecords.FieldBotID:
  8182. return m.BotID()
  8183. case chatrecords.FieldBotType:
  8184. return m.BotType()
  8185. }
  8186. return nil, false
  8187. }
  8188. // OldField returns the old value of the field from the database. An error is
  8189. // returned if the mutation operation is not UpdateOne, or the query to the
  8190. // database failed.
  8191. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8192. switch name {
  8193. case chatrecords.FieldCreatedAt:
  8194. return m.OldCreatedAt(ctx)
  8195. case chatrecords.FieldUpdatedAt:
  8196. return m.OldUpdatedAt(ctx)
  8197. case chatrecords.FieldDeletedAt:
  8198. return m.OldDeletedAt(ctx)
  8199. case chatrecords.FieldContent:
  8200. return m.OldContent(ctx)
  8201. case chatrecords.FieldContentType:
  8202. return m.OldContentType(ctx)
  8203. case chatrecords.FieldSessionID:
  8204. return m.OldSessionID(ctx)
  8205. case chatrecords.FieldUserID:
  8206. return m.OldUserID(ctx)
  8207. case chatrecords.FieldBotID:
  8208. return m.OldBotID(ctx)
  8209. case chatrecords.FieldBotType:
  8210. return m.OldBotType(ctx)
  8211. }
  8212. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8213. }
  8214. // SetField sets the value of a field with the given name. It returns an error if
  8215. // the field is not defined in the schema, or if the type mismatched the field
  8216. // type.
  8217. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8218. switch name {
  8219. case chatrecords.FieldCreatedAt:
  8220. v, ok := value.(time.Time)
  8221. if !ok {
  8222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8223. }
  8224. m.SetCreatedAt(v)
  8225. return nil
  8226. case chatrecords.FieldUpdatedAt:
  8227. v, ok := value.(time.Time)
  8228. if !ok {
  8229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8230. }
  8231. m.SetUpdatedAt(v)
  8232. return nil
  8233. case chatrecords.FieldDeletedAt:
  8234. v, ok := value.(time.Time)
  8235. if !ok {
  8236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8237. }
  8238. m.SetDeletedAt(v)
  8239. return nil
  8240. case chatrecords.FieldContent:
  8241. v, ok := value.(string)
  8242. if !ok {
  8243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8244. }
  8245. m.SetContent(v)
  8246. return nil
  8247. case chatrecords.FieldContentType:
  8248. v, ok := value.(uint8)
  8249. if !ok {
  8250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8251. }
  8252. m.SetContentType(v)
  8253. return nil
  8254. case chatrecords.FieldSessionID:
  8255. v, ok := value.(uint64)
  8256. if !ok {
  8257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8258. }
  8259. m.SetSessionID(v)
  8260. return nil
  8261. case chatrecords.FieldUserID:
  8262. v, ok := value.(uint64)
  8263. if !ok {
  8264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8265. }
  8266. m.SetUserID(v)
  8267. return nil
  8268. case chatrecords.FieldBotID:
  8269. v, ok := value.(uint64)
  8270. if !ok {
  8271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8272. }
  8273. m.SetBotID(v)
  8274. return nil
  8275. case chatrecords.FieldBotType:
  8276. v, ok := value.(uint8)
  8277. if !ok {
  8278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8279. }
  8280. m.SetBotType(v)
  8281. return nil
  8282. }
  8283. return fmt.Errorf("unknown ChatRecords field %s", name)
  8284. }
  8285. // AddedFields returns all numeric fields that were incremented/decremented during
  8286. // this mutation.
  8287. func (m *ChatRecordsMutation) AddedFields() []string {
  8288. var fields []string
  8289. if m.addcontent_type != nil {
  8290. fields = append(fields, chatrecords.FieldContentType)
  8291. }
  8292. if m.addsession_id != nil {
  8293. fields = append(fields, chatrecords.FieldSessionID)
  8294. }
  8295. if m.adduser_id != nil {
  8296. fields = append(fields, chatrecords.FieldUserID)
  8297. }
  8298. if m.addbot_id != nil {
  8299. fields = append(fields, chatrecords.FieldBotID)
  8300. }
  8301. if m.addbot_type != nil {
  8302. fields = append(fields, chatrecords.FieldBotType)
  8303. }
  8304. return fields
  8305. }
  8306. // AddedField returns the numeric value that was incremented/decremented on a field
  8307. // with the given name. The second boolean return value indicates that this field
  8308. // was not set, or was not defined in the schema.
  8309. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8310. switch name {
  8311. case chatrecords.FieldContentType:
  8312. return m.AddedContentType()
  8313. case chatrecords.FieldSessionID:
  8314. return m.AddedSessionID()
  8315. case chatrecords.FieldUserID:
  8316. return m.AddedUserID()
  8317. case chatrecords.FieldBotID:
  8318. return m.AddedBotID()
  8319. case chatrecords.FieldBotType:
  8320. return m.AddedBotType()
  8321. }
  8322. return nil, false
  8323. }
  8324. // AddField adds the value to the field with the given name. It returns an error if
  8325. // the field is not defined in the schema, or if the type mismatched the field
  8326. // type.
  8327. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8328. switch name {
  8329. case chatrecords.FieldContentType:
  8330. v, ok := value.(int8)
  8331. if !ok {
  8332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8333. }
  8334. m.AddContentType(v)
  8335. return nil
  8336. case chatrecords.FieldSessionID:
  8337. v, ok := value.(int64)
  8338. if !ok {
  8339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8340. }
  8341. m.AddSessionID(v)
  8342. return nil
  8343. case chatrecords.FieldUserID:
  8344. v, ok := value.(int64)
  8345. if !ok {
  8346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8347. }
  8348. m.AddUserID(v)
  8349. return nil
  8350. case chatrecords.FieldBotID:
  8351. v, ok := value.(int64)
  8352. if !ok {
  8353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8354. }
  8355. m.AddBotID(v)
  8356. return nil
  8357. case chatrecords.FieldBotType:
  8358. v, ok := value.(int8)
  8359. if !ok {
  8360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8361. }
  8362. m.AddBotType(v)
  8363. return nil
  8364. }
  8365. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8366. }
  8367. // ClearedFields returns all nullable fields that were cleared during this
  8368. // mutation.
  8369. func (m *ChatRecordsMutation) ClearedFields() []string {
  8370. var fields []string
  8371. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8372. fields = append(fields, chatrecords.FieldDeletedAt)
  8373. }
  8374. return fields
  8375. }
  8376. // FieldCleared returns a boolean indicating if a field with the given name was
  8377. // cleared in this mutation.
  8378. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8379. _, ok := m.clearedFields[name]
  8380. return ok
  8381. }
  8382. // ClearField clears the value of the field with the given name. It returns an
  8383. // error if the field is not defined in the schema.
  8384. func (m *ChatRecordsMutation) ClearField(name string) error {
  8385. switch name {
  8386. case chatrecords.FieldDeletedAt:
  8387. m.ClearDeletedAt()
  8388. return nil
  8389. }
  8390. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8391. }
  8392. // ResetField resets all changes in the mutation for the field with the given name.
  8393. // It returns an error if the field is not defined in the schema.
  8394. func (m *ChatRecordsMutation) ResetField(name string) error {
  8395. switch name {
  8396. case chatrecords.FieldCreatedAt:
  8397. m.ResetCreatedAt()
  8398. return nil
  8399. case chatrecords.FieldUpdatedAt:
  8400. m.ResetUpdatedAt()
  8401. return nil
  8402. case chatrecords.FieldDeletedAt:
  8403. m.ResetDeletedAt()
  8404. return nil
  8405. case chatrecords.FieldContent:
  8406. m.ResetContent()
  8407. return nil
  8408. case chatrecords.FieldContentType:
  8409. m.ResetContentType()
  8410. return nil
  8411. case chatrecords.FieldSessionID:
  8412. m.ResetSessionID()
  8413. return nil
  8414. case chatrecords.FieldUserID:
  8415. m.ResetUserID()
  8416. return nil
  8417. case chatrecords.FieldBotID:
  8418. m.ResetBotID()
  8419. return nil
  8420. case chatrecords.FieldBotType:
  8421. m.ResetBotType()
  8422. return nil
  8423. }
  8424. return fmt.Errorf("unknown ChatRecords field %s", name)
  8425. }
  8426. // AddedEdges returns all edge names that were set/added in this mutation.
  8427. func (m *ChatRecordsMutation) AddedEdges() []string {
  8428. edges := make([]string, 0, 0)
  8429. return edges
  8430. }
  8431. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8432. // name in this mutation.
  8433. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8434. return nil
  8435. }
  8436. // RemovedEdges returns all edge names that were removed in this mutation.
  8437. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8438. edges := make([]string, 0, 0)
  8439. return edges
  8440. }
  8441. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8442. // the given name in this mutation.
  8443. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8444. return nil
  8445. }
  8446. // ClearedEdges returns all edge names that were cleared in this mutation.
  8447. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8448. edges := make([]string, 0, 0)
  8449. return edges
  8450. }
  8451. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8452. // was cleared in this mutation.
  8453. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8454. return false
  8455. }
  8456. // ClearEdge clears the value of the edge with the given name. It returns an error
  8457. // if that edge is not defined in the schema.
  8458. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8459. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8460. }
  8461. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8462. // It returns an error if the edge is not defined in the schema.
  8463. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8464. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8465. }
  8466. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8467. type ChatSessionMutation struct {
  8468. config
  8469. op Op
  8470. typ string
  8471. id *uint64
  8472. created_at *time.Time
  8473. updated_at *time.Time
  8474. deleted_at *time.Time
  8475. name *string
  8476. user_id *uint64
  8477. adduser_id *int64
  8478. bot_id *uint64
  8479. addbot_id *int64
  8480. bot_type *uint8
  8481. addbot_type *int8
  8482. clearedFields map[string]struct{}
  8483. done bool
  8484. oldValue func(context.Context) (*ChatSession, error)
  8485. predicates []predicate.ChatSession
  8486. }
  8487. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8488. // chatsessionOption allows management of the mutation configuration using functional options.
  8489. type chatsessionOption func(*ChatSessionMutation)
  8490. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8491. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8492. m := &ChatSessionMutation{
  8493. config: c,
  8494. op: op,
  8495. typ: TypeChatSession,
  8496. clearedFields: make(map[string]struct{}),
  8497. }
  8498. for _, opt := range opts {
  8499. opt(m)
  8500. }
  8501. return m
  8502. }
  8503. // withChatSessionID sets the ID field of the mutation.
  8504. func withChatSessionID(id uint64) chatsessionOption {
  8505. return func(m *ChatSessionMutation) {
  8506. var (
  8507. err error
  8508. once sync.Once
  8509. value *ChatSession
  8510. )
  8511. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8512. once.Do(func() {
  8513. if m.done {
  8514. err = errors.New("querying old values post mutation is not allowed")
  8515. } else {
  8516. value, err = m.Client().ChatSession.Get(ctx, id)
  8517. }
  8518. })
  8519. return value, err
  8520. }
  8521. m.id = &id
  8522. }
  8523. }
  8524. // withChatSession sets the old ChatSession of the mutation.
  8525. func withChatSession(node *ChatSession) chatsessionOption {
  8526. return func(m *ChatSessionMutation) {
  8527. m.oldValue = func(context.Context) (*ChatSession, error) {
  8528. return node, nil
  8529. }
  8530. m.id = &node.ID
  8531. }
  8532. }
  8533. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8534. // executed in a transaction (ent.Tx), a transactional client is returned.
  8535. func (m ChatSessionMutation) Client() *Client {
  8536. client := &Client{config: m.config}
  8537. client.init()
  8538. return client
  8539. }
  8540. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8541. // it returns an error otherwise.
  8542. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8543. if _, ok := m.driver.(*txDriver); !ok {
  8544. return nil, errors.New("ent: mutation is not running in a transaction")
  8545. }
  8546. tx := &Tx{config: m.config}
  8547. tx.init()
  8548. return tx, nil
  8549. }
  8550. // SetID sets the value of the id field. Note that this
  8551. // operation is only accepted on creation of ChatSession entities.
  8552. func (m *ChatSessionMutation) SetID(id uint64) {
  8553. m.id = &id
  8554. }
  8555. // ID returns the ID value in the mutation. Note that the ID is only available
  8556. // if it was provided to the builder or after it was returned from the database.
  8557. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8558. if m.id == nil {
  8559. return
  8560. }
  8561. return *m.id, true
  8562. }
  8563. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8564. // That means, if the mutation is applied within a transaction with an isolation level such
  8565. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8566. // or updated by the mutation.
  8567. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8568. switch {
  8569. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8570. id, exists := m.ID()
  8571. if exists {
  8572. return []uint64{id}, nil
  8573. }
  8574. fallthrough
  8575. case m.op.Is(OpUpdate | OpDelete):
  8576. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8577. default:
  8578. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8579. }
  8580. }
  8581. // SetCreatedAt sets the "created_at" field.
  8582. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8583. m.created_at = &t
  8584. }
  8585. // CreatedAt returns the value of the "created_at" field in the mutation.
  8586. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8587. v := m.created_at
  8588. if v == nil {
  8589. return
  8590. }
  8591. return *v, true
  8592. }
  8593. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8594. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8596. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8597. if !m.op.Is(OpUpdateOne) {
  8598. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8599. }
  8600. if m.id == nil || m.oldValue == nil {
  8601. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8602. }
  8603. oldValue, err := m.oldValue(ctx)
  8604. if err != nil {
  8605. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8606. }
  8607. return oldValue.CreatedAt, nil
  8608. }
  8609. // ResetCreatedAt resets all changes to the "created_at" field.
  8610. func (m *ChatSessionMutation) ResetCreatedAt() {
  8611. m.created_at = nil
  8612. }
  8613. // SetUpdatedAt sets the "updated_at" field.
  8614. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8615. m.updated_at = &t
  8616. }
  8617. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8618. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8619. v := m.updated_at
  8620. if v == nil {
  8621. return
  8622. }
  8623. return *v, true
  8624. }
  8625. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8626. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8628. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8629. if !m.op.Is(OpUpdateOne) {
  8630. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8631. }
  8632. if m.id == nil || m.oldValue == nil {
  8633. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8634. }
  8635. oldValue, err := m.oldValue(ctx)
  8636. if err != nil {
  8637. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8638. }
  8639. return oldValue.UpdatedAt, nil
  8640. }
  8641. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8642. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8643. m.updated_at = nil
  8644. }
  8645. // SetDeletedAt sets the "deleted_at" field.
  8646. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8647. m.deleted_at = &t
  8648. }
  8649. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8650. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8651. v := m.deleted_at
  8652. if v == nil {
  8653. return
  8654. }
  8655. return *v, true
  8656. }
  8657. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8658. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8660. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8661. if !m.op.Is(OpUpdateOne) {
  8662. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8663. }
  8664. if m.id == nil || m.oldValue == nil {
  8665. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8666. }
  8667. oldValue, err := m.oldValue(ctx)
  8668. if err != nil {
  8669. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8670. }
  8671. return oldValue.DeletedAt, nil
  8672. }
  8673. // ClearDeletedAt clears the value of the "deleted_at" field.
  8674. func (m *ChatSessionMutation) ClearDeletedAt() {
  8675. m.deleted_at = nil
  8676. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8677. }
  8678. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8679. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  8680. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  8681. return ok
  8682. }
  8683. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8684. func (m *ChatSessionMutation) ResetDeletedAt() {
  8685. m.deleted_at = nil
  8686. delete(m.clearedFields, chatsession.FieldDeletedAt)
  8687. }
  8688. // SetName sets the "name" field.
  8689. func (m *ChatSessionMutation) SetName(s string) {
  8690. m.name = &s
  8691. }
  8692. // Name returns the value of the "name" field in the mutation.
  8693. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  8694. v := m.name
  8695. if v == nil {
  8696. return
  8697. }
  8698. return *v, true
  8699. }
  8700. // OldName returns the old "name" field's value of the ChatSession entity.
  8701. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8703. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  8704. if !m.op.Is(OpUpdateOne) {
  8705. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8706. }
  8707. if m.id == nil || m.oldValue == nil {
  8708. return v, errors.New("OldName requires an ID field in the mutation")
  8709. }
  8710. oldValue, err := m.oldValue(ctx)
  8711. if err != nil {
  8712. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8713. }
  8714. return oldValue.Name, nil
  8715. }
  8716. // ResetName resets all changes to the "name" field.
  8717. func (m *ChatSessionMutation) ResetName() {
  8718. m.name = nil
  8719. }
  8720. // SetUserID sets the "user_id" field.
  8721. func (m *ChatSessionMutation) SetUserID(u uint64) {
  8722. m.user_id = &u
  8723. m.adduser_id = nil
  8724. }
  8725. // UserID returns the value of the "user_id" field in the mutation.
  8726. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  8727. v := m.user_id
  8728. if v == nil {
  8729. return
  8730. }
  8731. return *v, true
  8732. }
  8733. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  8734. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8736. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8737. if !m.op.Is(OpUpdateOne) {
  8738. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8739. }
  8740. if m.id == nil || m.oldValue == nil {
  8741. return v, errors.New("OldUserID requires an ID field in the mutation")
  8742. }
  8743. oldValue, err := m.oldValue(ctx)
  8744. if err != nil {
  8745. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8746. }
  8747. return oldValue.UserID, nil
  8748. }
  8749. // AddUserID adds u to the "user_id" field.
  8750. func (m *ChatSessionMutation) AddUserID(u int64) {
  8751. if m.adduser_id != nil {
  8752. *m.adduser_id += u
  8753. } else {
  8754. m.adduser_id = &u
  8755. }
  8756. }
  8757. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8758. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  8759. v := m.adduser_id
  8760. if v == nil {
  8761. return
  8762. }
  8763. return *v, true
  8764. }
  8765. // ResetUserID resets all changes to the "user_id" field.
  8766. func (m *ChatSessionMutation) ResetUserID() {
  8767. m.user_id = nil
  8768. m.adduser_id = nil
  8769. }
  8770. // SetBotID sets the "bot_id" field.
  8771. func (m *ChatSessionMutation) SetBotID(u uint64) {
  8772. m.bot_id = &u
  8773. m.addbot_id = nil
  8774. }
  8775. // BotID returns the value of the "bot_id" field in the mutation.
  8776. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  8777. v := m.bot_id
  8778. if v == nil {
  8779. return
  8780. }
  8781. return *v, true
  8782. }
  8783. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  8784. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8786. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8787. if !m.op.Is(OpUpdateOne) {
  8788. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8789. }
  8790. if m.id == nil || m.oldValue == nil {
  8791. return v, errors.New("OldBotID requires an ID field in the mutation")
  8792. }
  8793. oldValue, err := m.oldValue(ctx)
  8794. if err != nil {
  8795. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8796. }
  8797. return oldValue.BotID, nil
  8798. }
  8799. // AddBotID adds u to the "bot_id" field.
  8800. func (m *ChatSessionMutation) AddBotID(u int64) {
  8801. if m.addbot_id != nil {
  8802. *m.addbot_id += u
  8803. } else {
  8804. m.addbot_id = &u
  8805. }
  8806. }
  8807. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8808. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  8809. v := m.addbot_id
  8810. if v == nil {
  8811. return
  8812. }
  8813. return *v, true
  8814. }
  8815. // ResetBotID resets all changes to the "bot_id" field.
  8816. func (m *ChatSessionMutation) ResetBotID() {
  8817. m.bot_id = nil
  8818. m.addbot_id = nil
  8819. }
  8820. // SetBotType sets the "bot_type" field.
  8821. func (m *ChatSessionMutation) SetBotType(u uint8) {
  8822. m.bot_type = &u
  8823. m.addbot_type = nil
  8824. }
  8825. // BotType returns the value of the "bot_type" field in the mutation.
  8826. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  8827. v := m.bot_type
  8828. if v == nil {
  8829. return
  8830. }
  8831. return *v, true
  8832. }
  8833. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  8834. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8836. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8837. if !m.op.Is(OpUpdateOne) {
  8838. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8839. }
  8840. if m.id == nil || m.oldValue == nil {
  8841. return v, errors.New("OldBotType requires an ID field in the mutation")
  8842. }
  8843. oldValue, err := m.oldValue(ctx)
  8844. if err != nil {
  8845. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8846. }
  8847. return oldValue.BotType, nil
  8848. }
  8849. // AddBotType adds u to the "bot_type" field.
  8850. func (m *ChatSessionMutation) AddBotType(u int8) {
  8851. if m.addbot_type != nil {
  8852. *m.addbot_type += u
  8853. } else {
  8854. m.addbot_type = &u
  8855. }
  8856. }
  8857. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8858. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  8859. v := m.addbot_type
  8860. if v == nil {
  8861. return
  8862. }
  8863. return *v, true
  8864. }
  8865. // ResetBotType resets all changes to the "bot_type" field.
  8866. func (m *ChatSessionMutation) ResetBotType() {
  8867. m.bot_type = nil
  8868. m.addbot_type = nil
  8869. }
  8870. // Where appends a list predicates to the ChatSessionMutation builder.
  8871. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  8872. m.predicates = append(m.predicates, ps...)
  8873. }
  8874. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  8875. // users can use type-assertion to append predicates that do not depend on any generated package.
  8876. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  8877. p := make([]predicate.ChatSession, len(ps))
  8878. for i := range ps {
  8879. p[i] = ps[i]
  8880. }
  8881. m.Where(p...)
  8882. }
  8883. // Op returns the operation name.
  8884. func (m *ChatSessionMutation) Op() Op {
  8885. return m.op
  8886. }
  8887. // SetOp allows setting the mutation operation.
  8888. func (m *ChatSessionMutation) SetOp(op Op) {
  8889. m.op = op
  8890. }
  8891. // Type returns the node type of this mutation (ChatSession).
  8892. func (m *ChatSessionMutation) Type() string {
  8893. return m.typ
  8894. }
  8895. // Fields returns all fields that were changed during this mutation. Note that in
  8896. // order to get all numeric fields that were incremented/decremented, call
  8897. // AddedFields().
  8898. func (m *ChatSessionMutation) Fields() []string {
  8899. fields := make([]string, 0, 7)
  8900. if m.created_at != nil {
  8901. fields = append(fields, chatsession.FieldCreatedAt)
  8902. }
  8903. if m.updated_at != nil {
  8904. fields = append(fields, chatsession.FieldUpdatedAt)
  8905. }
  8906. if m.deleted_at != nil {
  8907. fields = append(fields, chatsession.FieldDeletedAt)
  8908. }
  8909. if m.name != nil {
  8910. fields = append(fields, chatsession.FieldName)
  8911. }
  8912. if m.user_id != nil {
  8913. fields = append(fields, chatsession.FieldUserID)
  8914. }
  8915. if m.bot_id != nil {
  8916. fields = append(fields, chatsession.FieldBotID)
  8917. }
  8918. if m.bot_type != nil {
  8919. fields = append(fields, chatsession.FieldBotType)
  8920. }
  8921. return fields
  8922. }
  8923. // Field returns the value of a field with the given name. The second boolean
  8924. // return value indicates that this field was not set, or was not defined in the
  8925. // schema.
  8926. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  8927. switch name {
  8928. case chatsession.FieldCreatedAt:
  8929. return m.CreatedAt()
  8930. case chatsession.FieldUpdatedAt:
  8931. return m.UpdatedAt()
  8932. case chatsession.FieldDeletedAt:
  8933. return m.DeletedAt()
  8934. case chatsession.FieldName:
  8935. return m.Name()
  8936. case chatsession.FieldUserID:
  8937. return m.UserID()
  8938. case chatsession.FieldBotID:
  8939. return m.BotID()
  8940. case chatsession.FieldBotType:
  8941. return m.BotType()
  8942. }
  8943. return nil, false
  8944. }
  8945. // OldField returns the old value of the field from the database. An error is
  8946. // returned if the mutation operation is not UpdateOne, or the query to the
  8947. // database failed.
  8948. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8949. switch name {
  8950. case chatsession.FieldCreatedAt:
  8951. return m.OldCreatedAt(ctx)
  8952. case chatsession.FieldUpdatedAt:
  8953. return m.OldUpdatedAt(ctx)
  8954. case chatsession.FieldDeletedAt:
  8955. return m.OldDeletedAt(ctx)
  8956. case chatsession.FieldName:
  8957. return m.OldName(ctx)
  8958. case chatsession.FieldUserID:
  8959. return m.OldUserID(ctx)
  8960. case chatsession.FieldBotID:
  8961. return m.OldBotID(ctx)
  8962. case chatsession.FieldBotType:
  8963. return m.OldBotType(ctx)
  8964. }
  8965. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  8966. }
  8967. // SetField sets the value of a field with the given name. It returns an error if
  8968. // the field is not defined in the schema, or if the type mismatched the field
  8969. // type.
  8970. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  8971. switch name {
  8972. case chatsession.FieldCreatedAt:
  8973. v, ok := value.(time.Time)
  8974. if !ok {
  8975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8976. }
  8977. m.SetCreatedAt(v)
  8978. return nil
  8979. case chatsession.FieldUpdatedAt:
  8980. v, ok := value.(time.Time)
  8981. if !ok {
  8982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8983. }
  8984. m.SetUpdatedAt(v)
  8985. return nil
  8986. case chatsession.FieldDeletedAt:
  8987. v, ok := value.(time.Time)
  8988. if !ok {
  8989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8990. }
  8991. m.SetDeletedAt(v)
  8992. return nil
  8993. case chatsession.FieldName:
  8994. v, ok := value.(string)
  8995. if !ok {
  8996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8997. }
  8998. m.SetName(v)
  8999. return nil
  9000. case chatsession.FieldUserID:
  9001. v, ok := value.(uint64)
  9002. if !ok {
  9003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9004. }
  9005. m.SetUserID(v)
  9006. return nil
  9007. case chatsession.FieldBotID:
  9008. v, ok := value.(uint64)
  9009. if !ok {
  9010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9011. }
  9012. m.SetBotID(v)
  9013. return nil
  9014. case chatsession.FieldBotType:
  9015. v, ok := value.(uint8)
  9016. if !ok {
  9017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9018. }
  9019. m.SetBotType(v)
  9020. return nil
  9021. }
  9022. return fmt.Errorf("unknown ChatSession field %s", name)
  9023. }
  9024. // AddedFields returns all numeric fields that were incremented/decremented during
  9025. // this mutation.
  9026. func (m *ChatSessionMutation) AddedFields() []string {
  9027. var fields []string
  9028. if m.adduser_id != nil {
  9029. fields = append(fields, chatsession.FieldUserID)
  9030. }
  9031. if m.addbot_id != nil {
  9032. fields = append(fields, chatsession.FieldBotID)
  9033. }
  9034. if m.addbot_type != nil {
  9035. fields = append(fields, chatsession.FieldBotType)
  9036. }
  9037. return fields
  9038. }
  9039. // AddedField returns the numeric value that was incremented/decremented on a field
  9040. // with the given name. The second boolean return value indicates that this field
  9041. // was not set, or was not defined in the schema.
  9042. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9043. switch name {
  9044. case chatsession.FieldUserID:
  9045. return m.AddedUserID()
  9046. case chatsession.FieldBotID:
  9047. return m.AddedBotID()
  9048. case chatsession.FieldBotType:
  9049. return m.AddedBotType()
  9050. }
  9051. return nil, false
  9052. }
  9053. // AddField adds the value to the field with the given name. It returns an error if
  9054. // the field is not defined in the schema, or if the type mismatched the field
  9055. // type.
  9056. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9057. switch name {
  9058. case chatsession.FieldUserID:
  9059. v, ok := value.(int64)
  9060. if !ok {
  9061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9062. }
  9063. m.AddUserID(v)
  9064. return nil
  9065. case chatsession.FieldBotID:
  9066. v, ok := value.(int64)
  9067. if !ok {
  9068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9069. }
  9070. m.AddBotID(v)
  9071. return nil
  9072. case chatsession.FieldBotType:
  9073. v, ok := value.(int8)
  9074. if !ok {
  9075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9076. }
  9077. m.AddBotType(v)
  9078. return nil
  9079. }
  9080. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9081. }
  9082. // ClearedFields returns all nullable fields that were cleared during this
  9083. // mutation.
  9084. func (m *ChatSessionMutation) ClearedFields() []string {
  9085. var fields []string
  9086. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9087. fields = append(fields, chatsession.FieldDeletedAt)
  9088. }
  9089. return fields
  9090. }
  9091. // FieldCleared returns a boolean indicating if a field with the given name was
  9092. // cleared in this mutation.
  9093. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9094. _, ok := m.clearedFields[name]
  9095. return ok
  9096. }
  9097. // ClearField clears the value of the field with the given name. It returns an
  9098. // error if the field is not defined in the schema.
  9099. func (m *ChatSessionMutation) ClearField(name string) error {
  9100. switch name {
  9101. case chatsession.FieldDeletedAt:
  9102. m.ClearDeletedAt()
  9103. return nil
  9104. }
  9105. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9106. }
  9107. // ResetField resets all changes in the mutation for the field with the given name.
  9108. // It returns an error if the field is not defined in the schema.
  9109. func (m *ChatSessionMutation) ResetField(name string) error {
  9110. switch name {
  9111. case chatsession.FieldCreatedAt:
  9112. m.ResetCreatedAt()
  9113. return nil
  9114. case chatsession.FieldUpdatedAt:
  9115. m.ResetUpdatedAt()
  9116. return nil
  9117. case chatsession.FieldDeletedAt:
  9118. m.ResetDeletedAt()
  9119. return nil
  9120. case chatsession.FieldName:
  9121. m.ResetName()
  9122. return nil
  9123. case chatsession.FieldUserID:
  9124. m.ResetUserID()
  9125. return nil
  9126. case chatsession.FieldBotID:
  9127. m.ResetBotID()
  9128. return nil
  9129. case chatsession.FieldBotType:
  9130. m.ResetBotType()
  9131. return nil
  9132. }
  9133. return fmt.Errorf("unknown ChatSession field %s", name)
  9134. }
  9135. // AddedEdges returns all edge names that were set/added in this mutation.
  9136. func (m *ChatSessionMutation) AddedEdges() []string {
  9137. edges := make([]string, 0, 0)
  9138. return edges
  9139. }
  9140. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9141. // name in this mutation.
  9142. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9143. return nil
  9144. }
  9145. // RemovedEdges returns all edge names that were removed in this mutation.
  9146. func (m *ChatSessionMutation) RemovedEdges() []string {
  9147. edges := make([]string, 0, 0)
  9148. return edges
  9149. }
  9150. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9151. // the given name in this mutation.
  9152. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9153. return nil
  9154. }
  9155. // ClearedEdges returns all edge names that were cleared in this mutation.
  9156. func (m *ChatSessionMutation) ClearedEdges() []string {
  9157. edges := make([]string, 0, 0)
  9158. return edges
  9159. }
  9160. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9161. // was cleared in this mutation.
  9162. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9163. return false
  9164. }
  9165. // ClearEdge clears the value of the edge with the given name. It returns an error
  9166. // if that edge is not defined in the schema.
  9167. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9168. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9169. }
  9170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9171. // It returns an error if the edge is not defined in the schema.
  9172. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9173. return fmt.Errorf("unknown ChatSession edge %s", name)
  9174. }
  9175. // CompapiJobMutation represents an operation that mutates the CompapiJob nodes in the graph.
  9176. type CompapiJobMutation struct {
  9177. config
  9178. op Op
  9179. typ string
  9180. id *uint64
  9181. created_at *time.Time
  9182. updated_at *time.Time
  9183. dist_at *time.Time
  9184. dist_status *int8
  9185. adddist_status *int8
  9186. callback_status *int8
  9187. addcallback_status *int8
  9188. callback_url *string
  9189. request_json *custom_types.OriginalData
  9190. auth_token *string
  9191. event_type *string
  9192. workid_idx *int8
  9193. addworkid_idx *int8
  9194. chat_id *string
  9195. retry_count *int8
  9196. addretry_count *int8
  9197. clearedFields map[string]struct{}
  9198. done bool
  9199. oldValue func(context.Context) (*CompapiJob, error)
  9200. predicates []predicate.CompapiJob
  9201. }
  9202. var _ ent.Mutation = (*CompapiJobMutation)(nil)
  9203. // compapijobOption allows management of the mutation configuration using functional options.
  9204. type compapijobOption func(*CompapiJobMutation)
  9205. // newCompapiJobMutation creates new mutation for the CompapiJob entity.
  9206. func newCompapiJobMutation(c config, op Op, opts ...compapijobOption) *CompapiJobMutation {
  9207. m := &CompapiJobMutation{
  9208. config: c,
  9209. op: op,
  9210. typ: TypeCompapiJob,
  9211. clearedFields: make(map[string]struct{}),
  9212. }
  9213. for _, opt := range opts {
  9214. opt(m)
  9215. }
  9216. return m
  9217. }
  9218. // withCompapiJobID sets the ID field of the mutation.
  9219. func withCompapiJobID(id uint64) compapijobOption {
  9220. return func(m *CompapiJobMutation) {
  9221. var (
  9222. err error
  9223. once sync.Once
  9224. value *CompapiJob
  9225. )
  9226. m.oldValue = func(ctx context.Context) (*CompapiJob, error) {
  9227. once.Do(func() {
  9228. if m.done {
  9229. err = errors.New("querying old values post mutation is not allowed")
  9230. } else {
  9231. value, err = m.Client().CompapiJob.Get(ctx, id)
  9232. }
  9233. })
  9234. return value, err
  9235. }
  9236. m.id = &id
  9237. }
  9238. }
  9239. // withCompapiJob sets the old CompapiJob of the mutation.
  9240. func withCompapiJob(node *CompapiJob) compapijobOption {
  9241. return func(m *CompapiJobMutation) {
  9242. m.oldValue = func(context.Context) (*CompapiJob, error) {
  9243. return node, nil
  9244. }
  9245. m.id = &node.ID
  9246. }
  9247. }
  9248. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9249. // executed in a transaction (ent.Tx), a transactional client is returned.
  9250. func (m CompapiJobMutation) Client() *Client {
  9251. client := &Client{config: m.config}
  9252. client.init()
  9253. return client
  9254. }
  9255. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9256. // it returns an error otherwise.
  9257. func (m CompapiJobMutation) Tx() (*Tx, error) {
  9258. if _, ok := m.driver.(*txDriver); !ok {
  9259. return nil, errors.New("ent: mutation is not running in a transaction")
  9260. }
  9261. tx := &Tx{config: m.config}
  9262. tx.init()
  9263. return tx, nil
  9264. }
  9265. // SetID sets the value of the id field. Note that this
  9266. // operation is only accepted on creation of CompapiJob entities.
  9267. func (m *CompapiJobMutation) SetID(id uint64) {
  9268. m.id = &id
  9269. }
  9270. // ID returns the ID value in the mutation. Note that the ID is only available
  9271. // if it was provided to the builder or after it was returned from the database.
  9272. func (m *CompapiJobMutation) ID() (id uint64, exists bool) {
  9273. if m.id == nil {
  9274. return
  9275. }
  9276. return *m.id, true
  9277. }
  9278. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9279. // That means, if the mutation is applied within a transaction with an isolation level such
  9280. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9281. // or updated by the mutation.
  9282. func (m *CompapiJobMutation) IDs(ctx context.Context) ([]uint64, error) {
  9283. switch {
  9284. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9285. id, exists := m.ID()
  9286. if exists {
  9287. return []uint64{id}, nil
  9288. }
  9289. fallthrough
  9290. case m.op.Is(OpUpdate | OpDelete):
  9291. return m.Client().CompapiJob.Query().Where(m.predicates...).IDs(ctx)
  9292. default:
  9293. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9294. }
  9295. }
  9296. // SetCreatedAt sets the "created_at" field.
  9297. func (m *CompapiJobMutation) SetCreatedAt(t time.Time) {
  9298. m.created_at = &t
  9299. }
  9300. // CreatedAt returns the value of the "created_at" field in the mutation.
  9301. func (m *CompapiJobMutation) CreatedAt() (r time.Time, exists bool) {
  9302. v := m.created_at
  9303. if v == nil {
  9304. return
  9305. }
  9306. return *v, true
  9307. }
  9308. // OldCreatedAt returns the old "created_at" field's value of the CompapiJob entity.
  9309. // If the CompapiJob object wasn't provided to the builder, the object is fetched from the database.
  9310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9311. func (m *CompapiJobMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9312. if !m.op.Is(OpUpdateOne) {
  9313. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9314. }
  9315. if m.id == nil || m.oldValue == nil {
  9316. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9317. }
  9318. oldValue, err := m.oldValue(ctx)
  9319. if err != nil {
  9320. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9321. }
  9322. return oldValue.CreatedAt, nil
  9323. }
  9324. // ResetCreatedAt resets all changes to the "created_at" field.
  9325. func (m *CompapiJobMutation) ResetCreatedAt() {
  9326. m.created_at = nil
  9327. }
  9328. // SetUpdatedAt sets the "updated_at" field.
  9329. func (m *CompapiJobMutation) SetUpdatedAt(t time.Time) {
  9330. m.updated_at = &t
  9331. }
  9332. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9333. func (m *CompapiJobMutation) UpdatedAt() (r time.Time, exists bool) {
  9334. v := m.updated_at
  9335. if v == nil {
  9336. return
  9337. }
  9338. return *v, true
  9339. }
  9340. // OldUpdatedAt returns the old "updated_at" field's value of the CompapiJob entity.
  9341. // If the CompapiJob object wasn't provided to the builder, the object is fetched from the database.
  9342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9343. func (m *CompapiJobMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9344. if !m.op.Is(OpUpdateOne) {
  9345. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9346. }
  9347. if m.id == nil || m.oldValue == nil {
  9348. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9349. }
  9350. oldValue, err := m.oldValue(ctx)
  9351. if err != nil {
  9352. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9353. }
  9354. return oldValue.UpdatedAt, nil
  9355. }
  9356. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9357. func (m *CompapiJobMutation) ResetUpdatedAt() {
  9358. m.updated_at = nil
  9359. }
  9360. // SetDistAt sets the "dist_at" field.
  9361. func (m *CompapiJobMutation) SetDistAt(t time.Time) {
  9362. m.dist_at = &t
  9363. }
  9364. // DistAt returns the value of the "dist_at" field in the mutation.
  9365. func (m *CompapiJobMutation) DistAt() (r time.Time, exists bool) {
  9366. v := m.dist_at
  9367. if v == nil {
  9368. return
  9369. }
  9370. return *v, true
  9371. }
  9372. // OldDistAt returns the old "dist_at" field's value of the CompapiJob entity.
  9373. // If the CompapiJob object wasn't provided to the builder, the object is fetched from the database.
  9374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9375. func (m *CompapiJobMutation) OldDistAt(ctx context.Context) (v time.Time, err error) {
  9376. if !m.op.Is(OpUpdateOne) {
  9377. return v, errors.New("OldDistAt is only allowed on UpdateOne operations")
  9378. }
  9379. if m.id == nil || m.oldValue == nil {
  9380. return v, errors.New("OldDistAt requires an ID field in the mutation")
  9381. }
  9382. oldValue, err := m.oldValue(ctx)
  9383. if err != nil {
  9384. return v, fmt.Errorf("querying old value for OldDistAt: %w", err)
  9385. }
  9386. return oldValue.DistAt, nil
  9387. }
  9388. // ClearDistAt clears the value of the "dist_at" field.
  9389. func (m *CompapiJobMutation) ClearDistAt() {
  9390. m.dist_at = nil
  9391. m.clearedFields[compapijob.FieldDistAt] = struct{}{}
  9392. }
  9393. // DistAtCleared returns if the "dist_at" field was cleared in this mutation.
  9394. func (m *CompapiJobMutation) DistAtCleared() bool {
  9395. _, ok := m.clearedFields[compapijob.FieldDistAt]
  9396. return ok
  9397. }
  9398. // ResetDistAt resets all changes to the "dist_at" field.
  9399. func (m *CompapiJobMutation) ResetDistAt() {
  9400. m.dist_at = nil
  9401. delete(m.clearedFields, compapijob.FieldDistAt)
  9402. }
  9403. // SetDistStatus sets the "dist_status" field.
  9404. func (m *CompapiJobMutation) SetDistStatus(i int8) {
  9405. m.dist_status = &i
  9406. m.adddist_status = nil
  9407. }
  9408. // DistStatus returns the value of the "dist_status" field in the mutation.
  9409. func (m *CompapiJobMutation) DistStatus() (r int8, exists bool) {
  9410. v := m.dist_status
  9411. if v == nil {
  9412. return
  9413. }
  9414. return *v, true
  9415. }
  9416. // OldDistStatus returns the old "dist_status" field's value of the CompapiJob entity.
  9417. // If the CompapiJob object wasn't provided to the builder, the object is fetched from the database.
  9418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9419. func (m *CompapiJobMutation) OldDistStatus(ctx context.Context) (v int8, err error) {
  9420. if !m.op.Is(OpUpdateOne) {
  9421. return v, errors.New("OldDistStatus is only allowed on UpdateOne operations")
  9422. }
  9423. if m.id == nil || m.oldValue == nil {
  9424. return v, errors.New("OldDistStatus requires an ID field in the mutation")
  9425. }
  9426. oldValue, err := m.oldValue(ctx)
  9427. if err != nil {
  9428. return v, fmt.Errorf("querying old value for OldDistStatus: %w", err)
  9429. }
  9430. return oldValue.DistStatus, nil
  9431. }
  9432. // AddDistStatus adds i to the "dist_status" field.
  9433. func (m *CompapiJobMutation) AddDistStatus(i int8) {
  9434. if m.adddist_status != nil {
  9435. *m.adddist_status += i
  9436. } else {
  9437. m.adddist_status = &i
  9438. }
  9439. }
  9440. // AddedDistStatus returns the value that was added to the "dist_status" field in this mutation.
  9441. func (m *CompapiJobMutation) AddedDistStatus() (r int8, exists bool) {
  9442. v := m.adddist_status
  9443. if v == nil {
  9444. return
  9445. }
  9446. return *v, true
  9447. }
  9448. // ClearDistStatus clears the value of the "dist_status" field.
  9449. func (m *CompapiJobMutation) ClearDistStatus() {
  9450. m.dist_status = nil
  9451. m.adddist_status = nil
  9452. m.clearedFields[compapijob.FieldDistStatus] = struct{}{}
  9453. }
  9454. // DistStatusCleared returns if the "dist_status" field was cleared in this mutation.
  9455. func (m *CompapiJobMutation) DistStatusCleared() bool {
  9456. _, ok := m.clearedFields[compapijob.FieldDistStatus]
  9457. return ok
  9458. }
  9459. // ResetDistStatus resets all changes to the "dist_status" field.
  9460. func (m *CompapiJobMutation) ResetDistStatus() {
  9461. m.dist_status = nil
  9462. m.adddist_status = nil
  9463. delete(m.clearedFields, compapijob.FieldDistStatus)
  9464. }
  9465. // SetCallbackStatus sets the "callback_status" field.
  9466. func (m *CompapiJobMutation) SetCallbackStatus(i int8) {
  9467. m.callback_status = &i
  9468. m.addcallback_status = nil
  9469. }
  9470. // CallbackStatus returns the value of the "callback_status" field in the mutation.
  9471. func (m *CompapiJobMutation) CallbackStatus() (r int8, exists bool) {
  9472. v := m.callback_status
  9473. if v == nil {
  9474. return
  9475. }
  9476. return *v, true
  9477. }
  9478. // OldCallbackStatus returns the old "callback_status" field's value of the CompapiJob entity.
  9479. // If the CompapiJob object wasn't provided to the builder, the object is fetched from the database.
  9480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9481. func (m *CompapiJobMutation) OldCallbackStatus(ctx context.Context) (v int8, err error) {
  9482. if !m.op.Is(OpUpdateOne) {
  9483. return v, errors.New("OldCallbackStatus is only allowed on UpdateOne operations")
  9484. }
  9485. if m.id == nil || m.oldValue == nil {
  9486. return v, errors.New("OldCallbackStatus requires an ID field in the mutation")
  9487. }
  9488. oldValue, err := m.oldValue(ctx)
  9489. if err != nil {
  9490. return v, fmt.Errorf("querying old value for OldCallbackStatus: %w", err)
  9491. }
  9492. return oldValue.CallbackStatus, nil
  9493. }
  9494. // AddCallbackStatus adds i to the "callback_status" field.
  9495. func (m *CompapiJobMutation) AddCallbackStatus(i int8) {
  9496. if m.addcallback_status != nil {
  9497. *m.addcallback_status += i
  9498. } else {
  9499. m.addcallback_status = &i
  9500. }
  9501. }
  9502. // AddedCallbackStatus returns the value that was added to the "callback_status" field in this mutation.
  9503. func (m *CompapiJobMutation) AddedCallbackStatus() (r int8, exists bool) {
  9504. v := m.addcallback_status
  9505. if v == nil {
  9506. return
  9507. }
  9508. return *v, true
  9509. }
  9510. // ClearCallbackStatus clears the value of the "callback_status" field.
  9511. func (m *CompapiJobMutation) ClearCallbackStatus() {
  9512. m.callback_status = nil
  9513. m.addcallback_status = nil
  9514. m.clearedFields[compapijob.FieldCallbackStatus] = struct{}{}
  9515. }
  9516. // CallbackStatusCleared returns if the "callback_status" field was cleared in this mutation.
  9517. func (m *CompapiJobMutation) CallbackStatusCleared() bool {
  9518. _, ok := m.clearedFields[compapijob.FieldCallbackStatus]
  9519. return ok
  9520. }
  9521. // ResetCallbackStatus resets all changes to the "callback_status" field.
  9522. func (m *CompapiJobMutation) ResetCallbackStatus() {
  9523. m.callback_status = nil
  9524. m.addcallback_status = nil
  9525. delete(m.clearedFields, compapijob.FieldCallbackStatus)
  9526. }
  9527. // SetCallbackURL sets the "callback_url" field.
  9528. func (m *CompapiJobMutation) SetCallbackURL(s string) {
  9529. m.callback_url = &s
  9530. }
  9531. // CallbackURL returns the value of the "callback_url" field in the mutation.
  9532. func (m *CompapiJobMutation) CallbackURL() (r string, exists bool) {
  9533. v := m.callback_url
  9534. if v == nil {
  9535. return
  9536. }
  9537. return *v, true
  9538. }
  9539. // OldCallbackURL returns the old "callback_url" field's value of the CompapiJob entity.
  9540. // If the CompapiJob object wasn't provided to the builder, the object is fetched from the database.
  9541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9542. func (m *CompapiJobMutation) OldCallbackURL(ctx context.Context) (v string, err error) {
  9543. if !m.op.Is(OpUpdateOne) {
  9544. return v, errors.New("OldCallbackURL is only allowed on UpdateOne operations")
  9545. }
  9546. if m.id == nil || m.oldValue == nil {
  9547. return v, errors.New("OldCallbackURL requires an ID field in the mutation")
  9548. }
  9549. oldValue, err := m.oldValue(ctx)
  9550. if err != nil {
  9551. return v, fmt.Errorf("querying old value for OldCallbackURL: %w", err)
  9552. }
  9553. return oldValue.CallbackURL, nil
  9554. }
  9555. // ResetCallbackURL resets all changes to the "callback_url" field.
  9556. func (m *CompapiJobMutation) ResetCallbackURL() {
  9557. m.callback_url = nil
  9558. }
  9559. // SetRequestJSON sets the "request_json" field.
  9560. func (m *CompapiJobMutation) SetRequestJSON(ctd custom_types.OriginalData) {
  9561. m.request_json = &ctd
  9562. }
  9563. // RequestJSON returns the value of the "request_json" field in the mutation.
  9564. func (m *CompapiJobMutation) RequestJSON() (r custom_types.OriginalData, exists bool) {
  9565. v := m.request_json
  9566. if v == nil {
  9567. return
  9568. }
  9569. return *v, true
  9570. }
  9571. // OldRequestJSON returns the old "request_json" field's value of the CompapiJob entity.
  9572. // If the CompapiJob object wasn't provided to the builder, the object is fetched from the database.
  9573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9574. func (m *CompapiJobMutation) OldRequestJSON(ctx context.Context) (v custom_types.OriginalData, err error) {
  9575. if !m.op.Is(OpUpdateOne) {
  9576. return v, errors.New("OldRequestJSON is only allowed on UpdateOne operations")
  9577. }
  9578. if m.id == nil || m.oldValue == nil {
  9579. return v, errors.New("OldRequestJSON requires an ID field in the mutation")
  9580. }
  9581. oldValue, err := m.oldValue(ctx)
  9582. if err != nil {
  9583. return v, fmt.Errorf("querying old value for OldRequestJSON: %w", err)
  9584. }
  9585. return oldValue.RequestJSON, nil
  9586. }
  9587. // ResetRequestJSON resets all changes to the "request_json" field.
  9588. func (m *CompapiJobMutation) ResetRequestJSON() {
  9589. m.request_json = nil
  9590. }
  9591. // SetAuthToken sets the "auth_token" field.
  9592. func (m *CompapiJobMutation) SetAuthToken(s string) {
  9593. m.auth_token = &s
  9594. }
  9595. // AuthToken returns the value of the "auth_token" field in the mutation.
  9596. func (m *CompapiJobMutation) AuthToken() (r string, exists bool) {
  9597. v := m.auth_token
  9598. if v == nil {
  9599. return
  9600. }
  9601. return *v, true
  9602. }
  9603. // OldAuthToken returns the old "auth_token" field's value of the CompapiJob entity.
  9604. // If the CompapiJob object wasn't provided to the builder, the object is fetched from the database.
  9605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9606. func (m *CompapiJobMutation) OldAuthToken(ctx context.Context) (v string, err error) {
  9607. if !m.op.Is(OpUpdateOne) {
  9608. return v, errors.New("OldAuthToken is only allowed on UpdateOne operations")
  9609. }
  9610. if m.id == nil || m.oldValue == nil {
  9611. return v, errors.New("OldAuthToken requires an ID field in the mutation")
  9612. }
  9613. oldValue, err := m.oldValue(ctx)
  9614. if err != nil {
  9615. return v, fmt.Errorf("querying old value for OldAuthToken: %w", err)
  9616. }
  9617. return oldValue.AuthToken, nil
  9618. }
  9619. // ResetAuthToken resets all changes to the "auth_token" field.
  9620. func (m *CompapiJobMutation) ResetAuthToken() {
  9621. m.auth_token = nil
  9622. }
  9623. // SetEventType sets the "event_type" field.
  9624. func (m *CompapiJobMutation) SetEventType(s string) {
  9625. m.event_type = &s
  9626. }
  9627. // EventType returns the value of the "event_type" field in the mutation.
  9628. func (m *CompapiJobMutation) EventType() (r string, exists bool) {
  9629. v := m.event_type
  9630. if v == nil {
  9631. return
  9632. }
  9633. return *v, true
  9634. }
  9635. // OldEventType returns the old "event_type" field's value of the CompapiJob entity.
  9636. // If the CompapiJob object wasn't provided to the builder, the object is fetched from the database.
  9637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9638. func (m *CompapiJobMutation) OldEventType(ctx context.Context) (v string, err error) {
  9639. if !m.op.Is(OpUpdateOne) {
  9640. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  9641. }
  9642. if m.id == nil || m.oldValue == nil {
  9643. return v, errors.New("OldEventType requires an ID field in the mutation")
  9644. }
  9645. oldValue, err := m.oldValue(ctx)
  9646. if err != nil {
  9647. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  9648. }
  9649. return oldValue.EventType, nil
  9650. }
  9651. // ResetEventType resets all changes to the "event_type" field.
  9652. func (m *CompapiJobMutation) ResetEventType() {
  9653. m.event_type = nil
  9654. }
  9655. // SetWorkidIdx sets the "workid_idx" field.
  9656. func (m *CompapiJobMutation) SetWorkidIdx(i int8) {
  9657. m.workid_idx = &i
  9658. m.addworkid_idx = nil
  9659. }
  9660. // WorkidIdx returns the value of the "workid_idx" field in the mutation.
  9661. func (m *CompapiJobMutation) WorkidIdx() (r int8, exists bool) {
  9662. v := m.workid_idx
  9663. if v == nil {
  9664. return
  9665. }
  9666. return *v, true
  9667. }
  9668. // OldWorkidIdx returns the old "workid_idx" field's value of the CompapiJob entity.
  9669. // If the CompapiJob object wasn't provided to the builder, the object is fetched from the database.
  9670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9671. func (m *CompapiJobMutation) OldWorkidIdx(ctx context.Context) (v int8, err error) {
  9672. if !m.op.Is(OpUpdateOne) {
  9673. return v, errors.New("OldWorkidIdx is only allowed on UpdateOne operations")
  9674. }
  9675. if m.id == nil || m.oldValue == nil {
  9676. return v, errors.New("OldWorkidIdx requires an ID field in the mutation")
  9677. }
  9678. oldValue, err := m.oldValue(ctx)
  9679. if err != nil {
  9680. return v, fmt.Errorf("querying old value for OldWorkidIdx: %w", err)
  9681. }
  9682. return oldValue.WorkidIdx, nil
  9683. }
  9684. // AddWorkidIdx adds i to the "workid_idx" field.
  9685. func (m *CompapiJobMutation) AddWorkidIdx(i int8) {
  9686. if m.addworkid_idx != nil {
  9687. *m.addworkid_idx += i
  9688. } else {
  9689. m.addworkid_idx = &i
  9690. }
  9691. }
  9692. // AddedWorkidIdx returns the value that was added to the "workid_idx" field in this mutation.
  9693. func (m *CompapiJobMutation) AddedWorkidIdx() (r int8, exists bool) {
  9694. v := m.addworkid_idx
  9695. if v == nil {
  9696. return
  9697. }
  9698. return *v, true
  9699. }
  9700. // ClearWorkidIdx clears the value of the "workid_idx" field.
  9701. func (m *CompapiJobMutation) ClearWorkidIdx() {
  9702. m.workid_idx = nil
  9703. m.addworkid_idx = nil
  9704. m.clearedFields[compapijob.FieldWorkidIdx] = struct{}{}
  9705. }
  9706. // WorkidIdxCleared returns if the "workid_idx" field was cleared in this mutation.
  9707. func (m *CompapiJobMutation) WorkidIdxCleared() bool {
  9708. _, ok := m.clearedFields[compapijob.FieldWorkidIdx]
  9709. return ok
  9710. }
  9711. // ResetWorkidIdx resets all changes to the "workid_idx" field.
  9712. func (m *CompapiJobMutation) ResetWorkidIdx() {
  9713. m.workid_idx = nil
  9714. m.addworkid_idx = nil
  9715. delete(m.clearedFields, compapijob.FieldWorkidIdx)
  9716. }
  9717. // SetChatID sets the "chat_id" field.
  9718. func (m *CompapiJobMutation) SetChatID(s string) {
  9719. m.chat_id = &s
  9720. }
  9721. // ChatID returns the value of the "chat_id" field in the mutation.
  9722. func (m *CompapiJobMutation) ChatID() (r string, exists bool) {
  9723. v := m.chat_id
  9724. if v == nil {
  9725. return
  9726. }
  9727. return *v, true
  9728. }
  9729. // OldChatID returns the old "chat_id" field's value of the CompapiJob entity.
  9730. // If the CompapiJob object wasn't provided to the builder, the object is fetched from the database.
  9731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9732. func (m *CompapiJobMutation) OldChatID(ctx context.Context) (v string, err error) {
  9733. if !m.op.Is(OpUpdateOne) {
  9734. return v, errors.New("OldChatID is only allowed on UpdateOne operations")
  9735. }
  9736. if m.id == nil || m.oldValue == nil {
  9737. return v, errors.New("OldChatID requires an ID field in the mutation")
  9738. }
  9739. oldValue, err := m.oldValue(ctx)
  9740. if err != nil {
  9741. return v, fmt.Errorf("querying old value for OldChatID: %w", err)
  9742. }
  9743. return oldValue.ChatID, nil
  9744. }
  9745. // ClearChatID clears the value of the "chat_id" field.
  9746. func (m *CompapiJobMutation) ClearChatID() {
  9747. m.chat_id = nil
  9748. m.clearedFields[compapijob.FieldChatID] = struct{}{}
  9749. }
  9750. // ChatIDCleared returns if the "chat_id" field was cleared in this mutation.
  9751. func (m *CompapiJobMutation) ChatIDCleared() bool {
  9752. _, ok := m.clearedFields[compapijob.FieldChatID]
  9753. return ok
  9754. }
  9755. // ResetChatID resets all changes to the "chat_id" field.
  9756. func (m *CompapiJobMutation) ResetChatID() {
  9757. m.chat_id = nil
  9758. delete(m.clearedFields, compapijob.FieldChatID)
  9759. }
  9760. // SetRetryCount sets the "retry_count" field.
  9761. func (m *CompapiJobMutation) SetRetryCount(i int8) {
  9762. m.retry_count = &i
  9763. m.addretry_count = nil
  9764. }
  9765. // RetryCount returns the value of the "retry_count" field in the mutation.
  9766. func (m *CompapiJobMutation) RetryCount() (r int8, exists bool) {
  9767. v := m.retry_count
  9768. if v == nil {
  9769. return
  9770. }
  9771. return *v, true
  9772. }
  9773. // OldRetryCount returns the old "retry_count" field's value of the CompapiJob entity.
  9774. // If the CompapiJob object wasn't provided to the builder, the object is fetched from the database.
  9775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9776. func (m *CompapiJobMutation) OldRetryCount(ctx context.Context) (v int8, err error) {
  9777. if !m.op.Is(OpUpdateOne) {
  9778. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  9779. }
  9780. if m.id == nil || m.oldValue == nil {
  9781. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  9782. }
  9783. oldValue, err := m.oldValue(ctx)
  9784. if err != nil {
  9785. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  9786. }
  9787. return oldValue.RetryCount, nil
  9788. }
  9789. // AddRetryCount adds i to the "retry_count" field.
  9790. func (m *CompapiJobMutation) AddRetryCount(i int8) {
  9791. if m.addretry_count != nil {
  9792. *m.addretry_count += i
  9793. } else {
  9794. m.addretry_count = &i
  9795. }
  9796. }
  9797. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  9798. func (m *CompapiJobMutation) AddedRetryCount() (r int8, exists bool) {
  9799. v := m.addretry_count
  9800. if v == nil {
  9801. return
  9802. }
  9803. return *v, true
  9804. }
  9805. // ClearRetryCount clears the value of the "retry_count" field.
  9806. func (m *CompapiJobMutation) ClearRetryCount() {
  9807. m.retry_count = nil
  9808. m.addretry_count = nil
  9809. m.clearedFields[compapijob.FieldRetryCount] = struct{}{}
  9810. }
  9811. // RetryCountCleared returns if the "retry_count" field was cleared in this mutation.
  9812. func (m *CompapiJobMutation) RetryCountCleared() bool {
  9813. _, ok := m.clearedFields[compapijob.FieldRetryCount]
  9814. return ok
  9815. }
  9816. // ResetRetryCount resets all changes to the "retry_count" field.
  9817. func (m *CompapiJobMutation) ResetRetryCount() {
  9818. m.retry_count = nil
  9819. m.addretry_count = nil
  9820. delete(m.clearedFields, compapijob.FieldRetryCount)
  9821. }
  9822. // Where appends a list predicates to the CompapiJobMutation builder.
  9823. func (m *CompapiJobMutation) Where(ps ...predicate.CompapiJob) {
  9824. m.predicates = append(m.predicates, ps...)
  9825. }
  9826. // WhereP appends storage-level predicates to the CompapiJobMutation builder. Using this method,
  9827. // users can use type-assertion to append predicates that do not depend on any generated package.
  9828. func (m *CompapiJobMutation) WhereP(ps ...func(*sql.Selector)) {
  9829. p := make([]predicate.CompapiJob, len(ps))
  9830. for i := range ps {
  9831. p[i] = ps[i]
  9832. }
  9833. m.Where(p...)
  9834. }
  9835. // Op returns the operation name.
  9836. func (m *CompapiJobMutation) Op() Op {
  9837. return m.op
  9838. }
  9839. // SetOp allows setting the mutation operation.
  9840. func (m *CompapiJobMutation) SetOp(op Op) {
  9841. m.op = op
  9842. }
  9843. // Type returns the node type of this mutation (CompapiJob).
  9844. func (m *CompapiJobMutation) Type() string {
  9845. return m.typ
  9846. }
  9847. // Fields returns all fields that were changed during this mutation. Note that in
  9848. // order to get all numeric fields that were incremented/decremented, call
  9849. // AddedFields().
  9850. func (m *CompapiJobMutation) Fields() []string {
  9851. fields := make([]string, 0, 12)
  9852. if m.created_at != nil {
  9853. fields = append(fields, compapijob.FieldCreatedAt)
  9854. }
  9855. if m.updated_at != nil {
  9856. fields = append(fields, compapijob.FieldUpdatedAt)
  9857. }
  9858. if m.dist_at != nil {
  9859. fields = append(fields, compapijob.FieldDistAt)
  9860. }
  9861. if m.dist_status != nil {
  9862. fields = append(fields, compapijob.FieldDistStatus)
  9863. }
  9864. if m.callback_status != nil {
  9865. fields = append(fields, compapijob.FieldCallbackStatus)
  9866. }
  9867. if m.callback_url != nil {
  9868. fields = append(fields, compapijob.FieldCallbackURL)
  9869. }
  9870. if m.request_json != nil {
  9871. fields = append(fields, compapijob.FieldRequestJSON)
  9872. }
  9873. if m.auth_token != nil {
  9874. fields = append(fields, compapijob.FieldAuthToken)
  9875. }
  9876. if m.event_type != nil {
  9877. fields = append(fields, compapijob.FieldEventType)
  9878. }
  9879. if m.workid_idx != nil {
  9880. fields = append(fields, compapijob.FieldWorkidIdx)
  9881. }
  9882. if m.chat_id != nil {
  9883. fields = append(fields, compapijob.FieldChatID)
  9884. }
  9885. if m.retry_count != nil {
  9886. fields = append(fields, compapijob.FieldRetryCount)
  9887. }
  9888. return fields
  9889. }
  9890. // Field returns the value of a field with the given name. The second boolean
  9891. // return value indicates that this field was not set, or was not defined in the
  9892. // schema.
  9893. func (m *CompapiJobMutation) Field(name string) (ent.Value, bool) {
  9894. switch name {
  9895. case compapijob.FieldCreatedAt:
  9896. return m.CreatedAt()
  9897. case compapijob.FieldUpdatedAt:
  9898. return m.UpdatedAt()
  9899. case compapijob.FieldDistAt:
  9900. return m.DistAt()
  9901. case compapijob.FieldDistStatus:
  9902. return m.DistStatus()
  9903. case compapijob.FieldCallbackStatus:
  9904. return m.CallbackStatus()
  9905. case compapijob.FieldCallbackURL:
  9906. return m.CallbackURL()
  9907. case compapijob.FieldRequestJSON:
  9908. return m.RequestJSON()
  9909. case compapijob.FieldAuthToken:
  9910. return m.AuthToken()
  9911. case compapijob.FieldEventType:
  9912. return m.EventType()
  9913. case compapijob.FieldWorkidIdx:
  9914. return m.WorkidIdx()
  9915. case compapijob.FieldChatID:
  9916. return m.ChatID()
  9917. case compapijob.FieldRetryCount:
  9918. return m.RetryCount()
  9919. }
  9920. return nil, false
  9921. }
  9922. // OldField returns the old value of the field from the database. An error is
  9923. // returned if the mutation operation is not UpdateOne, or the query to the
  9924. // database failed.
  9925. func (m *CompapiJobMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9926. switch name {
  9927. case compapijob.FieldCreatedAt:
  9928. return m.OldCreatedAt(ctx)
  9929. case compapijob.FieldUpdatedAt:
  9930. return m.OldUpdatedAt(ctx)
  9931. case compapijob.FieldDistAt:
  9932. return m.OldDistAt(ctx)
  9933. case compapijob.FieldDistStatus:
  9934. return m.OldDistStatus(ctx)
  9935. case compapijob.FieldCallbackStatus:
  9936. return m.OldCallbackStatus(ctx)
  9937. case compapijob.FieldCallbackURL:
  9938. return m.OldCallbackURL(ctx)
  9939. case compapijob.FieldRequestJSON:
  9940. return m.OldRequestJSON(ctx)
  9941. case compapijob.FieldAuthToken:
  9942. return m.OldAuthToken(ctx)
  9943. case compapijob.FieldEventType:
  9944. return m.OldEventType(ctx)
  9945. case compapijob.FieldWorkidIdx:
  9946. return m.OldWorkidIdx(ctx)
  9947. case compapijob.FieldChatID:
  9948. return m.OldChatID(ctx)
  9949. case compapijob.FieldRetryCount:
  9950. return m.OldRetryCount(ctx)
  9951. }
  9952. return nil, fmt.Errorf("unknown CompapiJob field %s", name)
  9953. }
  9954. // SetField sets the value of a field with the given name. It returns an error if
  9955. // the field is not defined in the schema, or if the type mismatched the field
  9956. // type.
  9957. func (m *CompapiJobMutation) SetField(name string, value ent.Value) error {
  9958. switch name {
  9959. case compapijob.FieldCreatedAt:
  9960. v, ok := value.(time.Time)
  9961. if !ok {
  9962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9963. }
  9964. m.SetCreatedAt(v)
  9965. return nil
  9966. case compapijob.FieldUpdatedAt:
  9967. v, ok := value.(time.Time)
  9968. if !ok {
  9969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9970. }
  9971. m.SetUpdatedAt(v)
  9972. return nil
  9973. case compapijob.FieldDistAt:
  9974. v, ok := value.(time.Time)
  9975. if !ok {
  9976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9977. }
  9978. m.SetDistAt(v)
  9979. return nil
  9980. case compapijob.FieldDistStatus:
  9981. v, ok := value.(int8)
  9982. if !ok {
  9983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9984. }
  9985. m.SetDistStatus(v)
  9986. return nil
  9987. case compapijob.FieldCallbackStatus:
  9988. v, ok := value.(int8)
  9989. if !ok {
  9990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9991. }
  9992. m.SetCallbackStatus(v)
  9993. return nil
  9994. case compapijob.FieldCallbackURL:
  9995. v, ok := value.(string)
  9996. if !ok {
  9997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9998. }
  9999. m.SetCallbackURL(v)
  10000. return nil
  10001. case compapijob.FieldRequestJSON:
  10002. v, ok := value.(custom_types.OriginalData)
  10003. if !ok {
  10004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10005. }
  10006. m.SetRequestJSON(v)
  10007. return nil
  10008. case compapijob.FieldAuthToken:
  10009. v, ok := value.(string)
  10010. if !ok {
  10011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10012. }
  10013. m.SetAuthToken(v)
  10014. return nil
  10015. case compapijob.FieldEventType:
  10016. v, ok := value.(string)
  10017. if !ok {
  10018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10019. }
  10020. m.SetEventType(v)
  10021. return nil
  10022. case compapijob.FieldWorkidIdx:
  10023. v, ok := value.(int8)
  10024. if !ok {
  10025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10026. }
  10027. m.SetWorkidIdx(v)
  10028. return nil
  10029. case compapijob.FieldChatID:
  10030. v, ok := value.(string)
  10031. if !ok {
  10032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10033. }
  10034. m.SetChatID(v)
  10035. return nil
  10036. case compapijob.FieldRetryCount:
  10037. v, ok := value.(int8)
  10038. if !ok {
  10039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10040. }
  10041. m.SetRetryCount(v)
  10042. return nil
  10043. }
  10044. return fmt.Errorf("unknown CompapiJob field %s", name)
  10045. }
  10046. // AddedFields returns all numeric fields that were incremented/decremented during
  10047. // this mutation.
  10048. func (m *CompapiJobMutation) AddedFields() []string {
  10049. var fields []string
  10050. if m.adddist_status != nil {
  10051. fields = append(fields, compapijob.FieldDistStatus)
  10052. }
  10053. if m.addcallback_status != nil {
  10054. fields = append(fields, compapijob.FieldCallbackStatus)
  10055. }
  10056. if m.addworkid_idx != nil {
  10057. fields = append(fields, compapijob.FieldWorkidIdx)
  10058. }
  10059. if m.addretry_count != nil {
  10060. fields = append(fields, compapijob.FieldRetryCount)
  10061. }
  10062. return fields
  10063. }
  10064. // AddedField returns the numeric value that was incremented/decremented on a field
  10065. // with the given name. The second boolean return value indicates that this field
  10066. // was not set, or was not defined in the schema.
  10067. func (m *CompapiJobMutation) AddedField(name string) (ent.Value, bool) {
  10068. switch name {
  10069. case compapijob.FieldDistStatus:
  10070. return m.AddedDistStatus()
  10071. case compapijob.FieldCallbackStatus:
  10072. return m.AddedCallbackStatus()
  10073. case compapijob.FieldWorkidIdx:
  10074. return m.AddedWorkidIdx()
  10075. case compapijob.FieldRetryCount:
  10076. return m.AddedRetryCount()
  10077. }
  10078. return nil, false
  10079. }
  10080. // AddField adds the value to the field with the given name. It returns an error if
  10081. // the field is not defined in the schema, or if the type mismatched the field
  10082. // type.
  10083. func (m *CompapiJobMutation) AddField(name string, value ent.Value) error {
  10084. switch name {
  10085. case compapijob.FieldDistStatus:
  10086. v, ok := value.(int8)
  10087. if !ok {
  10088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10089. }
  10090. m.AddDistStatus(v)
  10091. return nil
  10092. case compapijob.FieldCallbackStatus:
  10093. v, ok := value.(int8)
  10094. if !ok {
  10095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10096. }
  10097. m.AddCallbackStatus(v)
  10098. return nil
  10099. case compapijob.FieldWorkidIdx:
  10100. v, ok := value.(int8)
  10101. if !ok {
  10102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10103. }
  10104. m.AddWorkidIdx(v)
  10105. return nil
  10106. case compapijob.FieldRetryCount:
  10107. v, ok := value.(int8)
  10108. if !ok {
  10109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10110. }
  10111. m.AddRetryCount(v)
  10112. return nil
  10113. }
  10114. return fmt.Errorf("unknown CompapiJob numeric field %s", name)
  10115. }
  10116. // ClearedFields returns all nullable fields that were cleared during this
  10117. // mutation.
  10118. func (m *CompapiJobMutation) ClearedFields() []string {
  10119. var fields []string
  10120. if m.FieldCleared(compapijob.FieldDistAt) {
  10121. fields = append(fields, compapijob.FieldDistAt)
  10122. }
  10123. if m.FieldCleared(compapijob.FieldDistStatus) {
  10124. fields = append(fields, compapijob.FieldDistStatus)
  10125. }
  10126. if m.FieldCleared(compapijob.FieldCallbackStatus) {
  10127. fields = append(fields, compapijob.FieldCallbackStatus)
  10128. }
  10129. if m.FieldCleared(compapijob.FieldWorkidIdx) {
  10130. fields = append(fields, compapijob.FieldWorkidIdx)
  10131. }
  10132. if m.FieldCleared(compapijob.FieldChatID) {
  10133. fields = append(fields, compapijob.FieldChatID)
  10134. }
  10135. if m.FieldCleared(compapijob.FieldRetryCount) {
  10136. fields = append(fields, compapijob.FieldRetryCount)
  10137. }
  10138. return fields
  10139. }
  10140. // FieldCleared returns a boolean indicating if a field with the given name was
  10141. // cleared in this mutation.
  10142. func (m *CompapiJobMutation) FieldCleared(name string) bool {
  10143. _, ok := m.clearedFields[name]
  10144. return ok
  10145. }
  10146. // ClearField clears the value of the field with the given name. It returns an
  10147. // error if the field is not defined in the schema.
  10148. func (m *CompapiJobMutation) ClearField(name string) error {
  10149. switch name {
  10150. case compapijob.FieldDistAt:
  10151. m.ClearDistAt()
  10152. return nil
  10153. case compapijob.FieldDistStatus:
  10154. m.ClearDistStatus()
  10155. return nil
  10156. case compapijob.FieldCallbackStatus:
  10157. m.ClearCallbackStatus()
  10158. return nil
  10159. case compapijob.FieldWorkidIdx:
  10160. m.ClearWorkidIdx()
  10161. return nil
  10162. case compapijob.FieldChatID:
  10163. m.ClearChatID()
  10164. return nil
  10165. case compapijob.FieldRetryCount:
  10166. m.ClearRetryCount()
  10167. return nil
  10168. }
  10169. return fmt.Errorf("unknown CompapiJob nullable field %s", name)
  10170. }
  10171. // ResetField resets all changes in the mutation for the field with the given name.
  10172. // It returns an error if the field is not defined in the schema.
  10173. func (m *CompapiJobMutation) ResetField(name string) error {
  10174. switch name {
  10175. case compapijob.FieldCreatedAt:
  10176. m.ResetCreatedAt()
  10177. return nil
  10178. case compapijob.FieldUpdatedAt:
  10179. m.ResetUpdatedAt()
  10180. return nil
  10181. case compapijob.FieldDistAt:
  10182. m.ResetDistAt()
  10183. return nil
  10184. case compapijob.FieldDistStatus:
  10185. m.ResetDistStatus()
  10186. return nil
  10187. case compapijob.FieldCallbackStatus:
  10188. m.ResetCallbackStatus()
  10189. return nil
  10190. case compapijob.FieldCallbackURL:
  10191. m.ResetCallbackURL()
  10192. return nil
  10193. case compapijob.FieldRequestJSON:
  10194. m.ResetRequestJSON()
  10195. return nil
  10196. case compapijob.FieldAuthToken:
  10197. m.ResetAuthToken()
  10198. return nil
  10199. case compapijob.FieldEventType:
  10200. m.ResetEventType()
  10201. return nil
  10202. case compapijob.FieldWorkidIdx:
  10203. m.ResetWorkidIdx()
  10204. return nil
  10205. case compapijob.FieldChatID:
  10206. m.ResetChatID()
  10207. return nil
  10208. case compapijob.FieldRetryCount:
  10209. m.ResetRetryCount()
  10210. return nil
  10211. }
  10212. return fmt.Errorf("unknown CompapiJob field %s", name)
  10213. }
  10214. // AddedEdges returns all edge names that were set/added in this mutation.
  10215. func (m *CompapiJobMutation) AddedEdges() []string {
  10216. edges := make([]string, 0, 0)
  10217. return edges
  10218. }
  10219. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10220. // name in this mutation.
  10221. func (m *CompapiJobMutation) AddedIDs(name string) []ent.Value {
  10222. return nil
  10223. }
  10224. // RemovedEdges returns all edge names that were removed in this mutation.
  10225. func (m *CompapiJobMutation) RemovedEdges() []string {
  10226. edges := make([]string, 0, 0)
  10227. return edges
  10228. }
  10229. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10230. // the given name in this mutation.
  10231. func (m *CompapiJobMutation) RemovedIDs(name string) []ent.Value {
  10232. return nil
  10233. }
  10234. // ClearedEdges returns all edge names that were cleared in this mutation.
  10235. func (m *CompapiJobMutation) ClearedEdges() []string {
  10236. edges := make([]string, 0, 0)
  10237. return edges
  10238. }
  10239. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10240. // was cleared in this mutation.
  10241. func (m *CompapiJobMutation) EdgeCleared(name string) bool {
  10242. return false
  10243. }
  10244. // ClearEdge clears the value of the edge with the given name. It returns an error
  10245. // if that edge is not defined in the schema.
  10246. func (m *CompapiJobMutation) ClearEdge(name string) error {
  10247. return fmt.Errorf("unknown CompapiJob unique edge %s", name)
  10248. }
  10249. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10250. // It returns an error if the edge is not defined in the schema.
  10251. func (m *CompapiJobMutation) ResetEdge(name string) error {
  10252. return fmt.Errorf("unknown CompapiJob edge %s", name)
  10253. }
  10254. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  10255. type ContactMutation struct {
  10256. config
  10257. op Op
  10258. typ string
  10259. id *uint64
  10260. created_at *time.Time
  10261. updated_at *time.Time
  10262. status *uint8
  10263. addstatus *int8
  10264. deleted_at *time.Time
  10265. wx_wxid *string
  10266. _type *int
  10267. add_type *int
  10268. wxid *string
  10269. account *string
  10270. nickname *string
  10271. markname *string
  10272. headimg *string
  10273. sex *int
  10274. addsex *int
  10275. starrole *string
  10276. dontseeit *int
  10277. adddontseeit *int
  10278. dontseeme *int
  10279. adddontseeme *int
  10280. lag *string
  10281. gid *string
  10282. gname *string
  10283. v3 *string
  10284. organization_id *uint64
  10285. addorganization_id *int64
  10286. ctype *uint64
  10287. addctype *int64
  10288. cage *int
  10289. addcage *int
  10290. cname *string
  10291. carea *string
  10292. cbirthday *string
  10293. cbirtharea *string
  10294. cidcard_no *string
  10295. ctitle *string
  10296. cc *string
  10297. phone *string
  10298. clearedFields map[string]struct{}
  10299. contact_relationships map[uint64]struct{}
  10300. removedcontact_relationships map[uint64]struct{}
  10301. clearedcontact_relationships bool
  10302. contact_messages map[uint64]struct{}
  10303. removedcontact_messages map[uint64]struct{}
  10304. clearedcontact_messages bool
  10305. done bool
  10306. oldValue func(context.Context) (*Contact, error)
  10307. predicates []predicate.Contact
  10308. }
  10309. var _ ent.Mutation = (*ContactMutation)(nil)
  10310. // contactOption allows management of the mutation configuration using functional options.
  10311. type contactOption func(*ContactMutation)
  10312. // newContactMutation creates new mutation for the Contact entity.
  10313. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  10314. m := &ContactMutation{
  10315. config: c,
  10316. op: op,
  10317. typ: TypeContact,
  10318. clearedFields: make(map[string]struct{}),
  10319. }
  10320. for _, opt := range opts {
  10321. opt(m)
  10322. }
  10323. return m
  10324. }
  10325. // withContactID sets the ID field of the mutation.
  10326. func withContactID(id uint64) contactOption {
  10327. return func(m *ContactMutation) {
  10328. var (
  10329. err error
  10330. once sync.Once
  10331. value *Contact
  10332. )
  10333. m.oldValue = func(ctx context.Context) (*Contact, error) {
  10334. once.Do(func() {
  10335. if m.done {
  10336. err = errors.New("querying old values post mutation is not allowed")
  10337. } else {
  10338. value, err = m.Client().Contact.Get(ctx, id)
  10339. }
  10340. })
  10341. return value, err
  10342. }
  10343. m.id = &id
  10344. }
  10345. }
  10346. // withContact sets the old Contact of the mutation.
  10347. func withContact(node *Contact) contactOption {
  10348. return func(m *ContactMutation) {
  10349. m.oldValue = func(context.Context) (*Contact, error) {
  10350. return node, nil
  10351. }
  10352. m.id = &node.ID
  10353. }
  10354. }
  10355. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10356. // executed in a transaction (ent.Tx), a transactional client is returned.
  10357. func (m ContactMutation) Client() *Client {
  10358. client := &Client{config: m.config}
  10359. client.init()
  10360. return client
  10361. }
  10362. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10363. // it returns an error otherwise.
  10364. func (m ContactMutation) Tx() (*Tx, error) {
  10365. if _, ok := m.driver.(*txDriver); !ok {
  10366. return nil, errors.New("ent: mutation is not running in a transaction")
  10367. }
  10368. tx := &Tx{config: m.config}
  10369. tx.init()
  10370. return tx, nil
  10371. }
  10372. // SetID sets the value of the id field. Note that this
  10373. // operation is only accepted on creation of Contact entities.
  10374. func (m *ContactMutation) SetID(id uint64) {
  10375. m.id = &id
  10376. }
  10377. // ID returns the ID value in the mutation. Note that the ID is only available
  10378. // if it was provided to the builder or after it was returned from the database.
  10379. func (m *ContactMutation) ID() (id uint64, exists bool) {
  10380. if m.id == nil {
  10381. return
  10382. }
  10383. return *m.id, true
  10384. }
  10385. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10386. // That means, if the mutation is applied within a transaction with an isolation level such
  10387. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10388. // or updated by the mutation.
  10389. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  10390. switch {
  10391. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10392. id, exists := m.ID()
  10393. if exists {
  10394. return []uint64{id}, nil
  10395. }
  10396. fallthrough
  10397. case m.op.Is(OpUpdate | OpDelete):
  10398. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  10399. default:
  10400. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10401. }
  10402. }
  10403. // SetCreatedAt sets the "created_at" field.
  10404. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  10405. m.created_at = &t
  10406. }
  10407. // CreatedAt returns the value of the "created_at" field in the mutation.
  10408. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  10409. v := m.created_at
  10410. if v == nil {
  10411. return
  10412. }
  10413. return *v, true
  10414. }
  10415. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  10416. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10418. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10419. if !m.op.Is(OpUpdateOne) {
  10420. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10421. }
  10422. if m.id == nil || m.oldValue == nil {
  10423. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10424. }
  10425. oldValue, err := m.oldValue(ctx)
  10426. if err != nil {
  10427. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10428. }
  10429. return oldValue.CreatedAt, nil
  10430. }
  10431. // ResetCreatedAt resets all changes to the "created_at" field.
  10432. func (m *ContactMutation) ResetCreatedAt() {
  10433. m.created_at = nil
  10434. }
  10435. // SetUpdatedAt sets the "updated_at" field.
  10436. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  10437. m.updated_at = &t
  10438. }
  10439. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10440. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  10441. v := m.updated_at
  10442. if v == nil {
  10443. return
  10444. }
  10445. return *v, true
  10446. }
  10447. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  10448. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10450. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10451. if !m.op.Is(OpUpdateOne) {
  10452. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10453. }
  10454. if m.id == nil || m.oldValue == nil {
  10455. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10456. }
  10457. oldValue, err := m.oldValue(ctx)
  10458. if err != nil {
  10459. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10460. }
  10461. return oldValue.UpdatedAt, nil
  10462. }
  10463. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10464. func (m *ContactMutation) ResetUpdatedAt() {
  10465. m.updated_at = nil
  10466. }
  10467. // SetStatus sets the "status" field.
  10468. func (m *ContactMutation) SetStatus(u uint8) {
  10469. m.status = &u
  10470. m.addstatus = nil
  10471. }
  10472. // Status returns the value of the "status" field in the mutation.
  10473. func (m *ContactMutation) Status() (r uint8, exists bool) {
  10474. v := m.status
  10475. if v == nil {
  10476. return
  10477. }
  10478. return *v, true
  10479. }
  10480. // OldStatus returns the old "status" field's value of the Contact entity.
  10481. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10483. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10484. if !m.op.Is(OpUpdateOne) {
  10485. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10486. }
  10487. if m.id == nil || m.oldValue == nil {
  10488. return v, errors.New("OldStatus requires an ID field in the mutation")
  10489. }
  10490. oldValue, err := m.oldValue(ctx)
  10491. if err != nil {
  10492. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10493. }
  10494. return oldValue.Status, nil
  10495. }
  10496. // AddStatus adds u to the "status" field.
  10497. func (m *ContactMutation) AddStatus(u int8) {
  10498. if m.addstatus != nil {
  10499. *m.addstatus += u
  10500. } else {
  10501. m.addstatus = &u
  10502. }
  10503. }
  10504. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10505. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  10506. v := m.addstatus
  10507. if v == nil {
  10508. return
  10509. }
  10510. return *v, true
  10511. }
  10512. // ClearStatus clears the value of the "status" field.
  10513. func (m *ContactMutation) ClearStatus() {
  10514. m.status = nil
  10515. m.addstatus = nil
  10516. m.clearedFields[contact.FieldStatus] = struct{}{}
  10517. }
  10518. // StatusCleared returns if the "status" field was cleared in this mutation.
  10519. func (m *ContactMutation) StatusCleared() bool {
  10520. _, ok := m.clearedFields[contact.FieldStatus]
  10521. return ok
  10522. }
  10523. // ResetStatus resets all changes to the "status" field.
  10524. func (m *ContactMutation) ResetStatus() {
  10525. m.status = nil
  10526. m.addstatus = nil
  10527. delete(m.clearedFields, contact.FieldStatus)
  10528. }
  10529. // SetDeletedAt sets the "deleted_at" field.
  10530. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  10531. m.deleted_at = &t
  10532. }
  10533. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10534. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  10535. v := m.deleted_at
  10536. if v == nil {
  10537. return
  10538. }
  10539. return *v, true
  10540. }
  10541. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  10542. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10544. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10545. if !m.op.Is(OpUpdateOne) {
  10546. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10547. }
  10548. if m.id == nil || m.oldValue == nil {
  10549. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10550. }
  10551. oldValue, err := m.oldValue(ctx)
  10552. if err != nil {
  10553. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10554. }
  10555. return oldValue.DeletedAt, nil
  10556. }
  10557. // ClearDeletedAt clears the value of the "deleted_at" field.
  10558. func (m *ContactMutation) ClearDeletedAt() {
  10559. m.deleted_at = nil
  10560. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  10561. }
  10562. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10563. func (m *ContactMutation) DeletedAtCleared() bool {
  10564. _, ok := m.clearedFields[contact.FieldDeletedAt]
  10565. return ok
  10566. }
  10567. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10568. func (m *ContactMutation) ResetDeletedAt() {
  10569. m.deleted_at = nil
  10570. delete(m.clearedFields, contact.FieldDeletedAt)
  10571. }
  10572. // SetWxWxid sets the "wx_wxid" field.
  10573. func (m *ContactMutation) SetWxWxid(s string) {
  10574. m.wx_wxid = &s
  10575. }
  10576. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  10577. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  10578. v := m.wx_wxid
  10579. if v == nil {
  10580. return
  10581. }
  10582. return *v, true
  10583. }
  10584. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  10585. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10587. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  10588. if !m.op.Is(OpUpdateOne) {
  10589. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  10590. }
  10591. if m.id == nil || m.oldValue == nil {
  10592. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  10593. }
  10594. oldValue, err := m.oldValue(ctx)
  10595. if err != nil {
  10596. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  10597. }
  10598. return oldValue.WxWxid, nil
  10599. }
  10600. // ResetWxWxid resets all changes to the "wx_wxid" field.
  10601. func (m *ContactMutation) ResetWxWxid() {
  10602. m.wx_wxid = nil
  10603. }
  10604. // SetType sets the "type" field.
  10605. func (m *ContactMutation) SetType(i int) {
  10606. m._type = &i
  10607. m.add_type = nil
  10608. }
  10609. // GetType returns the value of the "type" field in the mutation.
  10610. func (m *ContactMutation) GetType() (r int, exists bool) {
  10611. v := m._type
  10612. if v == nil {
  10613. return
  10614. }
  10615. return *v, true
  10616. }
  10617. // OldType returns the old "type" field's value of the Contact entity.
  10618. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10620. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  10621. if !m.op.Is(OpUpdateOne) {
  10622. return v, errors.New("OldType is only allowed on UpdateOne operations")
  10623. }
  10624. if m.id == nil || m.oldValue == nil {
  10625. return v, errors.New("OldType requires an ID field in the mutation")
  10626. }
  10627. oldValue, err := m.oldValue(ctx)
  10628. if err != nil {
  10629. return v, fmt.Errorf("querying old value for OldType: %w", err)
  10630. }
  10631. return oldValue.Type, nil
  10632. }
  10633. // AddType adds i to the "type" field.
  10634. func (m *ContactMutation) AddType(i int) {
  10635. if m.add_type != nil {
  10636. *m.add_type += i
  10637. } else {
  10638. m.add_type = &i
  10639. }
  10640. }
  10641. // AddedType returns the value that was added to the "type" field in this mutation.
  10642. func (m *ContactMutation) AddedType() (r int, exists bool) {
  10643. v := m.add_type
  10644. if v == nil {
  10645. return
  10646. }
  10647. return *v, true
  10648. }
  10649. // ClearType clears the value of the "type" field.
  10650. func (m *ContactMutation) ClearType() {
  10651. m._type = nil
  10652. m.add_type = nil
  10653. m.clearedFields[contact.FieldType] = struct{}{}
  10654. }
  10655. // TypeCleared returns if the "type" field was cleared in this mutation.
  10656. func (m *ContactMutation) TypeCleared() bool {
  10657. _, ok := m.clearedFields[contact.FieldType]
  10658. return ok
  10659. }
  10660. // ResetType resets all changes to the "type" field.
  10661. func (m *ContactMutation) ResetType() {
  10662. m._type = nil
  10663. m.add_type = nil
  10664. delete(m.clearedFields, contact.FieldType)
  10665. }
  10666. // SetWxid sets the "wxid" field.
  10667. func (m *ContactMutation) SetWxid(s string) {
  10668. m.wxid = &s
  10669. }
  10670. // Wxid returns the value of the "wxid" field in the mutation.
  10671. func (m *ContactMutation) Wxid() (r string, exists bool) {
  10672. v := m.wxid
  10673. if v == nil {
  10674. return
  10675. }
  10676. return *v, true
  10677. }
  10678. // OldWxid returns the old "wxid" field's value of the Contact entity.
  10679. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10681. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  10682. if !m.op.Is(OpUpdateOne) {
  10683. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  10684. }
  10685. if m.id == nil || m.oldValue == nil {
  10686. return v, errors.New("OldWxid requires an ID field in the mutation")
  10687. }
  10688. oldValue, err := m.oldValue(ctx)
  10689. if err != nil {
  10690. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  10691. }
  10692. return oldValue.Wxid, nil
  10693. }
  10694. // ResetWxid resets all changes to the "wxid" field.
  10695. func (m *ContactMutation) ResetWxid() {
  10696. m.wxid = nil
  10697. }
  10698. // SetAccount sets the "account" field.
  10699. func (m *ContactMutation) SetAccount(s string) {
  10700. m.account = &s
  10701. }
  10702. // Account returns the value of the "account" field in the mutation.
  10703. func (m *ContactMutation) Account() (r string, exists bool) {
  10704. v := m.account
  10705. if v == nil {
  10706. return
  10707. }
  10708. return *v, true
  10709. }
  10710. // OldAccount returns the old "account" field's value of the Contact entity.
  10711. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10713. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  10714. if !m.op.Is(OpUpdateOne) {
  10715. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  10716. }
  10717. if m.id == nil || m.oldValue == nil {
  10718. return v, errors.New("OldAccount requires an ID field in the mutation")
  10719. }
  10720. oldValue, err := m.oldValue(ctx)
  10721. if err != nil {
  10722. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  10723. }
  10724. return oldValue.Account, nil
  10725. }
  10726. // ResetAccount resets all changes to the "account" field.
  10727. func (m *ContactMutation) ResetAccount() {
  10728. m.account = nil
  10729. }
  10730. // SetNickname sets the "nickname" field.
  10731. func (m *ContactMutation) SetNickname(s string) {
  10732. m.nickname = &s
  10733. }
  10734. // Nickname returns the value of the "nickname" field in the mutation.
  10735. func (m *ContactMutation) Nickname() (r string, exists bool) {
  10736. v := m.nickname
  10737. if v == nil {
  10738. return
  10739. }
  10740. return *v, true
  10741. }
  10742. // OldNickname returns the old "nickname" field's value of the Contact entity.
  10743. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10745. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  10746. if !m.op.Is(OpUpdateOne) {
  10747. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  10748. }
  10749. if m.id == nil || m.oldValue == nil {
  10750. return v, errors.New("OldNickname requires an ID field in the mutation")
  10751. }
  10752. oldValue, err := m.oldValue(ctx)
  10753. if err != nil {
  10754. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  10755. }
  10756. return oldValue.Nickname, nil
  10757. }
  10758. // ResetNickname resets all changes to the "nickname" field.
  10759. func (m *ContactMutation) ResetNickname() {
  10760. m.nickname = nil
  10761. }
  10762. // SetMarkname sets the "markname" field.
  10763. func (m *ContactMutation) SetMarkname(s string) {
  10764. m.markname = &s
  10765. }
  10766. // Markname returns the value of the "markname" field in the mutation.
  10767. func (m *ContactMutation) Markname() (r string, exists bool) {
  10768. v := m.markname
  10769. if v == nil {
  10770. return
  10771. }
  10772. return *v, true
  10773. }
  10774. // OldMarkname returns the old "markname" field's value of the Contact entity.
  10775. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10777. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  10778. if !m.op.Is(OpUpdateOne) {
  10779. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  10780. }
  10781. if m.id == nil || m.oldValue == nil {
  10782. return v, errors.New("OldMarkname requires an ID field in the mutation")
  10783. }
  10784. oldValue, err := m.oldValue(ctx)
  10785. if err != nil {
  10786. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  10787. }
  10788. return oldValue.Markname, nil
  10789. }
  10790. // ResetMarkname resets all changes to the "markname" field.
  10791. func (m *ContactMutation) ResetMarkname() {
  10792. m.markname = nil
  10793. }
  10794. // SetHeadimg sets the "headimg" field.
  10795. func (m *ContactMutation) SetHeadimg(s string) {
  10796. m.headimg = &s
  10797. }
  10798. // Headimg returns the value of the "headimg" field in the mutation.
  10799. func (m *ContactMutation) Headimg() (r string, exists bool) {
  10800. v := m.headimg
  10801. if v == nil {
  10802. return
  10803. }
  10804. return *v, true
  10805. }
  10806. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  10807. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10809. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  10810. if !m.op.Is(OpUpdateOne) {
  10811. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  10812. }
  10813. if m.id == nil || m.oldValue == nil {
  10814. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  10815. }
  10816. oldValue, err := m.oldValue(ctx)
  10817. if err != nil {
  10818. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  10819. }
  10820. return oldValue.Headimg, nil
  10821. }
  10822. // ResetHeadimg resets all changes to the "headimg" field.
  10823. func (m *ContactMutation) ResetHeadimg() {
  10824. m.headimg = nil
  10825. }
  10826. // SetSex sets the "sex" field.
  10827. func (m *ContactMutation) SetSex(i int) {
  10828. m.sex = &i
  10829. m.addsex = nil
  10830. }
  10831. // Sex returns the value of the "sex" field in the mutation.
  10832. func (m *ContactMutation) Sex() (r int, exists bool) {
  10833. v := m.sex
  10834. if v == nil {
  10835. return
  10836. }
  10837. return *v, true
  10838. }
  10839. // OldSex returns the old "sex" field's value of the Contact entity.
  10840. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10842. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  10843. if !m.op.Is(OpUpdateOne) {
  10844. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  10845. }
  10846. if m.id == nil || m.oldValue == nil {
  10847. return v, errors.New("OldSex requires an ID field in the mutation")
  10848. }
  10849. oldValue, err := m.oldValue(ctx)
  10850. if err != nil {
  10851. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  10852. }
  10853. return oldValue.Sex, nil
  10854. }
  10855. // AddSex adds i to the "sex" field.
  10856. func (m *ContactMutation) AddSex(i int) {
  10857. if m.addsex != nil {
  10858. *m.addsex += i
  10859. } else {
  10860. m.addsex = &i
  10861. }
  10862. }
  10863. // AddedSex returns the value that was added to the "sex" field in this mutation.
  10864. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  10865. v := m.addsex
  10866. if v == nil {
  10867. return
  10868. }
  10869. return *v, true
  10870. }
  10871. // ResetSex resets all changes to the "sex" field.
  10872. func (m *ContactMutation) ResetSex() {
  10873. m.sex = nil
  10874. m.addsex = nil
  10875. }
  10876. // SetStarrole sets the "starrole" field.
  10877. func (m *ContactMutation) SetStarrole(s string) {
  10878. m.starrole = &s
  10879. }
  10880. // Starrole returns the value of the "starrole" field in the mutation.
  10881. func (m *ContactMutation) Starrole() (r string, exists bool) {
  10882. v := m.starrole
  10883. if v == nil {
  10884. return
  10885. }
  10886. return *v, true
  10887. }
  10888. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  10889. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10891. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  10892. if !m.op.Is(OpUpdateOne) {
  10893. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  10894. }
  10895. if m.id == nil || m.oldValue == nil {
  10896. return v, errors.New("OldStarrole requires an ID field in the mutation")
  10897. }
  10898. oldValue, err := m.oldValue(ctx)
  10899. if err != nil {
  10900. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  10901. }
  10902. return oldValue.Starrole, nil
  10903. }
  10904. // ResetStarrole resets all changes to the "starrole" field.
  10905. func (m *ContactMutation) ResetStarrole() {
  10906. m.starrole = nil
  10907. }
  10908. // SetDontseeit sets the "dontseeit" field.
  10909. func (m *ContactMutation) SetDontseeit(i int) {
  10910. m.dontseeit = &i
  10911. m.adddontseeit = nil
  10912. }
  10913. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  10914. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  10915. v := m.dontseeit
  10916. if v == nil {
  10917. return
  10918. }
  10919. return *v, true
  10920. }
  10921. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  10922. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10924. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  10925. if !m.op.Is(OpUpdateOne) {
  10926. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  10927. }
  10928. if m.id == nil || m.oldValue == nil {
  10929. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  10930. }
  10931. oldValue, err := m.oldValue(ctx)
  10932. if err != nil {
  10933. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  10934. }
  10935. return oldValue.Dontseeit, nil
  10936. }
  10937. // AddDontseeit adds i to the "dontseeit" field.
  10938. func (m *ContactMutation) AddDontseeit(i int) {
  10939. if m.adddontseeit != nil {
  10940. *m.adddontseeit += i
  10941. } else {
  10942. m.adddontseeit = &i
  10943. }
  10944. }
  10945. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  10946. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  10947. v := m.adddontseeit
  10948. if v == nil {
  10949. return
  10950. }
  10951. return *v, true
  10952. }
  10953. // ResetDontseeit resets all changes to the "dontseeit" field.
  10954. func (m *ContactMutation) ResetDontseeit() {
  10955. m.dontseeit = nil
  10956. m.adddontseeit = nil
  10957. }
  10958. // SetDontseeme sets the "dontseeme" field.
  10959. func (m *ContactMutation) SetDontseeme(i int) {
  10960. m.dontseeme = &i
  10961. m.adddontseeme = nil
  10962. }
  10963. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  10964. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  10965. v := m.dontseeme
  10966. if v == nil {
  10967. return
  10968. }
  10969. return *v, true
  10970. }
  10971. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  10972. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10974. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  10975. if !m.op.Is(OpUpdateOne) {
  10976. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  10977. }
  10978. if m.id == nil || m.oldValue == nil {
  10979. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  10980. }
  10981. oldValue, err := m.oldValue(ctx)
  10982. if err != nil {
  10983. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  10984. }
  10985. return oldValue.Dontseeme, nil
  10986. }
  10987. // AddDontseeme adds i to the "dontseeme" field.
  10988. func (m *ContactMutation) AddDontseeme(i int) {
  10989. if m.adddontseeme != nil {
  10990. *m.adddontseeme += i
  10991. } else {
  10992. m.adddontseeme = &i
  10993. }
  10994. }
  10995. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  10996. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  10997. v := m.adddontseeme
  10998. if v == nil {
  10999. return
  11000. }
  11001. return *v, true
  11002. }
  11003. // ResetDontseeme resets all changes to the "dontseeme" field.
  11004. func (m *ContactMutation) ResetDontseeme() {
  11005. m.dontseeme = nil
  11006. m.adddontseeme = nil
  11007. }
  11008. // SetLag sets the "lag" field.
  11009. func (m *ContactMutation) SetLag(s string) {
  11010. m.lag = &s
  11011. }
  11012. // Lag returns the value of the "lag" field in the mutation.
  11013. func (m *ContactMutation) Lag() (r string, exists bool) {
  11014. v := m.lag
  11015. if v == nil {
  11016. return
  11017. }
  11018. return *v, true
  11019. }
  11020. // OldLag returns the old "lag" field's value of the Contact entity.
  11021. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11023. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  11024. if !m.op.Is(OpUpdateOne) {
  11025. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  11026. }
  11027. if m.id == nil || m.oldValue == nil {
  11028. return v, errors.New("OldLag requires an ID field in the mutation")
  11029. }
  11030. oldValue, err := m.oldValue(ctx)
  11031. if err != nil {
  11032. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  11033. }
  11034. return oldValue.Lag, nil
  11035. }
  11036. // ResetLag resets all changes to the "lag" field.
  11037. func (m *ContactMutation) ResetLag() {
  11038. m.lag = nil
  11039. }
  11040. // SetGid sets the "gid" field.
  11041. func (m *ContactMutation) SetGid(s string) {
  11042. m.gid = &s
  11043. }
  11044. // Gid returns the value of the "gid" field in the mutation.
  11045. func (m *ContactMutation) Gid() (r string, exists bool) {
  11046. v := m.gid
  11047. if v == nil {
  11048. return
  11049. }
  11050. return *v, true
  11051. }
  11052. // OldGid returns the old "gid" field's value of the Contact entity.
  11053. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11055. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  11056. if !m.op.Is(OpUpdateOne) {
  11057. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  11058. }
  11059. if m.id == nil || m.oldValue == nil {
  11060. return v, errors.New("OldGid requires an ID field in the mutation")
  11061. }
  11062. oldValue, err := m.oldValue(ctx)
  11063. if err != nil {
  11064. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  11065. }
  11066. return oldValue.Gid, nil
  11067. }
  11068. // ResetGid resets all changes to the "gid" field.
  11069. func (m *ContactMutation) ResetGid() {
  11070. m.gid = nil
  11071. }
  11072. // SetGname sets the "gname" field.
  11073. func (m *ContactMutation) SetGname(s string) {
  11074. m.gname = &s
  11075. }
  11076. // Gname returns the value of the "gname" field in the mutation.
  11077. func (m *ContactMutation) Gname() (r string, exists bool) {
  11078. v := m.gname
  11079. if v == nil {
  11080. return
  11081. }
  11082. return *v, true
  11083. }
  11084. // OldGname returns the old "gname" field's value of the Contact entity.
  11085. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11087. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  11088. if !m.op.Is(OpUpdateOne) {
  11089. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  11090. }
  11091. if m.id == nil || m.oldValue == nil {
  11092. return v, errors.New("OldGname requires an ID field in the mutation")
  11093. }
  11094. oldValue, err := m.oldValue(ctx)
  11095. if err != nil {
  11096. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  11097. }
  11098. return oldValue.Gname, nil
  11099. }
  11100. // ResetGname resets all changes to the "gname" field.
  11101. func (m *ContactMutation) ResetGname() {
  11102. m.gname = nil
  11103. }
  11104. // SetV3 sets the "v3" field.
  11105. func (m *ContactMutation) SetV3(s string) {
  11106. m.v3 = &s
  11107. }
  11108. // V3 returns the value of the "v3" field in the mutation.
  11109. func (m *ContactMutation) V3() (r string, exists bool) {
  11110. v := m.v3
  11111. if v == nil {
  11112. return
  11113. }
  11114. return *v, true
  11115. }
  11116. // OldV3 returns the old "v3" field's value of the Contact entity.
  11117. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11119. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  11120. if !m.op.Is(OpUpdateOne) {
  11121. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  11122. }
  11123. if m.id == nil || m.oldValue == nil {
  11124. return v, errors.New("OldV3 requires an ID field in the mutation")
  11125. }
  11126. oldValue, err := m.oldValue(ctx)
  11127. if err != nil {
  11128. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  11129. }
  11130. return oldValue.V3, nil
  11131. }
  11132. // ResetV3 resets all changes to the "v3" field.
  11133. func (m *ContactMutation) ResetV3() {
  11134. m.v3 = nil
  11135. }
  11136. // SetOrganizationID sets the "organization_id" field.
  11137. func (m *ContactMutation) SetOrganizationID(u uint64) {
  11138. m.organization_id = &u
  11139. m.addorganization_id = nil
  11140. }
  11141. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11142. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  11143. v := m.organization_id
  11144. if v == nil {
  11145. return
  11146. }
  11147. return *v, true
  11148. }
  11149. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  11150. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11152. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11153. if !m.op.Is(OpUpdateOne) {
  11154. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11155. }
  11156. if m.id == nil || m.oldValue == nil {
  11157. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11158. }
  11159. oldValue, err := m.oldValue(ctx)
  11160. if err != nil {
  11161. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11162. }
  11163. return oldValue.OrganizationID, nil
  11164. }
  11165. // AddOrganizationID adds u to the "organization_id" field.
  11166. func (m *ContactMutation) AddOrganizationID(u int64) {
  11167. if m.addorganization_id != nil {
  11168. *m.addorganization_id += u
  11169. } else {
  11170. m.addorganization_id = &u
  11171. }
  11172. }
  11173. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11174. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  11175. v := m.addorganization_id
  11176. if v == nil {
  11177. return
  11178. }
  11179. return *v, true
  11180. }
  11181. // ClearOrganizationID clears the value of the "organization_id" field.
  11182. func (m *ContactMutation) ClearOrganizationID() {
  11183. m.organization_id = nil
  11184. m.addorganization_id = nil
  11185. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  11186. }
  11187. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11188. func (m *ContactMutation) OrganizationIDCleared() bool {
  11189. _, ok := m.clearedFields[contact.FieldOrganizationID]
  11190. return ok
  11191. }
  11192. // ResetOrganizationID resets all changes to the "organization_id" field.
  11193. func (m *ContactMutation) ResetOrganizationID() {
  11194. m.organization_id = nil
  11195. m.addorganization_id = nil
  11196. delete(m.clearedFields, contact.FieldOrganizationID)
  11197. }
  11198. // SetCtype sets the "ctype" field.
  11199. func (m *ContactMutation) SetCtype(u uint64) {
  11200. m.ctype = &u
  11201. m.addctype = nil
  11202. }
  11203. // Ctype returns the value of the "ctype" field in the mutation.
  11204. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  11205. v := m.ctype
  11206. if v == nil {
  11207. return
  11208. }
  11209. return *v, true
  11210. }
  11211. // OldCtype returns the old "ctype" field's value of the Contact entity.
  11212. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11214. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  11215. if !m.op.Is(OpUpdateOne) {
  11216. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  11217. }
  11218. if m.id == nil || m.oldValue == nil {
  11219. return v, errors.New("OldCtype requires an ID field in the mutation")
  11220. }
  11221. oldValue, err := m.oldValue(ctx)
  11222. if err != nil {
  11223. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  11224. }
  11225. return oldValue.Ctype, nil
  11226. }
  11227. // AddCtype adds u to the "ctype" field.
  11228. func (m *ContactMutation) AddCtype(u int64) {
  11229. if m.addctype != nil {
  11230. *m.addctype += u
  11231. } else {
  11232. m.addctype = &u
  11233. }
  11234. }
  11235. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  11236. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  11237. v := m.addctype
  11238. if v == nil {
  11239. return
  11240. }
  11241. return *v, true
  11242. }
  11243. // ResetCtype resets all changes to the "ctype" field.
  11244. func (m *ContactMutation) ResetCtype() {
  11245. m.ctype = nil
  11246. m.addctype = nil
  11247. }
  11248. // SetCage sets the "cage" field.
  11249. func (m *ContactMutation) SetCage(i int) {
  11250. m.cage = &i
  11251. m.addcage = nil
  11252. }
  11253. // Cage returns the value of the "cage" field in the mutation.
  11254. func (m *ContactMutation) Cage() (r int, exists bool) {
  11255. v := m.cage
  11256. if v == nil {
  11257. return
  11258. }
  11259. return *v, true
  11260. }
  11261. // OldCage returns the old "cage" field's value of the Contact entity.
  11262. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11264. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  11265. if !m.op.Is(OpUpdateOne) {
  11266. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  11267. }
  11268. if m.id == nil || m.oldValue == nil {
  11269. return v, errors.New("OldCage requires an ID field in the mutation")
  11270. }
  11271. oldValue, err := m.oldValue(ctx)
  11272. if err != nil {
  11273. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  11274. }
  11275. return oldValue.Cage, nil
  11276. }
  11277. // AddCage adds i to the "cage" field.
  11278. func (m *ContactMutation) AddCage(i int) {
  11279. if m.addcage != nil {
  11280. *m.addcage += i
  11281. } else {
  11282. m.addcage = &i
  11283. }
  11284. }
  11285. // AddedCage returns the value that was added to the "cage" field in this mutation.
  11286. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  11287. v := m.addcage
  11288. if v == nil {
  11289. return
  11290. }
  11291. return *v, true
  11292. }
  11293. // ResetCage resets all changes to the "cage" field.
  11294. func (m *ContactMutation) ResetCage() {
  11295. m.cage = nil
  11296. m.addcage = nil
  11297. }
  11298. // SetCname sets the "cname" field.
  11299. func (m *ContactMutation) SetCname(s string) {
  11300. m.cname = &s
  11301. }
  11302. // Cname returns the value of the "cname" field in the mutation.
  11303. func (m *ContactMutation) Cname() (r string, exists bool) {
  11304. v := m.cname
  11305. if v == nil {
  11306. return
  11307. }
  11308. return *v, true
  11309. }
  11310. // OldCname returns the old "cname" field's value of the Contact entity.
  11311. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11313. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  11314. if !m.op.Is(OpUpdateOne) {
  11315. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  11316. }
  11317. if m.id == nil || m.oldValue == nil {
  11318. return v, errors.New("OldCname requires an ID field in the mutation")
  11319. }
  11320. oldValue, err := m.oldValue(ctx)
  11321. if err != nil {
  11322. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  11323. }
  11324. return oldValue.Cname, nil
  11325. }
  11326. // ResetCname resets all changes to the "cname" field.
  11327. func (m *ContactMutation) ResetCname() {
  11328. m.cname = nil
  11329. }
  11330. // SetCarea sets the "carea" field.
  11331. func (m *ContactMutation) SetCarea(s string) {
  11332. m.carea = &s
  11333. }
  11334. // Carea returns the value of the "carea" field in the mutation.
  11335. func (m *ContactMutation) Carea() (r string, exists bool) {
  11336. v := m.carea
  11337. if v == nil {
  11338. return
  11339. }
  11340. return *v, true
  11341. }
  11342. // OldCarea returns the old "carea" field's value of the Contact entity.
  11343. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11345. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  11346. if !m.op.Is(OpUpdateOne) {
  11347. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  11348. }
  11349. if m.id == nil || m.oldValue == nil {
  11350. return v, errors.New("OldCarea requires an ID field in the mutation")
  11351. }
  11352. oldValue, err := m.oldValue(ctx)
  11353. if err != nil {
  11354. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  11355. }
  11356. return oldValue.Carea, nil
  11357. }
  11358. // ResetCarea resets all changes to the "carea" field.
  11359. func (m *ContactMutation) ResetCarea() {
  11360. m.carea = nil
  11361. }
  11362. // SetCbirthday sets the "cbirthday" field.
  11363. func (m *ContactMutation) SetCbirthday(s string) {
  11364. m.cbirthday = &s
  11365. }
  11366. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  11367. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  11368. v := m.cbirthday
  11369. if v == nil {
  11370. return
  11371. }
  11372. return *v, true
  11373. }
  11374. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  11375. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11377. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  11378. if !m.op.Is(OpUpdateOne) {
  11379. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  11380. }
  11381. if m.id == nil || m.oldValue == nil {
  11382. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  11383. }
  11384. oldValue, err := m.oldValue(ctx)
  11385. if err != nil {
  11386. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  11387. }
  11388. return oldValue.Cbirthday, nil
  11389. }
  11390. // ResetCbirthday resets all changes to the "cbirthday" field.
  11391. func (m *ContactMutation) ResetCbirthday() {
  11392. m.cbirthday = nil
  11393. }
  11394. // SetCbirtharea sets the "cbirtharea" field.
  11395. func (m *ContactMutation) SetCbirtharea(s string) {
  11396. m.cbirtharea = &s
  11397. }
  11398. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  11399. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  11400. v := m.cbirtharea
  11401. if v == nil {
  11402. return
  11403. }
  11404. return *v, true
  11405. }
  11406. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  11407. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11409. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  11410. if !m.op.Is(OpUpdateOne) {
  11411. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  11412. }
  11413. if m.id == nil || m.oldValue == nil {
  11414. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  11415. }
  11416. oldValue, err := m.oldValue(ctx)
  11417. if err != nil {
  11418. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  11419. }
  11420. return oldValue.Cbirtharea, nil
  11421. }
  11422. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  11423. func (m *ContactMutation) ResetCbirtharea() {
  11424. m.cbirtharea = nil
  11425. }
  11426. // SetCidcardNo sets the "cidcard_no" field.
  11427. func (m *ContactMutation) SetCidcardNo(s string) {
  11428. m.cidcard_no = &s
  11429. }
  11430. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  11431. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  11432. v := m.cidcard_no
  11433. if v == nil {
  11434. return
  11435. }
  11436. return *v, true
  11437. }
  11438. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  11439. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11441. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  11442. if !m.op.Is(OpUpdateOne) {
  11443. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  11444. }
  11445. if m.id == nil || m.oldValue == nil {
  11446. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  11447. }
  11448. oldValue, err := m.oldValue(ctx)
  11449. if err != nil {
  11450. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  11451. }
  11452. return oldValue.CidcardNo, nil
  11453. }
  11454. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  11455. func (m *ContactMutation) ResetCidcardNo() {
  11456. m.cidcard_no = nil
  11457. }
  11458. // SetCtitle sets the "ctitle" field.
  11459. func (m *ContactMutation) SetCtitle(s string) {
  11460. m.ctitle = &s
  11461. }
  11462. // Ctitle returns the value of the "ctitle" field in the mutation.
  11463. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  11464. v := m.ctitle
  11465. if v == nil {
  11466. return
  11467. }
  11468. return *v, true
  11469. }
  11470. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  11471. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11473. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  11474. if !m.op.Is(OpUpdateOne) {
  11475. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  11476. }
  11477. if m.id == nil || m.oldValue == nil {
  11478. return v, errors.New("OldCtitle requires an ID field in the mutation")
  11479. }
  11480. oldValue, err := m.oldValue(ctx)
  11481. if err != nil {
  11482. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  11483. }
  11484. return oldValue.Ctitle, nil
  11485. }
  11486. // ResetCtitle resets all changes to the "ctitle" field.
  11487. func (m *ContactMutation) ResetCtitle() {
  11488. m.ctitle = nil
  11489. }
  11490. // SetCc sets the "cc" field.
  11491. func (m *ContactMutation) SetCc(s string) {
  11492. m.cc = &s
  11493. }
  11494. // Cc returns the value of the "cc" field in the mutation.
  11495. func (m *ContactMutation) Cc() (r string, exists bool) {
  11496. v := m.cc
  11497. if v == nil {
  11498. return
  11499. }
  11500. return *v, true
  11501. }
  11502. // OldCc returns the old "cc" field's value of the Contact entity.
  11503. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11505. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  11506. if !m.op.Is(OpUpdateOne) {
  11507. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  11508. }
  11509. if m.id == nil || m.oldValue == nil {
  11510. return v, errors.New("OldCc requires an ID field in the mutation")
  11511. }
  11512. oldValue, err := m.oldValue(ctx)
  11513. if err != nil {
  11514. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  11515. }
  11516. return oldValue.Cc, nil
  11517. }
  11518. // ResetCc resets all changes to the "cc" field.
  11519. func (m *ContactMutation) ResetCc() {
  11520. m.cc = nil
  11521. }
  11522. // SetPhone sets the "phone" field.
  11523. func (m *ContactMutation) SetPhone(s string) {
  11524. m.phone = &s
  11525. }
  11526. // Phone returns the value of the "phone" field in the mutation.
  11527. func (m *ContactMutation) Phone() (r string, exists bool) {
  11528. v := m.phone
  11529. if v == nil {
  11530. return
  11531. }
  11532. return *v, true
  11533. }
  11534. // OldPhone returns the old "phone" field's value of the Contact entity.
  11535. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11537. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  11538. if !m.op.Is(OpUpdateOne) {
  11539. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  11540. }
  11541. if m.id == nil || m.oldValue == nil {
  11542. return v, errors.New("OldPhone requires an ID field in the mutation")
  11543. }
  11544. oldValue, err := m.oldValue(ctx)
  11545. if err != nil {
  11546. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  11547. }
  11548. return oldValue.Phone, nil
  11549. }
  11550. // ResetPhone resets all changes to the "phone" field.
  11551. func (m *ContactMutation) ResetPhone() {
  11552. m.phone = nil
  11553. }
  11554. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  11555. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  11556. if m.contact_relationships == nil {
  11557. m.contact_relationships = make(map[uint64]struct{})
  11558. }
  11559. for i := range ids {
  11560. m.contact_relationships[ids[i]] = struct{}{}
  11561. }
  11562. }
  11563. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  11564. func (m *ContactMutation) ClearContactRelationships() {
  11565. m.clearedcontact_relationships = true
  11566. }
  11567. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  11568. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  11569. return m.clearedcontact_relationships
  11570. }
  11571. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  11572. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  11573. if m.removedcontact_relationships == nil {
  11574. m.removedcontact_relationships = make(map[uint64]struct{})
  11575. }
  11576. for i := range ids {
  11577. delete(m.contact_relationships, ids[i])
  11578. m.removedcontact_relationships[ids[i]] = struct{}{}
  11579. }
  11580. }
  11581. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  11582. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  11583. for id := range m.removedcontact_relationships {
  11584. ids = append(ids, id)
  11585. }
  11586. return
  11587. }
  11588. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  11589. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  11590. for id := range m.contact_relationships {
  11591. ids = append(ids, id)
  11592. }
  11593. return
  11594. }
  11595. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  11596. func (m *ContactMutation) ResetContactRelationships() {
  11597. m.contact_relationships = nil
  11598. m.clearedcontact_relationships = false
  11599. m.removedcontact_relationships = nil
  11600. }
  11601. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  11602. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  11603. if m.contact_messages == nil {
  11604. m.contact_messages = make(map[uint64]struct{})
  11605. }
  11606. for i := range ids {
  11607. m.contact_messages[ids[i]] = struct{}{}
  11608. }
  11609. }
  11610. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  11611. func (m *ContactMutation) ClearContactMessages() {
  11612. m.clearedcontact_messages = true
  11613. }
  11614. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  11615. func (m *ContactMutation) ContactMessagesCleared() bool {
  11616. return m.clearedcontact_messages
  11617. }
  11618. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  11619. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  11620. if m.removedcontact_messages == nil {
  11621. m.removedcontact_messages = make(map[uint64]struct{})
  11622. }
  11623. for i := range ids {
  11624. delete(m.contact_messages, ids[i])
  11625. m.removedcontact_messages[ids[i]] = struct{}{}
  11626. }
  11627. }
  11628. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  11629. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  11630. for id := range m.removedcontact_messages {
  11631. ids = append(ids, id)
  11632. }
  11633. return
  11634. }
  11635. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  11636. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  11637. for id := range m.contact_messages {
  11638. ids = append(ids, id)
  11639. }
  11640. return
  11641. }
  11642. // ResetContactMessages resets all changes to the "contact_messages" edge.
  11643. func (m *ContactMutation) ResetContactMessages() {
  11644. m.contact_messages = nil
  11645. m.clearedcontact_messages = false
  11646. m.removedcontact_messages = nil
  11647. }
  11648. // Where appends a list predicates to the ContactMutation builder.
  11649. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  11650. m.predicates = append(m.predicates, ps...)
  11651. }
  11652. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  11653. // users can use type-assertion to append predicates that do not depend on any generated package.
  11654. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  11655. p := make([]predicate.Contact, len(ps))
  11656. for i := range ps {
  11657. p[i] = ps[i]
  11658. }
  11659. m.Where(p...)
  11660. }
  11661. // Op returns the operation name.
  11662. func (m *ContactMutation) Op() Op {
  11663. return m.op
  11664. }
  11665. // SetOp allows setting the mutation operation.
  11666. func (m *ContactMutation) SetOp(op Op) {
  11667. m.op = op
  11668. }
  11669. // Type returns the node type of this mutation (Contact).
  11670. func (m *ContactMutation) Type() string {
  11671. return m.typ
  11672. }
  11673. // Fields returns all fields that were changed during this mutation. Note that in
  11674. // order to get all numeric fields that were incremented/decremented, call
  11675. // AddedFields().
  11676. func (m *ContactMutation) Fields() []string {
  11677. fields := make([]string, 0, 30)
  11678. if m.created_at != nil {
  11679. fields = append(fields, contact.FieldCreatedAt)
  11680. }
  11681. if m.updated_at != nil {
  11682. fields = append(fields, contact.FieldUpdatedAt)
  11683. }
  11684. if m.status != nil {
  11685. fields = append(fields, contact.FieldStatus)
  11686. }
  11687. if m.deleted_at != nil {
  11688. fields = append(fields, contact.FieldDeletedAt)
  11689. }
  11690. if m.wx_wxid != nil {
  11691. fields = append(fields, contact.FieldWxWxid)
  11692. }
  11693. if m._type != nil {
  11694. fields = append(fields, contact.FieldType)
  11695. }
  11696. if m.wxid != nil {
  11697. fields = append(fields, contact.FieldWxid)
  11698. }
  11699. if m.account != nil {
  11700. fields = append(fields, contact.FieldAccount)
  11701. }
  11702. if m.nickname != nil {
  11703. fields = append(fields, contact.FieldNickname)
  11704. }
  11705. if m.markname != nil {
  11706. fields = append(fields, contact.FieldMarkname)
  11707. }
  11708. if m.headimg != nil {
  11709. fields = append(fields, contact.FieldHeadimg)
  11710. }
  11711. if m.sex != nil {
  11712. fields = append(fields, contact.FieldSex)
  11713. }
  11714. if m.starrole != nil {
  11715. fields = append(fields, contact.FieldStarrole)
  11716. }
  11717. if m.dontseeit != nil {
  11718. fields = append(fields, contact.FieldDontseeit)
  11719. }
  11720. if m.dontseeme != nil {
  11721. fields = append(fields, contact.FieldDontseeme)
  11722. }
  11723. if m.lag != nil {
  11724. fields = append(fields, contact.FieldLag)
  11725. }
  11726. if m.gid != nil {
  11727. fields = append(fields, contact.FieldGid)
  11728. }
  11729. if m.gname != nil {
  11730. fields = append(fields, contact.FieldGname)
  11731. }
  11732. if m.v3 != nil {
  11733. fields = append(fields, contact.FieldV3)
  11734. }
  11735. if m.organization_id != nil {
  11736. fields = append(fields, contact.FieldOrganizationID)
  11737. }
  11738. if m.ctype != nil {
  11739. fields = append(fields, contact.FieldCtype)
  11740. }
  11741. if m.cage != nil {
  11742. fields = append(fields, contact.FieldCage)
  11743. }
  11744. if m.cname != nil {
  11745. fields = append(fields, contact.FieldCname)
  11746. }
  11747. if m.carea != nil {
  11748. fields = append(fields, contact.FieldCarea)
  11749. }
  11750. if m.cbirthday != nil {
  11751. fields = append(fields, contact.FieldCbirthday)
  11752. }
  11753. if m.cbirtharea != nil {
  11754. fields = append(fields, contact.FieldCbirtharea)
  11755. }
  11756. if m.cidcard_no != nil {
  11757. fields = append(fields, contact.FieldCidcardNo)
  11758. }
  11759. if m.ctitle != nil {
  11760. fields = append(fields, contact.FieldCtitle)
  11761. }
  11762. if m.cc != nil {
  11763. fields = append(fields, contact.FieldCc)
  11764. }
  11765. if m.phone != nil {
  11766. fields = append(fields, contact.FieldPhone)
  11767. }
  11768. return fields
  11769. }
  11770. // Field returns the value of a field with the given name. The second boolean
  11771. // return value indicates that this field was not set, or was not defined in the
  11772. // schema.
  11773. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  11774. switch name {
  11775. case contact.FieldCreatedAt:
  11776. return m.CreatedAt()
  11777. case contact.FieldUpdatedAt:
  11778. return m.UpdatedAt()
  11779. case contact.FieldStatus:
  11780. return m.Status()
  11781. case contact.FieldDeletedAt:
  11782. return m.DeletedAt()
  11783. case contact.FieldWxWxid:
  11784. return m.WxWxid()
  11785. case contact.FieldType:
  11786. return m.GetType()
  11787. case contact.FieldWxid:
  11788. return m.Wxid()
  11789. case contact.FieldAccount:
  11790. return m.Account()
  11791. case contact.FieldNickname:
  11792. return m.Nickname()
  11793. case contact.FieldMarkname:
  11794. return m.Markname()
  11795. case contact.FieldHeadimg:
  11796. return m.Headimg()
  11797. case contact.FieldSex:
  11798. return m.Sex()
  11799. case contact.FieldStarrole:
  11800. return m.Starrole()
  11801. case contact.FieldDontseeit:
  11802. return m.Dontseeit()
  11803. case contact.FieldDontseeme:
  11804. return m.Dontseeme()
  11805. case contact.FieldLag:
  11806. return m.Lag()
  11807. case contact.FieldGid:
  11808. return m.Gid()
  11809. case contact.FieldGname:
  11810. return m.Gname()
  11811. case contact.FieldV3:
  11812. return m.V3()
  11813. case contact.FieldOrganizationID:
  11814. return m.OrganizationID()
  11815. case contact.FieldCtype:
  11816. return m.Ctype()
  11817. case contact.FieldCage:
  11818. return m.Cage()
  11819. case contact.FieldCname:
  11820. return m.Cname()
  11821. case contact.FieldCarea:
  11822. return m.Carea()
  11823. case contact.FieldCbirthday:
  11824. return m.Cbirthday()
  11825. case contact.FieldCbirtharea:
  11826. return m.Cbirtharea()
  11827. case contact.FieldCidcardNo:
  11828. return m.CidcardNo()
  11829. case contact.FieldCtitle:
  11830. return m.Ctitle()
  11831. case contact.FieldCc:
  11832. return m.Cc()
  11833. case contact.FieldPhone:
  11834. return m.Phone()
  11835. }
  11836. return nil, false
  11837. }
  11838. // OldField returns the old value of the field from the database. An error is
  11839. // returned if the mutation operation is not UpdateOne, or the query to the
  11840. // database failed.
  11841. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11842. switch name {
  11843. case contact.FieldCreatedAt:
  11844. return m.OldCreatedAt(ctx)
  11845. case contact.FieldUpdatedAt:
  11846. return m.OldUpdatedAt(ctx)
  11847. case contact.FieldStatus:
  11848. return m.OldStatus(ctx)
  11849. case contact.FieldDeletedAt:
  11850. return m.OldDeletedAt(ctx)
  11851. case contact.FieldWxWxid:
  11852. return m.OldWxWxid(ctx)
  11853. case contact.FieldType:
  11854. return m.OldType(ctx)
  11855. case contact.FieldWxid:
  11856. return m.OldWxid(ctx)
  11857. case contact.FieldAccount:
  11858. return m.OldAccount(ctx)
  11859. case contact.FieldNickname:
  11860. return m.OldNickname(ctx)
  11861. case contact.FieldMarkname:
  11862. return m.OldMarkname(ctx)
  11863. case contact.FieldHeadimg:
  11864. return m.OldHeadimg(ctx)
  11865. case contact.FieldSex:
  11866. return m.OldSex(ctx)
  11867. case contact.FieldStarrole:
  11868. return m.OldStarrole(ctx)
  11869. case contact.FieldDontseeit:
  11870. return m.OldDontseeit(ctx)
  11871. case contact.FieldDontseeme:
  11872. return m.OldDontseeme(ctx)
  11873. case contact.FieldLag:
  11874. return m.OldLag(ctx)
  11875. case contact.FieldGid:
  11876. return m.OldGid(ctx)
  11877. case contact.FieldGname:
  11878. return m.OldGname(ctx)
  11879. case contact.FieldV3:
  11880. return m.OldV3(ctx)
  11881. case contact.FieldOrganizationID:
  11882. return m.OldOrganizationID(ctx)
  11883. case contact.FieldCtype:
  11884. return m.OldCtype(ctx)
  11885. case contact.FieldCage:
  11886. return m.OldCage(ctx)
  11887. case contact.FieldCname:
  11888. return m.OldCname(ctx)
  11889. case contact.FieldCarea:
  11890. return m.OldCarea(ctx)
  11891. case contact.FieldCbirthday:
  11892. return m.OldCbirthday(ctx)
  11893. case contact.FieldCbirtharea:
  11894. return m.OldCbirtharea(ctx)
  11895. case contact.FieldCidcardNo:
  11896. return m.OldCidcardNo(ctx)
  11897. case contact.FieldCtitle:
  11898. return m.OldCtitle(ctx)
  11899. case contact.FieldCc:
  11900. return m.OldCc(ctx)
  11901. case contact.FieldPhone:
  11902. return m.OldPhone(ctx)
  11903. }
  11904. return nil, fmt.Errorf("unknown Contact field %s", name)
  11905. }
  11906. // SetField sets the value of a field with the given name. It returns an error if
  11907. // the field is not defined in the schema, or if the type mismatched the field
  11908. // type.
  11909. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  11910. switch name {
  11911. case contact.FieldCreatedAt:
  11912. v, ok := value.(time.Time)
  11913. if !ok {
  11914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11915. }
  11916. m.SetCreatedAt(v)
  11917. return nil
  11918. case contact.FieldUpdatedAt:
  11919. v, ok := value.(time.Time)
  11920. if !ok {
  11921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11922. }
  11923. m.SetUpdatedAt(v)
  11924. return nil
  11925. case contact.FieldStatus:
  11926. v, ok := value.(uint8)
  11927. if !ok {
  11928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11929. }
  11930. m.SetStatus(v)
  11931. return nil
  11932. case contact.FieldDeletedAt:
  11933. v, ok := value.(time.Time)
  11934. if !ok {
  11935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11936. }
  11937. m.SetDeletedAt(v)
  11938. return nil
  11939. case contact.FieldWxWxid:
  11940. v, ok := value.(string)
  11941. if !ok {
  11942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11943. }
  11944. m.SetWxWxid(v)
  11945. return nil
  11946. case contact.FieldType:
  11947. v, ok := value.(int)
  11948. if !ok {
  11949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11950. }
  11951. m.SetType(v)
  11952. return nil
  11953. case contact.FieldWxid:
  11954. v, ok := value.(string)
  11955. if !ok {
  11956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11957. }
  11958. m.SetWxid(v)
  11959. return nil
  11960. case contact.FieldAccount:
  11961. v, ok := value.(string)
  11962. if !ok {
  11963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11964. }
  11965. m.SetAccount(v)
  11966. return nil
  11967. case contact.FieldNickname:
  11968. v, ok := value.(string)
  11969. if !ok {
  11970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11971. }
  11972. m.SetNickname(v)
  11973. return nil
  11974. case contact.FieldMarkname:
  11975. v, ok := value.(string)
  11976. if !ok {
  11977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11978. }
  11979. m.SetMarkname(v)
  11980. return nil
  11981. case contact.FieldHeadimg:
  11982. v, ok := value.(string)
  11983. if !ok {
  11984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11985. }
  11986. m.SetHeadimg(v)
  11987. return nil
  11988. case contact.FieldSex:
  11989. v, ok := value.(int)
  11990. if !ok {
  11991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11992. }
  11993. m.SetSex(v)
  11994. return nil
  11995. case contact.FieldStarrole:
  11996. v, ok := value.(string)
  11997. if !ok {
  11998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11999. }
  12000. m.SetStarrole(v)
  12001. return nil
  12002. case contact.FieldDontseeit:
  12003. v, ok := value.(int)
  12004. if !ok {
  12005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12006. }
  12007. m.SetDontseeit(v)
  12008. return nil
  12009. case contact.FieldDontseeme:
  12010. v, ok := value.(int)
  12011. if !ok {
  12012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12013. }
  12014. m.SetDontseeme(v)
  12015. return nil
  12016. case contact.FieldLag:
  12017. v, ok := value.(string)
  12018. if !ok {
  12019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12020. }
  12021. m.SetLag(v)
  12022. return nil
  12023. case contact.FieldGid:
  12024. v, ok := value.(string)
  12025. if !ok {
  12026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12027. }
  12028. m.SetGid(v)
  12029. return nil
  12030. case contact.FieldGname:
  12031. v, ok := value.(string)
  12032. if !ok {
  12033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12034. }
  12035. m.SetGname(v)
  12036. return nil
  12037. case contact.FieldV3:
  12038. v, ok := value.(string)
  12039. if !ok {
  12040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12041. }
  12042. m.SetV3(v)
  12043. return nil
  12044. case contact.FieldOrganizationID:
  12045. v, ok := value.(uint64)
  12046. if !ok {
  12047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12048. }
  12049. m.SetOrganizationID(v)
  12050. return nil
  12051. case contact.FieldCtype:
  12052. v, ok := value.(uint64)
  12053. if !ok {
  12054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12055. }
  12056. m.SetCtype(v)
  12057. return nil
  12058. case contact.FieldCage:
  12059. v, ok := value.(int)
  12060. if !ok {
  12061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12062. }
  12063. m.SetCage(v)
  12064. return nil
  12065. case contact.FieldCname:
  12066. v, ok := value.(string)
  12067. if !ok {
  12068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12069. }
  12070. m.SetCname(v)
  12071. return nil
  12072. case contact.FieldCarea:
  12073. v, ok := value.(string)
  12074. if !ok {
  12075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12076. }
  12077. m.SetCarea(v)
  12078. return nil
  12079. case contact.FieldCbirthday:
  12080. v, ok := value.(string)
  12081. if !ok {
  12082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12083. }
  12084. m.SetCbirthday(v)
  12085. return nil
  12086. case contact.FieldCbirtharea:
  12087. v, ok := value.(string)
  12088. if !ok {
  12089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12090. }
  12091. m.SetCbirtharea(v)
  12092. return nil
  12093. case contact.FieldCidcardNo:
  12094. v, ok := value.(string)
  12095. if !ok {
  12096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12097. }
  12098. m.SetCidcardNo(v)
  12099. return nil
  12100. case contact.FieldCtitle:
  12101. v, ok := value.(string)
  12102. if !ok {
  12103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12104. }
  12105. m.SetCtitle(v)
  12106. return nil
  12107. case contact.FieldCc:
  12108. v, ok := value.(string)
  12109. if !ok {
  12110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12111. }
  12112. m.SetCc(v)
  12113. return nil
  12114. case contact.FieldPhone:
  12115. v, ok := value.(string)
  12116. if !ok {
  12117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12118. }
  12119. m.SetPhone(v)
  12120. return nil
  12121. }
  12122. return fmt.Errorf("unknown Contact field %s", name)
  12123. }
  12124. // AddedFields returns all numeric fields that were incremented/decremented during
  12125. // this mutation.
  12126. func (m *ContactMutation) AddedFields() []string {
  12127. var fields []string
  12128. if m.addstatus != nil {
  12129. fields = append(fields, contact.FieldStatus)
  12130. }
  12131. if m.add_type != nil {
  12132. fields = append(fields, contact.FieldType)
  12133. }
  12134. if m.addsex != nil {
  12135. fields = append(fields, contact.FieldSex)
  12136. }
  12137. if m.adddontseeit != nil {
  12138. fields = append(fields, contact.FieldDontseeit)
  12139. }
  12140. if m.adddontseeme != nil {
  12141. fields = append(fields, contact.FieldDontseeme)
  12142. }
  12143. if m.addorganization_id != nil {
  12144. fields = append(fields, contact.FieldOrganizationID)
  12145. }
  12146. if m.addctype != nil {
  12147. fields = append(fields, contact.FieldCtype)
  12148. }
  12149. if m.addcage != nil {
  12150. fields = append(fields, contact.FieldCage)
  12151. }
  12152. return fields
  12153. }
  12154. // AddedField returns the numeric value that was incremented/decremented on a field
  12155. // with the given name. The second boolean return value indicates that this field
  12156. // was not set, or was not defined in the schema.
  12157. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  12158. switch name {
  12159. case contact.FieldStatus:
  12160. return m.AddedStatus()
  12161. case contact.FieldType:
  12162. return m.AddedType()
  12163. case contact.FieldSex:
  12164. return m.AddedSex()
  12165. case contact.FieldDontseeit:
  12166. return m.AddedDontseeit()
  12167. case contact.FieldDontseeme:
  12168. return m.AddedDontseeme()
  12169. case contact.FieldOrganizationID:
  12170. return m.AddedOrganizationID()
  12171. case contact.FieldCtype:
  12172. return m.AddedCtype()
  12173. case contact.FieldCage:
  12174. return m.AddedCage()
  12175. }
  12176. return nil, false
  12177. }
  12178. // AddField adds the value to the field with the given name. It returns an error if
  12179. // the field is not defined in the schema, or if the type mismatched the field
  12180. // type.
  12181. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  12182. switch name {
  12183. case contact.FieldStatus:
  12184. v, ok := value.(int8)
  12185. if !ok {
  12186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12187. }
  12188. m.AddStatus(v)
  12189. return nil
  12190. case contact.FieldType:
  12191. v, ok := value.(int)
  12192. if !ok {
  12193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12194. }
  12195. m.AddType(v)
  12196. return nil
  12197. case contact.FieldSex:
  12198. v, ok := value.(int)
  12199. if !ok {
  12200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12201. }
  12202. m.AddSex(v)
  12203. return nil
  12204. case contact.FieldDontseeit:
  12205. v, ok := value.(int)
  12206. if !ok {
  12207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12208. }
  12209. m.AddDontseeit(v)
  12210. return nil
  12211. case contact.FieldDontseeme:
  12212. v, ok := value.(int)
  12213. if !ok {
  12214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12215. }
  12216. m.AddDontseeme(v)
  12217. return nil
  12218. case contact.FieldOrganizationID:
  12219. v, ok := value.(int64)
  12220. if !ok {
  12221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12222. }
  12223. m.AddOrganizationID(v)
  12224. return nil
  12225. case contact.FieldCtype:
  12226. v, ok := value.(int64)
  12227. if !ok {
  12228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12229. }
  12230. m.AddCtype(v)
  12231. return nil
  12232. case contact.FieldCage:
  12233. v, ok := value.(int)
  12234. if !ok {
  12235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12236. }
  12237. m.AddCage(v)
  12238. return nil
  12239. }
  12240. return fmt.Errorf("unknown Contact numeric field %s", name)
  12241. }
  12242. // ClearedFields returns all nullable fields that were cleared during this
  12243. // mutation.
  12244. func (m *ContactMutation) ClearedFields() []string {
  12245. var fields []string
  12246. if m.FieldCleared(contact.FieldStatus) {
  12247. fields = append(fields, contact.FieldStatus)
  12248. }
  12249. if m.FieldCleared(contact.FieldDeletedAt) {
  12250. fields = append(fields, contact.FieldDeletedAt)
  12251. }
  12252. if m.FieldCleared(contact.FieldType) {
  12253. fields = append(fields, contact.FieldType)
  12254. }
  12255. if m.FieldCleared(contact.FieldOrganizationID) {
  12256. fields = append(fields, contact.FieldOrganizationID)
  12257. }
  12258. return fields
  12259. }
  12260. // FieldCleared returns a boolean indicating if a field with the given name was
  12261. // cleared in this mutation.
  12262. func (m *ContactMutation) FieldCleared(name string) bool {
  12263. _, ok := m.clearedFields[name]
  12264. return ok
  12265. }
  12266. // ClearField clears the value of the field with the given name. It returns an
  12267. // error if the field is not defined in the schema.
  12268. func (m *ContactMutation) ClearField(name string) error {
  12269. switch name {
  12270. case contact.FieldStatus:
  12271. m.ClearStatus()
  12272. return nil
  12273. case contact.FieldDeletedAt:
  12274. m.ClearDeletedAt()
  12275. return nil
  12276. case contact.FieldType:
  12277. m.ClearType()
  12278. return nil
  12279. case contact.FieldOrganizationID:
  12280. m.ClearOrganizationID()
  12281. return nil
  12282. }
  12283. return fmt.Errorf("unknown Contact nullable field %s", name)
  12284. }
  12285. // ResetField resets all changes in the mutation for the field with the given name.
  12286. // It returns an error if the field is not defined in the schema.
  12287. func (m *ContactMutation) ResetField(name string) error {
  12288. switch name {
  12289. case contact.FieldCreatedAt:
  12290. m.ResetCreatedAt()
  12291. return nil
  12292. case contact.FieldUpdatedAt:
  12293. m.ResetUpdatedAt()
  12294. return nil
  12295. case contact.FieldStatus:
  12296. m.ResetStatus()
  12297. return nil
  12298. case contact.FieldDeletedAt:
  12299. m.ResetDeletedAt()
  12300. return nil
  12301. case contact.FieldWxWxid:
  12302. m.ResetWxWxid()
  12303. return nil
  12304. case contact.FieldType:
  12305. m.ResetType()
  12306. return nil
  12307. case contact.FieldWxid:
  12308. m.ResetWxid()
  12309. return nil
  12310. case contact.FieldAccount:
  12311. m.ResetAccount()
  12312. return nil
  12313. case contact.FieldNickname:
  12314. m.ResetNickname()
  12315. return nil
  12316. case contact.FieldMarkname:
  12317. m.ResetMarkname()
  12318. return nil
  12319. case contact.FieldHeadimg:
  12320. m.ResetHeadimg()
  12321. return nil
  12322. case contact.FieldSex:
  12323. m.ResetSex()
  12324. return nil
  12325. case contact.FieldStarrole:
  12326. m.ResetStarrole()
  12327. return nil
  12328. case contact.FieldDontseeit:
  12329. m.ResetDontseeit()
  12330. return nil
  12331. case contact.FieldDontseeme:
  12332. m.ResetDontseeme()
  12333. return nil
  12334. case contact.FieldLag:
  12335. m.ResetLag()
  12336. return nil
  12337. case contact.FieldGid:
  12338. m.ResetGid()
  12339. return nil
  12340. case contact.FieldGname:
  12341. m.ResetGname()
  12342. return nil
  12343. case contact.FieldV3:
  12344. m.ResetV3()
  12345. return nil
  12346. case contact.FieldOrganizationID:
  12347. m.ResetOrganizationID()
  12348. return nil
  12349. case contact.FieldCtype:
  12350. m.ResetCtype()
  12351. return nil
  12352. case contact.FieldCage:
  12353. m.ResetCage()
  12354. return nil
  12355. case contact.FieldCname:
  12356. m.ResetCname()
  12357. return nil
  12358. case contact.FieldCarea:
  12359. m.ResetCarea()
  12360. return nil
  12361. case contact.FieldCbirthday:
  12362. m.ResetCbirthday()
  12363. return nil
  12364. case contact.FieldCbirtharea:
  12365. m.ResetCbirtharea()
  12366. return nil
  12367. case contact.FieldCidcardNo:
  12368. m.ResetCidcardNo()
  12369. return nil
  12370. case contact.FieldCtitle:
  12371. m.ResetCtitle()
  12372. return nil
  12373. case contact.FieldCc:
  12374. m.ResetCc()
  12375. return nil
  12376. case contact.FieldPhone:
  12377. m.ResetPhone()
  12378. return nil
  12379. }
  12380. return fmt.Errorf("unknown Contact field %s", name)
  12381. }
  12382. // AddedEdges returns all edge names that were set/added in this mutation.
  12383. func (m *ContactMutation) AddedEdges() []string {
  12384. edges := make([]string, 0, 2)
  12385. if m.contact_relationships != nil {
  12386. edges = append(edges, contact.EdgeContactRelationships)
  12387. }
  12388. if m.contact_messages != nil {
  12389. edges = append(edges, contact.EdgeContactMessages)
  12390. }
  12391. return edges
  12392. }
  12393. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12394. // name in this mutation.
  12395. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  12396. switch name {
  12397. case contact.EdgeContactRelationships:
  12398. ids := make([]ent.Value, 0, len(m.contact_relationships))
  12399. for id := range m.contact_relationships {
  12400. ids = append(ids, id)
  12401. }
  12402. return ids
  12403. case contact.EdgeContactMessages:
  12404. ids := make([]ent.Value, 0, len(m.contact_messages))
  12405. for id := range m.contact_messages {
  12406. ids = append(ids, id)
  12407. }
  12408. return ids
  12409. }
  12410. return nil
  12411. }
  12412. // RemovedEdges returns all edge names that were removed in this mutation.
  12413. func (m *ContactMutation) RemovedEdges() []string {
  12414. edges := make([]string, 0, 2)
  12415. if m.removedcontact_relationships != nil {
  12416. edges = append(edges, contact.EdgeContactRelationships)
  12417. }
  12418. if m.removedcontact_messages != nil {
  12419. edges = append(edges, contact.EdgeContactMessages)
  12420. }
  12421. return edges
  12422. }
  12423. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12424. // the given name in this mutation.
  12425. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  12426. switch name {
  12427. case contact.EdgeContactRelationships:
  12428. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  12429. for id := range m.removedcontact_relationships {
  12430. ids = append(ids, id)
  12431. }
  12432. return ids
  12433. case contact.EdgeContactMessages:
  12434. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  12435. for id := range m.removedcontact_messages {
  12436. ids = append(ids, id)
  12437. }
  12438. return ids
  12439. }
  12440. return nil
  12441. }
  12442. // ClearedEdges returns all edge names that were cleared in this mutation.
  12443. func (m *ContactMutation) ClearedEdges() []string {
  12444. edges := make([]string, 0, 2)
  12445. if m.clearedcontact_relationships {
  12446. edges = append(edges, contact.EdgeContactRelationships)
  12447. }
  12448. if m.clearedcontact_messages {
  12449. edges = append(edges, contact.EdgeContactMessages)
  12450. }
  12451. return edges
  12452. }
  12453. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12454. // was cleared in this mutation.
  12455. func (m *ContactMutation) EdgeCleared(name string) bool {
  12456. switch name {
  12457. case contact.EdgeContactRelationships:
  12458. return m.clearedcontact_relationships
  12459. case contact.EdgeContactMessages:
  12460. return m.clearedcontact_messages
  12461. }
  12462. return false
  12463. }
  12464. // ClearEdge clears the value of the edge with the given name. It returns an error
  12465. // if that edge is not defined in the schema.
  12466. func (m *ContactMutation) ClearEdge(name string) error {
  12467. switch name {
  12468. }
  12469. return fmt.Errorf("unknown Contact unique edge %s", name)
  12470. }
  12471. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12472. // It returns an error if the edge is not defined in the schema.
  12473. func (m *ContactMutation) ResetEdge(name string) error {
  12474. switch name {
  12475. case contact.EdgeContactRelationships:
  12476. m.ResetContactRelationships()
  12477. return nil
  12478. case contact.EdgeContactMessages:
  12479. m.ResetContactMessages()
  12480. return nil
  12481. }
  12482. return fmt.Errorf("unknown Contact edge %s", name)
  12483. }
  12484. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  12485. type CreditBalanceMutation struct {
  12486. config
  12487. op Op
  12488. typ string
  12489. id *uint64
  12490. created_at *time.Time
  12491. updated_at *time.Time
  12492. deleted_at *time.Time
  12493. user_id *string
  12494. balance *float32
  12495. addbalance *float32
  12496. status *int
  12497. addstatus *int
  12498. organization_id *uint64
  12499. addorganization_id *int64
  12500. clearedFields map[string]struct{}
  12501. done bool
  12502. oldValue func(context.Context) (*CreditBalance, error)
  12503. predicates []predicate.CreditBalance
  12504. }
  12505. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  12506. // creditbalanceOption allows management of the mutation configuration using functional options.
  12507. type creditbalanceOption func(*CreditBalanceMutation)
  12508. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  12509. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  12510. m := &CreditBalanceMutation{
  12511. config: c,
  12512. op: op,
  12513. typ: TypeCreditBalance,
  12514. clearedFields: make(map[string]struct{}),
  12515. }
  12516. for _, opt := range opts {
  12517. opt(m)
  12518. }
  12519. return m
  12520. }
  12521. // withCreditBalanceID sets the ID field of the mutation.
  12522. func withCreditBalanceID(id uint64) creditbalanceOption {
  12523. return func(m *CreditBalanceMutation) {
  12524. var (
  12525. err error
  12526. once sync.Once
  12527. value *CreditBalance
  12528. )
  12529. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  12530. once.Do(func() {
  12531. if m.done {
  12532. err = errors.New("querying old values post mutation is not allowed")
  12533. } else {
  12534. value, err = m.Client().CreditBalance.Get(ctx, id)
  12535. }
  12536. })
  12537. return value, err
  12538. }
  12539. m.id = &id
  12540. }
  12541. }
  12542. // withCreditBalance sets the old CreditBalance of the mutation.
  12543. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  12544. return func(m *CreditBalanceMutation) {
  12545. m.oldValue = func(context.Context) (*CreditBalance, error) {
  12546. return node, nil
  12547. }
  12548. m.id = &node.ID
  12549. }
  12550. }
  12551. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12552. // executed in a transaction (ent.Tx), a transactional client is returned.
  12553. func (m CreditBalanceMutation) Client() *Client {
  12554. client := &Client{config: m.config}
  12555. client.init()
  12556. return client
  12557. }
  12558. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12559. // it returns an error otherwise.
  12560. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  12561. if _, ok := m.driver.(*txDriver); !ok {
  12562. return nil, errors.New("ent: mutation is not running in a transaction")
  12563. }
  12564. tx := &Tx{config: m.config}
  12565. tx.init()
  12566. return tx, nil
  12567. }
  12568. // SetID sets the value of the id field. Note that this
  12569. // operation is only accepted on creation of CreditBalance entities.
  12570. func (m *CreditBalanceMutation) SetID(id uint64) {
  12571. m.id = &id
  12572. }
  12573. // ID returns the ID value in the mutation. Note that the ID is only available
  12574. // if it was provided to the builder or after it was returned from the database.
  12575. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  12576. if m.id == nil {
  12577. return
  12578. }
  12579. return *m.id, true
  12580. }
  12581. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12582. // That means, if the mutation is applied within a transaction with an isolation level such
  12583. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12584. // or updated by the mutation.
  12585. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  12586. switch {
  12587. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12588. id, exists := m.ID()
  12589. if exists {
  12590. return []uint64{id}, nil
  12591. }
  12592. fallthrough
  12593. case m.op.Is(OpUpdate | OpDelete):
  12594. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  12595. default:
  12596. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12597. }
  12598. }
  12599. // SetCreatedAt sets the "created_at" field.
  12600. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  12601. m.created_at = &t
  12602. }
  12603. // CreatedAt returns the value of the "created_at" field in the mutation.
  12604. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  12605. v := m.created_at
  12606. if v == nil {
  12607. return
  12608. }
  12609. return *v, true
  12610. }
  12611. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  12612. // If the CreditBalance 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 *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12615. if !m.op.Is(OpUpdateOne) {
  12616. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12617. }
  12618. if m.id == nil || m.oldValue == nil {
  12619. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  12624. }
  12625. return oldValue.CreatedAt, nil
  12626. }
  12627. // ResetCreatedAt resets all changes to the "created_at" field.
  12628. func (m *CreditBalanceMutation) ResetCreatedAt() {
  12629. m.created_at = nil
  12630. }
  12631. // SetUpdatedAt sets the "updated_at" field.
  12632. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  12633. m.updated_at = &t
  12634. }
  12635. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12636. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  12637. v := m.updated_at
  12638. if v == nil {
  12639. return
  12640. }
  12641. return *v, true
  12642. }
  12643. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  12644. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12646. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12647. if !m.op.Is(OpUpdateOne) {
  12648. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12649. }
  12650. if m.id == nil || m.oldValue == nil {
  12651. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12652. }
  12653. oldValue, err := m.oldValue(ctx)
  12654. if err != nil {
  12655. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12656. }
  12657. return oldValue.UpdatedAt, nil
  12658. }
  12659. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12660. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  12661. m.updated_at = nil
  12662. }
  12663. // SetDeletedAt sets the "deleted_at" field.
  12664. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  12665. m.deleted_at = &t
  12666. }
  12667. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12668. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  12669. v := m.deleted_at
  12670. if v == nil {
  12671. return
  12672. }
  12673. return *v, true
  12674. }
  12675. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  12676. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12678. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12679. if !m.op.Is(OpUpdateOne) {
  12680. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12681. }
  12682. if m.id == nil || m.oldValue == nil {
  12683. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12684. }
  12685. oldValue, err := m.oldValue(ctx)
  12686. if err != nil {
  12687. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12688. }
  12689. return oldValue.DeletedAt, nil
  12690. }
  12691. // ClearDeletedAt clears the value of the "deleted_at" field.
  12692. func (m *CreditBalanceMutation) ClearDeletedAt() {
  12693. m.deleted_at = nil
  12694. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  12695. }
  12696. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12697. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  12698. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  12699. return ok
  12700. }
  12701. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12702. func (m *CreditBalanceMutation) ResetDeletedAt() {
  12703. m.deleted_at = nil
  12704. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  12705. }
  12706. // SetUserID sets the "user_id" field.
  12707. func (m *CreditBalanceMutation) SetUserID(s string) {
  12708. m.user_id = &s
  12709. }
  12710. // UserID returns the value of the "user_id" field in the mutation.
  12711. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  12712. v := m.user_id
  12713. if v == nil {
  12714. return
  12715. }
  12716. return *v, true
  12717. }
  12718. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  12719. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12721. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  12722. if !m.op.Is(OpUpdateOne) {
  12723. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  12724. }
  12725. if m.id == nil || m.oldValue == nil {
  12726. return v, errors.New("OldUserID requires an ID field in the mutation")
  12727. }
  12728. oldValue, err := m.oldValue(ctx)
  12729. if err != nil {
  12730. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  12731. }
  12732. return oldValue.UserID, nil
  12733. }
  12734. // ClearUserID clears the value of the "user_id" field.
  12735. func (m *CreditBalanceMutation) ClearUserID() {
  12736. m.user_id = nil
  12737. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  12738. }
  12739. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  12740. func (m *CreditBalanceMutation) UserIDCleared() bool {
  12741. _, ok := m.clearedFields[creditbalance.FieldUserID]
  12742. return ok
  12743. }
  12744. // ResetUserID resets all changes to the "user_id" field.
  12745. func (m *CreditBalanceMutation) ResetUserID() {
  12746. m.user_id = nil
  12747. delete(m.clearedFields, creditbalance.FieldUserID)
  12748. }
  12749. // SetBalance sets the "balance" field.
  12750. func (m *CreditBalanceMutation) SetBalance(f float32) {
  12751. m.balance = &f
  12752. m.addbalance = nil
  12753. }
  12754. // Balance returns the value of the "balance" field in the mutation.
  12755. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  12756. v := m.balance
  12757. if v == nil {
  12758. return
  12759. }
  12760. return *v, true
  12761. }
  12762. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  12763. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12765. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  12766. if !m.op.Is(OpUpdateOne) {
  12767. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  12768. }
  12769. if m.id == nil || m.oldValue == nil {
  12770. return v, errors.New("OldBalance requires an ID field in the mutation")
  12771. }
  12772. oldValue, err := m.oldValue(ctx)
  12773. if err != nil {
  12774. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  12775. }
  12776. return oldValue.Balance, nil
  12777. }
  12778. // AddBalance adds f to the "balance" field.
  12779. func (m *CreditBalanceMutation) AddBalance(f float32) {
  12780. if m.addbalance != nil {
  12781. *m.addbalance += f
  12782. } else {
  12783. m.addbalance = &f
  12784. }
  12785. }
  12786. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  12787. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  12788. v := m.addbalance
  12789. if v == nil {
  12790. return
  12791. }
  12792. return *v, true
  12793. }
  12794. // ResetBalance resets all changes to the "balance" field.
  12795. func (m *CreditBalanceMutation) ResetBalance() {
  12796. m.balance = nil
  12797. m.addbalance = nil
  12798. }
  12799. // SetStatus sets the "status" field.
  12800. func (m *CreditBalanceMutation) SetStatus(i int) {
  12801. m.status = &i
  12802. m.addstatus = nil
  12803. }
  12804. // Status returns the value of the "status" field in the mutation.
  12805. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  12806. v := m.status
  12807. if v == nil {
  12808. return
  12809. }
  12810. return *v, true
  12811. }
  12812. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  12813. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12815. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  12816. if !m.op.Is(OpUpdateOne) {
  12817. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12818. }
  12819. if m.id == nil || m.oldValue == nil {
  12820. return v, errors.New("OldStatus requires an ID field in the mutation")
  12821. }
  12822. oldValue, err := m.oldValue(ctx)
  12823. if err != nil {
  12824. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12825. }
  12826. return oldValue.Status, nil
  12827. }
  12828. // AddStatus adds i to the "status" field.
  12829. func (m *CreditBalanceMutation) AddStatus(i int) {
  12830. if m.addstatus != nil {
  12831. *m.addstatus += i
  12832. } else {
  12833. m.addstatus = &i
  12834. }
  12835. }
  12836. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12837. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  12838. v := m.addstatus
  12839. if v == nil {
  12840. return
  12841. }
  12842. return *v, true
  12843. }
  12844. // ClearStatus clears the value of the "status" field.
  12845. func (m *CreditBalanceMutation) ClearStatus() {
  12846. m.status = nil
  12847. m.addstatus = nil
  12848. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  12849. }
  12850. // StatusCleared returns if the "status" field was cleared in this mutation.
  12851. func (m *CreditBalanceMutation) StatusCleared() bool {
  12852. _, ok := m.clearedFields[creditbalance.FieldStatus]
  12853. return ok
  12854. }
  12855. // ResetStatus resets all changes to the "status" field.
  12856. func (m *CreditBalanceMutation) ResetStatus() {
  12857. m.status = nil
  12858. m.addstatus = nil
  12859. delete(m.clearedFields, creditbalance.FieldStatus)
  12860. }
  12861. // SetOrganizationID sets the "organization_id" field.
  12862. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  12863. m.organization_id = &u
  12864. m.addorganization_id = nil
  12865. }
  12866. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12867. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  12868. v := m.organization_id
  12869. if v == nil {
  12870. return
  12871. }
  12872. return *v, true
  12873. }
  12874. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  12875. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12877. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12878. if !m.op.Is(OpUpdateOne) {
  12879. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12880. }
  12881. if m.id == nil || m.oldValue == nil {
  12882. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12883. }
  12884. oldValue, err := m.oldValue(ctx)
  12885. if err != nil {
  12886. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12887. }
  12888. return oldValue.OrganizationID, nil
  12889. }
  12890. // AddOrganizationID adds u to the "organization_id" field.
  12891. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  12892. if m.addorganization_id != nil {
  12893. *m.addorganization_id += u
  12894. } else {
  12895. m.addorganization_id = &u
  12896. }
  12897. }
  12898. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12899. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  12900. v := m.addorganization_id
  12901. if v == nil {
  12902. return
  12903. }
  12904. return *v, true
  12905. }
  12906. // ClearOrganizationID clears the value of the "organization_id" field.
  12907. func (m *CreditBalanceMutation) ClearOrganizationID() {
  12908. m.organization_id = nil
  12909. m.addorganization_id = nil
  12910. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  12911. }
  12912. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12913. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  12914. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  12915. return ok
  12916. }
  12917. // ResetOrganizationID resets all changes to the "organization_id" field.
  12918. func (m *CreditBalanceMutation) ResetOrganizationID() {
  12919. m.organization_id = nil
  12920. m.addorganization_id = nil
  12921. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  12922. }
  12923. // Where appends a list predicates to the CreditBalanceMutation builder.
  12924. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  12925. m.predicates = append(m.predicates, ps...)
  12926. }
  12927. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  12928. // users can use type-assertion to append predicates that do not depend on any generated package.
  12929. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  12930. p := make([]predicate.CreditBalance, len(ps))
  12931. for i := range ps {
  12932. p[i] = ps[i]
  12933. }
  12934. m.Where(p...)
  12935. }
  12936. // Op returns the operation name.
  12937. func (m *CreditBalanceMutation) Op() Op {
  12938. return m.op
  12939. }
  12940. // SetOp allows setting the mutation operation.
  12941. func (m *CreditBalanceMutation) SetOp(op Op) {
  12942. m.op = op
  12943. }
  12944. // Type returns the node type of this mutation (CreditBalance).
  12945. func (m *CreditBalanceMutation) Type() string {
  12946. return m.typ
  12947. }
  12948. // Fields returns all fields that were changed during this mutation. Note that in
  12949. // order to get all numeric fields that were incremented/decremented, call
  12950. // AddedFields().
  12951. func (m *CreditBalanceMutation) Fields() []string {
  12952. fields := make([]string, 0, 7)
  12953. if m.created_at != nil {
  12954. fields = append(fields, creditbalance.FieldCreatedAt)
  12955. }
  12956. if m.updated_at != nil {
  12957. fields = append(fields, creditbalance.FieldUpdatedAt)
  12958. }
  12959. if m.deleted_at != nil {
  12960. fields = append(fields, creditbalance.FieldDeletedAt)
  12961. }
  12962. if m.user_id != nil {
  12963. fields = append(fields, creditbalance.FieldUserID)
  12964. }
  12965. if m.balance != nil {
  12966. fields = append(fields, creditbalance.FieldBalance)
  12967. }
  12968. if m.status != nil {
  12969. fields = append(fields, creditbalance.FieldStatus)
  12970. }
  12971. if m.organization_id != nil {
  12972. fields = append(fields, creditbalance.FieldOrganizationID)
  12973. }
  12974. return fields
  12975. }
  12976. // Field returns the value of a field with the given name. The second boolean
  12977. // return value indicates that this field was not set, or was not defined in the
  12978. // schema.
  12979. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  12980. switch name {
  12981. case creditbalance.FieldCreatedAt:
  12982. return m.CreatedAt()
  12983. case creditbalance.FieldUpdatedAt:
  12984. return m.UpdatedAt()
  12985. case creditbalance.FieldDeletedAt:
  12986. return m.DeletedAt()
  12987. case creditbalance.FieldUserID:
  12988. return m.UserID()
  12989. case creditbalance.FieldBalance:
  12990. return m.Balance()
  12991. case creditbalance.FieldStatus:
  12992. return m.Status()
  12993. case creditbalance.FieldOrganizationID:
  12994. return m.OrganizationID()
  12995. }
  12996. return nil, false
  12997. }
  12998. // OldField returns the old value of the field from the database. An error is
  12999. // returned if the mutation operation is not UpdateOne, or the query to the
  13000. // database failed.
  13001. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13002. switch name {
  13003. case creditbalance.FieldCreatedAt:
  13004. return m.OldCreatedAt(ctx)
  13005. case creditbalance.FieldUpdatedAt:
  13006. return m.OldUpdatedAt(ctx)
  13007. case creditbalance.FieldDeletedAt:
  13008. return m.OldDeletedAt(ctx)
  13009. case creditbalance.FieldUserID:
  13010. return m.OldUserID(ctx)
  13011. case creditbalance.FieldBalance:
  13012. return m.OldBalance(ctx)
  13013. case creditbalance.FieldStatus:
  13014. return m.OldStatus(ctx)
  13015. case creditbalance.FieldOrganizationID:
  13016. return m.OldOrganizationID(ctx)
  13017. }
  13018. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  13019. }
  13020. // SetField sets the value of a field with the given name. It returns an error if
  13021. // the field is not defined in the schema, or if the type mismatched the field
  13022. // type.
  13023. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  13024. switch name {
  13025. case creditbalance.FieldCreatedAt:
  13026. v, ok := value.(time.Time)
  13027. if !ok {
  13028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13029. }
  13030. m.SetCreatedAt(v)
  13031. return nil
  13032. case creditbalance.FieldUpdatedAt:
  13033. v, ok := value.(time.Time)
  13034. if !ok {
  13035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13036. }
  13037. m.SetUpdatedAt(v)
  13038. return nil
  13039. case creditbalance.FieldDeletedAt:
  13040. v, ok := value.(time.Time)
  13041. if !ok {
  13042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13043. }
  13044. m.SetDeletedAt(v)
  13045. return nil
  13046. case creditbalance.FieldUserID:
  13047. v, ok := value.(string)
  13048. if !ok {
  13049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13050. }
  13051. m.SetUserID(v)
  13052. return nil
  13053. case creditbalance.FieldBalance:
  13054. v, ok := value.(float32)
  13055. if !ok {
  13056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13057. }
  13058. m.SetBalance(v)
  13059. return nil
  13060. case creditbalance.FieldStatus:
  13061. v, ok := value.(int)
  13062. if !ok {
  13063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13064. }
  13065. m.SetStatus(v)
  13066. return nil
  13067. case creditbalance.FieldOrganizationID:
  13068. v, ok := value.(uint64)
  13069. if !ok {
  13070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13071. }
  13072. m.SetOrganizationID(v)
  13073. return nil
  13074. }
  13075. return fmt.Errorf("unknown CreditBalance field %s", name)
  13076. }
  13077. // AddedFields returns all numeric fields that were incremented/decremented during
  13078. // this mutation.
  13079. func (m *CreditBalanceMutation) AddedFields() []string {
  13080. var fields []string
  13081. if m.addbalance != nil {
  13082. fields = append(fields, creditbalance.FieldBalance)
  13083. }
  13084. if m.addstatus != nil {
  13085. fields = append(fields, creditbalance.FieldStatus)
  13086. }
  13087. if m.addorganization_id != nil {
  13088. fields = append(fields, creditbalance.FieldOrganizationID)
  13089. }
  13090. return fields
  13091. }
  13092. // AddedField returns the numeric value that was incremented/decremented on a field
  13093. // with the given name. The second boolean return value indicates that this field
  13094. // was not set, or was not defined in the schema.
  13095. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  13096. switch name {
  13097. case creditbalance.FieldBalance:
  13098. return m.AddedBalance()
  13099. case creditbalance.FieldStatus:
  13100. return m.AddedStatus()
  13101. case creditbalance.FieldOrganizationID:
  13102. return m.AddedOrganizationID()
  13103. }
  13104. return nil, false
  13105. }
  13106. // AddField adds the value to the field with the given name. It returns an error if
  13107. // the field is not defined in the schema, or if the type mismatched the field
  13108. // type.
  13109. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  13110. switch name {
  13111. case creditbalance.FieldBalance:
  13112. v, ok := value.(float32)
  13113. if !ok {
  13114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13115. }
  13116. m.AddBalance(v)
  13117. return nil
  13118. case creditbalance.FieldStatus:
  13119. v, ok := value.(int)
  13120. if !ok {
  13121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13122. }
  13123. m.AddStatus(v)
  13124. return nil
  13125. case creditbalance.FieldOrganizationID:
  13126. v, ok := value.(int64)
  13127. if !ok {
  13128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13129. }
  13130. m.AddOrganizationID(v)
  13131. return nil
  13132. }
  13133. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  13134. }
  13135. // ClearedFields returns all nullable fields that were cleared during this
  13136. // mutation.
  13137. func (m *CreditBalanceMutation) ClearedFields() []string {
  13138. var fields []string
  13139. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  13140. fields = append(fields, creditbalance.FieldDeletedAt)
  13141. }
  13142. if m.FieldCleared(creditbalance.FieldUserID) {
  13143. fields = append(fields, creditbalance.FieldUserID)
  13144. }
  13145. if m.FieldCleared(creditbalance.FieldStatus) {
  13146. fields = append(fields, creditbalance.FieldStatus)
  13147. }
  13148. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  13149. fields = append(fields, creditbalance.FieldOrganizationID)
  13150. }
  13151. return fields
  13152. }
  13153. // FieldCleared returns a boolean indicating if a field with the given name was
  13154. // cleared in this mutation.
  13155. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  13156. _, ok := m.clearedFields[name]
  13157. return ok
  13158. }
  13159. // ClearField clears the value of the field with the given name. It returns an
  13160. // error if the field is not defined in the schema.
  13161. func (m *CreditBalanceMutation) ClearField(name string) error {
  13162. switch name {
  13163. case creditbalance.FieldDeletedAt:
  13164. m.ClearDeletedAt()
  13165. return nil
  13166. case creditbalance.FieldUserID:
  13167. m.ClearUserID()
  13168. return nil
  13169. case creditbalance.FieldStatus:
  13170. m.ClearStatus()
  13171. return nil
  13172. case creditbalance.FieldOrganizationID:
  13173. m.ClearOrganizationID()
  13174. return nil
  13175. }
  13176. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  13177. }
  13178. // ResetField resets all changes in the mutation for the field with the given name.
  13179. // It returns an error if the field is not defined in the schema.
  13180. func (m *CreditBalanceMutation) ResetField(name string) error {
  13181. switch name {
  13182. case creditbalance.FieldCreatedAt:
  13183. m.ResetCreatedAt()
  13184. return nil
  13185. case creditbalance.FieldUpdatedAt:
  13186. m.ResetUpdatedAt()
  13187. return nil
  13188. case creditbalance.FieldDeletedAt:
  13189. m.ResetDeletedAt()
  13190. return nil
  13191. case creditbalance.FieldUserID:
  13192. m.ResetUserID()
  13193. return nil
  13194. case creditbalance.FieldBalance:
  13195. m.ResetBalance()
  13196. return nil
  13197. case creditbalance.FieldStatus:
  13198. m.ResetStatus()
  13199. return nil
  13200. case creditbalance.FieldOrganizationID:
  13201. m.ResetOrganizationID()
  13202. return nil
  13203. }
  13204. return fmt.Errorf("unknown CreditBalance field %s", name)
  13205. }
  13206. // AddedEdges returns all edge names that were set/added in this mutation.
  13207. func (m *CreditBalanceMutation) AddedEdges() []string {
  13208. edges := make([]string, 0, 0)
  13209. return edges
  13210. }
  13211. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13212. // name in this mutation.
  13213. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  13214. return nil
  13215. }
  13216. // RemovedEdges returns all edge names that were removed in this mutation.
  13217. func (m *CreditBalanceMutation) RemovedEdges() []string {
  13218. edges := make([]string, 0, 0)
  13219. return edges
  13220. }
  13221. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13222. // the given name in this mutation.
  13223. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  13224. return nil
  13225. }
  13226. // ClearedEdges returns all edge names that were cleared in this mutation.
  13227. func (m *CreditBalanceMutation) ClearedEdges() []string {
  13228. edges := make([]string, 0, 0)
  13229. return edges
  13230. }
  13231. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13232. // was cleared in this mutation.
  13233. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  13234. return false
  13235. }
  13236. // ClearEdge clears the value of the edge with the given name. It returns an error
  13237. // if that edge is not defined in the schema.
  13238. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  13239. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  13240. }
  13241. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13242. // It returns an error if the edge is not defined in the schema.
  13243. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  13244. return fmt.Errorf("unknown CreditBalance edge %s", name)
  13245. }
  13246. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  13247. type CreditUsageMutation struct {
  13248. config
  13249. op Op
  13250. typ string
  13251. id *uint64
  13252. created_at *time.Time
  13253. updated_at *time.Time
  13254. deleted_at *time.Time
  13255. user_id *string
  13256. number *float32
  13257. addnumber *float32
  13258. status *int
  13259. addstatus *int
  13260. ntype *int
  13261. addntype *int
  13262. table *string
  13263. organization_id *uint64
  13264. addorganization_id *int64
  13265. nid *uint64
  13266. addnid *int64
  13267. reason *string
  13268. operator *string
  13269. clearedFields map[string]struct{}
  13270. done bool
  13271. oldValue func(context.Context) (*CreditUsage, error)
  13272. predicates []predicate.CreditUsage
  13273. }
  13274. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  13275. // creditusageOption allows management of the mutation configuration using functional options.
  13276. type creditusageOption func(*CreditUsageMutation)
  13277. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  13278. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  13279. m := &CreditUsageMutation{
  13280. config: c,
  13281. op: op,
  13282. typ: TypeCreditUsage,
  13283. clearedFields: make(map[string]struct{}),
  13284. }
  13285. for _, opt := range opts {
  13286. opt(m)
  13287. }
  13288. return m
  13289. }
  13290. // withCreditUsageID sets the ID field of the mutation.
  13291. func withCreditUsageID(id uint64) creditusageOption {
  13292. return func(m *CreditUsageMutation) {
  13293. var (
  13294. err error
  13295. once sync.Once
  13296. value *CreditUsage
  13297. )
  13298. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  13299. once.Do(func() {
  13300. if m.done {
  13301. err = errors.New("querying old values post mutation is not allowed")
  13302. } else {
  13303. value, err = m.Client().CreditUsage.Get(ctx, id)
  13304. }
  13305. })
  13306. return value, err
  13307. }
  13308. m.id = &id
  13309. }
  13310. }
  13311. // withCreditUsage sets the old CreditUsage of the mutation.
  13312. func withCreditUsage(node *CreditUsage) creditusageOption {
  13313. return func(m *CreditUsageMutation) {
  13314. m.oldValue = func(context.Context) (*CreditUsage, error) {
  13315. return node, nil
  13316. }
  13317. m.id = &node.ID
  13318. }
  13319. }
  13320. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13321. // executed in a transaction (ent.Tx), a transactional client is returned.
  13322. func (m CreditUsageMutation) Client() *Client {
  13323. client := &Client{config: m.config}
  13324. client.init()
  13325. return client
  13326. }
  13327. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13328. // it returns an error otherwise.
  13329. func (m CreditUsageMutation) Tx() (*Tx, error) {
  13330. if _, ok := m.driver.(*txDriver); !ok {
  13331. return nil, errors.New("ent: mutation is not running in a transaction")
  13332. }
  13333. tx := &Tx{config: m.config}
  13334. tx.init()
  13335. return tx, nil
  13336. }
  13337. // SetID sets the value of the id field. Note that this
  13338. // operation is only accepted on creation of CreditUsage entities.
  13339. func (m *CreditUsageMutation) SetID(id uint64) {
  13340. m.id = &id
  13341. }
  13342. // ID returns the ID value in the mutation. Note that the ID is only available
  13343. // if it was provided to the builder or after it was returned from the database.
  13344. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  13345. if m.id == nil {
  13346. return
  13347. }
  13348. return *m.id, true
  13349. }
  13350. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13351. // That means, if the mutation is applied within a transaction with an isolation level such
  13352. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13353. // or updated by the mutation.
  13354. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  13355. switch {
  13356. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13357. id, exists := m.ID()
  13358. if exists {
  13359. return []uint64{id}, nil
  13360. }
  13361. fallthrough
  13362. case m.op.Is(OpUpdate | OpDelete):
  13363. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  13364. default:
  13365. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13366. }
  13367. }
  13368. // SetCreatedAt sets the "created_at" field.
  13369. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  13370. m.created_at = &t
  13371. }
  13372. // CreatedAt returns the value of the "created_at" field in the mutation.
  13373. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  13374. v := m.created_at
  13375. if v == nil {
  13376. return
  13377. }
  13378. return *v, true
  13379. }
  13380. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  13381. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13383. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13384. if !m.op.Is(OpUpdateOne) {
  13385. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13386. }
  13387. if m.id == nil || m.oldValue == nil {
  13388. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13389. }
  13390. oldValue, err := m.oldValue(ctx)
  13391. if err != nil {
  13392. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13393. }
  13394. return oldValue.CreatedAt, nil
  13395. }
  13396. // ResetCreatedAt resets all changes to the "created_at" field.
  13397. func (m *CreditUsageMutation) ResetCreatedAt() {
  13398. m.created_at = nil
  13399. }
  13400. // SetUpdatedAt sets the "updated_at" field.
  13401. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  13402. m.updated_at = &t
  13403. }
  13404. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13405. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  13406. v := m.updated_at
  13407. if v == nil {
  13408. return
  13409. }
  13410. return *v, true
  13411. }
  13412. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  13413. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13415. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13416. if !m.op.Is(OpUpdateOne) {
  13417. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13418. }
  13419. if m.id == nil || m.oldValue == nil {
  13420. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13421. }
  13422. oldValue, err := m.oldValue(ctx)
  13423. if err != nil {
  13424. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13425. }
  13426. return oldValue.UpdatedAt, nil
  13427. }
  13428. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13429. func (m *CreditUsageMutation) ResetUpdatedAt() {
  13430. m.updated_at = nil
  13431. }
  13432. // SetDeletedAt sets the "deleted_at" field.
  13433. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  13434. m.deleted_at = &t
  13435. }
  13436. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13437. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  13438. v := m.deleted_at
  13439. if v == nil {
  13440. return
  13441. }
  13442. return *v, true
  13443. }
  13444. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  13445. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13447. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13448. if !m.op.Is(OpUpdateOne) {
  13449. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13450. }
  13451. if m.id == nil || m.oldValue == nil {
  13452. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13453. }
  13454. oldValue, err := m.oldValue(ctx)
  13455. if err != nil {
  13456. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13457. }
  13458. return oldValue.DeletedAt, nil
  13459. }
  13460. // ClearDeletedAt clears the value of the "deleted_at" field.
  13461. func (m *CreditUsageMutation) ClearDeletedAt() {
  13462. m.deleted_at = nil
  13463. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  13464. }
  13465. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13466. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  13467. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  13468. return ok
  13469. }
  13470. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13471. func (m *CreditUsageMutation) ResetDeletedAt() {
  13472. m.deleted_at = nil
  13473. delete(m.clearedFields, creditusage.FieldDeletedAt)
  13474. }
  13475. // SetUserID sets the "user_id" field.
  13476. func (m *CreditUsageMutation) SetUserID(s string) {
  13477. m.user_id = &s
  13478. }
  13479. // UserID returns the value of the "user_id" field in the mutation.
  13480. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  13481. v := m.user_id
  13482. if v == nil {
  13483. return
  13484. }
  13485. return *v, true
  13486. }
  13487. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  13488. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13490. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  13491. if !m.op.Is(OpUpdateOne) {
  13492. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  13493. }
  13494. if m.id == nil || m.oldValue == nil {
  13495. return v, errors.New("OldUserID requires an ID field in the mutation")
  13496. }
  13497. oldValue, err := m.oldValue(ctx)
  13498. if err != nil {
  13499. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  13500. }
  13501. return oldValue.UserID, nil
  13502. }
  13503. // ClearUserID clears the value of the "user_id" field.
  13504. func (m *CreditUsageMutation) ClearUserID() {
  13505. m.user_id = nil
  13506. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  13507. }
  13508. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  13509. func (m *CreditUsageMutation) UserIDCleared() bool {
  13510. _, ok := m.clearedFields[creditusage.FieldUserID]
  13511. return ok
  13512. }
  13513. // ResetUserID resets all changes to the "user_id" field.
  13514. func (m *CreditUsageMutation) ResetUserID() {
  13515. m.user_id = nil
  13516. delete(m.clearedFields, creditusage.FieldUserID)
  13517. }
  13518. // SetNumber sets the "number" field.
  13519. func (m *CreditUsageMutation) SetNumber(f float32) {
  13520. m.number = &f
  13521. m.addnumber = nil
  13522. }
  13523. // Number returns the value of the "number" field in the mutation.
  13524. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  13525. v := m.number
  13526. if v == nil {
  13527. return
  13528. }
  13529. return *v, true
  13530. }
  13531. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  13532. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13534. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  13535. if !m.op.Is(OpUpdateOne) {
  13536. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  13537. }
  13538. if m.id == nil || m.oldValue == nil {
  13539. return v, errors.New("OldNumber requires an ID field in the mutation")
  13540. }
  13541. oldValue, err := m.oldValue(ctx)
  13542. if err != nil {
  13543. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  13544. }
  13545. return oldValue.Number, nil
  13546. }
  13547. // AddNumber adds f to the "number" field.
  13548. func (m *CreditUsageMutation) AddNumber(f float32) {
  13549. if m.addnumber != nil {
  13550. *m.addnumber += f
  13551. } else {
  13552. m.addnumber = &f
  13553. }
  13554. }
  13555. // AddedNumber returns the value that was added to the "number" field in this mutation.
  13556. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  13557. v := m.addnumber
  13558. if v == nil {
  13559. return
  13560. }
  13561. return *v, true
  13562. }
  13563. // ResetNumber resets all changes to the "number" field.
  13564. func (m *CreditUsageMutation) ResetNumber() {
  13565. m.number = nil
  13566. m.addnumber = nil
  13567. }
  13568. // SetStatus sets the "status" field.
  13569. func (m *CreditUsageMutation) SetStatus(i int) {
  13570. m.status = &i
  13571. m.addstatus = nil
  13572. }
  13573. // Status returns the value of the "status" field in the mutation.
  13574. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  13575. v := m.status
  13576. if v == nil {
  13577. return
  13578. }
  13579. return *v, true
  13580. }
  13581. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  13582. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13584. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  13585. if !m.op.Is(OpUpdateOne) {
  13586. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13587. }
  13588. if m.id == nil || m.oldValue == nil {
  13589. return v, errors.New("OldStatus requires an ID field in the mutation")
  13590. }
  13591. oldValue, err := m.oldValue(ctx)
  13592. if err != nil {
  13593. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13594. }
  13595. return oldValue.Status, nil
  13596. }
  13597. // AddStatus adds i to the "status" field.
  13598. func (m *CreditUsageMutation) AddStatus(i int) {
  13599. if m.addstatus != nil {
  13600. *m.addstatus += i
  13601. } else {
  13602. m.addstatus = &i
  13603. }
  13604. }
  13605. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13606. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  13607. v := m.addstatus
  13608. if v == nil {
  13609. return
  13610. }
  13611. return *v, true
  13612. }
  13613. // ClearStatus clears the value of the "status" field.
  13614. func (m *CreditUsageMutation) ClearStatus() {
  13615. m.status = nil
  13616. m.addstatus = nil
  13617. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  13618. }
  13619. // StatusCleared returns if the "status" field was cleared in this mutation.
  13620. func (m *CreditUsageMutation) StatusCleared() bool {
  13621. _, ok := m.clearedFields[creditusage.FieldStatus]
  13622. return ok
  13623. }
  13624. // ResetStatus resets all changes to the "status" field.
  13625. func (m *CreditUsageMutation) ResetStatus() {
  13626. m.status = nil
  13627. m.addstatus = nil
  13628. delete(m.clearedFields, creditusage.FieldStatus)
  13629. }
  13630. // SetNtype sets the "ntype" field.
  13631. func (m *CreditUsageMutation) SetNtype(i int) {
  13632. m.ntype = &i
  13633. m.addntype = nil
  13634. }
  13635. // Ntype returns the value of the "ntype" field in the mutation.
  13636. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  13637. v := m.ntype
  13638. if v == nil {
  13639. return
  13640. }
  13641. return *v, true
  13642. }
  13643. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  13644. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13646. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  13647. if !m.op.Is(OpUpdateOne) {
  13648. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  13649. }
  13650. if m.id == nil || m.oldValue == nil {
  13651. return v, errors.New("OldNtype requires an ID field in the mutation")
  13652. }
  13653. oldValue, err := m.oldValue(ctx)
  13654. if err != nil {
  13655. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  13656. }
  13657. return oldValue.Ntype, nil
  13658. }
  13659. // AddNtype adds i to the "ntype" field.
  13660. func (m *CreditUsageMutation) AddNtype(i int) {
  13661. if m.addntype != nil {
  13662. *m.addntype += i
  13663. } else {
  13664. m.addntype = &i
  13665. }
  13666. }
  13667. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  13668. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  13669. v := m.addntype
  13670. if v == nil {
  13671. return
  13672. }
  13673. return *v, true
  13674. }
  13675. // ResetNtype resets all changes to the "ntype" field.
  13676. func (m *CreditUsageMutation) ResetNtype() {
  13677. m.ntype = nil
  13678. m.addntype = nil
  13679. }
  13680. // SetTable sets the "table" field.
  13681. func (m *CreditUsageMutation) SetTable(s string) {
  13682. m.table = &s
  13683. }
  13684. // Table returns the value of the "table" field in the mutation.
  13685. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  13686. v := m.table
  13687. if v == nil {
  13688. return
  13689. }
  13690. return *v, true
  13691. }
  13692. // OldTable returns the old "table" field's value of the CreditUsage entity.
  13693. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13695. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  13696. if !m.op.Is(OpUpdateOne) {
  13697. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  13698. }
  13699. if m.id == nil || m.oldValue == nil {
  13700. return v, errors.New("OldTable requires an ID field in the mutation")
  13701. }
  13702. oldValue, err := m.oldValue(ctx)
  13703. if err != nil {
  13704. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  13705. }
  13706. return oldValue.Table, nil
  13707. }
  13708. // ResetTable resets all changes to the "table" field.
  13709. func (m *CreditUsageMutation) ResetTable() {
  13710. m.table = nil
  13711. }
  13712. // SetOrganizationID sets the "organization_id" field.
  13713. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  13714. m.organization_id = &u
  13715. m.addorganization_id = nil
  13716. }
  13717. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13718. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  13719. v := m.organization_id
  13720. if v == nil {
  13721. return
  13722. }
  13723. return *v, true
  13724. }
  13725. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  13726. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13728. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13729. if !m.op.Is(OpUpdateOne) {
  13730. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13731. }
  13732. if m.id == nil || m.oldValue == nil {
  13733. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13734. }
  13735. oldValue, err := m.oldValue(ctx)
  13736. if err != nil {
  13737. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13738. }
  13739. return oldValue.OrganizationID, nil
  13740. }
  13741. // AddOrganizationID adds u to the "organization_id" field.
  13742. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  13743. if m.addorganization_id != nil {
  13744. *m.addorganization_id += u
  13745. } else {
  13746. m.addorganization_id = &u
  13747. }
  13748. }
  13749. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13750. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  13751. v := m.addorganization_id
  13752. if v == nil {
  13753. return
  13754. }
  13755. return *v, true
  13756. }
  13757. // ClearOrganizationID clears the value of the "organization_id" field.
  13758. func (m *CreditUsageMutation) ClearOrganizationID() {
  13759. m.organization_id = nil
  13760. m.addorganization_id = nil
  13761. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  13762. }
  13763. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13764. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  13765. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  13766. return ok
  13767. }
  13768. // ResetOrganizationID resets all changes to the "organization_id" field.
  13769. func (m *CreditUsageMutation) ResetOrganizationID() {
  13770. m.organization_id = nil
  13771. m.addorganization_id = nil
  13772. delete(m.clearedFields, creditusage.FieldOrganizationID)
  13773. }
  13774. // SetNid sets the "nid" field.
  13775. func (m *CreditUsageMutation) SetNid(u uint64) {
  13776. m.nid = &u
  13777. m.addnid = nil
  13778. }
  13779. // Nid returns the value of the "nid" field in the mutation.
  13780. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  13781. v := m.nid
  13782. if v == nil {
  13783. return
  13784. }
  13785. return *v, true
  13786. }
  13787. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  13788. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13790. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  13791. if !m.op.Is(OpUpdateOne) {
  13792. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  13793. }
  13794. if m.id == nil || m.oldValue == nil {
  13795. return v, errors.New("OldNid requires an ID field in the mutation")
  13796. }
  13797. oldValue, err := m.oldValue(ctx)
  13798. if err != nil {
  13799. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  13800. }
  13801. return oldValue.Nid, nil
  13802. }
  13803. // AddNid adds u to the "nid" field.
  13804. func (m *CreditUsageMutation) AddNid(u int64) {
  13805. if m.addnid != nil {
  13806. *m.addnid += u
  13807. } else {
  13808. m.addnid = &u
  13809. }
  13810. }
  13811. // AddedNid returns the value that was added to the "nid" field in this mutation.
  13812. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  13813. v := m.addnid
  13814. if v == nil {
  13815. return
  13816. }
  13817. return *v, true
  13818. }
  13819. // ResetNid resets all changes to the "nid" field.
  13820. func (m *CreditUsageMutation) ResetNid() {
  13821. m.nid = nil
  13822. m.addnid = nil
  13823. }
  13824. // SetReason sets the "reason" field.
  13825. func (m *CreditUsageMutation) SetReason(s string) {
  13826. m.reason = &s
  13827. }
  13828. // Reason returns the value of the "reason" field in the mutation.
  13829. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  13830. v := m.reason
  13831. if v == nil {
  13832. return
  13833. }
  13834. return *v, true
  13835. }
  13836. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  13837. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13839. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  13840. if !m.op.Is(OpUpdateOne) {
  13841. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  13842. }
  13843. if m.id == nil || m.oldValue == nil {
  13844. return v, errors.New("OldReason requires an ID field in the mutation")
  13845. }
  13846. oldValue, err := m.oldValue(ctx)
  13847. if err != nil {
  13848. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  13849. }
  13850. return oldValue.Reason, nil
  13851. }
  13852. // ResetReason resets all changes to the "reason" field.
  13853. func (m *CreditUsageMutation) ResetReason() {
  13854. m.reason = nil
  13855. }
  13856. // SetOperator sets the "operator" field.
  13857. func (m *CreditUsageMutation) SetOperator(s string) {
  13858. m.operator = &s
  13859. }
  13860. // Operator returns the value of the "operator" field in the mutation.
  13861. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  13862. v := m.operator
  13863. if v == nil {
  13864. return
  13865. }
  13866. return *v, true
  13867. }
  13868. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  13869. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13871. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  13872. if !m.op.Is(OpUpdateOne) {
  13873. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  13874. }
  13875. if m.id == nil || m.oldValue == nil {
  13876. return v, errors.New("OldOperator requires an ID field in the mutation")
  13877. }
  13878. oldValue, err := m.oldValue(ctx)
  13879. if err != nil {
  13880. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  13881. }
  13882. return oldValue.Operator, nil
  13883. }
  13884. // ResetOperator resets all changes to the "operator" field.
  13885. func (m *CreditUsageMutation) ResetOperator() {
  13886. m.operator = nil
  13887. }
  13888. // Where appends a list predicates to the CreditUsageMutation builder.
  13889. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  13890. m.predicates = append(m.predicates, ps...)
  13891. }
  13892. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  13893. // users can use type-assertion to append predicates that do not depend on any generated package.
  13894. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  13895. p := make([]predicate.CreditUsage, len(ps))
  13896. for i := range ps {
  13897. p[i] = ps[i]
  13898. }
  13899. m.Where(p...)
  13900. }
  13901. // Op returns the operation name.
  13902. func (m *CreditUsageMutation) Op() Op {
  13903. return m.op
  13904. }
  13905. // SetOp allows setting the mutation operation.
  13906. func (m *CreditUsageMutation) SetOp(op Op) {
  13907. m.op = op
  13908. }
  13909. // Type returns the node type of this mutation (CreditUsage).
  13910. func (m *CreditUsageMutation) Type() string {
  13911. return m.typ
  13912. }
  13913. // Fields returns all fields that were changed during this mutation. Note that in
  13914. // order to get all numeric fields that were incremented/decremented, call
  13915. // AddedFields().
  13916. func (m *CreditUsageMutation) Fields() []string {
  13917. fields := make([]string, 0, 12)
  13918. if m.created_at != nil {
  13919. fields = append(fields, creditusage.FieldCreatedAt)
  13920. }
  13921. if m.updated_at != nil {
  13922. fields = append(fields, creditusage.FieldUpdatedAt)
  13923. }
  13924. if m.deleted_at != nil {
  13925. fields = append(fields, creditusage.FieldDeletedAt)
  13926. }
  13927. if m.user_id != nil {
  13928. fields = append(fields, creditusage.FieldUserID)
  13929. }
  13930. if m.number != nil {
  13931. fields = append(fields, creditusage.FieldNumber)
  13932. }
  13933. if m.status != nil {
  13934. fields = append(fields, creditusage.FieldStatus)
  13935. }
  13936. if m.ntype != nil {
  13937. fields = append(fields, creditusage.FieldNtype)
  13938. }
  13939. if m.table != nil {
  13940. fields = append(fields, creditusage.FieldTable)
  13941. }
  13942. if m.organization_id != nil {
  13943. fields = append(fields, creditusage.FieldOrganizationID)
  13944. }
  13945. if m.nid != nil {
  13946. fields = append(fields, creditusage.FieldNid)
  13947. }
  13948. if m.reason != nil {
  13949. fields = append(fields, creditusage.FieldReason)
  13950. }
  13951. if m.operator != nil {
  13952. fields = append(fields, creditusage.FieldOperator)
  13953. }
  13954. return fields
  13955. }
  13956. // Field returns the value of a field with the given name. The second boolean
  13957. // return value indicates that this field was not set, or was not defined in the
  13958. // schema.
  13959. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  13960. switch name {
  13961. case creditusage.FieldCreatedAt:
  13962. return m.CreatedAt()
  13963. case creditusage.FieldUpdatedAt:
  13964. return m.UpdatedAt()
  13965. case creditusage.FieldDeletedAt:
  13966. return m.DeletedAt()
  13967. case creditusage.FieldUserID:
  13968. return m.UserID()
  13969. case creditusage.FieldNumber:
  13970. return m.Number()
  13971. case creditusage.FieldStatus:
  13972. return m.Status()
  13973. case creditusage.FieldNtype:
  13974. return m.Ntype()
  13975. case creditusage.FieldTable:
  13976. return m.Table()
  13977. case creditusage.FieldOrganizationID:
  13978. return m.OrganizationID()
  13979. case creditusage.FieldNid:
  13980. return m.Nid()
  13981. case creditusage.FieldReason:
  13982. return m.Reason()
  13983. case creditusage.FieldOperator:
  13984. return m.Operator()
  13985. }
  13986. return nil, false
  13987. }
  13988. // OldField returns the old value of the field from the database. An error is
  13989. // returned if the mutation operation is not UpdateOne, or the query to the
  13990. // database failed.
  13991. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13992. switch name {
  13993. case creditusage.FieldCreatedAt:
  13994. return m.OldCreatedAt(ctx)
  13995. case creditusage.FieldUpdatedAt:
  13996. return m.OldUpdatedAt(ctx)
  13997. case creditusage.FieldDeletedAt:
  13998. return m.OldDeletedAt(ctx)
  13999. case creditusage.FieldUserID:
  14000. return m.OldUserID(ctx)
  14001. case creditusage.FieldNumber:
  14002. return m.OldNumber(ctx)
  14003. case creditusage.FieldStatus:
  14004. return m.OldStatus(ctx)
  14005. case creditusage.FieldNtype:
  14006. return m.OldNtype(ctx)
  14007. case creditusage.FieldTable:
  14008. return m.OldTable(ctx)
  14009. case creditusage.FieldOrganizationID:
  14010. return m.OldOrganizationID(ctx)
  14011. case creditusage.FieldNid:
  14012. return m.OldNid(ctx)
  14013. case creditusage.FieldReason:
  14014. return m.OldReason(ctx)
  14015. case creditusage.FieldOperator:
  14016. return m.OldOperator(ctx)
  14017. }
  14018. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  14019. }
  14020. // SetField sets the value of a field with the given name. It returns an error if
  14021. // the field is not defined in the schema, or if the type mismatched the field
  14022. // type.
  14023. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  14024. switch name {
  14025. case creditusage.FieldCreatedAt:
  14026. v, ok := value.(time.Time)
  14027. if !ok {
  14028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14029. }
  14030. m.SetCreatedAt(v)
  14031. return nil
  14032. case creditusage.FieldUpdatedAt:
  14033. v, ok := value.(time.Time)
  14034. if !ok {
  14035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14036. }
  14037. m.SetUpdatedAt(v)
  14038. return nil
  14039. case creditusage.FieldDeletedAt:
  14040. v, ok := value.(time.Time)
  14041. if !ok {
  14042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14043. }
  14044. m.SetDeletedAt(v)
  14045. return nil
  14046. case creditusage.FieldUserID:
  14047. v, ok := value.(string)
  14048. if !ok {
  14049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14050. }
  14051. m.SetUserID(v)
  14052. return nil
  14053. case creditusage.FieldNumber:
  14054. v, ok := value.(float32)
  14055. if !ok {
  14056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14057. }
  14058. m.SetNumber(v)
  14059. return nil
  14060. case creditusage.FieldStatus:
  14061. v, ok := value.(int)
  14062. if !ok {
  14063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14064. }
  14065. m.SetStatus(v)
  14066. return nil
  14067. case creditusage.FieldNtype:
  14068. v, ok := value.(int)
  14069. if !ok {
  14070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14071. }
  14072. m.SetNtype(v)
  14073. return nil
  14074. case creditusage.FieldTable:
  14075. v, ok := value.(string)
  14076. if !ok {
  14077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14078. }
  14079. m.SetTable(v)
  14080. return nil
  14081. case creditusage.FieldOrganizationID:
  14082. v, ok := value.(uint64)
  14083. if !ok {
  14084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14085. }
  14086. m.SetOrganizationID(v)
  14087. return nil
  14088. case creditusage.FieldNid:
  14089. v, ok := value.(uint64)
  14090. if !ok {
  14091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14092. }
  14093. m.SetNid(v)
  14094. return nil
  14095. case creditusage.FieldReason:
  14096. v, ok := value.(string)
  14097. if !ok {
  14098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14099. }
  14100. m.SetReason(v)
  14101. return nil
  14102. case creditusage.FieldOperator:
  14103. v, ok := value.(string)
  14104. if !ok {
  14105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14106. }
  14107. m.SetOperator(v)
  14108. return nil
  14109. }
  14110. return fmt.Errorf("unknown CreditUsage field %s", name)
  14111. }
  14112. // AddedFields returns all numeric fields that were incremented/decremented during
  14113. // this mutation.
  14114. func (m *CreditUsageMutation) AddedFields() []string {
  14115. var fields []string
  14116. if m.addnumber != nil {
  14117. fields = append(fields, creditusage.FieldNumber)
  14118. }
  14119. if m.addstatus != nil {
  14120. fields = append(fields, creditusage.FieldStatus)
  14121. }
  14122. if m.addntype != nil {
  14123. fields = append(fields, creditusage.FieldNtype)
  14124. }
  14125. if m.addorganization_id != nil {
  14126. fields = append(fields, creditusage.FieldOrganizationID)
  14127. }
  14128. if m.addnid != nil {
  14129. fields = append(fields, creditusage.FieldNid)
  14130. }
  14131. return fields
  14132. }
  14133. // AddedField returns the numeric value that was incremented/decremented on a field
  14134. // with the given name. The second boolean return value indicates that this field
  14135. // was not set, or was not defined in the schema.
  14136. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  14137. switch name {
  14138. case creditusage.FieldNumber:
  14139. return m.AddedNumber()
  14140. case creditusage.FieldStatus:
  14141. return m.AddedStatus()
  14142. case creditusage.FieldNtype:
  14143. return m.AddedNtype()
  14144. case creditusage.FieldOrganizationID:
  14145. return m.AddedOrganizationID()
  14146. case creditusage.FieldNid:
  14147. return m.AddedNid()
  14148. }
  14149. return nil, false
  14150. }
  14151. // AddField adds the value to the field with the given name. It returns an error if
  14152. // the field is not defined in the schema, or if the type mismatched the field
  14153. // type.
  14154. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  14155. switch name {
  14156. case creditusage.FieldNumber:
  14157. v, ok := value.(float32)
  14158. if !ok {
  14159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14160. }
  14161. m.AddNumber(v)
  14162. return nil
  14163. case creditusage.FieldStatus:
  14164. v, ok := value.(int)
  14165. if !ok {
  14166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14167. }
  14168. m.AddStatus(v)
  14169. return nil
  14170. case creditusage.FieldNtype:
  14171. v, ok := value.(int)
  14172. if !ok {
  14173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14174. }
  14175. m.AddNtype(v)
  14176. return nil
  14177. case creditusage.FieldOrganizationID:
  14178. v, ok := value.(int64)
  14179. if !ok {
  14180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14181. }
  14182. m.AddOrganizationID(v)
  14183. return nil
  14184. case creditusage.FieldNid:
  14185. v, ok := value.(int64)
  14186. if !ok {
  14187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14188. }
  14189. m.AddNid(v)
  14190. return nil
  14191. }
  14192. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  14193. }
  14194. // ClearedFields returns all nullable fields that were cleared during this
  14195. // mutation.
  14196. func (m *CreditUsageMutation) ClearedFields() []string {
  14197. var fields []string
  14198. if m.FieldCleared(creditusage.FieldDeletedAt) {
  14199. fields = append(fields, creditusage.FieldDeletedAt)
  14200. }
  14201. if m.FieldCleared(creditusage.FieldUserID) {
  14202. fields = append(fields, creditusage.FieldUserID)
  14203. }
  14204. if m.FieldCleared(creditusage.FieldStatus) {
  14205. fields = append(fields, creditusage.FieldStatus)
  14206. }
  14207. if m.FieldCleared(creditusage.FieldOrganizationID) {
  14208. fields = append(fields, creditusage.FieldOrganizationID)
  14209. }
  14210. return fields
  14211. }
  14212. // FieldCleared returns a boolean indicating if a field with the given name was
  14213. // cleared in this mutation.
  14214. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  14215. _, ok := m.clearedFields[name]
  14216. return ok
  14217. }
  14218. // ClearField clears the value of the field with the given name. It returns an
  14219. // error if the field is not defined in the schema.
  14220. func (m *CreditUsageMutation) ClearField(name string) error {
  14221. switch name {
  14222. case creditusage.FieldDeletedAt:
  14223. m.ClearDeletedAt()
  14224. return nil
  14225. case creditusage.FieldUserID:
  14226. m.ClearUserID()
  14227. return nil
  14228. case creditusage.FieldStatus:
  14229. m.ClearStatus()
  14230. return nil
  14231. case creditusage.FieldOrganizationID:
  14232. m.ClearOrganizationID()
  14233. return nil
  14234. }
  14235. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  14236. }
  14237. // ResetField resets all changes in the mutation for the field with the given name.
  14238. // It returns an error if the field is not defined in the schema.
  14239. func (m *CreditUsageMutation) ResetField(name string) error {
  14240. switch name {
  14241. case creditusage.FieldCreatedAt:
  14242. m.ResetCreatedAt()
  14243. return nil
  14244. case creditusage.FieldUpdatedAt:
  14245. m.ResetUpdatedAt()
  14246. return nil
  14247. case creditusage.FieldDeletedAt:
  14248. m.ResetDeletedAt()
  14249. return nil
  14250. case creditusage.FieldUserID:
  14251. m.ResetUserID()
  14252. return nil
  14253. case creditusage.FieldNumber:
  14254. m.ResetNumber()
  14255. return nil
  14256. case creditusage.FieldStatus:
  14257. m.ResetStatus()
  14258. return nil
  14259. case creditusage.FieldNtype:
  14260. m.ResetNtype()
  14261. return nil
  14262. case creditusage.FieldTable:
  14263. m.ResetTable()
  14264. return nil
  14265. case creditusage.FieldOrganizationID:
  14266. m.ResetOrganizationID()
  14267. return nil
  14268. case creditusage.FieldNid:
  14269. m.ResetNid()
  14270. return nil
  14271. case creditusage.FieldReason:
  14272. m.ResetReason()
  14273. return nil
  14274. case creditusage.FieldOperator:
  14275. m.ResetOperator()
  14276. return nil
  14277. }
  14278. return fmt.Errorf("unknown CreditUsage field %s", name)
  14279. }
  14280. // AddedEdges returns all edge names that were set/added in this mutation.
  14281. func (m *CreditUsageMutation) AddedEdges() []string {
  14282. edges := make([]string, 0, 0)
  14283. return edges
  14284. }
  14285. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14286. // name in this mutation.
  14287. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  14288. return nil
  14289. }
  14290. // RemovedEdges returns all edge names that were removed in this mutation.
  14291. func (m *CreditUsageMutation) RemovedEdges() []string {
  14292. edges := make([]string, 0, 0)
  14293. return edges
  14294. }
  14295. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14296. // the given name in this mutation.
  14297. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  14298. return nil
  14299. }
  14300. // ClearedEdges returns all edge names that were cleared in this mutation.
  14301. func (m *CreditUsageMutation) ClearedEdges() []string {
  14302. edges := make([]string, 0, 0)
  14303. return edges
  14304. }
  14305. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14306. // was cleared in this mutation.
  14307. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  14308. return false
  14309. }
  14310. // ClearEdge clears the value of the edge with the given name. It returns an error
  14311. // if that edge is not defined in the schema.
  14312. func (m *CreditUsageMutation) ClearEdge(name string) error {
  14313. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  14314. }
  14315. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14316. // It returns an error if the edge is not defined in the schema.
  14317. func (m *CreditUsageMutation) ResetEdge(name string) error {
  14318. return fmt.Errorf("unknown CreditUsage edge %s", name)
  14319. }
  14320. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  14321. type EmployeeMutation struct {
  14322. config
  14323. op Op
  14324. typ string
  14325. id *uint64
  14326. created_at *time.Time
  14327. updated_at *time.Time
  14328. deleted_at *time.Time
  14329. title *string
  14330. avatar *string
  14331. tags *string
  14332. hire_count *int
  14333. addhire_count *int
  14334. service_count *int
  14335. addservice_count *int
  14336. achievement_count *int
  14337. addachievement_count *int
  14338. intro *string
  14339. estimate *string
  14340. skill *string
  14341. ability_type *string
  14342. scene *string
  14343. switch_in *string
  14344. video_url *string
  14345. organization_id *uint64
  14346. addorganization_id *int64
  14347. category_id *uint64
  14348. addcategory_id *int64
  14349. api_base *string
  14350. api_key *string
  14351. ai_info *string
  14352. is_vip *int
  14353. addis_vip *int
  14354. chat_url *string
  14355. clearedFields map[string]struct{}
  14356. em_work_experiences map[uint64]struct{}
  14357. removedem_work_experiences map[uint64]struct{}
  14358. clearedem_work_experiences bool
  14359. em_tutorial map[uint64]struct{}
  14360. removedem_tutorial map[uint64]struct{}
  14361. clearedem_tutorial bool
  14362. done bool
  14363. oldValue func(context.Context) (*Employee, error)
  14364. predicates []predicate.Employee
  14365. }
  14366. var _ ent.Mutation = (*EmployeeMutation)(nil)
  14367. // employeeOption allows management of the mutation configuration using functional options.
  14368. type employeeOption func(*EmployeeMutation)
  14369. // newEmployeeMutation creates new mutation for the Employee entity.
  14370. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  14371. m := &EmployeeMutation{
  14372. config: c,
  14373. op: op,
  14374. typ: TypeEmployee,
  14375. clearedFields: make(map[string]struct{}),
  14376. }
  14377. for _, opt := range opts {
  14378. opt(m)
  14379. }
  14380. return m
  14381. }
  14382. // withEmployeeID sets the ID field of the mutation.
  14383. func withEmployeeID(id uint64) employeeOption {
  14384. return func(m *EmployeeMutation) {
  14385. var (
  14386. err error
  14387. once sync.Once
  14388. value *Employee
  14389. )
  14390. m.oldValue = func(ctx context.Context) (*Employee, error) {
  14391. once.Do(func() {
  14392. if m.done {
  14393. err = errors.New("querying old values post mutation is not allowed")
  14394. } else {
  14395. value, err = m.Client().Employee.Get(ctx, id)
  14396. }
  14397. })
  14398. return value, err
  14399. }
  14400. m.id = &id
  14401. }
  14402. }
  14403. // withEmployee sets the old Employee of the mutation.
  14404. func withEmployee(node *Employee) employeeOption {
  14405. return func(m *EmployeeMutation) {
  14406. m.oldValue = func(context.Context) (*Employee, error) {
  14407. return node, nil
  14408. }
  14409. m.id = &node.ID
  14410. }
  14411. }
  14412. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14413. // executed in a transaction (ent.Tx), a transactional client is returned.
  14414. func (m EmployeeMutation) Client() *Client {
  14415. client := &Client{config: m.config}
  14416. client.init()
  14417. return client
  14418. }
  14419. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14420. // it returns an error otherwise.
  14421. func (m EmployeeMutation) Tx() (*Tx, error) {
  14422. if _, ok := m.driver.(*txDriver); !ok {
  14423. return nil, errors.New("ent: mutation is not running in a transaction")
  14424. }
  14425. tx := &Tx{config: m.config}
  14426. tx.init()
  14427. return tx, nil
  14428. }
  14429. // SetID sets the value of the id field. Note that this
  14430. // operation is only accepted on creation of Employee entities.
  14431. func (m *EmployeeMutation) SetID(id uint64) {
  14432. m.id = &id
  14433. }
  14434. // ID returns the ID value in the mutation. Note that the ID is only available
  14435. // if it was provided to the builder or after it was returned from the database.
  14436. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  14437. if m.id == nil {
  14438. return
  14439. }
  14440. return *m.id, true
  14441. }
  14442. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14443. // That means, if the mutation is applied within a transaction with an isolation level such
  14444. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14445. // or updated by the mutation.
  14446. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  14447. switch {
  14448. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14449. id, exists := m.ID()
  14450. if exists {
  14451. return []uint64{id}, nil
  14452. }
  14453. fallthrough
  14454. case m.op.Is(OpUpdate | OpDelete):
  14455. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  14456. default:
  14457. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14458. }
  14459. }
  14460. // SetCreatedAt sets the "created_at" field.
  14461. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  14462. m.created_at = &t
  14463. }
  14464. // CreatedAt returns the value of the "created_at" field in the mutation.
  14465. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  14466. v := m.created_at
  14467. if v == nil {
  14468. return
  14469. }
  14470. return *v, true
  14471. }
  14472. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  14473. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14475. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14476. if !m.op.Is(OpUpdateOne) {
  14477. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14478. }
  14479. if m.id == nil || m.oldValue == nil {
  14480. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14481. }
  14482. oldValue, err := m.oldValue(ctx)
  14483. if err != nil {
  14484. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14485. }
  14486. return oldValue.CreatedAt, nil
  14487. }
  14488. // ResetCreatedAt resets all changes to the "created_at" field.
  14489. func (m *EmployeeMutation) ResetCreatedAt() {
  14490. m.created_at = nil
  14491. }
  14492. // SetUpdatedAt sets the "updated_at" field.
  14493. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  14494. m.updated_at = &t
  14495. }
  14496. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14497. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  14498. v := m.updated_at
  14499. if v == nil {
  14500. return
  14501. }
  14502. return *v, true
  14503. }
  14504. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  14505. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14507. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14508. if !m.op.Is(OpUpdateOne) {
  14509. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14510. }
  14511. if m.id == nil || m.oldValue == nil {
  14512. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14513. }
  14514. oldValue, err := m.oldValue(ctx)
  14515. if err != nil {
  14516. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14517. }
  14518. return oldValue.UpdatedAt, nil
  14519. }
  14520. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14521. func (m *EmployeeMutation) ResetUpdatedAt() {
  14522. m.updated_at = nil
  14523. }
  14524. // SetDeletedAt sets the "deleted_at" field.
  14525. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  14526. m.deleted_at = &t
  14527. }
  14528. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14529. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  14530. v := m.deleted_at
  14531. if v == nil {
  14532. return
  14533. }
  14534. return *v, true
  14535. }
  14536. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  14537. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14539. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14540. if !m.op.Is(OpUpdateOne) {
  14541. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14542. }
  14543. if m.id == nil || m.oldValue == nil {
  14544. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14545. }
  14546. oldValue, err := m.oldValue(ctx)
  14547. if err != nil {
  14548. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14549. }
  14550. return oldValue.DeletedAt, nil
  14551. }
  14552. // ClearDeletedAt clears the value of the "deleted_at" field.
  14553. func (m *EmployeeMutation) ClearDeletedAt() {
  14554. m.deleted_at = nil
  14555. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  14556. }
  14557. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14558. func (m *EmployeeMutation) DeletedAtCleared() bool {
  14559. _, ok := m.clearedFields[employee.FieldDeletedAt]
  14560. return ok
  14561. }
  14562. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14563. func (m *EmployeeMutation) ResetDeletedAt() {
  14564. m.deleted_at = nil
  14565. delete(m.clearedFields, employee.FieldDeletedAt)
  14566. }
  14567. // SetTitle sets the "title" field.
  14568. func (m *EmployeeMutation) SetTitle(s string) {
  14569. m.title = &s
  14570. }
  14571. // Title returns the value of the "title" field in the mutation.
  14572. func (m *EmployeeMutation) Title() (r string, exists bool) {
  14573. v := m.title
  14574. if v == nil {
  14575. return
  14576. }
  14577. return *v, true
  14578. }
  14579. // OldTitle returns the old "title" field's value of the Employee entity.
  14580. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14582. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  14583. if !m.op.Is(OpUpdateOne) {
  14584. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  14585. }
  14586. if m.id == nil || m.oldValue == nil {
  14587. return v, errors.New("OldTitle requires an ID field in the mutation")
  14588. }
  14589. oldValue, err := m.oldValue(ctx)
  14590. if err != nil {
  14591. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  14592. }
  14593. return oldValue.Title, nil
  14594. }
  14595. // ResetTitle resets all changes to the "title" field.
  14596. func (m *EmployeeMutation) ResetTitle() {
  14597. m.title = nil
  14598. }
  14599. // SetAvatar sets the "avatar" field.
  14600. func (m *EmployeeMutation) SetAvatar(s string) {
  14601. m.avatar = &s
  14602. }
  14603. // Avatar returns the value of the "avatar" field in the mutation.
  14604. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  14605. v := m.avatar
  14606. if v == nil {
  14607. return
  14608. }
  14609. return *v, true
  14610. }
  14611. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  14612. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14614. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  14615. if !m.op.Is(OpUpdateOne) {
  14616. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  14617. }
  14618. if m.id == nil || m.oldValue == nil {
  14619. return v, errors.New("OldAvatar requires an ID field in the mutation")
  14620. }
  14621. oldValue, err := m.oldValue(ctx)
  14622. if err != nil {
  14623. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  14624. }
  14625. return oldValue.Avatar, nil
  14626. }
  14627. // ResetAvatar resets all changes to the "avatar" field.
  14628. func (m *EmployeeMutation) ResetAvatar() {
  14629. m.avatar = nil
  14630. }
  14631. // SetTags sets the "tags" field.
  14632. func (m *EmployeeMutation) SetTags(s string) {
  14633. m.tags = &s
  14634. }
  14635. // Tags returns the value of the "tags" field in the mutation.
  14636. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  14637. v := m.tags
  14638. if v == nil {
  14639. return
  14640. }
  14641. return *v, true
  14642. }
  14643. // OldTags returns the old "tags" field's value of the Employee entity.
  14644. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14646. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  14647. if !m.op.Is(OpUpdateOne) {
  14648. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  14649. }
  14650. if m.id == nil || m.oldValue == nil {
  14651. return v, errors.New("OldTags requires an ID field in the mutation")
  14652. }
  14653. oldValue, err := m.oldValue(ctx)
  14654. if err != nil {
  14655. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  14656. }
  14657. return oldValue.Tags, nil
  14658. }
  14659. // ResetTags resets all changes to the "tags" field.
  14660. func (m *EmployeeMutation) ResetTags() {
  14661. m.tags = nil
  14662. }
  14663. // SetHireCount sets the "hire_count" field.
  14664. func (m *EmployeeMutation) SetHireCount(i int) {
  14665. m.hire_count = &i
  14666. m.addhire_count = nil
  14667. }
  14668. // HireCount returns the value of the "hire_count" field in the mutation.
  14669. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  14670. v := m.hire_count
  14671. if v == nil {
  14672. return
  14673. }
  14674. return *v, true
  14675. }
  14676. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  14677. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14679. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  14680. if !m.op.Is(OpUpdateOne) {
  14681. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  14682. }
  14683. if m.id == nil || m.oldValue == nil {
  14684. return v, errors.New("OldHireCount requires an ID field in the mutation")
  14685. }
  14686. oldValue, err := m.oldValue(ctx)
  14687. if err != nil {
  14688. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  14689. }
  14690. return oldValue.HireCount, nil
  14691. }
  14692. // AddHireCount adds i to the "hire_count" field.
  14693. func (m *EmployeeMutation) AddHireCount(i int) {
  14694. if m.addhire_count != nil {
  14695. *m.addhire_count += i
  14696. } else {
  14697. m.addhire_count = &i
  14698. }
  14699. }
  14700. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  14701. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  14702. v := m.addhire_count
  14703. if v == nil {
  14704. return
  14705. }
  14706. return *v, true
  14707. }
  14708. // ResetHireCount resets all changes to the "hire_count" field.
  14709. func (m *EmployeeMutation) ResetHireCount() {
  14710. m.hire_count = nil
  14711. m.addhire_count = nil
  14712. }
  14713. // SetServiceCount sets the "service_count" field.
  14714. func (m *EmployeeMutation) SetServiceCount(i int) {
  14715. m.service_count = &i
  14716. m.addservice_count = nil
  14717. }
  14718. // ServiceCount returns the value of the "service_count" field in the mutation.
  14719. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  14720. v := m.service_count
  14721. if v == nil {
  14722. return
  14723. }
  14724. return *v, true
  14725. }
  14726. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  14727. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14729. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  14730. if !m.op.Is(OpUpdateOne) {
  14731. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  14732. }
  14733. if m.id == nil || m.oldValue == nil {
  14734. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  14735. }
  14736. oldValue, err := m.oldValue(ctx)
  14737. if err != nil {
  14738. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  14739. }
  14740. return oldValue.ServiceCount, nil
  14741. }
  14742. // AddServiceCount adds i to the "service_count" field.
  14743. func (m *EmployeeMutation) AddServiceCount(i int) {
  14744. if m.addservice_count != nil {
  14745. *m.addservice_count += i
  14746. } else {
  14747. m.addservice_count = &i
  14748. }
  14749. }
  14750. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  14751. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  14752. v := m.addservice_count
  14753. if v == nil {
  14754. return
  14755. }
  14756. return *v, true
  14757. }
  14758. // ResetServiceCount resets all changes to the "service_count" field.
  14759. func (m *EmployeeMutation) ResetServiceCount() {
  14760. m.service_count = nil
  14761. m.addservice_count = nil
  14762. }
  14763. // SetAchievementCount sets the "achievement_count" field.
  14764. func (m *EmployeeMutation) SetAchievementCount(i int) {
  14765. m.achievement_count = &i
  14766. m.addachievement_count = nil
  14767. }
  14768. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  14769. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  14770. v := m.achievement_count
  14771. if v == nil {
  14772. return
  14773. }
  14774. return *v, true
  14775. }
  14776. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  14777. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14779. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  14780. if !m.op.Is(OpUpdateOne) {
  14781. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  14782. }
  14783. if m.id == nil || m.oldValue == nil {
  14784. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  14785. }
  14786. oldValue, err := m.oldValue(ctx)
  14787. if err != nil {
  14788. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  14789. }
  14790. return oldValue.AchievementCount, nil
  14791. }
  14792. // AddAchievementCount adds i to the "achievement_count" field.
  14793. func (m *EmployeeMutation) AddAchievementCount(i int) {
  14794. if m.addachievement_count != nil {
  14795. *m.addachievement_count += i
  14796. } else {
  14797. m.addachievement_count = &i
  14798. }
  14799. }
  14800. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  14801. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  14802. v := m.addachievement_count
  14803. if v == nil {
  14804. return
  14805. }
  14806. return *v, true
  14807. }
  14808. // ResetAchievementCount resets all changes to the "achievement_count" field.
  14809. func (m *EmployeeMutation) ResetAchievementCount() {
  14810. m.achievement_count = nil
  14811. m.addachievement_count = nil
  14812. }
  14813. // SetIntro sets the "intro" field.
  14814. func (m *EmployeeMutation) SetIntro(s string) {
  14815. m.intro = &s
  14816. }
  14817. // Intro returns the value of the "intro" field in the mutation.
  14818. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  14819. v := m.intro
  14820. if v == nil {
  14821. return
  14822. }
  14823. return *v, true
  14824. }
  14825. // OldIntro returns the old "intro" field's value of the Employee entity.
  14826. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14828. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  14829. if !m.op.Is(OpUpdateOne) {
  14830. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  14831. }
  14832. if m.id == nil || m.oldValue == nil {
  14833. return v, errors.New("OldIntro requires an ID field in the mutation")
  14834. }
  14835. oldValue, err := m.oldValue(ctx)
  14836. if err != nil {
  14837. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  14838. }
  14839. return oldValue.Intro, nil
  14840. }
  14841. // ResetIntro resets all changes to the "intro" field.
  14842. func (m *EmployeeMutation) ResetIntro() {
  14843. m.intro = nil
  14844. }
  14845. // SetEstimate sets the "estimate" field.
  14846. func (m *EmployeeMutation) SetEstimate(s string) {
  14847. m.estimate = &s
  14848. }
  14849. // Estimate returns the value of the "estimate" field in the mutation.
  14850. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  14851. v := m.estimate
  14852. if v == nil {
  14853. return
  14854. }
  14855. return *v, true
  14856. }
  14857. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  14858. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14860. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  14861. if !m.op.Is(OpUpdateOne) {
  14862. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  14863. }
  14864. if m.id == nil || m.oldValue == nil {
  14865. return v, errors.New("OldEstimate requires an ID field in the mutation")
  14866. }
  14867. oldValue, err := m.oldValue(ctx)
  14868. if err != nil {
  14869. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  14870. }
  14871. return oldValue.Estimate, nil
  14872. }
  14873. // ResetEstimate resets all changes to the "estimate" field.
  14874. func (m *EmployeeMutation) ResetEstimate() {
  14875. m.estimate = nil
  14876. }
  14877. // SetSkill sets the "skill" field.
  14878. func (m *EmployeeMutation) SetSkill(s string) {
  14879. m.skill = &s
  14880. }
  14881. // Skill returns the value of the "skill" field in the mutation.
  14882. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  14883. v := m.skill
  14884. if v == nil {
  14885. return
  14886. }
  14887. return *v, true
  14888. }
  14889. // OldSkill returns the old "skill" field's value of the Employee entity.
  14890. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14892. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  14893. if !m.op.Is(OpUpdateOne) {
  14894. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  14895. }
  14896. if m.id == nil || m.oldValue == nil {
  14897. return v, errors.New("OldSkill requires an ID field in the mutation")
  14898. }
  14899. oldValue, err := m.oldValue(ctx)
  14900. if err != nil {
  14901. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  14902. }
  14903. return oldValue.Skill, nil
  14904. }
  14905. // ResetSkill resets all changes to the "skill" field.
  14906. func (m *EmployeeMutation) ResetSkill() {
  14907. m.skill = nil
  14908. }
  14909. // SetAbilityType sets the "ability_type" field.
  14910. func (m *EmployeeMutation) SetAbilityType(s string) {
  14911. m.ability_type = &s
  14912. }
  14913. // AbilityType returns the value of the "ability_type" field in the mutation.
  14914. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  14915. v := m.ability_type
  14916. if v == nil {
  14917. return
  14918. }
  14919. return *v, true
  14920. }
  14921. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  14922. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14924. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  14925. if !m.op.Is(OpUpdateOne) {
  14926. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  14927. }
  14928. if m.id == nil || m.oldValue == nil {
  14929. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  14930. }
  14931. oldValue, err := m.oldValue(ctx)
  14932. if err != nil {
  14933. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  14934. }
  14935. return oldValue.AbilityType, nil
  14936. }
  14937. // ResetAbilityType resets all changes to the "ability_type" field.
  14938. func (m *EmployeeMutation) ResetAbilityType() {
  14939. m.ability_type = nil
  14940. }
  14941. // SetScene sets the "scene" field.
  14942. func (m *EmployeeMutation) SetScene(s string) {
  14943. m.scene = &s
  14944. }
  14945. // Scene returns the value of the "scene" field in the mutation.
  14946. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  14947. v := m.scene
  14948. if v == nil {
  14949. return
  14950. }
  14951. return *v, true
  14952. }
  14953. // OldScene returns the old "scene" field's value of the Employee entity.
  14954. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14956. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  14957. if !m.op.Is(OpUpdateOne) {
  14958. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  14959. }
  14960. if m.id == nil || m.oldValue == nil {
  14961. return v, errors.New("OldScene requires an ID field in the mutation")
  14962. }
  14963. oldValue, err := m.oldValue(ctx)
  14964. if err != nil {
  14965. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  14966. }
  14967. return oldValue.Scene, nil
  14968. }
  14969. // ResetScene resets all changes to the "scene" field.
  14970. func (m *EmployeeMutation) ResetScene() {
  14971. m.scene = nil
  14972. }
  14973. // SetSwitchIn sets the "switch_in" field.
  14974. func (m *EmployeeMutation) SetSwitchIn(s string) {
  14975. m.switch_in = &s
  14976. }
  14977. // SwitchIn returns the value of the "switch_in" field in the mutation.
  14978. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  14979. v := m.switch_in
  14980. if v == nil {
  14981. return
  14982. }
  14983. return *v, true
  14984. }
  14985. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  14986. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14988. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  14989. if !m.op.Is(OpUpdateOne) {
  14990. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  14991. }
  14992. if m.id == nil || m.oldValue == nil {
  14993. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  14994. }
  14995. oldValue, err := m.oldValue(ctx)
  14996. if err != nil {
  14997. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  14998. }
  14999. return oldValue.SwitchIn, nil
  15000. }
  15001. // ResetSwitchIn resets all changes to the "switch_in" field.
  15002. func (m *EmployeeMutation) ResetSwitchIn() {
  15003. m.switch_in = nil
  15004. }
  15005. // SetVideoURL sets the "video_url" field.
  15006. func (m *EmployeeMutation) SetVideoURL(s string) {
  15007. m.video_url = &s
  15008. }
  15009. // VideoURL returns the value of the "video_url" field in the mutation.
  15010. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  15011. v := m.video_url
  15012. if v == nil {
  15013. return
  15014. }
  15015. return *v, true
  15016. }
  15017. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  15018. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15020. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  15021. if !m.op.Is(OpUpdateOne) {
  15022. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  15023. }
  15024. if m.id == nil || m.oldValue == nil {
  15025. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  15026. }
  15027. oldValue, err := m.oldValue(ctx)
  15028. if err != nil {
  15029. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  15030. }
  15031. return oldValue.VideoURL, nil
  15032. }
  15033. // ResetVideoURL resets all changes to the "video_url" field.
  15034. func (m *EmployeeMutation) ResetVideoURL() {
  15035. m.video_url = nil
  15036. }
  15037. // SetOrganizationID sets the "organization_id" field.
  15038. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  15039. m.organization_id = &u
  15040. m.addorganization_id = nil
  15041. }
  15042. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15043. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  15044. v := m.organization_id
  15045. if v == nil {
  15046. return
  15047. }
  15048. return *v, true
  15049. }
  15050. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  15051. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15053. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15054. if !m.op.Is(OpUpdateOne) {
  15055. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15056. }
  15057. if m.id == nil || m.oldValue == nil {
  15058. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15059. }
  15060. oldValue, err := m.oldValue(ctx)
  15061. if err != nil {
  15062. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15063. }
  15064. return oldValue.OrganizationID, nil
  15065. }
  15066. // AddOrganizationID adds u to the "organization_id" field.
  15067. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  15068. if m.addorganization_id != nil {
  15069. *m.addorganization_id += u
  15070. } else {
  15071. m.addorganization_id = &u
  15072. }
  15073. }
  15074. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15075. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  15076. v := m.addorganization_id
  15077. if v == nil {
  15078. return
  15079. }
  15080. return *v, true
  15081. }
  15082. // ResetOrganizationID resets all changes to the "organization_id" field.
  15083. func (m *EmployeeMutation) ResetOrganizationID() {
  15084. m.organization_id = nil
  15085. m.addorganization_id = nil
  15086. }
  15087. // SetCategoryID sets the "category_id" field.
  15088. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  15089. m.category_id = &u
  15090. m.addcategory_id = nil
  15091. }
  15092. // CategoryID returns the value of the "category_id" field in the mutation.
  15093. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  15094. v := m.category_id
  15095. if v == nil {
  15096. return
  15097. }
  15098. return *v, true
  15099. }
  15100. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  15101. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15103. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  15104. if !m.op.Is(OpUpdateOne) {
  15105. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  15106. }
  15107. if m.id == nil || m.oldValue == nil {
  15108. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  15109. }
  15110. oldValue, err := m.oldValue(ctx)
  15111. if err != nil {
  15112. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  15113. }
  15114. return oldValue.CategoryID, nil
  15115. }
  15116. // AddCategoryID adds u to the "category_id" field.
  15117. func (m *EmployeeMutation) AddCategoryID(u int64) {
  15118. if m.addcategory_id != nil {
  15119. *m.addcategory_id += u
  15120. } else {
  15121. m.addcategory_id = &u
  15122. }
  15123. }
  15124. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  15125. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  15126. v := m.addcategory_id
  15127. if v == nil {
  15128. return
  15129. }
  15130. return *v, true
  15131. }
  15132. // ResetCategoryID resets all changes to the "category_id" field.
  15133. func (m *EmployeeMutation) ResetCategoryID() {
  15134. m.category_id = nil
  15135. m.addcategory_id = nil
  15136. }
  15137. // SetAPIBase sets the "api_base" field.
  15138. func (m *EmployeeMutation) SetAPIBase(s string) {
  15139. m.api_base = &s
  15140. }
  15141. // APIBase returns the value of the "api_base" field in the mutation.
  15142. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  15143. v := m.api_base
  15144. if v == nil {
  15145. return
  15146. }
  15147. return *v, true
  15148. }
  15149. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  15150. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15152. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  15153. if !m.op.Is(OpUpdateOne) {
  15154. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  15155. }
  15156. if m.id == nil || m.oldValue == nil {
  15157. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  15158. }
  15159. oldValue, err := m.oldValue(ctx)
  15160. if err != nil {
  15161. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  15162. }
  15163. return oldValue.APIBase, nil
  15164. }
  15165. // ResetAPIBase resets all changes to the "api_base" field.
  15166. func (m *EmployeeMutation) ResetAPIBase() {
  15167. m.api_base = nil
  15168. }
  15169. // SetAPIKey sets the "api_key" field.
  15170. func (m *EmployeeMutation) SetAPIKey(s string) {
  15171. m.api_key = &s
  15172. }
  15173. // APIKey returns the value of the "api_key" field in the mutation.
  15174. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  15175. v := m.api_key
  15176. if v == nil {
  15177. return
  15178. }
  15179. return *v, true
  15180. }
  15181. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  15182. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15184. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  15185. if !m.op.Is(OpUpdateOne) {
  15186. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  15187. }
  15188. if m.id == nil || m.oldValue == nil {
  15189. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  15190. }
  15191. oldValue, err := m.oldValue(ctx)
  15192. if err != nil {
  15193. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  15194. }
  15195. return oldValue.APIKey, nil
  15196. }
  15197. // ResetAPIKey resets all changes to the "api_key" field.
  15198. func (m *EmployeeMutation) ResetAPIKey() {
  15199. m.api_key = nil
  15200. }
  15201. // SetAiInfo sets the "ai_info" field.
  15202. func (m *EmployeeMutation) SetAiInfo(s string) {
  15203. m.ai_info = &s
  15204. }
  15205. // AiInfo returns the value of the "ai_info" field in the mutation.
  15206. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  15207. v := m.ai_info
  15208. if v == nil {
  15209. return
  15210. }
  15211. return *v, true
  15212. }
  15213. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  15214. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15216. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  15217. if !m.op.Is(OpUpdateOne) {
  15218. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  15219. }
  15220. if m.id == nil || m.oldValue == nil {
  15221. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  15222. }
  15223. oldValue, err := m.oldValue(ctx)
  15224. if err != nil {
  15225. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  15226. }
  15227. return oldValue.AiInfo, nil
  15228. }
  15229. // ClearAiInfo clears the value of the "ai_info" field.
  15230. func (m *EmployeeMutation) ClearAiInfo() {
  15231. m.ai_info = nil
  15232. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  15233. }
  15234. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  15235. func (m *EmployeeMutation) AiInfoCleared() bool {
  15236. _, ok := m.clearedFields[employee.FieldAiInfo]
  15237. return ok
  15238. }
  15239. // ResetAiInfo resets all changes to the "ai_info" field.
  15240. func (m *EmployeeMutation) ResetAiInfo() {
  15241. m.ai_info = nil
  15242. delete(m.clearedFields, employee.FieldAiInfo)
  15243. }
  15244. // SetIsVip sets the "is_vip" field.
  15245. func (m *EmployeeMutation) SetIsVip(i int) {
  15246. m.is_vip = &i
  15247. m.addis_vip = nil
  15248. }
  15249. // IsVip returns the value of the "is_vip" field in the mutation.
  15250. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  15251. v := m.is_vip
  15252. if v == nil {
  15253. return
  15254. }
  15255. return *v, true
  15256. }
  15257. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  15258. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15260. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  15261. if !m.op.Is(OpUpdateOne) {
  15262. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  15263. }
  15264. if m.id == nil || m.oldValue == nil {
  15265. return v, errors.New("OldIsVip requires an ID field in the mutation")
  15266. }
  15267. oldValue, err := m.oldValue(ctx)
  15268. if err != nil {
  15269. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  15270. }
  15271. return oldValue.IsVip, nil
  15272. }
  15273. // AddIsVip adds i to the "is_vip" field.
  15274. func (m *EmployeeMutation) AddIsVip(i int) {
  15275. if m.addis_vip != nil {
  15276. *m.addis_vip += i
  15277. } else {
  15278. m.addis_vip = &i
  15279. }
  15280. }
  15281. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  15282. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  15283. v := m.addis_vip
  15284. if v == nil {
  15285. return
  15286. }
  15287. return *v, true
  15288. }
  15289. // ResetIsVip resets all changes to the "is_vip" field.
  15290. func (m *EmployeeMutation) ResetIsVip() {
  15291. m.is_vip = nil
  15292. m.addis_vip = nil
  15293. }
  15294. // SetChatURL sets the "chat_url" field.
  15295. func (m *EmployeeMutation) SetChatURL(s string) {
  15296. m.chat_url = &s
  15297. }
  15298. // ChatURL returns the value of the "chat_url" field in the mutation.
  15299. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  15300. v := m.chat_url
  15301. if v == nil {
  15302. return
  15303. }
  15304. return *v, true
  15305. }
  15306. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  15307. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15309. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  15310. if !m.op.Is(OpUpdateOne) {
  15311. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  15312. }
  15313. if m.id == nil || m.oldValue == nil {
  15314. return v, errors.New("OldChatURL requires an ID field in the mutation")
  15315. }
  15316. oldValue, err := m.oldValue(ctx)
  15317. if err != nil {
  15318. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  15319. }
  15320. return oldValue.ChatURL, nil
  15321. }
  15322. // ResetChatURL resets all changes to the "chat_url" field.
  15323. func (m *EmployeeMutation) ResetChatURL() {
  15324. m.chat_url = nil
  15325. }
  15326. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  15327. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  15328. if m.em_work_experiences == nil {
  15329. m.em_work_experiences = make(map[uint64]struct{})
  15330. }
  15331. for i := range ids {
  15332. m.em_work_experiences[ids[i]] = struct{}{}
  15333. }
  15334. }
  15335. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  15336. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  15337. m.clearedem_work_experiences = true
  15338. }
  15339. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  15340. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  15341. return m.clearedem_work_experiences
  15342. }
  15343. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  15344. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  15345. if m.removedem_work_experiences == nil {
  15346. m.removedem_work_experiences = make(map[uint64]struct{})
  15347. }
  15348. for i := range ids {
  15349. delete(m.em_work_experiences, ids[i])
  15350. m.removedem_work_experiences[ids[i]] = struct{}{}
  15351. }
  15352. }
  15353. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  15354. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  15355. for id := range m.removedem_work_experiences {
  15356. ids = append(ids, id)
  15357. }
  15358. return
  15359. }
  15360. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  15361. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  15362. for id := range m.em_work_experiences {
  15363. ids = append(ids, id)
  15364. }
  15365. return
  15366. }
  15367. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  15368. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  15369. m.em_work_experiences = nil
  15370. m.clearedem_work_experiences = false
  15371. m.removedem_work_experiences = nil
  15372. }
  15373. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  15374. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  15375. if m.em_tutorial == nil {
  15376. m.em_tutorial = make(map[uint64]struct{})
  15377. }
  15378. for i := range ids {
  15379. m.em_tutorial[ids[i]] = struct{}{}
  15380. }
  15381. }
  15382. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  15383. func (m *EmployeeMutation) ClearEmTutorial() {
  15384. m.clearedem_tutorial = true
  15385. }
  15386. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  15387. func (m *EmployeeMutation) EmTutorialCleared() bool {
  15388. return m.clearedem_tutorial
  15389. }
  15390. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  15391. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  15392. if m.removedem_tutorial == nil {
  15393. m.removedem_tutorial = make(map[uint64]struct{})
  15394. }
  15395. for i := range ids {
  15396. delete(m.em_tutorial, ids[i])
  15397. m.removedem_tutorial[ids[i]] = struct{}{}
  15398. }
  15399. }
  15400. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  15401. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  15402. for id := range m.removedem_tutorial {
  15403. ids = append(ids, id)
  15404. }
  15405. return
  15406. }
  15407. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  15408. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  15409. for id := range m.em_tutorial {
  15410. ids = append(ids, id)
  15411. }
  15412. return
  15413. }
  15414. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  15415. func (m *EmployeeMutation) ResetEmTutorial() {
  15416. m.em_tutorial = nil
  15417. m.clearedem_tutorial = false
  15418. m.removedem_tutorial = nil
  15419. }
  15420. // Where appends a list predicates to the EmployeeMutation builder.
  15421. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  15422. m.predicates = append(m.predicates, ps...)
  15423. }
  15424. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  15425. // users can use type-assertion to append predicates that do not depend on any generated package.
  15426. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  15427. p := make([]predicate.Employee, len(ps))
  15428. for i := range ps {
  15429. p[i] = ps[i]
  15430. }
  15431. m.Where(p...)
  15432. }
  15433. // Op returns the operation name.
  15434. func (m *EmployeeMutation) Op() Op {
  15435. return m.op
  15436. }
  15437. // SetOp allows setting the mutation operation.
  15438. func (m *EmployeeMutation) SetOp(op Op) {
  15439. m.op = op
  15440. }
  15441. // Type returns the node type of this mutation (Employee).
  15442. func (m *EmployeeMutation) Type() string {
  15443. return m.typ
  15444. }
  15445. // Fields returns all fields that were changed during this mutation. Note that in
  15446. // order to get all numeric fields that were incremented/decremented, call
  15447. // AddedFields().
  15448. func (m *EmployeeMutation) Fields() []string {
  15449. fields := make([]string, 0, 23)
  15450. if m.created_at != nil {
  15451. fields = append(fields, employee.FieldCreatedAt)
  15452. }
  15453. if m.updated_at != nil {
  15454. fields = append(fields, employee.FieldUpdatedAt)
  15455. }
  15456. if m.deleted_at != nil {
  15457. fields = append(fields, employee.FieldDeletedAt)
  15458. }
  15459. if m.title != nil {
  15460. fields = append(fields, employee.FieldTitle)
  15461. }
  15462. if m.avatar != nil {
  15463. fields = append(fields, employee.FieldAvatar)
  15464. }
  15465. if m.tags != nil {
  15466. fields = append(fields, employee.FieldTags)
  15467. }
  15468. if m.hire_count != nil {
  15469. fields = append(fields, employee.FieldHireCount)
  15470. }
  15471. if m.service_count != nil {
  15472. fields = append(fields, employee.FieldServiceCount)
  15473. }
  15474. if m.achievement_count != nil {
  15475. fields = append(fields, employee.FieldAchievementCount)
  15476. }
  15477. if m.intro != nil {
  15478. fields = append(fields, employee.FieldIntro)
  15479. }
  15480. if m.estimate != nil {
  15481. fields = append(fields, employee.FieldEstimate)
  15482. }
  15483. if m.skill != nil {
  15484. fields = append(fields, employee.FieldSkill)
  15485. }
  15486. if m.ability_type != nil {
  15487. fields = append(fields, employee.FieldAbilityType)
  15488. }
  15489. if m.scene != nil {
  15490. fields = append(fields, employee.FieldScene)
  15491. }
  15492. if m.switch_in != nil {
  15493. fields = append(fields, employee.FieldSwitchIn)
  15494. }
  15495. if m.video_url != nil {
  15496. fields = append(fields, employee.FieldVideoURL)
  15497. }
  15498. if m.organization_id != nil {
  15499. fields = append(fields, employee.FieldOrganizationID)
  15500. }
  15501. if m.category_id != nil {
  15502. fields = append(fields, employee.FieldCategoryID)
  15503. }
  15504. if m.api_base != nil {
  15505. fields = append(fields, employee.FieldAPIBase)
  15506. }
  15507. if m.api_key != nil {
  15508. fields = append(fields, employee.FieldAPIKey)
  15509. }
  15510. if m.ai_info != nil {
  15511. fields = append(fields, employee.FieldAiInfo)
  15512. }
  15513. if m.is_vip != nil {
  15514. fields = append(fields, employee.FieldIsVip)
  15515. }
  15516. if m.chat_url != nil {
  15517. fields = append(fields, employee.FieldChatURL)
  15518. }
  15519. return fields
  15520. }
  15521. // Field returns the value of a field with the given name. The second boolean
  15522. // return value indicates that this field was not set, or was not defined in the
  15523. // schema.
  15524. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  15525. switch name {
  15526. case employee.FieldCreatedAt:
  15527. return m.CreatedAt()
  15528. case employee.FieldUpdatedAt:
  15529. return m.UpdatedAt()
  15530. case employee.FieldDeletedAt:
  15531. return m.DeletedAt()
  15532. case employee.FieldTitle:
  15533. return m.Title()
  15534. case employee.FieldAvatar:
  15535. return m.Avatar()
  15536. case employee.FieldTags:
  15537. return m.Tags()
  15538. case employee.FieldHireCount:
  15539. return m.HireCount()
  15540. case employee.FieldServiceCount:
  15541. return m.ServiceCount()
  15542. case employee.FieldAchievementCount:
  15543. return m.AchievementCount()
  15544. case employee.FieldIntro:
  15545. return m.Intro()
  15546. case employee.FieldEstimate:
  15547. return m.Estimate()
  15548. case employee.FieldSkill:
  15549. return m.Skill()
  15550. case employee.FieldAbilityType:
  15551. return m.AbilityType()
  15552. case employee.FieldScene:
  15553. return m.Scene()
  15554. case employee.FieldSwitchIn:
  15555. return m.SwitchIn()
  15556. case employee.FieldVideoURL:
  15557. return m.VideoURL()
  15558. case employee.FieldOrganizationID:
  15559. return m.OrganizationID()
  15560. case employee.FieldCategoryID:
  15561. return m.CategoryID()
  15562. case employee.FieldAPIBase:
  15563. return m.APIBase()
  15564. case employee.FieldAPIKey:
  15565. return m.APIKey()
  15566. case employee.FieldAiInfo:
  15567. return m.AiInfo()
  15568. case employee.FieldIsVip:
  15569. return m.IsVip()
  15570. case employee.FieldChatURL:
  15571. return m.ChatURL()
  15572. }
  15573. return nil, false
  15574. }
  15575. // OldField returns the old value of the field from the database. An error is
  15576. // returned if the mutation operation is not UpdateOne, or the query to the
  15577. // database failed.
  15578. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15579. switch name {
  15580. case employee.FieldCreatedAt:
  15581. return m.OldCreatedAt(ctx)
  15582. case employee.FieldUpdatedAt:
  15583. return m.OldUpdatedAt(ctx)
  15584. case employee.FieldDeletedAt:
  15585. return m.OldDeletedAt(ctx)
  15586. case employee.FieldTitle:
  15587. return m.OldTitle(ctx)
  15588. case employee.FieldAvatar:
  15589. return m.OldAvatar(ctx)
  15590. case employee.FieldTags:
  15591. return m.OldTags(ctx)
  15592. case employee.FieldHireCount:
  15593. return m.OldHireCount(ctx)
  15594. case employee.FieldServiceCount:
  15595. return m.OldServiceCount(ctx)
  15596. case employee.FieldAchievementCount:
  15597. return m.OldAchievementCount(ctx)
  15598. case employee.FieldIntro:
  15599. return m.OldIntro(ctx)
  15600. case employee.FieldEstimate:
  15601. return m.OldEstimate(ctx)
  15602. case employee.FieldSkill:
  15603. return m.OldSkill(ctx)
  15604. case employee.FieldAbilityType:
  15605. return m.OldAbilityType(ctx)
  15606. case employee.FieldScene:
  15607. return m.OldScene(ctx)
  15608. case employee.FieldSwitchIn:
  15609. return m.OldSwitchIn(ctx)
  15610. case employee.FieldVideoURL:
  15611. return m.OldVideoURL(ctx)
  15612. case employee.FieldOrganizationID:
  15613. return m.OldOrganizationID(ctx)
  15614. case employee.FieldCategoryID:
  15615. return m.OldCategoryID(ctx)
  15616. case employee.FieldAPIBase:
  15617. return m.OldAPIBase(ctx)
  15618. case employee.FieldAPIKey:
  15619. return m.OldAPIKey(ctx)
  15620. case employee.FieldAiInfo:
  15621. return m.OldAiInfo(ctx)
  15622. case employee.FieldIsVip:
  15623. return m.OldIsVip(ctx)
  15624. case employee.FieldChatURL:
  15625. return m.OldChatURL(ctx)
  15626. }
  15627. return nil, fmt.Errorf("unknown Employee field %s", name)
  15628. }
  15629. // SetField sets the value of a field with the given name. It returns an error if
  15630. // the field is not defined in the schema, or if the type mismatched the field
  15631. // type.
  15632. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  15633. switch name {
  15634. case employee.FieldCreatedAt:
  15635. v, ok := value.(time.Time)
  15636. if !ok {
  15637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15638. }
  15639. m.SetCreatedAt(v)
  15640. return nil
  15641. case employee.FieldUpdatedAt:
  15642. v, ok := value.(time.Time)
  15643. if !ok {
  15644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15645. }
  15646. m.SetUpdatedAt(v)
  15647. return nil
  15648. case employee.FieldDeletedAt:
  15649. v, ok := value.(time.Time)
  15650. if !ok {
  15651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15652. }
  15653. m.SetDeletedAt(v)
  15654. return nil
  15655. case employee.FieldTitle:
  15656. v, ok := value.(string)
  15657. if !ok {
  15658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15659. }
  15660. m.SetTitle(v)
  15661. return nil
  15662. case employee.FieldAvatar:
  15663. v, ok := value.(string)
  15664. if !ok {
  15665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15666. }
  15667. m.SetAvatar(v)
  15668. return nil
  15669. case employee.FieldTags:
  15670. v, ok := value.(string)
  15671. if !ok {
  15672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15673. }
  15674. m.SetTags(v)
  15675. return nil
  15676. case employee.FieldHireCount:
  15677. v, ok := value.(int)
  15678. if !ok {
  15679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15680. }
  15681. m.SetHireCount(v)
  15682. return nil
  15683. case employee.FieldServiceCount:
  15684. v, ok := value.(int)
  15685. if !ok {
  15686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15687. }
  15688. m.SetServiceCount(v)
  15689. return nil
  15690. case employee.FieldAchievementCount:
  15691. v, ok := value.(int)
  15692. if !ok {
  15693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15694. }
  15695. m.SetAchievementCount(v)
  15696. return nil
  15697. case employee.FieldIntro:
  15698. v, ok := value.(string)
  15699. if !ok {
  15700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15701. }
  15702. m.SetIntro(v)
  15703. return nil
  15704. case employee.FieldEstimate:
  15705. v, ok := value.(string)
  15706. if !ok {
  15707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15708. }
  15709. m.SetEstimate(v)
  15710. return nil
  15711. case employee.FieldSkill:
  15712. v, ok := value.(string)
  15713. if !ok {
  15714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15715. }
  15716. m.SetSkill(v)
  15717. return nil
  15718. case employee.FieldAbilityType:
  15719. v, ok := value.(string)
  15720. if !ok {
  15721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15722. }
  15723. m.SetAbilityType(v)
  15724. return nil
  15725. case employee.FieldScene:
  15726. v, ok := value.(string)
  15727. if !ok {
  15728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15729. }
  15730. m.SetScene(v)
  15731. return nil
  15732. case employee.FieldSwitchIn:
  15733. v, ok := value.(string)
  15734. if !ok {
  15735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15736. }
  15737. m.SetSwitchIn(v)
  15738. return nil
  15739. case employee.FieldVideoURL:
  15740. v, ok := value.(string)
  15741. if !ok {
  15742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15743. }
  15744. m.SetVideoURL(v)
  15745. return nil
  15746. case employee.FieldOrganizationID:
  15747. v, ok := value.(uint64)
  15748. if !ok {
  15749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15750. }
  15751. m.SetOrganizationID(v)
  15752. return nil
  15753. case employee.FieldCategoryID:
  15754. v, ok := value.(uint64)
  15755. if !ok {
  15756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15757. }
  15758. m.SetCategoryID(v)
  15759. return nil
  15760. case employee.FieldAPIBase:
  15761. v, ok := value.(string)
  15762. if !ok {
  15763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15764. }
  15765. m.SetAPIBase(v)
  15766. return nil
  15767. case employee.FieldAPIKey:
  15768. v, ok := value.(string)
  15769. if !ok {
  15770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15771. }
  15772. m.SetAPIKey(v)
  15773. return nil
  15774. case employee.FieldAiInfo:
  15775. v, ok := value.(string)
  15776. if !ok {
  15777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15778. }
  15779. m.SetAiInfo(v)
  15780. return nil
  15781. case employee.FieldIsVip:
  15782. v, ok := value.(int)
  15783. if !ok {
  15784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15785. }
  15786. m.SetIsVip(v)
  15787. return nil
  15788. case employee.FieldChatURL:
  15789. v, ok := value.(string)
  15790. if !ok {
  15791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15792. }
  15793. m.SetChatURL(v)
  15794. return nil
  15795. }
  15796. return fmt.Errorf("unknown Employee field %s", name)
  15797. }
  15798. // AddedFields returns all numeric fields that were incremented/decremented during
  15799. // this mutation.
  15800. func (m *EmployeeMutation) AddedFields() []string {
  15801. var fields []string
  15802. if m.addhire_count != nil {
  15803. fields = append(fields, employee.FieldHireCount)
  15804. }
  15805. if m.addservice_count != nil {
  15806. fields = append(fields, employee.FieldServiceCount)
  15807. }
  15808. if m.addachievement_count != nil {
  15809. fields = append(fields, employee.FieldAchievementCount)
  15810. }
  15811. if m.addorganization_id != nil {
  15812. fields = append(fields, employee.FieldOrganizationID)
  15813. }
  15814. if m.addcategory_id != nil {
  15815. fields = append(fields, employee.FieldCategoryID)
  15816. }
  15817. if m.addis_vip != nil {
  15818. fields = append(fields, employee.FieldIsVip)
  15819. }
  15820. return fields
  15821. }
  15822. // AddedField returns the numeric value that was incremented/decremented on a field
  15823. // with the given name. The second boolean return value indicates that this field
  15824. // was not set, or was not defined in the schema.
  15825. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  15826. switch name {
  15827. case employee.FieldHireCount:
  15828. return m.AddedHireCount()
  15829. case employee.FieldServiceCount:
  15830. return m.AddedServiceCount()
  15831. case employee.FieldAchievementCount:
  15832. return m.AddedAchievementCount()
  15833. case employee.FieldOrganizationID:
  15834. return m.AddedOrganizationID()
  15835. case employee.FieldCategoryID:
  15836. return m.AddedCategoryID()
  15837. case employee.FieldIsVip:
  15838. return m.AddedIsVip()
  15839. }
  15840. return nil, false
  15841. }
  15842. // AddField adds the value to the field with the given name. It returns an error if
  15843. // the field is not defined in the schema, or if the type mismatched the field
  15844. // type.
  15845. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  15846. switch name {
  15847. case employee.FieldHireCount:
  15848. v, ok := value.(int)
  15849. if !ok {
  15850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15851. }
  15852. m.AddHireCount(v)
  15853. return nil
  15854. case employee.FieldServiceCount:
  15855. v, ok := value.(int)
  15856. if !ok {
  15857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15858. }
  15859. m.AddServiceCount(v)
  15860. return nil
  15861. case employee.FieldAchievementCount:
  15862. v, ok := value.(int)
  15863. if !ok {
  15864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15865. }
  15866. m.AddAchievementCount(v)
  15867. return nil
  15868. case employee.FieldOrganizationID:
  15869. v, ok := value.(int64)
  15870. if !ok {
  15871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15872. }
  15873. m.AddOrganizationID(v)
  15874. return nil
  15875. case employee.FieldCategoryID:
  15876. v, ok := value.(int64)
  15877. if !ok {
  15878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15879. }
  15880. m.AddCategoryID(v)
  15881. return nil
  15882. case employee.FieldIsVip:
  15883. v, ok := value.(int)
  15884. if !ok {
  15885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15886. }
  15887. m.AddIsVip(v)
  15888. return nil
  15889. }
  15890. return fmt.Errorf("unknown Employee numeric field %s", name)
  15891. }
  15892. // ClearedFields returns all nullable fields that were cleared during this
  15893. // mutation.
  15894. func (m *EmployeeMutation) ClearedFields() []string {
  15895. var fields []string
  15896. if m.FieldCleared(employee.FieldDeletedAt) {
  15897. fields = append(fields, employee.FieldDeletedAt)
  15898. }
  15899. if m.FieldCleared(employee.FieldAiInfo) {
  15900. fields = append(fields, employee.FieldAiInfo)
  15901. }
  15902. return fields
  15903. }
  15904. // FieldCleared returns a boolean indicating if a field with the given name was
  15905. // cleared in this mutation.
  15906. func (m *EmployeeMutation) FieldCleared(name string) bool {
  15907. _, ok := m.clearedFields[name]
  15908. return ok
  15909. }
  15910. // ClearField clears the value of the field with the given name. It returns an
  15911. // error if the field is not defined in the schema.
  15912. func (m *EmployeeMutation) ClearField(name string) error {
  15913. switch name {
  15914. case employee.FieldDeletedAt:
  15915. m.ClearDeletedAt()
  15916. return nil
  15917. case employee.FieldAiInfo:
  15918. m.ClearAiInfo()
  15919. return nil
  15920. }
  15921. return fmt.Errorf("unknown Employee nullable field %s", name)
  15922. }
  15923. // ResetField resets all changes in the mutation for the field with the given name.
  15924. // It returns an error if the field is not defined in the schema.
  15925. func (m *EmployeeMutation) ResetField(name string) error {
  15926. switch name {
  15927. case employee.FieldCreatedAt:
  15928. m.ResetCreatedAt()
  15929. return nil
  15930. case employee.FieldUpdatedAt:
  15931. m.ResetUpdatedAt()
  15932. return nil
  15933. case employee.FieldDeletedAt:
  15934. m.ResetDeletedAt()
  15935. return nil
  15936. case employee.FieldTitle:
  15937. m.ResetTitle()
  15938. return nil
  15939. case employee.FieldAvatar:
  15940. m.ResetAvatar()
  15941. return nil
  15942. case employee.FieldTags:
  15943. m.ResetTags()
  15944. return nil
  15945. case employee.FieldHireCount:
  15946. m.ResetHireCount()
  15947. return nil
  15948. case employee.FieldServiceCount:
  15949. m.ResetServiceCount()
  15950. return nil
  15951. case employee.FieldAchievementCount:
  15952. m.ResetAchievementCount()
  15953. return nil
  15954. case employee.FieldIntro:
  15955. m.ResetIntro()
  15956. return nil
  15957. case employee.FieldEstimate:
  15958. m.ResetEstimate()
  15959. return nil
  15960. case employee.FieldSkill:
  15961. m.ResetSkill()
  15962. return nil
  15963. case employee.FieldAbilityType:
  15964. m.ResetAbilityType()
  15965. return nil
  15966. case employee.FieldScene:
  15967. m.ResetScene()
  15968. return nil
  15969. case employee.FieldSwitchIn:
  15970. m.ResetSwitchIn()
  15971. return nil
  15972. case employee.FieldVideoURL:
  15973. m.ResetVideoURL()
  15974. return nil
  15975. case employee.FieldOrganizationID:
  15976. m.ResetOrganizationID()
  15977. return nil
  15978. case employee.FieldCategoryID:
  15979. m.ResetCategoryID()
  15980. return nil
  15981. case employee.FieldAPIBase:
  15982. m.ResetAPIBase()
  15983. return nil
  15984. case employee.FieldAPIKey:
  15985. m.ResetAPIKey()
  15986. return nil
  15987. case employee.FieldAiInfo:
  15988. m.ResetAiInfo()
  15989. return nil
  15990. case employee.FieldIsVip:
  15991. m.ResetIsVip()
  15992. return nil
  15993. case employee.FieldChatURL:
  15994. m.ResetChatURL()
  15995. return nil
  15996. }
  15997. return fmt.Errorf("unknown Employee field %s", name)
  15998. }
  15999. // AddedEdges returns all edge names that were set/added in this mutation.
  16000. func (m *EmployeeMutation) AddedEdges() []string {
  16001. edges := make([]string, 0, 2)
  16002. if m.em_work_experiences != nil {
  16003. edges = append(edges, employee.EdgeEmWorkExperiences)
  16004. }
  16005. if m.em_tutorial != nil {
  16006. edges = append(edges, employee.EdgeEmTutorial)
  16007. }
  16008. return edges
  16009. }
  16010. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16011. // name in this mutation.
  16012. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  16013. switch name {
  16014. case employee.EdgeEmWorkExperiences:
  16015. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  16016. for id := range m.em_work_experiences {
  16017. ids = append(ids, id)
  16018. }
  16019. return ids
  16020. case employee.EdgeEmTutorial:
  16021. ids := make([]ent.Value, 0, len(m.em_tutorial))
  16022. for id := range m.em_tutorial {
  16023. ids = append(ids, id)
  16024. }
  16025. return ids
  16026. }
  16027. return nil
  16028. }
  16029. // RemovedEdges returns all edge names that were removed in this mutation.
  16030. func (m *EmployeeMutation) RemovedEdges() []string {
  16031. edges := make([]string, 0, 2)
  16032. if m.removedem_work_experiences != nil {
  16033. edges = append(edges, employee.EdgeEmWorkExperiences)
  16034. }
  16035. if m.removedem_tutorial != nil {
  16036. edges = append(edges, employee.EdgeEmTutorial)
  16037. }
  16038. return edges
  16039. }
  16040. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16041. // the given name in this mutation.
  16042. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  16043. switch name {
  16044. case employee.EdgeEmWorkExperiences:
  16045. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  16046. for id := range m.removedem_work_experiences {
  16047. ids = append(ids, id)
  16048. }
  16049. return ids
  16050. case employee.EdgeEmTutorial:
  16051. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  16052. for id := range m.removedem_tutorial {
  16053. ids = append(ids, id)
  16054. }
  16055. return ids
  16056. }
  16057. return nil
  16058. }
  16059. // ClearedEdges returns all edge names that were cleared in this mutation.
  16060. func (m *EmployeeMutation) ClearedEdges() []string {
  16061. edges := make([]string, 0, 2)
  16062. if m.clearedem_work_experiences {
  16063. edges = append(edges, employee.EdgeEmWorkExperiences)
  16064. }
  16065. if m.clearedem_tutorial {
  16066. edges = append(edges, employee.EdgeEmTutorial)
  16067. }
  16068. return edges
  16069. }
  16070. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16071. // was cleared in this mutation.
  16072. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  16073. switch name {
  16074. case employee.EdgeEmWorkExperiences:
  16075. return m.clearedem_work_experiences
  16076. case employee.EdgeEmTutorial:
  16077. return m.clearedem_tutorial
  16078. }
  16079. return false
  16080. }
  16081. // ClearEdge clears the value of the edge with the given name. It returns an error
  16082. // if that edge is not defined in the schema.
  16083. func (m *EmployeeMutation) ClearEdge(name string) error {
  16084. switch name {
  16085. }
  16086. return fmt.Errorf("unknown Employee unique edge %s", name)
  16087. }
  16088. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16089. // It returns an error if the edge is not defined in the schema.
  16090. func (m *EmployeeMutation) ResetEdge(name string) error {
  16091. switch name {
  16092. case employee.EdgeEmWorkExperiences:
  16093. m.ResetEmWorkExperiences()
  16094. return nil
  16095. case employee.EdgeEmTutorial:
  16096. m.ResetEmTutorial()
  16097. return nil
  16098. }
  16099. return fmt.Errorf("unknown Employee edge %s", name)
  16100. }
  16101. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  16102. type EmployeeConfigMutation struct {
  16103. config
  16104. op Op
  16105. typ string
  16106. id *uint64
  16107. created_at *time.Time
  16108. updated_at *time.Time
  16109. deleted_at *time.Time
  16110. stype *string
  16111. title *string
  16112. photo *string
  16113. organization_id *uint64
  16114. addorganization_id *int64
  16115. clearedFields map[string]struct{}
  16116. done bool
  16117. oldValue func(context.Context) (*EmployeeConfig, error)
  16118. predicates []predicate.EmployeeConfig
  16119. }
  16120. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  16121. // employeeconfigOption allows management of the mutation configuration using functional options.
  16122. type employeeconfigOption func(*EmployeeConfigMutation)
  16123. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  16124. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  16125. m := &EmployeeConfigMutation{
  16126. config: c,
  16127. op: op,
  16128. typ: TypeEmployeeConfig,
  16129. clearedFields: make(map[string]struct{}),
  16130. }
  16131. for _, opt := range opts {
  16132. opt(m)
  16133. }
  16134. return m
  16135. }
  16136. // withEmployeeConfigID sets the ID field of the mutation.
  16137. func withEmployeeConfigID(id uint64) employeeconfigOption {
  16138. return func(m *EmployeeConfigMutation) {
  16139. var (
  16140. err error
  16141. once sync.Once
  16142. value *EmployeeConfig
  16143. )
  16144. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  16145. once.Do(func() {
  16146. if m.done {
  16147. err = errors.New("querying old values post mutation is not allowed")
  16148. } else {
  16149. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  16150. }
  16151. })
  16152. return value, err
  16153. }
  16154. m.id = &id
  16155. }
  16156. }
  16157. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  16158. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  16159. return func(m *EmployeeConfigMutation) {
  16160. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  16161. return node, nil
  16162. }
  16163. m.id = &node.ID
  16164. }
  16165. }
  16166. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16167. // executed in a transaction (ent.Tx), a transactional client is returned.
  16168. func (m EmployeeConfigMutation) Client() *Client {
  16169. client := &Client{config: m.config}
  16170. client.init()
  16171. return client
  16172. }
  16173. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16174. // it returns an error otherwise.
  16175. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  16176. if _, ok := m.driver.(*txDriver); !ok {
  16177. return nil, errors.New("ent: mutation is not running in a transaction")
  16178. }
  16179. tx := &Tx{config: m.config}
  16180. tx.init()
  16181. return tx, nil
  16182. }
  16183. // SetID sets the value of the id field. Note that this
  16184. // operation is only accepted on creation of EmployeeConfig entities.
  16185. func (m *EmployeeConfigMutation) SetID(id uint64) {
  16186. m.id = &id
  16187. }
  16188. // ID returns the ID value in the mutation. Note that the ID is only available
  16189. // if it was provided to the builder or after it was returned from the database.
  16190. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  16191. if m.id == nil {
  16192. return
  16193. }
  16194. return *m.id, true
  16195. }
  16196. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16197. // That means, if the mutation is applied within a transaction with an isolation level such
  16198. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16199. // or updated by the mutation.
  16200. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  16201. switch {
  16202. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16203. id, exists := m.ID()
  16204. if exists {
  16205. return []uint64{id}, nil
  16206. }
  16207. fallthrough
  16208. case m.op.Is(OpUpdate | OpDelete):
  16209. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  16210. default:
  16211. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16212. }
  16213. }
  16214. // SetCreatedAt sets the "created_at" field.
  16215. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  16216. m.created_at = &t
  16217. }
  16218. // CreatedAt returns the value of the "created_at" field in the mutation.
  16219. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  16220. v := m.created_at
  16221. if v == nil {
  16222. return
  16223. }
  16224. return *v, true
  16225. }
  16226. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  16227. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16229. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16230. if !m.op.Is(OpUpdateOne) {
  16231. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16232. }
  16233. if m.id == nil || m.oldValue == nil {
  16234. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16235. }
  16236. oldValue, err := m.oldValue(ctx)
  16237. if err != nil {
  16238. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16239. }
  16240. return oldValue.CreatedAt, nil
  16241. }
  16242. // ResetCreatedAt resets all changes to the "created_at" field.
  16243. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  16244. m.created_at = nil
  16245. }
  16246. // SetUpdatedAt sets the "updated_at" field.
  16247. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  16248. m.updated_at = &t
  16249. }
  16250. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16251. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  16252. v := m.updated_at
  16253. if v == nil {
  16254. return
  16255. }
  16256. return *v, true
  16257. }
  16258. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  16259. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16261. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16262. if !m.op.Is(OpUpdateOne) {
  16263. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16264. }
  16265. if m.id == nil || m.oldValue == nil {
  16266. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16267. }
  16268. oldValue, err := m.oldValue(ctx)
  16269. if err != nil {
  16270. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16271. }
  16272. return oldValue.UpdatedAt, nil
  16273. }
  16274. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16275. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  16276. m.updated_at = nil
  16277. }
  16278. // SetDeletedAt sets the "deleted_at" field.
  16279. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  16280. m.deleted_at = &t
  16281. }
  16282. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16283. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  16284. v := m.deleted_at
  16285. if v == nil {
  16286. return
  16287. }
  16288. return *v, true
  16289. }
  16290. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  16291. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16293. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16294. if !m.op.Is(OpUpdateOne) {
  16295. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16296. }
  16297. if m.id == nil || m.oldValue == nil {
  16298. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16299. }
  16300. oldValue, err := m.oldValue(ctx)
  16301. if err != nil {
  16302. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16303. }
  16304. return oldValue.DeletedAt, nil
  16305. }
  16306. // ClearDeletedAt clears the value of the "deleted_at" field.
  16307. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  16308. m.deleted_at = nil
  16309. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  16310. }
  16311. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16312. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  16313. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  16314. return ok
  16315. }
  16316. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16317. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  16318. m.deleted_at = nil
  16319. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  16320. }
  16321. // SetStype sets the "stype" field.
  16322. func (m *EmployeeConfigMutation) SetStype(s string) {
  16323. m.stype = &s
  16324. }
  16325. // Stype returns the value of the "stype" field in the mutation.
  16326. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  16327. v := m.stype
  16328. if v == nil {
  16329. return
  16330. }
  16331. return *v, true
  16332. }
  16333. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  16334. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16336. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  16337. if !m.op.Is(OpUpdateOne) {
  16338. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  16339. }
  16340. if m.id == nil || m.oldValue == nil {
  16341. return v, errors.New("OldStype requires an ID field in the mutation")
  16342. }
  16343. oldValue, err := m.oldValue(ctx)
  16344. if err != nil {
  16345. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  16346. }
  16347. return oldValue.Stype, nil
  16348. }
  16349. // ResetStype resets all changes to the "stype" field.
  16350. func (m *EmployeeConfigMutation) ResetStype() {
  16351. m.stype = nil
  16352. }
  16353. // SetTitle sets the "title" field.
  16354. func (m *EmployeeConfigMutation) SetTitle(s string) {
  16355. m.title = &s
  16356. }
  16357. // Title returns the value of the "title" field in the mutation.
  16358. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  16359. v := m.title
  16360. if v == nil {
  16361. return
  16362. }
  16363. return *v, true
  16364. }
  16365. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  16366. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16368. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  16369. if !m.op.Is(OpUpdateOne) {
  16370. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  16371. }
  16372. if m.id == nil || m.oldValue == nil {
  16373. return v, errors.New("OldTitle requires an ID field in the mutation")
  16374. }
  16375. oldValue, err := m.oldValue(ctx)
  16376. if err != nil {
  16377. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  16378. }
  16379. return oldValue.Title, nil
  16380. }
  16381. // ResetTitle resets all changes to the "title" field.
  16382. func (m *EmployeeConfigMutation) ResetTitle() {
  16383. m.title = nil
  16384. }
  16385. // SetPhoto sets the "photo" field.
  16386. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  16387. m.photo = &s
  16388. }
  16389. // Photo returns the value of the "photo" field in the mutation.
  16390. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  16391. v := m.photo
  16392. if v == nil {
  16393. return
  16394. }
  16395. return *v, true
  16396. }
  16397. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  16398. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16400. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  16401. if !m.op.Is(OpUpdateOne) {
  16402. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  16403. }
  16404. if m.id == nil || m.oldValue == nil {
  16405. return v, errors.New("OldPhoto requires an ID field in the mutation")
  16406. }
  16407. oldValue, err := m.oldValue(ctx)
  16408. if err != nil {
  16409. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  16410. }
  16411. return oldValue.Photo, nil
  16412. }
  16413. // ResetPhoto resets all changes to the "photo" field.
  16414. func (m *EmployeeConfigMutation) ResetPhoto() {
  16415. m.photo = nil
  16416. }
  16417. // SetOrganizationID sets the "organization_id" field.
  16418. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  16419. m.organization_id = &u
  16420. m.addorganization_id = nil
  16421. }
  16422. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16423. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  16424. v := m.organization_id
  16425. if v == nil {
  16426. return
  16427. }
  16428. return *v, true
  16429. }
  16430. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  16431. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16433. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16434. if !m.op.Is(OpUpdateOne) {
  16435. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16436. }
  16437. if m.id == nil || m.oldValue == nil {
  16438. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16439. }
  16440. oldValue, err := m.oldValue(ctx)
  16441. if err != nil {
  16442. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16443. }
  16444. return oldValue.OrganizationID, nil
  16445. }
  16446. // AddOrganizationID adds u to the "organization_id" field.
  16447. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  16448. if m.addorganization_id != nil {
  16449. *m.addorganization_id += u
  16450. } else {
  16451. m.addorganization_id = &u
  16452. }
  16453. }
  16454. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16455. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  16456. v := m.addorganization_id
  16457. if v == nil {
  16458. return
  16459. }
  16460. return *v, true
  16461. }
  16462. // ClearOrganizationID clears the value of the "organization_id" field.
  16463. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  16464. m.organization_id = nil
  16465. m.addorganization_id = nil
  16466. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  16467. }
  16468. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16469. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  16470. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  16471. return ok
  16472. }
  16473. // ResetOrganizationID resets all changes to the "organization_id" field.
  16474. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  16475. m.organization_id = nil
  16476. m.addorganization_id = nil
  16477. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  16478. }
  16479. // Where appends a list predicates to the EmployeeConfigMutation builder.
  16480. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  16481. m.predicates = append(m.predicates, ps...)
  16482. }
  16483. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  16484. // users can use type-assertion to append predicates that do not depend on any generated package.
  16485. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  16486. p := make([]predicate.EmployeeConfig, len(ps))
  16487. for i := range ps {
  16488. p[i] = ps[i]
  16489. }
  16490. m.Where(p...)
  16491. }
  16492. // Op returns the operation name.
  16493. func (m *EmployeeConfigMutation) Op() Op {
  16494. return m.op
  16495. }
  16496. // SetOp allows setting the mutation operation.
  16497. func (m *EmployeeConfigMutation) SetOp(op Op) {
  16498. m.op = op
  16499. }
  16500. // Type returns the node type of this mutation (EmployeeConfig).
  16501. func (m *EmployeeConfigMutation) Type() string {
  16502. return m.typ
  16503. }
  16504. // Fields returns all fields that were changed during this mutation. Note that in
  16505. // order to get all numeric fields that were incremented/decremented, call
  16506. // AddedFields().
  16507. func (m *EmployeeConfigMutation) Fields() []string {
  16508. fields := make([]string, 0, 7)
  16509. if m.created_at != nil {
  16510. fields = append(fields, employeeconfig.FieldCreatedAt)
  16511. }
  16512. if m.updated_at != nil {
  16513. fields = append(fields, employeeconfig.FieldUpdatedAt)
  16514. }
  16515. if m.deleted_at != nil {
  16516. fields = append(fields, employeeconfig.FieldDeletedAt)
  16517. }
  16518. if m.stype != nil {
  16519. fields = append(fields, employeeconfig.FieldStype)
  16520. }
  16521. if m.title != nil {
  16522. fields = append(fields, employeeconfig.FieldTitle)
  16523. }
  16524. if m.photo != nil {
  16525. fields = append(fields, employeeconfig.FieldPhoto)
  16526. }
  16527. if m.organization_id != nil {
  16528. fields = append(fields, employeeconfig.FieldOrganizationID)
  16529. }
  16530. return fields
  16531. }
  16532. // Field returns the value of a field with the given name. The second boolean
  16533. // return value indicates that this field was not set, or was not defined in the
  16534. // schema.
  16535. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  16536. switch name {
  16537. case employeeconfig.FieldCreatedAt:
  16538. return m.CreatedAt()
  16539. case employeeconfig.FieldUpdatedAt:
  16540. return m.UpdatedAt()
  16541. case employeeconfig.FieldDeletedAt:
  16542. return m.DeletedAt()
  16543. case employeeconfig.FieldStype:
  16544. return m.Stype()
  16545. case employeeconfig.FieldTitle:
  16546. return m.Title()
  16547. case employeeconfig.FieldPhoto:
  16548. return m.Photo()
  16549. case employeeconfig.FieldOrganizationID:
  16550. return m.OrganizationID()
  16551. }
  16552. return nil, false
  16553. }
  16554. // OldField returns the old value of the field from the database. An error is
  16555. // returned if the mutation operation is not UpdateOne, or the query to the
  16556. // database failed.
  16557. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16558. switch name {
  16559. case employeeconfig.FieldCreatedAt:
  16560. return m.OldCreatedAt(ctx)
  16561. case employeeconfig.FieldUpdatedAt:
  16562. return m.OldUpdatedAt(ctx)
  16563. case employeeconfig.FieldDeletedAt:
  16564. return m.OldDeletedAt(ctx)
  16565. case employeeconfig.FieldStype:
  16566. return m.OldStype(ctx)
  16567. case employeeconfig.FieldTitle:
  16568. return m.OldTitle(ctx)
  16569. case employeeconfig.FieldPhoto:
  16570. return m.OldPhoto(ctx)
  16571. case employeeconfig.FieldOrganizationID:
  16572. return m.OldOrganizationID(ctx)
  16573. }
  16574. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  16575. }
  16576. // SetField sets the value of a field with the given name. It returns an error if
  16577. // the field is not defined in the schema, or if the type mismatched the field
  16578. // type.
  16579. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  16580. switch name {
  16581. case employeeconfig.FieldCreatedAt:
  16582. v, ok := value.(time.Time)
  16583. if !ok {
  16584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16585. }
  16586. m.SetCreatedAt(v)
  16587. return nil
  16588. case employeeconfig.FieldUpdatedAt:
  16589. v, ok := value.(time.Time)
  16590. if !ok {
  16591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16592. }
  16593. m.SetUpdatedAt(v)
  16594. return nil
  16595. case employeeconfig.FieldDeletedAt:
  16596. v, ok := value.(time.Time)
  16597. if !ok {
  16598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16599. }
  16600. m.SetDeletedAt(v)
  16601. return nil
  16602. case employeeconfig.FieldStype:
  16603. v, ok := value.(string)
  16604. if !ok {
  16605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16606. }
  16607. m.SetStype(v)
  16608. return nil
  16609. case employeeconfig.FieldTitle:
  16610. v, ok := value.(string)
  16611. if !ok {
  16612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16613. }
  16614. m.SetTitle(v)
  16615. return nil
  16616. case employeeconfig.FieldPhoto:
  16617. v, ok := value.(string)
  16618. if !ok {
  16619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16620. }
  16621. m.SetPhoto(v)
  16622. return nil
  16623. case employeeconfig.FieldOrganizationID:
  16624. v, ok := value.(uint64)
  16625. if !ok {
  16626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16627. }
  16628. m.SetOrganizationID(v)
  16629. return nil
  16630. }
  16631. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  16632. }
  16633. // AddedFields returns all numeric fields that were incremented/decremented during
  16634. // this mutation.
  16635. func (m *EmployeeConfigMutation) AddedFields() []string {
  16636. var fields []string
  16637. if m.addorganization_id != nil {
  16638. fields = append(fields, employeeconfig.FieldOrganizationID)
  16639. }
  16640. return fields
  16641. }
  16642. // AddedField returns the numeric value that was incremented/decremented on a field
  16643. // with the given name. The second boolean return value indicates that this field
  16644. // was not set, or was not defined in the schema.
  16645. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  16646. switch name {
  16647. case employeeconfig.FieldOrganizationID:
  16648. return m.AddedOrganizationID()
  16649. }
  16650. return nil, false
  16651. }
  16652. // AddField adds the value to the field with the given name. It returns an error if
  16653. // the field is not defined in the schema, or if the type mismatched the field
  16654. // type.
  16655. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  16656. switch name {
  16657. case employeeconfig.FieldOrganizationID:
  16658. v, ok := value.(int64)
  16659. if !ok {
  16660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16661. }
  16662. m.AddOrganizationID(v)
  16663. return nil
  16664. }
  16665. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  16666. }
  16667. // ClearedFields returns all nullable fields that were cleared during this
  16668. // mutation.
  16669. func (m *EmployeeConfigMutation) ClearedFields() []string {
  16670. var fields []string
  16671. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  16672. fields = append(fields, employeeconfig.FieldDeletedAt)
  16673. }
  16674. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  16675. fields = append(fields, employeeconfig.FieldOrganizationID)
  16676. }
  16677. return fields
  16678. }
  16679. // FieldCleared returns a boolean indicating if a field with the given name was
  16680. // cleared in this mutation.
  16681. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  16682. _, ok := m.clearedFields[name]
  16683. return ok
  16684. }
  16685. // ClearField clears the value of the field with the given name. It returns an
  16686. // error if the field is not defined in the schema.
  16687. func (m *EmployeeConfigMutation) ClearField(name string) error {
  16688. switch name {
  16689. case employeeconfig.FieldDeletedAt:
  16690. m.ClearDeletedAt()
  16691. return nil
  16692. case employeeconfig.FieldOrganizationID:
  16693. m.ClearOrganizationID()
  16694. return nil
  16695. }
  16696. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  16697. }
  16698. // ResetField resets all changes in the mutation for the field with the given name.
  16699. // It returns an error if the field is not defined in the schema.
  16700. func (m *EmployeeConfigMutation) ResetField(name string) error {
  16701. switch name {
  16702. case employeeconfig.FieldCreatedAt:
  16703. m.ResetCreatedAt()
  16704. return nil
  16705. case employeeconfig.FieldUpdatedAt:
  16706. m.ResetUpdatedAt()
  16707. return nil
  16708. case employeeconfig.FieldDeletedAt:
  16709. m.ResetDeletedAt()
  16710. return nil
  16711. case employeeconfig.FieldStype:
  16712. m.ResetStype()
  16713. return nil
  16714. case employeeconfig.FieldTitle:
  16715. m.ResetTitle()
  16716. return nil
  16717. case employeeconfig.FieldPhoto:
  16718. m.ResetPhoto()
  16719. return nil
  16720. case employeeconfig.FieldOrganizationID:
  16721. m.ResetOrganizationID()
  16722. return nil
  16723. }
  16724. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  16725. }
  16726. // AddedEdges returns all edge names that were set/added in this mutation.
  16727. func (m *EmployeeConfigMutation) AddedEdges() []string {
  16728. edges := make([]string, 0, 0)
  16729. return edges
  16730. }
  16731. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16732. // name in this mutation.
  16733. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  16734. return nil
  16735. }
  16736. // RemovedEdges returns all edge names that were removed in this mutation.
  16737. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  16738. edges := make([]string, 0, 0)
  16739. return edges
  16740. }
  16741. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16742. // the given name in this mutation.
  16743. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  16744. return nil
  16745. }
  16746. // ClearedEdges returns all edge names that were cleared in this mutation.
  16747. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  16748. edges := make([]string, 0, 0)
  16749. return edges
  16750. }
  16751. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16752. // was cleared in this mutation.
  16753. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  16754. return false
  16755. }
  16756. // ClearEdge clears the value of the edge with the given name. It returns an error
  16757. // if that edge is not defined in the schema.
  16758. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  16759. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  16760. }
  16761. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16762. // It returns an error if the edge is not defined in the schema.
  16763. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  16764. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  16765. }
  16766. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  16767. type LabelMutation struct {
  16768. config
  16769. op Op
  16770. typ string
  16771. id *uint64
  16772. created_at *time.Time
  16773. updated_at *time.Time
  16774. status *uint8
  16775. addstatus *int8
  16776. _type *int
  16777. add_type *int
  16778. name *string
  16779. from *int
  16780. addfrom *int
  16781. mode *int
  16782. addmode *int
  16783. conditions *string
  16784. organization_id *uint64
  16785. addorganization_id *int64
  16786. clearedFields map[string]struct{}
  16787. label_relationships map[uint64]struct{}
  16788. removedlabel_relationships map[uint64]struct{}
  16789. clearedlabel_relationships bool
  16790. done bool
  16791. oldValue func(context.Context) (*Label, error)
  16792. predicates []predicate.Label
  16793. }
  16794. var _ ent.Mutation = (*LabelMutation)(nil)
  16795. // labelOption allows management of the mutation configuration using functional options.
  16796. type labelOption func(*LabelMutation)
  16797. // newLabelMutation creates new mutation for the Label entity.
  16798. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  16799. m := &LabelMutation{
  16800. config: c,
  16801. op: op,
  16802. typ: TypeLabel,
  16803. clearedFields: make(map[string]struct{}),
  16804. }
  16805. for _, opt := range opts {
  16806. opt(m)
  16807. }
  16808. return m
  16809. }
  16810. // withLabelID sets the ID field of the mutation.
  16811. func withLabelID(id uint64) labelOption {
  16812. return func(m *LabelMutation) {
  16813. var (
  16814. err error
  16815. once sync.Once
  16816. value *Label
  16817. )
  16818. m.oldValue = func(ctx context.Context) (*Label, error) {
  16819. once.Do(func() {
  16820. if m.done {
  16821. err = errors.New("querying old values post mutation is not allowed")
  16822. } else {
  16823. value, err = m.Client().Label.Get(ctx, id)
  16824. }
  16825. })
  16826. return value, err
  16827. }
  16828. m.id = &id
  16829. }
  16830. }
  16831. // withLabel sets the old Label of the mutation.
  16832. func withLabel(node *Label) labelOption {
  16833. return func(m *LabelMutation) {
  16834. m.oldValue = func(context.Context) (*Label, error) {
  16835. return node, nil
  16836. }
  16837. m.id = &node.ID
  16838. }
  16839. }
  16840. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16841. // executed in a transaction (ent.Tx), a transactional client is returned.
  16842. func (m LabelMutation) Client() *Client {
  16843. client := &Client{config: m.config}
  16844. client.init()
  16845. return client
  16846. }
  16847. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16848. // it returns an error otherwise.
  16849. func (m LabelMutation) Tx() (*Tx, error) {
  16850. if _, ok := m.driver.(*txDriver); !ok {
  16851. return nil, errors.New("ent: mutation is not running in a transaction")
  16852. }
  16853. tx := &Tx{config: m.config}
  16854. tx.init()
  16855. return tx, nil
  16856. }
  16857. // SetID sets the value of the id field. Note that this
  16858. // operation is only accepted on creation of Label entities.
  16859. func (m *LabelMutation) SetID(id uint64) {
  16860. m.id = &id
  16861. }
  16862. // ID returns the ID value in the mutation. Note that the ID is only available
  16863. // if it was provided to the builder or after it was returned from the database.
  16864. func (m *LabelMutation) ID() (id uint64, exists bool) {
  16865. if m.id == nil {
  16866. return
  16867. }
  16868. return *m.id, true
  16869. }
  16870. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16871. // That means, if the mutation is applied within a transaction with an isolation level such
  16872. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16873. // or updated by the mutation.
  16874. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  16875. switch {
  16876. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16877. id, exists := m.ID()
  16878. if exists {
  16879. return []uint64{id}, nil
  16880. }
  16881. fallthrough
  16882. case m.op.Is(OpUpdate | OpDelete):
  16883. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  16884. default:
  16885. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16886. }
  16887. }
  16888. // SetCreatedAt sets the "created_at" field.
  16889. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  16890. m.created_at = &t
  16891. }
  16892. // CreatedAt returns the value of the "created_at" field in the mutation.
  16893. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  16894. v := m.created_at
  16895. if v == nil {
  16896. return
  16897. }
  16898. return *v, true
  16899. }
  16900. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  16901. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16903. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16904. if !m.op.Is(OpUpdateOne) {
  16905. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16906. }
  16907. if m.id == nil || m.oldValue == nil {
  16908. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16909. }
  16910. oldValue, err := m.oldValue(ctx)
  16911. if err != nil {
  16912. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16913. }
  16914. return oldValue.CreatedAt, nil
  16915. }
  16916. // ResetCreatedAt resets all changes to the "created_at" field.
  16917. func (m *LabelMutation) ResetCreatedAt() {
  16918. m.created_at = nil
  16919. }
  16920. // SetUpdatedAt sets the "updated_at" field.
  16921. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  16922. m.updated_at = &t
  16923. }
  16924. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16925. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  16926. v := m.updated_at
  16927. if v == nil {
  16928. return
  16929. }
  16930. return *v, true
  16931. }
  16932. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  16933. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16935. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16936. if !m.op.Is(OpUpdateOne) {
  16937. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16938. }
  16939. if m.id == nil || m.oldValue == nil {
  16940. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16941. }
  16942. oldValue, err := m.oldValue(ctx)
  16943. if err != nil {
  16944. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16945. }
  16946. return oldValue.UpdatedAt, nil
  16947. }
  16948. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16949. func (m *LabelMutation) ResetUpdatedAt() {
  16950. m.updated_at = nil
  16951. }
  16952. // SetStatus sets the "status" field.
  16953. func (m *LabelMutation) SetStatus(u uint8) {
  16954. m.status = &u
  16955. m.addstatus = nil
  16956. }
  16957. // Status returns the value of the "status" field in the mutation.
  16958. func (m *LabelMutation) Status() (r uint8, exists bool) {
  16959. v := m.status
  16960. if v == nil {
  16961. return
  16962. }
  16963. return *v, true
  16964. }
  16965. // OldStatus returns the old "status" field's value of the Label entity.
  16966. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16968. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16969. if !m.op.Is(OpUpdateOne) {
  16970. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16971. }
  16972. if m.id == nil || m.oldValue == nil {
  16973. return v, errors.New("OldStatus requires an ID field in the mutation")
  16974. }
  16975. oldValue, err := m.oldValue(ctx)
  16976. if err != nil {
  16977. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16978. }
  16979. return oldValue.Status, nil
  16980. }
  16981. // AddStatus adds u to the "status" field.
  16982. func (m *LabelMutation) AddStatus(u int8) {
  16983. if m.addstatus != nil {
  16984. *m.addstatus += u
  16985. } else {
  16986. m.addstatus = &u
  16987. }
  16988. }
  16989. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16990. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  16991. v := m.addstatus
  16992. if v == nil {
  16993. return
  16994. }
  16995. return *v, true
  16996. }
  16997. // ClearStatus clears the value of the "status" field.
  16998. func (m *LabelMutation) ClearStatus() {
  16999. m.status = nil
  17000. m.addstatus = nil
  17001. m.clearedFields[label.FieldStatus] = struct{}{}
  17002. }
  17003. // StatusCleared returns if the "status" field was cleared in this mutation.
  17004. func (m *LabelMutation) StatusCleared() bool {
  17005. _, ok := m.clearedFields[label.FieldStatus]
  17006. return ok
  17007. }
  17008. // ResetStatus resets all changes to the "status" field.
  17009. func (m *LabelMutation) ResetStatus() {
  17010. m.status = nil
  17011. m.addstatus = nil
  17012. delete(m.clearedFields, label.FieldStatus)
  17013. }
  17014. // SetType sets the "type" field.
  17015. func (m *LabelMutation) SetType(i int) {
  17016. m._type = &i
  17017. m.add_type = nil
  17018. }
  17019. // GetType returns the value of the "type" field in the mutation.
  17020. func (m *LabelMutation) GetType() (r int, exists bool) {
  17021. v := m._type
  17022. if v == nil {
  17023. return
  17024. }
  17025. return *v, true
  17026. }
  17027. // OldType returns the old "type" field's value of the Label entity.
  17028. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17030. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  17031. if !m.op.Is(OpUpdateOne) {
  17032. return v, errors.New("OldType is only allowed on UpdateOne operations")
  17033. }
  17034. if m.id == nil || m.oldValue == nil {
  17035. return v, errors.New("OldType requires an ID field in the mutation")
  17036. }
  17037. oldValue, err := m.oldValue(ctx)
  17038. if err != nil {
  17039. return v, fmt.Errorf("querying old value for OldType: %w", err)
  17040. }
  17041. return oldValue.Type, nil
  17042. }
  17043. // AddType adds i to the "type" field.
  17044. func (m *LabelMutation) AddType(i int) {
  17045. if m.add_type != nil {
  17046. *m.add_type += i
  17047. } else {
  17048. m.add_type = &i
  17049. }
  17050. }
  17051. // AddedType returns the value that was added to the "type" field in this mutation.
  17052. func (m *LabelMutation) AddedType() (r int, exists bool) {
  17053. v := m.add_type
  17054. if v == nil {
  17055. return
  17056. }
  17057. return *v, true
  17058. }
  17059. // ResetType resets all changes to the "type" field.
  17060. func (m *LabelMutation) ResetType() {
  17061. m._type = nil
  17062. m.add_type = nil
  17063. }
  17064. // SetName sets the "name" field.
  17065. func (m *LabelMutation) SetName(s string) {
  17066. m.name = &s
  17067. }
  17068. // Name returns the value of the "name" field in the mutation.
  17069. func (m *LabelMutation) Name() (r string, exists bool) {
  17070. v := m.name
  17071. if v == nil {
  17072. return
  17073. }
  17074. return *v, true
  17075. }
  17076. // OldName returns the old "name" field's value of the Label entity.
  17077. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17079. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  17080. if !m.op.Is(OpUpdateOne) {
  17081. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17082. }
  17083. if m.id == nil || m.oldValue == nil {
  17084. return v, errors.New("OldName requires an ID field in the mutation")
  17085. }
  17086. oldValue, err := m.oldValue(ctx)
  17087. if err != nil {
  17088. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17089. }
  17090. return oldValue.Name, nil
  17091. }
  17092. // ResetName resets all changes to the "name" field.
  17093. func (m *LabelMutation) ResetName() {
  17094. m.name = nil
  17095. }
  17096. // SetFrom sets the "from" field.
  17097. func (m *LabelMutation) SetFrom(i int) {
  17098. m.from = &i
  17099. m.addfrom = nil
  17100. }
  17101. // From returns the value of the "from" field in the mutation.
  17102. func (m *LabelMutation) From() (r int, exists bool) {
  17103. v := m.from
  17104. if v == nil {
  17105. return
  17106. }
  17107. return *v, true
  17108. }
  17109. // OldFrom returns the old "from" field's value of the Label entity.
  17110. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17112. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  17113. if !m.op.Is(OpUpdateOne) {
  17114. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  17115. }
  17116. if m.id == nil || m.oldValue == nil {
  17117. return v, errors.New("OldFrom requires an ID field in the mutation")
  17118. }
  17119. oldValue, err := m.oldValue(ctx)
  17120. if err != nil {
  17121. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  17122. }
  17123. return oldValue.From, nil
  17124. }
  17125. // AddFrom adds i to the "from" field.
  17126. func (m *LabelMutation) AddFrom(i int) {
  17127. if m.addfrom != nil {
  17128. *m.addfrom += i
  17129. } else {
  17130. m.addfrom = &i
  17131. }
  17132. }
  17133. // AddedFrom returns the value that was added to the "from" field in this mutation.
  17134. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  17135. v := m.addfrom
  17136. if v == nil {
  17137. return
  17138. }
  17139. return *v, true
  17140. }
  17141. // ResetFrom resets all changes to the "from" field.
  17142. func (m *LabelMutation) ResetFrom() {
  17143. m.from = nil
  17144. m.addfrom = nil
  17145. }
  17146. // SetMode sets the "mode" field.
  17147. func (m *LabelMutation) SetMode(i int) {
  17148. m.mode = &i
  17149. m.addmode = nil
  17150. }
  17151. // Mode returns the value of the "mode" field in the mutation.
  17152. func (m *LabelMutation) Mode() (r int, exists bool) {
  17153. v := m.mode
  17154. if v == nil {
  17155. return
  17156. }
  17157. return *v, true
  17158. }
  17159. // OldMode returns the old "mode" field's value of the Label entity.
  17160. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17162. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  17163. if !m.op.Is(OpUpdateOne) {
  17164. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  17165. }
  17166. if m.id == nil || m.oldValue == nil {
  17167. return v, errors.New("OldMode requires an ID field in the mutation")
  17168. }
  17169. oldValue, err := m.oldValue(ctx)
  17170. if err != nil {
  17171. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  17172. }
  17173. return oldValue.Mode, nil
  17174. }
  17175. // AddMode adds i to the "mode" field.
  17176. func (m *LabelMutation) AddMode(i int) {
  17177. if m.addmode != nil {
  17178. *m.addmode += i
  17179. } else {
  17180. m.addmode = &i
  17181. }
  17182. }
  17183. // AddedMode returns the value that was added to the "mode" field in this mutation.
  17184. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  17185. v := m.addmode
  17186. if v == nil {
  17187. return
  17188. }
  17189. return *v, true
  17190. }
  17191. // ResetMode resets all changes to the "mode" field.
  17192. func (m *LabelMutation) ResetMode() {
  17193. m.mode = nil
  17194. m.addmode = nil
  17195. }
  17196. // SetConditions sets the "conditions" field.
  17197. func (m *LabelMutation) SetConditions(s string) {
  17198. m.conditions = &s
  17199. }
  17200. // Conditions returns the value of the "conditions" field in the mutation.
  17201. func (m *LabelMutation) Conditions() (r string, exists bool) {
  17202. v := m.conditions
  17203. if v == nil {
  17204. return
  17205. }
  17206. return *v, true
  17207. }
  17208. // OldConditions returns the old "conditions" field's value of the Label entity.
  17209. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17211. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  17212. if !m.op.Is(OpUpdateOne) {
  17213. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  17214. }
  17215. if m.id == nil || m.oldValue == nil {
  17216. return v, errors.New("OldConditions requires an ID field in the mutation")
  17217. }
  17218. oldValue, err := m.oldValue(ctx)
  17219. if err != nil {
  17220. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  17221. }
  17222. return oldValue.Conditions, nil
  17223. }
  17224. // ClearConditions clears the value of the "conditions" field.
  17225. func (m *LabelMutation) ClearConditions() {
  17226. m.conditions = nil
  17227. m.clearedFields[label.FieldConditions] = struct{}{}
  17228. }
  17229. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  17230. func (m *LabelMutation) ConditionsCleared() bool {
  17231. _, ok := m.clearedFields[label.FieldConditions]
  17232. return ok
  17233. }
  17234. // ResetConditions resets all changes to the "conditions" field.
  17235. func (m *LabelMutation) ResetConditions() {
  17236. m.conditions = nil
  17237. delete(m.clearedFields, label.FieldConditions)
  17238. }
  17239. // SetOrganizationID sets the "organization_id" field.
  17240. func (m *LabelMutation) SetOrganizationID(u uint64) {
  17241. m.organization_id = &u
  17242. m.addorganization_id = nil
  17243. }
  17244. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17245. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  17246. v := m.organization_id
  17247. if v == nil {
  17248. return
  17249. }
  17250. return *v, true
  17251. }
  17252. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  17253. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17255. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17256. if !m.op.Is(OpUpdateOne) {
  17257. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17258. }
  17259. if m.id == nil || m.oldValue == nil {
  17260. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17261. }
  17262. oldValue, err := m.oldValue(ctx)
  17263. if err != nil {
  17264. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17265. }
  17266. return oldValue.OrganizationID, nil
  17267. }
  17268. // AddOrganizationID adds u to the "organization_id" field.
  17269. func (m *LabelMutation) AddOrganizationID(u int64) {
  17270. if m.addorganization_id != nil {
  17271. *m.addorganization_id += u
  17272. } else {
  17273. m.addorganization_id = &u
  17274. }
  17275. }
  17276. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17277. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  17278. v := m.addorganization_id
  17279. if v == nil {
  17280. return
  17281. }
  17282. return *v, true
  17283. }
  17284. // ClearOrganizationID clears the value of the "organization_id" field.
  17285. func (m *LabelMutation) ClearOrganizationID() {
  17286. m.organization_id = nil
  17287. m.addorganization_id = nil
  17288. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  17289. }
  17290. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17291. func (m *LabelMutation) OrganizationIDCleared() bool {
  17292. _, ok := m.clearedFields[label.FieldOrganizationID]
  17293. return ok
  17294. }
  17295. // ResetOrganizationID resets all changes to the "organization_id" field.
  17296. func (m *LabelMutation) ResetOrganizationID() {
  17297. m.organization_id = nil
  17298. m.addorganization_id = nil
  17299. delete(m.clearedFields, label.FieldOrganizationID)
  17300. }
  17301. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  17302. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  17303. if m.label_relationships == nil {
  17304. m.label_relationships = make(map[uint64]struct{})
  17305. }
  17306. for i := range ids {
  17307. m.label_relationships[ids[i]] = struct{}{}
  17308. }
  17309. }
  17310. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  17311. func (m *LabelMutation) ClearLabelRelationships() {
  17312. m.clearedlabel_relationships = true
  17313. }
  17314. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  17315. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  17316. return m.clearedlabel_relationships
  17317. }
  17318. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  17319. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  17320. if m.removedlabel_relationships == nil {
  17321. m.removedlabel_relationships = make(map[uint64]struct{})
  17322. }
  17323. for i := range ids {
  17324. delete(m.label_relationships, ids[i])
  17325. m.removedlabel_relationships[ids[i]] = struct{}{}
  17326. }
  17327. }
  17328. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  17329. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  17330. for id := range m.removedlabel_relationships {
  17331. ids = append(ids, id)
  17332. }
  17333. return
  17334. }
  17335. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  17336. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  17337. for id := range m.label_relationships {
  17338. ids = append(ids, id)
  17339. }
  17340. return
  17341. }
  17342. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  17343. func (m *LabelMutation) ResetLabelRelationships() {
  17344. m.label_relationships = nil
  17345. m.clearedlabel_relationships = false
  17346. m.removedlabel_relationships = nil
  17347. }
  17348. // Where appends a list predicates to the LabelMutation builder.
  17349. func (m *LabelMutation) Where(ps ...predicate.Label) {
  17350. m.predicates = append(m.predicates, ps...)
  17351. }
  17352. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  17353. // users can use type-assertion to append predicates that do not depend on any generated package.
  17354. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  17355. p := make([]predicate.Label, len(ps))
  17356. for i := range ps {
  17357. p[i] = ps[i]
  17358. }
  17359. m.Where(p...)
  17360. }
  17361. // Op returns the operation name.
  17362. func (m *LabelMutation) Op() Op {
  17363. return m.op
  17364. }
  17365. // SetOp allows setting the mutation operation.
  17366. func (m *LabelMutation) SetOp(op Op) {
  17367. m.op = op
  17368. }
  17369. // Type returns the node type of this mutation (Label).
  17370. func (m *LabelMutation) Type() string {
  17371. return m.typ
  17372. }
  17373. // Fields returns all fields that were changed during this mutation. Note that in
  17374. // order to get all numeric fields that were incremented/decremented, call
  17375. // AddedFields().
  17376. func (m *LabelMutation) Fields() []string {
  17377. fields := make([]string, 0, 9)
  17378. if m.created_at != nil {
  17379. fields = append(fields, label.FieldCreatedAt)
  17380. }
  17381. if m.updated_at != nil {
  17382. fields = append(fields, label.FieldUpdatedAt)
  17383. }
  17384. if m.status != nil {
  17385. fields = append(fields, label.FieldStatus)
  17386. }
  17387. if m._type != nil {
  17388. fields = append(fields, label.FieldType)
  17389. }
  17390. if m.name != nil {
  17391. fields = append(fields, label.FieldName)
  17392. }
  17393. if m.from != nil {
  17394. fields = append(fields, label.FieldFrom)
  17395. }
  17396. if m.mode != nil {
  17397. fields = append(fields, label.FieldMode)
  17398. }
  17399. if m.conditions != nil {
  17400. fields = append(fields, label.FieldConditions)
  17401. }
  17402. if m.organization_id != nil {
  17403. fields = append(fields, label.FieldOrganizationID)
  17404. }
  17405. return fields
  17406. }
  17407. // Field returns the value of a field with the given name. The second boolean
  17408. // return value indicates that this field was not set, or was not defined in the
  17409. // schema.
  17410. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  17411. switch name {
  17412. case label.FieldCreatedAt:
  17413. return m.CreatedAt()
  17414. case label.FieldUpdatedAt:
  17415. return m.UpdatedAt()
  17416. case label.FieldStatus:
  17417. return m.Status()
  17418. case label.FieldType:
  17419. return m.GetType()
  17420. case label.FieldName:
  17421. return m.Name()
  17422. case label.FieldFrom:
  17423. return m.From()
  17424. case label.FieldMode:
  17425. return m.Mode()
  17426. case label.FieldConditions:
  17427. return m.Conditions()
  17428. case label.FieldOrganizationID:
  17429. return m.OrganizationID()
  17430. }
  17431. return nil, false
  17432. }
  17433. // OldField returns the old value of the field from the database. An error is
  17434. // returned if the mutation operation is not UpdateOne, or the query to the
  17435. // database failed.
  17436. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17437. switch name {
  17438. case label.FieldCreatedAt:
  17439. return m.OldCreatedAt(ctx)
  17440. case label.FieldUpdatedAt:
  17441. return m.OldUpdatedAt(ctx)
  17442. case label.FieldStatus:
  17443. return m.OldStatus(ctx)
  17444. case label.FieldType:
  17445. return m.OldType(ctx)
  17446. case label.FieldName:
  17447. return m.OldName(ctx)
  17448. case label.FieldFrom:
  17449. return m.OldFrom(ctx)
  17450. case label.FieldMode:
  17451. return m.OldMode(ctx)
  17452. case label.FieldConditions:
  17453. return m.OldConditions(ctx)
  17454. case label.FieldOrganizationID:
  17455. return m.OldOrganizationID(ctx)
  17456. }
  17457. return nil, fmt.Errorf("unknown Label field %s", name)
  17458. }
  17459. // SetField sets the value of a field with the given name. It returns an error if
  17460. // the field is not defined in the schema, or if the type mismatched the field
  17461. // type.
  17462. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  17463. switch name {
  17464. case label.FieldCreatedAt:
  17465. v, ok := value.(time.Time)
  17466. if !ok {
  17467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17468. }
  17469. m.SetCreatedAt(v)
  17470. return nil
  17471. case label.FieldUpdatedAt:
  17472. v, ok := value.(time.Time)
  17473. if !ok {
  17474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17475. }
  17476. m.SetUpdatedAt(v)
  17477. return nil
  17478. case label.FieldStatus:
  17479. v, ok := value.(uint8)
  17480. if !ok {
  17481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17482. }
  17483. m.SetStatus(v)
  17484. return nil
  17485. case label.FieldType:
  17486. v, ok := value.(int)
  17487. if !ok {
  17488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17489. }
  17490. m.SetType(v)
  17491. return nil
  17492. case label.FieldName:
  17493. v, ok := value.(string)
  17494. if !ok {
  17495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17496. }
  17497. m.SetName(v)
  17498. return nil
  17499. case label.FieldFrom:
  17500. v, ok := value.(int)
  17501. if !ok {
  17502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17503. }
  17504. m.SetFrom(v)
  17505. return nil
  17506. case label.FieldMode:
  17507. v, ok := value.(int)
  17508. if !ok {
  17509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17510. }
  17511. m.SetMode(v)
  17512. return nil
  17513. case label.FieldConditions:
  17514. v, ok := value.(string)
  17515. if !ok {
  17516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17517. }
  17518. m.SetConditions(v)
  17519. return nil
  17520. case label.FieldOrganizationID:
  17521. v, ok := value.(uint64)
  17522. if !ok {
  17523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17524. }
  17525. m.SetOrganizationID(v)
  17526. return nil
  17527. }
  17528. return fmt.Errorf("unknown Label field %s", name)
  17529. }
  17530. // AddedFields returns all numeric fields that were incremented/decremented during
  17531. // this mutation.
  17532. func (m *LabelMutation) AddedFields() []string {
  17533. var fields []string
  17534. if m.addstatus != nil {
  17535. fields = append(fields, label.FieldStatus)
  17536. }
  17537. if m.add_type != nil {
  17538. fields = append(fields, label.FieldType)
  17539. }
  17540. if m.addfrom != nil {
  17541. fields = append(fields, label.FieldFrom)
  17542. }
  17543. if m.addmode != nil {
  17544. fields = append(fields, label.FieldMode)
  17545. }
  17546. if m.addorganization_id != nil {
  17547. fields = append(fields, label.FieldOrganizationID)
  17548. }
  17549. return fields
  17550. }
  17551. // AddedField returns the numeric value that was incremented/decremented on a field
  17552. // with the given name. The second boolean return value indicates that this field
  17553. // was not set, or was not defined in the schema.
  17554. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  17555. switch name {
  17556. case label.FieldStatus:
  17557. return m.AddedStatus()
  17558. case label.FieldType:
  17559. return m.AddedType()
  17560. case label.FieldFrom:
  17561. return m.AddedFrom()
  17562. case label.FieldMode:
  17563. return m.AddedMode()
  17564. case label.FieldOrganizationID:
  17565. return m.AddedOrganizationID()
  17566. }
  17567. return nil, false
  17568. }
  17569. // AddField adds the value to the field with the given name. It returns an error if
  17570. // the field is not defined in the schema, or if the type mismatched the field
  17571. // type.
  17572. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  17573. switch name {
  17574. case label.FieldStatus:
  17575. v, ok := value.(int8)
  17576. if !ok {
  17577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17578. }
  17579. m.AddStatus(v)
  17580. return nil
  17581. case label.FieldType:
  17582. v, ok := value.(int)
  17583. if !ok {
  17584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17585. }
  17586. m.AddType(v)
  17587. return nil
  17588. case label.FieldFrom:
  17589. v, ok := value.(int)
  17590. if !ok {
  17591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17592. }
  17593. m.AddFrom(v)
  17594. return nil
  17595. case label.FieldMode:
  17596. v, ok := value.(int)
  17597. if !ok {
  17598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17599. }
  17600. m.AddMode(v)
  17601. return nil
  17602. case label.FieldOrganizationID:
  17603. v, ok := value.(int64)
  17604. if !ok {
  17605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17606. }
  17607. m.AddOrganizationID(v)
  17608. return nil
  17609. }
  17610. return fmt.Errorf("unknown Label numeric field %s", name)
  17611. }
  17612. // ClearedFields returns all nullable fields that were cleared during this
  17613. // mutation.
  17614. func (m *LabelMutation) ClearedFields() []string {
  17615. var fields []string
  17616. if m.FieldCleared(label.FieldStatus) {
  17617. fields = append(fields, label.FieldStatus)
  17618. }
  17619. if m.FieldCleared(label.FieldConditions) {
  17620. fields = append(fields, label.FieldConditions)
  17621. }
  17622. if m.FieldCleared(label.FieldOrganizationID) {
  17623. fields = append(fields, label.FieldOrganizationID)
  17624. }
  17625. return fields
  17626. }
  17627. // FieldCleared returns a boolean indicating if a field with the given name was
  17628. // cleared in this mutation.
  17629. func (m *LabelMutation) FieldCleared(name string) bool {
  17630. _, ok := m.clearedFields[name]
  17631. return ok
  17632. }
  17633. // ClearField clears the value of the field with the given name. It returns an
  17634. // error if the field is not defined in the schema.
  17635. func (m *LabelMutation) ClearField(name string) error {
  17636. switch name {
  17637. case label.FieldStatus:
  17638. m.ClearStatus()
  17639. return nil
  17640. case label.FieldConditions:
  17641. m.ClearConditions()
  17642. return nil
  17643. case label.FieldOrganizationID:
  17644. m.ClearOrganizationID()
  17645. return nil
  17646. }
  17647. return fmt.Errorf("unknown Label nullable field %s", name)
  17648. }
  17649. // ResetField resets all changes in the mutation for the field with the given name.
  17650. // It returns an error if the field is not defined in the schema.
  17651. func (m *LabelMutation) ResetField(name string) error {
  17652. switch name {
  17653. case label.FieldCreatedAt:
  17654. m.ResetCreatedAt()
  17655. return nil
  17656. case label.FieldUpdatedAt:
  17657. m.ResetUpdatedAt()
  17658. return nil
  17659. case label.FieldStatus:
  17660. m.ResetStatus()
  17661. return nil
  17662. case label.FieldType:
  17663. m.ResetType()
  17664. return nil
  17665. case label.FieldName:
  17666. m.ResetName()
  17667. return nil
  17668. case label.FieldFrom:
  17669. m.ResetFrom()
  17670. return nil
  17671. case label.FieldMode:
  17672. m.ResetMode()
  17673. return nil
  17674. case label.FieldConditions:
  17675. m.ResetConditions()
  17676. return nil
  17677. case label.FieldOrganizationID:
  17678. m.ResetOrganizationID()
  17679. return nil
  17680. }
  17681. return fmt.Errorf("unknown Label field %s", name)
  17682. }
  17683. // AddedEdges returns all edge names that were set/added in this mutation.
  17684. func (m *LabelMutation) AddedEdges() []string {
  17685. edges := make([]string, 0, 1)
  17686. if m.label_relationships != nil {
  17687. edges = append(edges, label.EdgeLabelRelationships)
  17688. }
  17689. return edges
  17690. }
  17691. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17692. // name in this mutation.
  17693. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  17694. switch name {
  17695. case label.EdgeLabelRelationships:
  17696. ids := make([]ent.Value, 0, len(m.label_relationships))
  17697. for id := range m.label_relationships {
  17698. ids = append(ids, id)
  17699. }
  17700. return ids
  17701. }
  17702. return nil
  17703. }
  17704. // RemovedEdges returns all edge names that were removed in this mutation.
  17705. func (m *LabelMutation) RemovedEdges() []string {
  17706. edges := make([]string, 0, 1)
  17707. if m.removedlabel_relationships != nil {
  17708. edges = append(edges, label.EdgeLabelRelationships)
  17709. }
  17710. return edges
  17711. }
  17712. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17713. // the given name in this mutation.
  17714. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  17715. switch name {
  17716. case label.EdgeLabelRelationships:
  17717. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  17718. for id := range m.removedlabel_relationships {
  17719. ids = append(ids, id)
  17720. }
  17721. return ids
  17722. }
  17723. return nil
  17724. }
  17725. // ClearedEdges returns all edge names that were cleared in this mutation.
  17726. func (m *LabelMutation) ClearedEdges() []string {
  17727. edges := make([]string, 0, 1)
  17728. if m.clearedlabel_relationships {
  17729. edges = append(edges, label.EdgeLabelRelationships)
  17730. }
  17731. return edges
  17732. }
  17733. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17734. // was cleared in this mutation.
  17735. func (m *LabelMutation) EdgeCleared(name string) bool {
  17736. switch name {
  17737. case label.EdgeLabelRelationships:
  17738. return m.clearedlabel_relationships
  17739. }
  17740. return false
  17741. }
  17742. // ClearEdge clears the value of the edge with the given name. It returns an error
  17743. // if that edge is not defined in the schema.
  17744. func (m *LabelMutation) ClearEdge(name string) error {
  17745. switch name {
  17746. }
  17747. return fmt.Errorf("unknown Label unique edge %s", name)
  17748. }
  17749. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17750. // It returns an error if the edge is not defined in the schema.
  17751. func (m *LabelMutation) ResetEdge(name string) error {
  17752. switch name {
  17753. case label.EdgeLabelRelationships:
  17754. m.ResetLabelRelationships()
  17755. return nil
  17756. }
  17757. return fmt.Errorf("unknown Label edge %s", name)
  17758. }
  17759. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  17760. type LabelRelationshipMutation struct {
  17761. config
  17762. op Op
  17763. typ string
  17764. id *uint64
  17765. created_at *time.Time
  17766. updated_at *time.Time
  17767. status *uint8
  17768. addstatus *int8
  17769. organization_id *uint64
  17770. addorganization_id *int64
  17771. clearedFields map[string]struct{}
  17772. contacts *uint64
  17773. clearedcontacts bool
  17774. labels *uint64
  17775. clearedlabels bool
  17776. done bool
  17777. oldValue func(context.Context) (*LabelRelationship, error)
  17778. predicates []predicate.LabelRelationship
  17779. }
  17780. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  17781. // labelrelationshipOption allows management of the mutation configuration using functional options.
  17782. type labelrelationshipOption func(*LabelRelationshipMutation)
  17783. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  17784. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  17785. m := &LabelRelationshipMutation{
  17786. config: c,
  17787. op: op,
  17788. typ: TypeLabelRelationship,
  17789. clearedFields: make(map[string]struct{}),
  17790. }
  17791. for _, opt := range opts {
  17792. opt(m)
  17793. }
  17794. return m
  17795. }
  17796. // withLabelRelationshipID sets the ID field of the mutation.
  17797. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  17798. return func(m *LabelRelationshipMutation) {
  17799. var (
  17800. err error
  17801. once sync.Once
  17802. value *LabelRelationship
  17803. )
  17804. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  17805. once.Do(func() {
  17806. if m.done {
  17807. err = errors.New("querying old values post mutation is not allowed")
  17808. } else {
  17809. value, err = m.Client().LabelRelationship.Get(ctx, id)
  17810. }
  17811. })
  17812. return value, err
  17813. }
  17814. m.id = &id
  17815. }
  17816. }
  17817. // withLabelRelationship sets the old LabelRelationship of the mutation.
  17818. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  17819. return func(m *LabelRelationshipMutation) {
  17820. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  17821. return node, nil
  17822. }
  17823. m.id = &node.ID
  17824. }
  17825. }
  17826. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17827. // executed in a transaction (ent.Tx), a transactional client is returned.
  17828. func (m LabelRelationshipMutation) Client() *Client {
  17829. client := &Client{config: m.config}
  17830. client.init()
  17831. return client
  17832. }
  17833. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17834. // it returns an error otherwise.
  17835. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  17836. if _, ok := m.driver.(*txDriver); !ok {
  17837. return nil, errors.New("ent: mutation is not running in a transaction")
  17838. }
  17839. tx := &Tx{config: m.config}
  17840. tx.init()
  17841. return tx, nil
  17842. }
  17843. // SetID sets the value of the id field. Note that this
  17844. // operation is only accepted on creation of LabelRelationship entities.
  17845. func (m *LabelRelationshipMutation) SetID(id uint64) {
  17846. m.id = &id
  17847. }
  17848. // ID returns the ID value in the mutation. Note that the ID is only available
  17849. // if it was provided to the builder or after it was returned from the database.
  17850. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  17851. if m.id == nil {
  17852. return
  17853. }
  17854. return *m.id, true
  17855. }
  17856. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17857. // That means, if the mutation is applied within a transaction with an isolation level such
  17858. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17859. // or updated by the mutation.
  17860. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  17861. switch {
  17862. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17863. id, exists := m.ID()
  17864. if exists {
  17865. return []uint64{id}, nil
  17866. }
  17867. fallthrough
  17868. case m.op.Is(OpUpdate | OpDelete):
  17869. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  17870. default:
  17871. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17872. }
  17873. }
  17874. // SetCreatedAt sets the "created_at" field.
  17875. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  17876. m.created_at = &t
  17877. }
  17878. // CreatedAt returns the value of the "created_at" field in the mutation.
  17879. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  17880. v := m.created_at
  17881. if v == nil {
  17882. return
  17883. }
  17884. return *v, true
  17885. }
  17886. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  17887. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17889. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17890. if !m.op.Is(OpUpdateOne) {
  17891. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17892. }
  17893. if m.id == nil || m.oldValue == nil {
  17894. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17895. }
  17896. oldValue, err := m.oldValue(ctx)
  17897. if err != nil {
  17898. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17899. }
  17900. return oldValue.CreatedAt, nil
  17901. }
  17902. // ResetCreatedAt resets all changes to the "created_at" field.
  17903. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  17904. m.created_at = nil
  17905. }
  17906. // SetUpdatedAt sets the "updated_at" field.
  17907. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  17908. m.updated_at = &t
  17909. }
  17910. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17911. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  17912. v := m.updated_at
  17913. if v == nil {
  17914. return
  17915. }
  17916. return *v, true
  17917. }
  17918. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  17919. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17921. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17922. if !m.op.Is(OpUpdateOne) {
  17923. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17924. }
  17925. if m.id == nil || m.oldValue == nil {
  17926. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17927. }
  17928. oldValue, err := m.oldValue(ctx)
  17929. if err != nil {
  17930. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17931. }
  17932. return oldValue.UpdatedAt, nil
  17933. }
  17934. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17935. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  17936. m.updated_at = nil
  17937. }
  17938. // SetStatus sets the "status" field.
  17939. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  17940. m.status = &u
  17941. m.addstatus = nil
  17942. }
  17943. // Status returns the value of the "status" field in the mutation.
  17944. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  17945. v := m.status
  17946. if v == nil {
  17947. return
  17948. }
  17949. return *v, true
  17950. }
  17951. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  17952. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17954. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17955. if !m.op.Is(OpUpdateOne) {
  17956. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17957. }
  17958. if m.id == nil || m.oldValue == nil {
  17959. return v, errors.New("OldStatus requires an ID field in the mutation")
  17960. }
  17961. oldValue, err := m.oldValue(ctx)
  17962. if err != nil {
  17963. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17964. }
  17965. return oldValue.Status, nil
  17966. }
  17967. // AddStatus adds u to the "status" field.
  17968. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  17969. if m.addstatus != nil {
  17970. *m.addstatus += u
  17971. } else {
  17972. m.addstatus = &u
  17973. }
  17974. }
  17975. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17976. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  17977. v := m.addstatus
  17978. if v == nil {
  17979. return
  17980. }
  17981. return *v, true
  17982. }
  17983. // ClearStatus clears the value of the "status" field.
  17984. func (m *LabelRelationshipMutation) ClearStatus() {
  17985. m.status = nil
  17986. m.addstatus = nil
  17987. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  17988. }
  17989. // StatusCleared returns if the "status" field was cleared in this mutation.
  17990. func (m *LabelRelationshipMutation) StatusCleared() bool {
  17991. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  17992. return ok
  17993. }
  17994. // ResetStatus resets all changes to the "status" field.
  17995. func (m *LabelRelationshipMutation) ResetStatus() {
  17996. m.status = nil
  17997. m.addstatus = nil
  17998. delete(m.clearedFields, labelrelationship.FieldStatus)
  17999. }
  18000. // SetLabelID sets the "label_id" field.
  18001. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  18002. m.labels = &u
  18003. }
  18004. // LabelID returns the value of the "label_id" field in the mutation.
  18005. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  18006. v := m.labels
  18007. if v == nil {
  18008. return
  18009. }
  18010. return *v, true
  18011. }
  18012. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  18013. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18015. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  18016. if !m.op.Is(OpUpdateOne) {
  18017. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  18018. }
  18019. if m.id == nil || m.oldValue == nil {
  18020. return v, errors.New("OldLabelID requires an ID field in the mutation")
  18021. }
  18022. oldValue, err := m.oldValue(ctx)
  18023. if err != nil {
  18024. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  18025. }
  18026. return oldValue.LabelID, nil
  18027. }
  18028. // ResetLabelID resets all changes to the "label_id" field.
  18029. func (m *LabelRelationshipMutation) ResetLabelID() {
  18030. m.labels = nil
  18031. }
  18032. // SetContactID sets the "contact_id" field.
  18033. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  18034. m.contacts = &u
  18035. }
  18036. // ContactID returns the value of the "contact_id" field in the mutation.
  18037. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  18038. v := m.contacts
  18039. if v == nil {
  18040. return
  18041. }
  18042. return *v, true
  18043. }
  18044. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  18045. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18047. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  18048. if !m.op.Is(OpUpdateOne) {
  18049. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  18050. }
  18051. if m.id == nil || m.oldValue == nil {
  18052. return v, errors.New("OldContactID requires an ID field in the mutation")
  18053. }
  18054. oldValue, err := m.oldValue(ctx)
  18055. if err != nil {
  18056. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  18057. }
  18058. return oldValue.ContactID, nil
  18059. }
  18060. // ResetContactID resets all changes to the "contact_id" field.
  18061. func (m *LabelRelationshipMutation) ResetContactID() {
  18062. m.contacts = nil
  18063. }
  18064. // SetOrganizationID sets the "organization_id" field.
  18065. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  18066. m.organization_id = &u
  18067. m.addorganization_id = nil
  18068. }
  18069. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18070. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  18071. v := m.organization_id
  18072. if v == nil {
  18073. return
  18074. }
  18075. return *v, true
  18076. }
  18077. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  18078. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18080. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18081. if !m.op.Is(OpUpdateOne) {
  18082. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18083. }
  18084. if m.id == nil || m.oldValue == nil {
  18085. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18086. }
  18087. oldValue, err := m.oldValue(ctx)
  18088. if err != nil {
  18089. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18090. }
  18091. return oldValue.OrganizationID, nil
  18092. }
  18093. // AddOrganizationID adds u to the "organization_id" field.
  18094. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  18095. if m.addorganization_id != nil {
  18096. *m.addorganization_id += u
  18097. } else {
  18098. m.addorganization_id = &u
  18099. }
  18100. }
  18101. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18102. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  18103. v := m.addorganization_id
  18104. if v == nil {
  18105. return
  18106. }
  18107. return *v, true
  18108. }
  18109. // ClearOrganizationID clears the value of the "organization_id" field.
  18110. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  18111. m.organization_id = nil
  18112. m.addorganization_id = nil
  18113. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  18114. }
  18115. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18116. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  18117. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  18118. return ok
  18119. }
  18120. // ResetOrganizationID resets all changes to the "organization_id" field.
  18121. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  18122. m.organization_id = nil
  18123. m.addorganization_id = nil
  18124. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  18125. }
  18126. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  18127. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  18128. m.contacts = &id
  18129. }
  18130. // ClearContacts clears the "contacts" edge to the Contact entity.
  18131. func (m *LabelRelationshipMutation) ClearContacts() {
  18132. m.clearedcontacts = true
  18133. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  18134. }
  18135. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  18136. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  18137. return m.clearedcontacts
  18138. }
  18139. // ContactsID returns the "contacts" edge ID in the mutation.
  18140. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  18141. if m.contacts != nil {
  18142. return *m.contacts, true
  18143. }
  18144. return
  18145. }
  18146. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  18147. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18148. // ContactsID instead. It exists only for internal usage by the builders.
  18149. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  18150. if id := m.contacts; id != nil {
  18151. ids = append(ids, *id)
  18152. }
  18153. return
  18154. }
  18155. // ResetContacts resets all changes to the "contacts" edge.
  18156. func (m *LabelRelationshipMutation) ResetContacts() {
  18157. m.contacts = nil
  18158. m.clearedcontacts = false
  18159. }
  18160. // SetLabelsID sets the "labels" edge to the Label entity by id.
  18161. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  18162. m.labels = &id
  18163. }
  18164. // ClearLabels clears the "labels" edge to the Label entity.
  18165. func (m *LabelRelationshipMutation) ClearLabels() {
  18166. m.clearedlabels = true
  18167. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  18168. }
  18169. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  18170. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  18171. return m.clearedlabels
  18172. }
  18173. // LabelsID returns the "labels" edge ID in the mutation.
  18174. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  18175. if m.labels != nil {
  18176. return *m.labels, true
  18177. }
  18178. return
  18179. }
  18180. // LabelsIDs returns the "labels" edge IDs in the mutation.
  18181. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18182. // LabelsID instead. It exists only for internal usage by the builders.
  18183. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  18184. if id := m.labels; id != nil {
  18185. ids = append(ids, *id)
  18186. }
  18187. return
  18188. }
  18189. // ResetLabels resets all changes to the "labels" edge.
  18190. func (m *LabelRelationshipMutation) ResetLabels() {
  18191. m.labels = nil
  18192. m.clearedlabels = false
  18193. }
  18194. // Where appends a list predicates to the LabelRelationshipMutation builder.
  18195. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  18196. m.predicates = append(m.predicates, ps...)
  18197. }
  18198. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  18199. // users can use type-assertion to append predicates that do not depend on any generated package.
  18200. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  18201. p := make([]predicate.LabelRelationship, len(ps))
  18202. for i := range ps {
  18203. p[i] = ps[i]
  18204. }
  18205. m.Where(p...)
  18206. }
  18207. // Op returns the operation name.
  18208. func (m *LabelRelationshipMutation) Op() Op {
  18209. return m.op
  18210. }
  18211. // SetOp allows setting the mutation operation.
  18212. func (m *LabelRelationshipMutation) SetOp(op Op) {
  18213. m.op = op
  18214. }
  18215. // Type returns the node type of this mutation (LabelRelationship).
  18216. func (m *LabelRelationshipMutation) Type() string {
  18217. return m.typ
  18218. }
  18219. // Fields returns all fields that were changed during this mutation. Note that in
  18220. // order to get all numeric fields that were incremented/decremented, call
  18221. // AddedFields().
  18222. func (m *LabelRelationshipMutation) Fields() []string {
  18223. fields := make([]string, 0, 6)
  18224. if m.created_at != nil {
  18225. fields = append(fields, labelrelationship.FieldCreatedAt)
  18226. }
  18227. if m.updated_at != nil {
  18228. fields = append(fields, labelrelationship.FieldUpdatedAt)
  18229. }
  18230. if m.status != nil {
  18231. fields = append(fields, labelrelationship.FieldStatus)
  18232. }
  18233. if m.labels != nil {
  18234. fields = append(fields, labelrelationship.FieldLabelID)
  18235. }
  18236. if m.contacts != nil {
  18237. fields = append(fields, labelrelationship.FieldContactID)
  18238. }
  18239. if m.organization_id != nil {
  18240. fields = append(fields, labelrelationship.FieldOrganizationID)
  18241. }
  18242. return fields
  18243. }
  18244. // Field returns the value of a field with the given name. The second boolean
  18245. // return value indicates that this field was not set, or was not defined in the
  18246. // schema.
  18247. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  18248. switch name {
  18249. case labelrelationship.FieldCreatedAt:
  18250. return m.CreatedAt()
  18251. case labelrelationship.FieldUpdatedAt:
  18252. return m.UpdatedAt()
  18253. case labelrelationship.FieldStatus:
  18254. return m.Status()
  18255. case labelrelationship.FieldLabelID:
  18256. return m.LabelID()
  18257. case labelrelationship.FieldContactID:
  18258. return m.ContactID()
  18259. case labelrelationship.FieldOrganizationID:
  18260. return m.OrganizationID()
  18261. }
  18262. return nil, false
  18263. }
  18264. // OldField returns the old value of the field from the database. An error is
  18265. // returned if the mutation operation is not UpdateOne, or the query to the
  18266. // database failed.
  18267. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18268. switch name {
  18269. case labelrelationship.FieldCreatedAt:
  18270. return m.OldCreatedAt(ctx)
  18271. case labelrelationship.FieldUpdatedAt:
  18272. return m.OldUpdatedAt(ctx)
  18273. case labelrelationship.FieldStatus:
  18274. return m.OldStatus(ctx)
  18275. case labelrelationship.FieldLabelID:
  18276. return m.OldLabelID(ctx)
  18277. case labelrelationship.FieldContactID:
  18278. return m.OldContactID(ctx)
  18279. case labelrelationship.FieldOrganizationID:
  18280. return m.OldOrganizationID(ctx)
  18281. }
  18282. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  18283. }
  18284. // SetField sets the value of a field with the given name. It returns an error if
  18285. // the field is not defined in the schema, or if the type mismatched the field
  18286. // type.
  18287. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  18288. switch name {
  18289. case labelrelationship.FieldCreatedAt:
  18290. v, ok := value.(time.Time)
  18291. if !ok {
  18292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18293. }
  18294. m.SetCreatedAt(v)
  18295. return nil
  18296. case labelrelationship.FieldUpdatedAt:
  18297. v, ok := value.(time.Time)
  18298. if !ok {
  18299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18300. }
  18301. m.SetUpdatedAt(v)
  18302. return nil
  18303. case labelrelationship.FieldStatus:
  18304. v, ok := value.(uint8)
  18305. if !ok {
  18306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18307. }
  18308. m.SetStatus(v)
  18309. return nil
  18310. case labelrelationship.FieldLabelID:
  18311. v, ok := value.(uint64)
  18312. if !ok {
  18313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18314. }
  18315. m.SetLabelID(v)
  18316. return nil
  18317. case labelrelationship.FieldContactID:
  18318. v, ok := value.(uint64)
  18319. if !ok {
  18320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18321. }
  18322. m.SetContactID(v)
  18323. return nil
  18324. case labelrelationship.FieldOrganizationID:
  18325. v, ok := value.(uint64)
  18326. if !ok {
  18327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18328. }
  18329. m.SetOrganizationID(v)
  18330. return nil
  18331. }
  18332. return fmt.Errorf("unknown LabelRelationship field %s", name)
  18333. }
  18334. // AddedFields returns all numeric fields that were incremented/decremented during
  18335. // this mutation.
  18336. func (m *LabelRelationshipMutation) AddedFields() []string {
  18337. var fields []string
  18338. if m.addstatus != nil {
  18339. fields = append(fields, labelrelationship.FieldStatus)
  18340. }
  18341. if m.addorganization_id != nil {
  18342. fields = append(fields, labelrelationship.FieldOrganizationID)
  18343. }
  18344. return fields
  18345. }
  18346. // AddedField returns the numeric value that was incremented/decremented on a field
  18347. // with the given name. The second boolean return value indicates that this field
  18348. // was not set, or was not defined in the schema.
  18349. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  18350. switch name {
  18351. case labelrelationship.FieldStatus:
  18352. return m.AddedStatus()
  18353. case labelrelationship.FieldOrganizationID:
  18354. return m.AddedOrganizationID()
  18355. }
  18356. return nil, false
  18357. }
  18358. // AddField adds the value to the field with the given name. It returns an error if
  18359. // the field is not defined in the schema, or if the type mismatched the field
  18360. // type.
  18361. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  18362. switch name {
  18363. case labelrelationship.FieldStatus:
  18364. v, ok := value.(int8)
  18365. if !ok {
  18366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18367. }
  18368. m.AddStatus(v)
  18369. return nil
  18370. case labelrelationship.FieldOrganizationID:
  18371. v, ok := value.(int64)
  18372. if !ok {
  18373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18374. }
  18375. m.AddOrganizationID(v)
  18376. return nil
  18377. }
  18378. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  18379. }
  18380. // ClearedFields returns all nullable fields that were cleared during this
  18381. // mutation.
  18382. func (m *LabelRelationshipMutation) ClearedFields() []string {
  18383. var fields []string
  18384. if m.FieldCleared(labelrelationship.FieldStatus) {
  18385. fields = append(fields, labelrelationship.FieldStatus)
  18386. }
  18387. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  18388. fields = append(fields, labelrelationship.FieldOrganizationID)
  18389. }
  18390. return fields
  18391. }
  18392. // FieldCleared returns a boolean indicating if a field with the given name was
  18393. // cleared in this mutation.
  18394. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  18395. _, ok := m.clearedFields[name]
  18396. return ok
  18397. }
  18398. // ClearField clears the value of the field with the given name. It returns an
  18399. // error if the field is not defined in the schema.
  18400. func (m *LabelRelationshipMutation) ClearField(name string) error {
  18401. switch name {
  18402. case labelrelationship.FieldStatus:
  18403. m.ClearStatus()
  18404. return nil
  18405. case labelrelationship.FieldOrganizationID:
  18406. m.ClearOrganizationID()
  18407. return nil
  18408. }
  18409. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  18410. }
  18411. // ResetField resets all changes in the mutation for the field with the given name.
  18412. // It returns an error if the field is not defined in the schema.
  18413. func (m *LabelRelationshipMutation) ResetField(name string) error {
  18414. switch name {
  18415. case labelrelationship.FieldCreatedAt:
  18416. m.ResetCreatedAt()
  18417. return nil
  18418. case labelrelationship.FieldUpdatedAt:
  18419. m.ResetUpdatedAt()
  18420. return nil
  18421. case labelrelationship.FieldStatus:
  18422. m.ResetStatus()
  18423. return nil
  18424. case labelrelationship.FieldLabelID:
  18425. m.ResetLabelID()
  18426. return nil
  18427. case labelrelationship.FieldContactID:
  18428. m.ResetContactID()
  18429. return nil
  18430. case labelrelationship.FieldOrganizationID:
  18431. m.ResetOrganizationID()
  18432. return nil
  18433. }
  18434. return fmt.Errorf("unknown LabelRelationship field %s", name)
  18435. }
  18436. // AddedEdges returns all edge names that were set/added in this mutation.
  18437. func (m *LabelRelationshipMutation) AddedEdges() []string {
  18438. edges := make([]string, 0, 2)
  18439. if m.contacts != nil {
  18440. edges = append(edges, labelrelationship.EdgeContacts)
  18441. }
  18442. if m.labels != nil {
  18443. edges = append(edges, labelrelationship.EdgeLabels)
  18444. }
  18445. return edges
  18446. }
  18447. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18448. // name in this mutation.
  18449. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  18450. switch name {
  18451. case labelrelationship.EdgeContacts:
  18452. if id := m.contacts; id != nil {
  18453. return []ent.Value{*id}
  18454. }
  18455. case labelrelationship.EdgeLabels:
  18456. if id := m.labels; id != nil {
  18457. return []ent.Value{*id}
  18458. }
  18459. }
  18460. return nil
  18461. }
  18462. // RemovedEdges returns all edge names that were removed in this mutation.
  18463. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  18464. edges := make([]string, 0, 2)
  18465. return edges
  18466. }
  18467. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18468. // the given name in this mutation.
  18469. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  18470. return nil
  18471. }
  18472. // ClearedEdges returns all edge names that were cleared in this mutation.
  18473. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  18474. edges := make([]string, 0, 2)
  18475. if m.clearedcontacts {
  18476. edges = append(edges, labelrelationship.EdgeContacts)
  18477. }
  18478. if m.clearedlabels {
  18479. edges = append(edges, labelrelationship.EdgeLabels)
  18480. }
  18481. return edges
  18482. }
  18483. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18484. // was cleared in this mutation.
  18485. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  18486. switch name {
  18487. case labelrelationship.EdgeContacts:
  18488. return m.clearedcontacts
  18489. case labelrelationship.EdgeLabels:
  18490. return m.clearedlabels
  18491. }
  18492. return false
  18493. }
  18494. // ClearEdge clears the value of the edge with the given name. It returns an error
  18495. // if that edge is not defined in the schema.
  18496. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  18497. switch name {
  18498. case labelrelationship.EdgeContacts:
  18499. m.ClearContacts()
  18500. return nil
  18501. case labelrelationship.EdgeLabels:
  18502. m.ClearLabels()
  18503. return nil
  18504. }
  18505. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  18506. }
  18507. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18508. // It returns an error if the edge is not defined in the schema.
  18509. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  18510. switch name {
  18511. case labelrelationship.EdgeContacts:
  18512. m.ResetContacts()
  18513. return nil
  18514. case labelrelationship.EdgeLabels:
  18515. m.ResetLabels()
  18516. return nil
  18517. }
  18518. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  18519. }
  18520. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  18521. type LabelTaggingMutation struct {
  18522. config
  18523. op Op
  18524. typ string
  18525. id *uint64
  18526. created_at *time.Time
  18527. updated_at *time.Time
  18528. status *uint8
  18529. addstatus *int8
  18530. deleted_at *time.Time
  18531. organization_id *uint64
  18532. addorganization_id *int64
  18533. _type *int
  18534. add_type *int
  18535. conditions *string
  18536. action_label_add *[]uint64
  18537. appendaction_label_add []uint64
  18538. action_label_del *[]uint64
  18539. appendaction_label_del []uint64
  18540. clearedFields map[string]struct{}
  18541. done bool
  18542. oldValue func(context.Context) (*LabelTagging, error)
  18543. predicates []predicate.LabelTagging
  18544. }
  18545. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  18546. // labeltaggingOption allows management of the mutation configuration using functional options.
  18547. type labeltaggingOption func(*LabelTaggingMutation)
  18548. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  18549. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  18550. m := &LabelTaggingMutation{
  18551. config: c,
  18552. op: op,
  18553. typ: TypeLabelTagging,
  18554. clearedFields: make(map[string]struct{}),
  18555. }
  18556. for _, opt := range opts {
  18557. opt(m)
  18558. }
  18559. return m
  18560. }
  18561. // withLabelTaggingID sets the ID field of the mutation.
  18562. func withLabelTaggingID(id uint64) labeltaggingOption {
  18563. return func(m *LabelTaggingMutation) {
  18564. var (
  18565. err error
  18566. once sync.Once
  18567. value *LabelTagging
  18568. )
  18569. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  18570. once.Do(func() {
  18571. if m.done {
  18572. err = errors.New("querying old values post mutation is not allowed")
  18573. } else {
  18574. value, err = m.Client().LabelTagging.Get(ctx, id)
  18575. }
  18576. })
  18577. return value, err
  18578. }
  18579. m.id = &id
  18580. }
  18581. }
  18582. // withLabelTagging sets the old LabelTagging of the mutation.
  18583. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  18584. return func(m *LabelTaggingMutation) {
  18585. m.oldValue = func(context.Context) (*LabelTagging, error) {
  18586. return node, nil
  18587. }
  18588. m.id = &node.ID
  18589. }
  18590. }
  18591. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18592. // executed in a transaction (ent.Tx), a transactional client is returned.
  18593. func (m LabelTaggingMutation) Client() *Client {
  18594. client := &Client{config: m.config}
  18595. client.init()
  18596. return client
  18597. }
  18598. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18599. // it returns an error otherwise.
  18600. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  18601. if _, ok := m.driver.(*txDriver); !ok {
  18602. return nil, errors.New("ent: mutation is not running in a transaction")
  18603. }
  18604. tx := &Tx{config: m.config}
  18605. tx.init()
  18606. return tx, nil
  18607. }
  18608. // SetID sets the value of the id field. Note that this
  18609. // operation is only accepted on creation of LabelTagging entities.
  18610. func (m *LabelTaggingMutation) SetID(id uint64) {
  18611. m.id = &id
  18612. }
  18613. // ID returns the ID value in the mutation. Note that the ID is only available
  18614. // if it was provided to the builder or after it was returned from the database.
  18615. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  18616. if m.id == nil {
  18617. return
  18618. }
  18619. return *m.id, true
  18620. }
  18621. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18622. // That means, if the mutation is applied within a transaction with an isolation level such
  18623. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18624. // or updated by the mutation.
  18625. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  18626. switch {
  18627. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18628. id, exists := m.ID()
  18629. if exists {
  18630. return []uint64{id}, nil
  18631. }
  18632. fallthrough
  18633. case m.op.Is(OpUpdate | OpDelete):
  18634. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  18635. default:
  18636. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18637. }
  18638. }
  18639. // SetCreatedAt sets the "created_at" field.
  18640. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  18641. m.created_at = &t
  18642. }
  18643. // CreatedAt returns the value of the "created_at" field in the mutation.
  18644. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  18645. v := m.created_at
  18646. if v == nil {
  18647. return
  18648. }
  18649. return *v, true
  18650. }
  18651. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  18652. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18654. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18655. if !m.op.Is(OpUpdateOne) {
  18656. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18657. }
  18658. if m.id == nil || m.oldValue == nil {
  18659. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18660. }
  18661. oldValue, err := m.oldValue(ctx)
  18662. if err != nil {
  18663. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18664. }
  18665. return oldValue.CreatedAt, nil
  18666. }
  18667. // ResetCreatedAt resets all changes to the "created_at" field.
  18668. func (m *LabelTaggingMutation) ResetCreatedAt() {
  18669. m.created_at = nil
  18670. }
  18671. // SetUpdatedAt sets the "updated_at" field.
  18672. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  18673. m.updated_at = &t
  18674. }
  18675. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18676. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  18677. v := m.updated_at
  18678. if v == nil {
  18679. return
  18680. }
  18681. return *v, true
  18682. }
  18683. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  18684. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18686. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18687. if !m.op.Is(OpUpdateOne) {
  18688. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18689. }
  18690. if m.id == nil || m.oldValue == nil {
  18691. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18692. }
  18693. oldValue, err := m.oldValue(ctx)
  18694. if err != nil {
  18695. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18696. }
  18697. return oldValue.UpdatedAt, nil
  18698. }
  18699. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18700. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  18701. m.updated_at = nil
  18702. }
  18703. // SetStatus sets the "status" field.
  18704. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  18705. m.status = &u
  18706. m.addstatus = nil
  18707. }
  18708. // Status returns the value of the "status" field in the mutation.
  18709. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  18710. v := m.status
  18711. if v == nil {
  18712. return
  18713. }
  18714. return *v, true
  18715. }
  18716. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  18717. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18719. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18720. if !m.op.Is(OpUpdateOne) {
  18721. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18722. }
  18723. if m.id == nil || m.oldValue == nil {
  18724. return v, errors.New("OldStatus requires an ID field in the mutation")
  18725. }
  18726. oldValue, err := m.oldValue(ctx)
  18727. if err != nil {
  18728. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18729. }
  18730. return oldValue.Status, nil
  18731. }
  18732. // AddStatus adds u to the "status" field.
  18733. func (m *LabelTaggingMutation) AddStatus(u int8) {
  18734. if m.addstatus != nil {
  18735. *m.addstatus += u
  18736. } else {
  18737. m.addstatus = &u
  18738. }
  18739. }
  18740. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18741. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  18742. v := m.addstatus
  18743. if v == nil {
  18744. return
  18745. }
  18746. return *v, true
  18747. }
  18748. // ClearStatus clears the value of the "status" field.
  18749. func (m *LabelTaggingMutation) ClearStatus() {
  18750. m.status = nil
  18751. m.addstatus = nil
  18752. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  18753. }
  18754. // StatusCleared returns if the "status" field was cleared in this mutation.
  18755. func (m *LabelTaggingMutation) StatusCleared() bool {
  18756. _, ok := m.clearedFields[labeltagging.FieldStatus]
  18757. return ok
  18758. }
  18759. // ResetStatus resets all changes to the "status" field.
  18760. func (m *LabelTaggingMutation) ResetStatus() {
  18761. m.status = nil
  18762. m.addstatus = nil
  18763. delete(m.clearedFields, labeltagging.FieldStatus)
  18764. }
  18765. // SetDeletedAt sets the "deleted_at" field.
  18766. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  18767. m.deleted_at = &t
  18768. }
  18769. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18770. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  18771. v := m.deleted_at
  18772. if v == nil {
  18773. return
  18774. }
  18775. return *v, true
  18776. }
  18777. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  18778. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18780. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18781. if !m.op.Is(OpUpdateOne) {
  18782. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18783. }
  18784. if m.id == nil || m.oldValue == nil {
  18785. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18786. }
  18787. oldValue, err := m.oldValue(ctx)
  18788. if err != nil {
  18789. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18790. }
  18791. return oldValue.DeletedAt, nil
  18792. }
  18793. // ClearDeletedAt clears the value of the "deleted_at" field.
  18794. func (m *LabelTaggingMutation) ClearDeletedAt() {
  18795. m.deleted_at = nil
  18796. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  18797. }
  18798. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18799. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  18800. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  18801. return ok
  18802. }
  18803. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18804. func (m *LabelTaggingMutation) ResetDeletedAt() {
  18805. m.deleted_at = nil
  18806. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  18807. }
  18808. // SetOrganizationID sets the "organization_id" field.
  18809. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  18810. m.organization_id = &u
  18811. m.addorganization_id = nil
  18812. }
  18813. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18814. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  18815. v := m.organization_id
  18816. if v == nil {
  18817. return
  18818. }
  18819. return *v, true
  18820. }
  18821. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  18822. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18824. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18825. if !m.op.Is(OpUpdateOne) {
  18826. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18827. }
  18828. if m.id == nil || m.oldValue == nil {
  18829. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18830. }
  18831. oldValue, err := m.oldValue(ctx)
  18832. if err != nil {
  18833. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18834. }
  18835. return oldValue.OrganizationID, nil
  18836. }
  18837. // AddOrganizationID adds u to the "organization_id" field.
  18838. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  18839. if m.addorganization_id != nil {
  18840. *m.addorganization_id += u
  18841. } else {
  18842. m.addorganization_id = &u
  18843. }
  18844. }
  18845. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18846. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  18847. v := m.addorganization_id
  18848. if v == nil {
  18849. return
  18850. }
  18851. return *v, true
  18852. }
  18853. // ResetOrganizationID resets all changes to the "organization_id" field.
  18854. func (m *LabelTaggingMutation) ResetOrganizationID() {
  18855. m.organization_id = nil
  18856. m.addorganization_id = nil
  18857. }
  18858. // SetType sets the "type" field.
  18859. func (m *LabelTaggingMutation) SetType(i int) {
  18860. m._type = &i
  18861. m.add_type = nil
  18862. }
  18863. // GetType returns the value of the "type" field in the mutation.
  18864. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  18865. v := m._type
  18866. if v == nil {
  18867. return
  18868. }
  18869. return *v, true
  18870. }
  18871. // OldType returns the old "type" field's value of the LabelTagging entity.
  18872. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18874. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  18875. if !m.op.Is(OpUpdateOne) {
  18876. return v, errors.New("OldType is only allowed on UpdateOne operations")
  18877. }
  18878. if m.id == nil || m.oldValue == nil {
  18879. return v, errors.New("OldType requires an ID field in the mutation")
  18880. }
  18881. oldValue, err := m.oldValue(ctx)
  18882. if err != nil {
  18883. return v, fmt.Errorf("querying old value for OldType: %w", err)
  18884. }
  18885. return oldValue.Type, nil
  18886. }
  18887. // AddType adds i to the "type" field.
  18888. func (m *LabelTaggingMutation) AddType(i int) {
  18889. if m.add_type != nil {
  18890. *m.add_type += i
  18891. } else {
  18892. m.add_type = &i
  18893. }
  18894. }
  18895. // AddedType returns the value that was added to the "type" field in this mutation.
  18896. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  18897. v := m.add_type
  18898. if v == nil {
  18899. return
  18900. }
  18901. return *v, true
  18902. }
  18903. // ResetType resets all changes to the "type" field.
  18904. func (m *LabelTaggingMutation) ResetType() {
  18905. m._type = nil
  18906. m.add_type = nil
  18907. }
  18908. // SetConditions sets the "conditions" field.
  18909. func (m *LabelTaggingMutation) SetConditions(s string) {
  18910. m.conditions = &s
  18911. }
  18912. // Conditions returns the value of the "conditions" field in the mutation.
  18913. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  18914. v := m.conditions
  18915. if v == nil {
  18916. return
  18917. }
  18918. return *v, true
  18919. }
  18920. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  18921. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18923. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  18924. if !m.op.Is(OpUpdateOne) {
  18925. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  18926. }
  18927. if m.id == nil || m.oldValue == nil {
  18928. return v, errors.New("OldConditions requires an ID field in the mutation")
  18929. }
  18930. oldValue, err := m.oldValue(ctx)
  18931. if err != nil {
  18932. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  18933. }
  18934. return oldValue.Conditions, nil
  18935. }
  18936. // ResetConditions resets all changes to the "conditions" field.
  18937. func (m *LabelTaggingMutation) ResetConditions() {
  18938. m.conditions = nil
  18939. }
  18940. // SetActionLabelAdd sets the "action_label_add" field.
  18941. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  18942. m.action_label_add = &u
  18943. m.appendaction_label_add = nil
  18944. }
  18945. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18946. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18947. v := m.action_label_add
  18948. if v == nil {
  18949. return
  18950. }
  18951. return *v, true
  18952. }
  18953. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  18954. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18956. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18957. if !m.op.Is(OpUpdateOne) {
  18958. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18959. }
  18960. if m.id == nil || m.oldValue == nil {
  18961. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18962. }
  18963. oldValue, err := m.oldValue(ctx)
  18964. if err != nil {
  18965. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18966. }
  18967. return oldValue.ActionLabelAdd, nil
  18968. }
  18969. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18970. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  18971. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18972. }
  18973. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18974. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18975. if len(m.appendaction_label_add) == 0 {
  18976. return nil, false
  18977. }
  18978. return m.appendaction_label_add, true
  18979. }
  18980. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18981. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  18982. m.action_label_add = nil
  18983. m.appendaction_label_add = nil
  18984. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  18985. }
  18986. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18987. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  18988. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  18989. return ok
  18990. }
  18991. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18992. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  18993. m.action_label_add = nil
  18994. m.appendaction_label_add = nil
  18995. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  18996. }
  18997. // SetActionLabelDel sets the "action_label_del" field.
  18998. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  18999. m.action_label_del = &u
  19000. m.appendaction_label_del = nil
  19001. }
  19002. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  19003. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  19004. v := m.action_label_del
  19005. if v == nil {
  19006. return
  19007. }
  19008. return *v, true
  19009. }
  19010. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  19011. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19013. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  19014. if !m.op.Is(OpUpdateOne) {
  19015. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  19016. }
  19017. if m.id == nil || m.oldValue == nil {
  19018. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  19019. }
  19020. oldValue, err := m.oldValue(ctx)
  19021. if err != nil {
  19022. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  19023. }
  19024. return oldValue.ActionLabelDel, nil
  19025. }
  19026. // AppendActionLabelDel adds u to the "action_label_del" field.
  19027. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  19028. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  19029. }
  19030. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  19031. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  19032. if len(m.appendaction_label_del) == 0 {
  19033. return nil, false
  19034. }
  19035. return m.appendaction_label_del, true
  19036. }
  19037. // ClearActionLabelDel clears the value of the "action_label_del" field.
  19038. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  19039. m.action_label_del = nil
  19040. m.appendaction_label_del = nil
  19041. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  19042. }
  19043. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  19044. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  19045. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  19046. return ok
  19047. }
  19048. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  19049. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  19050. m.action_label_del = nil
  19051. m.appendaction_label_del = nil
  19052. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  19053. }
  19054. // Where appends a list predicates to the LabelTaggingMutation builder.
  19055. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  19056. m.predicates = append(m.predicates, ps...)
  19057. }
  19058. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  19059. // users can use type-assertion to append predicates that do not depend on any generated package.
  19060. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  19061. p := make([]predicate.LabelTagging, len(ps))
  19062. for i := range ps {
  19063. p[i] = ps[i]
  19064. }
  19065. m.Where(p...)
  19066. }
  19067. // Op returns the operation name.
  19068. func (m *LabelTaggingMutation) Op() Op {
  19069. return m.op
  19070. }
  19071. // SetOp allows setting the mutation operation.
  19072. func (m *LabelTaggingMutation) SetOp(op Op) {
  19073. m.op = op
  19074. }
  19075. // Type returns the node type of this mutation (LabelTagging).
  19076. func (m *LabelTaggingMutation) Type() string {
  19077. return m.typ
  19078. }
  19079. // Fields returns all fields that were changed during this mutation. Note that in
  19080. // order to get all numeric fields that were incremented/decremented, call
  19081. // AddedFields().
  19082. func (m *LabelTaggingMutation) Fields() []string {
  19083. fields := make([]string, 0, 9)
  19084. if m.created_at != nil {
  19085. fields = append(fields, labeltagging.FieldCreatedAt)
  19086. }
  19087. if m.updated_at != nil {
  19088. fields = append(fields, labeltagging.FieldUpdatedAt)
  19089. }
  19090. if m.status != nil {
  19091. fields = append(fields, labeltagging.FieldStatus)
  19092. }
  19093. if m.deleted_at != nil {
  19094. fields = append(fields, labeltagging.FieldDeletedAt)
  19095. }
  19096. if m.organization_id != nil {
  19097. fields = append(fields, labeltagging.FieldOrganizationID)
  19098. }
  19099. if m._type != nil {
  19100. fields = append(fields, labeltagging.FieldType)
  19101. }
  19102. if m.conditions != nil {
  19103. fields = append(fields, labeltagging.FieldConditions)
  19104. }
  19105. if m.action_label_add != nil {
  19106. fields = append(fields, labeltagging.FieldActionLabelAdd)
  19107. }
  19108. if m.action_label_del != nil {
  19109. fields = append(fields, labeltagging.FieldActionLabelDel)
  19110. }
  19111. return fields
  19112. }
  19113. // Field returns the value of a field with the given name. The second boolean
  19114. // return value indicates that this field was not set, or was not defined in the
  19115. // schema.
  19116. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  19117. switch name {
  19118. case labeltagging.FieldCreatedAt:
  19119. return m.CreatedAt()
  19120. case labeltagging.FieldUpdatedAt:
  19121. return m.UpdatedAt()
  19122. case labeltagging.FieldStatus:
  19123. return m.Status()
  19124. case labeltagging.FieldDeletedAt:
  19125. return m.DeletedAt()
  19126. case labeltagging.FieldOrganizationID:
  19127. return m.OrganizationID()
  19128. case labeltagging.FieldType:
  19129. return m.GetType()
  19130. case labeltagging.FieldConditions:
  19131. return m.Conditions()
  19132. case labeltagging.FieldActionLabelAdd:
  19133. return m.ActionLabelAdd()
  19134. case labeltagging.FieldActionLabelDel:
  19135. return m.ActionLabelDel()
  19136. }
  19137. return nil, false
  19138. }
  19139. // OldField returns the old value of the field from the database. An error is
  19140. // returned if the mutation operation is not UpdateOne, or the query to the
  19141. // database failed.
  19142. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19143. switch name {
  19144. case labeltagging.FieldCreatedAt:
  19145. return m.OldCreatedAt(ctx)
  19146. case labeltagging.FieldUpdatedAt:
  19147. return m.OldUpdatedAt(ctx)
  19148. case labeltagging.FieldStatus:
  19149. return m.OldStatus(ctx)
  19150. case labeltagging.FieldDeletedAt:
  19151. return m.OldDeletedAt(ctx)
  19152. case labeltagging.FieldOrganizationID:
  19153. return m.OldOrganizationID(ctx)
  19154. case labeltagging.FieldType:
  19155. return m.OldType(ctx)
  19156. case labeltagging.FieldConditions:
  19157. return m.OldConditions(ctx)
  19158. case labeltagging.FieldActionLabelAdd:
  19159. return m.OldActionLabelAdd(ctx)
  19160. case labeltagging.FieldActionLabelDel:
  19161. return m.OldActionLabelDel(ctx)
  19162. }
  19163. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  19164. }
  19165. // SetField sets the value of a field with the given name. It returns an error if
  19166. // the field is not defined in the schema, or if the type mismatched the field
  19167. // type.
  19168. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  19169. switch name {
  19170. case labeltagging.FieldCreatedAt:
  19171. v, ok := value.(time.Time)
  19172. if !ok {
  19173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19174. }
  19175. m.SetCreatedAt(v)
  19176. return nil
  19177. case labeltagging.FieldUpdatedAt:
  19178. v, ok := value.(time.Time)
  19179. if !ok {
  19180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19181. }
  19182. m.SetUpdatedAt(v)
  19183. return nil
  19184. case labeltagging.FieldStatus:
  19185. v, ok := value.(uint8)
  19186. if !ok {
  19187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19188. }
  19189. m.SetStatus(v)
  19190. return nil
  19191. case labeltagging.FieldDeletedAt:
  19192. v, ok := value.(time.Time)
  19193. if !ok {
  19194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19195. }
  19196. m.SetDeletedAt(v)
  19197. return nil
  19198. case labeltagging.FieldOrganizationID:
  19199. v, ok := value.(uint64)
  19200. if !ok {
  19201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19202. }
  19203. m.SetOrganizationID(v)
  19204. return nil
  19205. case labeltagging.FieldType:
  19206. v, ok := value.(int)
  19207. if !ok {
  19208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19209. }
  19210. m.SetType(v)
  19211. return nil
  19212. case labeltagging.FieldConditions:
  19213. v, ok := value.(string)
  19214. if !ok {
  19215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19216. }
  19217. m.SetConditions(v)
  19218. return nil
  19219. case labeltagging.FieldActionLabelAdd:
  19220. v, ok := value.([]uint64)
  19221. if !ok {
  19222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19223. }
  19224. m.SetActionLabelAdd(v)
  19225. return nil
  19226. case labeltagging.FieldActionLabelDel:
  19227. v, ok := value.([]uint64)
  19228. if !ok {
  19229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19230. }
  19231. m.SetActionLabelDel(v)
  19232. return nil
  19233. }
  19234. return fmt.Errorf("unknown LabelTagging field %s", name)
  19235. }
  19236. // AddedFields returns all numeric fields that were incremented/decremented during
  19237. // this mutation.
  19238. func (m *LabelTaggingMutation) AddedFields() []string {
  19239. var fields []string
  19240. if m.addstatus != nil {
  19241. fields = append(fields, labeltagging.FieldStatus)
  19242. }
  19243. if m.addorganization_id != nil {
  19244. fields = append(fields, labeltagging.FieldOrganizationID)
  19245. }
  19246. if m.add_type != nil {
  19247. fields = append(fields, labeltagging.FieldType)
  19248. }
  19249. return fields
  19250. }
  19251. // AddedField returns the numeric value that was incremented/decremented on a field
  19252. // with the given name. The second boolean return value indicates that this field
  19253. // was not set, or was not defined in the schema.
  19254. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  19255. switch name {
  19256. case labeltagging.FieldStatus:
  19257. return m.AddedStatus()
  19258. case labeltagging.FieldOrganizationID:
  19259. return m.AddedOrganizationID()
  19260. case labeltagging.FieldType:
  19261. return m.AddedType()
  19262. }
  19263. return nil, false
  19264. }
  19265. // AddField adds the value to the field with the given name. It returns an error if
  19266. // the field is not defined in the schema, or if the type mismatched the field
  19267. // type.
  19268. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  19269. switch name {
  19270. case labeltagging.FieldStatus:
  19271. v, ok := value.(int8)
  19272. if !ok {
  19273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19274. }
  19275. m.AddStatus(v)
  19276. return nil
  19277. case labeltagging.FieldOrganizationID:
  19278. v, ok := value.(int64)
  19279. if !ok {
  19280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19281. }
  19282. m.AddOrganizationID(v)
  19283. return nil
  19284. case labeltagging.FieldType:
  19285. v, ok := value.(int)
  19286. if !ok {
  19287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19288. }
  19289. m.AddType(v)
  19290. return nil
  19291. }
  19292. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  19293. }
  19294. // ClearedFields returns all nullable fields that were cleared during this
  19295. // mutation.
  19296. func (m *LabelTaggingMutation) ClearedFields() []string {
  19297. var fields []string
  19298. if m.FieldCleared(labeltagging.FieldStatus) {
  19299. fields = append(fields, labeltagging.FieldStatus)
  19300. }
  19301. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  19302. fields = append(fields, labeltagging.FieldDeletedAt)
  19303. }
  19304. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  19305. fields = append(fields, labeltagging.FieldActionLabelAdd)
  19306. }
  19307. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  19308. fields = append(fields, labeltagging.FieldActionLabelDel)
  19309. }
  19310. return fields
  19311. }
  19312. // FieldCleared returns a boolean indicating if a field with the given name was
  19313. // cleared in this mutation.
  19314. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  19315. _, ok := m.clearedFields[name]
  19316. return ok
  19317. }
  19318. // ClearField clears the value of the field with the given name. It returns an
  19319. // error if the field is not defined in the schema.
  19320. func (m *LabelTaggingMutation) ClearField(name string) error {
  19321. switch name {
  19322. case labeltagging.FieldStatus:
  19323. m.ClearStatus()
  19324. return nil
  19325. case labeltagging.FieldDeletedAt:
  19326. m.ClearDeletedAt()
  19327. return nil
  19328. case labeltagging.FieldActionLabelAdd:
  19329. m.ClearActionLabelAdd()
  19330. return nil
  19331. case labeltagging.FieldActionLabelDel:
  19332. m.ClearActionLabelDel()
  19333. return nil
  19334. }
  19335. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  19336. }
  19337. // ResetField resets all changes in the mutation for the field with the given name.
  19338. // It returns an error if the field is not defined in the schema.
  19339. func (m *LabelTaggingMutation) ResetField(name string) error {
  19340. switch name {
  19341. case labeltagging.FieldCreatedAt:
  19342. m.ResetCreatedAt()
  19343. return nil
  19344. case labeltagging.FieldUpdatedAt:
  19345. m.ResetUpdatedAt()
  19346. return nil
  19347. case labeltagging.FieldStatus:
  19348. m.ResetStatus()
  19349. return nil
  19350. case labeltagging.FieldDeletedAt:
  19351. m.ResetDeletedAt()
  19352. return nil
  19353. case labeltagging.FieldOrganizationID:
  19354. m.ResetOrganizationID()
  19355. return nil
  19356. case labeltagging.FieldType:
  19357. m.ResetType()
  19358. return nil
  19359. case labeltagging.FieldConditions:
  19360. m.ResetConditions()
  19361. return nil
  19362. case labeltagging.FieldActionLabelAdd:
  19363. m.ResetActionLabelAdd()
  19364. return nil
  19365. case labeltagging.FieldActionLabelDel:
  19366. m.ResetActionLabelDel()
  19367. return nil
  19368. }
  19369. return fmt.Errorf("unknown LabelTagging field %s", name)
  19370. }
  19371. // AddedEdges returns all edge names that were set/added in this mutation.
  19372. func (m *LabelTaggingMutation) AddedEdges() []string {
  19373. edges := make([]string, 0, 0)
  19374. return edges
  19375. }
  19376. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19377. // name in this mutation.
  19378. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  19379. return nil
  19380. }
  19381. // RemovedEdges returns all edge names that were removed in this mutation.
  19382. func (m *LabelTaggingMutation) RemovedEdges() []string {
  19383. edges := make([]string, 0, 0)
  19384. return edges
  19385. }
  19386. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19387. // the given name in this mutation.
  19388. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  19389. return nil
  19390. }
  19391. // ClearedEdges returns all edge names that were cleared in this mutation.
  19392. func (m *LabelTaggingMutation) ClearedEdges() []string {
  19393. edges := make([]string, 0, 0)
  19394. return edges
  19395. }
  19396. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19397. // was cleared in this mutation.
  19398. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  19399. return false
  19400. }
  19401. // ClearEdge clears the value of the edge with the given name. It returns an error
  19402. // if that edge is not defined in the schema.
  19403. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  19404. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  19405. }
  19406. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19407. // It returns an error if the edge is not defined in the schema.
  19408. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  19409. return fmt.Errorf("unknown LabelTagging edge %s", name)
  19410. }
  19411. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  19412. type MessageMutation struct {
  19413. config
  19414. op Op
  19415. typ string
  19416. id *int
  19417. wx_wxid *string
  19418. wxid *string
  19419. content *string
  19420. clearedFields map[string]struct{}
  19421. done bool
  19422. oldValue func(context.Context) (*Message, error)
  19423. predicates []predicate.Message
  19424. }
  19425. var _ ent.Mutation = (*MessageMutation)(nil)
  19426. // messageOption allows management of the mutation configuration using functional options.
  19427. type messageOption func(*MessageMutation)
  19428. // newMessageMutation creates new mutation for the Message entity.
  19429. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  19430. m := &MessageMutation{
  19431. config: c,
  19432. op: op,
  19433. typ: TypeMessage,
  19434. clearedFields: make(map[string]struct{}),
  19435. }
  19436. for _, opt := range opts {
  19437. opt(m)
  19438. }
  19439. return m
  19440. }
  19441. // withMessageID sets the ID field of the mutation.
  19442. func withMessageID(id int) messageOption {
  19443. return func(m *MessageMutation) {
  19444. var (
  19445. err error
  19446. once sync.Once
  19447. value *Message
  19448. )
  19449. m.oldValue = func(ctx context.Context) (*Message, error) {
  19450. once.Do(func() {
  19451. if m.done {
  19452. err = errors.New("querying old values post mutation is not allowed")
  19453. } else {
  19454. value, err = m.Client().Message.Get(ctx, id)
  19455. }
  19456. })
  19457. return value, err
  19458. }
  19459. m.id = &id
  19460. }
  19461. }
  19462. // withMessage sets the old Message of the mutation.
  19463. func withMessage(node *Message) messageOption {
  19464. return func(m *MessageMutation) {
  19465. m.oldValue = func(context.Context) (*Message, error) {
  19466. return node, nil
  19467. }
  19468. m.id = &node.ID
  19469. }
  19470. }
  19471. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19472. // executed in a transaction (ent.Tx), a transactional client is returned.
  19473. func (m MessageMutation) Client() *Client {
  19474. client := &Client{config: m.config}
  19475. client.init()
  19476. return client
  19477. }
  19478. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19479. // it returns an error otherwise.
  19480. func (m MessageMutation) Tx() (*Tx, error) {
  19481. if _, ok := m.driver.(*txDriver); !ok {
  19482. return nil, errors.New("ent: mutation is not running in a transaction")
  19483. }
  19484. tx := &Tx{config: m.config}
  19485. tx.init()
  19486. return tx, nil
  19487. }
  19488. // ID returns the ID value in the mutation. Note that the ID is only available
  19489. // if it was provided to the builder or after it was returned from the database.
  19490. func (m *MessageMutation) ID() (id int, exists bool) {
  19491. if m.id == nil {
  19492. return
  19493. }
  19494. return *m.id, true
  19495. }
  19496. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19497. // That means, if the mutation is applied within a transaction with an isolation level such
  19498. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19499. // or updated by the mutation.
  19500. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  19501. switch {
  19502. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19503. id, exists := m.ID()
  19504. if exists {
  19505. return []int{id}, nil
  19506. }
  19507. fallthrough
  19508. case m.op.Is(OpUpdate | OpDelete):
  19509. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  19510. default:
  19511. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19512. }
  19513. }
  19514. // SetWxWxid sets the "wx_wxid" field.
  19515. func (m *MessageMutation) SetWxWxid(s string) {
  19516. m.wx_wxid = &s
  19517. }
  19518. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  19519. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  19520. v := m.wx_wxid
  19521. if v == nil {
  19522. return
  19523. }
  19524. return *v, true
  19525. }
  19526. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  19527. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  19528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19529. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  19530. if !m.op.Is(OpUpdateOne) {
  19531. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  19532. }
  19533. if m.id == nil || m.oldValue == nil {
  19534. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  19535. }
  19536. oldValue, err := m.oldValue(ctx)
  19537. if err != nil {
  19538. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  19539. }
  19540. return oldValue.WxWxid, nil
  19541. }
  19542. // ClearWxWxid clears the value of the "wx_wxid" field.
  19543. func (m *MessageMutation) ClearWxWxid() {
  19544. m.wx_wxid = nil
  19545. m.clearedFields[message.FieldWxWxid] = struct{}{}
  19546. }
  19547. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  19548. func (m *MessageMutation) WxWxidCleared() bool {
  19549. _, ok := m.clearedFields[message.FieldWxWxid]
  19550. return ok
  19551. }
  19552. // ResetWxWxid resets all changes to the "wx_wxid" field.
  19553. func (m *MessageMutation) ResetWxWxid() {
  19554. m.wx_wxid = nil
  19555. delete(m.clearedFields, message.FieldWxWxid)
  19556. }
  19557. // SetWxid sets the "wxid" field.
  19558. func (m *MessageMutation) SetWxid(s string) {
  19559. m.wxid = &s
  19560. }
  19561. // Wxid returns the value of the "wxid" field in the mutation.
  19562. func (m *MessageMutation) Wxid() (r string, exists bool) {
  19563. v := m.wxid
  19564. if v == nil {
  19565. return
  19566. }
  19567. return *v, true
  19568. }
  19569. // OldWxid returns the old "wxid" field's value of the Message entity.
  19570. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  19571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19572. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  19573. if !m.op.Is(OpUpdateOne) {
  19574. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  19575. }
  19576. if m.id == nil || m.oldValue == nil {
  19577. return v, errors.New("OldWxid requires an ID field in the mutation")
  19578. }
  19579. oldValue, err := m.oldValue(ctx)
  19580. if err != nil {
  19581. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  19582. }
  19583. return oldValue.Wxid, nil
  19584. }
  19585. // ResetWxid resets all changes to the "wxid" field.
  19586. func (m *MessageMutation) ResetWxid() {
  19587. m.wxid = nil
  19588. }
  19589. // SetContent sets the "content" field.
  19590. func (m *MessageMutation) SetContent(s string) {
  19591. m.content = &s
  19592. }
  19593. // Content returns the value of the "content" field in the mutation.
  19594. func (m *MessageMutation) Content() (r string, exists bool) {
  19595. v := m.content
  19596. if v == nil {
  19597. return
  19598. }
  19599. return *v, true
  19600. }
  19601. // OldContent returns the old "content" field's value of the Message entity.
  19602. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  19603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19604. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  19605. if !m.op.Is(OpUpdateOne) {
  19606. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  19607. }
  19608. if m.id == nil || m.oldValue == nil {
  19609. return v, errors.New("OldContent requires an ID field in the mutation")
  19610. }
  19611. oldValue, err := m.oldValue(ctx)
  19612. if err != nil {
  19613. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  19614. }
  19615. return oldValue.Content, nil
  19616. }
  19617. // ResetContent resets all changes to the "content" field.
  19618. func (m *MessageMutation) ResetContent() {
  19619. m.content = nil
  19620. }
  19621. // Where appends a list predicates to the MessageMutation builder.
  19622. func (m *MessageMutation) Where(ps ...predicate.Message) {
  19623. m.predicates = append(m.predicates, ps...)
  19624. }
  19625. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  19626. // users can use type-assertion to append predicates that do not depend on any generated package.
  19627. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  19628. p := make([]predicate.Message, len(ps))
  19629. for i := range ps {
  19630. p[i] = ps[i]
  19631. }
  19632. m.Where(p...)
  19633. }
  19634. // Op returns the operation name.
  19635. func (m *MessageMutation) Op() Op {
  19636. return m.op
  19637. }
  19638. // SetOp allows setting the mutation operation.
  19639. func (m *MessageMutation) SetOp(op Op) {
  19640. m.op = op
  19641. }
  19642. // Type returns the node type of this mutation (Message).
  19643. func (m *MessageMutation) Type() string {
  19644. return m.typ
  19645. }
  19646. // Fields returns all fields that were changed during this mutation. Note that in
  19647. // order to get all numeric fields that were incremented/decremented, call
  19648. // AddedFields().
  19649. func (m *MessageMutation) Fields() []string {
  19650. fields := make([]string, 0, 3)
  19651. if m.wx_wxid != nil {
  19652. fields = append(fields, message.FieldWxWxid)
  19653. }
  19654. if m.wxid != nil {
  19655. fields = append(fields, message.FieldWxid)
  19656. }
  19657. if m.content != nil {
  19658. fields = append(fields, message.FieldContent)
  19659. }
  19660. return fields
  19661. }
  19662. // Field returns the value of a field with the given name. The second boolean
  19663. // return value indicates that this field was not set, or was not defined in the
  19664. // schema.
  19665. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  19666. switch name {
  19667. case message.FieldWxWxid:
  19668. return m.WxWxid()
  19669. case message.FieldWxid:
  19670. return m.Wxid()
  19671. case message.FieldContent:
  19672. return m.Content()
  19673. }
  19674. return nil, false
  19675. }
  19676. // OldField returns the old value of the field from the database. An error is
  19677. // returned if the mutation operation is not UpdateOne, or the query to the
  19678. // database failed.
  19679. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19680. switch name {
  19681. case message.FieldWxWxid:
  19682. return m.OldWxWxid(ctx)
  19683. case message.FieldWxid:
  19684. return m.OldWxid(ctx)
  19685. case message.FieldContent:
  19686. return m.OldContent(ctx)
  19687. }
  19688. return nil, fmt.Errorf("unknown Message field %s", name)
  19689. }
  19690. // SetField sets the value of a field with the given name. It returns an error if
  19691. // the field is not defined in the schema, or if the type mismatched the field
  19692. // type.
  19693. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  19694. switch name {
  19695. case message.FieldWxWxid:
  19696. v, ok := value.(string)
  19697. if !ok {
  19698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19699. }
  19700. m.SetWxWxid(v)
  19701. return nil
  19702. case message.FieldWxid:
  19703. v, ok := value.(string)
  19704. if !ok {
  19705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19706. }
  19707. m.SetWxid(v)
  19708. return nil
  19709. case message.FieldContent:
  19710. v, ok := value.(string)
  19711. if !ok {
  19712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19713. }
  19714. m.SetContent(v)
  19715. return nil
  19716. }
  19717. return fmt.Errorf("unknown Message field %s", name)
  19718. }
  19719. // AddedFields returns all numeric fields that were incremented/decremented during
  19720. // this mutation.
  19721. func (m *MessageMutation) AddedFields() []string {
  19722. return nil
  19723. }
  19724. // AddedField returns the numeric value that was incremented/decremented on a field
  19725. // with the given name. The second boolean return value indicates that this field
  19726. // was not set, or was not defined in the schema.
  19727. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  19728. return nil, false
  19729. }
  19730. // AddField adds the value to the field with the given name. It returns an error if
  19731. // the field is not defined in the schema, or if the type mismatched the field
  19732. // type.
  19733. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  19734. switch name {
  19735. }
  19736. return fmt.Errorf("unknown Message numeric field %s", name)
  19737. }
  19738. // ClearedFields returns all nullable fields that were cleared during this
  19739. // mutation.
  19740. func (m *MessageMutation) ClearedFields() []string {
  19741. var fields []string
  19742. if m.FieldCleared(message.FieldWxWxid) {
  19743. fields = append(fields, message.FieldWxWxid)
  19744. }
  19745. return fields
  19746. }
  19747. // FieldCleared returns a boolean indicating if a field with the given name was
  19748. // cleared in this mutation.
  19749. func (m *MessageMutation) FieldCleared(name string) bool {
  19750. _, ok := m.clearedFields[name]
  19751. return ok
  19752. }
  19753. // ClearField clears the value of the field with the given name. It returns an
  19754. // error if the field is not defined in the schema.
  19755. func (m *MessageMutation) ClearField(name string) error {
  19756. switch name {
  19757. case message.FieldWxWxid:
  19758. m.ClearWxWxid()
  19759. return nil
  19760. }
  19761. return fmt.Errorf("unknown Message nullable field %s", name)
  19762. }
  19763. // ResetField resets all changes in the mutation for the field with the given name.
  19764. // It returns an error if the field is not defined in the schema.
  19765. func (m *MessageMutation) ResetField(name string) error {
  19766. switch name {
  19767. case message.FieldWxWxid:
  19768. m.ResetWxWxid()
  19769. return nil
  19770. case message.FieldWxid:
  19771. m.ResetWxid()
  19772. return nil
  19773. case message.FieldContent:
  19774. m.ResetContent()
  19775. return nil
  19776. }
  19777. return fmt.Errorf("unknown Message field %s", name)
  19778. }
  19779. // AddedEdges returns all edge names that were set/added in this mutation.
  19780. func (m *MessageMutation) AddedEdges() []string {
  19781. edges := make([]string, 0, 0)
  19782. return edges
  19783. }
  19784. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19785. // name in this mutation.
  19786. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  19787. return nil
  19788. }
  19789. // RemovedEdges returns all edge names that were removed in this mutation.
  19790. func (m *MessageMutation) RemovedEdges() []string {
  19791. edges := make([]string, 0, 0)
  19792. return edges
  19793. }
  19794. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19795. // the given name in this mutation.
  19796. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  19797. return nil
  19798. }
  19799. // ClearedEdges returns all edge names that were cleared in this mutation.
  19800. func (m *MessageMutation) ClearedEdges() []string {
  19801. edges := make([]string, 0, 0)
  19802. return edges
  19803. }
  19804. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19805. // was cleared in this mutation.
  19806. func (m *MessageMutation) EdgeCleared(name string) bool {
  19807. return false
  19808. }
  19809. // ClearEdge clears the value of the edge with the given name. It returns an error
  19810. // if that edge is not defined in the schema.
  19811. func (m *MessageMutation) ClearEdge(name string) error {
  19812. return fmt.Errorf("unknown Message unique edge %s", name)
  19813. }
  19814. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19815. // It returns an error if the edge is not defined in the schema.
  19816. func (m *MessageMutation) ResetEdge(name string) error {
  19817. return fmt.Errorf("unknown Message edge %s", name)
  19818. }
  19819. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  19820. type MessageRecordsMutation struct {
  19821. config
  19822. op Op
  19823. typ string
  19824. id *uint64
  19825. created_at *time.Time
  19826. updated_at *time.Time
  19827. status *uint8
  19828. addstatus *int8
  19829. bot_wxid *string
  19830. contact_type *int
  19831. addcontact_type *int
  19832. contact_wxid *string
  19833. content_type *int
  19834. addcontent_type *int
  19835. content *string
  19836. meta *custom_types.Meta
  19837. error_detail *string
  19838. send_time *time.Time
  19839. source_type *int
  19840. addsource_type *int
  19841. organization_id *uint64
  19842. addorganization_id *int64
  19843. clearedFields map[string]struct{}
  19844. sop_stage *uint64
  19845. clearedsop_stage bool
  19846. sop_node *uint64
  19847. clearedsop_node bool
  19848. message_contact *uint64
  19849. clearedmessage_contact bool
  19850. done bool
  19851. oldValue func(context.Context) (*MessageRecords, error)
  19852. predicates []predicate.MessageRecords
  19853. }
  19854. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  19855. // messagerecordsOption allows management of the mutation configuration using functional options.
  19856. type messagerecordsOption func(*MessageRecordsMutation)
  19857. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  19858. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  19859. m := &MessageRecordsMutation{
  19860. config: c,
  19861. op: op,
  19862. typ: TypeMessageRecords,
  19863. clearedFields: make(map[string]struct{}),
  19864. }
  19865. for _, opt := range opts {
  19866. opt(m)
  19867. }
  19868. return m
  19869. }
  19870. // withMessageRecordsID sets the ID field of the mutation.
  19871. func withMessageRecordsID(id uint64) messagerecordsOption {
  19872. return func(m *MessageRecordsMutation) {
  19873. var (
  19874. err error
  19875. once sync.Once
  19876. value *MessageRecords
  19877. )
  19878. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  19879. once.Do(func() {
  19880. if m.done {
  19881. err = errors.New("querying old values post mutation is not allowed")
  19882. } else {
  19883. value, err = m.Client().MessageRecords.Get(ctx, id)
  19884. }
  19885. })
  19886. return value, err
  19887. }
  19888. m.id = &id
  19889. }
  19890. }
  19891. // withMessageRecords sets the old MessageRecords of the mutation.
  19892. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  19893. return func(m *MessageRecordsMutation) {
  19894. m.oldValue = func(context.Context) (*MessageRecords, error) {
  19895. return node, nil
  19896. }
  19897. m.id = &node.ID
  19898. }
  19899. }
  19900. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19901. // executed in a transaction (ent.Tx), a transactional client is returned.
  19902. func (m MessageRecordsMutation) Client() *Client {
  19903. client := &Client{config: m.config}
  19904. client.init()
  19905. return client
  19906. }
  19907. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19908. // it returns an error otherwise.
  19909. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  19910. if _, ok := m.driver.(*txDriver); !ok {
  19911. return nil, errors.New("ent: mutation is not running in a transaction")
  19912. }
  19913. tx := &Tx{config: m.config}
  19914. tx.init()
  19915. return tx, nil
  19916. }
  19917. // SetID sets the value of the id field. Note that this
  19918. // operation is only accepted on creation of MessageRecords entities.
  19919. func (m *MessageRecordsMutation) SetID(id uint64) {
  19920. m.id = &id
  19921. }
  19922. // ID returns the ID value in the mutation. Note that the ID is only available
  19923. // if it was provided to the builder or after it was returned from the database.
  19924. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  19925. if m.id == nil {
  19926. return
  19927. }
  19928. return *m.id, true
  19929. }
  19930. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19931. // That means, if the mutation is applied within a transaction with an isolation level such
  19932. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19933. // or updated by the mutation.
  19934. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  19935. switch {
  19936. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19937. id, exists := m.ID()
  19938. if exists {
  19939. return []uint64{id}, nil
  19940. }
  19941. fallthrough
  19942. case m.op.Is(OpUpdate | OpDelete):
  19943. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  19944. default:
  19945. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19946. }
  19947. }
  19948. // SetCreatedAt sets the "created_at" field.
  19949. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  19950. m.created_at = &t
  19951. }
  19952. // CreatedAt returns the value of the "created_at" field in the mutation.
  19953. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  19954. v := m.created_at
  19955. if v == nil {
  19956. return
  19957. }
  19958. return *v, true
  19959. }
  19960. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  19961. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19963. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19964. if !m.op.Is(OpUpdateOne) {
  19965. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19966. }
  19967. if m.id == nil || m.oldValue == nil {
  19968. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19969. }
  19970. oldValue, err := m.oldValue(ctx)
  19971. if err != nil {
  19972. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19973. }
  19974. return oldValue.CreatedAt, nil
  19975. }
  19976. // ResetCreatedAt resets all changes to the "created_at" field.
  19977. func (m *MessageRecordsMutation) ResetCreatedAt() {
  19978. m.created_at = nil
  19979. }
  19980. // SetUpdatedAt sets the "updated_at" field.
  19981. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  19982. m.updated_at = &t
  19983. }
  19984. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19985. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  19986. v := m.updated_at
  19987. if v == nil {
  19988. return
  19989. }
  19990. return *v, true
  19991. }
  19992. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  19993. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19995. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19996. if !m.op.Is(OpUpdateOne) {
  19997. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19998. }
  19999. if m.id == nil || m.oldValue == nil {
  20000. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20001. }
  20002. oldValue, err := m.oldValue(ctx)
  20003. if err != nil {
  20004. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20005. }
  20006. return oldValue.UpdatedAt, nil
  20007. }
  20008. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20009. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  20010. m.updated_at = nil
  20011. }
  20012. // SetStatus sets the "status" field.
  20013. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  20014. m.status = &u
  20015. m.addstatus = nil
  20016. }
  20017. // Status returns the value of the "status" field in the mutation.
  20018. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  20019. v := m.status
  20020. if v == nil {
  20021. return
  20022. }
  20023. return *v, true
  20024. }
  20025. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  20026. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20028. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20029. if !m.op.Is(OpUpdateOne) {
  20030. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20031. }
  20032. if m.id == nil || m.oldValue == nil {
  20033. return v, errors.New("OldStatus requires an ID field in the mutation")
  20034. }
  20035. oldValue, err := m.oldValue(ctx)
  20036. if err != nil {
  20037. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20038. }
  20039. return oldValue.Status, nil
  20040. }
  20041. // AddStatus adds u to the "status" field.
  20042. func (m *MessageRecordsMutation) AddStatus(u int8) {
  20043. if m.addstatus != nil {
  20044. *m.addstatus += u
  20045. } else {
  20046. m.addstatus = &u
  20047. }
  20048. }
  20049. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20050. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  20051. v := m.addstatus
  20052. if v == nil {
  20053. return
  20054. }
  20055. return *v, true
  20056. }
  20057. // ClearStatus clears the value of the "status" field.
  20058. func (m *MessageRecordsMutation) ClearStatus() {
  20059. m.status = nil
  20060. m.addstatus = nil
  20061. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  20062. }
  20063. // StatusCleared returns if the "status" field was cleared in this mutation.
  20064. func (m *MessageRecordsMutation) StatusCleared() bool {
  20065. _, ok := m.clearedFields[messagerecords.FieldStatus]
  20066. return ok
  20067. }
  20068. // ResetStatus resets all changes to the "status" field.
  20069. func (m *MessageRecordsMutation) ResetStatus() {
  20070. m.status = nil
  20071. m.addstatus = nil
  20072. delete(m.clearedFields, messagerecords.FieldStatus)
  20073. }
  20074. // SetBotWxid sets the "bot_wxid" field.
  20075. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  20076. m.bot_wxid = &s
  20077. }
  20078. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  20079. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  20080. v := m.bot_wxid
  20081. if v == nil {
  20082. return
  20083. }
  20084. return *v, true
  20085. }
  20086. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  20087. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20089. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  20090. if !m.op.Is(OpUpdateOne) {
  20091. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  20092. }
  20093. if m.id == nil || m.oldValue == nil {
  20094. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  20095. }
  20096. oldValue, err := m.oldValue(ctx)
  20097. if err != nil {
  20098. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  20099. }
  20100. return oldValue.BotWxid, nil
  20101. }
  20102. // ResetBotWxid resets all changes to the "bot_wxid" field.
  20103. func (m *MessageRecordsMutation) ResetBotWxid() {
  20104. m.bot_wxid = nil
  20105. }
  20106. // SetContactID sets the "contact_id" field.
  20107. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  20108. m.message_contact = &u
  20109. }
  20110. // ContactID returns the value of the "contact_id" field in the mutation.
  20111. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  20112. v := m.message_contact
  20113. if v == nil {
  20114. return
  20115. }
  20116. return *v, true
  20117. }
  20118. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  20119. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20121. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  20122. if !m.op.Is(OpUpdateOne) {
  20123. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  20124. }
  20125. if m.id == nil || m.oldValue == nil {
  20126. return v, errors.New("OldContactID requires an ID field in the mutation")
  20127. }
  20128. oldValue, err := m.oldValue(ctx)
  20129. if err != nil {
  20130. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  20131. }
  20132. return oldValue.ContactID, nil
  20133. }
  20134. // ClearContactID clears the value of the "contact_id" field.
  20135. func (m *MessageRecordsMutation) ClearContactID() {
  20136. m.message_contact = nil
  20137. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  20138. }
  20139. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  20140. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  20141. _, ok := m.clearedFields[messagerecords.FieldContactID]
  20142. return ok
  20143. }
  20144. // ResetContactID resets all changes to the "contact_id" field.
  20145. func (m *MessageRecordsMutation) ResetContactID() {
  20146. m.message_contact = nil
  20147. delete(m.clearedFields, messagerecords.FieldContactID)
  20148. }
  20149. // SetContactType sets the "contact_type" field.
  20150. func (m *MessageRecordsMutation) SetContactType(i int) {
  20151. m.contact_type = &i
  20152. m.addcontact_type = nil
  20153. }
  20154. // ContactType returns the value of the "contact_type" field in the mutation.
  20155. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  20156. v := m.contact_type
  20157. if v == nil {
  20158. return
  20159. }
  20160. return *v, true
  20161. }
  20162. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  20163. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20165. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  20166. if !m.op.Is(OpUpdateOne) {
  20167. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  20168. }
  20169. if m.id == nil || m.oldValue == nil {
  20170. return v, errors.New("OldContactType requires an ID field in the mutation")
  20171. }
  20172. oldValue, err := m.oldValue(ctx)
  20173. if err != nil {
  20174. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  20175. }
  20176. return oldValue.ContactType, nil
  20177. }
  20178. // AddContactType adds i to the "contact_type" field.
  20179. func (m *MessageRecordsMutation) AddContactType(i int) {
  20180. if m.addcontact_type != nil {
  20181. *m.addcontact_type += i
  20182. } else {
  20183. m.addcontact_type = &i
  20184. }
  20185. }
  20186. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  20187. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  20188. v := m.addcontact_type
  20189. if v == nil {
  20190. return
  20191. }
  20192. return *v, true
  20193. }
  20194. // ResetContactType resets all changes to the "contact_type" field.
  20195. func (m *MessageRecordsMutation) ResetContactType() {
  20196. m.contact_type = nil
  20197. m.addcontact_type = nil
  20198. }
  20199. // SetContactWxid sets the "contact_wxid" field.
  20200. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  20201. m.contact_wxid = &s
  20202. }
  20203. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  20204. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  20205. v := m.contact_wxid
  20206. if v == nil {
  20207. return
  20208. }
  20209. return *v, true
  20210. }
  20211. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  20212. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20214. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  20215. if !m.op.Is(OpUpdateOne) {
  20216. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  20217. }
  20218. if m.id == nil || m.oldValue == nil {
  20219. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  20220. }
  20221. oldValue, err := m.oldValue(ctx)
  20222. if err != nil {
  20223. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  20224. }
  20225. return oldValue.ContactWxid, nil
  20226. }
  20227. // ResetContactWxid resets all changes to the "contact_wxid" field.
  20228. func (m *MessageRecordsMutation) ResetContactWxid() {
  20229. m.contact_wxid = nil
  20230. }
  20231. // SetContentType sets the "content_type" field.
  20232. func (m *MessageRecordsMutation) SetContentType(i int) {
  20233. m.content_type = &i
  20234. m.addcontent_type = nil
  20235. }
  20236. // ContentType returns the value of the "content_type" field in the mutation.
  20237. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  20238. v := m.content_type
  20239. if v == nil {
  20240. return
  20241. }
  20242. return *v, true
  20243. }
  20244. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  20245. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20247. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  20248. if !m.op.Is(OpUpdateOne) {
  20249. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  20250. }
  20251. if m.id == nil || m.oldValue == nil {
  20252. return v, errors.New("OldContentType requires an ID field in the mutation")
  20253. }
  20254. oldValue, err := m.oldValue(ctx)
  20255. if err != nil {
  20256. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  20257. }
  20258. return oldValue.ContentType, nil
  20259. }
  20260. // AddContentType adds i to the "content_type" field.
  20261. func (m *MessageRecordsMutation) AddContentType(i int) {
  20262. if m.addcontent_type != nil {
  20263. *m.addcontent_type += i
  20264. } else {
  20265. m.addcontent_type = &i
  20266. }
  20267. }
  20268. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  20269. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  20270. v := m.addcontent_type
  20271. if v == nil {
  20272. return
  20273. }
  20274. return *v, true
  20275. }
  20276. // ResetContentType resets all changes to the "content_type" field.
  20277. func (m *MessageRecordsMutation) ResetContentType() {
  20278. m.content_type = nil
  20279. m.addcontent_type = nil
  20280. }
  20281. // SetContent sets the "content" field.
  20282. func (m *MessageRecordsMutation) SetContent(s string) {
  20283. m.content = &s
  20284. }
  20285. // Content returns the value of the "content" field in the mutation.
  20286. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  20287. v := m.content
  20288. if v == nil {
  20289. return
  20290. }
  20291. return *v, true
  20292. }
  20293. // OldContent returns the old "content" field's value of the MessageRecords entity.
  20294. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20296. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  20297. if !m.op.Is(OpUpdateOne) {
  20298. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  20299. }
  20300. if m.id == nil || m.oldValue == nil {
  20301. return v, errors.New("OldContent requires an ID field in the mutation")
  20302. }
  20303. oldValue, err := m.oldValue(ctx)
  20304. if err != nil {
  20305. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  20306. }
  20307. return oldValue.Content, nil
  20308. }
  20309. // ResetContent resets all changes to the "content" field.
  20310. func (m *MessageRecordsMutation) ResetContent() {
  20311. m.content = nil
  20312. }
  20313. // SetMeta sets the "meta" field.
  20314. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  20315. m.meta = &ct
  20316. }
  20317. // Meta returns the value of the "meta" field in the mutation.
  20318. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  20319. v := m.meta
  20320. if v == nil {
  20321. return
  20322. }
  20323. return *v, true
  20324. }
  20325. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  20326. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20328. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  20329. if !m.op.Is(OpUpdateOne) {
  20330. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  20331. }
  20332. if m.id == nil || m.oldValue == nil {
  20333. return v, errors.New("OldMeta requires an ID field in the mutation")
  20334. }
  20335. oldValue, err := m.oldValue(ctx)
  20336. if err != nil {
  20337. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  20338. }
  20339. return oldValue.Meta, nil
  20340. }
  20341. // ClearMeta clears the value of the "meta" field.
  20342. func (m *MessageRecordsMutation) ClearMeta() {
  20343. m.meta = nil
  20344. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  20345. }
  20346. // MetaCleared returns if the "meta" field was cleared in this mutation.
  20347. func (m *MessageRecordsMutation) MetaCleared() bool {
  20348. _, ok := m.clearedFields[messagerecords.FieldMeta]
  20349. return ok
  20350. }
  20351. // ResetMeta resets all changes to the "meta" field.
  20352. func (m *MessageRecordsMutation) ResetMeta() {
  20353. m.meta = nil
  20354. delete(m.clearedFields, messagerecords.FieldMeta)
  20355. }
  20356. // SetErrorDetail sets the "error_detail" field.
  20357. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  20358. m.error_detail = &s
  20359. }
  20360. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  20361. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  20362. v := m.error_detail
  20363. if v == nil {
  20364. return
  20365. }
  20366. return *v, true
  20367. }
  20368. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  20369. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20371. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  20372. if !m.op.Is(OpUpdateOne) {
  20373. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  20374. }
  20375. if m.id == nil || m.oldValue == nil {
  20376. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  20377. }
  20378. oldValue, err := m.oldValue(ctx)
  20379. if err != nil {
  20380. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  20381. }
  20382. return oldValue.ErrorDetail, nil
  20383. }
  20384. // ResetErrorDetail resets all changes to the "error_detail" field.
  20385. func (m *MessageRecordsMutation) ResetErrorDetail() {
  20386. m.error_detail = nil
  20387. }
  20388. // SetSendTime sets the "send_time" field.
  20389. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  20390. m.send_time = &t
  20391. }
  20392. // SendTime returns the value of the "send_time" field in the mutation.
  20393. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  20394. v := m.send_time
  20395. if v == nil {
  20396. return
  20397. }
  20398. return *v, true
  20399. }
  20400. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  20401. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20403. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  20404. if !m.op.Is(OpUpdateOne) {
  20405. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  20406. }
  20407. if m.id == nil || m.oldValue == nil {
  20408. return v, errors.New("OldSendTime requires an ID field in the mutation")
  20409. }
  20410. oldValue, err := m.oldValue(ctx)
  20411. if err != nil {
  20412. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  20413. }
  20414. return oldValue.SendTime, nil
  20415. }
  20416. // ClearSendTime clears the value of the "send_time" field.
  20417. func (m *MessageRecordsMutation) ClearSendTime() {
  20418. m.send_time = nil
  20419. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  20420. }
  20421. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  20422. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  20423. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  20424. return ok
  20425. }
  20426. // ResetSendTime resets all changes to the "send_time" field.
  20427. func (m *MessageRecordsMutation) ResetSendTime() {
  20428. m.send_time = nil
  20429. delete(m.clearedFields, messagerecords.FieldSendTime)
  20430. }
  20431. // SetSourceType sets the "source_type" field.
  20432. func (m *MessageRecordsMutation) SetSourceType(i int) {
  20433. m.source_type = &i
  20434. m.addsource_type = nil
  20435. }
  20436. // SourceType returns the value of the "source_type" field in the mutation.
  20437. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  20438. v := m.source_type
  20439. if v == nil {
  20440. return
  20441. }
  20442. return *v, true
  20443. }
  20444. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  20445. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20447. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  20448. if !m.op.Is(OpUpdateOne) {
  20449. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  20450. }
  20451. if m.id == nil || m.oldValue == nil {
  20452. return v, errors.New("OldSourceType requires an ID field in the mutation")
  20453. }
  20454. oldValue, err := m.oldValue(ctx)
  20455. if err != nil {
  20456. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  20457. }
  20458. return oldValue.SourceType, nil
  20459. }
  20460. // AddSourceType adds i to the "source_type" field.
  20461. func (m *MessageRecordsMutation) AddSourceType(i int) {
  20462. if m.addsource_type != nil {
  20463. *m.addsource_type += i
  20464. } else {
  20465. m.addsource_type = &i
  20466. }
  20467. }
  20468. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  20469. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  20470. v := m.addsource_type
  20471. if v == nil {
  20472. return
  20473. }
  20474. return *v, true
  20475. }
  20476. // ResetSourceType resets all changes to the "source_type" field.
  20477. func (m *MessageRecordsMutation) ResetSourceType() {
  20478. m.source_type = nil
  20479. m.addsource_type = nil
  20480. }
  20481. // SetSourceID sets the "source_id" field.
  20482. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  20483. m.sop_stage = &u
  20484. }
  20485. // SourceID returns the value of the "source_id" field in the mutation.
  20486. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  20487. v := m.sop_stage
  20488. if v == nil {
  20489. return
  20490. }
  20491. return *v, true
  20492. }
  20493. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  20494. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20496. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  20497. if !m.op.Is(OpUpdateOne) {
  20498. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  20499. }
  20500. if m.id == nil || m.oldValue == nil {
  20501. return v, errors.New("OldSourceID requires an ID field in the mutation")
  20502. }
  20503. oldValue, err := m.oldValue(ctx)
  20504. if err != nil {
  20505. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  20506. }
  20507. return oldValue.SourceID, nil
  20508. }
  20509. // ClearSourceID clears the value of the "source_id" field.
  20510. func (m *MessageRecordsMutation) ClearSourceID() {
  20511. m.sop_stage = nil
  20512. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  20513. }
  20514. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  20515. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  20516. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  20517. return ok
  20518. }
  20519. // ResetSourceID resets all changes to the "source_id" field.
  20520. func (m *MessageRecordsMutation) ResetSourceID() {
  20521. m.sop_stage = nil
  20522. delete(m.clearedFields, messagerecords.FieldSourceID)
  20523. }
  20524. // SetSubSourceID sets the "sub_source_id" field.
  20525. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  20526. m.sop_node = &u
  20527. }
  20528. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  20529. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  20530. v := m.sop_node
  20531. if v == nil {
  20532. return
  20533. }
  20534. return *v, true
  20535. }
  20536. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  20537. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20539. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  20540. if !m.op.Is(OpUpdateOne) {
  20541. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  20542. }
  20543. if m.id == nil || m.oldValue == nil {
  20544. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  20545. }
  20546. oldValue, err := m.oldValue(ctx)
  20547. if err != nil {
  20548. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  20549. }
  20550. return oldValue.SubSourceID, nil
  20551. }
  20552. // ClearSubSourceID clears the value of the "sub_source_id" field.
  20553. func (m *MessageRecordsMutation) ClearSubSourceID() {
  20554. m.sop_node = nil
  20555. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  20556. }
  20557. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  20558. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  20559. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  20560. return ok
  20561. }
  20562. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  20563. func (m *MessageRecordsMutation) ResetSubSourceID() {
  20564. m.sop_node = nil
  20565. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  20566. }
  20567. // SetOrganizationID sets the "organization_id" field.
  20568. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  20569. m.organization_id = &u
  20570. m.addorganization_id = nil
  20571. }
  20572. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20573. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  20574. v := m.organization_id
  20575. if v == nil {
  20576. return
  20577. }
  20578. return *v, true
  20579. }
  20580. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  20581. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20583. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20584. if !m.op.Is(OpUpdateOne) {
  20585. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20586. }
  20587. if m.id == nil || m.oldValue == nil {
  20588. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20589. }
  20590. oldValue, err := m.oldValue(ctx)
  20591. if err != nil {
  20592. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20593. }
  20594. return oldValue.OrganizationID, nil
  20595. }
  20596. // AddOrganizationID adds u to the "organization_id" field.
  20597. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  20598. if m.addorganization_id != nil {
  20599. *m.addorganization_id += u
  20600. } else {
  20601. m.addorganization_id = &u
  20602. }
  20603. }
  20604. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20605. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  20606. v := m.addorganization_id
  20607. if v == nil {
  20608. return
  20609. }
  20610. return *v, true
  20611. }
  20612. // ClearOrganizationID clears the value of the "organization_id" field.
  20613. func (m *MessageRecordsMutation) ClearOrganizationID() {
  20614. m.organization_id = nil
  20615. m.addorganization_id = nil
  20616. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  20617. }
  20618. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20619. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  20620. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  20621. return ok
  20622. }
  20623. // ResetOrganizationID resets all changes to the "organization_id" field.
  20624. func (m *MessageRecordsMutation) ResetOrganizationID() {
  20625. m.organization_id = nil
  20626. m.addorganization_id = nil
  20627. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  20628. }
  20629. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  20630. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  20631. m.sop_stage = &id
  20632. }
  20633. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  20634. func (m *MessageRecordsMutation) ClearSopStage() {
  20635. m.clearedsop_stage = true
  20636. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  20637. }
  20638. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  20639. func (m *MessageRecordsMutation) SopStageCleared() bool {
  20640. return m.SourceIDCleared() || m.clearedsop_stage
  20641. }
  20642. // SopStageID returns the "sop_stage" edge ID in the mutation.
  20643. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  20644. if m.sop_stage != nil {
  20645. return *m.sop_stage, true
  20646. }
  20647. return
  20648. }
  20649. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  20650. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20651. // SopStageID instead. It exists only for internal usage by the builders.
  20652. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  20653. if id := m.sop_stage; id != nil {
  20654. ids = append(ids, *id)
  20655. }
  20656. return
  20657. }
  20658. // ResetSopStage resets all changes to the "sop_stage" edge.
  20659. func (m *MessageRecordsMutation) ResetSopStage() {
  20660. m.sop_stage = nil
  20661. m.clearedsop_stage = false
  20662. }
  20663. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  20664. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  20665. m.sop_node = &id
  20666. }
  20667. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  20668. func (m *MessageRecordsMutation) ClearSopNode() {
  20669. m.clearedsop_node = true
  20670. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  20671. }
  20672. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  20673. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  20674. return m.SubSourceIDCleared() || m.clearedsop_node
  20675. }
  20676. // SopNodeID returns the "sop_node" edge ID in the mutation.
  20677. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  20678. if m.sop_node != nil {
  20679. return *m.sop_node, true
  20680. }
  20681. return
  20682. }
  20683. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  20684. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20685. // SopNodeID instead. It exists only for internal usage by the builders.
  20686. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  20687. if id := m.sop_node; id != nil {
  20688. ids = append(ids, *id)
  20689. }
  20690. return
  20691. }
  20692. // ResetSopNode resets all changes to the "sop_node" edge.
  20693. func (m *MessageRecordsMutation) ResetSopNode() {
  20694. m.sop_node = nil
  20695. m.clearedsop_node = false
  20696. }
  20697. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  20698. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  20699. m.message_contact = &id
  20700. }
  20701. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  20702. func (m *MessageRecordsMutation) ClearMessageContact() {
  20703. m.clearedmessage_contact = true
  20704. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  20705. }
  20706. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  20707. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  20708. return m.ContactIDCleared() || m.clearedmessage_contact
  20709. }
  20710. // MessageContactID returns the "message_contact" edge ID in the mutation.
  20711. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  20712. if m.message_contact != nil {
  20713. return *m.message_contact, true
  20714. }
  20715. return
  20716. }
  20717. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  20718. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20719. // MessageContactID instead. It exists only for internal usage by the builders.
  20720. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  20721. if id := m.message_contact; id != nil {
  20722. ids = append(ids, *id)
  20723. }
  20724. return
  20725. }
  20726. // ResetMessageContact resets all changes to the "message_contact" edge.
  20727. func (m *MessageRecordsMutation) ResetMessageContact() {
  20728. m.message_contact = nil
  20729. m.clearedmessage_contact = false
  20730. }
  20731. // Where appends a list predicates to the MessageRecordsMutation builder.
  20732. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  20733. m.predicates = append(m.predicates, ps...)
  20734. }
  20735. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  20736. // users can use type-assertion to append predicates that do not depend on any generated package.
  20737. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  20738. p := make([]predicate.MessageRecords, len(ps))
  20739. for i := range ps {
  20740. p[i] = ps[i]
  20741. }
  20742. m.Where(p...)
  20743. }
  20744. // Op returns the operation name.
  20745. func (m *MessageRecordsMutation) Op() Op {
  20746. return m.op
  20747. }
  20748. // SetOp allows setting the mutation operation.
  20749. func (m *MessageRecordsMutation) SetOp(op Op) {
  20750. m.op = op
  20751. }
  20752. // Type returns the node type of this mutation (MessageRecords).
  20753. func (m *MessageRecordsMutation) Type() string {
  20754. return m.typ
  20755. }
  20756. // Fields returns all fields that were changed during this mutation. Note that in
  20757. // order to get all numeric fields that were incremented/decremented, call
  20758. // AddedFields().
  20759. func (m *MessageRecordsMutation) Fields() []string {
  20760. fields := make([]string, 0, 16)
  20761. if m.created_at != nil {
  20762. fields = append(fields, messagerecords.FieldCreatedAt)
  20763. }
  20764. if m.updated_at != nil {
  20765. fields = append(fields, messagerecords.FieldUpdatedAt)
  20766. }
  20767. if m.status != nil {
  20768. fields = append(fields, messagerecords.FieldStatus)
  20769. }
  20770. if m.bot_wxid != nil {
  20771. fields = append(fields, messagerecords.FieldBotWxid)
  20772. }
  20773. if m.message_contact != nil {
  20774. fields = append(fields, messagerecords.FieldContactID)
  20775. }
  20776. if m.contact_type != nil {
  20777. fields = append(fields, messagerecords.FieldContactType)
  20778. }
  20779. if m.contact_wxid != nil {
  20780. fields = append(fields, messagerecords.FieldContactWxid)
  20781. }
  20782. if m.content_type != nil {
  20783. fields = append(fields, messagerecords.FieldContentType)
  20784. }
  20785. if m.content != nil {
  20786. fields = append(fields, messagerecords.FieldContent)
  20787. }
  20788. if m.meta != nil {
  20789. fields = append(fields, messagerecords.FieldMeta)
  20790. }
  20791. if m.error_detail != nil {
  20792. fields = append(fields, messagerecords.FieldErrorDetail)
  20793. }
  20794. if m.send_time != nil {
  20795. fields = append(fields, messagerecords.FieldSendTime)
  20796. }
  20797. if m.source_type != nil {
  20798. fields = append(fields, messagerecords.FieldSourceType)
  20799. }
  20800. if m.sop_stage != nil {
  20801. fields = append(fields, messagerecords.FieldSourceID)
  20802. }
  20803. if m.sop_node != nil {
  20804. fields = append(fields, messagerecords.FieldSubSourceID)
  20805. }
  20806. if m.organization_id != nil {
  20807. fields = append(fields, messagerecords.FieldOrganizationID)
  20808. }
  20809. return fields
  20810. }
  20811. // Field returns the value of a field with the given name. The second boolean
  20812. // return value indicates that this field was not set, or was not defined in the
  20813. // schema.
  20814. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  20815. switch name {
  20816. case messagerecords.FieldCreatedAt:
  20817. return m.CreatedAt()
  20818. case messagerecords.FieldUpdatedAt:
  20819. return m.UpdatedAt()
  20820. case messagerecords.FieldStatus:
  20821. return m.Status()
  20822. case messagerecords.FieldBotWxid:
  20823. return m.BotWxid()
  20824. case messagerecords.FieldContactID:
  20825. return m.ContactID()
  20826. case messagerecords.FieldContactType:
  20827. return m.ContactType()
  20828. case messagerecords.FieldContactWxid:
  20829. return m.ContactWxid()
  20830. case messagerecords.FieldContentType:
  20831. return m.ContentType()
  20832. case messagerecords.FieldContent:
  20833. return m.Content()
  20834. case messagerecords.FieldMeta:
  20835. return m.Meta()
  20836. case messagerecords.FieldErrorDetail:
  20837. return m.ErrorDetail()
  20838. case messagerecords.FieldSendTime:
  20839. return m.SendTime()
  20840. case messagerecords.FieldSourceType:
  20841. return m.SourceType()
  20842. case messagerecords.FieldSourceID:
  20843. return m.SourceID()
  20844. case messagerecords.FieldSubSourceID:
  20845. return m.SubSourceID()
  20846. case messagerecords.FieldOrganizationID:
  20847. return m.OrganizationID()
  20848. }
  20849. return nil, false
  20850. }
  20851. // OldField returns the old value of the field from the database. An error is
  20852. // returned if the mutation operation is not UpdateOne, or the query to the
  20853. // database failed.
  20854. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20855. switch name {
  20856. case messagerecords.FieldCreatedAt:
  20857. return m.OldCreatedAt(ctx)
  20858. case messagerecords.FieldUpdatedAt:
  20859. return m.OldUpdatedAt(ctx)
  20860. case messagerecords.FieldStatus:
  20861. return m.OldStatus(ctx)
  20862. case messagerecords.FieldBotWxid:
  20863. return m.OldBotWxid(ctx)
  20864. case messagerecords.FieldContactID:
  20865. return m.OldContactID(ctx)
  20866. case messagerecords.FieldContactType:
  20867. return m.OldContactType(ctx)
  20868. case messagerecords.FieldContactWxid:
  20869. return m.OldContactWxid(ctx)
  20870. case messagerecords.FieldContentType:
  20871. return m.OldContentType(ctx)
  20872. case messagerecords.FieldContent:
  20873. return m.OldContent(ctx)
  20874. case messagerecords.FieldMeta:
  20875. return m.OldMeta(ctx)
  20876. case messagerecords.FieldErrorDetail:
  20877. return m.OldErrorDetail(ctx)
  20878. case messagerecords.FieldSendTime:
  20879. return m.OldSendTime(ctx)
  20880. case messagerecords.FieldSourceType:
  20881. return m.OldSourceType(ctx)
  20882. case messagerecords.FieldSourceID:
  20883. return m.OldSourceID(ctx)
  20884. case messagerecords.FieldSubSourceID:
  20885. return m.OldSubSourceID(ctx)
  20886. case messagerecords.FieldOrganizationID:
  20887. return m.OldOrganizationID(ctx)
  20888. }
  20889. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  20890. }
  20891. // SetField sets the value of a field with the given name. It returns an error if
  20892. // the field is not defined in the schema, or if the type mismatched the field
  20893. // type.
  20894. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  20895. switch name {
  20896. case messagerecords.FieldCreatedAt:
  20897. v, ok := value.(time.Time)
  20898. if !ok {
  20899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20900. }
  20901. m.SetCreatedAt(v)
  20902. return nil
  20903. case messagerecords.FieldUpdatedAt:
  20904. v, ok := value.(time.Time)
  20905. if !ok {
  20906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20907. }
  20908. m.SetUpdatedAt(v)
  20909. return nil
  20910. case messagerecords.FieldStatus:
  20911. v, ok := value.(uint8)
  20912. if !ok {
  20913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20914. }
  20915. m.SetStatus(v)
  20916. return nil
  20917. case messagerecords.FieldBotWxid:
  20918. v, ok := value.(string)
  20919. if !ok {
  20920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20921. }
  20922. m.SetBotWxid(v)
  20923. return nil
  20924. case messagerecords.FieldContactID:
  20925. v, ok := value.(uint64)
  20926. if !ok {
  20927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20928. }
  20929. m.SetContactID(v)
  20930. return nil
  20931. case messagerecords.FieldContactType:
  20932. v, ok := value.(int)
  20933. if !ok {
  20934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20935. }
  20936. m.SetContactType(v)
  20937. return nil
  20938. case messagerecords.FieldContactWxid:
  20939. v, ok := value.(string)
  20940. if !ok {
  20941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20942. }
  20943. m.SetContactWxid(v)
  20944. return nil
  20945. case messagerecords.FieldContentType:
  20946. v, ok := value.(int)
  20947. if !ok {
  20948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20949. }
  20950. m.SetContentType(v)
  20951. return nil
  20952. case messagerecords.FieldContent:
  20953. v, ok := value.(string)
  20954. if !ok {
  20955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20956. }
  20957. m.SetContent(v)
  20958. return nil
  20959. case messagerecords.FieldMeta:
  20960. v, ok := value.(custom_types.Meta)
  20961. if !ok {
  20962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20963. }
  20964. m.SetMeta(v)
  20965. return nil
  20966. case messagerecords.FieldErrorDetail:
  20967. v, ok := value.(string)
  20968. if !ok {
  20969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20970. }
  20971. m.SetErrorDetail(v)
  20972. return nil
  20973. case messagerecords.FieldSendTime:
  20974. v, ok := value.(time.Time)
  20975. if !ok {
  20976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20977. }
  20978. m.SetSendTime(v)
  20979. return nil
  20980. case messagerecords.FieldSourceType:
  20981. v, ok := value.(int)
  20982. if !ok {
  20983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20984. }
  20985. m.SetSourceType(v)
  20986. return nil
  20987. case messagerecords.FieldSourceID:
  20988. v, ok := value.(uint64)
  20989. if !ok {
  20990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20991. }
  20992. m.SetSourceID(v)
  20993. return nil
  20994. case messagerecords.FieldSubSourceID:
  20995. v, ok := value.(uint64)
  20996. if !ok {
  20997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20998. }
  20999. m.SetSubSourceID(v)
  21000. return nil
  21001. case messagerecords.FieldOrganizationID:
  21002. v, ok := value.(uint64)
  21003. if !ok {
  21004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21005. }
  21006. m.SetOrganizationID(v)
  21007. return nil
  21008. }
  21009. return fmt.Errorf("unknown MessageRecords field %s", name)
  21010. }
  21011. // AddedFields returns all numeric fields that were incremented/decremented during
  21012. // this mutation.
  21013. func (m *MessageRecordsMutation) AddedFields() []string {
  21014. var fields []string
  21015. if m.addstatus != nil {
  21016. fields = append(fields, messagerecords.FieldStatus)
  21017. }
  21018. if m.addcontact_type != nil {
  21019. fields = append(fields, messagerecords.FieldContactType)
  21020. }
  21021. if m.addcontent_type != nil {
  21022. fields = append(fields, messagerecords.FieldContentType)
  21023. }
  21024. if m.addsource_type != nil {
  21025. fields = append(fields, messagerecords.FieldSourceType)
  21026. }
  21027. if m.addorganization_id != nil {
  21028. fields = append(fields, messagerecords.FieldOrganizationID)
  21029. }
  21030. return fields
  21031. }
  21032. // AddedField returns the numeric value that was incremented/decremented on a field
  21033. // with the given name. The second boolean return value indicates that this field
  21034. // was not set, or was not defined in the schema.
  21035. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  21036. switch name {
  21037. case messagerecords.FieldStatus:
  21038. return m.AddedStatus()
  21039. case messagerecords.FieldContactType:
  21040. return m.AddedContactType()
  21041. case messagerecords.FieldContentType:
  21042. return m.AddedContentType()
  21043. case messagerecords.FieldSourceType:
  21044. return m.AddedSourceType()
  21045. case messagerecords.FieldOrganizationID:
  21046. return m.AddedOrganizationID()
  21047. }
  21048. return nil, false
  21049. }
  21050. // AddField adds the value to the field with the given name. It returns an error if
  21051. // the field is not defined in the schema, or if the type mismatched the field
  21052. // type.
  21053. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  21054. switch name {
  21055. case messagerecords.FieldStatus:
  21056. v, ok := value.(int8)
  21057. if !ok {
  21058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21059. }
  21060. m.AddStatus(v)
  21061. return nil
  21062. case messagerecords.FieldContactType:
  21063. v, ok := value.(int)
  21064. if !ok {
  21065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21066. }
  21067. m.AddContactType(v)
  21068. return nil
  21069. case messagerecords.FieldContentType:
  21070. v, ok := value.(int)
  21071. if !ok {
  21072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21073. }
  21074. m.AddContentType(v)
  21075. return nil
  21076. case messagerecords.FieldSourceType:
  21077. v, ok := value.(int)
  21078. if !ok {
  21079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21080. }
  21081. m.AddSourceType(v)
  21082. return nil
  21083. case messagerecords.FieldOrganizationID:
  21084. v, ok := value.(int64)
  21085. if !ok {
  21086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21087. }
  21088. m.AddOrganizationID(v)
  21089. return nil
  21090. }
  21091. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  21092. }
  21093. // ClearedFields returns all nullable fields that were cleared during this
  21094. // mutation.
  21095. func (m *MessageRecordsMutation) ClearedFields() []string {
  21096. var fields []string
  21097. if m.FieldCleared(messagerecords.FieldStatus) {
  21098. fields = append(fields, messagerecords.FieldStatus)
  21099. }
  21100. if m.FieldCleared(messagerecords.FieldContactID) {
  21101. fields = append(fields, messagerecords.FieldContactID)
  21102. }
  21103. if m.FieldCleared(messagerecords.FieldMeta) {
  21104. fields = append(fields, messagerecords.FieldMeta)
  21105. }
  21106. if m.FieldCleared(messagerecords.FieldSendTime) {
  21107. fields = append(fields, messagerecords.FieldSendTime)
  21108. }
  21109. if m.FieldCleared(messagerecords.FieldSourceID) {
  21110. fields = append(fields, messagerecords.FieldSourceID)
  21111. }
  21112. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  21113. fields = append(fields, messagerecords.FieldSubSourceID)
  21114. }
  21115. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  21116. fields = append(fields, messagerecords.FieldOrganizationID)
  21117. }
  21118. return fields
  21119. }
  21120. // FieldCleared returns a boolean indicating if a field with the given name was
  21121. // cleared in this mutation.
  21122. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  21123. _, ok := m.clearedFields[name]
  21124. return ok
  21125. }
  21126. // ClearField clears the value of the field with the given name. It returns an
  21127. // error if the field is not defined in the schema.
  21128. func (m *MessageRecordsMutation) ClearField(name string) error {
  21129. switch name {
  21130. case messagerecords.FieldStatus:
  21131. m.ClearStatus()
  21132. return nil
  21133. case messagerecords.FieldContactID:
  21134. m.ClearContactID()
  21135. return nil
  21136. case messagerecords.FieldMeta:
  21137. m.ClearMeta()
  21138. return nil
  21139. case messagerecords.FieldSendTime:
  21140. m.ClearSendTime()
  21141. return nil
  21142. case messagerecords.FieldSourceID:
  21143. m.ClearSourceID()
  21144. return nil
  21145. case messagerecords.FieldSubSourceID:
  21146. m.ClearSubSourceID()
  21147. return nil
  21148. case messagerecords.FieldOrganizationID:
  21149. m.ClearOrganizationID()
  21150. return nil
  21151. }
  21152. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  21153. }
  21154. // ResetField resets all changes in the mutation for the field with the given name.
  21155. // It returns an error if the field is not defined in the schema.
  21156. func (m *MessageRecordsMutation) ResetField(name string) error {
  21157. switch name {
  21158. case messagerecords.FieldCreatedAt:
  21159. m.ResetCreatedAt()
  21160. return nil
  21161. case messagerecords.FieldUpdatedAt:
  21162. m.ResetUpdatedAt()
  21163. return nil
  21164. case messagerecords.FieldStatus:
  21165. m.ResetStatus()
  21166. return nil
  21167. case messagerecords.FieldBotWxid:
  21168. m.ResetBotWxid()
  21169. return nil
  21170. case messagerecords.FieldContactID:
  21171. m.ResetContactID()
  21172. return nil
  21173. case messagerecords.FieldContactType:
  21174. m.ResetContactType()
  21175. return nil
  21176. case messagerecords.FieldContactWxid:
  21177. m.ResetContactWxid()
  21178. return nil
  21179. case messagerecords.FieldContentType:
  21180. m.ResetContentType()
  21181. return nil
  21182. case messagerecords.FieldContent:
  21183. m.ResetContent()
  21184. return nil
  21185. case messagerecords.FieldMeta:
  21186. m.ResetMeta()
  21187. return nil
  21188. case messagerecords.FieldErrorDetail:
  21189. m.ResetErrorDetail()
  21190. return nil
  21191. case messagerecords.FieldSendTime:
  21192. m.ResetSendTime()
  21193. return nil
  21194. case messagerecords.FieldSourceType:
  21195. m.ResetSourceType()
  21196. return nil
  21197. case messagerecords.FieldSourceID:
  21198. m.ResetSourceID()
  21199. return nil
  21200. case messagerecords.FieldSubSourceID:
  21201. m.ResetSubSourceID()
  21202. return nil
  21203. case messagerecords.FieldOrganizationID:
  21204. m.ResetOrganizationID()
  21205. return nil
  21206. }
  21207. return fmt.Errorf("unknown MessageRecords field %s", name)
  21208. }
  21209. // AddedEdges returns all edge names that were set/added in this mutation.
  21210. func (m *MessageRecordsMutation) AddedEdges() []string {
  21211. edges := make([]string, 0, 3)
  21212. if m.sop_stage != nil {
  21213. edges = append(edges, messagerecords.EdgeSopStage)
  21214. }
  21215. if m.sop_node != nil {
  21216. edges = append(edges, messagerecords.EdgeSopNode)
  21217. }
  21218. if m.message_contact != nil {
  21219. edges = append(edges, messagerecords.EdgeMessageContact)
  21220. }
  21221. return edges
  21222. }
  21223. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21224. // name in this mutation.
  21225. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  21226. switch name {
  21227. case messagerecords.EdgeSopStage:
  21228. if id := m.sop_stage; id != nil {
  21229. return []ent.Value{*id}
  21230. }
  21231. case messagerecords.EdgeSopNode:
  21232. if id := m.sop_node; id != nil {
  21233. return []ent.Value{*id}
  21234. }
  21235. case messagerecords.EdgeMessageContact:
  21236. if id := m.message_contact; id != nil {
  21237. return []ent.Value{*id}
  21238. }
  21239. }
  21240. return nil
  21241. }
  21242. // RemovedEdges returns all edge names that were removed in this mutation.
  21243. func (m *MessageRecordsMutation) RemovedEdges() []string {
  21244. edges := make([]string, 0, 3)
  21245. return edges
  21246. }
  21247. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21248. // the given name in this mutation.
  21249. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  21250. return nil
  21251. }
  21252. // ClearedEdges returns all edge names that were cleared in this mutation.
  21253. func (m *MessageRecordsMutation) ClearedEdges() []string {
  21254. edges := make([]string, 0, 3)
  21255. if m.clearedsop_stage {
  21256. edges = append(edges, messagerecords.EdgeSopStage)
  21257. }
  21258. if m.clearedsop_node {
  21259. edges = append(edges, messagerecords.EdgeSopNode)
  21260. }
  21261. if m.clearedmessage_contact {
  21262. edges = append(edges, messagerecords.EdgeMessageContact)
  21263. }
  21264. return edges
  21265. }
  21266. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21267. // was cleared in this mutation.
  21268. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  21269. switch name {
  21270. case messagerecords.EdgeSopStage:
  21271. return m.clearedsop_stage
  21272. case messagerecords.EdgeSopNode:
  21273. return m.clearedsop_node
  21274. case messagerecords.EdgeMessageContact:
  21275. return m.clearedmessage_contact
  21276. }
  21277. return false
  21278. }
  21279. // ClearEdge clears the value of the edge with the given name. It returns an error
  21280. // if that edge is not defined in the schema.
  21281. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  21282. switch name {
  21283. case messagerecords.EdgeSopStage:
  21284. m.ClearSopStage()
  21285. return nil
  21286. case messagerecords.EdgeSopNode:
  21287. m.ClearSopNode()
  21288. return nil
  21289. case messagerecords.EdgeMessageContact:
  21290. m.ClearMessageContact()
  21291. return nil
  21292. }
  21293. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  21294. }
  21295. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21296. // It returns an error if the edge is not defined in the schema.
  21297. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  21298. switch name {
  21299. case messagerecords.EdgeSopStage:
  21300. m.ResetSopStage()
  21301. return nil
  21302. case messagerecords.EdgeSopNode:
  21303. m.ResetSopNode()
  21304. return nil
  21305. case messagerecords.EdgeMessageContact:
  21306. m.ResetMessageContact()
  21307. return nil
  21308. }
  21309. return fmt.Errorf("unknown MessageRecords edge %s", name)
  21310. }
  21311. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  21312. type MsgMutation struct {
  21313. config
  21314. op Op
  21315. typ string
  21316. id *uint64
  21317. created_at *time.Time
  21318. updated_at *time.Time
  21319. deleted_at *time.Time
  21320. status *uint8
  21321. addstatus *int8
  21322. fromwxid *string
  21323. toid *string
  21324. msgtype *int32
  21325. addmsgtype *int32
  21326. msg *string
  21327. batch_no *string
  21328. cc *string
  21329. phone *string
  21330. clearedFields map[string]struct{}
  21331. done bool
  21332. oldValue func(context.Context) (*Msg, error)
  21333. predicates []predicate.Msg
  21334. }
  21335. var _ ent.Mutation = (*MsgMutation)(nil)
  21336. // msgOption allows management of the mutation configuration using functional options.
  21337. type msgOption func(*MsgMutation)
  21338. // newMsgMutation creates new mutation for the Msg entity.
  21339. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  21340. m := &MsgMutation{
  21341. config: c,
  21342. op: op,
  21343. typ: TypeMsg,
  21344. clearedFields: make(map[string]struct{}),
  21345. }
  21346. for _, opt := range opts {
  21347. opt(m)
  21348. }
  21349. return m
  21350. }
  21351. // withMsgID sets the ID field of the mutation.
  21352. func withMsgID(id uint64) msgOption {
  21353. return func(m *MsgMutation) {
  21354. var (
  21355. err error
  21356. once sync.Once
  21357. value *Msg
  21358. )
  21359. m.oldValue = func(ctx context.Context) (*Msg, error) {
  21360. once.Do(func() {
  21361. if m.done {
  21362. err = errors.New("querying old values post mutation is not allowed")
  21363. } else {
  21364. value, err = m.Client().Msg.Get(ctx, id)
  21365. }
  21366. })
  21367. return value, err
  21368. }
  21369. m.id = &id
  21370. }
  21371. }
  21372. // withMsg sets the old Msg of the mutation.
  21373. func withMsg(node *Msg) msgOption {
  21374. return func(m *MsgMutation) {
  21375. m.oldValue = func(context.Context) (*Msg, error) {
  21376. return node, nil
  21377. }
  21378. m.id = &node.ID
  21379. }
  21380. }
  21381. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21382. // executed in a transaction (ent.Tx), a transactional client is returned.
  21383. func (m MsgMutation) Client() *Client {
  21384. client := &Client{config: m.config}
  21385. client.init()
  21386. return client
  21387. }
  21388. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21389. // it returns an error otherwise.
  21390. func (m MsgMutation) Tx() (*Tx, error) {
  21391. if _, ok := m.driver.(*txDriver); !ok {
  21392. return nil, errors.New("ent: mutation is not running in a transaction")
  21393. }
  21394. tx := &Tx{config: m.config}
  21395. tx.init()
  21396. return tx, nil
  21397. }
  21398. // SetID sets the value of the id field. Note that this
  21399. // operation is only accepted on creation of Msg entities.
  21400. func (m *MsgMutation) SetID(id uint64) {
  21401. m.id = &id
  21402. }
  21403. // ID returns the ID value in the mutation. Note that the ID is only available
  21404. // if it was provided to the builder or after it was returned from the database.
  21405. func (m *MsgMutation) ID() (id uint64, exists bool) {
  21406. if m.id == nil {
  21407. return
  21408. }
  21409. return *m.id, true
  21410. }
  21411. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21412. // That means, if the mutation is applied within a transaction with an isolation level such
  21413. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21414. // or updated by the mutation.
  21415. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  21416. switch {
  21417. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21418. id, exists := m.ID()
  21419. if exists {
  21420. return []uint64{id}, nil
  21421. }
  21422. fallthrough
  21423. case m.op.Is(OpUpdate | OpDelete):
  21424. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  21425. default:
  21426. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21427. }
  21428. }
  21429. // SetCreatedAt sets the "created_at" field.
  21430. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  21431. m.created_at = &t
  21432. }
  21433. // CreatedAt returns the value of the "created_at" field in the mutation.
  21434. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  21435. v := m.created_at
  21436. if v == nil {
  21437. return
  21438. }
  21439. return *v, true
  21440. }
  21441. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  21442. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21444. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21445. if !m.op.Is(OpUpdateOne) {
  21446. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21447. }
  21448. if m.id == nil || m.oldValue == nil {
  21449. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21450. }
  21451. oldValue, err := m.oldValue(ctx)
  21452. if err != nil {
  21453. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21454. }
  21455. return oldValue.CreatedAt, nil
  21456. }
  21457. // ResetCreatedAt resets all changes to the "created_at" field.
  21458. func (m *MsgMutation) ResetCreatedAt() {
  21459. m.created_at = nil
  21460. }
  21461. // SetUpdatedAt sets the "updated_at" field.
  21462. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  21463. m.updated_at = &t
  21464. }
  21465. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21466. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  21467. v := m.updated_at
  21468. if v == nil {
  21469. return
  21470. }
  21471. return *v, true
  21472. }
  21473. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  21474. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21476. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21477. if !m.op.Is(OpUpdateOne) {
  21478. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21479. }
  21480. if m.id == nil || m.oldValue == nil {
  21481. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21482. }
  21483. oldValue, err := m.oldValue(ctx)
  21484. if err != nil {
  21485. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21486. }
  21487. return oldValue.UpdatedAt, nil
  21488. }
  21489. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21490. func (m *MsgMutation) ResetUpdatedAt() {
  21491. m.updated_at = nil
  21492. }
  21493. // SetDeletedAt sets the "deleted_at" field.
  21494. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  21495. m.deleted_at = &t
  21496. }
  21497. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21498. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  21499. v := m.deleted_at
  21500. if v == nil {
  21501. return
  21502. }
  21503. return *v, true
  21504. }
  21505. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  21506. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21508. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21509. if !m.op.Is(OpUpdateOne) {
  21510. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21511. }
  21512. if m.id == nil || m.oldValue == nil {
  21513. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21514. }
  21515. oldValue, err := m.oldValue(ctx)
  21516. if err != nil {
  21517. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21518. }
  21519. return oldValue.DeletedAt, nil
  21520. }
  21521. // ClearDeletedAt clears the value of the "deleted_at" field.
  21522. func (m *MsgMutation) ClearDeletedAt() {
  21523. m.deleted_at = nil
  21524. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  21525. }
  21526. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21527. func (m *MsgMutation) DeletedAtCleared() bool {
  21528. _, ok := m.clearedFields[msg.FieldDeletedAt]
  21529. return ok
  21530. }
  21531. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21532. func (m *MsgMutation) ResetDeletedAt() {
  21533. m.deleted_at = nil
  21534. delete(m.clearedFields, msg.FieldDeletedAt)
  21535. }
  21536. // SetStatus sets the "status" field.
  21537. func (m *MsgMutation) SetStatus(u uint8) {
  21538. m.status = &u
  21539. m.addstatus = nil
  21540. }
  21541. // Status returns the value of the "status" field in the mutation.
  21542. func (m *MsgMutation) Status() (r uint8, exists bool) {
  21543. v := m.status
  21544. if v == nil {
  21545. return
  21546. }
  21547. return *v, true
  21548. }
  21549. // OldStatus returns the old "status" field's value of the Msg entity.
  21550. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21552. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21553. if !m.op.Is(OpUpdateOne) {
  21554. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21555. }
  21556. if m.id == nil || m.oldValue == nil {
  21557. return v, errors.New("OldStatus requires an ID field in the mutation")
  21558. }
  21559. oldValue, err := m.oldValue(ctx)
  21560. if err != nil {
  21561. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21562. }
  21563. return oldValue.Status, nil
  21564. }
  21565. // AddStatus adds u to the "status" field.
  21566. func (m *MsgMutation) AddStatus(u int8) {
  21567. if m.addstatus != nil {
  21568. *m.addstatus += u
  21569. } else {
  21570. m.addstatus = &u
  21571. }
  21572. }
  21573. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21574. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  21575. v := m.addstatus
  21576. if v == nil {
  21577. return
  21578. }
  21579. return *v, true
  21580. }
  21581. // ClearStatus clears the value of the "status" field.
  21582. func (m *MsgMutation) ClearStatus() {
  21583. m.status = nil
  21584. m.addstatus = nil
  21585. m.clearedFields[msg.FieldStatus] = struct{}{}
  21586. }
  21587. // StatusCleared returns if the "status" field was cleared in this mutation.
  21588. func (m *MsgMutation) StatusCleared() bool {
  21589. _, ok := m.clearedFields[msg.FieldStatus]
  21590. return ok
  21591. }
  21592. // ResetStatus resets all changes to the "status" field.
  21593. func (m *MsgMutation) ResetStatus() {
  21594. m.status = nil
  21595. m.addstatus = nil
  21596. delete(m.clearedFields, msg.FieldStatus)
  21597. }
  21598. // SetFromwxid sets the "fromwxid" field.
  21599. func (m *MsgMutation) SetFromwxid(s string) {
  21600. m.fromwxid = &s
  21601. }
  21602. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  21603. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  21604. v := m.fromwxid
  21605. if v == nil {
  21606. return
  21607. }
  21608. return *v, true
  21609. }
  21610. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  21611. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21613. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  21614. if !m.op.Is(OpUpdateOne) {
  21615. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  21616. }
  21617. if m.id == nil || m.oldValue == nil {
  21618. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  21619. }
  21620. oldValue, err := m.oldValue(ctx)
  21621. if err != nil {
  21622. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  21623. }
  21624. return oldValue.Fromwxid, nil
  21625. }
  21626. // ClearFromwxid clears the value of the "fromwxid" field.
  21627. func (m *MsgMutation) ClearFromwxid() {
  21628. m.fromwxid = nil
  21629. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  21630. }
  21631. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  21632. func (m *MsgMutation) FromwxidCleared() bool {
  21633. _, ok := m.clearedFields[msg.FieldFromwxid]
  21634. return ok
  21635. }
  21636. // ResetFromwxid resets all changes to the "fromwxid" field.
  21637. func (m *MsgMutation) ResetFromwxid() {
  21638. m.fromwxid = nil
  21639. delete(m.clearedFields, msg.FieldFromwxid)
  21640. }
  21641. // SetToid sets the "toid" field.
  21642. func (m *MsgMutation) SetToid(s string) {
  21643. m.toid = &s
  21644. }
  21645. // Toid returns the value of the "toid" field in the mutation.
  21646. func (m *MsgMutation) Toid() (r string, exists bool) {
  21647. v := m.toid
  21648. if v == nil {
  21649. return
  21650. }
  21651. return *v, true
  21652. }
  21653. // OldToid returns the old "toid" field's value of the Msg entity.
  21654. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21656. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  21657. if !m.op.Is(OpUpdateOne) {
  21658. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  21659. }
  21660. if m.id == nil || m.oldValue == nil {
  21661. return v, errors.New("OldToid requires an ID field in the mutation")
  21662. }
  21663. oldValue, err := m.oldValue(ctx)
  21664. if err != nil {
  21665. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  21666. }
  21667. return oldValue.Toid, nil
  21668. }
  21669. // ClearToid clears the value of the "toid" field.
  21670. func (m *MsgMutation) ClearToid() {
  21671. m.toid = nil
  21672. m.clearedFields[msg.FieldToid] = struct{}{}
  21673. }
  21674. // ToidCleared returns if the "toid" field was cleared in this mutation.
  21675. func (m *MsgMutation) ToidCleared() bool {
  21676. _, ok := m.clearedFields[msg.FieldToid]
  21677. return ok
  21678. }
  21679. // ResetToid resets all changes to the "toid" field.
  21680. func (m *MsgMutation) ResetToid() {
  21681. m.toid = nil
  21682. delete(m.clearedFields, msg.FieldToid)
  21683. }
  21684. // SetMsgtype sets the "msgtype" field.
  21685. func (m *MsgMutation) SetMsgtype(i int32) {
  21686. m.msgtype = &i
  21687. m.addmsgtype = nil
  21688. }
  21689. // Msgtype returns the value of the "msgtype" field in the mutation.
  21690. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  21691. v := m.msgtype
  21692. if v == nil {
  21693. return
  21694. }
  21695. return *v, true
  21696. }
  21697. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  21698. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21700. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  21701. if !m.op.Is(OpUpdateOne) {
  21702. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  21703. }
  21704. if m.id == nil || m.oldValue == nil {
  21705. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  21706. }
  21707. oldValue, err := m.oldValue(ctx)
  21708. if err != nil {
  21709. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  21710. }
  21711. return oldValue.Msgtype, nil
  21712. }
  21713. // AddMsgtype adds i to the "msgtype" field.
  21714. func (m *MsgMutation) AddMsgtype(i int32) {
  21715. if m.addmsgtype != nil {
  21716. *m.addmsgtype += i
  21717. } else {
  21718. m.addmsgtype = &i
  21719. }
  21720. }
  21721. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  21722. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  21723. v := m.addmsgtype
  21724. if v == nil {
  21725. return
  21726. }
  21727. return *v, true
  21728. }
  21729. // ClearMsgtype clears the value of the "msgtype" field.
  21730. func (m *MsgMutation) ClearMsgtype() {
  21731. m.msgtype = nil
  21732. m.addmsgtype = nil
  21733. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  21734. }
  21735. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  21736. func (m *MsgMutation) MsgtypeCleared() bool {
  21737. _, ok := m.clearedFields[msg.FieldMsgtype]
  21738. return ok
  21739. }
  21740. // ResetMsgtype resets all changes to the "msgtype" field.
  21741. func (m *MsgMutation) ResetMsgtype() {
  21742. m.msgtype = nil
  21743. m.addmsgtype = nil
  21744. delete(m.clearedFields, msg.FieldMsgtype)
  21745. }
  21746. // SetMsg sets the "msg" field.
  21747. func (m *MsgMutation) SetMsg(s string) {
  21748. m.msg = &s
  21749. }
  21750. // Msg returns the value of the "msg" field in the mutation.
  21751. func (m *MsgMutation) Msg() (r string, exists bool) {
  21752. v := m.msg
  21753. if v == nil {
  21754. return
  21755. }
  21756. return *v, true
  21757. }
  21758. // OldMsg returns the old "msg" field's value of the Msg entity.
  21759. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21761. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  21762. if !m.op.Is(OpUpdateOne) {
  21763. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  21764. }
  21765. if m.id == nil || m.oldValue == nil {
  21766. return v, errors.New("OldMsg requires an ID field in the mutation")
  21767. }
  21768. oldValue, err := m.oldValue(ctx)
  21769. if err != nil {
  21770. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  21771. }
  21772. return oldValue.Msg, nil
  21773. }
  21774. // ClearMsg clears the value of the "msg" field.
  21775. func (m *MsgMutation) ClearMsg() {
  21776. m.msg = nil
  21777. m.clearedFields[msg.FieldMsg] = struct{}{}
  21778. }
  21779. // MsgCleared returns if the "msg" field was cleared in this mutation.
  21780. func (m *MsgMutation) MsgCleared() bool {
  21781. _, ok := m.clearedFields[msg.FieldMsg]
  21782. return ok
  21783. }
  21784. // ResetMsg resets all changes to the "msg" field.
  21785. func (m *MsgMutation) ResetMsg() {
  21786. m.msg = nil
  21787. delete(m.clearedFields, msg.FieldMsg)
  21788. }
  21789. // SetBatchNo sets the "batch_no" field.
  21790. func (m *MsgMutation) SetBatchNo(s string) {
  21791. m.batch_no = &s
  21792. }
  21793. // BatchNo returns the value of the "batch_no" field in the mutation.
  21794. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  21795. v := m.batch_no
  21796. if v == nil {
  21797. return
  21798. }
  21799. return *v, true
  21800. }
  21801. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  21802. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21804. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  21805. if !m.op.Is(OpUpdateOne) {
  21806. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  21807. }
  21808. if m.id == nil || m.oldValue == nil {
  21809. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  21810. }
  21811. oldValue, err := m.oldValue(ctx)
  21812. if err != nil {
  21813. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  21814. }
  21815. return oldValue.BatchNo, nil
  21816. }
  21817. // ClearBatchNo clears the value of the "batch_no" field.
  21818. func (m *MsgMutation) ClearBatchNo() {
  21819. m.batch_no = nil
  21820. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  21821. }
  21822. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  21823. func (m *MsgMutation) BatchNoCleared() bool {
  21824. _, ok := m.clearedFields[msg.FieldBatchNo]
  21825. return ok
  21826. }
  21827. // ResetBatchNo resets all changes to the "batch_no" field.
  21828. func (m *MsgMutation) ResetBatchNo() {
  21829. m.batch_no = nil
  21830. delete(m.clearedFields, msg.FieldBatchNo)
  21831. }
  21832. // SetCc sets the "cc" field.
  21833. func (m *MsgMutation) SetCc(s string) {
  21834. m.cc = &s
  21835. }
  21836. // Cc returns the value of the "cc" field in the mutation.
  21837. func (m *MsgMutation) Cc() (r string, exists bool) {
  21838. v := m.cc
  21839. if v == nil {
  21840. return
  21841. }
  21842. return *v, true
  21843. }
  21844. // OldCc returns the old "cc" field's value of the Msg entity.
  21845. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21847. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  21848. if !m.op.Is(OpUpdateOne) {
  21849. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  21850. }
  21851. if m.id == nil || m.oldValue == nil {
  21852. return v, errors.New("OldCc requires an ID field in the mutation")
  21853. }
  21854. oldValue, err := m.oldValue(ctx)
  21855. if err != nil {
  21856. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  21857. }
  21858. return oldValue.Cc, nil
  21859. }
  21860. // ResetCc resets all changes to the "cc" field.
  21861. func (m *MsgMutation) ResetCc() {
  21862. m.cc = nil
  21863. }
  21864. // SetPhone sets the "phone" field.
  21865. func (m *MsgMutation) SetPhone(s string) {
  21866. m.phone = &s
  21867. }
  21868. // Phone returns the value of the "phone" field in the mutation.
  21869. func (m *MsgMutation) Phone() (r string, exists bool) {
  21870. v := m.phone
  21871. if v == nil {
  21872. return
  21873. }
  21874. return *v, true
  21875. }
  21876. // OldPhone returns the old "phone" field's value of the Msg entity.
  21877. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21879. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  21880. if !m.op.Is(OpUpdateOne) {
  21881. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  21882. }
  21883. if m.id == nil || m.oldValue == nil {
  21884. return v, errors.New("OldPhone requires an ID field in the mutation")
  21885. }
  21886. oldValue, err := m.oldValue(ctx)
  21887. if err != nil {
  21888. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  21889. }
  21890. return oldValue.Phone, nil
  21891. }
  21892. // ResetPhone resets all changes to the "phone" field.
  21893. func (m *MsgMutation) ResetPhone() {
  21894. m.phone = nil
  21895. }
  21896. // Where appends a list predicates to the MsgMutation builder.
  21897. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  21898. m.predicates = append(m.predicates, ps...)
  21899. }
  21900. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  21901. // users can use type-assertion to append predicates that do not depend on any generated package.
  21902. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  21903. p := make([]predicate.Msg, len(ps))
  21904. for i := range ps {
  21905. p[i] = ps[i]
  21906. }
  21907. m.Where(p...)
  21908. }
  21909. // Op returns the operation name.
  21910. func (m *MsgMutation) Op() Op {
  21911. return m.op
  21912. }
  21913. // SetOp allows setting the mutation operation.
  21914. func (m *MsgMutation) SetOp(op Op) {
  21915. m.op = op
  21916. }
  21917. // Type returns the node type of this mutation (Msg).
  21918. func (m *MsgMutation) Type() string {
  21919. return m.typ
  21920. }
  21921. // Fields returns all fields that were changed during this mutation. Note that in
  21922. // order to get all numeric fields that were incremented/decremented, call
  21923. // AddedFields().
  21924. func (m *MsgMutation) Fields() []string {
  21925. fields := make([]string, 0, 11)
  21926. if m.created_at != nil {
  21927. fields = append(fields, msg.FieldCreatedAt)
  21928. }
  21929. if m.updated_at != nil {
  21930. fields = append(fields, msg.FieldUpdatedAt)
  21931. }
  21932. if m.deleted_at != nil {
  21933. fields = append(fields, msg.FieldDeletedAt)
  21934. }
  21935. if m.status != nil {
  21936. fields = append(fields, msg.FieldStatus)
  21937. }
  21938. if m.fromwxid != nil {
  21939. fields = append(fields, msg.FieldFromwxid)
  21940. }
  21941. if m.toid != nil {
  21942. fields = append(fields, msg.FieldToid)
  21943. }
  21944. if m.msgtype != nil {
  21945. fields = append(fields, msg.FieldMsgtype)
  21946. }
  21947. if m.msg != nil {
  21948. fields = append(fields, msg.FieldMsg)
  21949. }
  21950. if m.batch_no != nil {
  21951. fields = append(fields, msg.FieldBatchNo)
  21952. }
  21953. if m.cc != nil {
  21954. fields = append(fields, msg.FieldCc)
  21955. }
  21956. if m.phone != nil {
  21957. fields = append(fields, msg.FieldPhone)
  21958. }
  21959. return fields
  21960. }
  21961. // Field returns the value of a field with the given name. The second boolean
  21962. // return value indicates that this field was not set, or was not defined in the
  21963. // schema.
  21964. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  21965. switch name {
  21966. case msg.FieldCreatedAt:
  21967. return m.CreatedAt()
  21968. case msg.FieldUpdatedAt:
  21969. return m.UpdatedAt()
  21970. case msg.FieldDeletedAt:
  21971. return m.DeletedAt()
  21972. case msg.FieldStatus:
  21973. return m.Status()
  21974. case msg.FieldFromwxid:
  21975. return m.Fromwxid()
  21976. case msg.FieldToid:
  21977. return m.Toid()
  21978. case msg.FieldMsgtype:
  21979. return m.Msgtype()
  21980. case msg.FieldMsg:
  21981. return m.Msg()
  21982. case msg.FieldBatchNo:
  21983. return m.BatchNo()
  21984. case msg.FieldCc:
  21985. return m.Cc()
  21986. case msg.FieldPhone:
  21987. return m.Phone()
  21988. }
  21989. return nil, false
  21990. }
  21991. // OldField returns the old value of the field from the database. An error is
  21992. // returned if the mutation operation is not UpdateOne, or the query to the
  21993. // database failed.
  21994. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21995. switch name {
  21996. case msg.FieldCreatedAt:
  21997. return m.OldCreatedAt(ctx)
  21998. case msg.FieldUpdatedAt:
  21999. return m.OldUpdatedAt(ctx)
  22000. case msg.FieldDeletedAt:
  22001. return m.OldDeletedAt(ctx)
  22002. case msg.FieldStatus:
  22003. return m.OldStatus(ctx)
  22004. case msg.FieldFromwxid:
  22005. return m.OldFromwxid(ctx)
  22006. case msg.FieldToid:
  22007. return m.OldToid(ctx)
  22008. case msg.FieldMsgtype:
  22009. return m.OldMsgtype(ctx)
  22010. case msg.FieldMsg:
  22011. return m.OldMsg(ctx)
  22012. case msg.FieldBatchNo:
  22013. return m.OldBatchNo(ctx)
  22014. case msg.FieldCc:
  22015. return m.OldCc(ctx)
  22016. case msg.FieldPhone:
  22017. return m.OldPhone(ctx)
  22018. }
  22019. return nil, fmt.Errorf("unknown Msg field %s", name)
  22020. }
  22021. // SetField sets the value of a field with the given name. It returns an error if
  22022. // the field is not defined in the schema, or if the type mismatched the field
  22023. // type.
  22024. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  22025. switch name {
  22026. case msg.FieldCreatedAt:
  22027. v, ok := value.(time.Time)
  22028. if !ok {
  22029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22030. }
  22031. m.SetCreatedAt(v)
  22032. return nil
  22033. case msg.FieldUpdatedAt:
  22034. v, ok := value.(time.Time)
  22035. if !ok {
  22036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22037. }
  22038. m.SetUpdatedAt(v)
  22039. return nil
  22040. case msg.FieldDeletedAt:
  22041. v, ok := value.(time.Time)
  22042. if !ok {
  22043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22044. }
  22045. m.SetDeletedAt(v)
  22046. return nil
  22047. case msg.FieldStatus:
  22048. v, ok := value.(uint8)
  22049. if !ok {
  22050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22051. }
  22052. m.SetStatus(v)
  22053. return nil
  22054. case msg.FieldFromwxid:
  22055. v, ok := value.(string)
  22056. if !ok {
  22057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22058. }
  22059. m.SetFromwxid(v)
  22060. return nil
  22061. case msg.FieldToid:
  22062. v, ok := value.(string)
  22063. if !ok {
  22064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22065. }
  22066. m.SetToid(v)
  22067. return nil
  22068. case msg.FieldMsgtype:
  22069. v, ok := value.(int32)
  22070. if !ok {
  22071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22072. }
  22073. m.SetMsgtype(v)
  22074. return nil
  22075. case msg.FieldMsg:
  22076. v, ok := value.(string)
  22077. if !ok {
  22078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22079. }
  22080. m.SetMsg(v)
  22081. return nil
  22082. case msg.FieldBatchNo:
  22083. v, ok := value.(string)
  22084. if !ok {
  22085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22086. }
  22087. m.SetBatchNo(v)
  22088. return nil
  22089. case msg.FieldCc:
  22090. v, ok := value.(string)
  22091. if !ok {
  22092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22093. }
  22094. m.SetCc(v)
  22095. return nil
  22096. case msg.FieldPhone:
  22097. v, ok := value.(string)
  22098. if !ok {
  22099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22100. }
  22101. m.SetPhone(v)
  22102. return nil
  22103. }
  22104. return fmt.Errorf("unknown Msg field %s", name)
  22105. }
  22106. // AddedFields returns all numeric fields that were incremented/decremented during
  22107. // this mutation.
  22108. func (m *MsgMutation) AddedFields() []string {
  22109. var fields []string
  22110. if m.addstatus != nil {
  22111. fields = append(fields, msg.FieldStatus)
  22112. }
  22113. if m.addmsgtype != nil {
  22114. fields = append(fields, msg.FieldMsgtype)
  22115. }
  22116. return fields
  22117. }
  22118. // AddedField returns the numeric value that was incremented/decremented on a field
  22119. // with the given name. The second boolean return value indicates that this field
  22120. // was not set, or was not defined in the schema.
  22121. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  22122. switch name {
  22123. case msg.FieldStatus:
  22124. return m.AddedStatus()
  22125. case msg.FieldMsgtype:
  22126. return m.AddedMsgtype()
  22127. }
  22128. return nil, false
  22129. }
  22130. // AddField adds the value to the field with the given name. It returns an error if
  22131. // the field is not defined in the schema, or if the type mismatched the field
  22132. // type.
  22133. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  22134. switch name {
  22135. case msg.FieldStatus:
  22136. v, ok := value.(int8)
  22137. if !ok {
  22138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22139. }
  22140. m.AddStatus(v)
  22141. return nil
  22142. case msg.FieldMsgtype:
  22143. v, ok := value.(int32)
  22144. if !ok {
  22145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22146. }
  22147. m.AddMsgtype(v)
  22148. return nil
  22149. }
  22150. return fmt.Errorf("unknown Msg numeric field %s", name)
  22151. }
  22152. // ClearedFields returns all nullable fields that were cleared during this
  22153. // mutation.
  22154. func (m *MsgMutation) ClearedFields() []string {
  22155. var fields []string
  22156. if m.FieldCleared(msg.FieldDeletedAt) {
  22157. fields = append(fields, msg.FieldDeletedAt)
  22158. }
  22159. if m.FieldCleared(msg.FieldStatus) {
  22160. fields = append(fields, msg.FieldStatus)
  22161. }
  22162. if m.FieldCleared(msg.FieldFromwxid) {
  22163. fields = append(fields, msg.FieldFromwxid)
  22164. }
  22165. if m.FieldCleared(msg.FieldToid) {
  22166. fields = append(fields, msg.FieldToid)
  22167. }
  22168. if m.FieldCleared(msg.FieldMsgtype) {
  22169. fields = append(fields, msg.FieldMsgtype)
  22170. }
  22171. if m.FieldCleared(msg.FieldMsg) {
  22172. fields = append(fields, msg.FieldMsg)
  22173. }
  22174. if m.FieldCleared(msg.FieldBatchNo) {
  22175. fields = append(fields, msg.FieldBatchNo)
  22176. }
  22177. return fields
  22178. }
  22179. // FieldCleared returns a boolean indicating if a field with the given name was
  22180. // cleared in this mutation.
  22181. func (m *MsgMutation) FieldCleared(name string) bool {
  22182. _, ok := m.clearedFields[name]
  22183. return ok
  22184. }
  22185. // ClearField clears the value of the field with the given name. It returns an
  22186. // error if the field is not defined in the schema.
  22187. func (m *MsgMutation) ClearField(name string) error {
  22188. switch name {
  22189. case msg.FieldDeletedAt:
  22190. m.ClearDeletedAt()
  22191. return nil
  22192. case msg.FieldStatus:
  22193. m.ClearStatus()
  22194. return nil
  22195. case msg.FieldFromwxid:
  22196. m.ClearFromwxid()
  22197. return nil
  22198. case msg.FieldToid:
  22199. m.ClearToid()
  22200. return nil
  22201. case msg.FieldMsgtype:
  22202. m.ClearMsgtype()
  22203. return nil
  22204. case msg.FieldMsg:
  22205. m.ClearMsg()
  22206. return nil
  22207. case msg.FieldBatchNo:
  22208. m.ClearBatchNo()
  22209. return nil
  22210. }
  22211. return fmt.Errorf("unknown Msg nullable field %s", name)
  22212. }
  22213. // ResetField resets all changes in the mutation for the field with the given name.
  22214. // It returns an error if the field is not defined in the schema.
  22215. func (m *MsgMutation) ResetField(name string) error {
  22216. switch name {
  22217. case msg.FieldCreatedAt:
  22218. m.ResetCreatedAt()
  22219. return nil
  22220. case msg.FieldUpdatedAt:
  22221. m.ResetUpdatedAt()
  22222. return nil
  22223. case msg.FieldDeletedAt:
  22224. m.ResetDeletedAt()
  22225. return nil
  22226. case msg.FieldStatus:
  22227. m.ResetStatus()
  22228. return nil
  22229. case msg.FieldFromwxid:
  22230. m.ResetFromwxid()
  22231. return nil
  22232. case msg.FieldToid:
  22233. m.ResetToid()
  22234. return nil
  22235. case msg.FieldMsgtype:
  22236. m.ResetMsgtype()
  22237. return nil
  22238. case msg.FieldMsg:
  22239. m.ResetMsg()
  22240. return nil
  22241. case msg.FieldBatchNo:
  22242. m.ResetBatchNo()
  22243. return nil
  22244. case msg.FieldCc:
  22245. m.ResetCc()
  22246. return nil
  22247. case msg.FieldPhone:
  22248. m.ResetPhone()
  22249. return nil
  22250. }
  22251. return fmt.Errorf("unknown Msg field %s", name)
  22252. }
  22253. // AddedEdges returns all edge names that were set/added in this mutation.
  22254. func (m *MsgMutation) AddedEdges() []string {
  22255. edges := make([]string, 0, 0)
  22256. return edges
  22257. }
  22258. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22259. // name in this mutation.
  22260. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  22261. return nil
  22262. }
  22263. // RemovedEdges returns all edge names that were removed in this mutation.
  22264. func (m *MsgMutation) RemovedEdges() []string {
  22265. edges := make([]string, 0, 0)
  22266. return edges
  22267. }
  22268. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22269. // the given name in this mutation.
  22270. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  22271. return nil
  22272. }
  22273. // ClearedEdges returns all edge names that were cleared in this mutation.
  22274. func (m *MsgMutation) ClearedEdges() []string {
  22275. edges := make([]string, 0, 0)
  22276. return edges
  22277. }
  22278. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22279. // was cleared in this mutation.
  22280. func (m *MsgMutation) EdgeCleared(name string) bool {
  22281. return false
  22282. }
  22283. // ClearEdge clears the value of the edge with the given name. It returns an error
  22284. // if that edge is not defined in the schema.
  22285. func (m *MsgMutation) ClearEdge(name string) error {
  22286. return fmt.Errorf("unknown Msg unique edge %s", name)
  22287. }
  22288. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22289. // It returns an error if the edge is not defined in the schema.
  22290. func (m *MsgMutation) ResetEdge(name string) error {
  22291. return fmt.Errorf("unknown Msg edge %s", name)
  22292. }
  22293. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  22294. type PayRechargeMutation struct {
  22295. config
  22296. op Op
  22297. typ string
  22298. id *uint64
  22299. created_at *time.Time
  22300. updated_at *time.Time
  22301. deleted_at *time.Time
  22302. user_id *string
  22303. number *float32
  22304. addnumber *float32
  22305. status *int
  22306. addstatus *int
  22307. money *float32
  22308. addmoney *float32
  22309. out_trade_no *string
  22310. organization_id *uint64
  22311. addorganization_id *int64
  22312. clearedFields map[string]struct{}
  22313. done bool
  22314. oldValue func(context.Context) (*PayRecharge, error)
  22315. predicates []predicate.PayRecharge
  22316. }
  22317. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  22318. // payrechargeOption allows management of the mutation configuration using functional options.
  22319. type payrechargeOption func(*PayRechargeMutation)
  22320. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  22321. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  22322. m := &PayRechargeMutation{
  22323. config: c,
  22324. op: op,
  22325. typ: TypePayRecharge,
  22326. clearedFields: make(map[string]struct{}),
  22327. }
  22328. for _, opt := range opts {
  22329. opt(m)
  22330. }
  22331. return m
  22332. }
  22333. // withPayRechargeID sets the ID field of the mutation.
  22334. func withPayRechargeID(id uint64) payrechargeOption {
  22335. return func(m *PayRechargeMutation) {
  22336. var (
  22337. err error
  22338. once sync.Once
  22339. value *PayRecharge
  22340. )
  22341. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  22342. once.Do(func() {
  22343. if m.done {
  22344. err = errors.New("querying old values post mutation is not allowed")
  22345. } else {
  22346. value, err = m.Client().PayRecharge.Get(ctx, id)
  22347. }
  22348. })
  22349. return value, err
  22350. }
  22351. m.id = &id
  22352. }
  22353. }
  22354. // withPayRecharge sets the old PayRecharge of the mutation.
  22355. func withPayRecharge(node *PayRecharge) payrechargeOption {
  22356. return func(m *PayRechargeMutation) {
  22357. m.oldValue = func(context.Context) (*PayRecharge, error) {
  22358. return node, nil
  22359. }
  22360. m.id = &node.ID
  22361. }
  22362. }
  22363. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22364. // executed in a transaction (ent.Tx), a transactional client is returned.
  22365. func (m PayRechargeMutation) Client() *Client {
  22366. client := &Client{config: m.config}
  22367. client.init()
  22368. return client
  22369. }
  22370. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22371. // it returns an error otherwise.
  22372. func (m PayRechargeMutation) Tx() (*Tx, error) {
  22373. if _, ok := m.driver.(*txDriver); !ok {
  22374. return nil, errors.New("ent: mutation is not running in a transaction")
  22375. }
  22376. tx := &Tx{config: m.config}
  22377. tx.init()
  22378. return tx, nil
  22379. }
  22380. // SetID sets the value of the id field. Note that this
  22381. // operation is only accepted on creation of PayRecharge entities.
  22382. func (m *PayRechargeMutation) SetID(id uint64) {
  22383. m.id = &id
  22384. }
  22385. // ID returns the ID value in the mutation. Note that the ID is only available
  22386. // if it was provided to the builder or after it was returned from the database.
  22387. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  22388. if m.id == nil {
  22389. return
  22390. }
  22391. return *m.id, true
  22392. }
  22393. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22394. // That means, if the mutation is applied within a transaction with an isolation level such
  22395. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22396. // or updated by the mutation.
  22397. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  22398. switch {
  22399. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22400. id, exists := m.ID()
  22401. if exists {
  22402. return []uint64{id}, nil
  22403. }
  22404. fallthrough
  22405. case m.op.Is(OpUpdate | OpDelete):
  22406. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  22407. default:
  22408. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22409. }
  22410. }
  22411. // SetCreatedAt sets the "created_at" field.
  22412. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  22413. m.created_at = &t
  22414. }
  22415. // CreatedAt returns the value of the "created_at" field in the mutation.
  22416. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  22417. v := m.created_at
  22418. if v == nil {
  22419. return
  22420. }
  22421. return *v, true
  22422. }
  22423. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  22424. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22426. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22427. if !m.op.Is(OpUpdateOne) {
  22428. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22429. }
  22430. if m.id == nil || m.oldValue == nil {
  22431. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22432. }
  22433. oldValue, err := m.oldValue(ctx)
  22434. if err != nil {
  22435. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22436. }
  22437. return oldValue.CreatedAt, nil
  22438. }
  22439. // ResetCreatedAt resets all changes to the "created_at" field.
  22440. func (m *PayRechargeMutation) ResetCreatedAt() {
  22441. m.created_at = nil
  22442. }
  22443. // SetUpdatedAt sets the "updated_at" field.
  22444. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  22445. m.updated_at = &t
  22446. }
  22447. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22448. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  22449. v := m.updated_at
  22450. if v == nil {
  22451. return
  22452. }
  22453. return *v, true
  22454. }
  22455. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  22456. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22458. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22459. if !m.op.Is(OpUpdateOne) {
  22460. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22461. }
  22462. if m.id == nil || m.oldValue == nil {
  22463. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22464. }
  22465. oldValue, err := m.oldValue(ctx)
  22466. if err != nil {
  22467. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22468. }
  22469. return oldValue.UpdatedAt, nil
  22470. }
  22471. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22472. func (m *PayRechargeMutation) ResetUpdatedAt() {
  22473. m.updated_at = nil
  22474. }
  22475. // SetDeletedAt sets the "deleted_at" field.
  22476. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  22477. m.deleted_at = &t
  22478. }
  22479. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22480. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  22481. v := m.deleted_at
  22482. if v == nil {
  22483. return
  22484. }
  22485. return *v, true
  22486. }
  22487. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  22488. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22490. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22491. if !m.op.Is(OpUpdateOne) {
  22492. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22493. }
  22494. if m.id == nil || m.oldValue == nil {
  22495. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22496. }
  22497. oldValue, err := m.oldValue(ctx)
  22498. if err != nil {
  22499. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22500. }
  22501. return oldValue.DeletedAt, nil
  22502. }
  22503. // ClearDeletedAt clears the value of the "deleted_at" field.
  22504. func (m *PayRechargeMutation) ClearDeletedAt() {
  22505. m.deleted_at = nil
  22506. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  22507. }
  22508. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22509. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  22510. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  22511. return ok
  22512. }
  22513. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22514. func (m *PayRechargeMutation) ResetDeletedAt() {
  22515. m.deleted_at = nil
  22516. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  22517. }
  22518. // SetUserID sets the "user_id" field.
  22519. func (m *PayRechargeMutation) SetUserID(s string) {
  22520. m.user_id = &s
  22521. }
  22522. // UserID returns the value of the "user_id" field in the mutation.
  22523. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  22524. v := m.user_id
  22525. if v == nil {
  22526. return
  22527. }
  22528. return *v, true
  22529. }
  22530. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  22531. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22533. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  22534. if !m.op.Is(OpUpdateOne) {
  22535. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  22536. }
  22537. if m.id == nil || m.oldValue == nil {
  22538. return v, errors.New("OldUserID requires an ID field in the mutation")
  22539. }
  22540. oldValue, err := m.oldValue(ctx)
  22541. if err != nil {
  22542. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  22543. }
  22544. return oldValue.UserID, nil
  22545. }
  22546. // ResetUserID resets all changes to the "user_id" field.
  22547. func (m *PayRechargeMutation) ResetUserID() {
  22548. m.user_id = nil
  22549. }
  22550. // SetNumber sets the "number" field.
  22551. func (m *PayRechargeMutation) SetNumber(f float32) {
  22552. m.number = &f
  22553. m.addnumber = nil
  22554. }
  22555. // Number returns the value of the "number" field in the mutation.
  22556. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  22557. v := m.number
  22558. if v == nil {
  22559. return
  22560. }
  22561. return *v, true
  22562. }
  22563. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  22564. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22566. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  22567. if !m.op.Is(OpUpdateOne) {
  22568. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  22569. }
  22570. if m.id == nil || m.oldValue == nil {
  22571. return v, errors.New("OldNumber requires an ID field in the mutation")
  22572. }
  22573. oldValue, err := m.oldValue(ctx)
  22574. if err != nil {
  22575. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  22576. }
  22577. return oldValue.Number, nil
  22578. }
  22579. // AddNumber adds f to the "number" field.
  22580. func (m *PayRechargeMutation) AddNumber(f float32) {
  22581. if m.addnumber != nil {
  22582. *m.addnumber += f
  22583. } else {
  22584. m.addnumber = &f
  22585. }
  22586. }
  22587. // AddedNumber returns the value that was added to the "number" field in this mutation.
  22588. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  22589. v := m.addnumber
  22590. if v == nil {
  22591. return
  22592. }
  22593. return *v, true
  22594. }
  22595. // ResetNumber resets all changes to the "number" field.
  22596. func (m *PayRechargeMutation) ResetNumber() {
  22597. m.number = nil
  22598. m.addnumber = nil
  22599. }
  22600. // SetStatus sets the "status" field.
  22601. func (m *PayRechargeMutation) SetStatus(i int) {
  22602. m.status = &i
  22603. m.addstatus = nil
  22604. }
  22605. // Status returns the value of the "status" field in the mutation.
  22606. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  22607. v := m.status
  22608. if v == nil {
  22609. return
  22610. }
  22611. return *v, true
  22612. }
  22613. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  22614. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22616. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  22617. if !m.op.Is(OpUpdateOne) {
  22618. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22619. }
  22620. if m.id == nil || m.oldValue == nil {
  22621. return v, errors.New("OldStatus requires an ID field in the mutation")
  22622. }
  22623. oldValue, err := m.oldValue(ctx)
  22624. if err != nil {
  22625. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22626. }
  22627. return oldValue.Status, nil
  22628. }
  22629. // AddStatus adds i to the "status" field.
  22630. func (m *PayRechargeMutation) AddStatus(i int) {
  22631. if m.addstatus != nil {
  22632. *m.addstatus += i
  22633. } else {
  22634. m.addstatus = &i
  22635. }
  22636. }
  22637. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22638. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  22639. v := m.addstatus
  22640. if v == nil {
  22641. return
  22642. }
  22643. return *v, true
  22644. }
  22645. // ClearStatus clears the value of the "status" field.
  22646. func (m *PayRechargeMutation) ClearStatus() {
  22647. m.status = nil
  22648. m.addstatus = nil
  22649. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  22650. }
  22651. // StatusCleared returns if the "status" field was cleared in this mutation.
  22652. func (m *PayRechargeMutation) StatusCleared() bool {
  22653. _, ok := m.clearedFields[payrecharge.FieldStatus]
  22654. return ok
  22655. }
  22656. // ResetStatus resets all changes to the "status" field.
  22657. func (m *PayRechargeMutation) ResetStatus() {
  22658. m.status = nil
  22659. m.addstatus = nil
  22660. delete(m.clearedFields, payrecharge.FieldStatus)
  22661. }
  22662. // SetMoney sets the "money" field.
  22663. func (m *PayRechargeMutation) SetMoney(f float32) {
  22664. m.money = &f
  22665. m.addmoney = nil
  22666. }
  22667. // Money returns the value of the "money" field in the mutation.
  22668. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  22669. v := m.money
  22670. if v == nil {
  22671. return
  22672. }
  22673. return *v, true
  22674. }
  22675. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  22676. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22678. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  22679. if !m.op.Is(OpUpdateOne) {
  22680. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  22681. }
  22682. if m.id == nil || m.oldValue == nil {
  22683. return v, errors.New("OldMoney requires an ID field in the mutation")
  22684. }
  22685. oldValue, err := m.oldValue(ctx)
  22686. if err != nil {
  22687. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  22688. }
  22689. return oldValue.Money, nil
  22690. }
  22691. // AddMoney adds f to the "money" field.
  22692. func (m *PayRechargeMutation) AddMoney(f float32) {
  22693. if m.addmoney != nil {
  22694. *m.addmoney += f
  22695. } else {
  22696. m.addmoney = &f
  22697. }
  22698. }
  22699. // AddedMoney returns the value that was added to the "money" field in this mutation.
  22700. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  22701. v := m.addmoney
  22702. if v == nil {
  22703. return
  22704. }
  22705. return *v, true
  22706. }
  22707. // ClearMoney clears the value of the "money" field.
  22708. func (m *PayRechargeMutation) ClearMoney() {
  22709. m.money = nil
  22710. m.addmoney = nil
  22711. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  22712. }
  22713. // MoneyCleared returns if the "money" field was cleared in this mutation.
  22714. func (m *PayRechargeMutation) MoneyCleared() bool {
  22715. _, ok := m.clearedFields[payrecharge.FieldMoney]
  22716. return ok
  22717. }
  22718. // ResetMoney resets all changes to the "money" field.
  22719. func (m *PayRechargeMutation) ResetMoney() {
  22720. m.money = nil
  22721. m.addmoney = nil
  22722. delete(m.clearedFields, payrecharge.FieldMoney)
  22723. }
  22724. // SetOutTradeNo sets the "out_trade_no" field.
  22725. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  22726. m.out_trade_no = &s
  22727. }
  22728. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  22729. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  22730. v := m.out_trade_no
  22731. if v == nil {
  22732. return
  22733. }
  22734. return *v, true
  22735. }
  22736. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  22737. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22739. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  22740. if !m.op.Is(OpUpdateOne) {
  22741. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  22742. }
  22743. if m.id == nil || m.oldValue == nil {
  22744. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  22745. }
  22746. oldValue, err := m.oldValue(ctx)
  22747. if err != nil {
  22748. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  22749. }
  22750. return oldValue.OutTradeNo, nil
  22751. }
  22752. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  22753. func (m *PayRechargeMutation) ClearOutTradeNo() {
  22754. m.out_trade_no = nil
  22755. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  22756. }
  22757. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  22758. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  22759. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  22760. return ok
  22761. }
  22762. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  22763. func (m *PayRechargeMutation) ResetOutTradeNo() {
  22764. m.out_trade_no = nil
  22765. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  22766. }
  22767. // SetOrganizationID sets the "organization_id" field.
  22768. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  22769. m.organization_id = &u
  22770. m.addorganization_id = nil
  22771. }
  22772. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22773. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  22774. v := m.organization_id
  22775. if v == nil {
  22776. return
  22777. }
  22778. return *v, true
  22779. }
  22780. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  22781. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22783. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22784. if !m.op.Is(OpUpdateOne) {
  22785. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22786. }
  22787. if m.id == nil || m.oldValue == nil {
  22788. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22789. }
  22790. oldValue, err := m.oldValue(ctx)
  22791. if err != nil {
  22792. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22793. }
  22794. return oldValue.OrganizationID, nil
  22795. }
  22796. // AddOrganizationID adds u to the "organization_id" field.
  22797. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  22798. if m.addorganization_id != nil {
  22799. *m.addorganization_id += u
  22800. } else {
  22801. m.addorganization_id = &u
  22802. }
  22803. }
  22804. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22805. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  22806. v := m.addorganization_id
  22807. if v == nil {
  22808. return
  22809. }
  22810. return *v, true
  22811. }
  22812. // ResetOrganizationID resets all changes to the "organization_id" field.
  22813. func (m *PayRechargeMutation) ResetOrganizationID() {
  22814. m.organization_id = nil
  22815. m.addorganization_id = nil
  22816. }
  22817. // Where appends a list predicates to the PayRechargeMutation builder.
  22818. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  22819. m.predicates = append(m.predicates, ps...)
  22820. }
  22821. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  22822. // users can use type-assertion to append predicates that do not depend on any generated package.
  22823. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  22824. p := make([]predicate.PayRecharge, len(ps))
  22825. for i := range ps {
  22826. p[i] = ps[i]
  22827. }
  22828. m.Where(p...)
  22829. }
  22830. // Op returns the operation name.
  22831. func (m *PayRechargeMutation) Op() Op {
  22832. return m.op
  22833. }
  22834. // SetOp allows setting the mutation operation.
  22835. func (m *PayRechargeMutation) SetOp(op Op) {
  22836. m.op = op
  22837. }
  22838. // Type returns the node type of this mutation (PayRecharge).
  22839. func (m *PayRechargeMutation) Type() string {
  22840. return m.typ
  22841. }
  22842. // Fields returns all fields that were changed during this mutation. Note that in
  22843. // order to get all numeric fields that were incremented/decremented, call
  22844. // AddedFields().
  22845. func (m *PayRechargeMutation) Fields() []string {
  22846. fields := make([]string, 0, 9)
  22847. if m.created_at != nil {
  22848. fields = append(fields, payrecharge.FieldCreatedAt)
  22849. }
  22850. if m.updated_at != nil {
  22851. fields = append(fields, payrecharge.FieldUpdatedAt)
  22852. }
  22853. if m.deleted_at != nil {
  22854. fields = append(fields, payrecharge.FieldDeletedAt)
  22855. }
  22856. if m.user_id != nil {
  22857. fields = append(fields, payrecharge.FieldUserID)
  22858. }
  22859. if m.number != nil {
  22860. fields = append(fields, payrecharge.FieldNumber)
  22861. }
  22862. if m.status != nil {
  22863. fields = append(fields, payrecharge.FieldStatus)
  22864. }
  22865. if m.money != nil {
  22866. fields = append(fields, payrecharge.FieldMoney)
  22867. }
  22868. if m.out_trade_no != nil {
  22869. fields = append(fields, payrecharge.FieldOutTradeNo)
  22870. }
  22871. if m.organization_id != nil {
  22872. fields = append(fields, payrecharge.FieldOrganizationID)
  22873. }
  22874. return fields
  22875. }
  22876. // Field returns the value of a field with the given name. The second boolean
  22877. // return value indicates that this field was not set, or was not defined in the
  22878. // schema.
  22879. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  22880. switch name {
  22881. case payrecharge.FieldCreatedAt:
  22882. return m.CreatedAt()
  22883. case payrecharge.FieldUpdatedAt:
  22884. return m.UpdatedAt()
  22885. case payrecharge.FieldDeletedAt:
  22886. return m.DeletedAt()
  22887. case payrecharge.FieldUserID:
  22888. return m.UserID()
  22889. case payrecharge.FieldNumber:
  22890. return m.Number()
  22891. case payrecharge.FieldStatus:
  22892. return m.Status()
  22893. case payrecharge.FieldMoney:
  22894. return m.Money()
  22895. case payrecharge.FieldOutTradeNo:
  22896. return m.OutTradeNo()
  22897. case payrecharge.FieldOrganizationID:
  22898. return m.OrganizationID()
  22899. }
  22900. return nil, false
  22901. }
  22902. // OldField returns the old value of the field from the database. An error is
  22903. // returned if the mutation operation is not UpdateOne, or the query to the
  22904. // database failed.
  22905. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22906. switch name {
  22907. case payrecharge.FieldCreatedAt:
  22908. return m.OldCreatedAt(ctx)
  22909. case payrecharge.FieldUpdatedAt:
  22910. return m.OldUpdatedAt(ctx)
  22911. case payrecharge.FieldDeletedAt:
  22912. return m.OldDeletedAt(ctx)
  22913. case payrecharge.FieldUserID:
  22914. return m.OldUserID(ctx)
  22915. case payrecharge.FieldNumber:
  22916. return m.OldNumber(ctx)
  22917. case payrecharge.FieldStatus:
  22918. return m.OldStatus(ctx)
  22919. case payrecharge.FieldMoney:
  22920. return m.OldMoney(ctx)
  22921. case payrecharge.FieldOutTradeNo:
  22922. return m.OldOutTradeNo(ctx)
  22923. case payrecharge.FieldOrganizationID:
  22924. return m.OldOrganizationID(ctx)
  22925. }
  22926. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  22927. }
  22928. // SetField sets the value of a field with the given name. It returns an error if
  22929. // the field is not defined in the schema, or if the type mismatched the field
  22930. // type.
  22931. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  22932. switch name {
  22933. case payrecharge.FieldCreatedAt:
  22934. v, ok := value.(time.Time)
  22935. if !ok {
  22936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22937. }
  22938. m.SetCreatedAt(v)
  22939. return nil
  22940. case payrecharge.FieldUpdatedAt:
  22941. v, ok := value.(time.Time)
  22942. if !ok {
  22943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22944. }
  22945. m.SetUpdatedAt(v)
  22946. return nil
  22947. case payrecharge.FieldDeletedAt:
  22948. v, ok := value.(time.Time)
  22949. if !ok {
  22950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22951. }
  22952. m.SetDeletedAt(v)
  22953. return nil
  22954. case payrecharge.FieldUserID:
  22955. v, ok := value.(string)
  22956. if !ok {
  22957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22958. }
  22959. m.SetUserID(v)
  22960. return nil
  22961. case payrecharge.FieldNumber:
  22962. v, ok := value.(float32)
  22963. if !ok {
  22964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22965. }
  22966. m.SetNumber(v)
  22967. return nil
  22968. case payrecharge.FieldStatus:
  22969. v, ok := value.(int)
  22970. if !ok {
  22971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22972. }
  22973. m.SetStatus(v)
  22974. return nil
  22975. case payrecharge.FieldMoney:
  22976. v, ok := value.(float32)
  22977. if !ok {
  22978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22979. }
  22980. m.SetMoney(v)
  22981. return nil
  22982. case payrecharge.FieldOutTradeNo:
  22983. v, ok := value.(string)
  22984. if !ok {
  22985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22986. }
  22987. m.SetOutTradeNo(v)
  22988. return nil
  22989. case payrecharge.FieldOrganizationID:
  22990. v, ok := value.(uint64)
  22991. if !ok {
  22992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22993. }
  22994. m.SetOrganizationID(v)
  22995. return nil
  22996. }
  22997. return fmt.Errorf("unknown PayRecharge field %s", name)
  22998. }
  22999. // AddedFields returns all numeric fields that were incremented/decremented during
  23000. // this mutation.
  23001. func (m *PayRechargeMutation) AddedFields() []string {
  23002. var fields []string
  23003. if m.addnumber != nil {
  23004. fields = append(fields, payrecharge.FieldNumber)
  23005. }
  23006. if m.addstatus != nil {
  23007. fields = append(fields, payrecharge.FieldStatus)
  23008. }
  23009. if m.addmoney != nil {
  23010. fields = append(fields, payrecharge.FieldMoney)
  23011. }
  23012. if m.addorganization_id != nil {
  23013. fields = append(fields, payrecharge.FieldOrganizationID)
  23014. }
  23015. return fields
  23016. }
  23017. // AddedField returns the numeric value that was incremented/decremented on a field
  23018. // with the given name. The second boolean return value indicates that this field
  23019. // was not set, or was not defined in the schema.
  23020. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  23021. switch name {
  23022. case payrecharge.FieldNumber:
  23023. return m.AddedNumber()
  23024. case payrecharge.FieldStatus:
  23025. return m.AddedStatus()
  23026. case payrecharge.FieldMoney:
  23027. return m.AddedMoney()
  23028. case payrecharge.FieldOrganizationID:
  23029. return m.AddedOrganizationID()
  23030. }
  23031. return nil, false
  23032. }
  23033. // AddField adds the value to the field with the given name. It returns an error if
  23034. // the field is not defined in the schema, or if the type mismatched the field
  23035. // type.
  23036. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  23037. switch name {
  23038. case payrecharge.FieldNumber:
  23039. v, ok := value.(float32)
  23040. if !ok {
  23041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23042. }
  23043. m.AddNumber(v)
  23044. return nil
  23045. case payrecharge.FieldStatus:
  23046. v, ok := value.(int)
  23047. if !ok {
  23048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23049. }
  23050. m.AddStatus(v)
  23051. return nil
  23052. case payrecharge.FieldMoney:
  23053. v, ok := value.(float32)
  23054. if !ok {
  23055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23056. }
  23057. m.AddMoney(v)
  23058. return nil
  23059. case payrecharge.FieldOrganizationID:
  23060. v, ok := value.(int64)
  23061. if !ok {
  23062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23063. }
  23064. m.AddOrganizationID(v)
  23065. return nil
  23066. }
  23067. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  23068. }
  23069. // ClearedFields returns all nullable fields that were cleared during this
  23070. // mutation.
  23071. func (m *PayRechargeMutation) ClearedFields() []string {
  23072. var fields []string
  23073. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  23074. fields = append(fields, payrecharge.FieldDeletedAt)
  23075. }
  23076. if m.FieldCleared(payrecharge.FieldStatus) {
  23077. fields = append(fields, payrecharge.FieldStatus)
  23078. }
  23079. if m.FieldCleared(payrecharge.FieldMoney) {
  23080. fields = append(fields, payrecharge.FieldMoney)
  23081. }
  23082. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  23083. fields = append(fields, payrecharge.FieldOutTradeNo)
  23084. }
  23085. return fields
  23086. }
  23087. // FieldCleared returns a boolean indicating if a field with the given name was
  23088. // cleared in this mutation.
  23089. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  23090. _, ok := m.clearedFields[name]
  23091. return ok
  23092. }
  23093. // ClearField clears the value of the field with the given name. It returns an
  23094. // error if the field is not defined in the schema.
  23095. func (m *PayRechargeMutation) ClearField(name string) error {
  23096. switch name {
  23097. case payrecharge.FieldDeletedAt:
  23098. m.ClearDeletedAt()
  23099. return nil
  23100. case payrecharge.FieldStatus:
  23101. m.ClearStatus()
  23102. return nil
  23103. case payrecharge.FieldMoney:
  23104. m.ClearMoney()
  23105. return nil
  23106. case payrecharge.FieldOutTradeNo:
  23107. m.ClearOutTradeNo()
  23108. return nil
  23109. }
  23110. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  23111. }
  23112. // ResetField resets all changes in the mutation for the field with the given name.
  23113. // It returns an error if the field is not defined in the schema.
  23114. func (m *PayRechargeMutation) ResetField(name string) error {
  23115. switch name {
  23116. case payrecharge.FieldCreatedAt:
  23117. m.ResetCreatedAt()
  23118. return nil
  23119. case payrecharge.FieldUpdatedAt:
  23120. m.ResetUpdatedAt()
  23121. return nil
  23122. case payrecharge.FieldDeletedAt:
  23123. m.ResetDeletedAt()
  23124. return nil
  23125. case payrecharge.FieldUserID:
  23126. m.ResetUserID()
  23127. return nil
  23128. case payrecharge.FieldNumber:
  23129. m.ResetNumber()
  23130. return nil
  23131. case payrecharge.FieldStatus:
  23132. m.ResetStatus()
  23133. return nil
  23134. case payrecharge.FieldMoney:
  23135. m.ResetMoney()
  23136. return nil
  23137. case payrecharge.FieldOutTradeNo:
  23138. m.ResetOutTradeNo()
  23139. return nil
  23140. case payrecharge.FieldOrganizationID:
  23141. m.ResetOrganizationID()
  23142. return nil
  23143. }
  23144. return fmt.Errorf("unknown PayRecharge field %s", name)
  23145. }
  23146. // AddedEdges returns all edge names that were set/added in this mutation.
  23147. func (m *PayRechargeMutation) AddedEdges() []string {
  23148. edges := make([]string, 0, 0)
  23149. return edges
  23150. }
  23151. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23152. // name in this mutation.
  23153. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  23154. return nil
  23155. }
  23156. // RemovedEdges returns all edge names that were removed in this mutation.
  23157. func (m *PayRechargeMutation) RemovedEdges() []string {
  23158. edges := make([]string, 0, 0)
  23159. return edges
  23160. }
  23161. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23162. // the given name in this mutation.
  23163. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  23164. return nil
  23165. }
  23166. // ClearedEdges returns all edge names that were cleared in this mutation.
  23167. func (m *PayRechargeMutation) ClearedEdges() []string {
  23168. edges := make([]string, 0, 0)
  23169. return edges
  23170. }
  23171. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23172. // was cleared in this mutation.
  23173. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  23174. return false
  23175. }
  23176. // ClearEdge clears the value of the edge with the given name. It returns an error
  23177. // if that edge is not defined in the schema.
  23178. func (m *PayRechargeMutation) ClearEdge(name string) error {
  23179. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  23180. }
  23181. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23182. // It returns an error if the edge is not defined in the schema.
  23183. func (m *PayRechargeMutation) ResetEdge(name string) error {
  23184. return fmt.Errorf("unknown PayRecharge edge %s", name)
  23185. }
  23186. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  23187. type ServerMutation struct {
  23188. config
  23189. op Op
  23190. typ string
  23191. id *uint64
  23192. created_at *time.Time
  23193. updated_at *time.Time
  23194. status *uint8
  23195. addstatus *int8
  23196. deleted_at *time.Time
  23197. name *string
  23198. public_ip *string
  23199. private_ip *string
  23200. admin_port *string
  23201. clearedFields map[string]struct{}
  23202. wxs map[uint64]struct{}
  23203. removedwxs map[uint64]struct{}
  23204. clearedwxs bool
  23205. done bool
  23206. oldValue func(context.Context) (*Server, error)
  23207. predicates []predicate.Server
  23208. }
  23209. var _ ent.Mutation = (*ServerMutation)(nil)
  23210. // serverOption allows management of the mutation configuration using functional options.
  23211. type serverOption func(*ServerMutation)
  23212. // newServerMutation creates new mutation for the Server entity.
  23213. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  23214. m := &ServerMutation{
  23215. config: c,
  23216. op: op,
  23217. typ: TypeServer,
  23218. clearedFields: make(map[string]struct{}),
  23219. }
  23220. for _, opt := range opts {
  23221. opt(m)
  23222. }
  23223. return m
  23224. }
  23225. // withServerID sets the ID field of the mutation.
  23226. func withServerID(id uint64) serverOption {
  23227. return func(m *ServerMutation) {
  23228. var (
  23229. err error
  23230. once sync.Once
  23231. value *Server
  23232. )
  23233. m.oldValue = func(ctx context.Context) (*Server, error) {
  23234. once.Do(func() {
  23235. if m.done {
  23236. err = errors.New("querying old values post mutation is not allowed")
  23237. } else {
  23238. value, err = m.Client().Server.Get(ctx, id)
  23239. }
  23240. })
  23241. return value, err
  23242. }
  23243. m.id = &id
  23244. }
  23245. }
  23246. // withServer sets the old Server of the mutation.
  23247. func withServer(node *Server) serverOption {
  23248. return func(m *ServerMutation) {
  23249. m.oldValue = func(context.Context) (*Server, error) {
  23250. return node, nil
  23251. }
  23252. m.id = &node.ID
  23253. }
  23254. }
  23255. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23256. // executed in a transaction (ent.Tx), a transactional client is returned.
  23257. func (m ServerMutation) Client() *Client {
  23258. client := &Client{config: m.config}
  23259. client.init()
  23260. return client
  23261. }
  23262. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23263. // it returns an error otherwise.
  23264. func (m ServerMutation) Tx() (*Tx, error) {
  23265. if _, ok := m.driver.(*txDriver); !ok {
  23266. return nil, errors.New("ent: mutation is not running in a transaction")
  23267. }
  23268. tx := &Tx{config: m.config}
  23269. tx.init()
  23270. return tx, nil
  23271. }
  23272. // SetID sets the value of the id field. Note that this
  23273. // operation is only accepted on creation of Server entities.
  23274. func (m *ServerMutation) SetID(id uint64) {
  23275. m.id = &id
  23276. }
  23277. // ID returns the ID value in the mutation. Note that the ID is only available
  23278. // if it was provided to the builder or after it was returned from the database.
  23279. func (m *ServerMutation) ID() (id uint64, exists bool) {
  23280. if m.id == nil {
  23281. return
  23282. }
  23283. return *m.id, true
  23284. }
  23285. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23286. // That means, if the mutation is applied within a transaction with an isolation level such
  23287. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23288. // or updated by the mutation.
  23289. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  23290. switch {
  23291. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23292. id, exists := m.ID()
  23293. if exists {
  23294. return []uint64{id}, nil
  23295. }
  23296. fallthrough
  23297. case m.op.Is(OpUpdate | OpDelete):
  23298. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  23299. default:
  23300. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23301. }
  23302. }
  23303. // SetCreatedAt sets the "created_at" field.
  23304. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  23305. m.created_at = &t
  23306. }
  23307. // CreatedAt returns the value of the "created_at" field in the mutation.
  23308. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  23309. v := m.created_at
  23310. if v == nil {
  23311. return
  23312. }
  23313. return *v, true
  23314. }
  23315. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  23316. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23318. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23319. if !m.op.Is(OpUpdateOne) {
  23320. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23321. }
  23322. if m.id == nil || m.oldValue == nil {
  23323. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23324. }
  23325. oldValue, err := m.oldValue(ctx)
  23326. if err != nil {
  23327. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23328. }
  23329. return oldValue.CreatedAt, nil
  23330. }
  23331. // ResetCreatedAt resets all changes to the "created_at" field.
  23332. func (m *ServerMutation) ResetCreatedAt() {
  23333. m.created_at = nil
  23334. }
  23335. // SetUpdatedAt sets the "updated_at" field.
  23336. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  23337. m.updated_at = &t
  23338. }
  23339. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23340. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  23341. v := m.updated_at
  23342. if v == nil {
  23343. return
  23344. }
  23345. return *v, true
  23346. }
  23347. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  23348. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23350. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23351. if !m.op.Is(OpUpdateOne) {
  23352. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23353. }
  23354. if m.id == nil || m.oldValue == nil {
  23355. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23356. }
  23357. oldValue, err := m.oldValue(ctx)
  23358. if err != nil {
  23359. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23360. }
  23361. return oldValue.UpdatedAt, nil
  23362. }
  23363. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23364. func (m *ServerMutation) ResetUpdatedAt() {
  23365. m.updated_at = nil
  23366. }
  23367. // SetStatus sets the "status" field.
  23368. func (m *ServerMutation) SetStatus(u uint8) {
  23369. m.status = &u
  23370. m.addstatus = nil
  23371. }
  23372. // Status returns the value of the "status" field in the mutation.
  23373. func (m *ServerMutation) Status() (r uint8, exists bool) {
  23374. v := m.status
  23375. if v == nil {
  23376. return
  23377. }
  23378. return *v, true
  23379. }
  23380. // OldStatus returns the old "status" field's value of the Server entity.
  23381. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23383. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23384. if !m.op.Is(OpUpdateOne) {
  23385. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23386. }
  23387. if m.id == nil || m.oldValue == nil {
  23388. return v, errors.New("OldStatus requires an ID field in the mutation")
  23389. }
  23390. oldValue, err := m.oldValue(ctx)
  23391. if err != nil {
  23392. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23393. }
  23394. return oldValue.Status, nil
  23395. }
  23396. // AddStatus adds u to the "status" field.
  23397. func (m *ServerMutation) AddStatus(u int8) {
  23398. if m.addstatus != nil {
  23399. *m.addstatus += u
  23400. } else {
  23401. m.addstatus = &u
  23402. }
  23403. }
  23404. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23405. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  23406. v := m.addstatus
  23407. if v == nil {
  23408. return
  23409. }
  23410. return *v, true
  23411. }
  23412. // ClearStatus clears the value of the "status" field.
  23413. func (m *ServerMutation) ClearStatus() {
  23414. m.status = nil
  23415. m.addstatus = nil
  23416. m.clearedFields[server.FieldStatus] = struct{}{}
  23417. }
  23418. // StatusCleared returns if the "status" field was cleared in this mutation.
  23419. func (m *ServerMutation) StatusCleared() bool {
  23420. _, ok := m.clearedFields[server.FieldStatus]
  23421. return ok
  23422. }
  23423. // ResetStatus resets all changes to the "status" field.
  23424. func (m *ServerMutation) ResetStatus() {
  23425. m.status = nil
  23426. m.addstatus = nil
  23427. delete(m.clearedFields, server.FieldStatus)
  23428. }
  23429. // SetDeletedAt sets the "deleted_at" field.
  23430. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  23431. m.deleted_at = &t
  23432. }
  23433. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23434. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  23435. v := m.deleted_at
  23436. if v == nil {
  23437. return
  23438. }
  23439. return *v, true
  23440. }
  23441. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  23442. // If the Server 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 *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23445. if !m.op.Is(OpUpdateOne) {
  23446. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23447. }
  23448. if m.id == nil || m.oldValue == nil {
  23449. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  23454. }
  23455. return oldValue.DeletedAt, nil
  23456. }
  23457. // ClearDeletedAt clears the value of the "deleted_at" field.
  23458. func (m *ServerMutation) ClearDeletedAt() {
  23459. m.deleted_at = nil
  23460. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  23461. }
  23462. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23463. func (m *ServerMutation) DeletedAtCleared() bool {
  23464. _, ok := m.clearedFields[server.FieldDeletedAt]
  23465. return ok
  23466. }
  23467. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23468. func (m *ServerMutation) ResetDeletedAt() {
  23469. m.deleted_at = nil
  23470. delete(m.clearedFields, server.FieldDeletedAt)
  23471. }
  23472. // SetName sets the "name" field.
  23473. func (m *ServerMutation) SetName(s string) {
  23474. m.name = &s
  23475. }
  23476. // Name returns the value of the "name" field in the mutation.
  23477. func (m *ServerMutation) Name() (r string, exists bool) {
  23478. v := m.name
  23479. if v == nil {
  23480. return
  23481. }
  23482. return *v, true
  23483. }
  23484. // OldName returns the old "name" field's value of the Server entity.
  23485. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23487. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  23488. if !m.op.Is(OpUpdateOne) {
  23489. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23490. }
  23491. if m.id == nil || m.oldValue == nil {
  23492. return v, errors.New("OldName requires an ID field in the mutation")
  23493. }
  23494. oldValue, err := m.oldValue(ctx)
  23495. if err != nil {
  23496. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23497. }
  23498. return oldValue.Name, nil
  23499. }
  23500. // ResetName resets all changes to the "name" field.
  23501. func (m *ServerMutation) ResetName() {
  23502. m.name = nil
  23503. }
  23504. // SetPublicIP sets the "public_ip" field.
  23505. func (m *ServerMutation) SetPublicIP(s string) {
  23506. m.public_ip = &s
  23507. }
  23508. // PublicIP returns the value of the "public_ip" field in the mutation.
  23509. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  23510. v := m.public_ip
  23511. if v == nil {
  23512. return
  23513. }
  23514. return *v, true
  23515. }
  23516. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  23517. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23519. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  23520. if !m.op.Is(OpUpdateOne) {
  23521. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  23522. }
  23523. if m.id == nil || m.oldValue == nil {
  23524. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  23525. }
  23526. oldValue, err := m.oldValue(ctx)
  23527. if err != nil {
  23528. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  23529. }
  23530. return oldValue.PublicIP, nil
  23531. }
  23532. // ResetPublicIP resets all changes to the "public_ip" field.
  23533. func (m *ServerMutation) ResetPublicIP() {
  23534. m.public_ip = nil
  23535. }
  23536. // SetPrivateIP sets the "private_ip" field.
  23537. func (m *ServerMutation) SetPrivateIP(s string) {
  23538. m.private_ip = &s
  23539. }
  23540. // PrivateIP returns the value of the "private_ip" field in the mutation.
  23541. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  23542. v := m.private_ip
  23543. if v == nil {
  23544. return
  23545. }
  23546. return *v, true
  23547. }
  23548. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  23549. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23551. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  23552. if !m.op.Is(OpUpdateOne) {
  23553. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  23554. }
  23555. if m.id == nil || m.oldValue == nil {
  23556. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  23557. }
  23558. oldValue, err := m.oldValue(ctx)
  23559. if err != nil {
  23560. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  23561. }
  23562. return oldValue.PrivateIP, nil
  23563. }
  23564. // ResetPrivateIP resets all changes to the "private_ip" field.
  23565. func (m *ServerMutation) ResetPrivateIP() {
  23566. m.private_ip = nil
  23567. }
  23568. // SetAdminPort sets the "admin_port" field.
  23569. func (m *ServerMutation) SetAdminPort(s string) {
  23570. m.admin_port = &s
  23571. }
  23572. // AdminPort returns the value of the "admin_port" field in the mutation.
  23573. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  23574. v := m.admin_port
  23575. if v == nil {
  23576. return
  23577. }
  23578. return *v, true
  23579. }
  23580. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  23581. // If the Server 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 *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  23584. if !m.op.Is(OpUpdateOne) {
  23585. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  23586. }
  23587. if m.id == nil || m.oldValue == nil {
  23588. return v, errors.New("OldAdminPort 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 OldAdminPort: %w", err)
  23593. }
  23594. return oldValue.AdminPort, nil
  23595. }
  23596. // ResetAdminPort resets all changes to the "admin_port" field.
  23597. func (m *ServerMutation) ResetAdminPort() {
  23598. m.admin_port = nil
  23599. }
  23600. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  23601. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  23602. if m.wxs == nil {
  23603. m.wxs = make(map[uint64]struct{})
  23604. }
  23605. for i := range ids {
  23606. m.wxs[ids[i]] = struct{}{}
  23607. }
  23608. }
  23609. // ClearWxs clears the "wxs" edge to the Wx entity.
  23610. func (m *ServerMutation) ClearWxs() {
  23611. m.clearedwxs = true
  23612. }
  23613. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  23614. func (m *ServerMutation) WxsCleared() bool {
  23615. return m.clearedwxs
  23616. }
  23617. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  23618. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  23619. if m.removedwxs == nil {
  23620. m.removedwxs = make(map[uint64]struct{})
  23621. }
  23622. for i := range ids {
  23623. delete(m.wxs, ids[i])
  23624. m.removedwxs[ids[i]] = struct{}{}
  23625. }
  23626. }
  23627. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  23628. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  23629. for id := range m.removedwxs {
  23630. ids = append(ids, id)
  23631. }
  23632. return
  23633. }
  23634. // WxsIDs returns the "wxs" edge IDs in the mutation.
  23635. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  23636. for id := range m.wxs {
  23637. ids = append(ids, id)
  23638. }
  23639. return
  23640. }
  23641. // ResetWxs resets all changes to the "wxs" edge.
  23642. func (m *ServerMutation) ResetWxs() {
  23643. m.wxs = nil
  23644. m.clearedwxs = false
  23645. m.removedwxs = nil
  23646. }
  23647. // Where appends a list predicates to the ServerMutation builder.
  23648. func (m *ServerMutation) Where(ps ...predicate.Server) {
  23649. m.predicates = append(m.predicates, ps...)
  23650. }
  23651. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  23652. // users can use type-assertion to append predicates that do not depend on any generated package.
  23653. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  23654. p := make([]predicate.Server, len(ps))
  23655. for i := range ps {
  23656. p[i] = ps[i]
  23657. }
  23658. m.Where(p...)
  23659. }
  23660. // Op returns the operation name.
  23661. func (m *ServerMutation) Op() Op {
  23662. return m.op
  23663. }
  23664. // SetOp allows setting the mutation operation.
  23665. func (m *ServerMutation) SetOp(op Op) {
  23666. m.op = op
  23667. }
  23668. // Type returns the node type of this mutation (Server).
  23669. func (m *ServerMutation) Type() string {
  23670. return m.typ
  23671. }
  23672. // Fields returns all fields that were changed during this mutation. Note that in
  23673. // order to get all numeric fields that were incremented/decremented, call
  23674. // AddedFields().
  23675. func (m *ServerMutation) Fields() []string {
  23676. fields := make([]string, 0, 8)
  23677. if m.created_at != nil {
  23678. fields = append(fields, server.FieldCreatedAt)
  23679. }
  23680. if m.updated_at != nil {
  23681. fields = append(fields, server.FieldUpdatedAt)
  23682. }
  23683. if m.status != nil {
  23684. fields = append(fields, server.FieldStatus)
  23685. }
  23686. if m.deleted_at != nil {
  23687. fields = append(fields, server.FieldDeletedAt)
  23688. }
  23689. if m.name != nil {
  23690. fields = append(fields, server.FieldName)
  23691. }
  23692. if m.public_ip != nil {
  23693. fields = append(fields, server.FieldPublicIP)
  23694. }
  23695. if m.private_ip != nil {
  23696. fields = append(fields, server.FieldPrivateIP)
  23697. }
  23698. if m.admin_port != nil {
  23699. fields = append(fields, server.FieldAdminPort)
  23700. }
  23701. return fields
  23702. }
  23703. // Field returns the value of a field with the given name. The second boolean
  23704. // return value indicates that this field was not set, or was not defined in the
  23705. // schema.
  23706. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  23707. switch name {
  23708. case server.FieldCreatedAt:
  23709. return m.CreatedAt()
  23710. case server.FieldUpdatedAt:
  23711. return m.UpdatedAt()
  23712. case server.FieldStatus:
  23713. return m.Status()
  23714. case server.FieldDeletedAt:
  23715. return m.DeletedAt()
  23716. case server.FieldName:
  23717. return m.Name()
  23718. case server.FieldPublicIP:
  23719. return m.PublicIP()
  23720. case server.FieldPrivateIP:
  23721. return m.PrivateIP()
  23722. case server.FieldAdminPort:
  23723. return m.AdminPort()
  23724. }
  23725. return nil, false
  23726. }
  23727. // OldField returns the old value of the field from the database. An error is
  23728. // returned if the mutation operation is not UpdateOne, or the query to the
  23729. // database failed.
  23730. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23731. switch name {
  23732. case server.FieldCreatedAt:
  23733. return m.OldCreatedAt(ctx)
  23734. case server.FieldUpdatedAt:
  23735. return m.OldUpdatedAt(ctx)
  23736. case server.FieldStatus:
  23737. return m.OldStatus(ctx)
  23738. case server.FieldDeletedAt:
  23739. return m.OldDeletedAt(ctx)
  23740. case server.FieldName:
  23741. return m.OldName(ctx)
  23742. case server.FieldPublicIP:
  23743. return m.OldPublicIP(ctx)
  23744. case server.FieldPrivateIP:
  23745. return m.OldPrivateIP(ctx)
  23746. case server.FieldAdminPort:
  23747. return m.OldAdminPort(ctx)
  23748. }
  23749. return nil, fmt.Errorf("unknown Server field %s", name)
  23750. }
  23751. // SetField sets the value of a field with the given name. It returns an error if
  23752. // the field is not defined in the schema, or if the type mismatched the field
  23753. // type.
  23754. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  23755. switch name {
  23756. case server.FieldCreatedAt:
  23757. v, ok := value.(time.Time)
  23758. if !ok {
  23759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23760. }
  23761. m.SetCreatedAt(v)
  23762. return nil
  23763. case server.FieldUpdatedAt:
  23764. v, ok := value.(time.Time)
  23765. if !ok {
  23766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23767. }
  23768. m.SetUpdatedAt(v)
  23769. return nil
  23770. case server.FieldStatus:
  23771. v, ok := value.(uint8)
  23772. if !ok {
  23773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23774. }
  23775. m.SetStatus(v)
  23776. return nil
  23777. case server.FieldDeletedAt:
  23778. v, ok := value.(time.Time)
  23779. if !ok {
  23780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23781. }
  23782. m.SetDeletedAt(v)
  23783. return nil
  23784. case server.FieldName:
  23785. v, ok := value.(string)
  23786. if !ok {
  23787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23788. }
  23789. m.SetName(v)
  23790. return nil
  23791. case server.FieldPublicIP:
  23792. v, ok := value.(string)
  23793. if !ok {
  23794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23795. }
  23796. m.SetPublicIP(v)
  23797. return nil
  23798. case server.FieldPrivateIP:
  23799. v, ok := value.(string)
  23800. if !ok {
  23801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23802. }
  23803. m.SetPrivateIP(v)
  23804. return nil
  23805. case server.FieldAdminPort:
  23806. v, ok := value.(string)
  23807. if !ok {
  23808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23809. }
  23810. m.SetAdminPort(v)
  23811. return nil
  23812. }
  23813. return fmt.Errorf("unknown Server field %s", name)
  23814. }
  23815. // AddedFields returns all numeric fields that were incremented/decremented during
  23816. // this mutation.
  23817. func (m *ServerMutation) AddedFields() []string {
  23818. var fields []string
  23819. if m.addstatus != nil {
  23820. fields = append(fields, server.FieldStatus)
  23821. }
  23822. return fields
  23823. }
  23824. // AddedField returns the numeric value that was incremented/decremented on a field
  23825. // with the given name. The second boolean return value indicates that this field
  23826. // was not set, or was not defined in the schema.
  23827. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  23828. switch name {
  23829. case server.FieldStatus:
  23830. return m.AddedStatus()
  23831. }
  23832. return nil, false
  23833. }
  23834. // AddField adds the value to the field with the given name. It returns an error if
  23835. // the field is not defined in the schema, or if the type mismatched the field
  23836. // type.
  23837. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  23838. switch name {
  23839. case server.FieldStatus:
  23840. v, ok := value.(int8)
  23841. if !ok {
  23842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23843. }
  23844. m.AddStatus(v)
  23845. return nil
  23846. }
  23847. return fmt.Errorf("unknown Server numeric field %s", name)
  23848. }
  23849. // ClearedFields returns all nullable fields that were cleared during this
  23850. // mutation.
  23851. func (m *ServerMutation) ClearedFields() []string {
  23852. var fields []string
  23853. if m.FieldCleared(server.FieldStatus) {
  23854. fields = append(fields, server.FieldStatus)
  23855. }
  23856. if m.FieldCleared(server.FieldDeletedAt) {
  23857. fields = append(fields, server.FieldDeletedAt)
  23858. }
  23859. return fields
  23860. }
  23861. // FieldCleared returns a boolean indicating if a field with the given name was
  23862. // cleared in this mutation.
  23863. func (m *ServerMutation) FieldCleared(name string) bool {
  23864. _, ok := m.clearedFields[name]
  23865. return ok
  23866. }
  23867. // ClearField clears the value of the field with the given name. It returns an
  23868. // error if the field is not defined in the schema.
  23869. func (m *ServerMutation) ClearField(name string) error {
  23870. switch name {
  23871. case server.FieldStatus:
  23872. m.ClearStatus()
  23873. return nil
  23874. case server.FieldDeletedAt:
  23875. m.ClearDeletedAt()
  23876. return nil
  23877. }
  23878. return fmt.Errorf("unknown Server nullable field %s", name)
  23879. }
  23880. // ResetField resets all changes in the mutation for the field with the given name.
  23881. // It returns an error if the field is not defined in the schema.
  23882. func (m *ServerMutation) ResetField(name string) error {
  23883. switch name {
  23884. case server.FieldCreatedAt:
  23885. m.ResetCreatedAt()
  23886. return nil
  23887. case server.FieldUpdatedAt:
  23888. m.ResetUpdatedAt()
  23889. return nil
  23890. case server.FieldStatus:
  23891. m.ResetStatus()
  23892. return nil
  23893. case server.FieldDeletedAt:
  23894. m.ResetDeletedAt()
  23895. return nil
  23896. case server.FieldName:
  23897. m.ResetName()
  23898. return nil
  23899. case server.FieldPublicIP:
  23900. m.ResetPublicIP()
  23901. return nil
  23902. case server.FieldPrivateIP:
  23903. m.ResetPrivateIP()
  23904. return nil
  23905. case server.FieldAdminPort:
  23906. m.ResetAdminPort()
  23907. return nil
  23908. }
  23909. return fmt.Errorf("unknown Server field %s", name)
  23910. }
  23911. // AddedEdges returns all edge names that were set/added in this mutation.
  23912. func (m *ServerMutation) AddedEdges() []string {
  23913. edges := make([]string, 0, 1)
  23914. if m.wxs != nil {
  23915. edges = append(edges, server.EdgeWxs)
  23916. }
  23917. return edges
  23918. }
  23919. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23920. // name in this mutation.
  23921. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  23922. switch name {
  23923. case server.EdgeWxs:
  23924. ids := make([]ent.Value, 0, len(m.wxs))
  23925. for id := range m.wxs {
  23926. ids = append(ids, id)
  23927. }
  23928. return ids
  23929. }
  23930. return nil
  23931. }
  23932. // RemovedEdges returns all edge names that were removed in this mutation.
  23933. func (m *ServerMutation) RemovedEdges() []string {
  23934. edges := make([]string, 0, 1)
  23935. if m.removedwxs != nil {
  23936. edges = append(edges, server.EdgeWxs)
  23937. }
  23938. return edges
  23939. }
  23940. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23941. // the given name in this mutation.
  23942. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  23943. switch name {
  23944. case server.EdgeWxs:
  23945. ids := make([]ent.Value, 0, len(m.removedwxs))
  23946. for id := range m.removedwxs {
  23947. ids = append(ids, id)
  23948. }
  23949. return ids
  23950. }
  23951. return nil
  23952. }
  23953. // ClearedEdges returns all edge names that were cleared in this mutation.
  23954. func (m *ServerMutation) ClearedEdges() []string {
  23955. edges := make([]string, 0, 1)
  23956. if m.clearedwxs {
  23957. edges = append(edges, server.EdgeWxs)
  23958. }
  23959. return edges
  23960. }
  23961. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23962. // was cleared in this mutation.
  23963. func (m *ServerMutation) EdgeCleared(name string) bool {
  23964. switch name {
  23965. case server.EdgeWxs:
  23966. return m.clearedwxs
  23967. }
  23968. return false
  23969. }
  23970. // ClearEdge clears the value of the edge with the given name. It returns an error
  23971. // if that edge is not defined in the schema.
  23972. func (m *ServerMutation) ClearEdge(name string) error {
  23973. switch name {
  23974. }
  23975. return fmt.Errorf("unknown Server unique edge %s", name)
  23976. }
  23977. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23978. // It returns an error if the edge is not defined in the schema.
  23979. func (m *ServerMutation) ResetEdge(name string) error {
  23980. switch name {
  23981. case server.EdgeWxs:
  23982. m.ResetWxs()
  23983. return nil
  23984. }
  23985. return fmt.Errorf("unknown Server edge %s", name)
  23986. }
  23987. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  23988. type SopNodeMutation struct {
  23989. config
  23990. op Op
  23991. typ string
  23992. id *uint64
  23993. created_at *time.Time
  23994. updated_at *time.Time
  23995. status *uint8
  23996. addstatus *int8
  23997. deleted_at *time.Time
  23998. parent_id *uint64
  23999. addparent_id *int64
  24000. name *string
  24001. condition_type *int
  24002. addcondition_type *int
  24003. condition_list *[]string
  24004. appendcondition_list []string
  24005. no_reply_condition *uint64
  24006. addno_reply_condition *int64
  24007. no_reply_unit *string
  24008. action_message *[]custom_types.Action
  24009. appendaction_message []custom_types.Action
  24010. action_label_add *[]uint64
  24011. appendaction_label_add []uint64
  24012. action_label_del *[]uint64
  24013. appendaction_label_del []uint64
  24014. action_forward **custom_types.ActionForward
  24015. clearedFields map[string]struct{}
  24016. sop_stage *uint64
  24017. clearedsop_stage bool
  24018. node_messages map[uint64]struct{}
  24019. removednode_messages map[uint64]struct{}
  24020. clearednode_messages bool
  24021. done bool
  24022. oldValue func(context.Context) (*SopNode, error)
  24023. predicates []predicate.SopNode
  24024. }
  24025. var _ ent.Mutation = (*SopNodeMutation)(nil)
  24026. // sopnodeOption allows management of the mutation configuration using functional options.
  24027. type sopnodeOption func(*SopNodeMutation)
  24028. // newSopNodeMutation creates new mutation for the SopNode entity.
  24029. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  24030. m := &SopNodeMutation{
  24031. config: c,
  24032. op: op,
  24033. typ: TypeSopNode,
  24034. clearedFields: make(map[string]struct{}),
  24035. }
  24036. for _, opt := range opts {
  24037. opt(m)
  24038. }
  24039. return m
  24040. }
  24041. // withSopNodeID sets the ID field of the mutation.
  24042. func withSopNodeID(id uint64) sopnodeOption {
  24043. return func(m *SopNodeMutation) {
  24044. var (
  24045. err error
  24046. once sync.Once
  24047. value *SopNode
  24048. )
  24049. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  24050. once.Do(func() {
  24051. if m.done {
  24052. err = errors.New("querying old values post mutation is not allowed")
  24053. } else {
  24054. value, err = m.Client().SopNode.Get(ctx, id)
  24055. }
  24056. })
  24057. return value, err
  24058. }
  24059. m.id = &id
  24060. }
  24061. }
  24062. // withSopNode sets the old SopNode of the mutation.
  24063. func withSopNode(node *SopNode) sopnodeOption {
  24064. return func(m *SopNodeMutation) {
  24065. m.oldValue = func(context.Context) (*SopNode, error) {
  24066. return node, nil
  24067. }
  24068. m.id = &node.ID
  24069. }
  24070. }
  24071. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24072. // executed in a transaction (ent.Tx), a transactional client is returned.
  24073. func (m SopNodeMutation) Client() *Client {
  24074. client := &Client{config: m.config}
  24075. client.init()
  24076. return client
  24077. }
  24078. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24079. // it returns an error otherwise.
  24080. func (m SopNodeMutation) Tx() (*Tx, error) {
  24081. if _, ok := m.driver.(*txDriver); !ok {
  24082. return nil, errors.New("ent: mutation is not running in a transaction")
  24083. }
  24084. tx := &Tx{config: m.config}
  24085. tx.init()
  24086. return tx, nil
  24087. }
  24088. // SetID sets the value of the id field. Note that this
  24089. // operation is only accepted on creation of SopNode entities.
  24090. func (m *SopNodeMutation) SetID(id uint64) {
  24091. m.id = &id
  24092. }
  24093. // ID returns the ID value in the mutation. Note that the ID is only available
  24094. // if it was provided to the builder or after it was returned from the database.
  24095. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  24096. if m.id == nil {
  24097. return
  24098. }
  24099. return *m.id, true
  24100. }
  24101. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24102. // That means, if the mutation is applied within a transaction with an isolation level such
  24103. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24104. // or updated by the mutation.
  24105. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  24106. switch {
  24107. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24108. id, exists := m.ID()
  24109. if exists {
  24110. return []uint64{id}, nil
  24111. }
  24112. fallthrough
  24113. case m.op.Is(OpUpdate | OpDelete):
  24114. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  24115. default:
  24116. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24117. }
  24118. }
  24119. // SetCreatedAt sets the "created_at" field.
  24120. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  24121. m.created_at = &t
  24122. }
  24123. // CreatedAt returns the value of the "created_at" field in the mutation.
  24124. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  24125. v := m.created_at
  24126. if v == nil {
  24127. return
  24128. }
  24129. return *v, true
  24130. }
  24131. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  24132. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24134. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24135. if !m.op.Is(OpUpdateOne) {
  24136. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24137. }
  24138. if m.id == nil || m.oldValue == nil {
  24139. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24140. }
  24141. oldValue, err := m.oldValue(ctx)
  24142. if err != nil {
  24143. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24144. }
  24145. return oldValue.CreatedAt, nil
  24146. }
  24147. // ResetCreatedAt resets all changes to the "created_at" field.
  24148. func (m *SopNodeMutation) ResetCreatedAt() {
  24149. m.created_at = nil
  24150. }
  24151. // SetUpdatedAt sets the "updated_at" field.
  24152. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  24153. m.updated_at = &t
  24154. }
  24155. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24156. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  24157. v := m.updated_at
  24158. if v == nil {
  24159. return
  24160. }
  24161. return *v, true
  24162. }
  24163. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  24164. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24166. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24167. if !m.op.Is(OpUpdateOne) {
  24168. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24169. }
  24170. if m.id == nil || m.oldValue == nil {
  24171. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24172. }
  24173. oldValue, err := m.oldValue(ctx)
  24174. if err != nil {
  24175. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24176. }
  24177. return oldValue.UpdatedAt, nil
  24178. }
  24179. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24180. func (m *SopNodeMutation) ResetUpdatedAt() {
  24181. m.updated_at = nil
  24182. }
  24183. // SetStatus sets the "status" field.
  24184. func (m *SopNodeMutation) SetStatus(u uint8) {
  24185. m.status = &u
  24186. m.addstatus = nil
  24187. }
  24188. // Status returns the value of the "status" field in the mutation.
  24189. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  24190. v := m.status
  24191. if v == nil {
  24192. return
  24193. }
  24194. return *v, true
  24195. }
  24196. // OldStatus returns the old "status" field's value of the SopNode entity.
  24197. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24199. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24200. if !m.op.Is(OpUpdateOne) {
  24201. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24202. }
  24203. if m.id == nil || m.oldValue == nil {
  24204. return v, errors.New("OldStatus requires an ID field in the mutation")
  24205. }
  24206. oldValue, err := m.oldValue(ctx)
  24207. if err != nil {
  24208. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24209. }
  24210. return oldValue.Status, nil
  24211. }
  24212. // AddStatus adds u to the "status" field.
  24213. func (m *SopNodeMutation) AddStatus(u int8) {
  24214. if m.addstatus != nil {
  24215. *m.addstatus += u
  24216. } else {
  24217. m.addstatus = &u
  24218. }
  24219. }
  24220. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24221. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  24222. v := m.addstatus
  24223. if v == nil {
  24224. return
  24225. }
  24226. return *v, true
  24227. }
  24228. // ClearStatus clears the value of the "status" field.
  24229. func (m *SopNodeMutation) ClearStatus() {
  24230. m.status = nil
  24231. m.addstatus = nil
  24232. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  24233. }
  24234. // StatusCleared returns if the "status" field was cleared in this mutation.
  24235. func (m *SopNodeMutation) StatusCleared() bool {
  24236. _, ok := m.clearedFields[sopnode.FieldStatus]
  24237. return ok
  24238. }
  24239. // ResetStatus resets all changes to the "status" field.
  24240. func (m *SopNodeMutation) ResetStatus() {
  24241. m.status = nil
  24242. m.addstatus = nil
  24243. delete(m.clearedFields, sopnode.FieldStatus)
  24244. }
  24245. // SetDeletedAt sets the "deleted_at" field.
  24246. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  24247. m.deleted_at = &t
  24248. }
  24249. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24250. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  24251. v := m.deleted_at
  24252. if v == nil {
  24253. return
  24254. }
  24255. return *v, true
  24256. }
  24257. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  24258. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24260. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24261. if !m.op.Is(OpUpdateOne) {
  24262. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24263. }
  24264. if m.id == nil || m.oldValue == nil {
  24265. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24266. }
  24267. oldValue, err := m.oldValue(ctx)
  24268. if err != nil {
  24269. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24270. }
  24271. return oldValue.DeletedAt, nil
  24272. }
  24273. // ClearDeletedAt clears the value of the "deleted_at" field.
  24274. func (m *SopNodeMutation) ClearDeletedAt() {
  24275. m.deleted_at = nil
  24276. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  24277. }
  24278. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24279. func (m *SopNodeMutation) DeletedAtCleared() bool {
  24280. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  24281. return ok
  24282. }
  24283. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24284. func (m *SopNodeMutation) ResetDeletedAt() {
  24285. m.deleted_at = nil
  24286. delete(m.clearedFields, sopnode.FieldDeletedAt)
  24287. }
  24288. // SetStageID sets the "stage_id" field.
  24289. func (m *SopNodeMutation) SetStageID(u uint64) {
  24290. m.sop_stage = &u
  24291. }
  24292. // StageID returns the value of the "stage_id" field in the mutation.
  24293. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  24294. v := m.sop_stage
  24295. if v == nil {
  24296. return
  24297. }
  24298. return *v, true
  24299. }
  24300. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  24301. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24303. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  24304. if !m.op.Is(OpUpdateOne) {
  24305. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  24306. }
  24307. if m.id == nil || m.oldValue == nil {
  24308. return v, errors.New("OldStageID requires an ID field in the mutation")
  24309. }
  24310. oldValue, err := m.oldValue(ctx)
  24311. if err != nil {
  24312. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  24313. }
  24314. return oldValue.StageID, nil
  24315. }
  24316. // ResetStageID resets all changes to the "stage_id" field.
  24317. func (m *SopNodeMutation) ResetStageID() {
  24318. m.sop_stage = nil
  24319. }
  24320. // SetParentID sets the "parent_id" field.
  24321. func (m *SopNodeMutation) SetParentID(u uint64) {
  24322. m.parent_id = &u
  24323. m.addparent_id = nil
  24324. }
  24325. // ParentID returns the value of the "parent_id" field in the mutation.
  24326. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  24327. v := m.parent_id
  24328. if v == nil {
  24329. return
  24330. }
  24331. return *v, true
  24332. }
  24333. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  24334. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24336. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  24337. if !m.op.Is(OpUpdateOne) {
  24338. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  24339. }
  24340. if m.id == nil || m.oldValue == nil {
  24341. return v, errors.New("OldParentID requires an ID field in the mutation")
  24342. }
  24343. oldValue, err := m.oldValue(ctx)
  24344. if err != nil {
  24345. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  24346. }
  24347. return oldValue.ParentID, nil
  24348. }
  24349. // AddParentID adds u to the "parent_id" field.
  24350. func (m *SopNodeMutation) AddParentID(u int64) {
  24351. if m.addparent_id != nil {
  24352. *m.addparent_id += u
  24353. } else {
  24354. m.addparent_id = &u
  24355. }
  24356. }
  24357. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  24358. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  24359. v := m.addparent_id
  24360. if v == nil {
  24361. return
  24362. }
  24363. return *v, true
  24364. }
  24365. // ResetParentID resets all changes to the "parent_id" field.
  24366. func (m *SopNodeMutation) ResetParentID() {
  24367. m.parent_id = nil
  24368. m.addparent_id = nil
  24369. }
  24370. // SetName sets the "name" field.
  24371. func (m *SopNodeMutation) SetName(s string) {
  24372. m.name = &s
  24373. }
  24374. // Name returns the value of the "name" field in the mutation.
  24375. func (m *SopNodeMutation) Name() (r string, exists bool) {
  24376. v := m.name
  24377. if v == nil {
  24378. return
  24379. }
  24380. return *v, true
  24381. }
  24382. // OldName returns the old "name" field's value of the SopNode entity.
  24383. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24385. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  24386. if !m.op.Is(OpUpdateOne) {
  24387. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24388. }
  24389. if m.id == nil || m.oldValue == nil {
  24390. return v, errors.New("OldName requires an ID field in the mutation")
  24391. }
  24392. oldValue, err := m.oldValue(ctx)
  24393. if err != nil {
  24394. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24395. }
  24396. return oldValue.Name, nil
  24397. }
  24398. // ResetName resets all changes to the "name" field.
  24399. func (m *SopNodeMutation) ResetName() {
  24400. m.name = nil
  24401. }
  24402. // SetConditionType sets the "condition_type" field.
  24403. func (m *SopNodeMutation) SetConditionType(i int) {
  24404. m.condition_type = &i
  24405. m.addcondition_type = nil
  24406. }
  24407. // ConditionType returns the value of the "condition_type" field in the mutation.
  24408. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  24409. v := m.condition_type
  24410. if v == nil {
  24411. return
  24412. }
  24413. return *v, true
  24414. }
  24415. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  24416. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24418. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  24419. if !m.op.Is(OpUpdateOne) {
  24420. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  24421. }
  24422. if m.id == nil || m.oldValue == nil {
  24423. return v, errors.New("OldConditionType requires an ID field in the mutation")
  24424. }
  24425. oldValue, err := m.oldValue(ctx)
  24426. if err != nil {
  24427. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  24428. }
  24429. return oldValue.ConditionType, nil
  24430. }
  24431. // AddConditionType adds i to the "condition_type" field.
  24432. func (m *SopNodeMutation) AddConditionType(i int) {
  24433. if m.addcondition_type != nil {
  24434. *m.addcondition_type += i
  24435. } else {
  24436. m.addcondition_type = &i
  24437. }
  24438. }
  24439. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  24440. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  24441. v := m.addcondition_type
  24442. if v == nil {
  24443. return
  24444. }
  24445. return *v, true
  24446. }
  24447. // ResetConditionType resets all changes to the "condition_type" field.
  24448. func (m *SopNodeMutation) ResetConditionType() {
  24449. m.condition_type = nil
  24450. m.addcondition_type = nil
  24451. }
  24452. // SetConditionList sets the "condition_list" field.
  24453. func (m *SopNodeMutation) SetConditionList(s []string) {
  24454. m.condition_list = &s
  24455. m.appendcondition_list = nil
  24456. }
  24457. // ConditionList returns the value of the "condition_list" field in the mutation.
  24458. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  24459. v := m.condition_list
  24460. if v == nil {
  24461. return
  24462. }
  24463. return *v, true
  24464. }
  24465. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  24466. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24468. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  24469. if !m.op.Is(OpUpdateOne) {
  24470. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  24471. }
  24472. if m.id == nil || m.oldValue == nil {
  24473. return v, errors.New("OldConditionList requires an ID field in the mutation")
  24474. }
  24475. oldValue, err := m.oldValue(ctx)
  24476. if err != nil {
  24477. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  24478. }
  24479. return oldValue.ConditionList, nil
  24480. }
  24481. // AppendConditionList adds s to the "condition_list" field.
  24482. func (m *SopNodeMutation) AppendConditionList(s []string) {
  24483. m.appendcondition_list = append(m.appendcondition_list, s...)
  24484. }
  24485. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  24486. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  24487. if len(m.appendcondition_list) == 0 {
  24488. return nil, false
  24489. }
  24490. return m.appendcondition_list, true
  24491. }
  24492. // ClearConditionList clears the value of the "condition_list" field.
  24493. func (m *SopNodeMutation) ClearConditionList() {
  24494. m.condition_list = nil
  24495. m.appendcondition_list = nil
  24496. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  24497. }
  24498. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  24499. func (m *SopNodeMutation) ConditionListCleared() bool {
  24500. _, ok := m.clearedFields[sopnode.FieldConditionList]
  24501. return ok
  24502. }
  24503. // ResetConditionList resets all changes to the "condition_list" field.
  24504. func (m *SopNodeMutation) ResetConditionList() {
  24505. m.condition_list = nil
  24506. m.appendcondition_list = nil
  24507. delete(m.clearedFields, sopnode.FieldConditionList)
  24508. }
  24509. // SetNoReplyCondition sets the "no_reply_condition" field.
  24510. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  24511. m.no_reply_condition = &u
  24512. m.addno_reply_condition = nil
  24513. }
  24514. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  24515. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  24516. v := m.no_reply_condition
  24517. if v == nil {
  24518. return
  24519. }
  24520. return *v, true
  24521. }
  24522. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  24523. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24525. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  24526. if !m.op.Is(OpUpdateOne) {
  24527. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  24528. }
  24529. if m.id == nil || m.oldValue == nil {
  24530. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  24531. }
  24532. oldValue, err := m.oldValue(ctx)
  24533. if err != nil {
  24534. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  24535. }
  24536. return oldValue.NoReplyCondition, nil
  24537. }
  24538. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  24539. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  24540. if m.addno_reply_condition != nil {
  24541. *m.addno_reply_condition += u
  24542. } else {
  24543. m.addno_reply_condition = &u
  24544. }
  24545. }
  24546. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  24547. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  24548. v := m.addno_reply_condition
  24549. if v == nil {
  24550. return
  24551. }
  24552. return *v, true
  24553. }
  24554. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  24555. func (m *SopNodeMutation) ResetNoReplyCondition() {
  24556. m.no_reply_condition = nil
  24557. m.addno_reply_condition = nil
  24558. }
  24559. // SetNoReplyUnit sets the "no_reply_unit" field.
  24560. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  24561. m.no_reply_unit = &s
  24562. }
  24563. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  24564. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  24565. v := m.no_reply_unit
  24566. if v == nil {
  24567. return
  24568. }
  24569. return *v, true
  24570. }
  24571. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  24572. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24574. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  24575. if !m.op.Is(OpUpdateOne) {
  24576. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  24577. }
  24578. if m.id == nil || m.oldValue == nil {
  24579. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  24580. }
  24581. oldValue, err := m.oldValue(ctx)
  24582. if err != nil {
  24583. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  24584. }
  24585. return oldValue.NoReplyUnit, nil
  24586. }
  24587. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  24588. func (m *SopNodeMutation) ResetNoReplyUnit() {
  24589. m.no_reply_unit = nil
  24590. }
  24591. // SetActionMessage sets the "action_message" field.
  24592. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  24593. m.action_message = &ct
  24594. m.appendaction_message = nil
  24595. }
  24596. // ActionMessage returns the value of the "action_message" field in the mutation.
  24597. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  24598. v := m.action_message
  24599. if v == nil {
  24600. return
  24601. }
  24602. return *v, true
  24603. }
  24604. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  24605. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24607. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  24608. if !m.op.Is(OpUpdateOne) {
  24609. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  24610. }
  24611. if m.id == nil || m.oldValue == nil {
  24612. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  24613. }
  24614. oldValue, err := m.oldValue(ctx)
  24615. if err != nil {
  24616. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  24617. }
  24618. return oldValue.ActionMessage, nil
  24619. }
  24620. // AppendActionMessage adds ct to the "action_message" field.
  24621. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  24622. m.appendaction_message = append(m.appendaction_message, ct...)
  24623. }
  24624. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  24625. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  24626. if len(m.appendaction_message) == 0 {
  24627. return nil, false
  24628. }
  24629. return m.appendaction_message, true
  24630. }
  24631. // ClearActionMessage clears the value of the "action_message" field.
  24632. func (m *SopNodeMutation) ClearActionMessage() {
  24633. m.action_message = nil
  24634. m.appendaction_message = nil
  24635. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  24636. }
  24637. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  24638. func (m *SopNodeMutation) ActionMessageCleared() bool {
  24639. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  24640. return ok
  24641. }
  24642. // ResetActionMessage resets all changes to the "action_message" field.
  24643. func (m *SopNodeMutation) ResetActionMessage() {
  24644. m.action_message = nil
  24645. m.appendaction_message = nil
  24646. delete(m.clearedFields, sopnode.FieldActionMessage)
  24647. }
  24648. // SetActionLabelAdd sets the "action_label_add" field.
  24649. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  24650. m.action_label_add = &u
  24651. m.appendaction_label_add = nil
  24652. }
  24653. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  24654. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  24655. v := m.action_label_add
  24656. if v == nil {
  24657. return
  24658. }
  24659. return *v, true
  24660. }
  24661. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  24662. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24664. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  24665. if !m.op.Is(OpUpdateOne) {
  24666. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  24667. }
  24668. if m.id == nil || m.oldValue == nil {
  24669. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  24670. }
  24671. oldValue, err := m.oldValue(ctx)
  24672. if err != nil {
  24673. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  24674. }
  24675. return oldValue.ActionLabelAdd, nil
  24676. }
  24677. // AppendActionLabelAdd adds u to the "action_label_add" field.
  24678. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  24679. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  24680. }
  24681. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  24682. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  24683. if len(m.appendaction_label_add) == 0 {
  24684. return nil, false
  24685. }
  24686. return m.appendaction_label_add, true
  24687. }
  24688. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  24689. func (m *SopNodeMutation) ClearActionLabelAdd() {
  24690. m.action_label_add = nil
  24691. m.appendaction_label_add = nil
  24692. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  24693. }
  24694. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  24695. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  24696. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  24697. return ok
  24698. }
  24699. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  24700. func (m *SopNodeMutation) ResetActionLabelAdd() {
  24701. m.action_label_add = nil
  24702. m.appendaction_label_add = nil
  24703. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  24704. }
  24705. // SetActionLabelDel sets the "action_label_del" field.
  24706. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  24707. m.action_label_del = &u
  24708. m.appendaction_label_del = nil
  24709. }
  24710. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  24711. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  24712. v := m.action_label_del
  24713. if v == nil {
  24714. return
  24715. }
  24716. return *v, true
  24717. }
  24718. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  24719. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24721. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  24722. if !m.op.Is(OpUpdateOne) {
  24723. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  24724. }
  24725. if m.id == nil || m.oldValue == nil {
  24726. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  24727. }
  24728. oldValue, err := m.oldValue(ctx)
  24729. if err != nil {
  24730. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  24731. }
  24732. return oldValue.ActionLabelDel, nil
  24733. }
  24734. // AppendActionLabelDel adds u to the "action_label_del" field.
  24735. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  24736. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  24737. }
  24738. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  24739. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  24740. if len(m.appendaction_label_del) == 0 {
  24741. return nil, false
  24742. }
  24743. return m.appendaction_label_del, true
  24744. }
  24745. // ClearActionLabelDel clears the value of the "action_label_del" field.
  24746. func (m *SopNodeMutation) ClearActionLabelDel() {
  24747. m.action_label_del = nil
  24748. m.appendaction_label_del = nil
  24749. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  24750. }
  24751. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  24752. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  24753. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  24754. return ok
  24755. }
  24756. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  24757. func (m *SopNodeMutation) ResetActionLabelDel() {
  24758. m.action_label_del = nil
  24759. m.appendaction_label_del = nil
  24760. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  24761. }
  24762. // SetActionForward sets the "action_forward" field.
  24763. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  24764. m.action_forward = &ctf
  24765. }
  24766. // ActionForward returns the value of the "action_forward" field in the mutation.
  24767. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  24768. v := m.action_forward
  24769. if v == nil {
  24770. return
  24771. }
  24772. return *v, true
  24773. }
  24774. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  24775. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24777. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  24778. if !m.op.Is(OpUpdateOne) {
  24779. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  24780. }
  24781. if m.id == nil || m.oldValue == nil {
  24782. return v, errors.New("OldActionForward requires an ID field in the mutation")
  24783. }
  24784. oldValue, err := m.oldValue(ctx)
  24785. if err != nil {
  24786. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  24787. }
  24788. return oldValue.ActionForward, nil
  24789. }
  24790. // ClearActionForward clears the value of the "action_forward" field.
  24791. func (m *SopNodeMutation) ClearActionForward() {
  24792. m.action_forward = nil
  24793. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  24794. }
  24795. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  24796. func (m *SopNodeMutation) ActionForwardCleared() bool {
  24797. _, ok := m.clearedFields[sopnode.FieldActionForward]
  24798. return ok
  24799. }
  24800. // ResetActionForward resets all changes to the "action_forward" field.
  24801. func (m *SopNodeMutation) ResetActionForward() {
  24802. m.action_forward = nil
  24803. delete(m.clearedFields, sopnode.FieldActionForward)
  24804. }
  24805. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  24806. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  24807. m.sop_stage = &id
  24808. }
  24809. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  24810. func (m *SopNodeMutation) ClearSopStage() {
  24811. m.clearedsop_stage = true
  24812. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  24813. }
  24814. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  24815. func (m *SopNodeMutation) SopStageCleared() bool {
  24816. return m.clearedsop_stage
  24817. }
  24818. // SopStageID returns the "sop_stage" edge ID in the mutation.
  24819. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  24820. if m.sop_stage != nil {
  24821. return *m.sop_stage, true
  24822. }
  24823. return
  24824. }
  24825. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  24826. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24827. // SopStageID instead. It exists only for internal usage by the builders.
  24828. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  24829. if id := m.sop_stage; id != nil {
  24830. ids = append(ids, *id)
  24831. }
  24832. return
  24833. }
  24834. // ResetSopStage resets all changes to the "sop_stage" edge.
  24835. func (m *SopNodeMutation) ResetSopStage() {
  24836. m.sop_stage = nil
  24837. m.clearedsop_stage = false
  24838. }
  24839. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  24840. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  24841. if m.node_messages == nil {
  24842. m.node_messages = make(map[uint64]struct{})
  24843. }
  24844. for i := range ids {
  24845. m.node_messages[ids[i]] = struct{}{}
  24846. }
  24847. }
  24848. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  24849. func (m *SopNodeMutation) ClearNodeMessages() {
  24850. m.clearednode_messages = true
  24851. }
  24852. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  24853. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  24854. return m.clearednode_messages
  24855. }
  24856. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  24857. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  24858. if m.removednode_messages == nil {
  24859. m.removednode_messages = make(map[uint64]struct{})
  24860. }
  24861. for i := range ids {
  24862. delete(m.node_messages, ids[i])
  24863. m.removednode_messages[ids[i]] = struct{}{}
  24864. }
  24865. }
  24866. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  24867. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  24868. for id := range m.removednode_messages {
  24869. ids = append(ids, id)
  24870. }
  24871. return
  24872. }
  24873. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  24874. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  24875. for id := range m.node_messages {
  24876. ids = append(ids, id)
  24877. }
  24878. return
  24879. }
  24880. // ResetNodeMessages resets all changes to the "node_messages" edge.
  24881. func (m *SopNodeMutation) ResetNodeMessages() {
  24882. m.node_messages = nil
  24883. m.clearednode_messages = false
  24884. m.removednode_messages = nil
  24885. }
  24886. // Where appends a list predicates to the SopNodeMutation builder.
  24887. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  24888. m.predicates = append(m.predicates, ps...)
  24889. }
  24890. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  24891. // users can use type-assertion to append predicates that do not depend on any generated package.
  24892. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  24893. p := make([]predicate.SopNode, len(ps))
  24894. for i := range ps {
  24895. p[i] = ps[i]
  24896. }
  24897. m.Where(p...)
  24898. }
  24899. // Op returns the operation name.
  24900. func (m *SopNodeMutation) Op() Op {
  24901. return m.op
  24902. }
  24903. // SetOp allows setting the mutation operation.
  24904. func (m *SopNodeMutation) SetOp(op Op) {
  24905. m.op = op
  24906. }
  24907. // Type returns the node type of this mutation (SopNode).
  24908. func (m *SopNodeMutation) Type() string {
  24909. return m.typ
  24910. }
  24911. // Fields returns all fields that were changed during this mutation. Note that in
  24912. // order to get all numeric fields that were incremented/decremented, call
  24913. // AddedFields().
  24914. func (m *SopNodeMutation) Fields() []string {
  24915. fields := make([]string, 0, 15)
  24916. if m.created_at != nil {
  24917. fields = append(fields, sopnode.FieldCreatedAt)
  24918. }
  24919. if m.updated_at != nil {
  24920. fields = append(fields, sopnode.FieldUpdatedAt)
  24921. }
  24922. if m.status != nil {
  24923. fields = append(fields, sopnode.FieldStatus)
  24924. }
  24925. if m.deleted_at != nil {
  24926. fields = append(fields, sopnode.FieldDeletedAt)
  24927. }
  24928. if m.sop_stage != nil {
  24929. fields = append(fields, sopnode.FieldStageID)
  24930. }
  24931. if m.parent_id != nil {
  24932. fields = append(fields, sopnode.FieldParentID)
  24933. }
  24934. if m.name != nil {
  24935. fields = append(fields, sopnode.FieldName)
  24936. }
  24937. if m.condition_type != nil {
  24938. fields = append(fields, sopnode.FieldConditionType)
  24939. }
  24940. if m.condition_list != nil {
  24941. fields = append(fields, sopnode.FieldConditionList)
  24942. }
  24943. if m.no_reply_condition != nil {
  24944. fields = append(fields, sopnode.FieldNoReplyCondition)
  24945. }
  24946. if m.no_reply_unit != nil {
  24947. fields = append(fields, sopnode.FieldNoReplyUnit)
  24948. }
  24949. if m.action_message != nil {
  24950. fields = append(fields, sopnode.FieldActionMessage)
  24951. }
  24952. if m.action_label_add != nil {
  24953. fields = append(fields, sopnode.FieldActionLabelAdd)
  24954. }
  24955. if m.action_label_del != nil {
  24956. fields = append(fields, sopnode.FieldActionLabelDel)
  24957. }
  24958. if m.action_forward != nil {
  24959. fields = append(fields, sopnode.FieldActionForward)
  24960. }
  24961. return fields
  24962. }
  24963. // Field returns the value of a field with the given name. The second boolean
  24964. // return value indicates that this field was not set, or was not defined in the
  24965. // schema.
  24966. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  24967. switch name {
  24968. case sopnode.FieldCreatedAt:
  24969. return m.CreatedAt()
  24970. case sopnode.FieldUpdatedAt:
  24971. return m.UpdatedAt()
  24972. case sopnode.FieldStatus:
  24973. return m.Status()
  24974. case sopnode.FieldDeletedAt:
  24975. return m.DeletedAt()
  24976. case sopnode.FieldStageID:
  24977. return m.StageID()
  24978. case sopnode.FieldParentID:
  24979. return m.ParentID()
  24980. case sopnode.FieldName:
  24981. return m.Name()
  24982. case sopnode.FieldConditionType:
  24983. return m.ConditionType()
  24984. case sopnode.FieldConditionList:
  24985. return m.ConditionList()
  24986. case sopnode.FieldNoReplyCondition:
  24987. return m.NoReplyCondition()
  24988. case sopnode.FieldNoReplyUnit:
  24989. return m.NoReplyUnit()
  24990. case sopnode.FieldActionMessage:
  24991. return m.ActionMessage()
  24992. case sopnode.FieldActionLabelAdd:
  24993. return m.ActionLabelAdd()
  24994. case sopnode.FieldActionLabelDel:
  24995. return m.ActionLabelDel()
  24996. case sopnode.FieldActionForward:
  24997. return m.ActionForward()
  24998. }
  24999. return nil, false
  25000. }
  25001. // OldField returns the old value of the field from the database. An error is
  25002. // returned if the mutation operation is not UpdateOne, or the query to the
  25003. // database failed.
  25004. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25005. switch name {
  25006. case sopnode.FieldCreatedAt:
  25007. return m.OldCreatedAt(ctx)
  25008. case sopnode.FieldUpdatedAt:
  25009. return m.OldUpdatedAt(ctx)
  25010. case sopnode.FieldStatus:
  25011. return m.OldStatus(ctx)
  25012. case sopnode.FieldDeletedAt:
  25013. return m.OldDeletedAt(ctx)
  25014. case sopnode.FieldStageID:
  25015. return m.OldStageID(ctx)
  25016. case sopnode.FieldParentID:
  25017. return m.OldParentID(ctx)
  25018. case sopnode.FieldName:
  25019. return m.OldName(ctx)
  25020. case sopnode.FieldConditionType:
  25021. return m.OldConditionType(ctx)
  25022. case sopnode.FieldConditionList:
  25023. return m.OldConditionList(ctx)
  25024. case sopnode.FieldNoReplyCondition:
  25025. return m.OldNoReplyCondition(ctx)
  25026. case sopnode.FieldNoReplyUnit:
  25027. return m.OldNoReplyUnit(ctx)
  25028. case sopnode.FieldActionMessage:
  25029. return m.OldActionMessage(ctx)
  25030. case sopnode.FieldActionLabelAdd:
  25031. return m.OldActionLabelAdd(ctx)
  25032. case sopnode.FieldActionLabelDel:
  25033. return m.OldActionLabelDel(ctx)
  25034. case sopnode.FieldActionForward:
  25035. return m.OldActionForward(ctx)
  25036. }
  25037. return nil, fmt.Errorf("unknown SopNode field %s", name)
  25038. }
  25039. // SetField sets the value of a field with the given name. It returns an error if
  25040. // the field is not defined in the schema, or if the type mismatched the field
  25041. // type.
  25042. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  25043. switch name {
  25044. case sopnode.FieldCreatedAt:
  25045. v, ok := value.(time.Time)
  25046. if !ok {
  25047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25048. }
  25049. m.SetCreatedAt(v)
  25050. return nil
  25051. case sopnode.FieldUpdatedAt:
  25052. v, ok := value.(time.Time)
  25053. if !ok {
  25054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25055. }
  25056. m.SetUpdatedAt(v)
  25057. return nil
  25058. case sopnode.FieldStatus:
  25059. v, ok := value.(uint8)
  25060. if !ok {
  25061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25062. }
  25063. m.SetStatus(v)
  25064. return nil
  25065. case sopnode.FieldDeletedAt:
  25066. v, ok := value.(time.Time)
  25067. if !ok {
  25068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25069. }
  25070. m.SetDeletedAt(v)
  25071. return nil
  25072. case sopnode.FieldStageID:
  25073. v, ok := value.(uint64)
  25074. if !ok {
  25075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25076. }
  25077. m.SetStageID(v)
  25078. return nil
  25079. case sopnode.FieldParentID:
  25080. v, ok := value.(uint64)
  25081. if !ok {
  25082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25083. }
  25084. m.SetParentID(v)
  25085. return nil
  25086. case sopnode.FieldName:
  25087. v, ok := value.(string)
  25088. if !ok {
  25089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25090. }
  25091. m.SetName(v)
  25092. return nil
  25093. case sopnode.FieldConditionType:
  25094. v, ok := value.(int)
  25095. if !ok {
  25096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25097. }
  25098. m.SetConditionType(v)
  25099. return nil
  25100. case sopnode.FieldConditionList:
  25101. v, ok := value.([]string)
  25102. if !ok {
  25103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25104. }
  25105. m.SetConditionList(v)
  25106. return nil
  25107. case sopnode.FieldNoReplyCondition:
  25108. v, ok := value.(uint64)
  25109. if !ok {
  25110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25111. }
  25112. m.SetNoReplyCondition(v)
  25113. return nil
  25114. case sopnode.FieldNoReplyUnit:
  25115. v, ok := value.(string)
  25116. if !ok {
  25117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25118. }
  25119. m.SetNoReplyUnit(v)
  25120. return nil
  25121. case sopnode.FieldActionMessage:
  25122. v, ok := value.([]custom_types.Action)
  25123. if !ok {
  25124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25125. }
  25126. m.SetActionMessage(v)
  25127. return nil
  25128. case sopnode.FieldActionLabelAdd:
  25129. v, ok := value.([]uint64)
  25130. if !ok {
  25131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25132. }
  25133. m.SetActionLabelAdd(v)
  25134. return nil
  25135. case sopnode.FieldActionLabelDel:
  25136. v, ok := value.([]uint64)
  25137. if !ok {
  25138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25139. }
  25140. m.SetActionLabelDel(v)
  25141. return nil
  25142. case sopnode.FieldActionForward:
  25143. v, ok := value.(*custom_types.ActionForward)
  25144. if !ok {
  25145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25146. }
  25147. m.SetActionForward(v)
  25148. return nil
  25149. }
  25150. return fmt.Errorf("unknown SopNode field %s", name)
  25151. }
  25152. // AddedFields returns all numeric fields that were incremented/decremented during
  25153. // this mutation.
  25154. func (m *SopNodeMutation) AddedFields() []string {
  25155. var fields []string
  25156. if m.addstatus != nil {
  25157. fields = append(fields, sopnode.FieldStatus)
  25158. }
  25159. if m.addparent_id != nil {
  25160. fields = append(fields, sopnode.FieldParentID)
  25161. }
  25162. if m.addcondition_type != nil {
  25163. fields = append(fields, sopnode.FieldConditionType)
  25164. }
  25165. if m.addno_reply_condition != nil {
  25166. fields = append(fields, sopnode.FieldNoReplyCondition)
  25167. }
  25168. return fields
  25169. }
  25170. // AddedField returns the numeric value that was incremented/decremented on a field
  25171. // with the given name. The second boolean return value indicates that this field
  25172. // was not set, or was not defined in the schema.
  25173. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  25174. switch name {
  25175. case sopnode.FieldStatus:
  25176. return m.AddedStatus()
  25177. case sopnode.FieldParentID:
  25178. return m.AddedParentID()
  25179. case sopnode.FieldConditionType:
  25180. return m.AddedConditionType()
  25181. case sopnode.FieldNoReplyCondition:
  25182. return m.AddedNoReplyCondition()
  25183. }
  25184. return nil, false
  25185. }
  25186. // AddField adds the value to the field with the given name. It returns an error if
  25187. // the field is not defined in the schema, or if the type mismatched the field
  25188. // type.
  25189. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  25190. switch name {
  25191. case sopnode.FieldStatus:
  25192. v, ok := value.(int8)
  25193. if !ok {
  25194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25195. }
  25196. m.AddStatus(v)
  25197. return nil
  25198. case sopnode.FieldParentID:
  25199. v, ok := value.(int64)
  25200. if !ok {
  25201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25202. }
  25203. m.AddParentID(v)
  25204. return nil
  25205. case sopnode.FieldConditionType:
  25206. v, ok := value.(int)
  25207. if !ok {
  25208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25209. }
  25210. m.AddConditionType(v)
  25211. return nil
  25212. case sopnode.FieldNoReplyCondition:
  25213. v, ok := value.(int64)
  25214. if !ok {
  25215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25216. }
  25217. m.AddNoReplyCondition(v)
  25218. return nil
  25219. }
  25220. return fmt.Errorf("unknown SopNode numeric field %s", name)
  25221. }
  25222. // ClearedFields returns all nullable fields that were cleared during this
  25223. // mutation.
  25224. func (m *SopNodeMutation) ClearedFields() []string {
  25225. var fields []string
  25226. if m.FieldCleared(sopnode.FieldStatus) {
  25227. fields = append(fields, sopnode.FieldStatus)
  25228. }
  25229. if m.FieldCleared(sopnode.FieldDeletedAt) {
  25230. fields = append(fields, sopnode.FieldDeletedAt)
  25231. }
  25232. if m.FieldCleared(sopnode.FieldConditionList) {
  25233. fields = append(fields, sopnode.FieldConditionList)
  25234. }
  25235. if m.FieldCleared(sopnode.FieldActionMessage) {
  25236. fields = append(fields, sopnode.FieldActionMessage)
  25237. }
  25238. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  25239. fields = append(fields, sopnode.FieldActionLabelAdd)
  25240. }
  25241. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  25242. fields = append(fields, sopnode.FieldActionLabelDel)
  25243. }
  25244. if m.FieldCleared(sopnode.FieldActionForward) {
  25245. fields = append(fields, sopnode.FieldActionForward)
  25246. }
  25247. return fields
  25248. }
  25249. // FieldCleared returns a boolean indicating if a field with the given name was
  25250. // cleared in this mutation.
  25251. func (m *SopNodeMutation) FieldCleared(name string) bool {
  25252. _, ok := m.clearedFields[name]
  25253. return ok
  25254. }
  25255. // ClearField clears the value of the field with the given name. It returns an
  25256. // error if the field is not defined in the schema.
  25257. func (m *SopNodeMutation) ClearField(name string) error {
  25258. switch name {
  25259. case sopnode.FieldStatus:
  25260. m.ClearStatus()
  25261. return nil
  25262. case sopnode.FieldDeletedAt:
  25263. m.ClearDeletedAt()
  25264. return nil
  25265. case sopnode.FieldConditionList:
  25266. m.ClearConditionList()
  25267. return nil
  25268. case sopnode.FieldActionMessage:
  25269. m.ClearActionMessage()
  25270. return nil
  25271. case sopnode.FieldActionLabelAdd:
  25272. m.ClearActionLabelAdd()
  25273. return nil
  25274. case sopnode.FieldActionLabelDel:
  25275. m.ClearActionLabelDel()
  25276. return nil
  25277. case sopnode.FieldActionForward:
  25278. m.ClearActionForward()
  25279. return nil
  25280. }
  25281. return fmt.Errorf("unknown SopNode nullable field %s", name)
  25282. }
  25283. // ResetField resets all changes in the mutation for the field with the given name.
  25284. // It returns an error if the field is not defined in the schema.
  25285. func (m *SopNodeMutation) ResetField(name string) error {
  25286. switch name {
  25287. case sopnode.FieldCreatedAt:
  25288. m.ResetCreatedAt()
  25289. return nil
  25290. case sopnode.FieldUpdatedAt:
  25291. m.ResetUpdatedAt()
  25292. return nil
  25293. case sopnode.FieldStatus:
  25294. m.ResetStatus()
  25295. return nil
  25296. case sopnode.FieldDeletedAt:
  25297. m.ResetDeletedAt()
  25298. return nil
  25299. case sopnode.FieldStageID:
  25300. m.ResetStageID()
  25301. return nil
  25302. case sopnode.FieldParentID:
  25303. m.ResetParentID()
  25304. return nil
  25305. case sopnode.FieldName:
  25306. m.ResetName()
  25307. return nil
  25308. case sopnode.FieldConditionType:
  25309. m.ResetConditionType()
  25310. return nil
  25311. case sopnode.FieldConditionList:
  25312. m.ResetConditionList()
  25313. return nil
  25314. case sopnode.FieldNoReplyCondition:
  25315. m.ResetNoReplyCondition()
  25316. return nil
  25317. case sopnode.FieldNoReplyUnit:
  25318. m.ResetNoReplyUnit()
  25319. return nil
  25320. case sopnode.FieldActionMessage:
  25321. m.ResetActionMessage()
  25322. return nil
  25323. case sopnode.FieldActionLabelAdd:
  25324. m.ResetActionLabelAdd()
  25325. return nil
  25326. case sopnode.FieldActionLabelDel:
  25327. m.ResetActionLabelDel()
  25328. return nil
  25329. case sopnode.FieldActionForward:
  25330. m.ResetActionForward()
  25331. return nil
  25332. }
  25333. return fmt.Errorf("unknown SopNode field %s", name)
  25334. }
  25335. // AddedEdges returns all edge names that were set/added in this mutation.
  25336. func (m *SopNodeMutation) AddedEdges() []string {
  25337. edges := make([]string, 0, 2)
  25338. if m.sop_stage != nil {
  25339. edges = append(edges, sopnode.EdgeSopStage)
  25340. }
  25341. if m.node_messages != nil {
  25342. edges = append(edges, sopnode.EdgeNodeMessages)
  25343. }
  25344. return edges
  25345. }
  25346. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25347. // name in this mutation.
  25348. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  25349. switch name {
  25350. case sopnode.EdgeSopStage:
  25351. if id := m.sop_stage; id != nil {
  25352. return []ent.Value{*id}
  25353. }
  25354. case sopnode.EdgeNodeMessages:
  25355. ids := make([]ent.Value, 0, len(m.node_messages))
  25356. for id := range m.node_messages {
  25357. ids = append(ids, id)
  25358. }
  25359. return ids
  25360. }
  25361. return nil
  25362. }
  25363. // RemovedEdges returns all edge names that were removed in this mutation.
  25364. func (m *SopNodeMutation) RemovedEdges() []string {
  25365. edges := make([]string, 0, 2)
  25366. if m.removednode_messages != nil {
  25367. edges = append(edges, sopnode.EdgeNodeMessages)
  25368. }
  25369. return edges
  25370. }
  25371. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25372. // the given name in this mutation.
  25373. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  25374. switch name {
  25375. case sopnode.EdgeNodeMessages:
  25376. ids := make([]ent.Value, 0, len(m.removednode_messages))
  25377. for id := range m.removednode_messages {
  25378. ids = append(ids, id)
  25379. }
  25380. return ids
  25381. }
  25382. return nil
  25383. }
  25384. // ClearedEdges returns all edge names that were cleared in this mutation.
  25385. func (m *SopNodeMutation) ClearedEdges() []string {
  25386. edges := make([]string, 0, 2)
  25387. if m.clearedsop_stage {
  25388. edges = append(edges, sopnode.EdgeSopStage)
  25389. }
  25390. if m.clearednode_messages {
  25391. edges = append(edges, sopnode.EdgeNodeMessages)
  25392. }
  25393. return edges
  25394. }
  25395. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25396. // was cleared in this mutation.
  25397. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  25398. switch name {
  25399. case sopnode.EdgeSopStage:
  25400. return m.clearedsop_stage
  25401. case sopnode.EdgeNodeMessages:
  25402. return m.clearednode_messages
  25403. }
  25404. return false
  25405. }
  25406. // ClearEdge clears the value of the edge with the given name. It returns an error
  25407. // if that edge is not defined in the schema.
  25408. func (m *SopNodeMutation) ClearEdge(name string) error {
  25409. switch name {
  25410. case sopnode.EdgeSopStage:
  25411. m.ClearSopStage()
  25412. return nil
  25413. }
  25414. return fmt.Errorf("unknown SopNode unique edge %s", name)
  25415. }
  25416. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25417. // It returns an error if the edge is not defined in the schema.
  25418. func (m *SopNodeMutation) ResetEdge(name string) error {
  25419. switch name {
  25420. case sopnode.EdgeSopStage:
  25421. m.ResetSopStage()
  25422. return nil
  25423. case sopnode.EdgeNodeMessages:
  25424. m.ResetNodeMessages()
  25425. return nil
  25426. }
  25427. return fmt.Errorf("unknown SopNode edge %s", name)
  25428. }
  25429. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  25430. type SopStageMutation struct {
  25431. config
  25432. op Op
  25433. typ string
  25434. id *uint64
  25435. created_at *time.Time
  25436. updated_at *time.Time
  25437. status *uint8
  25438. addstatus *int8
  25439. deleted_at *time.Time
  25440. name *string
  25441. condition_type *int
  25442. addcondition_type *int
  25443. condition_operator *int
  25444. addcondition_operator *int
  25445. condition_list *[]custom_types.Condition
  25446. appendcondition_list []custom_types.Condition
  25447. action_message *[]custom_types.Action
  25448. appendaction_message []custom_types.Action
  25449. action_label_add *[]uint64
  25450. appendaction_label_add []uint64
  25451. action_label_del *[]uint64
  25452. appendaction_label_del []uint64
  25453. action_forward **custom_types.ActionForward
  25454. index_sort *int
  25455. addindex_sort *int
  25456. clearedFields map[string]struct{}
  25457. sop_task *uint64
  25458. clearedsop_task bool
  25459. stage_nodes map[uint64]struct{}
  25460. removedstage_nodes map[uint64]struct{}
  25461. clearedstage_nodes bool
  25462. stage_messages map[uint64]struct{}
  25463. removedstage_messages map[uint64]struct{}
  25464. clearedstage_messages bool
  25465. done bool
  25466. oldValue func(context.Context) (*SopStage, error)
  25467. predicates []predicate.SopStage
  25468. }
  25469. var _ ent.Mutation = (*SopStageMutation)(nil)
  25470. // sopstageOption allows management of the mutation configuration using functional options.
  25471. type sopstageOption func(*SopStageMutation)
  25472. // newSopStageMutation creates new mutation for the SopStage entity.
  25473. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  25474. m := &SopStageMutation{
  25475. config: c,
  25476. op: op,
  25477. typ: TypeSopStage,
  25478. clearedFields: make(map[string]struct{}),
  25479. }
  25480. for _, opt := range opts {
  25481. opt(m)
  25482. }
  25483. return m
  25484. }
  25485. // withSopStageID sets the ID field of the mutation.
  25486. func withSopStageID(id uint64) sopstageOption {
  25487. return func(m *SopStageMutation) {
  25488. var (
  25489. err error
  25490. once sync.Once
  25491. value *SopStage
  25492. )
  25493. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  25494. once.Do(func() {
  25495. if m.done {
  25496. err = errors.New("querying old values post mutation is not allowed")
  25497. } else {
  25498. value, err = m.Client().SopStage.Get(ctx, id)
  25499. }
  25500. })
  25501. return value, err
  25502. }
  25503. m.id = &id
  25504. }
  25505. }
  25506. // withSopStage sets the old SopStage of the mutation.
  25507. func withSopStage(node *SopStage) sopstageOption {
  25508. return func(m *SopStageMutation) {
  25509. m.oldValue = func(context.Context) (*SopStage, error) {
  25510. return node, nil
  25511. }
  25512. m.id = &node.ID
  25513. }
  25514. }
  25515. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25516. // executed in a transaction (ent.Tx), a transactional client is returned.
  25517. func (m SopStageMutation) Client() *Client {
  25518. client := &Client{config: m.config}
  25519. client.init()
  25520. return client
  25521. }
  25522. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25523. // it returns an error otherwise.
  25524. func (m SopStageMutation) Tx() (*Tx, error) {
  25525. if _, ok := m.driver.(*txDriver); !ok {
  25526. return nil, errors.New("ent: mutation is not running in a transaction")
  25527. }
  25528. tx := &Tx{config: m.config}
  25529. tx.init()
  25530. return tx, nil
  25531. }
  25532. // SetID sets the value of the id field. Note that this
  25533. // operation is only accepted on creation of SopStage entities.
  25534. func (m *SopStageMutation) SetID(id uint64) {
  25535. m.id = &id
  25536. }
  25537. // ID returns the ID value in the mutation. Note that the ID is only available
  25538. // if it was provided to the builder or after it was returned from the database.
  25539. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  25540. if m.id == nil {
  25541. return
  25542. }
  25543. return *m.id, true
  25544. }
  25545. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25546. // That means, if the mutation is applied within a transaction with an isolation level such
  25547. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25548. // or updated by the mutation.
  25549. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  25550. switch {
  25551. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25552. id, exists := m.ID()
  25553. if exists {
  25554. return []uint64{id}, nil
  25555. }
  25556. fallthrough
  25557. case m.op.Is(OpUpdate | OpDelete):
  25558. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  25559. default:
  25560. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25561. }
  25562. }
  25563. // SetCreatedAt sets the "created_at" field.
  25564. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  25565. m.created_at = &t
  25566. }
  25567. // CreatedAt returns the value of the "created_at" field in the mutation.
  25568. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  25569. v := m.created_at
  25570. if v == nil {
  25571. return
  25572. }
  25573. return *v, true
  25574. }
  25575. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  25576. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25578. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25579. if !m.op.Is(OpUpdateOne) {
  25580. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25581. }
  25582. if m.id == nil || m.oldValue == nil {
  25583. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25584. }
  25585. oldValue, err := m.oldValue(ctx)
  25586. if err != nil {
  25587. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25588. }
  25589. return oldValue.CreatedAt, nil
  25590. }
  25591. // ResetCreatedAt resets all changes to the "created_at" field.
  25592. func (m *SopStageMutation) ResetCreatedAt() {
  25593. m.created_at = nil
  25594. }
  25595. // SetUpdatedAt sets the "updated_at" field.
  25596. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  25597. m.updated_at = &t
  25598. }
  25599. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25600. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  25601. v := m.updated_at
  25602. if v == nil {
  25603. return
  25604. }
  25605. return *v, true
  25606. }
  25607. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  25608. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25610. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25611. if !m.op.Is(OpUpdateOne) {
  25612. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25613. }
  25614. if m.id == nil || m.oldValue == nil {
  25615. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25616. }
  25617. oldValue, err := m.oldValue(ctx)
  25618. if err != nil {
  25619. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25620. }
  25621. return oldValue.UpdatedAt, nil
  25622. }
  25623. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25624. func (m *SopStageMutation) ResetUpdatedAt() {
  25625. m.updated_at = nil
  25626. }
  25627. // SetStatus sets the "status" field.
  25628. func (m *SopStageMutation) SetStatus(u uint8) {
  25629. m.status = &u
  25630. m.addstatus = nil
  25631. }
  25632. // Status returns the value of the "status" field in the mutation.
  25633. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  25634. v := m.status
  25635. if v == nil {
  25636. return
  25637. }
  25638. return *v, true
  25639. }
  25640. // OldStatus returns the old "status" field's value of the SopStage entity.
  25641. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25643. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25644. if !m.op.Is(OpUpdateOne) {
  25645. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25646. }
  25647. if m.id == nil || m.oldValue == nil {
  25648. return v, errors.New("OldStatus requires an ID field in the mutation")
  25649. }
  25650. oldValue, err := m.oldValue(ctx)
  25651. if err != nil {
  25652. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25653. }
  25654. return oldValue.Status, nil
  25655. }
  25656. // AddStatus adds u to the "status" field.
  25657. func (m *SopStageMutation) AddStatus(u int8) {
  25658. if m.addstatus != nil {
  25659. *m.addstatus += u
  25660. } else {
  25661. m.addstatus = &u
  25662. }
  25663. }
  25664. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25665. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  25666. v := m.addstatus
  25667. if v == nil {
  25668. return
  25669. }
  25670. return *v, true
  25671. }
  25672. // ClearStatus clears the value of the "status" field.
  25673. func (m *SopStageMutation) ClearStatus() {
  25674. m.status = nil
  25675. m.addstatus = nil
  25676. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  25677. }
  25678. // StatusCleared returns if the "status" field was cleared in this mutation.
  25679. func (m *SopStageMutation) StatusCleared() bool {
  25680. _, ok := m.clearedFields[sopstage.FieldStatus]
  25681. return ok
  25682. }
  25683. // ResetStatus resets all changes to the "status" field.
  25684. func (m *SopStageMutation) ResetStatus() {
  25685. m.status = nil
  25686. m.addstatus = nil
  25687. delete(m.clearedFields, sopstage.FieldStatus)
  25688. }
  25689. // SetDeletedAt sets the "deleted_at" field.
  25690. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  25691. m.deleted_at = &t
  25692. }
  25693. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25694. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  25695. v := m.deleted_at
  25696. if v == nil {
  25697. return
  25698. }
  25699. return *v, true
  25700. }
  25701. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  25702. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25704. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25705. if !m.op.Is(OpUpdateOne) {
  25706. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25707. }
  25708. if m.id == nil || m.oldValue == nil {
  25709. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25710. }
  25711. oldValue, err := m.oldValue(ctx)
  25712. if err != nil {
  25713. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25714. }
  25715. return oldValue.DeletedAt, nil
  25716. }
  25717. // ClearDeletedAt clears the value of the "deleted_at" field.
  25718. func (m *SopStageMutation) ClearDeletedAt() {
  25719. m.deleted_at = nil
  25720. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  25721. }
  25722. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25723. func (m *SopStageMutation) DeletedAtCleared() bool {
  25724. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  25725. return ok
  25726. }
  25727. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25728. func (m *SopStageMutation) ResetDeletedAt() {
  25729. m.deleted_at = nil
  25730. delete(m.clearedFields, sopstage.FieldDeletedAt)
  25731. }
  25732. // SetTaskID sets the "task_id" field.
  25733. func (m *SopStageMutation) SetTaskID(u uint64) {
  25734. m.sop_task = &u
  25735. }
  25736. // TaskID returns the value of the "task_id" field in the mutation.
  25737. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  25738. v := m.sop_task
  25739. if v == nil {
  25740. return
  25741. }
  25742. return *v, true
  25743. }
  25744. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  25745. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25747. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  25748. if !m.op.Is(OpUpdateOne) {
  25749. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  25750. }
  25751. if m.id == nil || m.oldValue == nil {
  25752. return v, errors.New("OldTaskID requires an ID field in the mutation")
  25753. }
  25754. oldValue, err := m.oldValue(ctx)
  25755. if err != nil {
  25756. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  25757. }
  25758. return oldValue.TaskID, nil
  25759. }
  25760. // ResetTaskID resets all changes to the "task_id" field.
  25761. func (m *SopStageMutation) ResetTaskID() {
  25762. m.sop_task = nil
  25763. }
  25764. // SetName sets the "name" field.
  25765. func (m *SopStageMutation) SetName(s string) {
  25766. m.name = &s
  25767. }
  25768. // Name returns the value of the "name" field in the mutation.
  25769. func (m *SopStageMutation) Name() (r string, exists bool) {
  25770. v := m.name
  25771. if v == nil {
  25772. return
  25773. }
  25774. return *v, true
  25775. }
  25776. // OldName returns the old "name" field's value of the SopStage entity.
  25777. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25779. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  25780. if !m.op.Is(OpUpdateOne) {
  25781. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25782. }
  25783. if m.id == nil || m.oldValue == nil {
  25784. return v, errors.New("OldName requires an ID field in the mutation")
  25785. }
  25786. oldValue, err := m.oldValue(ctx)
  25787. if err != nil {
  25788. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25789. }
  25790. return oldValue.Name, nil
  25791. }
  25792. // ResetName resets all changes to the "name" field.
  25793. func (m *SopStageMutation) ResetName() {
  25794. m.name = nil
  25795. }
  25796. // SetConditionType sets the "condition_type" field.
  25797. func (m *SopStageMutation) SetConditionType(i int) {
  25798. m.condition_type = &i
  25799. m.addcondition_type = nil
  25800. }
  25801. // ConditionType returns the value of the "condition_type" field in the mutation.
  25802. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  25803. v := m.condition_type
  25804. if v == nil {
  25805. return
  25806. }
  25807. return *v, true
  25808. }
  25809. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  25810. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25812. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  25813. if !m.op.Is(OpUpdateOne) {
  25814. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  25815. }
  25816. if m.id == nil || m.oldValue == nil {
  25817. return v, errors.New("OldConditionType requires an ID field in the mutation")
  25818. }
  25819. oldValue, err := m.oldValue(ctx)
  25820. if err != nil {
  25821. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  25822. }
  25823. return oldValue.ConditionType, nil
  25824. }
  25825. // AddConditionType adds i to the "condition_type" field.
  25826. func (m *SopStageMutation) AddConditionType(i int) {
  25827. if m.addcondition_type != nil {
  25828. *m.addcondition_type += i
  25829. } else {
  25830. m.addcondition_type = &i
  25831. }
  25832. }
  25833. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  25834. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  25835. v := m.addcondition_type
  25836. if v == nil {
  25837. return
  25838. }
  25839. return *v, true
  25840. }
  25841. // ResetConditionType resets all changes to the "condition_type" field.
  25842. func (m *SopStageMutation) ResetConditionType() {
  25843. m.condition_type = nil
  25844. m.addcondition_type = nil
  25845. }
  25846. // SetConditionOperator sets the "condition_operator" field.
  25847. func (m *SopStageMutation) SetConditionOperator(i int) {
  25848. m.condition_operator = &i
  25849. m.addcondition_operator = nil
  25850. }
  25851. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  25852. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  25853. v := m.condition_operator
  25854. if v == nil {
  25855. return
  25856. }
  25857. return *v, true
  25858. }
  25859. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  25860. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25862. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  25863. if !m.op.Is(OpUpdateOne) {
  25864. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  25865. }
  25866. if m.id == nil || m.oldValue == nil {
  25867. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  25868. }
  25869. oldValue, err := m.oldValue(ctx)
  25870. if err != nil {
  25871. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  25872. }
  25873. return oldValue.ConditionOperator, nil
  25874. }
  25875. // AddConditionOperator adds i to the "condition_operator" field.
  25876. func (m *SopStageMutation) AddConditionOperator(i int) {
  25877. if m.addcondition_operator != nil {
  25878. *m.addcondition_operator += i
  25879. } else {
  25880. m.addcondition_operator = &i
  25881. }
  25882. }
  25883. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  25884. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  25885. v := m.addcondition_operator
  25886. if v == nil {
  25887. return
  25888. }
  25889. return *v, true
  25890. }
  25891. // ResetConditionOperator resets all changes to the "condition_operator" field.
  25892. func (m *SopStageMutation) ResetConditionOperator() {
  25893. m.condition_operator = nil
  25894. m.addcondition_operator = nil
  25895. }
  25896. // SetConditionList sets the "condition_list" field.
  25897. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  25898. m.condition_list = &ct
  25899. m.appendcondition_list = nil
  25900. }
  25901. // ConditionList returns the value of the "condition_list" field in the mutation.
  25902. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  25903. v := m.condition_list
  25904. if v == nil {
  25905. return
  25906. }
  25907. return *v, true
  25908. }
  25909. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  25910. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25912. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  25913. if !m.op.Is(OpUpdateOne) {
  25914. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  25915. }
  25916. if m.id == nil || m.oldValue == nil {
  25917. return v, errors.New("OldConditionList requires an ID field in the mutation")
  25918. }
  25919. oldValue, err := m.oldValue(ctx)
  25920. if err != nil {
  25921. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  25922. }
  25923. return oldValue.ConditionList, nil
  25924. }
  25925. // AppendConditionList adds ct to the "condition_list" field.
  25926. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  25927. m.appendcondition_list = append(m.appendcondition_list, ct...)
  25928. }
  25929. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  25930. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  25931. if len(m.appendcondition_list) == 0 {
  25932. return nil, false
  25933. }
  25934. return m.appendcondition_list, true
  25935. }
  25936. // ResetConditionList resets all changes to the "condition_list" field.
  25937. func (m *SopStageMutation) ResetConditionList() {
  25938. m.condition_list = nil
  25939. m.appendcondition_list = nil
  25940. }
  25941. // SetActionMessage sets the "action_message" field.
  25942. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  25943. m.action_message = &ct
  25944. m.appendaction_message = nil
  25945. }
  25946. // ActionMessage returns the value of the "action_message" field in the mutation.
  25947. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  25948. v := m.action_message
  25949. if v == nil {
  25950. return
  25951. }
  25952. return *v, true
  25953. }
  25954. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  25955. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25957. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  25958. if !m.op.Is(OpUpdateOne) {
  25959. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  25960. }
  25961. if m.id == nil || m.oldValue == nil {
  25962. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  25963. }
  25964. oldValue, err := m.oldValue(ctx)
  25965. if err != nil {
  25966. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  25967. }
  25968. return oldValue.ActionMessage, nil
  25969. }
  25970. // AppendActionMessage adds ct to the "action_message" field.
  25971. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  25972. m.appendaction_message = append(m.appendaction_message, ct...)
  25973. }
  25974. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  25975. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  25976. if len(m.appendaction_message) == 0 {
  25977. return nil, false
  25978. }
  25979. return m.appendaction_message, true
  25980. }
  25981. // ClearActionMessage clears the value of the "action_message" field.
  25982. func (m *SopStageMutation) ClearActionMessage() {
  25983. m.action_message = nil
  25984. m.appendaction_message = nil
  25985. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  25986. }
  25987. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  25988. func (m *SopStageMutation) ActionMessageCleared() bool {
  25989. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  25990. return ok
  25991. }
  25992. // ResetActionMessage resets all changes to the "action_message" field.
  25993. func (m *SopStageMutation) ResetActionMessage() {
  25994. m.action_message = nil
  25995. m.appendaction_message = nil
  25996. delete(m.clearedFields, sopstage.FieldActionMessage)
  25997. }
  25998. // SetActionLabelAdd sets the "action_label_add" field.
  25999. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  26000. m.action_label_add = &u
  26001. m.appendaction_label_add = nil
  26002. }
  26003. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  26004. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  26005. v := m.action_label_add
  26006. if v == nil {
  26007. return
  26008. }
  26009. return *v, true
  26010. }
  26011. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  26012. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26014. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  26015. if !m.op.Is(OpUpdateOne) {
  26016. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  26017. }
  26018. if m.id == nil || m.oldValue == nil {
  26019. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  26020. }
  26021. oldValue, err := m.oldValue(ctx)
  26022. if err != nil {
  26023. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  26024. }
  26025. return oldValue.ActionLabelAdd, nil
  26026. }
  26027. // AppendActionLabelAdd adds u to the "action_label_add" field.
  26028. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  26029. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  26030. }
  26031. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  26032. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  26033. if len(m.appendaction_label_add) == 0 {
  26034. return nil, false
  26035. }
  26036. return m.appendaction_label_add, true
  26037. }
  26038. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  26039. func (m *SopStageMutation) ClearActionLabelAdd() {
  26040. m.action_label_add = nil
  26041. m.appendaction_label_add = nil
  26042. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  26043. }
  26044. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  26045. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  26046. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  26047. return ok
  26048. }
  26049. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  26050. func (m *SopStageMutation) ResetActionLabelAdd() {
  26051. m.action_label_add = nil
  26052. m.appendaction_label_add = nil
  26053. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  26054. }
  26055. // SetActionLabelDel sets the "action_label_del" field.
  26056. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  26057. m.action_label_del = &u
  26058. m.appendaction_label_del = nil
  26059. }
  26060. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  26061. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  26062. v := m.action_label_del
  26063. if v == nil {
  26064. return
  26065. }
  26066. return *v, true
  26067. }
  26068. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  26069. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26071. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  26072. if !m.op.Is(OpUpdateOne) {
  26073. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  26074. }
  26075. if m.id == nil || m.oldValue == nil {
  26076. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  26077. }
  26078. oldValue, err := m.oldValue(ctx)
  26079. if err != nil {
  26080. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  26081. }
  26082. return oldValue.ActionLabelDel, nil
  26083. }
  26084. // AppendActionLabelDel adds u to the "action_label_del" field.
  26085. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  26086. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  26087. }
  26088. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  26089. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  26090. if len(m.appendaction_label_del) == 0 {
  26091. return nil, false
  26092. }
  26093. return m.appendaction_label_del, true
  26094. }
  26095. // ClearActionLabelDel clears the value of the "action_label_del" field.
  26096. func (m *SopStageMutation) ClearActionLabelDel() {
  26097. m.action_label_del = nil
  26098. m.appendaction_label_del = nil
  26099. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  26100. }
  26101. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  26102. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  26103. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  26104. return ok
  26105. }
  26106. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  26107. func (m *SopStageMutation) ResetActionLabelDel() {
  26108. m.action_label_del = nil
  26109. m.appendaction_label_del = nil
  26110. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  26111. }
  26112. // SetActionForward sets the "action_forward" field.
  26113. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  26114. m.action_forward = &ctf
  26115. }
  26116. // ActionForward returns the value of the "action_forward" field in the mutation.
  26117. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  26118. v := m.action_forward
  26119. if v == nil {
  26120. return
  26121. }
  26122. return *v, true
  26123. }
  26124. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  26125. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26127. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  26128. if !m.op.Is(OpUpdateOne) {
  26129. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  26130. }
  26131. if m.id == nil || m.oldValue == nil {
  26132. return v, errors.New("OldActionForward requires an ID field in the mutation")
  26133. }
  26134. oldValue, err := m.oldValue(ctx)
  26135. if err != nil {
  26136. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  26137. }
  26138. return oldValue.ActionForward, nil
  26139. }
  26140. // ClearActionForward clears the value of the "action_forward" field.
  26141. func (m *SopStageMutation) ClearActionForward() {
  26142. m.action_forward = nil
  26143. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  26144. }
  26145. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  26146. func (m *SopStageMutation) ActionForwardCleared() bool {
  26147. _, ok := m.clearedFields[sopstage.FieldActionForward]
  26148. return ok
  26149. }
  26150. // ResetActionForward resets all changes to the "action_forward" field.
  26151. func (m *SopStageMutation) ResetActionForward() {
  26152. m.action_forward = nil
  26153. delete(m.clearedFields, sopstage.FieldActionForward)
  26154. }
  26155. // SetIndexSort sets the "index_sort" field.
  26156. func (m *SopStageMutation) SetIndexSort(i int) {
  26157. m.index_sort = &i
  26158. m.addindex_sort = nil
  26159. }
  26160. // IndexSort returns the value of the "index_sort" field in the mutation.
  26161. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  26162. v := m.index_sort
  26163. if v == nil {
  26164. return
  26165. }
  26166. return *v, true
  26167. }
  26168. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  26169. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26171. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  26172. if !m.op.Is(OpUpdateOne) {
  26173. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  26174. }
  26175. if m.id == nil || m.oldValue == nil {
  26176. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  26177. }
  26178. oldValue, err := m.oldValue(ctx)
  26179. if err != nil {
  26180. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  26181. }
  26182. return oldValue.IndexSort, nil
  26183. }
  26184. // AddIndexSort adds i to the "index_sort" field.
  26185. func (m *SopStageMutation) AddIndexSort(i int) {
  26186. if m.addindex_sort != nil {
  26187. *m.addindex_sort += i
  26188. } else {
  26189. m.addindex_sort = &i
  26190. }
  26191. }
  26192. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  26193. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  26194. v := m.addindex_sort
  26195. if v == nil {
  26196. return
  26197. }
  26198. return *v, true
  26199. }
  26200. // ClearIndexSort clears the value of the "index_sort" field.
  26201. func (m *SopStageMutation) ClearIndexSort() {
  26202. m.index_sort = nil
  26203. m.addindex_sort = nil
  26204. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  26205. }
  26206. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  26207. func (m *SopStageMutation) IndexSortCleared() bool {
  26208. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  26209. return ok
  26210. }
  26211. // ResetIndexSort resets all changes to the "index_sort" field.
  26212. func (m *SopStageMutation) ResetIndexSort() {
  26213. m.index_sort = nil
  26214. m.addindex_sort = nil
  26215. delete(m.clearedFields, sopstage.FieldIndexSort)
  26216. }
  26217. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  26218. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  26219. m.sop_task = &id
  26220. }
  26221. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  26222. func (m *SopStageMutation) ClearSopTask() {
  26223. m.clearedsop_task = true
  26224. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  26225. }
  26226. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  26227. func (m *SopStageMutation) SopTaskCleared() bool {
  26228. return m.clearedsop_task
  26229. }
  26230. // SopTaskID returns the "sop_task" edge ID in the mutation.
  26231. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  26232. if m.sop_task != nil {
  26233. return *m.sop_task, true
  26234. }
  26235. return
  26236. }
  26237. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  26238. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26239. // SopTaskID instead. It exists only for internal usage by the builders.
  26240. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  26241. if id := m.sop_task; id != nil {
  26242. ids = append(ids, *id)
  26243. }
  26244. return
  26245. }
  26246. // ResetSopTask resets all changes to the "sop_task" edge.
  26247. func (m *SopStageMutation) ResetSopTask() {
  26248. m.sop_task = nil
  26249. m.clearedsop_task = false
  26250. }
  26251. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  26252. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  26253. if m.stage_nodes == nil {
  26254. m.stage_nodes = make(map[uint64]struct{})
  26255. }
  26256. for i := range ids {
  26257. m.stage_nodes[ids[i]] = struct{}{}
  26258. }
  26259. }
  26260. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  26261. func (m *SopStageMutation) ClearStageNodes() {
  26262. m.clearedstage_nodes = true
  26263. }
  26264. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  26265. func (m *SopStageMutation) StageNodesCleared() bool {
  26266. return m.clearedstage_nodes
  26267. }
  26268. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  26269. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  26270. if m.removedstage_nodes == nil {
  26271. m.removedstage_nodes = make(map[uint64]struct{})
  26272. }
  26273. for i := range ids {
  26274. delete(m.stage_nodes, ids[i])
  26275. m.removedstage_nodes[ids[i]] = struct{}{}
  26276. }
  26277. }
  26278. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  26279. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  26280. for id := range m.removedstage_nodes {
  26281. ids = append(ids, id)
  26282. }
  26283. return
  26284. }
  26285. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  26286. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  26287. for id := range m.stage_nodes {
  26288. ids = append(ids, id)
  26289. }
  26290. return
  26291. }
  26292. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  26293. func (m *SopStageMutation) ResetStageNodes() {
  26294. m.stage_nodes = nil
  26295. m.clearedstage_nodes = false
  26296. m.removedstage_nodes = nil
  26297. }
  26298. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  26299. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  26300. if m.stage_messages == nil {
  26301. m.stage_messages = make(map[uint64]struct{})
  26302. }
  26303. for i := range ids {
  26304. m.stage_messages[ids[i]] = struct{}{}
  26305. }
  26306. }
  26307. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  26308. func (m *SopStageMutation) ClearStageMessages() {
  26309. m.clearedstage_messages = true
  26310. }
  26311. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  26312. func (m *SopStageMutation) StageMessagesCleared() bool {
  26313. return m.clearedstage_messages
  26314. }
  26315. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  26316. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  26317. if m.removedstage_messages == nil {
  26318. m.removedstage_messages = make(map[uint64]struct{})
  26319. }
  26320. for i := range ids {
  26321. delete(m.stage_messages, ids[i])
  26322. m.removedstage_messages[ids[i]] = struct{}{}
  26323. }
  26324. }
  26325. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  26326. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  26327. for id := range m.removedstage_messages {
  26328. ids = append(ids, id)
  26329. }
  26330. return
  26331. }
  26332. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  26333. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  26334. for id := range m.stage_messages {
  26335. ids = append(ids, id)
  26336. }
  26337. return
  26338. }
  26339. // ResetStageMessages resets all changes to the "stage_messages" edge.
  26340. func (m *SopStageMutation) ResetStageMessages() {
  26341. m.stage_messages = nil
  26342. m.clearedstage_messages = false
  26343. m.removedstage_messages = nil
  26344. }
  26345. // Where appends a list predicates to the SopStageMutation builder.
  26346. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  26347. m.predicates = append(m.predicates, ps...)
  26348. }
  26349. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  26350. // users can use type-assertion to append predicates that do not depend on any generated package.
  26351. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  26352. p := make([]predicate.SopStage, len(ps))
  26353. for i := range ps {
  26354. p[i] = ps[i]
  26355. }
  26356. m.Where(p...)
  26357. }
  26358. // Op returns the operation name.
  26359. func (m *SopStageMutation) Op() Op {
  26360. return m.op
  26361. }
  26362. // SetOp allows setting the mutation operation.
  26363. func (m *SopStageMutation) SetOp(op Op) {
  26364. m.op = op
  26365. }
  26366. // Type returns the node type of this mutation (SopStage).
  26367. func (m *SopStageMutation) Type() string {
  26368. return m.typ
  26369. }
  26370. // Fields returns all fields that were changed during this mutation. Note that in
  26371. // order to get all numeric fields that were incremented/decremented, call
  26372. // AddedFields().
  26373. func (m *SopStageMutation) Fields() []string {
  26374. fields := make([]string, 0, 14)
  26375. if m.created_at != nil {
  26376. fields = append(fields, sopstage.FieldCreatedAt)
  26377. }
  26378. if m.updated_at != nil {
  26379. fields = append(fields, sopstage.FieldUpdatedAt)
  26380. }
  26381. if m.status != nil {
  26382. fields = append(fields, sopstage.FieldStatus)
  26383. }
  26384. if m.deleted_at != nil {
  26385. fields = append(fields, sopstage.FieldDeletedAt)
  26386. }
  26387. if m.sop_task != nil {
  26388. fields = append(fields, sopstage.FieldTaskID)
  26389. }
  26390. if m.name != nil {
  26391. fields = append(fields, sopstage.FieldName)
  26392. }
  26393. if m.condition_type != nil {
  26394. fields = append(fields, sopstage.FieldConditionType)
  26395. }
  26396. if m.condition_operator != nil {
  26397. fields = append(fields, sopstage.FieldConditionOperator)
  26398. }
  26399. if m.condition_list != nil {
  26400. fields = append(fields, sopstage.FieldConditionList)
  26401. }
  26402. if m.action_message != nil {
  26403. fields = append(fields, sopstage.FieldActionMessage)
  26404. }
  26405. if m.action_label_add != nil {
  26406. fields = append(fields, sopstage.FieldActionLabelAdd)
  26407. }
  26408. if m.action_label_del != nil {
  26409. fields = append(fields, sopstage.FieldActionLabelDel)
  26410. }
  26411. if m.action_forward != nil {
  26412. fields = append(fields, sopstage.FieldActionForward)
  26413. }
  26414. if m.index_sort != nil {
  26415. fields = append(fields, sopstage.FieldIndexSort)
  26416. }
  26417. return fields
  26418. }
  26419. // Field returns the value of a field with the given name. The second boolean
  26420. // return value indicates that this field was not set, or was not defined in the
  26421. // schema.
  26422. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  26423. switch name {
  26424. case sopstage.FieldCreatedAt:
  26425. return m.CreatedAt()
  26426. case sopstage.FieldUpdatedAt:
  26427. return m.UpdatedAt()
  26428. case sopstage.FieldStatus:
  26429. return m.Status()
  26430. case sopstage.FieldDeletedAt:
  26431. return m.DeletedAt()
  26432. case sopstage.FieldTaskID:
  26433. return m.TaskID()
  26434. case sopstage.FieldName:
  26435. return m.Name()
  26436. case sopstage.FieldConditionType:
  26437. return m.ConditionType()
  26438. case sopstage.FieldConditionOperator:
  26439. return m.ConditionOperator()
  26440. case sopstage.FieldConditionList:
  26441. return m.ConditionList()
  26442. case sopstage.FieldActionMessage:
  26443. return m.ActionMessage()
  26444. case sopstage.FieldActionLabelAdd:
  26445. return m.ActionLabelAdd()
  26446. case sopstage.FieldActionLabelDel:
  26447. return m.ActionLabelDel()
  26448. case sopstage.FieldActionForward:
  26449. return m.ActionForward()
  26450. case sopstage.FieldIndexSort:
  26451. return m.IndexSort()
  26452. }
  26453. return nil, false
  26454. }
  26455. // OldField returns the old value of the field from the database. An error is
  26456. // returned if the mutation operation is not UpdateOne, or the query to the
  26457. // database failed.
  26458. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26459. switch name {
  26460. case sopstage.FieldCreatedAt:
  26461. return m.OldCreatedAt(ctx)
  26462. case sopstage.FieldUpdatedAt:
  26463. return m.OldUpdatedAt(ctx)
  26464. case sopstage.FieldStatus:
  26465. return m.OldStatus(ctx)
  26466. case sopstage.FieldDeletedAt:
  26467. return m.OldDeletedAt(ctx)
  26468. case sopstage.FieldTaskID:
  26469. return m.OldTaskID(ctx)
  26470. case sopstage.FieldName:
  26471. return m.OldName(ctx)
  26472. case sopstage.FieldConditionType:
  26473. return m.OldConditionType(ctx)
  26474. case sopstage.FieldConditionOperator:
  26475. return m.OldConditionOperator(ctx)
  26476. case sopstage.FieldConditionList:
  26477. return m.OldConditionList(ctx)
  26478. case sopstage.FieldActionMessage:
  26479. return m.OldActionMessage(ctx)
  26480. case sopstage.FieldActionLabelAdd:
  26481. return m.OldActionLabelAdd(ctx)
  26482. case sopstage.FieldActionLabelDel:
  26483. return m.OldActionLabelDel(ctx)
  26484. case sopstage.FieldActionForward:
  26485. return m.OldActionForward(ctx)
  26486. case sopstage.FieldIndexSort:
  26487. return m.OldIndexSort(ctx)
  26488. }
  26489. return nil, fmt.Errorf("unknown SopStage field %s", name)
  26490. }
  26491. // SetField sets the value of a field with the given name. It returns an error if
  26492. // the field is not defined in the schema, or if the type mismatched the field
  26493. // type.
  26494. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  26495. switch name {
  26496. case sopstage.FieldCreatedAt:
  26497. v, ok := value.(time.Time)
  26498. if !ok {
  26499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26500. }
  26501. m.SetCreatedAt(v)
  26502. return nil
  26503. case sopstage.FieldUpdatedAt:
  26504. v, ok := value.(time.Time)
  26505. if !ok {
  26506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26507. }
  26508. m.SetUpdatedAt(v)
  26509. return nil
  26510. case sopstage.FieldStatus:
  26511. v, ok := value.(uint8)
  26512. if !ok {
  26513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26514. }
  26515. m.SetStatus(v)
  26516. return nil
  26517. case sopstage.FieldDeletedAt:
  26518. v, ok := value.(time.Time)
  26519. if !ok {
  26520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26521. }
  26522. m.SetDeletedAt(v)
  26523. return nil
  26524. case sopstage.FieldTaskID:
  26525. v, ok := value.(uint64)
  26526. if !ok {
  26527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26528. }
  26529. m.SetTaskID(v)
  26530. return nil
  26531. case sopstage.FieldName:
  26532. v, ok := value.(string)
  26533. if !ok {
  26534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26535. }
  26536. m.SetName(v)
  26537. return nil
  26538. case sopstage.FieldConditionType:
  26539. v, ok := value.(int)
  26540. if !ok {
  26541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26542. }
  26543. m.SetConditionType(v)
  26544. return nil
  26545. case sopstage.FieldConditionOperator:
  26546. v, ok := value.(int)
  26547. if !ok {
  26548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26549. }
  26550. m.SetConditionOperator(v)
  26551. return nil
  26552. case sopstage.FieldConditionList:
  26553. v, ok := value.([]custom_types.Condition)
  26554. if !ok {
  26555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26556. }
  26557. m.SetConditionList(v)
  26558. return nil
  26559. case sopstage.FieldActionMessage:
  26560. v, ok := value.([]custom_types.Action)
  26561. if !ok {
  26562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26563. }
  26564. m.SetActionMessage(v)
  26565. return nil
  26566. case sopstage.FieldActionLabelAdd:
  26567. v, ok := value.([]uint64)
  26568. if !ok {
  26569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26570. }
  26571. m.SetActionLabelAdd(v)
  26572. return nil
  26573. case sopstage.FieldActionLabelDel:
  26574. v, ok := value.([]uint64)
  26575. if !ok {
  26576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26577. }
  26578. m.SetActionLabelDel(v)
  26579. return nil
  26580. case sopstage.FieldActionForward:
  26581. v, ok := value.(*custom_types.ActionForward)
  26582. if !ok {
  26583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26584. }
  26585. m.SetActionForward(v)
  26586. return nil
  26587. case sopstage.FieldIndexSort:
  26588. v, ok := value.(int)
  26589. if !ok {
  26590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26591. }
  26592. m.SetIndexSort(v)
  26593. return nil
  26594. }
  26595. return fmt.Errorf("unknown SopStage field %s", name)
  26596. }
  26597. // AddedFields returns all numeric fields that were incremented/decremented during
  26598. // this mutation.
  26599. func (m *SopStageMutation) AddedFields() []string {
  26600. var fields []string
  26601. if m.addstatus != nil {
  26602. fields = append(fields, sopstage.FieldStatus)
  26603. }
  26604. if m.addcondition_type != nil {
  26605. fields = append(fields, sopstage.FieldConditionType)
  26606. }
  26607. if m.addcondition_operator != nil {
  26608. fields = append(fields, sopstage.FieldConditionOperator)
  26609. }
  26610. if m.addindex_sort != nil {
  26611. fields = append(fields, sopstage.FieldIndexSort)
  26612. }
  26613. return fields
  26614. }
  26615. // AddedField returns the numeric value that was incremented/decremented on a field
  26616. // with the given name. The second boolean return value indicates that this field
  26617. // was not set, or was not defined in the schema.
  26618. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  26619. switch name {
  26620. case sopstage.FieldStatus:
  26621. return m.AddedStatus()
  26622. case sopstage.FieldConditionType:
  26623. return m.AddedConditionType()
  26624. case sopstage.FieldConditionOperator:
  26625. return m.AddedConditionOperator()
  26626. case sopstage.FieldIndexSort:
  26627. return m.AddedIndexSort()
  26628. }
  26629. return nil, false
  26630. }
  26631. // AddField adds the value to the field with the given name. It returns an error if
  26632. // the field is not defined in the schema, or if the type mismatched the field
  26633. // type.
  26634. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  26635. switch name {
  26636. case sopstage.FieldStatus:
  26637. v, ok := value.(int8)
  26638. if !ok {
  26639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26640. }
  26641. m.AddStatus(v)
  26642. return nil
  26643. case sopstage.FieldConditionType:
  26644. v, ok := value.(int)
  26645. if !ok {
  26646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26647. }
  26648. m.AddConditionType(v)
  26649. return nil
  26650. case sopstage.FieldConditionOperator:
  26651. v, ok := value.(int)
  26652. if !ok {
  26653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26654. }
  26655. m.AddConditionOperator(v)
  26656. return nil
  26657. case sopstage.FieldIndexSort:
  26658. v, ok := value.(int)
  26659. if !ok {
  26660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26661. }
  26662. m.AddIndexSort(v)
  26663. return nil
  26664. }
  26665. return fmt.Errorf("unknown SopStage numeric field %s", name)
  26666. }
  26667. // ClearedFields returns all nullable fields that were cleared during this
  26668. // mutation.
  26669. func (m *SopStageMutation) ClearedFields() []string {
  26670. var fields []string
  26671. if m.FieldCleared(sopstage.FieldStatus) {
  26672. fields = append(fields, sopstage.FieldStatus)
  26673. }
  26674. if m.FieldCleared(sopstage.FieldDeletedAt) {
  26675. fields = append(fields, sopstage.FieldDeletedAt)
  26676. }
  26677. if m.FieldCleared(sopstage.FieldActionMessage) {
  26678. fields = append(fields, sopstage.FieldActionMessage)
  26679. }
  26680. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  26681. fields = append(fields, sopstage.FieldActionLabelAdd)
  26682. }
  26683. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  26684. fields = append(fields, sopstage.FieldActionLabelDel)
  26685. }
  26686. if m.FieldCleared(sopstage.FieldActionForward) {
  26687. fields = append(fields, sopstage.FieldActionForward)
  26688. }
  26689. if m.FieldCleared(sopstage.FieldIndexSort) {
  26690. fields = append(fields, sopstage.FieldIndexSort)
  26691. }
  26692. return fields
  26693. }
  26694. // FieldCleared returns a boolean indicating if a field with the given name was
  26695. // cleared in this mutation.
  26696. func (m *SopStageMutation) FieldCleared(name string) bool {
  26697. _, ok := m.clearedFields[name]
  26698. return ok
  26699. }
  26700. // ClearField clears the value of the field with the given name. It returns an
  26701. // error if the field is not defined in the schema.
  26702. func (m *SopStageMutation) ClearField(name string) error {
  26703. switch name {
  26704. case sopstage.FieldStatus:
  26705. m.ClearStatus()
  26706. return nil
  26707. case sopstage.FieldDeletedAt:
  26708. m.ClearDeletedAt()
  26709. return nil
  26710. case sopstage.FieldActionMessage:
  26711. m.ClearActionMessage()
  26712. return nil
  26713. case sopstage.FieldActionLabelAdd:
  26714. m.ClearActionLabelAdd()
  26715. return nil
  26716. case sopstage.FieldActionLabelDel:
  26717. m.ClearActionLabelDel()
  26718. return nil
  26719. case sopstage.FieldActionForward:
  26720. m.ClearActionForward()
  26721. return nil
  26722. case sopstage.FieldIndexSort:
  26723. m.ClearIndexSort()
  26724. return nil
  26725. }
  26726. return fmt.Errorf("unknown SopStage nullable field %s", name)
  26727. }
  26728. // ResetField resets all changes in the mutation for the field with the given name.
  26729. // It returns an error if the field is not defined in the schema.
  26730. func (m *SopStageMutation) ResetField(name string) error {
  26731. switch name {
  26732. case sopstage.FieldCreatedAt:
  26733. m.ResetCreatedAt()
  26734. return nil
  26735. case sopstage.FieldUpdatedAt:
  26736. m.ResetUpdatedAt()
  26737. return nil
  26738. case sopstage.FieldStatus:
  26739. m.ResetStatus()
  26740. return nil
  26741. case sopstage.FieldDeletedAt:
  26742. m.ResetDeletedAt()
  26743. return nil
  26744. case sopstage.FieldTaskID:
  26745. m.ResetTaskID()
  26746. return nil
  26747. case sopstage.FieldName:
  26748. m.ResetName()
  26749. return nil
  26750. case sopstage.FieldConditionType:
  26751. m.ResetConditionType()
  26752. return nil
  26753. case sopstage.FieldConditionOperator:
  26754. m.ResetConditionOperator()
  26755. return nil
  26756. case sopstage.FieldConditionList:
  26757. m.ResetConditionList()
  26758. return nil
  26759. case sopstage.FieldActionMessage:
  26760. m.ResetActionMessage()
  26761. return nil
  26762. case sopstage.FieldActionLabelAdd:
  26763. m.ResetActionLabelAdd()
  26764. return nil
  26765. case sopstage.FieldActionLabelDel:
  26766. m.ResetActionLabelDel()
  26767. return nil
  26768. case sopstage.FieldActionForward:
  26769. m.ResetActionForward()
  26770. return nil
  26771. case sopstage.FieldIndexSort:
  26772. m.ResetIndexSort()
  26773. return nil
  26774. }
  26775. return fmt.Errorf("unknown SopStage field %s", name)
  26776. }
  26777. // AddedEdges returns all edge names that were set/added in this mutation.
  26778. func (m *SopStageMutation) AddedEdges() []string {
  26779. edges := make([]string, 0, 3)
  26780. if m.sop_task != nil {
  26781. edges = append(edges, sopstage.EdgeSopTask)
  26782. }
  26783. if m.stage_nodes != nil {
  26784. edges = append(edges, sopstage.EdgeStageNodes)
  26785. }
  26786. if m.stage_messages != nil {
  26787. edges = append(edges, sopstage.EdgeStageMessages)
  26788. }
  26789. return edges
  26790. }
  26791. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26792. // name in this mutation.
  26793. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  26794. switch name {
  26795. case sopstage.EdgeSopTask:
  26796. if id := m.sop_task; id != nil {
  26797. return []ent.Value{*id}
  26798. }
  26799. case sopstage.EdgeStageNodes:
  26800. ids := make([]ent.Value, 0, len(m.stage_nodes))
  26801. for id := range m.stage_nodes {
  26802. ids = append(ids, id)
  26803. }
  26804. return ids
  26805. case sopstage.EdgeStageMessages:
  26806. ids := make([]ent.Value, 0, len(m.stage_messages))
  26807. for id := range m.stage_messages {
  26808. ids = append(ids, id)
  26809. }
  26810. return ids
  26811. }
  26812. return nil
  26813. }
  26814. // RemovedEdges returns all edge names that were removed in this mutation.
  26815. func (m *SopStageMutation) RemovedEdges() []string {
  26816. edges := make([]string, 0, 3)
  26817. if m.removedstage_nodes != nil {
  26818. edges = append(edges, sopstage.EdgeStageNodes)
  26819. }
  26820. if m.removedstage_messages != nil {
  26821. edges = append(edges, sopstage.EdgeStageMessages)
  26822. }
  26823. return edges
  26824. }
  26825. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26826. // the given name in this mutation.
  26827. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  26828. switch name {
  26829. case sopstage.EdgeStageNodes:
  26830. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  26831. for id := range m.removedstage_nodes {
  26832. ids = append(ids, id)
  26833. }
  26834. return ids
  26835. case sopstage.EdgeStageMessages:
  26836. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  26837. for id := range m.removedstage_messages {
  26838. ids = append(ids, id)
  26839. }
  26840. return ids
  26841. }
  26842. return nil
  26843. }
  26844. // ClearedEdges returns all edge names that were cleared in this mutation.
  26845. func (m *SopStageMutation) ClearedEdges() []string {
  26846. edges := make([]string, 0, 3)
  26847. if m.clearedsop_task {
  26848. edges = append(edges, sopstage.EdgeSopTask)
  26849. }
  26850. if m.clearedstage_nodes {
  26851. edges = append(edges, sopstage.EdgeStageNodes)
  26852. }
  26853. if m.clearedstage_messages {
  26854. edges = append(edges, sopstage.EdgeStageMessages)
  26855. }
  26856. return edges
  26857. }
  26858. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26859. // was cleared in this mutation.
  26860. func (m *SopStageMutation) EdgeCleared(name string) bool {
  26861. switch name {
  26862. case sopstage.EdgeSopTask:
  26863. return m.clearedsop_task
  26864. case sopstage.EdgeStageNodes:
  26865. return m.clearedstage_nodes
  26866. case sopstage.EdgeStageMessages:
  26867. return m.clearedstage_messages
  26868. }
  26869. return false
  26870. }
  26871. // ClearEdge clears the value of the edge with the given name. It returns an error
  26872. // if that edge is not defined in the schema.
  26873. func (m *SopStageMutation) ClearEdge(name string) error {
  26874. switch name {
  26875. case sopstage.EdgeSopTask:
  26876. m.ClearSopTask()
  26877. return nil
  26878. }
  26879. return fmt.Errorf("unknown SopStage unique edge %s", name)
  26880. }
  26881. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26882. // It returns an error if the edge is not defined in the schema.
  26883. func (m *SopStageMutation) ResetEdge(name string) error {
  26884. switch name {
  26885. case sopstage.EdgeSopTask:
  26886. m.ResetSopTask()
  26887. return nil
  26888. case sopstage.EdgeStageNodes:
  26889. m.ResetStageNodes()
  26890. return nil
  26891. case sopstage.EdgeStageMessages:
  26892. m.ResetStageMessages()
  26893. return nil
  26894. }
  26895. return fmt.Errorf("unknown SopStage edge %s", name)
  26896. }
  26897. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  26898. type SopTaskMutation struct {
  26899. config
  26900. op Op
  26901. typ string
  26902. id *uint64
  26903. created_at *time.Time
  26904. updated_at *time.Time
  26905. status *uint8
  26906. addstatus *int8
  26907. deleted_at *time.Time
  26908. name *string
  26909. bot_wxid_list *[]string
  26910. appendbot_wxid_list []string
  26911. _type *int
  26912. add_type *int
  26913. plan_start_time *time.Time
  26914. plan_end_time *time.Time
  26915. creator_id *string
  26916. organization_id *uint64
  26917. addorganization_id *int64
  26918. token *[]string
  26919. appendtoken []string
  26920. clearedFields map[string]struct{}
  26921. task_stages map[uint64]struct{}
  26922. removedtask_stages map[uint64]struct{}
  26923. clearedtask_stages bool
  26924. done bool
  26925. oldValue func(context.Context) (*SopTask, error)
  26926. predicates []predicate.SopTask
  26927. }
  26928. var _ ent.Mutation = (*SopTaskMutation)(nil)
  26929. // soptaskOption allows management of the mutation configuration using functional options.
  26930. type soptaskOption func(*SopTaskMutation)
  26931. // newSopTaskMutation creates new mutation for the SopTask entity.
  26932. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  26933. m := &SopTaskMutation{
  26934. config: c,
  26935. op: op,
  26936. typ: TypeSopTask,
  26937. clearedFields: make(map[string]struct{}),
  26938. }
  26939. for _, opt := range opts {
  26940. opt(m)
  26941. }
  26942. return m
  26943. }
  26944. // withSopTaskID sets the ID field of the mutation.
  26945. func withSopTaskID(id uint64) soptaskOption {
  26946. return func(m *SopTaskMutation) {
  26947. var (
  26948. err error
  26949. once sync.Once
  26950. value *SopTask
  26951. )
  26952. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  26953. once.Do(func() {
  26954. if m.done {
  26955. err = errors.New("querying old values post mutation is not allowed")
  26956. } else {
  26957. value, err = m.Client().SopTask.Get(ctx, id)
  26958. }
  26959. })
  26960. return value, err
  26961. }
  26962. m.id = &id
  26963. }
  26964. }
  26965. // withSopTask sets the old SopTask of the mutation.
  26966. func withSopTask(node *SopTask) soptaskOption {
  26967. return func(m *SopTaskMutation) {
  26968. m.oldValue = func(context.Context) (*SopTask, error) {
  26969. return node, nil
  26970. }
  26971. m.id = &node.ID
  26972. }
  26973. }
  26974. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26975. // executed in a transaction (ent.Tx), a transactional client is returned.
  26976. func (m SopTaskMutation) Client() *Client {
  26977. client := &Client{config: m.config}
  26978. client.init()
  26979. return client
  26980. }
  26981. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26982. // it returns an error otherwise.
  26983. func (m SopTaskMutation) Tx() (*Tx, error) {
  26984. if _, ok := m.driver.(*txDriver); !ok {
  26985. return nil, errors.New("ent: mutation is not running in a transaction")
  26986. }
  26987. tx := &Tx{config: m.config}
  26988. tx.init()
  26989. return tx, nil
  26990. }
  26991. // SetID sets the value of the id field. Note that this
  26992. // operation is only accepted on creation of SopTask entities.
  26993. func (m *SopTaskMutation) SetID(id uint64) {
  26994. m.id = &id
  26995. }
  26996. // ID returns the ID value in the mutation. Note that the ID is only available
  26997. // if it was provided to the builder or after it was returned from the database.
  26998. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  26999. if m.id == nil {
  27000. return
  27001. }
  27002. return *m.id, true
  27003. }
  27004. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27005. // That means, if the mutation is applied within a transaction with an isolation level such
  27006. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27007. // or updated by the mutation.
  27008. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  27009. switch {
  27010. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27011. id, exists := m.ID()
  27012. if exists {
  27013. return []uint64{id}, nil
  27014. }
  27015. fallthrough
  27016. case m.op.Is(OpUpdate | OpDelete):
  27017. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  27018. default:
  27019. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27020. }
  27021. }
  27022. // SetCreatedAt sets the "created_at" field.
  27023. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  27024. m.created_at = &t
  27025. }
  27026. // CreatedAt returns the value of the "created_at" field in the mutation.
  27027. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  27028. v := m.created_at
  27029. if v == nil {
  27030. return
  27031. }
  27032. return *v, true
  27033. }
  27034. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  27035. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27037. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27038. if !m.op.Is(OpUpdateOne) {
  27039. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27040. }
  27041. if m.id == nil || m.oldValue == nil {
  27042. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27043. }
  27044. oldValue, err := m.oldValue(ctx)
  27045. if err != nil {
  27046. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27047. }
  27048. return oldValue.CreatedAt, nil
  27049. }
  27050. // ResetCreatedAt resets all changes to the "created_at" field.
  27051. func (m *SopTaskMutation) ResetCreatedAt() {
  27052. m.created_at = nil
  27053. }
  27054. // SetUpdatedAt sets the "updated_at" field.
  27055. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  27056. m.updated_at = &t
  27057. }
  27058. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27059. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  27060. v := m.updated_at
  27061. if v == nil {
  27062. return
  27063. }
  27064. return *v, true
  27065. }
  27066. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  27067. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27069. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27070. if !m.op.Is(OpUpdateOne) {
  27071. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27072. }
  27073. if m.id == nil || m.oldValue == nil {
  27074. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27075. }
  27076. oldValue, err := m.oldValue(ctx)
  27077. if err != nil {
  27078. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27079. }
  27080. return oldValue.UpdatedAt, nil
  27081. }
  27082. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27083. func (m *SopTaskMutation) ResetUpdatedAt() {
  27084. m.updated_at = nil
  27085. }
  27086. // SetStatus sets the "status" field.
  27087. func (m *SopTaskMutation) SetStatus(u uint8) {
  27088. m.status = &u
  27089. m.addstatus = nil
  27090. }
  27091. // Status returns the value of the "status" field in the mutation.
  27092. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  27093. v := m.status
  27094. if v == nil {
  27095. return
  27096. }
  27097. return *v, true
  27098. }
  27099. // OldStatus returns the old "status" field's value of the SopTask entity.
  27100. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27102. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27103. if !m.op.Is(OpUpdateOne) {
  27104. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27105. }
  27106. if m.id == nil || m.oldValue == nil {
  27107. return v, errors.New("OldStatus requires an ID field in the mutation")
  27108. }
  27109. oldValue, err := m.oldValue(ctx)
  27110. if err != nil {
  27111. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27112. }
  27113. return oldValue.Status, nil
  27114. }
  27115. // AddStatus adds u to the "status" field.
  27116. func (m *SopTaskMutation) AddStatus(u int8) {
  27117. if m.addstatus != nil {
  27118. *m.addstatus += u
  27119. } else {
  27120. m.addstatus = &u
  27121. }
  27122. }
  27123. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27124. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  27125. v := m.addstatus
  27126. if v == nil {
  27127. return
  27128. }
  27129. return *v, true
  27130. }
  27131. // ClearStatus clears the value of the "status" field.
  27132. func (m *SopTaskMutation) ClearStatus() {
  27133. m.status = nil
  27134. m.addstatus = nil
  27135. m.clearedFields[soptask.FieldStatus] = struct{}{}
  27136. }
  27137. // StatusCleared returns if the "status" field was cleared in this mutation.
  27138. func (m *SopTaskMutation) StatusCleared() bool {
  27139. _, ok := m.clearedFields[soptask.FieldStatus]
  27140. return ok
  27141. }
  27142. // ResetStatus resets all changes to the "status" field.
  27143. func (m *SopTaskMutation) ResetStatus() {
  27144. m.status = nil
  27145. m.addstatus = nil
  27146. delete(m.clearedFields, soptask.FieldStatus)
  27147. }
  27148. // SetDeletedAt sets the "deleted_at" field.
  27149. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  27150. m.deleted_at = &t
  27151. }
  27152. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27153. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  27154. v := m.deleted_at
  27155. if v == nil {
  27156. return
  27157. }
  27158. return *v, true
  27159. }
  27160. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  27161. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27163. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27164. if !m.op.Is(OpUpdateOne) {
  27165. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27166. }
  27167. if m.id == nil || m.oldValue == nil {
  27168. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27169. }
  27170. oldValue, err := m.oldValue(ctx)
  27171. if err != nil {
  27172. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27173. }
  27174. return oldValue.DeletedAt, nil
  27175. }
  27176. // ClearDeletedAt clears the value of the "deleted_at" field.
  27177. func (m *SopTaskMutation) ClearDeletedAt() {
  27178. m.deleted_at = nil
  27179. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  27180. }
  27181. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27182. func (m *SopTaskMutation) DeletedAtCleared() bool {
  27183. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  27184. return ok
  27185. }
  27186. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27187. func (m *SopTaskMutation) ResetDeletedAt() {
  27188. m.deleted_at = nil
  27189. delete(m.clearedFields, soptask.FieldDeletedAt)
  27190. }
  27191. // SetName sets the "name" field.
  27192. func (m *SopTaskMutation) SetName(s string) {
  27193. m.name = &s
  27194. }
  27195. // Name returns the value of the "name" field in the mutation.
  27196. func (m *SopTaskMutation) Name() (r string, exists bool) {
  27197. v := m.name
  27198. if v == nil {
  27199. return
  27200. }
  27201. return *v, true
  27202. }
  27203. // OldName returns the old "name" field's value of the SopTask entity.
  27204. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27206. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  27207. if !m.op.Is(OpUpdateOne) {
  27208. return v, errors.New("OldName is only allowed on UpdateOne operations")
  27209. }
  27210. if m.id == nil || m.oldValue == nil {
  27211. return v, errors.New("OldName requires an ID field in the mutation")
  27212. }
  27213. oldValue, err := m.oldValue(ctx)
  27214. if err != nil {
  27215. return v, fmt.Errorf("querying old value for OldName: %w", err)
  27216. }
  27217. return oldValue.Name, nil
  27218. }
  27219. // ResetName resets all changes to the "name" field.
  27220. func (m *SopTaskMutation) ResetName() {
  27221. m.name = nil
  27222. }
  27223. // SetBotWxidList sets the "bot_wxid_list" field.
  27224. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  27225. m.bot_wxid_list = &s
  27226. m.appendbot_wxid_list = nil
  27227. }
  27228. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  27229. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  27230. v := m.bot_wxid_list
  27231. if v == nil {
  27232. return
  27233. }
  27234. return *v, true
  27235. }
  27236. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  27237. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27239. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  27240. if !m.op.Is(OpUpdateOne) {
  27241. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  27242. }
  27243. if m.id == nil || m.oldValue == nil {
  27244. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  27245. }
  27246. oldValue, err := m.oldValue(ctx)
  27247. if err != nil {
  27248. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  27249. }
  27250. return oldValue.BotWxidList, nil
  27251. }
  27252. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  27253. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  27254. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  27255. }
  27256. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  27257. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  27258. if len(m.appendbot_wxid_list) == 0 {
  27259. return nil, false
  27260. }
  27261. return m.appendbot_wxid_list, true
  27262. }
  27263. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  27264. func (m *SopTaskMutation) ClearBotWxidList() {
  27265. m.bot_wxid_list = nil
  27266. m.appendbot_wxid_list = nil
  27267. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  27268. }
  27269. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  27270. func (m *SopTaskMutation) BotWxidListCleared() bool {
  27271. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  27272. return ok
  27273. }
  27274. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  27275. func (m *SopTaskMutation) ResetBotWxidList() {
  27276. m.bot_wxid_list = nil
  27277. m.appendbot_wxid_list = nil
  27278. delete(m.clearedFields, soptask.FieldBotWxidList)
  27279. }
  27280. // SetType sets the "type" field.
  27281. func (m *SopTaskMutation) SetType(i int) {
  27282. m._type = &i
  27283. m.add_type = nil
  27284. }
  27285. // GetType returns the value of the "type" field in the mutation.
  27286. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  27287. v := m._type
  27288. if v == nil {
  27289. return
  27290. }
  27291. return *v, true
  27292. }
  27293. // OldType returns the old "type" field's value of the SopTask entity.
  27294. // If the SopTask 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 *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  27297. if !m.op.Is(OpUpdateOne) {
  27298. return v, errors.New("OldType is only allowed on UpdateOne operations")
  27299. }
  27300. if m.id == nil || m.oldValue == nil {
  27301. return v, errors.New("OldType 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 OldType: %w", err)
  27306. }
  27307. return oldValue.Type, nil
  27308. }
  27309. // AddType adds i to the "type" field.
  27310. func (m *SopTaskMutation) AddType(i int) {
  27311. if m.add_type != nil {
  27312. *m.add_type += i
  27313. } else {
  27314. m.add_type = &i
  27315. }
  27316. }
  27317. // AddedType returns the value that was added to the "type" field in this mutation.
  27318. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  27319. v := m.add_type
  27320. if v == nil {
  27321. return
  27322. }
  27323. return *v, true
  27324. }
  27325. // ResetType resets all changes to the "type" field.
  27326. func (m *SopTaskMutation) ResetType() {
  27327. m._type = nil
  27328. m.add_type = nil
  27329. }
  27330. // SetPlanStartTime sets the "plan_start_time" field.
  27331. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  27332. m.plan_start_time = &t
  27333. }
  27334. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  27335. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  27336. v := m.plan_start_time
  27337. if v == nil {
  27338. return
  27339. }
  27340. return *v, true
  27341. }
  27342. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  27343. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27345. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  27346. if !m.op.Is(OpUpdateOne) {
  27347. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  27348. }
  27349. if m.id == nil || m.oldValue == nil {
  27350. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  27351. }
  27352. oldValue, err := m.oldValue(ctx)
  27353. if err != nil {
  27354. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  27355. }
  27356. return oldValue.PlanStartTime, nil
  27357. }
  27358. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  27359. func (m *SopTaskMutation) ClearPlanStartTime() {
  27360. m.plan_start_time = nil
  27361. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  27362. }
  27363. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  27364. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  27365. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  27366. return ok
  27367. }
  27368. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  27369. func (m *SopTaskMutation) ResetPlanStartTime() {
  27370. m.plan_start_time = nil
  27371. delete(m.clearedFields, soptask.FieldPlanStartTime)
  27372. }
  27373. // SetPlanEndTime sets the "plan_end_time" field.
  27374. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  27375. m.plan_end_time = &t
  27376. }
  27377. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  27378. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  27379. v := m.plan_end_time
  27380. if v == nil {
  27381. return
  27382. }
  27383. return *v, true
  27384. }
  27385. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  27386. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27388. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  27389. if !m.op.Is(OpUpdateOne) {
  27390. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  27391. }
  27392. if m.id == nil || m.oldValue == nil {
  27393. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  27394. }
  27395. oldValue, err := m.oldValue(ctx)
  27396. if err != nil {
  27397. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  27398. }
  27399. return oldValue.PlanEndTime, nil
  27400. }
  27401. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  27402. func (m *SopTaskMutation) ClearPlanEndTime() {
  27403. m.plan_end_time = nil
  27404. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  27405. }
  27406. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  27407. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  27408. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  27409. return ok
  27410. }
  27411. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  27412. func (m *SopTaskMutation) ResetPlanEndTime() {
  27413. m.plan_end_time = nil
  27414. delete(m.clearedFields, soptask.FieldPlanEndTime)
  27415. }
  27416. // SetCreatorID sets the "creator_id" field.
  27417. func (m *SopTaskMutation) SetCreatorID(s string) {
  27418. m.creator_id = &s
  27419. }
  27420. // CreatorID returns the value of the "creator_id" field in the mutation.
  27421. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  27422. v := m.creator_id
  27423. if v == nil {
  27424. return
  27425. }
  27426. return *v, true
  27427. }
  27428. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  27429. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27431. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  27432. if !m.op.Is(OpUpdateOne) {
  27433. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  27434. }
  27435. if m.id == nil || m.oldValue == nil {
  27436. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  27437. }
  27438. oldValue, err := m.oldValue(ctx)
  27439. if err != nil {
  27440. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  27441. }
  27442. return oldValue.CreatorID, nil
  27443. }
  27444. // ClearCreatorID clears the value of the "creator_id" field.
  27445. func (m *SopTaskMutation) ClearCreatorID() {
  27446. m.creator_id = nil
  27447. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  27448. }
  27449. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  27450. func (m *SopTaskMutation) CreatorIDCleared() bool {
  27451. _, ok := m.clearedFields[soptask.FieldCreatorID]
  27452. return ok
  27453. }
  27454. // ResetCreatorID resets all changes to the "creator_id" field.
  27455. func (m *SopTaskMutation) ResetCreatorID() {
  27456. m.creator_id = nil
  27457. delete(m.clearedFields, soptask.FieldCreatorID)
  27458. }
  27459. // SetOrganizationID sets the "organization_id" field.
  27460. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  27461. m.organization_id = &u
  27462. m.addorganization_id = nil
  27463. }
  27464. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27465. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  27466. v := m.organization_id
  27467. if v == nil {
  27468. return
  27469. }
  27470. return *v, true
  27471. }
  27472. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  27473. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27475. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27476. if !m.op.Is(OpUpdateOne) {
  27477. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27478. }
  27479. if m.id == nil || m.oldValue == nil {
  27480. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27481. }
  27482. oldValue, err := m.oldValue(ctx)
  27483. if err != nil {
  27484. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27485. }
  27486. return oldValue.OrganizationID, nil
  27487. }
  27488. // AddOrganizationID adds u to the "organization_id" field.
  27489. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  27490. if m.addorganization_id != nil {
  27491. *m.addorganization_id += u
  27492. } else {
  27493. m.addorganization_id = &u
  27494. }
  27495. }
  27496. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27497. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  27498. v := m.addorganization_id
  27499. if v == nil {
  27500. return
  27501. }
  27502. return *v, true
  27503. }
  27504. // ClearOrganizationID clears the value of the "organization_id" field.
  27505. func (m *SopTaskMutation) ClearOrganizationID() {
  27506. m.organization_id = nil
  27507. m.addorganization_id = nil
  27508. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  27509. }
  27510. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27511. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  27512. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  27513. return ok
  27514. }
  27515. // ResetOrganizationID resets all changes to the "organization_id" field.
  27516. func (m *SopTaskMutation) ResetOrganizationID() {
  27517. m.organization_id = nil
  27518. m.addorganization_id = nil
  27519. delete(m.clearedFields, soptask.FieldOrganizationID)
  27520. }
  27521. // SetToken sets the "token" field.
  27522. func (m *SopTaskMutation) SetToken(s []string) {
  27523. m.token = &s
  27524. m.appendtoken = nil
  27525. }
  27526. // Token returns the value of the "token" field in the mutation.
  27527. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  27528. v := m.token
  27529. if v == nil {
  27530. return
  27531. }
  27532. return *v, true
  27533. }
  27534. // OldToken returns the old "token" field's value of the SopTask entity.
  27535. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27537. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  27538. if !m.op.Is(OpUpdateOne) {
  27539. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  27540. }
  27541. if m.id == nil || m.oldValue == nil {
  27542. return v, errors.New("OldToken requires an ID field in the mutation")
  27543. }
  27544. oldValue, err := m.oldValue(ctx)
  27545. if err != nil {
  27546. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  27547. }
  27548. return oldValue.Token, nil
  27549. }
  27550. // AppendToken adds s to the "token" field.
  27551. func (m *SopTaskMutation) AppendToken(s []string) {
  27552. m.appendtoken = append(m.appendtoken, s...)
  27553. }
  27554. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  27555. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  27556. if len(m.appendtoken) == 0 {
  27557. return nil, false
  27558. }
  27559. return m.appendtoken, true
  27560. }
  27561. // ClearToken clears the value of the "token" field.
  27562. func (m *SopTaskMutation) ClearToken() {
  27563. m.token = nil
  27564. m.appendtoken = nil
  27565. m.clearedFields[soptask.FieldToken] = struct{}{}
  27566. }
  27567. // TokenCleared returns if the "token" field was cleared in this mutation.
  27568. func (m *SopTaskMutation) TokenCleared() bool {
  27569. _, ok := m.clearedFields[soptask.FieldToken]
  27570. return ok
  27571. }
  27572. // ResetToken resets all changes to the "token" field.
  27573. func (m *SopTaskMutation) ResetToken() {
  27574. m.token = nil
  27575. m.appendtoken = nil
  27576. delete(m.clearedFields, soptask.FieldToken)
  27577. }
  27578. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  27579. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  27580. if m.task_stages == nil {
  27581. m.task_stages = make(map[uint64]struct{})
  27582. }
  27583. for i := range ids {
  27584. m.task_stages[ids[i]] = struct{}{}
  27585. }
  27586. }
  27587. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  27588. func (m *SopTaskMutation) ClearTaskStages() {
  27589. m.clearedtask_stages = true
  27590. }
  27591. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  27592. func (m *SopTaskMutation) TaskStagesCleared() bool {
  27593. return m.clearedtask_stages
  27594. }
  27595. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  27596. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  27597. if m.removedtask_stages == nil {
  27598. m.removedtask_stages = make(map[uint64]struct{})
  27599. }
  27600. for i := range ids {
  27601. delete(m.task_stages, ids[i])
  27602. m.removedtask_stages[ids[i]] = struct{}{}
  27603. }
  27604. }
  27605. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  27606. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  27607. for id := range m.removedtask_stages {
  27608. ids = append(ids, id)
  27609. }
  27610. return
  27611. }
  27612. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  27613. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  27614. for id := range m.task_stages {
  27615. ids = append(ids, id)
  27616. }
  27617. return
  27618. }
  27619. // ResetTaskStages resets all changes to the "task_stages" edge.
  27620. func (m *SopTaskMutation) ResetTaskStages() {
  27621. m.task_stages = nil
  27622. m.clearedtask_stages = false
  27623. m.removedtask_stages = nil
  27624. }
  27625. // Where appends a list predicates to the SopTaskMutation builder.
  27626. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  27627. m.predicates = append(m.predicates, ps...)
  27628. }
  27629. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  27630. // users can use type-assertion to append predicates that do not depend on any generated package.
  27631. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  27632. p := make([]predicate.SopTask, len(ps))
  27633. for i := range ps {
  27634. p[i] = ps[i]
  27635. }
  27636. m.Where(p...)
  27637. }
  27638. // Op returns the operation name.
  27639. func (m *SopTaskMutation) Op() Op {
  27640. return m.op
  27641. }
  27642. // SetOp allows setting the mutation operation.
  27643. func (m *SopTaskMutation) SetOp(op Op) {
  27644. m.op = op
  27645. }
  27646. // Type returns the node type of this mutation (SopTask).
  27647. func (m *SopTaskMutation) Type() string {
  27648. return m.typ
  27649. }
  27650. // Fields returns all fields that were changed during this mutation. Note that in
  27651. // order to get all numeric fields that were incremented/decremented, call
  27652. // AddedFields().
  27653. func (m *SopTaskMutation) Fields() []string {
  27654. fields := make([]string, 0, 12)
  27655. if m.created_at != nil {
  27656. fields = append(fields, soptask.FieldCreatedAt)
  27657. }
  27658. if m.updated_at != nil {
  27659. fields = append(fields, soptask.FieldUpdatedAt)
  27660. }
  27661. if m.status != nil {
  27662. fields = append(fields, soptask.FieldStatus)
  27663. }
  27664. if m.deleted_at != nil {
  27665. fields = append(fields, soptask.FieldDeletedAt)
  27666. }
  27667. if m.name != nil {
  27668. fields = append(fields, soptask.FieldName)
  27669. }
  27670. if m.bot_wxid_list != nil {
  27671. fields = append(fields, soptask.FieldBotWxidList)
  27672. }
  27673. if m._type != nil {
  27674. fields = append(fields, soptask.FieldType)
  27675. }
  27676. if m.plan_start_time != nil {
  27677. fields = append(fields, soptask.FieldPlanStartTime)
  27678. }
  27679. if m.plan_end_time != nil {
  27680. fields = append(fields, soptask.FieldPlanEndTime)
  27681. }
  27682. if m.creator_id != nil {
  27683. fields = append(fields, soptask.FieldCreatorID)
  27684. }
  27685. if m.organization_id != nil {
  27686. fields = append(fields, soptask.FieldOrganizationID)
  27687. }
  27688. if m.token != nil {
  27689. fields = append(fields, soptask.FieldToken)
  27690. }
  27691. return fields
  27692. }
  27693. // Field returns the value of a field with the given name. The second boolean
  27694. // return value indicates that this field was not set, or was not defined in the
  27695. // schema.
  27696. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  27697. switch name {
  27698. case soptask.FieldCreatedAt:
  27699. return m.CreatedAt()
  27700. case soptask.FieldUpdatedAt:
  27701. return m.UpdatedAt()
  27702. case soptask.FieldStatus:
  27703. return m.Status()
  27704. case soptask.FieldDeletedAt:
  27705. return m.DeletedAt()
  27706. case soptask.FieldName:
  27707. return m.Name()
  27708. case soptask.FieldBotWxidList:
  27709. return m.BotWxidList()
  27710. case soptask.FieldType:
  27711. return m.GetType()
  27712. case soptask.FieldPlanStartTime:
  27713. return m.PlanStartTime()
  27714. case soptask.FieldPlanEndTime:
  27715. return m.PlanEndTime()
  27716. case soptask.FieldCreatorID:
  27717. return m.CreatorID()
  27718. case soptask.FieldOrganizationID:
  27719. return m.OrganizationID()
  27720. case soptask.FieldToken:
  27721. return m.Token()
  27722. }
  27723. return nil, false
  27724. }
  27725. // OldField returns the old value of the field from the database. An error is
  27726. // returned if the mutation operation is not UpdateOne, or the query to the
  27727. // database failed.
  27728. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27729. switch name {
  27730. case soptask.FieldCreatedAt:
  27731. return m.OldCreatedAt(ctx)
  27732. case soptask.FieldUpdatedAt:
  27733. return m.OldUpdatedAt(ctx)
  27734. case soptask.FieldStatus:
  27735. return m.OldStatus(ctx)
  27736. case soptask.FieldDeletedAt:
  27737. return m.OldDeletedAt(ctx)
  27738. case soptask.FieldName:
  27739. return m.OldName(ctx)
  27740. case soptask.FieldBotWxidList:
  27741. return m.OldBotWxidList(ctx)
  27742. case soptask.FieldType:
  27743. return m.OldType(ctx)
  27744. case soptask.FieldPlanStartTime:
  27745. return m.OldPlanStartTime(ctx)
  27746. case soptask.FieldPlanEndTime:
  27747. return m.OldPlanEndTime(ctx)
  27748. case soptask.FieldCreatorID:
  27749. return m.OldCreatorID(ctx)
  27750. case soptask.FieldOrganizationID:
  27751. return m.OldOrganizationID(ctx)
  27752. case soptask.FieldToken:
  27753. return m.OldToken(ctx)
  27754. }
  27755. return nil, fmt.Errorf("unknown SopTask field %s", name)
  27756. }
  27757. // SetField sets the value of a field with the given name. It returns an error if
  27758. // the field is not defined in the schema, or if the type mismatched the field
  27759. // type.
  27760. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  27761. switch name {
  27762. case soptask.FieldCreatedAt:
  27763. v, ok := value.(time.Time)
  27764. if !ok {
  27765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27766. }
  27767. m.SetCreatedAt(v)
  27768. return nil
  27769. case soptask.FieldUpdatedAt:
  27770. v, ok := value.(time.Time)
  27771. if !ok {
  27772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27773. }
  27774. m.SetUpdatedAt(v)
  27775. return nil
  27776. case soptask.FieldStatus:
  27777. v, ok := value.(uint8)
  27778. if !ok {
  27779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27780. }
  27781. m.SetStatus(v)
  27782. return nil
  27783. case soptask.FieldDeletedAt:
  27784. v, ok := value.(time.Time)
  27785. if !ok {
  27786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27787. }
  27788. m.SetDeletedAt(v)
  27789. return nil
  27790. case soptask.FieldName:
  27791. v, ok := value.(string)
  27792. if !ok {
  27793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27794. }
  27795. m.SetName(v)
  27796. return nil
  27797. case soptask.FieldBotWxidList:
  27798. v, ok := value.([]string)
  27799. if !ok {
  27800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27801. }
  27802. m.SetBotWxidList(v)
  27803. return nil
  27804. case soptask.FieldType:
  27805. v, ok := value.(int)
  27806. if !ok {
  27807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27808. }
  27809. m.SetType(v)
  27810. return nil
  27811. case soptask.FieldPlanStartTime:
  27812. v, ok := value.(time.Time)
  27813. if !ok {
  27814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27815. }
  27816. m.SetPlanStartTime(v)
  27817. return nil
  27818. case soptask.FieldPlanEndTime:
  27819. v, ok := value.(time.Time)
  27820. if !ok {
  27821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27822. }
  27823. m.SetPlanEndTime(v)
  27824. return nil
  27825. case soptask.FieldCreatorID:
  27826. v, ok := value.(string)
  27827. if !ok {
  27828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27829. }
  27830. m.SetCreatorID(v)
  27831. return nil
  27832. case soptask.FieldOrganizationID:
  27833. v, ok := value.(uint64)
  27834. if !ok {
  27835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27836. }
  27837. m.SetOrganizationID(v)
  27838. return nil
  27839. case soptask.FieldToken:
  27840. v, ok := value.([]string)
  27841. if !ok {
  27842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27843. }
  27844. m.SetToken(v)
  27845. return nil
  27846. }
  27847. return fmt.Errorf("unknown SopTask field %s", name)
  27848. }
  27849. // AddedFields returns all numeric fields that were incremented/decremented during
  27850. // this mutation.
  27851. func (m *SopTaskMutation) AddedFields() []string {
  27852. var fields []string
  27853. if m.addstatus != nil {
  27854. fields = append(fields, soptask.FieldStatus)
  27855. }
  27856. if m.add_type != nil {
  27857. fields = append(fields, soptask.FieldType)
  27858. }
  27859. if m.addorganization_id != nil {
  27860. fields = append(fields, soptask.FieldOrganizationID)
  27861. }
  27862. return fields
  27863. }
  27864. // AddedField returns the numeric value that was incremented/decremented on a field
  27865. // with the given name. The second boolean return value indicates that this field
  27866. // was not set, or was not defined in the schema.
  27867. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  27868. switch name {
  27869. case soptask.FieldStatus:
  27870. return m.AddedStatus()
  27871. case soptask.FieldType:
  27872. return m.AddedType()
  27873. case soptask.FieldOrganizationID:
  27874. return m.AddedOrganizationID()
  27875. }
  27876. return nil, false
  27877. }
  27878. // AddField adds the value to the field with the given name. It returns an error if
  27879. // the field is not defined in the schema, or if the type mismatched the field
  27880. // type.
  27881. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  27882. switch name {
  27883. case soptask.FieldStatus:
  27884. v, ok := value.(int8)
  27885. if !ok {
  27886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27887. }
  27888. m.AddStatus(v)
  27889. return nil
  27890. case soptask.FieldType:
  27891. v, ok := value.(int)
  27892. if !ok {
  27893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27894. }
  27895. m.AddType(v)
  27896. return nil
  27897. case soptask.FieldOrganizationID:
  27898. v, ok := value.(int64)
  27899. if !ok {
  27900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27901. }
  27902. m.AddOrganizationID(v)
  27903. return nil
  27904. }
  27905. return fmt.Errorf("unknown SopTask numeric field %s", name)
  27906. }
  27907. // ClearedFields returns all nullable fields that were cleared during this
  27908. // mutation.
  27909. func (m *SopTaskMutation) ClearedFields() []string {
  27910. var fields []string
  27911. if m.FieldCleared(soptask.FieldStatus) {
  27912. fields = append(fields, soptask.FieldStatus)
  27913. }
  27914. if m.FieldCleared(soptask.FieldDeletedAt) {
  27915. fields = append(fields, soptask.FieldDeletedAt)
  27916. }
  27917. if m.FieldCleared(soptask.FieldBotWxidList) {
  27918. fields = append(fields, soptask.FieldBotWxidList)
  27919. }
  27920. if m.FieldCleared(soptask.FieldPlanStartTime) {
  27921. fields = append(fields, soptask.FieldPlanStartTime)
  27922. }
  27923. if m.FieldCleared(soptask.FieldPlanEndTime) {
  27924. fields = append(fields, soptask.FieldPlanEndTime)
  27925. }
  27926. if m.FieldCleared(soptask.FieldCreatorID) {
  27927. fields = append(fields, soptask.FieldCreatorID)
  27928. }
  27929. if m.FieldCleared(soptask.FieldOrganizationID) {
  27930. fields = append(fields, soptask.FieldOrganizationID)
  27931. }
  27932. if m.FieldCleared(soptask.FieldToken) {
  27933. fields = append(fields, soptask.FieldToken)
  27934. }
  27935. return fields
  27936. }
  27937. // FieldCleared returns a boolean indicating if a field with the given name was
  27938. // cleared in this mutation.
  27939. func (m *SopTaskMutation) FieldCleared(name string) bool {
  27940. _, ok := m.clearedFields[name]
  27941. return ok
  27942. }
  27943. // ClearField clears the value of the field with the given name. It returns an
  27944. // error if the field is not defined in the schema.
  27945. func (m *SopTaskMutation) ClearField(name string) error {
  27946. switch name {
  27947. case soptask.FieldStatus:
  27948. m.ClearStatus()
  27949. return nil
  27950. case soptask.FieldDeletedAt:
  27951. m.ClearDeletedAt()
  27952. return nil
  27953. case soptask.FieldBotWxidList:
  27954. m.ClearBotWxidList()
  27955. return nil
  27956. case soptask.FieldPlanStartTime:
  27957. m.ClearPlanStartTime()
  27958. return nil
  27959. case soptask.FieldPlanEndTime:
  27960. m.ClearPlanEndTime()
  27961. return nil
  27962. case soptask.FieldCreatorID:
  27963. m.ClearCreatorID()
  27964. return nil
  27965. case soptask.FieldOrganizationID:
  27966. m.ClearOrganizationID()
  27967. return nil
  27968. case soptask.FieldToken:
  27969. m.ClearToken()
  27970. return nil
  27971. }
  27972. return fmt.Errorf("unknown SopTask nullable field %s", name)
  27973. }
  27974. // ResetField resets all changes in the mutation for the field with the given name.
  27975. // It returns an error if the field is not defined in the schema.
  27976. func (m *SopTaskMutation) ResetField(name string) error {
  27977. switch name {
  27978. case soptask.FieldCreatedAt:
  27979. m.ResetCreatedAt()
  27980. return nil
  27981. case soptask.FieldUpdatedAt:
  27982. m.ResetUpdatedAt()
  27983. return nil
  27984. case soptask.FieldStatus:
  27985. m.ResetStatus()
  27986. return nil
  27987. case soptask.FieldDeletedAt:
  27988. m.ResetDeletedAt()
  27989. return nil
  27990. case soptask.FieldName:
  27991. m.ResetName()
  27992. return nil
  27993. case soptask.FieldBotWxidList:
  27994. m.ResetBotWxidList()
  27995. return nil
  27996. case soptask.FieldType:
  27997. m.ResetType()
  27998. return nil
  27999. case soptask.FieldPlanStartTime:
  28000. m.ResetPlanStartTime()
  28001. return nil
  28002. case soptask.FieldPlanEndTime:
  28003. m.ResetPlanEndTime()
  28004. return nil
  28005. case soptask.FieldCreatorID:
  28006. m.ResetCreatorID()
  28007. return nil
  28008. case soptask.FieldOrganizationID:
  28009. m.ResetOrganizationID()
  28010. return nil
  28011. case soptask.FieldToken:
  28012. m.ResetToken()
  28013. return nil
  28014. }
  28015. return fmt.Errorf("unknown SopTask field %s", name)
  28016. }
  28017. // AddedEdges returns all edge names that were set/added in this mutation.
  28018. func (m *SopTaskMutation) AddedEdges() []string {
  28019. edges := make([]string, 0, 1)
  28020. if m.task_stages != nil {
  28021. edges = append(edges, soptask.EdgeTaskStages)
  28022. }
  28023. return edges
  28024. }
  28025. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28026. // name in this mutation.
  28027. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  28028. switch name {
  28029. case soptask.EdgeTaskStages:
  28030. ids := make([]ent.Value, 0, len(m.task_stages))
  28031. for id := range m.task_stages {
  28032. ids = append(ids, id)
  28033. }
  28034. return ids
  28035. }
  28036. return nil
  28037. }
  28038. // RemovedEdges returns all edge names that were removed in this mutation.
  28039. func (m *SopTaskMutation) RemovedEdges() []string {
  28040. edges := make([]string, 0, 1)
  28041. if m.removedtask_stages != nil {
  28042. edges = append(edges, soptask.EdgeTaskStages)
  28043. }
  28044. return edges
  28045. }
  28046. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28047. // the given name in this mutation.
  28048. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  28049. switch name {
  28050. case soptask.EdgeTaskStages:
  28051. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  28052. for id := range m.removedtask_stages {
  28053. ids = append(ids, id)
  28054. }
  28055. return ids
  28056. }
  28057. return nil
  28058. }
  28059. // ClearedEdges returns all edge names that were cleared in this mutation.
  28060. func (m *SopTaskMutation) ClearedEdges() []string {
  28061. edges := make([]string, 0, 1)
  28062. if m.clearedtask_stages {
  28063. edges = append(edges, soptask.EdgeTaskStages)
  28064. }
  28065. return edges
  28066. }
  28067. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28068. // was cleared in this mutation.
  28069. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  28070. switch name {
  28071. case soptask.EdgeTaskStages:
  28072. return m.clearedtask_stages
  28073. }
  28074. return false
  28075. }
  28076. // ClearEdge clears the value of the edge with the given name. It returns an error
  28077. // if that edge is not defined in the schema.
  28078. func (m *SopTaskMutation) ClearEdge(name string) error {
  28079. switch name {
  28080. }
  28081. return fmt.Errorf("unknown SopTask unique edge %s", name)
  28082. }
  28083. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28084. // It returns an error if the edge is not defined in the schema.
  28085. func (m *SopTaskMutation) ResetEdge(name string) error {
  28086. switch name {
  28087. case soptask.EdgeTaskStages:
  28088. m.ResetTaskStages()
  28089. return nil
  28090. }
  28091. return fmt.Errorf("unknown SopTask edge %s", name)
  28092. }
  28093. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  28094. type TokenMutation struct {
  28095. config
  28096. op Op
  28097. typ string
  28098. id *uint64
  28099. created_at *time.Time
  28100. updated_at *time.Time
  28101. deleted_at *time.Time
  28102. expire_at *time.Time
  28103. token *string
  28104. mac *string
  28105. organization_id *uint64
  28106. addorganization_id *int64
  28107. custom_agent_base *string
  28108. custom_agent_key *string
  28109. openai_base *string
  28110. openai_key *string
  28111. clearedFields map[string]struct{}
  28112. agent *uint64
  28113. clearedagent bool
  28114. done bool
  28115. oldValue func(context.Context) (*Token, error)
  28116. predicates []predicate.Token
  28117. }
  28118. var _ ent.Mutation = (*TokenMutation)(nil)
  28119. // tokenOption allows management of the mutation configuration using functional options.
  28120. type tokenOption func(*TokenMutation)
  28121. // newTokenMutation creates new mutation for the Token entity.
  28122. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  28123. m := &TokenMutation{
  28124. config: c,
  28125. op: op,
  28126. typ: TypeToken,
  28127. clearedFields: make(map[string]struct{}),
  28128. }
  28129. for _, opt := range opts {
  28130. opt(m)
  28131. }
  28132. return m
  28133. }
  28134. // withTokenID sets the ID field of the mutation.
  28135. func withTokenID(id uint64) tokenOption {
  28136. return func(m *TokenMutation) {
  28137. var (
  28138. err error
  28139. once sync.Once
  28140. value *Token
  28141. )
  28142. m.oldValue = func(ctx context.Context) (*Token, error) {
  28143. once.Do(func() {
  28144. if m.done {
  28145. err = errors.New("querying old values post mutation is not allowed")
  28146. } else {
  28147. value, err = m.Client().Token.Get(ctx, id)
  28148. }
  28149. })
  28150. return value, err
  28151. }
  28152. m.id = &id
  28153. }
  28154. }
  28155. // withToken sets the old Token of the mutation.
  28156. func withToken(node *Token) tokenOption {
  28157. return func(m *TokenMutation) {
  28158. m.oldValue = func(context.Context) (*Token, error) {
  28159. return node, nil
  28160. }
  28161. m.id = &node.ID
  28162. }
  28163. }
  28164. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28165. // executed in a transaction (ent.Tx), a transactional client is returned.
  28166. func (m TokenMutation) Client() *Client {
  28167. client := &Client{config: m.config}
  28168. client.init()
  28169. return client
  28170. }
  28171. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28172. // it returns an error otherwise.
  28173. func (m TokenMutation) Tx() (*Tx, error) {
  28174. if _, ok := m.driver.(*txDriver); !ok {
  28175. return nil, errors.New("ent: mutation is not running in a transaction")
  28176. }
  28177. tx := &Tx{config: m.config}
  28178. tx.init()
  28179. return tx, nil
  28180. }
  28181. // SetID sets the value of the id field. Note that this
  28182. // operation is only accepted on creation of Token entities.
  28183. func (m *TokenMutation) SetID(id uint64) {
  28184. m.id = &id
  28185. }
  28186. // ID returns the ID value in the mutation. Note that the ID is only available
  28187. // if it was provided to the builder or after it was returned from the database.
  28188. func (m *TokenMutation) ID() (id uint64, exists bool) {
  28189. if m.id == nil {
  28190. return
  28191. }
  28192. return *m.id, true
  28193. }
  28194. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28195. // That means, if the mutation is applied within a transaction with an isolation level such
  28196. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28197. // or updated by the mutation.
  28198. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  28199. switch {
  28200. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28201. id, exists := m.ID()
  28202. if exists {
  28203. return []uint64{id}, nil
  28204. }
  28205. fallthrough
  28206. case m.op.Is(OpUpdate | OpDelete):
  28207. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  28208. default:
  28209. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28210. }
  28211. }
  28212. // SetCreatedAt sets the "created_at" field.
  28213. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  28214. m.created_at = &t
  28215. }
  28216. // CreatedAt returns the value of the "created_at" field in the mutation.
  28217. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  28218. v := m.created_at
  28219. if v == nil {
  28220. return
  28221. }
  28222. return *v, true
  28223. }
  28224. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  28225. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28227. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28228. if !m.op.Is(OpUpdateOne) {
  28229. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28230. }
  28231. if m.id == nil || m.oldValue == nil {
  28232. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28233. }
  28234. oldValue, err := m.oldValue(ctx)
  28235. if err != nil {
  28236. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28237. }
  28238. return oldValue.CreatedAt, nil
  28239. }
  28240. // ResetCreatedAt resets all changes to the "created_at" field.
  28241. func (m *TokenMutation) ResetCreatedAt() {
  28242. m.created_at = nil
  28243. }
  28244. // SetUpdatedAt sets the "updated_at" field.
  28245. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  28246. m.updated_at = &t
  28247. }
  28248. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28249. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  28250. v := m.updated_at
  28251. if v == nil {
  28252. return
  28253. }
  28254. return *v, true
  28255. }
  28256. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  28257. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28259. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28260. if !m.op.Is(OpUpdateOne) {
  28261. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28262. }
  28263. if m.id == nil || m.oldValue == nil {
  28264. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28265. }
  28266. oldValue, err := m.oldValue(ctx)
  28267. if err != nil {
  28268. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28269. }
  28270. return oldValue.UpdatedAt, nil
  28271. }
  28272. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28273. func (m *TokenMutation) ResetUpdatedAt() {
  28274. m.updated_at = nil
  28275. }
  28276. // SetDeletedAt sets the "deleted_at" field.
  28277. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  28278. m.deleted_at = &t
  28279. }
  28280. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28281. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  28282. v := m.deleted_at
  28283. if v == nil {
  28284. return
  28285. }
  28286. return *v, true
  28287. }
  28288. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  28289. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28291. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28292. if !m.op.Is(OpUpdateOne) {
  28293. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28294. }
  28295. if m.id == nil || m.oldValue == nil {
  28296. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28297. }
  28298. oldValue, err := m.oldValue(ctx)
  28299. if err != nil {
  28300. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28301. }
  28302. return oldValue.DeletedAt, nil
  28303. }
  28304. // ClearDeletedAt clears the value of the "deleted_at" field.
  28305. func (m *TokenMutation) ClearDeletedAt() {
  28306. m.deleted_at = nil
  28307. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  28308. }
  28309. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28310. func (m *TokenMutation) DeletedAtCleared() bool {
  28311. _, ok := m.clearedFields[token.FieldDeletedAt]
  28312. return ok
  28313. }
  28314. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28315. func (m *TokenMutation) ResetDeletedAt() {
  28316. m.deleted_at = nil
  28317. delete(m.clearedFields, token.FieldDeletedAt)
  28318. }
  28319. // SetExpireAt sets the "expire_at" field.
  28320. func (m *TokenMutation) SetExpireAt(t time.Time) {
  28321. m.expire_at = &t
  28322. }
  28323. // ExpireAt returns the value of the "expire_at" field in the mutation.
  28324. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  28325. v := m.expire_at
  28326. if v == nil {
  28327. return
  28328. }
  28329. return *v, true
  28330. }
  28331. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  28332. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28334. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  28335. if !m.op.Is(OpUpdateOne) {
  28336. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  28337. }
  28338. if m.id == nil || m.oldValue == nil {
  28339. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  28340. }
  28341. oldValue, err := m.oldValue(ctx)
  28342. if err != nil {
  28343. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  28344. }
  28345. return oldValue.ExpireAt, nil
  28346. }
  28347. // ClearExpireAt clears the value of the "expire_at" field.
  28348. func (m *TokenMutation) ClearExpireAt() {
  28349. m.expire_at = nil
  28350. m.clearedFields[token.FieldExpireAt] = struct{}{}
  28351. }
  28352. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  28353. func (m *TokenMutation) ExpireAtCleared() bool {
  28354. _, ok := m.clearedFields[token.FieldExpireAt]
  28355. return ok
  28356. }
  28357. // ResetExpireAt resets all changes to the "expire_at" field.
  28358. func (m *TokenMutation) ResetExpireAt() {
  28359. m.expire_at = nil
  28360. delete(m.clearedFields, token.FieldExpireAt)
  28361. }
  28362. // SetToken sets the "token" field.
  28363. func (m *TokenMutation) SetToken(s string) {
  28364. m.token = &s
  28365. }
  28366. // Token returns the value of the "token" field in the mutation.
  28367. func (m *TokenMutation) Token() (r string, exists bool) {
  28368. v := m.token
  28369. if v == nil {
  28370. return
  28371. }
  28372. return *v, true
  28373. }
  28374. // OldToken returns the old "token" field's value of the Token entity.
  28375. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28377. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  28378. if !m.op.Is(OpUpdateOne) {
  28379. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  28380. }
  28381. if m.id == nil || m.oldValue == nil {
  28382. return v, errors.New("OldToken requires an ID field in the mutation")
  28383. }
  28384. oldValue, err := m.oldValue(ctx)
  28385. if err != nil {
  28386. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  28387. }
  28388. return oldValue.Token, nil
  28389. }
  28390. // ClearToken clears the value of the "token" field.
  28391. func (m *TokenMutation) ClearToken() {
  28392. m.token = nil
  28393. m.clearedFields[token.FieldToken] = struct{}{}
  28394. }
  28395. // TokenCleared returns if the "token" field was cleared in this mutation.
  28396. func (m *TokenMutation) TokenCleared() bool {
  28397. _, ok := m.clearedFields[token.FieldToken]
  28398. return ok
  28399. }
  28400. // ResetToken resets all changes to the "token" field.
  28401. func (m *TokenMutation) ResetToken() {
  28402. m.token = nil
  28403. delete(m.clearedFields, token.FieldToken)
  28404. }
  28405. // SetMAC sets the "mac" field.
  28406. func (m *TokenMutation) SetMAC(s string) {
  28407. m.mac = &s
  28408. }
  28409. // MAC returns the value of the "mac" field in the mutation.
  28410. func (m *TokenMutation) MAC() (r string, exists bool) {
  28411. v := m.mac
  28412. if v == nil {
  28413. return
  28414. }
  28415. return *v, true
  28416. }
  28417. // OldMAC returns the old "mac" field's value of the Token entity.
  28418. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28420. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  28421. if !m.op.Is(OpUpdateOne) {
  28422. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  28423. }
  28424. if m.id == nil || m.oldValue == nil {
  28425. return v, errors.New("OldMAC requires an ID field in the mutation")
  28426. }
  28427. oldValue, err := m.oldValue(ctx)
  28428. if err != nil {
  28429. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  28430. }
  28431. return oldValue.MAC, nil
  28432. }
  28433. // ClearMAC clears the value of the "mac" field.
  28434. func (m *TokenMutation) ClearMAC() {
  28435. m.mac = nil
  28436. m.clearedFields[token.FieldMAC] = struct{}{}
  28437. }
  28438. // MACCleared returns if the "mac" field was cleared in this mutation.
  28439. func (m *TokenMutation) MACCleared() bool {
  28440. _, ok := m.clearedFields[token.FieldMAC]
  28441. return ok
  28442. }
  28443. // ResetMAC resets all changes to the "mac" field.
  28444. func (m *TokenMutation) ResetMAC() {
  28445. m.mac = nil
  28446. delete(m.clearedFields, token.FieldMAC)
  28447. }
  28448. // SetOrganizationID sets the "organization_id" field.
  28449. func (m *TokenMutation) SetOrganizationID(u uint64) {
  28450. m.organization_id = &u
  28451. m.addorganization_id = nil
  28452. }
  28453. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28454. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  28455. v := m.organization_id
  28456. if v == nil {
  28457. return
  28458. }
  28459. return *v, true
  28460. }
  28461. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  28462. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28464. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28465. if !m.op.Is(OpUpdateOne) {
  28466. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28467. }
  28468. if m.id == nil || m.oldValue == nil {
  28469. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28470. }
  28471. oldValue, err := m.oldValue(ctx)
  28472. if err != nil {
  28473. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28474. }
  28475. return oldValue.OrganizationID, nil
  28476. }
  28477. // AddOrganizationID adds u to the "organization_id" field.
  28478. func (m *TokenMutation) AddOrganizationID(u int64) {
  28479. if m.addorganization_id != nil {
  28480. *m.addorganization_id += u
  28481. } else {
  28482. m.addorganization_id = &u
  28483. }
  28484. }
  28485. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28486. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  28487. v := m.addorganization_id
  28488. if v == nil {
  28489. return
  28490. }
  28491. return *v, true
  28492. }
  28493. // ResetOrganizationID resets all changes to the "organization_id" field.
  28494. func (m *TokenMutation) ResetOrganizationID() {
  28495. m.organization_id = nil
  28496. m.addorganization_id = nil
  28497. }
  28498. // SetAgentID sets the "agent_id" field.
  28499. func (m *TokenMutation) SetAgentID(u uint64) {
  28500. m.agent = &u
  28501. }
  28502. // AgentID returns the value of the "agent_id" field in the mutation.
  28503. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  28504. v := m.agent
  28505. if v == nil {
  28506. return
  28507. }
  28508. return *v, true
  28509. }
  28510. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  28511. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28513. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  28514. if !m.op.Is(OpUpdateOne) {
  28515. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  28516. }
  28517. if m.id == nil || m.oldValue == nil {
  28518. return v, errors.New("OldAgentID requires an ID field in the mutation")
  28519. }
  28520. oldValue, err := m.oldValue(ctx)
  28521. if err != nil {
  28522. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  28523. }
  28524. return oldValue.AgentID, nil
  28525. }
  28526. // ResetAgentID resets all changes to the "agent_id" field.
  28527. func (m *TokenMutation) ResetAgentID() {
  28528. m.agent = nil
  28529. }
  28530. // SetCustomAgentBase sets the "custom_agent_base" field.
  28531. func (m *TokenMutation) SetCustomAgentBase(s string) {
  28532. m.custom_agent_base = &s
  28533. }
  28534. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  28535. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  28536. v := m.custom_agent_base
  28537. if v == nil {
  28538. return
  28539. }
  28540. return *v, true
  28541. }
  28542. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  28543. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28545. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  28546. if !m.op.Is(OpUpdateOne) {
  28547. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  28548. }
  28549. if m.id == nil || m.oldValue == nil {
  28550. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  28551. }
  28552. oldValue, err := m.oldValue(ctx)
  28553. if err != nil {
  28554. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  28555. }
  28556. return oldValue.CustomAgentBase, nil
  28557. }
  28558. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  28559. func (m *TokenMutation) ClearCustomAgentBase() {
  28560. m.custom_agent_base = nil
  28561. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  28562. }
  28563. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  28564. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  28565. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  28566. return ok
  28567. }
  28568. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  28569. func (m *TokenMutation) ResetCustomAgentBase() {
  28570. m.custom_agent_base = nil
  28571. delete(m.clearedFields, token.FieldCustomAgentBase)
  28572. }
  28573. // SetCustomAgentKey sets the "custom_agent_key" field.
  28574. func (m *TokenMutation) SetCustomAgentKey(s string) {
  28575. m.custom_agent_key = &s
  28576. }
  28577. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  28578. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  28579. v := m.custom_agent_key
  28580. if v == nil {
  28581. return
  28582. }
  28583. return *v, true
  28584. }
  28585. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  28586. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28588. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  28589. if !m.op.Is(OpUpdateOne) {
  28590. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  28591. }
  28592. if m.id == nil || m.oldValue == nil {
  28593. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  28594. }
  28595. oldValue, err := m.oldValue(ctx)
  28596. if err != nil {
  28597. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  28598. }
  28599. return oldValue.CustomAgentKey, nil
  28600. }
  28601. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  28602. func (m *TokenMutation) ClearCustomAgentKey() {
  28603. m.custom_agent_key = nil
  28604. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  28605. }
  28606. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  28607. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  28608. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  28609. return ok
  28610. }
  28611. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  28612. func (m *TokenMutation) ResetCustomAgentKey() {
  28613. m.custom_agent_key = nil
  28614. delete(m.clearedFields, token.FieldCustomAgentKey)
  28615. }
  28616. // SetOpenaiBase sets the "openai_base" field.
  28617. func (m *TokenMutation) SetOpenaiBase(s string) {
  28618. m.openai_base = &s
  28619. }
  28620. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  28621. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  28622. v := m.openai_base
  28623. if v == nil {
  28624. return
  28625. }
  28626. return *v, true
  28627. }
  28628. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  28629. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28631. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  28632. if !m.op.Is(OpUpdateOne) {
  28633. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  28634. }
  28635. if m.id == nil || m.oldValue == nil {
  28636. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  28637. }
  28638. oldValue, err := m.oldValue(ctx)
  28639. if err != nil {
  28640. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  28641. }
  28642. return oldValue.OpenaiBase, nil
  28643. }
  28644. // ClearOpenaiBase clears the value of the "openai_base" field.
  28645. func (m *TokenMutation) ClearOpenaiBase() {
  28646. m.openai_base = nil
  28647. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  28648. }
  28649. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  28650. func (m *TokenMutation) OpenaiBaseCleared() bool {
  28651. _, ok := m.clearedFields[token.FieldOpenaiBase]
  28652. return ok
  28653. }
  28654. // ResetOpenaiBase resets all changes to the "openai_base" field.
  28655. func (m *TokenMutation) ResetOpenaiBase() {
  28656. m.openai_base = nil
  28657. delete(m.clearedFields, token.FieldOpenaiBase)
  28658. }
  28659. // SetOpenaiKey sets the "openai_key" field.
  28660. func (m *TokenMutation) SetOpenaiKey(s string) {
  28661. m.openai_key = &s
  28662. }
  28663. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  28664. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  28665. v := m.openai_key
  28666. if v == nil {
  28667. return
  28668. }
  28669. return *v, true
  28670. }
  28671. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  28672. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28674. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  28675. if !m.op.Is(OpUpdateOne) {
  28676. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  28677. }
  28678. if m.id == nil || m.oldValue == nil {
  28679. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  28680. }
  28681. oldValue, err := m.oldValue(ctx)
  28682. if err != nil {
  28683. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  28684. }
  28685. return oldValue.OpenaiKey, nil
  28686. }
  28687. // ClearOpenaiKey clears the value of the "openai_key" field.
  28688. func (m *TokenMutation) ClearOpenaiKey() {
  28689. m.openai_key = nil
  28690. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  28691. }
  28692. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  28693. func (m *TokenMutation) OpenaiKeyCleared() bool {
  28694. _, ok := m.clearedFields[token.FieldOpenaiKey]
  28695. return ok
  28696. }
  28697. // ResetOpenaiKey resets all changes to the "openai_key" field.
  28698. func (m *TokenMutation) ResetOpenaiKey() {
  28699. m.openai_key = nil
  28700. delete(m.clearedFields, token.FieldOpenaiKey)
  28701. }
  28702. // ClearAgent clears the "agent" edge to the Agent entity.
  28703. func (m *TokenMutation) ClearAgent() {
  28704. m.clearedagent = true
  28705. m.clearedFields[token.FieldAgentID] = struct{}{}
  28706. }
  28707. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  28708. func (m *TokenMutation) AgentCleared() bool {
  28709. return m.clearedagent
  28710. }
  28711. // AgentIDs returns the "agent" edge IDs in the mutation.
  28712. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28713. // AgentID instead. It exists only for internal usage by the builders.
  28714. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  28715. if id := m.agent; id != nil {
  28716. ids = append(ids, *id)
  28717. }
  28718. return
  28719. }
  28720. // ResetAgent resets all changes to the "agent" edge.
  28721. func (m *TokenMutation) ResetAgent() {
  28722. m.agent = nil
  28723. m.clearedagent = false
  28724. }
  28725. // Where appends a list predicates to the TokenMutation builder.
  28726. func (m *TokenMutation) Where(ps ...predicate.Token) {
  28727. m.predicates = append(m.predicates, ps...)
  28728. }
  28729. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  28730. // users can use type-assertion to append predicates that do not depend on any generated package.
  28731. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  28732. p := make([]predicate.Token, len(ps))
  28733. for i := range ps {
  28734. p[i] = ps[i]
  28735. }
  28736. m.Where(p...)
  28737. }
  28738. // Op returns the operation name.
  28739. func (m *TokenMutation) Op() Op {
  28740. return m.op
  28741. }
  28742. // SetOp allows setting the mutation operation.
  28743. func (m *TokenMutation) SetOp(op Op) {
  28744. m.op = op
  28745. }
  28746. // Type returns the node type of this mutation (Token).
  28747. func (m *TokenMutation) Type() string {
  28748. return m.typ
  28749. }
  28750. // Fields returns all fields that were changed during this mutation. Note that in
  28751. // order to get all numeric fields that were incremented/decremented, call
  28752. // AddedFields().
  28753. func (m *TokenMutation) Fields() []string {
  28754. fields := make([]string, 0, 12)
  28755. if m.created_at != nil {
  28756. fields = append(fields, token.FieldCreatedAt)
  28757. }
  28758. if m.updated_at != nil {
  28759. fields = append(fields, token.FieldUpdatedAt)
  28760. }
  28761. if m.deleted_at != nil {
  28762. fields = append(fields, token.FieldDeletedAt)
  28763. }
  28764. if m.expire_at != nil {
  28765. fields = append(fields, token.FieldExpireAt)
  28766. }
  28767. if m.token != nil {
  28768. fields = append(fields, token.FieldToken)
  28769. }
  28770. if m.mac != nil {
  28771. fields = append(fields, token.FieldMAC)
  28772. }
  28773. if m.organization_id != nil {
  28774. fields = append(fields, token.FieldOrganizationID)
  28775. }
  28776. if m.agent != nil {
  28777. fields = append(fields, token.FieldAgentID)
  28778. }
  28779. if m.custom_agent_base != nil {
  28780. fields = append(fields, token.FieldCustomAgentBase)
  28781. }
  28782. if m.custom_agent_key != nil {
  28783. fields = append(fields, token.FieldCustomAgentKey)
  28784. }
  28785. if m.openai_base != nil {
  28786. fields = append(fields, token.FieldOpenaiBase)
  28787. }
  28788. if m.openai_key != nil {
  28789. fields = append(fields, token.FieldOpenaiKey)
  28790. }
  28791. return fields
  28792. }
  28793. // Field returns the value of a field with the given name. The second boolean
  28794. // return value indicates that this field was not set, or was not defined in the
  28795. // schema.
  28796. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  28797. switch name {
  28798. case token.FieldCreatedAt:
  28799. return m.CreatedAt()
  28800. case token.FieldUpdatedAt:
  28801. return m.UpdatedAt()
  28802. case token.FieldDeletedAt:
  28803. return m.DeletedAt()
  28804. case token.FieldExpireAt:
  28805. return m.ExpireAt()
  28806. case token.FieldToken:
  28807. return m.Token()
  28808. case token.FieldMAC:
  28809. return m.MAC()
  28810. case token.FieldOrganizationID:
  28811. return m.OrganizationID()
  28812. case token.FieldAgentID:
  28813. return m.AgentID()
  28814. case token.FieldCustomAgentBase:
  28815. return m.CustomAgentBase()
  28816. case token.FieldCustomAgentKey:
  28817. return m.CustomAgentKey()
  28818. case token.FieldOpenaiBase:
  28819. return m.OpenaiBase()
  28820. case token.FieldOpenaiKey:
  28821. return m.OpenaiKey()
  28822. }
  28823. return nil, false
  28824. }
  28825. // OldField returns the old value of the field from the database. An error is
  28826. // returned if the mutation operation is not UpdateOne, or the query to the
  28827. // database failed.
  28828. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28829. switch name {
  28830. case token.FieldCreatedAt:
  28831. return m.OldCreatedAt(ctx)
  28832. case token.FieldUpdatedAt:
  28833. return m.OldUpdatedAt(ctx)
  28834. case token.FieldDeletedAt:
  28835. return m.OldDeletedAt(ctx)
  28836. case token.FieldExpireAt:
  28837. return m.OldExpireAt(ctx)
  28838. case token.FieldToken:
  28839. return m.OldToken(ctx)
  28840. case token.FieldMAC:
  28841. return m.OldMAC(ctx)
  28842. case token.FieldOrganizationID:
  28843. return m.OldOrganizationID(ctx)
  28844. case token.FieldAgentID:
  28845. return m.OldAgentID(ctx)
  28846. case token.FieldCustomAgentBase:
  28847. return m.OldCustomAgentBase(ctx)
  28848. case token.FieldCustomAgentKey:
  28849. return m.OldCustomAgentKey(ctx)
  28850. case token.FieldOpenaiBase:
  28851. return m.OldOpenaiBase(ctx)
  28852. case token.FieldOpenaiKey:
  28853. return m.OldOpenaiKey(ctx)
  28854. }
  28855. return nil, fmt.Errorf("unknown Token field %s", name)
  28856. }
  28857. // SetField sets the value of a field with the given name. It returns an error if
  28858. // the field is not defined in the schema, or if the type mismatched the field
  28859. // type.
  28860. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  28861. switch name {
  28862. case token.FieldCreatedAt:
  28863. v, ok := value.(time.Time)
  28864. if !ok {
  28865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28866. }
  28867. m.SetCreatedAt(v)
  28868. return nil
  28869. case token.FieldUpdatedAt:
  28870. v, ok := value.(time.Time)
  28871. if !ok {
  28872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28873. }
  28874. m.SetUpdatedAt(v)
  28875. return nil
  28876. case token.FieldDeletedAt:
  28877. v, ok := value.(time.Time)
  28878. if !ok {
  28879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28880. }
  28881. m.SetDeletedAt(v)
  28882. return nil
  28883. case token.FieldExpireAt:
  28884. v, ok := value.(time.Time)
  28885. if !ok {
  28886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28887. }
  28888. m.SetExpireAt(v)
  28889. return nil
  28890. case token.FieldToken:
  28891. v, ok := value.(string)
  28892. if !ok {
  28893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28894. }
  28895. m.SetToken(v)
  28896. return nil
  28897. case token.FieldMAC:
  28898. v, ok := value.(string)
  28899. if !ok {
  28900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28901. }
  28902. m.SetMAC(v)
  28903. return nil
  28904. case token.FieldOrganizationID:
  28905. v, ok := value.(uint64)
  28906. if !ok {
  28907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28908. }
  28909. m.SetOrganizationID(v)
  28910. return nil
  28911. case token.FieldAgentID:
  28912. v, ok := value.(uint64)
  28913. if !ok {
  28914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28915. }
  28916. m.SetAgentID(v)
  28917. return nil
  28918. case token.FieldCustomAgentBase:
  28919. v, ok := value.(string)
  28920. if !ok {
  28921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28922. }
  28923. m.SetCustomAgentBase(v)
  28924. return nil
  28925. case token.FieldCustomAgentKey:
  28926. v, ok := value.(string)
  28927. if !ok {
  28928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28929. }
  28930. m.SetCustomAgentKey(v)
  28931. return nil
  28932. case token.FieldOpenaiBase:
  28933. v, ok := value.(string)
  28934. if !ok {
  28935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28936. }
  28937. m.SetOpenaiBase(v)
  28938. return nil
  28939. case token.FieldOpenaiKey:
  28940. v, ok := value.(string)
  28941. if !ok {
  28942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28943. }
  28944. m.SetOpenaiKey(v)
  28945. return nil
  28946. }
  28947. return fmt.Errorf("unknown Token field %s", name)
  28948. }
  28949. // AddedFields returns all numeric fields that were incremented/decremented during
  28950. // this mutation.
  28951. func (m *TokenMutation) AddedFields() []string {
  28952. var fields []string
  28953. if m.addorganization_id != nil {
  28954. fields = append(fields, token.FieldOrganizationID)
  28955. }
  28956. return fields
  28957. }
  28958. // AddedField returns the numeric value that was incremented/decremented on a field
  28959. // with the given name. The second boolean return value indicates that this field
  28960. // was not set, or was not defined in the schema.
  28961. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  28962. switch name {
  28963. case token.FieldOrganizationID:
  28964. return m.AddedOrganizationID()
  28965. }
  28966. return nil, false
  28967. }
  28968. // AddField adds the value to the field with the given name. It returns an error if
  28969. // the field is not defined in the schema, or if the type mismatched the field
  28970. // type.
  28971. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  28972. switch name {
  28973. case token.FieldOrganizationID:
  28974. v, ok := value.(int64)
  28975. if !ok {
  28976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28977. }
  28978. m.AddOrganizationID(v)
  28979. return nil
  28980. }
  28981. return fmt.Errorf("unknown Token numeric field %s", name)
  28982. }
  28983. // ClearedFields returns all nullable fields that were cleared during this
  28984. // mutation.
  28985. func (m *TokenMutation) ClearedFields() []string {
  28986. var fields []string
  28987. if m.FieldCleared(token.FieldDeletedAt) {
  28988. fields = append(fields, token.FieldDeletedAt)
  28989. }
  28990. if m.FieldCleared(token.FieldExpireAt) {
  28991. fields = append(fields, token.FieldExpireAt)
  28992. }
  28993. if m.FieldCleared(token.FieldToken) {
  28994. fields = append(fields, token.FieldToken)
  28995. }
  28996. if m.FieldCleared(token.FieldMAC) {
  28997. fields = append(fields, token.FieldMAC)
  28998. }
  28999. if m.FieldCleared(token.FieldCustomAgentBase) {
  29000. fields = append(fields, token.FieldCustomAgentBase)
  29001. }
  29002. if m.FieldCleared(token.FieldCustomAgentKey) {
  29003. fields = append(fields, token.FieldCustomAgentKey)
  29004. }
  29005. if m.FieldCleared(token.FieldOpenaiBase) {
  29006. fields = append(fields, token.FieldOpenaiBase)
  29007. }
  29008. if m.FieldCleared(token.FieldOpenaiKey) {
  29009. fields = append(fields, token.FieldOpenaiKey)
  29010. }
  29011. return fields
  29012. }
  29013. // FieldCleared returns a boolean indicating if a field with the given name was
  29014. // cleared in this mutation.
  29015. func (m *TokenMutation) FieldCleared(name string) bool {
  29016. _, ok := m.clearedFields[name]
  29017. return ok
  29018. }
  29019. // ClearField clears the value of the field with the given name. It returns an
  29020. // error if the field is not defined in the schema.
  29021. func (m *TokenMutation) ClearField(name string) error {
  29022. switch name {
  29023. case token.FieldDeletedAt:
  29024. m.ClearDeletedAt()
  29025. return nil
  29026. case token.FieldExpireAt:
  29027. m.ClearExpireAt()
  29028. return nil
  29029. case token.FieldToken:
  29030. m.ClearToken()
  29031. return nil
  29032. case token.FieldMAC:
  29033. m.ClearMAC()
  29034. return nil
  29035. case token.FieldCustomAgentBase:
  29036. m.ClearCustomAgentBase()
  29037. return nil
  29038. case token.FieldCustomAgentKey:
  29039. m.ClearCustomAgentKey()
  29040. return nil
  29041. case token.FieldOpenaiBase:
  29042. m.ClearOpenaiBase()
  29043. return nil
  29044. case token.FieldOpenaiKey:
  29045. m.ClearOpenaiKey()
  29046. return nil
  29047. }
  29048. return fmt.Errorf("unknown Token nullable field %s", name)
  29049. }
  29050. // ResetField resets all changes in the mutation for the field with the given name.
  29051. // It returns an error if the field is not defined in the schema.
  29052. func (m *TokenMutation) ResetField(name string) error {
  29053. switch name {
  29054. case token.FieldCreatedAt:
  29055. m.ResetCreatedAt()
  29056. return nil
  29057. case token.FieldUpdatedAt:
  29058. m.ResetUpdatedAt()
  29059. return nil
  29060. case token.FieldDeletedAt:
  29061. m.ResetDeletedAt()
  29062. return nil
  29063. case token.FieldExpireAt:
  29064. m.ResetExpireAt()
  29065. return nil
  29066. case token.FieldToken:
  29067. m.ResetToken()
  29068. return nil
  29069. case token.FieldMAC:
  29070. m.ResetMAC()
  29071. return nil
  29072. case token.FieldOrganizationID:
  29073. m.ResetOrganizationID()
  29074. return nil
  29075. case token.FieldAgentID:
  29076. m.ResetAgentID()
  29077. return nil
  29078. case token.FieldCustomAgentBase:
  29079. m.ResetCustomAgentBase()
  29080. return nil
  29081. case token.FieldCustomAgentKey:
  29082. m.ResetCustomAgentKey()
  29083. return nil
  29084. case token.FieldOpenaiBase:
  29085. m.ResetOpenaiBase()
  29086. return nil
  29087. case token.FieldOpenaiKey:
  29088. m.ResetOpenaiKey()
  29089. return nil
  29090. }
  29091. return fmt.Errorf("unknown Token field %s", name)
  29092. }
  29093. // AddedEdges returns all edge names that were set/added in this mutation.
  29094. func (m *TokenMutation) AddedEdges() []string {
  29095. edges := make([]string, 0, 1)
  29096. if m.agent != nil {
  29097. edges = append(edges, token.EdgeAgent)
  29098. }
  29099. return edges
  29100. }
  29101. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29102. // name in this mutation.
  29103. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  29104. switch name {
  29105. case token.EdgeAgent:
  29106. if id := m.agent; id != nil {
  29107. return []ent.Value{*id}
  29108. }
  29109. }
  29110. return nil
  29111. }
  29112. // RemovedEdges returns all edge names that were removed in this mutation.
  29113. func (m *TokenMutation) RemovedEdges() []string {
  29114. edges := make([]string, 0, 1)
  29115. return edges
  29116. }
  29117. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29118. // the given name in this mutation.
  29119. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  29120. return nil
  29121. }
  29122. // ClearedEdges returns all edge names that were cleared in this mutation.
  29123. func (m *TokenMutation) ClearedEdges() []string {
  29124. edges := make([]string, 0, 1)
  29125. if m.clearedagent {
  29126. edges = append(edges, token.EdgeAgent)
  29127. }
  29128. return edges
  29129. }
  29130. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29131. // was cleared in this mutation.
  29132. func (m *TokenMutation) EdgeCleared(name string) bool {
  29133. switch name {
  29134. case token.EdgeAgent:
  29135. return m.clearedagent
  29136. }
  29137. return false
  29138. }
  29139. // ClearEdge clears the value of the edge with the given name. It returns an error
  29140. // if that edge is not defined in the schema.
  29141. func (m *TokenMutation) ClearEdge(name string) error {
  29142. switch name {
  29143. case token.EdgeAgent:
  29144. m.ClearAgent()
  29145. return nil
  29146. }
  29147. return fmt.Errorf("unknown Token unique edge %s", name)
  29148. }
  29149. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29150. // It returns an error if the edge is not defined in the schema.
  29151. func (m *TokenMutation) ResetEdge(name string) error {
  29152. switch name {
  29153. case token.EdgeAgent:
  29154. m.ResetAgent()
  29155. return nil
  29156. }
  29157. return fmt.Errorf("unknown Token edge %s", name)
  29158. }
  29159. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  29160. type TutorialMutation struct {
  29161. config
  29162. op Op
  29163. typ string
  29164. id *uint64
  29165. created_at *time.Time
  29166. updated_at *time.Time
  29167. deleted_at *time.Time
  29168. index *int
  29169. addindex *int
  29170. title *string
  29171. content *string
  29172. organization_id *uint64
  29173. addorganization_id *int64
  29174. clearedFields map[string]struct{}
  29175. employee *uint64
  29176. clearedemployee bool
  29177. done bool
  29178. oldValue func(context.Context) (*Tutorial, error)
  29179. predicates []predicate.Tutorial
  29180. }
  29181. var _ ent.Mutation = (*TutorialMutation)(nil)
  29182. // tutorialOption allows management of the mutation configuration using functional options.
  29183. type tutorialOption func(*TutorialMutation)
  29184. // newTutorialMutation creates new mutation for the Tutorial entity.
  29185. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  29186. m := &TutorialMutation{
  29187. config: c,
  29188. op: op,
  29189. typ: TypeTutorial,
  29190. clearedFields: make(map[string]struct{}),
  29191. }
  29192. for _, opt := range opts {
  29193. opt(m)
  29194. }
  29195. return m
  29196. }
  29197. // withTutorialID sets the ID field of the mutation.
  29198. func withTutorialID(id uint64) tutorialOption {
  29199. return func(m *TutorialMutation) {
  29200. var (
  29201. err error
  29202. once sync.Once
  29203. value *Tutorial
  29204. )
  29205. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  29206. once.Do(func() {
  29207. if m.done {
  29208. err = errors.New("querying old values post mutation is not allowed")
  29209. } else {
  29210. value, err = m.Client().Tutorial.Get(ctx, id)
  29211. }
  29212. })
  29213. return value, err
  29214. }
  29215. m.id = &id
  29216. }
  29217. }
  29218. // withTutorial sets the old Tutorial of the mutation.
  29219. func withTutorial(node *Tutorial) tutorialOption {
  29220. return func(m *TutorialMutation) {
  29221. m.oldValue = func(context.Context) (*Tutorial, error) {
  29222. return node, nil
  29223. }
  29224. m.id = &node.ID
  29225. }
  29226. }
  29227. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29228. // executed in a transaction (ent.Tx), a transactional client is returned.
  29229. func (m TutorialMutation) Client() *Client {
  29230. client := &Client{config: m.config}
  29231. client.init()
  29232. return client
  29233. }
  29234. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29235. // it returns an error otherwise.
  29236. func (m TutorialMutation) Tx() (*Tx, error) {
  29237. if _, ok := m.driver.(*txDriver); !ok {
  29238. return nil, errors.New("ent: mutation is not running in a transaction")
  29239. }
  29240. tx := &Tx{config: m.config}
  29241. tx.init()
  29242. return tx, nil
  29243. }
  29244. // SetID sets the value of the id field. Note that this
  29245. // operation is only accepted on creation of Tutorial entities.
  29246. func (m *TutorialMutation) SetID(id uint64) {
  29247. m.id = &id
  29248. }
  29249. // ID returns the ID value in the mutation. Note that the ID is only available
  29250. // if it was provided to the builder or after it was returned from the database.
  29251. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  29252. if m.id == nil {
  29253. return
  29254. }
  29255. return *m.id, true
  29256. }
  29257. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29258. // That means, if the mutation is applied within a transaction with an isolation level such
  29259. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29260. // or updated by the mutation.
  29261. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  29262. switch {
  29263. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29264. id, exists := m.ID()
  29265. if exists {
  29266. return []uint64{id}, nil
  29267. }
  29268. fallthrough
  29269. case m.op.Is(OpUpdate | OpDelete):
  29270. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  29271. default:
  29272. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29273. }
  29274. }
  29275. // SetCreatedAt sets the "created_at" field.
  29276. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  29277. m.created_at = &t
  29278. }
  29279. // CreatedAt returns the value of the "created_at" field in the mutation.
  29280. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  29281. v := m.created_at
  29282. if v == nil {
  29283. return
  29284. }
  29285. return *v, true
  29286. }
  29287. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  29288. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29290. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29291. if !m.op.Is(OpUpdateOne) {
  29292. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29293. }
  29294. if m.id == nil || m.oldValue == nil {
  29295. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29296. }
  29297. oldValue, err := m.oldValue(ctx)
  29298. if err != nil {
  29299. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29300. }
  29301. return oldValue.CreatedAt, nil
  29302. }
  29303. // ResetCreatedAt resets all changes to the "created_at" field.
  29304. func (m *TutorialMutation) ResetCreatedAt() {
  29305. m.created_at = nil
  29306. }
  29307. // SetUpdatedAt sets the "updated_at" field.
  29308. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  29309. m.updated_at = &t
  29310. }
  29311. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29312. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  29313. v := m.updated_at
  29314. if v == nil {
  29315. return
  29316. }
  29317. return *v, true
  29318. }
  29319. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  29320. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29322. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29323. if !m.op.Is(OpUpdateOne) {
  29324. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29325. }
  29326. if m.id == nil || m.oldValue == nil {
  29327. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29328. }
  29329. oldValue, err := m.oldValue(ctx)
  29330. if err != nil {
  29331. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29332. }
  29333. return oldValue.UpdatedAt, nil
  29334. }
  29335. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29336. func (m *TutorialMutation) ResetUpdatedAt() {
  29337. m.updated_at = nil
  29338. }
  29339. // SetDeletedAt sets the "deleted_at" field.
  29340. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  29341. m.deleted_at = &t
  29342. }
  29343. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29344. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  29345. v := m.deleted_at
  29346. if v == nil {
  29347. return
  29348. }
  29349. return *v, true
  29350. }
  29351. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  29352. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29354. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29355. if !m.op.Is(OpUpdateOne) {
  29356. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29357. }
  29358. if m.id == nil || m.oldValue == nil {
  29359. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29360. }
  29361. oldValue, err := m.oldValue(ctx)
  29362. if err != nil {
  29363. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29364. }
  29365. return oldValue.DeletedAt, nil
  29366. }
  29367. // ClearDeletedAt clears the value of the "deleted_at" field.
  29368. func (m *TutorialMutation) ClearDeletedAt() {
  29369. m.deleted_at = nil
  29370. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  29371. }
  29372. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29373. func (m *TutorialMutation) DeletedAtCleared() bool {
  29374. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  29375. return ok
  29376. }
  29377. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29378. func (m *TutorialMutation) ResetDeletedAt() {
  29379. m.deleted_at = nil
  29380. delete(m.clearedFields, tutorial.FieldDeletedAt)
  29381. }
  29382. // SetEmployeeID sets the "employee_id" field.
  29383. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  29384. m.employee = &u
  29385. }
  29386. // EmployeeID returns the value of the "employee_id" field in the mutation.
  29387. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  29388. v := m.employee
  29389. if v == nil {
  29390. return
  29391. }
  29392. return *v, true
  29393. }
  29394. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  29395. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29397. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  29398. if !m.op.Is(OpUpdateOne) {
  29399. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  29400. }
  29401. if m.id == nil || m.oldValue == nil {
  29402. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  29403. }
  29404. oldValue, err := m.oldValue(ctx)
  29405. if err != nil {
  29406. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  29407. }
  29408. return oldValue.EmployeeID, nil
  29409. }
  29410. // ResetEmployeeID resets all changes to the "employee_id" field.
  29411. func (m *TutorialMutation) ResetEmployeeID() {
  29412. m.employee = nil
  29413. }
  29414. // SetIndex sets the "index" field.
  29415. func (m *TutorialMutation) SetIndex(i int) {
  29416. m.index = &i
  29417. m.addindex = nil
  29418. }
  29419. // Index returns the value of the "index" field in the mutation.
  29420. func (m *TutorialMutation) Index() (r int, exists bool) {
  29421. v := m.index
  29422. if v == nil {
  29423. return
  29424. }
  29425. return *v, true
  29426. }
  29427. // OldIndex returns the old "index" field's value of the Tutorial entity.
  29428. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29430. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  29431. if !m.op.Is(OpUpdateOne) {
  29432. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  29433. }
  29434. if m.id == nil || m.oldValue == nil {
  29435. return v, errors.New("OldIndex requires an ID field in the mutation")
  29436. }
  29437. oldValue, err := m.oldValue(ctx)
  29438. if err != nil {
  29439. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  29440. }
  29441. return oldValue.Index, nil
  29442. }
  29443. // AddIndex adds i to the "index" field.
  29444. func (m *TutorialMutation) AddIndex(i int) {
  29445. if m.addindex != nil {
  29446. *m.addindex += i
  29447. } else {
  29448. m.addindex = &i
  29449. }
  29450. }
  29451. // AddedIndex returns the value that was added to the "index" field in this mutation.
  29452. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  29453. v := m.addindex
  29454. if v == nil {
  29455. return
  29456. }
  29457. return *v, true
  29458. }
  29459. // ResetIndex resets all changes to the "index" field.
  29460. func (m *TutorialMutation) ResetIndex() {
  29461. m.index = nil
  29462. m.addindex = nil
  29463. }
  29464. // SetTitle sets the "title" field.
  29465. func (m *TutorialMutation) SetTitle(s string) {
  29466. m.title = &s
  29467. }
  29468. // Title returns the value of the "title" field in the mutation.
  29469. func (m *TutorialMutation) Title() (r string, exists bool) {
  29470. v := m.title
  29471. if v == nil {
  29472. return
  29473. }
  29474. return *v, true
  29475. }
  29476. // OldTitle returns the old "title" field's value of the Tutorial entity.
  29477. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29479. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  29480. if !m.op.Is(OpUpdateOne) {
  29481. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  29482. }
  29483. if m.id == nil || m.oldValue == nil {
  29484. return v, errors.New("OldTitle requires an ID field in the mutation")
  29485. }
  29486. oldValue, err := m.oldValue(ctx)
  29487. if err != nil {
  29488. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  29489. }
  29490. return oldValue.Title, nil
  29491. }
  29492. // ResetTitle resets all changes to the "title" field.
  29493. func (m *TutorialMutation) ResetTitle() {
  29494. m.title = nil
  29495. }
  29496. // SetContent sets the "content" field.
  29497. func (m *TutorialMutation) SetContent(s string) {
  29498. m.content = &s
  29499. }
  29500. // Content returns the value of the "content" field in the mutation.
  29501. func (m *TutorialMutation) Content() (r string, exists bool) {
  29502. v := m.content
  29503. if v == nil {
  29504. return
  29505. }
  29506. return *v, true
  29507. }
  29508. // OldContent returns the old "content" field's value of the Tutorial entity.
  29509. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29511. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  29512. if !m.op.Is(OpUpdateOne) {
  29513. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  29514. }
  29515. if m.id == nil || m.oldValue == nil {
  29516. return v, errors.New("OldContent requires an ID field in the mutation")
  29517. }
  29518. oldValue, err := m.oldValue(ctx)
  29519. if err != nil {
  29520. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  29521. }
  29522. return oldValue.Content, nil
  29523. }
  29524. // ResetContent resets all changes to the "content" field.
  29525. func (m *TutorialMutation) ResetContent() {
  29526. m.content = nil
  29527. }
  29528. // SetOrganizationID sets the "organization_id" field.
  29529. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  29530. m.organization_id = &u
  29531. m.addorganization_id = nil
  29532. }
  29533. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29534. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  29535. v := m.organization_id
  29536. if v == nil {
  29537. return
  29538. }
  29539. return *v, true
  29540. }
  29541. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  29542. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29544. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29545. if !m.op.Is(OpUpdateOne) {
  29546. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29547. }
  29548. if m.id == nil || m.oldValue == nil {
  29549. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29550. }
  29551. oldValue, err := m.oldValue(ctx)
  29552. if err != nil {
  29553. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29554. }
  29555. return oldValue.OrganizationID, nil
  29556. }
  29557. // AddOrganizationID adds u to the "organization_id" field.
  29558. func (m *TutorialMutation) AddOrganizationID(u int64) {
  29559. if m.addorganization_id != nil {
  29560. *m.addorganization_id += u
  29561. } else {
  29562. m.addorganization_id = &u
  29563. }
  29564. }
  29565. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29566. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  29567. v := m.addorganization_id
  29568. if v == nil {
  29569. return
  29570. }
  29571. return *v, true
  29572. }
  29573. // ResetOrganizationID resets all changes to the "organization_id" field.
  29574. func (m *TutorialMutation) ResetOrganizationID() {
  29575. m.organization_id = nil
  29576. m.addorganization_id = nil
  29577. }
  29578. // ClearEmployee clears the "employee" edge to the Employee entity.
  29579. func (m *TutorialMutation) ClearEmployee() {
  29580. m.clearedemployee = true
  29581. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  29582. }
  29583. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  29584. func (m *TutorialMutation) EmployeeCleared() bool {
  29585. return m.clearedemployee
  29586. }
  29587. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  29588. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29589. // EmployeeID instead. It exists only for internal usage by the builders.
  29590. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  29591. if id := m.employee; id != nil {
  29592. ids = append(ids, *id)
  29593. }
  29594. return
  29595. }
  29596. // ResetEmployee resets all changes to the "employee" edge.
  29597. func (m *TutorialMutation) ResetEmployee() {
  29598. m.employee = nil
  29599. m.clearedemployee = false
  29600. }
  29601. // Where appends a list predicates to the TutorialMutation builder.
  29602. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  29603. m.predicates = append(m.predicates, ps...)
  29604. }
  29605. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  29606. // users can use type-assertion to append predicates that do not depend on any generated package.
  29607. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  29608. p := make([]predicate.Tutorial, len(ps))
  29609. for i := range ps {
  29610. p[i] = ps[i]
  29611. }
  29612. m.Where(p...)
  29613. }
  29614. // Op returns the operation name.
  29615. func (m *TutorialMutation) Op() Op {
  29616. return m.op
  29617. }
  29618. // SetOp allows setting the mutation operation.
  29619. func (m *TutorialMutation) SetOp(op Op) {
  29620. m.op = op
  29621. }
  29622. // Type returns the node type of this mutation (Tutorial).
  29623. func (m *TutorialMutation) Type() string {
  29624. return m.typ
  29625. }
  29626. // Fields returns all fields that were changed during this mutation. Note that in
  29627. // order to get all numeric fields that were incremented/decremented, call
  29628. // AddedFields().
  29629. func (m *TutorialMutation) Fields() []string {
  29630. fields := make([]string, 0, 8)
  29631. if m.created_at != nil {
  29632. fields = append(fields, tutorial.FieldCreatedAt)
  29633. }
  29634. if m.updated_at != nil {
  29635. fields = append(fields, tutorial.FieldUpdatedAt)
  29636. }
  29637. if m.deleted_at != nil {
  29638. fields = append(fields, tutorial.FieldDeletedAt)
  29639. }
  29640. if m.employee != nil {
  29641. fields = append(fields, tutorial.FieldEmployeeID)
  29642. }
  29643. if m.index != nil {
  29644. fields = append(fields, tutorial.FieldIndex)
  29645. }
  29646. if m.title != nil {
  29647. fields = append(fields, tutorial.FieldTitle)
  29648. }
  29649. if m.content != nil {
  29650. fields = append(fields, tutorial.FieldContent)
  29651. }
  29652. if m.organization_id != nil {
  29653. fields = append(fields, tutorial.FieldOrganizationID)
  29654. }
  29655. return fields
  29656. }
  29657. // Field returns the value of a field with the given name. The second boolean
  29658. // return value indicates that this field was not set, or was not defined in the
  29659. // schema.
  29660. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  29661. switch name {
  29662. case tutorial.FieldCreatedAt:
  29663. return m.CreatedAt()
  29664. case tutorial.FieldUpdatedAt:
  29665. return m.UpdatedAt()
  29666. case tutorial.FieldDeletedAt:
  29667. return m.DeletedAt()
  29668. case tutorial.FieldEmployeeID:
  29669. return m.EmployeeID()
  29670. case tutorial.FieldIndex:
  29671. return m.Index()
  29672. case tutorial.FieldTitle:
  29673. return m.Title()
  29674. case tutorial.FieldContent:
  29675. return m.Content()
  29676. case tutorial.FieldOrganizationID:
  29677. return m.OrganizationID()
  29678. }
  29679. return nil, false
  29680. }
  29681. // OldField returns the old value of the field from the database. An error is
  29682. // returned if the mutation operation is not UpdateOne, or the query to the
  29683. // database failed.
  29684. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29685. switch name {
  29686. case tutorial.FieldCreatedAt:
  29687. return m.OldCreatedAt(ctx)
  29688. case tutorial.FieldUpdatedAt:
  29689. return m.OldUpdatedAt(ctx)
  29690. case tutorial.FieldDeletedAt:
  29691. return m.OldDeletedAt(ctx)
  29692. case tutorial.FieldEmployeeID:
  29693. return m.OldEmployeeID(ctx)
  29694. case tutorial.FieldIndex:
  29695. return m.OldIndex(ctx)
  29696. case tutorial.FieldTitle:
  29697. return m.OldTitle(ctx)
  29698. case tutorial.FieldContent:
  29699. return m.OldContent(ctx)
  29700. case tutorial.FieldOrganizationID:
  29701. return m.OldOrganizationID(ctx)
  29702. }
  29703. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  29704. }
  29705. // SetField sets the value of a field with the given name. It returns an error if
  29706. // the field is not defined in the schema, or if the type mismatched the field
  29707. // type.
  29708. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  29709. switch name {
  29710. case tutorial.FieldCreatedAt:
  29711. v, ok := value.(time.Time)
  29712. if !ok {
  29713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29714. }
  29715. m.SetCreatedAt(v)
  29716. return nil
  29717. case tutorial.FieldUpdatedAt:
  29718. v, ok := value.(time.Time)
  29719. if !ok {
  29720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29721. }
  29722. m.SetUpdatedAt(v)
  29723. return nil
  29724. case tutorial.FieldDeletedAt:
  29725. v, ok := value.(time.Time)
  29726. if !ok {
  29727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29728. }
  29729. m.SetDeletedAt(v)
  29730. return nil
  29731. case tutorial.FieldEmployeeID:
  29732. v, ok := value.(uint64)
  29733. if !ok {
  29734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29735. }
  29736. m.SetEmployeeID(v)
  29737. return nil
  29738. case tutorial.FieldIndex:
  29739. v, ok := value.(int)
  29740. if !ok {
  29741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29742. }
  29743. m.SetIndex(v)
  29744. return nil
  29745. case tutorial.FieldTitle:
  29746. v, ok := value.(string)
  29747. if !ok {
  29748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29749. }
  29750. m.SetTitle(v)
  29751. return nil
  29752. case tutorial.FieldContent:
  29753. v, ok := value.(string)
  29754. if !ok {
  29755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29756. }
  29757. m.SetContent(v)
  29758. return nil
  29759. case tutorial.FieldOrganizationID:
  29760. v, ok := value.(uint64)
  29761. if !ok {
  29762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29763. }
  29764. m.SetOrganizationID(v)
  29765. return nil
  29766. }
  29767. return fmt.Errorf("unknown Tutorial field %s", name)
  29768. }
  29769. // AddedFields returns all numeric fields that were incremented/decremented during
  29770. // this mutation.
  29771. func (m *TutorialMutation) AddedFields() []string {
  29772. var fields []string
  29773. if m.addindex != nil {
  29774. fields = append(fields, tutorial.FieldIndex)
  29775. }
  29776. if m.addorganization_id != nil {
  29777. fields = append(fields, tutorial.FieldOrganizationID)
  29778. }
  29779. return fields
  29780. }
  29781. // AddedField returns the numeric value that was incremented/decremented on a field
  29782. // with the given name. The second boolean return value indicates that this field
  29783. // was not set, or was not defined in the schema.
  29784. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  29785. switch name {
  29786. case tutorial.FieldIndex:
  29787. return m.AddedIndex()
  29788. case tutorial.FieldOrganizationID:
  29789. return m.AddedOrganizationID()
  29790. }
  29791. return nil, false
  29792. }
  29793. // AddField adds the value to the field with the given name. It returns an error if
  29794. // the field is not defined in the schema, or if the type mismatched the field
  29795. // type.
  29796. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  29797. switch name {
  29798. case tutorial.FieldIndex:
  29799. v, ok := value.(int)
  29800. if !ok {
  29801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29802. }
  29803. m.AddIndex(v)
  29804. return nil
  29805. case tutorial.FieldOrganizationID:
  29806. v, ok := value.(int64)
  29807. if !ok {
  29808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29809. }
  29810. m.AddOrganizationID(v)
  29811. return nil
  29812. }
  29813. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  29814. }
  29815. // ClearedFields returns all nullable fields that were cleared during this
  29816. // mutation.
  29817. func (m *TutorialMutation) ClearedFields() []string {
  29818. var fields []string
  29819. if m.FieldCleared(tutorial.FieldDeletedAt) {
  29820. fields = append(fields, tutorial.FieldDeletedAt)
  29821. }
  29822. return fields
  29823. }
  29824. // FieldCleared returns a boolean indicating if a field with the given name was
  29825. // cleared in this mutation.
  29826. func (m *TutorialMutation) FieldCleared(name string) bool {
  29827. _, ok := m.clearedFields[name]
  29828. return ok
  29829. }
  29830. // ClearField clears the value of the field with the given name. It returns an
  29831. // error if the field is not defined in the schema.
  29832. func (m *TutorialMutation) ClearField(name string) error {
  29833. switch name {
  29834. case tutorial.FieldDeletedAt:
  29835. m.ClearDeletedAt()
  29836. return nil
  29837. }
  29838. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  29839. }
  29840. // ResetField resets all changes in the mutation for the field with the given name.
  29841. // It returns an error if the field is not defined in the schema.
  29842. func (m *TutorialMutation) ResetField(name string) error {
  29843. switch name {
  29844. case tutorial.FieldCreatedAt:
  29845. m.ResetCreatedAt()
  29846. return nil
  29847. case tutorial.FieldUpdatedAt:
  29848. m.ResetUpdatedAt()
  29849. return nil
  29850. case tutorial.FieldDeletedAt:
  29851. m.ResetDeletedAt()
  29852. return nil
  29853. case tutorial.FieldEmployeeID:
  29854. m.ResetEmployeeID()
  29855. return nil
  29856. case tutorial.FieldIndex:
  29857. m.ResetIndex()
  29858. return nil
  29859. case tutorial.FieldTitle:
  29860. m.ResetTitle()
  29861. return nil
  29862. case tutorial.FieldContent:
  29863. m.ResetContent()
  29864. return nil
  29865. case tutorial.FieldOrganizationID:
  29866. m.ResetOrganizationID()
  29867. return nil
  29868. }
  29869. return fmt.Errorf("unknown Tutorial field %s", name)
  29870. }
  29871. // AddedEdges returns all edge names that were set/added in this mutation.
  29872. func (m *TutorialMutation) AddedEdges() []string {
  29873. edges := make([]string, 0, 1)
  29874. if m.employee != nil {
  29875. edges = append(edges, tutorial.EdgeEmployee)
  29876. }
  29877. return edges
  29878. }
  29879. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29880. // name in this mutation.
  29881. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  29882. switch name {
  29883. case tutorial.EdgeEmployee:
  29884. if id := m.employee; id != nil {
  29885. return []ent.Value{*id}
  29886. }
  29887. }
  29888. return nil
  29889. }
  29890. // RemovedEdges returns all edge names that were removed in this mutation.
  29891. func (m *TutorialMutation) RemovedEdges() []string {
  29892. edges := make([]string, 0, 1)
  29893. return edges
  29894. }
  29895. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29896. // the given name in this mutation.
  29897. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  29898. return nil
  29899. }
  29900. // ClearedEdges returns all edge names that were cleared in this mutation.
  29901. func (m *TutorialMutation) ClearedEdges() []string {
  29902. edges := make([]string, 0, 1)
  29903. if m.clearedemployee {
  29904. edges = append(edges, tutorial.EdgeEmployee)
  29905. }
  29906. return edges
  29907. }
  29908. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29909. // was cleared in this mutation.
  29910. func (m *TutorialMutation) EdgeCleared(name string) bool {
  29911. switch name {
  29912. case tutorial.EdgeEmployee:
  29913. return m.clearedemployee
  29914. }
  29915. return false
  29916. }
  29917. // ClearEdge clears the value of the edge with the given name. It returns an error
  29918. // if that edge is not defined in the schema.
  29919. func (m *TutorialMutation) ClearEdge(name string) error {
  29920. switch name {
  29921. case tutorial.EdgeEmployee:
  29922. m.ClearEmployee()
  29923. return nil
  29924. }
  29925. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  29926. }
  29927. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29928. // It returns an error if the edge is not defined in the schema.
  29929. func (m *TutorialMutation) ResetEdge(name string) error {
  29930. switch name {
  29931. case tutorial.EdgeEmployee:
  29932. m.ResetEmployee()
  29933. return nil
  29934. }
  29935. return fmt.Errorf("unknown Tutorial edge %s", name)
  29936. }
  29937. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  29938. type UsageDetailMutation struct {
  29939. config
  29940. op Op
  29941. typ string
  29942. id *uint64
  29943. created_at *time.Time
  29944. updated_at *time.Time
  29945. status *uint8
  29946. addstatus *int8
  29947. _type *int
  29948. add_type *int
  29949. bot_id *string
  29950. receiver_id *string
  29951. app *int
  29952. addapp *int
  29953. session_id *uint64
  29954. addsession_id *int64
  29955. request *string
  29956. response *string
  29957. original_data *custom_types.OriginalData
  29958. total_tokens *uint64
  29959. addtotal_tokens *int64
  29960. prompt_tokens *uint64
  29961. addprompt_tokens *int64
  29962. completion_tokens *uint64
  29963. addcompletion_tokens *int64
  29964. organization_id *uint64
  29965. addorganization_id *int64
  29966. clearedFields map[string]struct{}
  29967. done bool
  29968. oldValue func(context.Context) (*UsageDetail, error)
  29969. predicates []predicate.UsageDetail
  29970. }
  29971. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  29972. // usagedetailOption allows management of the mutation configuration using functional options.
  29973. type usagedetailOption func(*UsageDetailMutation)
  29974. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  29975. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  29976. m := &UsageDetailMutation{
  29977. config: c,
  29978. op: op,
  29979. typ: TypeUsageDetail,
  29980. clearedFields: make(map[string]struct{}),
  29981. }
  29982. for _, opt := range opts {
  29983. opt(m)
  29984. }
  29985. return m
  29986. }
  29987. // withUsageDetailID sets the ID field of the mutation.
  29988. func withUsageDetailID(id uint64) usagedetailOption {
  29989. return func(m *UsageDetailMutation) {
  29990. var (
  29991. err error
  29992. once sync.Once
  29993. value *UsageDetail
  29994. )
  29995. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  29996. once.Do(func() {
  29997. if m.done {
  29998. err = errors.New("querying old values post mutation is not allowed")
  29999. } else {
  30000. value, err = m.Client().UsageDetail.Get(ctx, id)
  30001. }
  30002. })
  30003. return value, err
  30004. }
  30005. m.id = &id
  30006. }
  30007. }
  30008. // withUsageDetail sets the old UsageDetail of the mutation.
  30009. func withUsageDetail(node *UsageDetail) usagedetailOption {
  30010. return func(m *UsageDetailMutation) {
  30011. m.oldValue = func(context.Context) (*UsageDetail, error) {
  30012. return node, nil
  30013. }
  30014. m.id = &node.ID
  30015. }
  30016. }
  30017. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30018. // executed in a transaction (ent.Tx), a transactional client is returned.
  30019. func (m UsageDetailMutation) Client() *Client {
  30020. client := &Client{config: m.config}
  30021. client.init()
  30022. return client
  30023. }
  30024. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30025. // it returns an error otherwise.
  30026. func (m UsageDetailMutation) Tx() (*Tx, error) {
  30027. if _, ok := m.driver.(*txDriver); !ok {
  30028. return nil, errors.New("ent: mutation is not running in a transaction")
  30029. }
  30030. tx := &Tx{config: m.config}
  30031. tx.init()
  30032. return tx, nil
  30033. }
  30034. // SetID sets the value of the id field. Note that this
  30035. // operation is only accepted on creation of UsageDetail entities.
  30036. func (m *UsageDetailMutation) SetID(id uint64) {
  30037. m.id = &id
  30038. }
  30039. // ID returns the ID value in the mutation. Note that the ID is only available
  30040. // if it was provided to the builder or after it was returned from the database.
  30041. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  30042. if m.id == nil {
  30043. return
  30044. }
  30045. return *m.id, true
  30046. }
  30047. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30048. // That means, if the mutation is applied within a transaction with an isolation level such
  30049. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30050. // or updated by the mutation.
  30051. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  30052. switch {
  30053. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30054. id, exists := m.ID()
  30055. if exists {
  30056. return []uint64{id}, nil
  30057. }
  30058. fallthrough
  30059. case m.op.Is(OpUpdate | OpDelete):
  30060. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  30061. default:
  30062. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30063. }
  30064. }
  30065. // SetCreatedAt sets the "created_at" field.
  30066. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  30067. m.created_at = &t
  30068. }
  30069. // CreatedAt returns the value of the "created_at" field in the mutation.
  30070. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  30071. v := m.created_at
  30072. if v == nil {
  30073. return
  30074. }
  30075. return *v, true
  30076. }
  30077. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  30078. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30080. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30081. if !m.op.Is(OpUpdateOne) {
  30082. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30083. }
  30084. if m.id == nil || m.oldValue == nil {
  30085. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30086. }
  30087. oldValue, err := m.oldValue(ctx)
  30088. if err != nil {
  30089. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30090. }
  30091. return oldValue.CreatedAt, nil
  30092. }
  30093. // ResetCreatedAt resets all changes to the "created_at" field.
  30094. func (m *UsageDetailMutation) ResetCreatedAt() {
  30095. m.created_at = nil
  30096. }
  30097. // SetUpdatedAt sets the "updated_at" field.
  30098. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  30099. m.updated_at = &t
  30100. }
  30101. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30102. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  30103. v := m.updated_at
  30104. if v == nil {
  30105. return
  30106. }
  30107. return *v, true
  30108. }
  30109. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  30110. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30112. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30113. if !m.op.Is(OpUpdateOne) {
  30114. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30115. }
  30116. if m.id == nil || m.oldValue == nil {
  30117. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30118. }
  30119. oldValue, err := m.oldValue(ctx)
  30120. if err != nil {
  30121. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30122. }
  30123. return oldValue.UpdatedAt, nil
  30124. }
  30125. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30126. func (m *UsageDetailMutation) ResetUpdatedAt() {
  30127. m.updated_at = nil
  30128. }
  30129. // SetStatus sets the "status" field.
  30130. func (m *UsageDetailMutation) SetStatus(u uint8) {
  30131. m.status = &u
  30132. m.addstatus = nil
  30133. }
  30134. // Status returns the value of the "status" field in the mutation.
  30135. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  30136. v := m.status
  30137. if v == nil {
  30138. return
  30139. }
  30140. return *v, true
  30141. }
  30142. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  30143. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30145. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30146. if !m.op.Is(OpUpdateOne) {
  30147. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30148. }
  30149. if m.id == nil || m.oldValue == nil {
  30150. return v, errors.New("OldStatus requires an ID field in the mutation")
  30151. }
  30152. oldValue, err := m.oldValue(ctx)
  30153. if err != nil {
  30154. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30155. }
  30156. return oldValue.Status, nil
  30157. }
  30158. // AddStatus adds u to the "status" field.
  30159. func (m *UsageDetailMutation) AddStatus(u int8) {
  30160. if m.addstatus != nil {
  30161. *m.addstatus += u
  30162. } else {
  30163. m.addstatus = &u
  30164. }
  30165. }
  30166. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30167. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  30168. v := m.addstatus
  30169. if v == nil {
  30170. return
  30171. }
  30172. return *v, true
  30173. }
  30174. // ClearStatus clears the value of the "status" field.
  30175. func (m *UsageDetailMutation) ClearStatus() {
  30176. m.status = nil
  30177. m.addstatus = nil
  30178. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  30179. }
  30180. // StatusCleared returns if the "status" field was cleared in this mutation.
  30181. func (m *UsageDetailMutation) StatusCleared() bool {
  30182. _, ok := m.clearedFields[usagedetail.FieldStatus]
  30183. return ok
  30184. }
  30185. // ResetStatus resets all changes to the "status" field.
  30186. func (m *UsageDetailMutation) ResetStatus() {
  30187. m.status = nil
  30188. m.addstatus = nil
  30189. delete(m.clearedFields, usagedetail.FieldStatus)
  30190. }
  30191. // SetType sets the "type" field.
  30192. func (m *UsageDetailMutation) SetType(i int) {
  30193. m._type = &i
  30194. m.add_type = nil
  30195. }
  30196. // GetType returns the value of the "type" field in the mutation.
  30197. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  30198. v := m._type
  30199. if v == nil {
  30200. return
  30201. }
  30202. return *v, true
  30203. }
  30204. // OldType returns the old "type" field's value of the UsageDetail entity.
  30205. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30207. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  30208. if !m.op.Is(OpUpdateOne) {
  30209. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30210. }
  30211. if m.id == nil || m.oldValue == nil {
  30212. return v, errors.New("OldType requires an ID field in the mutation")
  30213. }
  30214. oldValue, err := m.oldValue(ctx)
  30215. if err != nil {
  30216. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30217. }
  30218. return oldValue.Type, nil
  30219. }
  30220. // AddType adds i to the "type" field.
  30221. func (m *UsageDetailMutation) AddType(i int) {
  30222. if m.add_type != nil {
  30223. *m.add_type += i
  30224. } else {
  30225. m.add_type = &i
  30226. }
  30227. }
  30228. // AddedType returns the value that was added to the "type" field in this mutation.
  30229. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  30230. v := m.add_type
  30231. if v == nil {
  30232. return
  30233. }
  30234. return *v, true
  30235. }
  30236. // ClearType clears the value of the "type" field.
  30237. func (m *UsageDetailMutation) ClearType() {
  30238. m._type = nil
  30239. m.add_type = nil
  30240. m.clearedFields[usagedetail.FieldType] = struct{}{}
  30241. }
  30242. // TypeCleared returns if the "type" field was cleared in this mutation.
  30243. func (m *UsageDetailMutation) TypeCleared() bool {
  30244. _, ok := m.clearedFields[usagedetail.FieldType]
  30245. return ok
  30246. }
  30247. // ResetType resets all changes to the "type" field.
  30248. func (m *UsageDetailMutation) ResetType() {
  30249. m._type = nil
  30250. m.add_type = nil
  30251. delete(m.clearedFields, usagedetail.FieldType)
  30252. }
  30253. // SetBotID sets the "bot_id" field.
  30254. func (m *UsageDetailMutation) SetBotID(s string) {
  30255. m.bot_id = &s
  30256. }
  30257. // BotID returns the value of the "bot_id" field in the mutation.
  30258. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  30259. v := m.bot_id
  30260. if v == nil {
  30261. return
  30262. }
  30263. return *v, true
  30264. }
  30265. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  30266. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30268. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  30269. if !m.op.Is(OpUpdateOne) {
  30270. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30271. }
  30272. if m.id == nil || m.oldValue == nil {
  30273. return v, errors.New("OldBotID requires an ID field in the mutation")
  30274. }
  30275. oldValue, err := m.oldValue(ctx)
  30276. if err != nil {
  30277. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30278. }
  30279. return oldValue.BotID, nil
  30280. }
  30281. // ResetBotID resets all changes to the "bot_id" field.
  30282. func (m *UsageDetailMutation) ResetBotID() {
  30283. m.bot_id = nil
  30284. }
  30285. // SetReceiverID sets the "receiver_id" field.
  30286. func (m *UsageDetailMutation) SetReceiverID(s string) {
  30287. m.receiver_id = &s
  30288. }
  30289. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  30290. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  30291. v := m.receiver_id
  30292. if v == nil {
  30293. return
  30294. }
  30295. return *v, true
  30296. }
  30297. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  30298. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30300. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  30301. if !m.op.Is(OpUpdateOne) {
  30302. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  30303. }
  30304. if m.id == nil || m.oldValue == nil {
  30305. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  30306. }
  30307. oldValue, err := m.oldValue(ctx)
  30308. if err != nil {
  30309. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  30310. }
  30311. return oldValue.ReceiverID, nil
  30312. }
  30313. // ResetReceiverID resets all changes to the "receiver_id" field.
  30314. func (m *UsageDetailMutation) ResetReceiverID() {
  30315. m.receiver_id = nil
  30316. }
  30317. // SetApp sets the "app" field.
  30318. func (m *UsageDetailMutation) SetApp(i int) {
  30319. m.app = &i
  30320. m.addapp = nil
  30321. }
  30322. // App returns the value of the "app" field in the mutation.
  30323. func (m *UsageDetailMutation) App() (r int, exists bool) {
  30324. v := m.app
  30325. if v == nil {
  30326. return
  30327. }
  30328. return *v, true
  30329. }
  30330. // OldApp returns the old "app" field's value of the UsageDetail entity.
  30331. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30333. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  30334. if !m.op.Is(OpUpdateOne) {
  30335. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  30336. }
  30337. if m.id == nil || m.oldValue == nil {
  30338. return v, errors.New("OldApp requires an ID field in the mutation")
  30339. }
  30340. oldValue, err := m.oldValue(ctx)
  30341. if err != nil {
  30342. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  30343. }
  30344. return oldValue.App, nil
  30345. }
  30346. // AddApp adds i to the "app" field.
  30347. func (m *UsageDetailMutation) AddApp(i int) {
  30348. if m.addapp != nil {
  30349. *m.addapp += i
  30350. } else {
  30351. m.addapp = &i
  30352. }
  30353. }
  30354. // AddedApp returns the value that was added to the "app" field in this mutation.
  30355. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  30356. v := m.addapp
  30357. if v == nil {
  30358. return
  30359. }
  30360. return *v, true
  30361. }
  30362. // ClearApp clears the value of the "app" field.
  30363. func (m *UsageDetailMutation) ClearApp() {
  30364. m.app = nil
  30365. m.addapp = nil
  30366. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  30367. }
  30368. // AppCleared returns if the "app" field was cleared in this mutation.
  30369. func (m *UsageDetailMutation) AppCleared() bool {
  30370. _, ok := m.clearedFields[usagedetail.FieldApp]
  30371. return ok
  30372. }
  30373. // ResetApp resets all changes to the "app" field.
  30374. func (m *UsageDetailMutation) ResetApp() {
  30375. m.app = nil
  30376. m.addapp = nil
  30377. delete(m.clearedFields, usagedetail.FieldApp)
  30378. }
  30379. // SetSessionID sets the "session_id" field.
  30380. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  30381. m.session_id = &u
  30382. m.addsession_id = nil
  30383. }
  30384. // SessionID returns the value of the "session_id" field in the mutation.
  30385. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  30386. v := m.session_id
  30387. if v == nil {
  30388. return
  30389. }
  30390. return *v, true
  30391. }
  30392. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  30393. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30395. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  30396. if !m.op.Is(OpUpdateOne) {
  30397. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  30398. }
  30399. if m.id == nil || m.oldValue == nil {
  30400. return v, errors.New("OldSessionID requires an ID field in the mutation")
  30401. }
  30402. oldValue, err := m.oldValue(ctx)
  30403. if err != nil {
  30404. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  30405. }
  30406. return oldValue.SessionID, nil
  30407. }
  30408. // AddSessionID adds u to the "session_id" field.
  30409. func (m *UsageDetailMutation) AddSessionID(u int64) {
  30410. if m.addsession_id != nil {
  30411. *m.addsession_id += u
  30412. } else {
  30413. m.addsession_id = &u
  30414. }
  30415. }
  30416. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  30417. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  30418. v := m.addsession_id
  30419. if v == nil {
  30420. return
  30421. }
  30422. return *v, true
  30423. }
  30424. // ClearSessionID clears the value of the "session_id" field.
  30425. func (m *UsageDetailMutation) ClearSessionID() {
  30426. m.session_id = nil
  30427. m.addsession_id = nil
  30428. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  30429. }
  30430. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  30431. func (m *UsageDetailMutation) SessionIDCleared() bool {
  30432. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  30433. return ok
  30434. }
  30435. // ResetSessionID resets all changes to the "session_id" field.
  30436. func (m *UsageDetailMutation) ResetSessionID() {
  30437. m.session_id = nil
  30438. m.addsession_id = nil
  30439. delete(m.clearedFields, usagedetail.FieldSessionID)
  30440. }
  30441. // SetRequest sets the "request" field.
  30442. func (m *UsageDetailMutation) SetRequest(s string) {
  30443. m.request = &s
  30444. }
  30445. // Request returns the value of the "request" field in the mutation.
  30446. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  30447. v := m.request
  30448. if v == nil {
  30449. return
  30450. }
  30451. return *v, true
  30452. }
  30453. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  30454. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30456. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  30457. if !m.op.Is(OpUpdateOne) {
  30458. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  30459. }
  30460. if m.id == nil || m.oldValue == nil {
  30461. return v, errors.New("OldRequest requires an ID field in the mutation")
  30462. }
  30463. oldValue, err := m.oldValue(ctx)
  30464. if err != nil {
  30465. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  30466. }
  30467. return oldValue.Request, nil
  30468. }
  30469. // ResetRequest resets all changes to the "request" field.
  30470. func (m *UsageDetailMutation) ResetRequest() {
  30471. m.request = nil
  30472. }
  30473. // SetResponse sets the "response" field.
  30474. func (m *UsageDetailMutation) SetResponse(s string) {
  30475. m.response = &s
  30476. }
  30477. // Response returns the value of the "response" field in the mutation.
  30478. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  30479. v := m.response
  30480. if v == nil {
  30481. return
  30482. }
  30483. return *v, true
  30484. }
  30485. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  30486. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30488. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  30489. if !m.op.Is(OpUpdateOne) {
  30490. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  30491. }
  30492. if m.id == nil || m.oldValue == nil {
  30493. return v, errors.New("OldResponse requires an ID field in the mutation")
  30494. }
  30495. oldValue, err := m.oldValue(ctx)
  30496. if err != nil {
  30497. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  30498. }
  30499. return oldValue.Response, nil
  30500. }
  30501. // ResetResponse resets all changes to the "response" field.
  30502. func (m *UsageDetailMutation) ResetResponse() {
  30503. m.response = nil
  30504. }
  30505. // SetOriginalData sets the "original_data" field.
  30506. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  30507. m.original_data = &ctd
  30508. }
  30509. // OriginalData returns the value of the "original_data" field in the mutation.
  30510. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  30511. v := m.original_data
  30512. if v == nil {
  30513. return
  30514. }
  30515. return *v, true
  30516. }
  30517. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  30518. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30520. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  30521. if !m.op.Is(OpUpdateOne) {
  30522. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  30523. }
  30524. if m.id == nil || m.oldValue == nil {
  30525. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  30526. }
  30527. oldValue, err := m.oldValue(ctx)
  30528. if err != nil {
  30529. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  30530. }
  30531. return oldValue.OriginalData, nil
  30532. }
  30533. // ResetOriginalData resets all changes to the "original_data" field.
  30534. func (m *UsageDetailMutation) ResetOriginalData() {
  30535. m.original_data = nil
  30536. }
  30537. // SetTotalTokens sets the "total_tokens" field.
  30538. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  30539. m.total_tokens = &u
  30540. m.addtotal_tokens = nil
  30541. }
  30542. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  30543. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  30544. v := m.total_tokens
  30545. if v == nil {
  30546. return
  30547. }
  30548. return *v, true
  30549. }
  30550. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  30551. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30553. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  30554. if !m.op.Is(OpUpdateOne) {
  30555. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  30556. }
  30557. if m.id == nil || m.oldValue == nil {
  30558. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  30559. }
  30560. oldValue, err := m.oldValue(ctx)
  30561. if err != nil {
  30562. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  30563. }
  30564. return oldValue.TotalTokens, nil
  30565. }
  30566. // AddTotalTokens adds u to the "total_tokens" field.
  30567. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  30568. if m.addtotal_tokens != nil {
  30569. *m.addtotal_tokens += u
  30570. } else {
  30571. m.addtotal_tokens = &u
  30572. }
  30573. }
  30574. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  30575. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  30576. v := m.addtotal_tokens
  30577. if v == nil {
  30578. return
  30579. }
  30580. return *v, true
  30581. }
  30582. // ClearTotalTokens clears the value of the "total_tokens" field.
  30583. func (m *UsageDetailMutation) ClearTotalTokens() {
  30584. m.total_tokens = nil
  30585. m.addtotal_tokens = nil
  30586. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  30587. }
  30588. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  30589. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  30590. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  30591. return ok
  30592. }
  30593. // ResetTotalTokens resets all changes to the "total_tokens" field.
  30594. func (m *UsageDetailMutation) ResetTotalTokens() {
  30595. m.total_tokens = nil
  30596. m.addtotal_tokens = nil
  30597. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  30598. }
  30599. // SetPromptTokens sets the "prompt_tokens" field.
  30600. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  30601. m.prompt_tokens = &u
  30602. m.addprompt_tokens = nil
  30603. }
  30604. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  30605. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  30606. v := m.prompt_tokens
  30607. if v == nil {
  30608. return
  30609. }
  30610. return *v, true
  30611. }
  30612. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  30613. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30615. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  30616. if !m.op.Is(OpUpdateOne) {
  30617. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  30618. }
  30619. if m.id == nil || m.oldValue == nil {
  30620. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  30621. }
  30622. oldValue, err := m.oldValue(ctx)
  30623. if err != nil {
  30624. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  30625. }
  30626. return oldValue.PromptTokens, nil
  30627. }
  30628. // AddPromptTokens adds u to the "prompt_tokens" field.
  30629. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  30630. if m.addprompt_tokens != nil {
  30631. *m.addprompt_tokens += u
  30632. } else {
  30633. m.addprompt_tokens = &u
  30634. }
  30635. }
  30636. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  30637. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  30638. v := m.addprompt_tokens
  30639. if v == nil {
  30640. return
  30641. }
  30642. return *v, true
  30643. }
  30644. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  30645. func (m *UsageDetailMutation) ClearPromptTokens() {
  30646. m.prompt_tokens = nil
  30647. m.addprompt_tokens = nil
  30648. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  30649. }
  30650. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  30651. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  30652. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  30653. return ok
  30654. }
  30655. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  30656. func (m *UsageDetailMutation) ResetPromptTokens() {
  30657. m.prompt_tokens = nil
  30658. m.addprompt_tokens = nil
  30659. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  30660. }
  30661. // SetCompletionTokens sets the "completion_tokens" field.
  30662. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  30663. m.completion_tokens = &u
  30664. m.addcompletion_tokens = nil
  30665. }
  30666. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  30667. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  30668. v := m.completion_tokens
  30669. if v == nil {
  30670. return
  30671. }
  30672. return *v, true
  30673. }
  30674. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  30675. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30677. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  30678. if !m.op.Is(OpUpdateOne) {
  30679. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  30680. }
  30681. if m.id == nil || m.oldValue == nil {
  30682. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  30683. }
  30684. oldValue, err := m.oldValue(ctx)
  30685. if err != nil {
  30686. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  30687. }
  30688. return oldValue.CompletionTokens, nil
  30689. }
  30690. // AddCompletionTokens adds u to the "completion_tokens" field.
  30691. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  30692. if m.addcompletion_tokens != nil {
  30693. *m.addcompletion_tokens += u
  30694. } else {
  30695. m.addcompletion_tokens = &u
  30696. }
  30697. }
  30698. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  30699. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  30700. v := m.addcompletion_tokens
  30701. if v == nil {
  30702. return
  30703. }
  30704. return *v, true
  30705. }
  30706. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  30707. func (m *UsageDetailMutation) ClearCompletionTokens() {
  30708. m.completion_tokens = nil
  30709. m.addcompletion_tokens = nil
  30710. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  30711. }
  30712. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  30713. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  30714. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  30715. return ok
  30716. }
  30717. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  30718. func (m *UsageDetailMutation) ResetCompletionTokens() {
  30719. m.completion_tokens = nil
  30720. m.addcompletion_tokens = nil
  30721. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  30722. }
  30723. // SetOrganizationID sets the "organization_id" field.
  30724. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  30725. m.organization_id = &u
  30726. m.addorganization_id = nil
  30727. }
  30728. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30729. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  30730. v := m.organization_id
  30731. if v == nil {
  30732. return
  30733. }
  30734. return *v, true
  30735. }
  30736. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  30737. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30739. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30740. if !m.op.Is(OpUpdateOne) {
  30741. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30742. }
  30743. if m.id == nil || m.oldValue == nil {
  30744. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30745. }
  30746. oldValue, err := m.oldValue(ctx)
  30747. if err != nil {
  30748. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30749. }
  30750. return oldValue.OrganizationID, nil
  30751. }
  30752. // AddOrganizationID adds u to the "organization_id" field.
  30753. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  30754. if m.addorganization_id != nil {
  30755. *m.addorganization_id += u
  30756. } else {
  30757. m.addorganization_id = &u
  30758. }
  30759. }
  30760. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30761. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  30762. v := m.addorganization_id
  30763. if v == nil {
  30764. return
  30765. }
  30766. return *v, true
  30767. }
  30768. // ClearOrganizationID clears the value of the "organization_id" field.
  30769. func (m *UsageDetailMutation) ClearOrganizationID() {
  30770. m.organization_id = nil
  30771. m.addorganization_id = nil
  30772. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  30773. }
  30774. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30775. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  30776. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  30777. return ok
  30778. }
  30779. // ResetOrganizationID resets all changes to the "organization_id" field.
  30780. func (m *UsageDetailMutation) ResetOrganizationID() {
  30781. m.organization_id = nil
  30782. m.addorganization_id = nil
  30783. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  30784. }
  30785. // Where appends a list predicates to the UsageDetailMutation builder.
  30786. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  30787. m.predicates = append(m.predicates, ps...)
  30788. }
  30789. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  30790. // users can use type-assertion to append predicates that do not depend on any generated package.
  30791. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  30792. p := make([]predicate.UsageDetail, len(ps))
  30793. for i := range ps {
  30794. p[i] = ps[i]
  30795. }
  30796. m.Where(p...)
  30797. }
  30798. // Op returns the operation name.
  30799. func (m *UsageDetailMutation) Op() Op {
  30800. return m.op
  30801. }
  30802. // SetOp allows setting the mutation operation.
  30803. func (m *UsageDetailMutation) SetOp(op Op) {
  30804. m.op = op
  30805. }
  30806. // Type returns the node type of this mutation (UsageDetail).
  30807. func (m *UsageDetailMutation) Type() string {
  30808. return m.typ
  30809. }
  30810. // Fields returns all fields that were changed during this mutation. Note that in
  30811. // order to get all numeric fields that were incremented/decremented, call
  30812. // AddedFields().
  30813. func (m *UsageDetailMutation) Fields() []string {
  30814. fields := make([]string, 0, 15)
  30815. if m.created_at != nil {
  30816. fields = append(fields, usagedetail.FieldCreatedAt)
  30817. }
  30818. if m.updated_at != nil {
  30819. fields = append(fields, usagedetail.FieldUpdatedAt)
  30820. }
  30821. if m.status != nil {
  30822. fields = append(fields, usagedetail.FieldStatus)
  30823. }
  30824. if m._type != nil {
  30825. fields = append(fields, usagedetail.FieldType)
  30826. }
  30827. if m.bot_id != nil {
  30828. fields = append(fields, usagedetail.FieldBotID)
  30829. }
  30830. if m.receiver_id != nil {
  30831. fields = append(fields, usagedetail.FieldReceiverID)
  30832. }
  30833. if m.app != nil {
  30834. fields = append(fields, usagedetail.FieldApp)
  30835. }
  30836. if m.session_id != nil {
  30837. fields = append(fields, usagedetail.FieldSessionID)
  30838. }
  30839. if m.request != nil {
  30840. fields = append(fields, usagedetail.FieldRequest)
  30841. }
  30842. if m.response != nil {
  30843. fields = append(fields, usagedetail.FieldResponse)
  30844. }
  30845. if m.original_data != nil {
  30846. fields = append(fields, usagedetail.FieldOriginalData)
  30847. }
  30848. if m.total_tokens != nil {
  30849. fields = append(fields, usagedetail.FieldTotalTokens)
  30850. }
  30851. if m.prompt_tokens != nil {
  30852. fields = append(fields, usagedetail.FieldPromptTokens)
  30853. }
  30854. if m.completion_tokens != nil {
  30855. fields = append(fields, usagedetail.FieldCompletionTokens)
  30856. }
  30857. if m.organization_id != nil {
  30858. fields = append(fields, usagedetail.FieldOrganizationID)
  30859. }
  30860. return fields
  30861. }
  30862. // Field returns the value of a field with the given name. The second boolean
  30863. // return value indicates that this field was not set, or was not defined in the
  30864. // schema.
  30865. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  30866. switch name {
  30867. case usagedetail.FieldCreatedAt:
  30868. return m.CreatedAt()
  30869. case usagedetail.FieldUpdatedAt:
  30870. return m.UpdatedAt()
  30871. case usagedetail.FieldStatus:
  30872. return m.Status()
  30873. case usagedetail.FieldType:
  30874. return m.GetType()
  30875. case usagedetail.FieldBotID:
  30876. return m.BotID()
  30877. case usagedetail.FieldReceiverID:
  30878. return m.ReceiverID()
  30879. case usagedetail.FieldApp:
  30880. return m.App()
  30881. case usagedetail.FieldSessionID:
  30882. return m.SessionID()
  30883. case usagedetail.FieldRequest:
  30884. return m.Request()
  30885. case usagedetail.FieldResponse:
  30886. return m.Response()
  30887. case usagedetail.FieldOriginalData:
  30888. return m.OriginalData()
  30889. case usagedetail.FieldTotalTokens:
  30890. return m.TotalTokens()
  30891. case usagedetail.FieldPromptTokens:
  30892. return m.PromptTokens()
  30893. case usagedetail.FieldCompletionTokens:
  30894. return m.CompletionTokens()
  30895. case usagedetail.FieldOrganizationID:
  30896. return m.OrganizationID()
  30897. }
  30898. return nil, false
  30899. }
  30900. // OldField returns the old value of the field from the database. An error is
  30901. // returned if the mutation operation is not UpdateOne, or the query to the
  30902. // database failed.
  30903. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30904. switch name {
  30905. case usagedetail.FieldCreatedAt:
  30906. return m.OldCreatedAt(ctx)
  30907. case usagedetail.FieldUpdatedAt:
  30908. return m.OldUpdatedAt(ctx)
  30909. case usagedetail.FieldStatus:
  30910. return m.OldStatus(ctx)
  30911. case usagedetail.FieldType:
  30912. return m.OldType(ctx)
  30913. case usagedetail.FieldBotID:
  30914. return m.OldBotID(ctx)
  30915. case usagedetail.FieldReceiverID:
  30916. return m.OldReceiverID(ctx)
  30917. case usagedetail.FieldApp:
  30918. return m.OldApp(ctx)
  30919. case usagedetail.FieldSessionID:
  30920. return m.OldSessionID(ctx)
  30921. case usagedetail.FieldRequest:
  30922. return m.OldRequest(ctx)
  30923. case usagedetail.FieldResponse:
  30924. return m.OldResponse(ctx)
  30925. case usagedetail.FieldOriginalData:
  30926. return m.OldOriginalData(ctx)
  30927. case usagedetail.FieldTotalTokens:
  30928. return m.OldTotalTokens(ctx)
  30929. case usagedetail.FieldPromptTokens:
  30930. return m.OldPromptTokens(ctx)
  30931. case usagedetail.FieldCompletionTokens:
  30932. return m.OldCompletionTokens(ctx)
  30933. case usagedetail.FieldOrganizationID:
  30934. return m.OldOrganizationID(ctx)
  30935. }
  30936. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  30937. }
  30938. // SetField sets the value of a field with the given name. It returns an error if
  30939. // the field is not defined in the schema, or if the type mismatched the field
  30940. // type.
  30941. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  30942. switch name {
  30943. case usagedetail.FieldCreatedAt:
  30944. v, ok := value.(time.Time)
  30945. if !ok {
  30946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30947. }
  30948. m.SetCreatedAt(v)
  30949. return nil
  30950. case usagedetail.FieldUpdatedAt:
  30951. v, ok := value.(time.Time)
  30952. if !ok {
  30953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30954. }
  30955. m.SetUpdatedAt(v)
  30956. return nil
  30957. case usagedetail.FieldStatus:
  30958. v, ok := value.(uint8)
  30959. if !ok {
  30960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30961. }
  30962. m.SetStatus(v)
  30963. return nil
  30964. case usagedetail.FieldType:
  30965. v, ok := value.(int)
  30966. if !ok {
  30967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30968. }
  30969. m.SetType(v)
  30970. return nil
  30971. case usagedetail.FieldBotID:
  30972. v, ok := value.(string)
  30973. if !ok {
  30974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30975. }
  30976. m.SetBotID(v)
  30977. return nil
  30978. case usagedetail.FieldReceiverID:
  30979. v, ok := value.(string)
  30980. if !ok {
  30981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30982. }
  30983. m.SetReceiverID(v)
  30984. return nil
  30985. case usagedetail.FieldApp:
  30986. v, ok := value.(int)
  30987. if !ok {
  30988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30989. }
  30990. m.SetApp(v)
  30991. return nil
  30992. case usagedetail.FieldSessionID:
  30993. v, ok := value.(uint64)
  30994. if !ok {
  30995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30996. }
  30997. m.SetSessionID(v)
  30998. return nil
  30999. case usagedetail.FieldRequest:
  31000. v, ok := value.(string)
  31001. if !ok {
  31002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31003. }
  31004. m.SetRequest(v)
  31005. return nil
  31006. case usagedetail.FieldResponse:
  31007. v, ok := value.(string)
  31008. if !ok {
  31009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31010. }
  31011. m.SetResponse(v)
  31012. return nil
  31013. case usagedetail.FieldOriginalData:
  31014. v, ok := value.(custom_types.OriginalData)
  31015. if !ok {
  31016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31017. }
  31018. m.SetOriginalData(v)
  31019. return nil
  31020. case usagedetail.FieldTotalTokens:
  31021. v, ok := value.(uint64)
  31022. if !ok {
  31023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31024. }
  31025. m.SetTotalTokens(v)
  31026. return nil
  31027. case usagedetail.FieldPromptTokens:
  31028. v, ok := value.(uint64)
  31029. if !ok {
  31030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31031. }
  31032. m.SetPromptTokens(v)
  31033. return nil
  31034. case usagedetail.FieldCompletionTokens:
  31035. v, ok := value.(uint64)
  31036. if !ok {
  31037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31038. }
  31039. m.SetCompletionTokens(v)
  31040. return nil
  31041. case usagedetail.FieldOrganizationID:
  31042. v, ok := value.(uint64)
  31043. if !ok {
  31044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31045. }
  31046. m.SetOrganizationID(v)
  31047. return nil
  31048. }
  31049. return fmt.Errorf("unknown UsageDetail field %s", name)
  31050. }
  31051. // AddedFields returns all numeric fields that were incremented/decremented during
  31052. // this mutation.
  31053. func (m *UsageDetailMutation) AddedFields() []string {
  31054. var fields []string
  31055. if m.addstatus != nil {
  31056. fields = append(fields, usagedetail.FieldStatus)
  31057. }
  31058. if m.add_type != nil {
  31059. fields = append(fields, usagedetail.FieldType)
  31060. }
  31061. if m.addapp != nil {
  31062. fields = append(fields, usagedetail.FieldApp)
  31063. }
  31064. if m.addsession_id != nil {
  31065. fields = append(fields, usagedetail.FieldSessionID)
  31066. }
  31067. if m.addtotal_tokens != nil {
  31068. fields = append(fields, usagedetail.FieldTotalTokens)
  31069. }
  31070. if m.addprompt_tokens != nil {
  31071. fields = append(fields, usagedetail.FieldPromptTokens)
  31072. }
  31073. if m.addcompletion_tokens != nil {
  31074. fields = append(fields, usagedetail.FieldCompletionTokens)
  31075. }
  31076. if m.addorganization_id != nil {
  31077. fields = append(fields, usagedetail.FieldOrganizationID)
  31078. }
  31079. return fields
  31080. }
  31081. // AddedField returns the numeric value that was incremented/decremented on a field
  31082. // with the given name. The second boolean return value indicates that this field
  31083. // was not set, or was not defined in the schema.
  31084. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  31085. switch name {
  31086. case usagedetail.FieldStatus:
  31087. return m.AddedStatus()
  31088. case usagedetail.FieldType:
  31089. return m.AddedType()
  31090. case usagedetail.FieldApp:
  31091. return m.AddedApp()
  31092. case usagedetail.FieldSessionID:
  31093. return m.AddedSessionID()
  31094. case usagedetail.FieldTotalTokens:
  31095. return m.AddedTotalTokens()
  31096. case usagedetail.FieldPromptTokens:
  31097. return m.AddedPromptTokens()
  31098. case usagedetail.FieldCompletionTokens:
  31099. return m.AddedCompletionTokens()
  31100. case usagedetail.FieldOrganizationID:
  31101. return m.AddedOrganizationID()
  31102. }
  31103. return nil, false
  31104. }
  31105. // AddField adds the value to the field with the given name. It returns an error if
  31106. // the field is not defined in the schema, or if the type mismatched the field
  31107. // type.
  31108. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  31109. switch name {
  31110. case usagedetail.FieldStatus:
  31111. v, ok := value.(int8)
  31112. if !ok {
  31113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31114. }
  31115. m.AddStatus(v)
  31116. return nil
  31117. case usagedetail.FieldType:
  31118. v, ok := value.(int)
  31119. if !ok {
  31120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31121. }
  31122. m.AddType(v)
  31123. return nil
  31124. case usagedetail.FieldApp:
  31125. v, ok := value.(int)
  31126. if !ok {
  31127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31128. }
  31129. m.AddApp(v)
  31130. return nil
  31131. case usagedetail.FieldSessionID:
  31132. v, ok := value.(int64)
  31133. if !ok {
  31134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31135. }
  31136. m.AddSessionID(v)
  31137. return nil
  31138. case usagedetail.FieldTotalTokens:
  31139. v, ok := value.(int64)
  31140. if !ok {
  31141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31142. }
  31143. m.AddTotalTokens(v)
  31144. return nil
  31145. case usagedetail.FieldPromptTokens:
  31146. v, ok := value.(int64)
  31147. if !ok {
  31148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31149. }
  31150. m.AddPromptTokens(v)
  31151. return nil
  31152. case usagedetail.FieldCompletionTokens:
  31153. v, ok := value.(int64)
  31154. if !ok {
  31155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31156. }
  31157. m.AddCompletionTokens(v)
  31158. return nil
  31159. case usagedetail.FieldOrganizationID:
  31160. v, ok := value.(int64)
  31161. if !ok {
  31162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31163. }
  31164. m.AddOrganizationID(v)
  31165. return nil
  31166. }
  31167. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  31168. }
  31169. // ClearedFields returns all nullable fields that were cleared during this
  31170. // mutation.
  31171. func (m *UsageDetailMutation) ClearedFields() []string {
  31172. var fields []string
  31173. if m.FieldCleared(usagedetail.FieldStatus) {
  31174. fields = append(fields, usagedetail.FieldStatus)
  31175. }
  31176. if m.FieldCleared(usagedetail.FieldType) {
  31177. fields = append(fields, usagedetail.FieldType)
  31178. }
  31179. if m.FieldCleared(usagedetail.FieldApp) {
  31180. fields = append(fields, usagedetail.FieldApp)
  31181. }
  31182. if m.FieldCleared(usagedetail.FieldSessionID) {
  31183. fields = append(fields, usagedetail.FieldSessionID)
  31184. }
  31185. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  31186. fields = append(fields, usagedetail.FieldTotalTokens)
  31187. }
  31188. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  31189. fields = append(fields, usagedetail.FieldPromptTokens)
  31190. }
  31191. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  31192. fields = append(fields, usagedetail.FieldCompletionTokens)
  31193. }
  31194. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  31195. fields = append(fields, usagedetail.FieldOrganizationID)
  31196. }
  31197. return fields
  31198. }
  31199. // FieldCleared returns a boolean indicating if a field with the given name was
  31200. // cleared in this mutation.
  31201. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  31202. _, ok := m.clearedFields[name]
  31203. return ok
  31204. }
  31205. // ClearField clears the value of the field with the given name. It returns an
  31206. // error if the field is not defined in the schema.
  31207. func (m *UsageDetailMutation) ClearField(name string) error {
  31208. switch name {
  31209. case usagedetail.FieldStatus:
  31210. m.ClearStatus()
  31211. return nil
  31212. case usagedetail.FieldType:
  31213. m.ClearType()
  31214. return nil
  31215. case usagedetail.FieldApp:
  31216. m.ClearApp()
  31217. return nil
  31218. case usagedetail.FieldSessionID:
  31219. m.ClearSessionID()
  31220. return nil
  31221. case usagedetail.FieldTotalTokens:
  31222. m.ClearTotalTokens()
  31223. return nil
  31224. case usagedetail.FieldPromptTokens:
  31225. m.ClearPromptTokens()
  31226. return nil
  31227. case usagedetail.FieldCompletionTokens:
  31228. m.ClearCompletionTokens()
  31229. return nil
  31230. case usagedetail.FieldOrganizationID:
  31231. m.ClearOrganizationID()
  31232. return nil
  31233. }
  31234. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  31235. }
  31236. // ResetField resets all changes in the mutation for the field with the given name.
  31237. // It returns an error if the field is not defined in the schema.
  31238. func (m *UsageDetailMutation) ResetField(name string) error {
  31239. switch name {
  31240. case usagedetail.FieldCreatedAt:
  31241. m.ResetCreatedAt()
  31242. return nil
  31243. case usagedetail.FieldUpdatedAt:
  31244. m.ResetUpdatedAt()
  31245. return nil
  31246. case usagedetail.FieldStatus:
  31247. m.ResetStatus()
  31248. return nil
  31249. case usagedetail.FieldType:
  31250. m.ResetType()
  31251. return nil
  31252. case usagedetail.FieldBotID:
  31253. m.ResetBotID()
  31254. return nil
  31255. case usagedetail.FieldReceiverID:
  31256. m.ResetReceiverID()
  31257. return nil
  31258. case usagedetail.FieldApp:
  31259. m.ResetApp()
  31260. return nil
  31261. case usagedetail.FieldSessionID:
  31262. m.ResetSessionID()
  31263. return nil
  31264. case usagedetail.FieldRequest:
  31265. m.ResetRequest()
  31266. return nil
  31267. case usagedetail.FieldResponse:
  31268. m.ResetResponse()
  31269. return nil
  31270. case usagedetail.FieldOriginalData:
  31271. m.ResetOriginalData()
  31272. return nil
  31273. case usagedetail.FieldTotalTokens:
  31274. m.ResetTotalTokens()
  31275. return nil
  31276. case usagedetail.FieldPromptTokens:
  31277. m.ResetPromptTokens()
  31278. return nil
  31279. case usagedetail.FieldCompletionTokens:
  31280. m.ResetCompletionTokens()
  31281. return nil
  31282. case usagedetail.FieldOrganizationID:
  31283. m.ResetOrganizationID()
  31284. return nil
  31285. }
  31286. return fmt.Errorf("unknown UsageDetail field %s", name)
  31287. }
  31288. // AddedEdges returns all edge names that were set/added in this mutation.
  31289. func (m *UsageDetailMutation) AddedEdges() []string {
  31290. edges := make([]string, 0, 0)
  31291. return edges
  31292. }
  31293. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31294. // name in this mutation.
  31295. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  31296. return nil
  31297. }
  31298. // RemovedEdges returns all edge names that were removed in this mutation.
  31299. func (m *UsageDetailMutation) RemovedEdges() []string {
  31300. edges := make([]string, 0, 0)
  31301. return edges
  31302. }
  31303. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31304. // the given name in this mutation.
  31305. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  31306. return nil
  31307. }
  31308. // ClearedEdges returns all edge names that were cleared in this mutation.
  31309. func (m *UsageDetailMutation) ClearedEdges() []string {
  31310. edges := make([]string, 0, 0)
  31311. return edges
  31312. }
  31313. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31314. // was cleared in this mutation.
  31315. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  31316. return false
  31317. }
  31318. // ClearEdge clears the value of the edge with the given name. It returns an error
  31319. // if that edge is not defined in the schema.
  31320. func (m *UsageDetailMutation) ClearEdge(name string) error {
  31321. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  31322. }
  31323. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31324. // It returns an error if the edge is not defined in the schema.
  31325. func (m *UsageDetailMutation) ResetEdge(name string) error {
  31326. return fmt.Errorf("unknown UsageDetail edge %s", name)
  31327. }
  31328. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  31329. type UsageStatisticDayMutation struct {
  31330. config
  31331. op Op
  31332. typ string
  31333. id *uint64
  31334. created_at *time.Time
  31335. updated_at *time.Time
  31336. status *uint8
  31337. addstatus *int8
  31338. deleted_at *time.Time
  31339. addtime *uint64
  31340. addaddtime *int64
  31341. _type *int
  31342. add_type *int
  31343. bot_id *string
  31344. organization_id *uint64
  31345. addorganization_id *int64
  31346. ai_response *uint64
  31347. addai_response *int64
  31348. sop_run *uint64
  31349. addsop_run *int64
  31350. total_friend *uint64
  31351. addtotal_friend *int64
  31352. total_group *uint64
  31353. addtotal_group *int64
  31354. account_balance *uint64
  31355. addaccount_balance *int64
  31356. consume_token *uint64
  31357. addconsume_token *int64
  31358. active_user *uint64
  31359. addactive_user *int64
  31360. new_user *int64
  31361. addnew_user *int64
  31362. label_dist *[]custom_types.LabelDist
  31363. appendlabel_dist []custom_types.LabelDist
  31364. clearedFields map[string]struct{}
  31365. done bool
  31366. oldValue func(context.Context) (*UsageStatisticDay, error)
  31367. predicates []predicate.UsageStatisticDay
  31368. }
  31369. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  31370. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  31371. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  31372. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  31373. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  31374. m := &UsageStatisticDayMutation{
  31375. config: c,
  31376. op: op,
  31377. typ: TypeUsageStatisticDay,
  31378. clearedFields: make(map[string]struct{}),
  31379. }
  31380. for _, opt := range opts {
  31381. opt(m)
  31382. }
  31383. return m
  31384. }
  31385. // withUsageStatisticDayID sets the ID field of the mutation.
  31386. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  31387. return func(m *UsageStatisticDayMutation) {
  31388. var (
  31389. err error
  31390. once sync.Once
  31391. value *UsageStatisticDay
  31392. )
  31393. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  31394. once.Do(func() {
  31395. if m.done {
  31396. err = errors.New("querying old values post mutation is not allowed")
  31397. } else {
  31398. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  31399. }
  31400. })
  31401. return value, err
  31402. }
  31403. m.id = &id
  31404. }
  31405. }
  31406. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  31407. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  31408. return func(m *UsageStatisticDayMutation) {
  31409. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  31410. return node, nil
  31411. }
  31412. m.id = &node.ID
  31413. }
  31414. }
  31415. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31416. // executed in a transaction (ent.Tx), a transactional client is returned.
  31417. func (m UsageStatisticDayMutation) Client() *Client {
  31418. client := &Client{config: m.config}
  31419. client.init()
  31420. return client
  31421. }
  31422. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31423. // it returns an error otherwise.
  31424. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  31425. if _, ok := m.driver.(*txDriver); !ok {
  31426. return nil, errors.New("ent: mutation is not running in a transaction")
  31427. }
  31428. tx := &Tx{config: m.config}
  31429. tx.init()
  31430. return tx, nil
  31431. }
  31432. // SetID sets the value of the id field. Note that this
  31433. // operation is only accepted on creation of UsageStatisticDay entities.
  31434. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  31435. m.id = &id
  31436. }
  31437. // ID returns the ID value in the mutation. Note that the ID is only available
  31438. // if it was provided to the builder or after it was returned from the database.
  31439. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  31440. if m.id == nil {
  31441. return
  31442. }
  31443. return *m.id, true
  31444. }
  31445. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31446. // That means, if the mutation is applied within a transaction with an isolation level such
  31447. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31448. // or updated by the mutation.
  31449. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  31450. switch {
  31451. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31452. id, exists := m.ID()
  31453. if exists {
  31454. return []uint64{id}, nil
  31455. }
  31456. fallthrough
  31457. case m.op.Is(OpUpdate | OpDelete):
  31458. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  31459. default:
  31460. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31461. }
  31462. }
  31463. // SetCreatedAt sets the "created_at" field.
  31464. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  31465. m.created_at = &t
  31466. }
  31467. // CreatedAt returns the value of the "created_at" field in the mutation.
  31468. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  31469. v := m.created_at
  31470. if v == nil {
  31471. return
  31472. }
  31473. return *v, true
  31474. }
  31475. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  31476. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31478. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31479. if !m.op.Is(OpUpdateOne) {
  31480. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31481. }
  31482. if m.id == nil || m.oldValue == nil {
  31483. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31484. }
  31485. oldValue, err := m.oldValue(ctx)
  31486. if err != nil {
  31487. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31488. }
  31489. return oldValue.CreatedAt, nil
  31490. }
  31491. // ResetCreatedAt resets all changes to the "created_at" field.
  31492. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  31493. m.created_at = nil
  31494. }
  31495. // SetUpdatedAt sets the "updated_at" field.
  31496. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  31497. m.updated_at = &t
  31498. }
  31499. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31500. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  31501. v := m.updated_at
  31502. if v == nil {
  31503. return
  31504. }
  31505. return *v, true
  31506. }
  31507. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  31508. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31510. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31511. if !m.op.Is(OpUpdateOne) {
  31512. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31513. }
  31514. if m.id == nil || m.oldValue == nil {
  31515. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31516. }
  31517. oldValue, err := m.oldValue(ctx)
  31518. if err != nil {
  31519. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31520. }
  31521. return oldValue.UpdatedAt, nil
  31522. }
  31523. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31524. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  31525. m.updated_at = nil
  31526. }
  31527. // SetStatus sets the "status" field.
  31528. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  31529. m.status = &u
  31530. m.addstatus = nil
  31531. }
  31532. // Status returns the value of the "status" field in the mutation.
  31533. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  31534. v := m.status
  31535. if v == nil {
  31536. return
  31537. }
  31538. return *v, true
  31539. }
  31540. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  31541. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31543. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31544. if !m.op.Is(OpUpdateOne) {
  31545. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31546. }
  31547. if m.id == nil || m.oldValue == nil {
  31548. return v, errors.New("OldStatus requires an ID field in the mutation")
  31549. }
  31550. oldValue, err := m.oldValue(ctx)
  31551. if err != nil {
  31552. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31553. }
  31554. return oldValue.Status, nil
  31555. }
  31556. // AddStatus adds u to the "status" field.
  31557. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  31558. if m.addstatus != nil {
  31559. *m.addstatus += u
  31560. } else {
  31561. m.addstatus = &u
  31562. }
  31563. }
  31564. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31565. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  31566. v := m.addstatus
  31567. if v == nil {
  31568. return
  31569. }
  31570. return *v, true
  31571. }
  31572. // ClearStatus clears the value of the "status" field.
  31573. func (m *UsageStatisticDayMutation) ClearStatus() {
  31574. m.status = nil
  31575. m.addstatus = nil
  31576. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  31577. }
  31578. // StatusCleared returns if the "status" field was cleared in this mutation.
  31579. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  31580. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  31581. return ok
  31582. }
  31583. // ResetStatus resets all changes to the "status" field.
  31584. func (m *UsageStatisticDayMutation) ResetStatus() {
  31585. m.status = nil
  31586. m.addstatus = nil
  31587. delete(m.clearedFields, usagestatisticday.FieldStatus)
  31588. }
  31589. // SetDeletedAt sets the "deleted_at" field.
  31590. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  31591. m.deleted_at = &t
  31592. }
  31593. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31594. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  31595. v := m.deleted_at
  31596. if v == nil {
  31597. return
  31598. }
  31599. return *v, true
  31600. }
  31601. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  31602. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31604. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31605. if !m.op.Is(OpUpdateOne) {
  31606. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31607. }
  31608. if m.id == nil || m.oldValue == nil {
  31609. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31610. }
  31611. oldValue, err := m.oldValue(ctx)
  31612. if err != nil {
  31613. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31614. }
  31615. return oldValue.DeletedAt, nil
  31616. }
  31617. // ClearDeletedAt clears the value of the "deleted_at" field.
  31618. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  31619. m.deleted_at = nil
  31620. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  31621. }
  31622. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31623. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  31624. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  31625. return ok
  31626. }
  31627. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31628. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  31629. m.deleted_at = nil
  31630. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  31631. }
  31632. // SetAddtime sets the "addtime" field.
  31633. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  31634. m.addtime = &u
  31635. m.addaddtime = nil
  31636. }
  31637. // Addtime returns the value of the "addtime" field in the mutation.
  31638. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  31639. v := m.addtime
  31640. if v == nil {
  31641. return
  31642. }
  31643. return *v, true
  31644. }
  31645. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  31646. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31648. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31649. if !m.op.Is(OpUpdateOne) {
  31650. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31651. }
  31652. if m.id == nil || m.oldValue == nil {
  31653. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31654. }
  31655. oldValue, err := m.oldValue(ctx)
  31656. if err != nil {
  31657. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31658. }
  31659. return oldValue.Addtime, nil
  31660. }
  31661. // AddAddtime adds u to the "addtime" field.
  31662. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  31663. if m.addaddtime != nil {
  31664. *m.addaddtime += u
  31665. } else {
  31666. m.addaddtime = &u
  31667. }
  31668. }
  31669. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31670. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  31671. v := m.addaddtime
  31672. if v == nil {
  31673. return
  31674. }
  31675. return *v, true
  31676. }
  31677. // ResetAddtime resets all changes to the "addtime" field.
  31678. func (m *UsageStatisticDayMutation) ResetAddtime() {
  31679. m.addtime = nil
  31680. m.addaddtime = nil
  31681. }
  31682. // SetType sets the "type" field.
  31683. func (m *UsageStatisticDayMutation) SetType(i int) {
  31684. m._type = &i
  31685. m.add_type = nil
  31686. }
  31687. // GetType returns the value of the "type" field in the mutation.
  31688. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  31689. v := m._type
  31690. if v == nil {
  31691. return
  31692. }
  31693. return *v, true
  31694. }
  31695. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  31696. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31698. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  31699. if !m.op.Is(OpUpdateOne) {
  31700. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31701. }
  31702. if m.id == nil || m.oldValue == nil {
  31703. return v, errors.New("OldType requires an ID field in the mutation")
  31704. }
  31705. oldValue, err := m.oldValue(ctx)
  31706. if err != nil {
  31707. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31708. }
  31709. return oldValue.Type, nil
  31710. }
  31711. // AddType adds i to the "type" field.
  31712. func (m *UsageStatisticDayMutation) AddType(i int) {
  31713. if m.add_type != nil {
  31714. *m.add_type += i
  31715. } else {
  31716. m.add_type = &i
  31717. }
  31718. }
  31719. // AddedType returns the value that was added to the "type" field in this mutation.
  31720. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  31721. v := m.add_type
  31722. if v == nil {
  31723. return
  31724. }
  31725. return *v, true
  31726. }
  31727. // ResetType resets all changes to the "type" field.
  31728. func (m *UsageStatisticDayMutation) ResetType() {
  31729. m._type = nil
  31730. m.add_type = nil
  31731. }
  31732. // SetBotID sets the "bot_id" field.
  31733. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  31734. m.bot_id = &s
  31735. }
  31736. // BotID returns the value of the "bot_id" field in the mutation.
  31737. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  31738. v := m.bot_id
  31739. if v == nil {
  31740. return
  31741. }
  31742. return *v, true
  31743. }
  31744. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  31745. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31747. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  31748. if !m.op.Is(OpUpdateOne) {
  31749. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31750. }
  31751. if m.id == nil || m.oldValue == nil {
  31752. return v, errors.New("OldBotID requires an ID field in the mutation")
  31753. }
  31754. oldValue, err := m.oldValue(ctx)
  31755. if err != nil {
  31756. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31757. }
  31758. return oldValue.BotID, nil
  31759. }
  31760. // ClearBotID clears the value of the "bot_id" field.
  31761. func (m *UsageStatisticDayMutation) ClearBotID() {
  31762. m.bot_id = nil
  31763. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  31764. }
  31765. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31766. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  31767. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  31768. return ok
  31769. }
  31770. // ResetBotID resets all changes to the "bot_id" field.
  31771. func (m *UsageStatisticDayMutation) ResetBotID() {
  31772. m.bot_id = nil
  31773. delete(m.clearedFields, usagestatisticday.FieldBotID)
  31774. }
  31775. // SetOrganizationID sets the "organization_id" field.
  31776. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  31777. m.organization_id = &u
  31778. m.addorganization_id = nil
  31779. }
  31780. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31781. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  31782. v := m.organization_id
  31783. if v == nil {
  31784. return
  31785. }
  31786. return *v, true
  31787. }
  31788. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  31789. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31791. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31792. if !m.op.Is(OpUpdateOne) {
  31793. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31794. }
  31795. if m.id == nil || m.oldValue == nil {
  31796. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31797. }
  31798. oldValue, err := m.oldValue(ctx)
  31799. if err != nil {
  31800. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31801. }
  31802. return oldValue.OrganizationID, nil
  31803. }
  31804. // AddOrganizationID adds u to the "organization_id" field.
  31805. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  31806. if m.addorganization_id != nil {
  31807. *m.addorganization_id += u
  31808. } else {
  31809. m.addorganization_id = &u
  31810. }
  31811. }
  31812. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31813. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  31814. v := m.addorganization_id
  31815. if v == nil {
  31816. return
  31817. }
  31818. return *v, true
  31819. }
  31820. // ClearOrganizationID clears the value of the "organization_id" field.
  31821. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  31822. m.organization_id = nil
  31823. m.addorganization_id = nil
  31824. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  31825. }
  31826. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31827. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  31828. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  31829. return ok
  31830. }
  31831. // ResetOrganizationID resets all changes to the "organization_id" field.
  31832. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  31833. m.organization_id = nil
  31834. m.addorganization_id = nil
  31835. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  31836. }
  31837. // SetAiResponse sets the "ai_response" field.
  31838. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  31839. m.ai_response = &u
  31840. m.addai_response = nil
  31841. }
  31842. // AiResponse returns the value of the "ai_response" field in the mutation.
  31843. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  31844. v := m.ai_response
  31845. if v == nil {
  31846. return
  31847. }
  31848. return *v, true
  31849. }
  31850. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  31851. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31853. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31854. if !m.op.Is(OpUpdateOne) {
  31855. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31856. }
  31857. if m.id == nil || m.oldValue == nil {
  31858. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31859. }
  31860. oldValue, err := m.oldValue(ctx)
  31861. if err != nil {
  31862. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31863. }
  31864. return oldValue.AiResponse, nil
  31865. }
  31866. // AddAiResponse adds u to the "ai_response" field.
  31867. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  31868. if m.addai_response != nil {
  31869. *m.addai_response += u
  31870. } else {
  31871. m.addai_response = &u
  31872. }
  31873. }
  31874. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31875. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  31876. v := m.addai_response
  31877. if v == nil {
  31878. return
  31879. }
  31880. return *v, true
  31881. }
  31882. // ResetAiResponse resets all changes to the "ai_response" field.
  31883. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  31884. m.ai_response = nil
  31885. m.addai_response = nil
  31886. }
  31887. // SetSopRun sets the "sop_run" field.
  31888. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  31889. m.sop_run = &u
  31890. m.addsop_run = nil
  31891. }
  31892. // SopRun returns the value of the "sop_run" field in the mutation.
  31893. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  31894. v := m.sop_run
  31895. if v == nil {
  31896. return
  31897. }
  31898. return *v, true
  31899. }
  31900. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  31901. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31903. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31904. if !m.op.Is(OpUpdateOne) {
  31905. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31906. }
  31907. if m.id == nil || m.oldValue == nil {
  31908. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31909. }
  31910. oldValue, err := m.oldValue(ctx)
  31911. if err != nil {
  31912. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31913. }
  31914. return oldValue.SopRun, nil
  31915. }
  31916. // AddSopRun adds u to the "sop_run" field.
  31917. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  31918. if m.addsop_run != nil {
  31919. *m.addsop_run += u
  31920. } else {
  31921. m.addsop_run = &u
  31922. }
  31923. }
  31924. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31925. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  31926. v := m.addsop_run
  31927. if v == nil {
  31928. return
  31929. }
  31930. return *v, true
  31931. }
  31932. // ResetSopRun resets all changes to the "sop_run" field.
  31933. func (m *UsageStatisticDayMutation) ResetSopRun() {
  31934. m.sop_run = nil
  31935. m.addsop_run = nil
  31936. }
  31937. // SetTotalFriend sets the "total_friend" field.
  31938. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  31939. m.total_friend = &u
  31940. m.addtotal_friend = nil
  31941. }
  31942. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31943. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  31944. v := m.total_friend
  31945. if v == nil {
  31946. return
  31947. }
  31948. return *v, true
  31949. }
  31950. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  31951. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31953. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31954. if !m.op.Is(OpUpdateOne) {
  31955. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31956. }
  31957. if m.id == nil || m.oldValue == nil {
  31958. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31959. }
  31960. oldValue, err := m.oldValue(ctx)
  31961. if err != nil {
  31962. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31963. }
  31964. return oldValue.TotalFriend, nil
  31965. }
  31966. // AddTotalFriend adds u to the "total_friend" field.
  31967. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  31968. if m.addtotal_friend != nil {
  31969. *m.addtotal_friend += u
  31970. } else {
  31971. m.addtotal_friend = &u
  31972. }
  31973. }
  31974. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31975. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  31976. v := m.addtotal_friend
  31977. if v == nil {
  31978. return
  31979. }
  31980. return *v, true
  31981. }
  31982. // ResetTotalFriend resets all changes to the "total_friend" field.
  31983. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  31984. m.total_friend = nil
  31985. m.addtotal_friend = nil
  31986. }
  31987. // SetTotalGroup sets the "total_group" field.
  31988. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  31989. m.total_group = &u
  31990. m.addtotal_group = nil
  31991. }
  31992. // TotalGroup returns the value of the "total_group" field in the mutation.
  31993. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  31994. v := m.total_group
  31995. if v == nil {
  31996. return
  31997. }
  31998. return *v, true
  31999. }
  32000. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  32001. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32003. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32004. if !m.op.Is(OpUpdateOne) {
  32005. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32006. }
  32007. if m.id == nil || m.oldValue == nil {
  32008. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32009. }
  32010. oldValue, err := m.oldValue(ctx)
  32011. if err != nil {
  32012. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32013. }
  32014. return oldValue.TotalGroup, nil
  32015. }
  32016. // AddTotalGroup adds u to the "total_group" field.
  32017. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  32018. if m.addtotal_group != nil {
  32019. *m.addtotal_group += u
  32020. } else {
  32021. m.addtotal_group = &u
  32022. }
  32023. }
  32024. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32025. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  32026. v := m.addtotal_group
  32027. if v == nil {
  32028. return
  32029. }
  32030. return *v, true
  32031. }
  32032. // ResetTotalGroup resets all changes to the "total_group" field.
  32033. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  32034. m.total_group = nil
  32035. m.addtotal_group = nil
  32036. }
  32037. // SetAccountBalance sets the "account_balance" field.
  32038. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  32039. m.account_balance = &u
  32040. m.addaccount_balance = nil
  32041. }
  32042. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32043. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  32044. v := m.account_balance
  32045. if v == nil {
  32046. return
  32047. }
  32048. return *v, true
  32049. }
  32050. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  32051. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32053. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32054. if !m.op.Is(OpUpdateOne) {
  32055. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32056. }
  32057. if m.id == nil || m.oldValue == nil {
  32058. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32059. }
  32060. oldValue, err := m.oldValue(ctx)
  32061. if err != nil {
  32062. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32063. }
  32064. return oldValue.AccountBalance, nil
  32065. }
  32066. // AddAccountBalance adds u to the "account_balance" field.
  32067. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  32068. if m.addaccount_balance != nil {
  32069. *m.addaccount_balance += u
  32070. } else {
  32071. m.addaccount_balance = &u
  32072. }
  32073. }
  32074. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32075. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  32076. v := m.addaccount_balance
  32077. if v == nil {
  32078. return
  32079. }
  32080. return *v, true
  32081. }
  32082. // ResetAccountBalance resets all changes to the "account_balance" field.
  32083. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  32084. m.account_balance = nil
  32085. m.addaccount_balance = nil
  32086. }
  32087. // SetConsumeToken sets the "consume_token" field.
  32088. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  32089. m.consume_token = &u
  32090. m.addconsume_token = nil
  32091. }
  32092. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32093. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  32094. v := m.consume_token
  32095. if v == nil {
  32096. return
  32097. }
  32098. return *v, true
  32099. }
  32100. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  32101. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32103. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32104. if !m.op.Is(OpUpdateOne) {
  32105. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32106. }
  32107. if m.id == nil || m.oldValue == nil {
  32108. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32109. }
  32110. oldValue, err := m.oldValue(ctx)
  32111. if err != nil {
  32112. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32113. }
  32114. return oldValue.ConsumeToken, nil
  32115. }
  32116. // AddConsumeToken adds u to the "consume_token" field.
  32117. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  32118. if m.addconsume_token != nil {
  32119. *m.addconsume_token += u
  32120. } else {
  32121. m.addconsume_token = &u
  32122. }
  32123. }
  32124. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  32125. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  32126. v := m.addconsume_token
  32127. if v == nil {
  32128. return
  32129. }
  32130. return *v, true
  32131. }
  32132. // ResetConsumeToken resets all changes to the "consume_token" field.
  32133. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  32134. m.consume_token = nil
  32135. m.addconsume_token = nil
  32136. }
  32137. // SetActiveUser sets the "active_user" field.
  32138. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  32139. m.active_user = &u
  32140. m.addactive_user = nil
  32141. }
  32142. // ActiveUser returns the value of the "active_user" field in the mutation.
  32143. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  32144. v := m.active_user
  32145. if v == nil {
  32146. return
  32147. }
  32148. return *v, true
  32149. }
  32150. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  32151. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32153. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32154. if !m.op.Is(OpUpdateOne) {
  32155. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32156. }
  32157. if m.id == nil || m.oldValue == nil {
  32158. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32159. }
  32160. oldValue, err := m.oldValue(ctx)
  32161. if err != nil {
  32162. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32163. }
  32164. return oldValue.ActiveUser, nil
  32165. }
  32166. // AddActiveUser adds u to the "active_user" field.
  32167. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  32168. if m.addactive_user != nil {
  32169. *m.addactive_user += u
  32170. } else {
  32171. m.addactive_user = &u
  32172. }
  32173. }
  32174. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32175. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  32176. v := m.addactive_user
  32177. if v == nil {
  32178. return
  32179. }
  32180. return *v, true
  32181. }
  32182. // ResetActiveUser resets all changes to the "active_user" field.
  32183. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  32184. m.active_user = nil
  32185. m.addactive_user = nil
  32186. }
  32187. // SetNewUser sets the "new_user" field.
  32188. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  32189. m.new_user = &i
  32190. m.addnew_user = nil
  32191. }
  32192. // NewUser returns the value of the "new_user" field in the mutation.
  32193. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  32194. v := m.new_user
  32195. if v == nil {
  32196. return
  32197. }
  32198. return *v, true
  32199. }
  32200. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  32201. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32203. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32204. if !m.op.Is(OpUpdateOne) {
  32205. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32206. }
  32207. if m.id == nil || m.oldValue == nil {
  32208. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32209. }
  32210. oldValue, err := m.oldValue(ctx)
  32211. if err != nil {
  32212. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32213. }
  32214. return oldValue.NewUser, nil
  32215. }
  32216. // AddNewUser adds i to the "new_user" field.
  32217. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  32218. if m.addnew_user != nil {
  32219. *m.addnew_user += i
  32220. } else {
  32221. m.addnew_user = &i
  32222. }
  32223. }
  32224. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32225. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  32226. v := m.addnew_user
  32227. if v == nil {
  32228. return
  32229. }
  32230. return *v, true
  32231. }
  32232. // ResetNewUser resets all changes to the "new_user" field.
  32233. func (m *UsageStatisticDayMutation) ResetNewUser() {
  32234. m.new_user = nil
  32235. m.addnew_user = nil
  32236. }
  32237. // SetLabelDist sets the "label_dist" field.
  32238. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32239. m.label_dist = &ctd
  32240. m.appendlabel_dist = nil
  32241. }
  32242. // LabelDist returns the value of the "label_dist" field in the mutation.
  32243. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32244. v := m.label_dist
  32245. if v == nil {
  32246. return
  32247. }
  32248. return *v, true
  32249. }
  32250. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  32251. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32253. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32254. if !m.op.Is(OpUpdateOne) {
  32255. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32256. }
  32257. if m.id == nil || m.oldValue == nil {
  32258. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32259. }
  32260. oldValue, err := m.oldValue(ctx)
  32261. if err != nil {
  32262. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32263. }
  32264. return oldValue.LabelDist, nil
  32265. }
  32266. // AppendLabelDist adds ctd to the "label_dist" field.
  32267. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32268. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32269. }
  32270. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32271. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32272. if len(m.appendlabel_dist) == 0 {
  32273. return nil, false
  32274. }
  32275. return m.appendlabel_dist, true
  32276. }
  32277. // ResetLabelDist resets all changes to the "label_dist" field.
  32278. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  32279. m.label_dist = nil
  32280. m.appendlabel_dist = nil
  32281. }
  32282. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  32283. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  32284. m.predicates = append(m.predicates, ps...)
  32285. }
  32286. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  32287. // users can use type-assertion to append predicates that do not depend on any generated package.
  32288. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  32289. p := make([]predicate.UsageStatisticDay, len(ps))
  32290. for i := range ps {
  32291. p[i] = ps[i]
  32292. }
  32293. m.Where(p...)
  32294. }
  32295. // Op returns the operation name.
  32296. func (m *UsageStatisticDayMutation) Op() Op {
  32297. return m.op
  32298. }
  32299. // SetOp allows setting the mutation operation.
  32300. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  32301. m.op = op
  32302. }
  32303. // Type returns the node type of this mutation (UsageStatisticDay).
  32304. func (m *UsageStatisticDayMutation) Type() string {
  32305. return m.typ
  32306. }
  32307. // Fields returns all fields that were changed during this mutation. Note that in
  32308. // order to get all numeric fields that were incremented/decremented, call
  32309. // AddedFields().
  32310. func (m *UsageStatisticDayMutation) Fields() []string {
  32311. fields := make([]string, 0, 17)
  32312. if m.created_at != nil {
  32313. fields = append(fields, usagestatisticday.FieldCreatedAt)
  32314. }
  32315. if m.updated_at != nil {
  32316. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  32317. }
  32318. if m.status != nil {
  32319. fields = append(fields, usagestatisticday.FieldStatus)
  32320. }
  32321. if m.deleted_at != nil {
  32322. fields = append(fields, usagestatisticday.FieldDeletedAt)
  32323. }
  32324. if m.addtime != nil {
  32325. fields = append(fields, usagestatisticday.FieldAddtime)
  32326. }
  32327. if m._type != nil {
  32328. fields = append(fields, usagestatisticday.FieldType)
  32329. }
  32330. if m.bot_id != nil {
  32331. fields = append(fields, usagestatisticday.FieldBotID)
  32332. }
  32333. if m.organization_id != nil {
  32334. fields = append(fields, usagestatisticday.FieldOrganizationID)
  32335. }
  32336. if m.ai_response != nil {
  32337. fields = append(fields, usagestatisticday.FieldAiResponse)
  32338. }
  32339. if m.sop_run != nil {
  32340. fields = append(fields, usagestatisticday.FieldSopRun)
  32341. }
  32342. if m.total_friend != nil {
  32343. fields = append(fields, usagestatisticday.FieldTotalFriend)
  32344. }
  32345. if m.total_group != nil {
  32346. fields = append(fields, usagestatisticday.FieldTotalGroup)
  32347. }
  32348. if m.account_balance != nil {
  32349. fields = append(fields, usagestatisticday.FieldAccountBalance)
  32350. }
  32351. if m.consume_token != nil {
  32352. fields = append(fields, usagestatisticday.FieldConsumeToken)
  32353. }
  32354. if m.active_user != nil {
  32355. fields = append(fields, usagestatisticday.FieldActiveUser)
  32356. }
  32357. if m.new_user != nil {
  32358. fields = append(fields, usagestatisticday.FieldNewUser)
  32359. }
  32360. if m.label_dist != nil {
  32361. fields = append(fields, usagestatisticday.FieldLabelDist)
  32362. }
  32363. return fields
  32364. }
  32365. // Field returns the value of a field with the given name. The second boolean
  32366. // return value indicates that this field was not set, or was not defined in the
  32367. // schema.
  32368. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  32369. switch name {
  32370. case usagestatisticday.FieldCreatedAt:
  32371. return m.CreatedAt()
  32372. case usagestatisticday.FieldUpdatedAt:
  32373. return m.UpdatedAt()
  32374. case usagestatisticday.FieldStatus:
  32375. return m.Status()
  32376. case usagestatisticday.FieldDeletedAt:
  32377. return m.DeletedAt()
  32378. case usagestatisticday.FieldAddtime:
  32379. return m.Addtime()
  32380. case usagestatisticday.FieldType:
  32381. return m.GetType()
  32382. case usagestatisticday.FieldBotID:
  32383. return m.BotID()
  32384. case usagestatisticday.FieldOrganizationID:
  32385. return m.OrganizationID()
  32386. case usagestatisticday.FieldAiResponse:
  32387. return m.AiResponse()
  32388. case usagestatisticday.FieldSopRun:
  32389. return m.SopRun()
  32390. case usagestatisticday.FieldTotalFriend:
  32391. return m.TotalFriend()
  32392. case usagestatisticday.FieldTotalGroup:
  32393. return m.TotalGroup()
  32394. case usagestatisticday.FieldAccountBalance:
  32395. return m.AccountBalance()
  32396. case usagestatisticday.FieldConsumeToken:
  32397. return m.ConsumeToken()
  32398. case usagestatisticday.FieldActiveUser:
  32399. return m.ActiveUser()
  32400. case usagestatisticday.FieldNewUser:
  32401. return m.NewUser()
  32402. case usagestatisticday.FieldLabelDist:
  32403. return m.LabelDist()
  32404. }
  32405. return nil, false
  32406. }
  32407. // OldField returns the old value of the field from the database. An error is
  32408. // returned if the mutation operation is not UpdateOne, or the query to the
  32409. // database failed.
  32410. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32411. switch name {
  32412. case usagestatisticday.FieldCreatedAt:
  32413. return m.OldCreatedAt(ctx)
  32414. case usagestatisticday.FieldUpdatedAt:
  32415. return m.OldUpdatedAt(ctx)
  32416. case usagestatisticday.FieldStatus:
  32417. return m.OldStatus(ctx)
  32418. case usagestatisticday.FieldDeletedAt:
  32419. return m.OldDeletedAt(ctx)
  32420. case usagestatisticday.FieldAddtime:
  32421. return m.OldAddtime(ctx)
  32422. case usagestatisticday.FieldType:
  32423. return m.OldType(ctx)
  32424. case usagestatisticday.FieldBotID:
  32425. return m.OldBotID(ctx)
  32426. case usagestatisticday.FieldOrganizationID:
  32427. return m.OldOrganizationID(ctx)
  32428. case usagestatisticday.FieldAiResponse:
  32429. return m.OldAiResponse(ctx)
  32430. case usagestatisticday.FieldSopRun:
  32431. return m.OldSopRun(ctx)
  32432. case usagestatisticday.FieldTotalFriend:
  32433. return m.OldTotalFriend(ctx)
  32434. case usagestatisticday.FieldTotalGroup:
  32435. return m.OldTotalGroup(ctx)
  32436. case usagestatisticday.FieldAccountBalance:
  32437. return m.OldAccountBalance(ctx)
  32438. case usagestatisticday.FieldConsumeToken:
  32439. return m.OldConsumeToken(ctx)
  32440. case usagestatisticday.FieldActiveUser:
  32441. return m.OldActiveUser(ctx)
  32442. case usagestatisticday.FieldNewUser:
  32443. return m.OldNewUser(ctx)
  32444. case usagestatisticday.FieldLabelDist:
  32445. return m.OldLabelDist(ctx)
  32446. }
  32447. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  32448. }
  32449. // SetField sets the value of a field with the given name. It returns an error if
  32450. // the field is not defined in the schema, or if the type mismatched the field
  32451. // type.
  32452. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  32453. switch name {
  32454. case usagestatisticday.FieldCreatedAt:
  32455. v, ok := value.(time.Time)
  32456. if !ok {
  32457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32458. }
  32459. m.SetCreatedAt(v)
  32460. return nil
  32461. case usagestatisticday.FieldUpdatedAt:
  32462. v, ok := value.(time.Time)
  32463. if !ok {
  32464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32465. }
  32466. m.SetUpdatedAt(v)
  32467. return nil
  32468. case usagestatisticday.FieldStatus:
  32469. v, ok := value.(uint8)
  32470. if !ok {
  32471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32472. }
  32473. m.SetStatus(v)
  32474. return nil
  32475. case usagestatisticday.FieldDeletedAt:
  32476. v, ok := value.(time.Time)
  32477. if !ok {
  32478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32479. }
  32480. m.SetDeletedAt(v)
  32481. return nil
  32482. case usagestatisticday.FieldAddtime:
  32483. v, ok := value.(uint64)
  32484. if !ok {
  32485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32486. }
  32487. m.SetAddtime(v)
  32488. return nil
  32489. case usagestatisticday.FieldType:
  32490. v, ok := value.(int)
  32491. if !ok {
  32492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32493. }
  32494. m.SetType(v)
  32495. return nil
  32496. case usagestatisticday.FieldBotID:
  32497. v, ok := value.(string)
  32498. if !ok {
  32499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32500. }
  32501. m.SetBotID(v)
  32502. return nil
  32503. case usagestatisticday.FieldOrganizationID:
  32504. v, ok := value.(uint64)
  32505. if !ok {
  32506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32507. }
  32508. m.SetOrganizationID(v)
  32509. return nil
  32510. case usagestatisticday.FieldAiResponse:
  32511. v, ok := value.(uint64)
  32512. if !ok {
  32513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32514. }
  32515. m.SetAiResponse(v)
  32516. return nil
  32517. case usagestatisticday.FieldSopRun:
  32518. v, ok := value.(uint64)
  32519. if !ok {
  32520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32521. }
  32522. m.SetSopRun(v)
  32523. return nil
  32524. case usagestatisticday.FieldTotalFriend:
  32525. v, ok := value.(uint64)
  32526. if !ok {
  32527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32528. }
  32529. m.SetTotalFriend(v)
  32530. return nil
  32531. case usagestatisticday.FieldTotalGroup:
  32532. v, ok := value.(uint64)
  32533. if !ok {
  32534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32535. }
  32536. m.SetTotalGroup(v)
  32537. return nil
  32538. case usagestatisticday.FieldAccountBalance:
  32539. v, ok := value.(uint64)
  32540. if !ok {
  32541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32542. }
  32543. m.SetAccountBalance(v)
  32544. return nil
  32545. case usagestatisticday.FieldConsumeToken:
  32546. v, ok := value.(uint64)
  32547. if !ok {
  32548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32549. }
  32550. m.SetConsumeToken(v)
  32551. return nil
  32552. case usagestatisticday.FieldActiveUser:
  32553. v, ok := value.(uint64)
  32554. if !ok {
  32555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32556. }
  32557. m.SetActiveUser(v)
  32558. return nil
  32559. case usagestatisticday.FieldNewUser:
  32560. v, ok := value.(int64)
  32561. if !ok {
  32562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32563. }
  32564. m.SetNewUser(v)
  32565. return nil
  32566. case usagestatisticday.FieldLabelDist:
  32567. v, ok := value.([]custom_types.LabelDist)
  32568. if !ok {
  32569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32570. }
  32571. m.SetLabelDist(v)
  32572. return nil
  32573. }
  32574. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  32575. }
  32576. // AddedFields returns all numeric fields that were incremented/decremented during
  32577. // this mutation.
  32578. func (m *UsageStatisticDayMutation) AddedFields() []string {
  32579. var fields []string
  32580. if m.addstatus != nil {
  32581. fields = append(fields, usagestatisticday.FieldStatus)
  32582. }
  32583. if m.addaddtime != nil {
  32584. fields = append(fields, usagestatisticday.FieldAddtime)
  32585. }
  32586. if m.add_type != nil {
  32587. fields = append(fields, usagestatisticday.FieldType)
  32588. }
  32589. if m.addorganization_id != nil {
  32590. fields = append(fields, usagestatisticday.FieldOrganizationID)
  32591. }
  32592. if m.addai_response != nil {
  32593. fields = append(fields, usagestatisticday.FieldAiResponse)
  32594. }
  32595. if m.addsop_run != nil {
  32596. fields = append(fields, usagestatisticday.FieldSopRun)
  32597. }
  32598. if m.addtotal_friend != nil {
  32599. fields = append(fields, usagestatisticday.FieldTotalFriend)
  32600. }
  32601. if m.addtotal_group != nil {
  32602. fields = append(fields, usagestatisticday.FieldTotalGroup)
  32603. }
  32604. if m.addaccount_balance != nil {
  32605. fields = append(fields, usagestatisticday.FieldAccountBalance)
  32606. }
  32607. if m.addconsume_token != nil {
  32608. fields = append(fields, usagestatisticday.FieldConsumeToken)
  32609. }
  32610. if m.addactive_user != nil {
  32611. fields = append(fields, usagestatisticday.FieldActiveUser)
  32612. }
  32613. if m.addnew_user != nil {
  32614. fields = append(fields, usagestatisticday.FieldNewUser)
  32615. }
  32616. return fields
  32617. }
  32618. // AddedField returns the numeric value that was incremented/decremented on a field
  32619. // with the given name. The second boolean return value indicates that this field
  32620. // was not set, or was not defined in the schema.
  32621. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  32622. switch name {
  32623. case usagestatisticday.FieldStatus:
  32624. return m.AddedStatus()
  32625. case usagestatisticday.FieldAddtime:
  32626. return m.AddedAddtime()
  32627. case usagestatisticday.FieldType:
  32628. return m.AddedType()
  32629. case usagestatisticday.FieldOrganizationID:
  32630. return m.AddedOrganizationID()
  32631. case usagestatisticday.FieldAiResponse:
  32632. return m.AddedAiResponse()
  32633. case usagestatisticday.FieldSopRun:
  32634. return m.AddedSopRun()
  32635. case usagestatisticday.FieldTotalFriend:
  32636. return m.AddedTotalFriend()
  32637. case usagestatisticday.FieldTotalGroup:
  32638. return m.AddedTotalGroup()
  32639. case usagestatisticday.FieldAccountBalance:
  32640. return m.AddedAccountBalance()
  32641. case usagestatisticday.FieldConsumeToken:
  32642. return m.AddedConsumeToken()
  32643. case usagestatisticday.FieldActiveUser:
  32644. return m.AddedActiveUser()
  32645. case usagestatisticday.FieldNewUser:
  32646. return m.AddedNewUser()
  32647. }
  32648. return nil, false
  32649. }
  32650. // AddField adds the value to the field with the given name. It returns an error if
  32651. // the field is not defined in the schema, or if the type mismatched the field
  32652. // type.
  32653. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  32654. switch name {
  32655. case usagestatisticday.FieldStatus:
  32656. v, ok := value.(int8)
  32657. if !ok {
  32658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32659. }
  32660. m.AddStatus(v)
  32661. return nil
  32662. case usagestatisticday.FieldAddtime:
  32663. v, ok := value.(int64)
  32664. if !ok {
  32665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32666. }
  32667. m.AddAddtime(v)
  32668. return nil
  32669. case usagestatisticday.FieldType:
  32670. v, ok := value.(int)
  32671. if !ok {
  32672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32673. }
  32674. m.AddType(v)
  32675. return nil
  32676. case usagestatisticday.FieldOrganizationID:
  32677. v, ok := value.(int64)
  32678. if !ok {
  32679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32680. }
  32681. m.AddOrganizationID(v)
  32682. return nil
  32683. case usagestatisticday.FieldAiResponse:
  32684. v, ok := value.(int64)
  32685. if !ok {
  32686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32687. }
  32688. m.AddAiResponse(v)
  32689. return nil
  32690. case usagestatisticday.FieldSopRun:
  32691. v, ok := value.(int64)
  32692. if !ok {
  32693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32694. }
  32695. m.AddSopRun(v)
  32696. return nil
  32697. case usagestatisticday.FieldTotalFriend:
  32698. v, ok := value.(int64)
  32699. if !ok {
  32700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32701. }
  32702. m.AddTotalFriend(v)
  32703. return nil
  32704. case usagestatisticday.FieldTotalGroup:
  32705. v, ok := value.(int64)
  32706. if !ok {
  32707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32708. }
  32709. m.AddTotalGroup(v)
  32710. return nil
  32711. case usagestatisticday.FieldAccountBalance:
  32712. v, ok := value.(int64)
  32713. if !ok {
  32714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32715. }
  32716. m.AddAccountBalance(v)
  32717. return nil
  32718. case usagestatisticday.FieldConsumeToken:
  32719. v, ok := value.(int64)
  32720. if !ok {
  32721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32722. }
  32723. m.AddConsumeToken(v)
  32724. return nil
  32725. case usagestatisticday.FieldActiveUser:
  32726. v, ok := value.(int64)
  32727. if !ok {
  32728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32729. }
  32730. m.AddActiveUser(v)
  32731. return nil
  32732. case usagestatisticday.FieldNewUser:
  32733. v, ok := value.(int64)
  32734. if !ok {
  32735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32736. }
  32737. m.AddNewUser(v)
  32738. return nil
  32739. }
  32740. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  32741. }
  32742. // ClearedFields returns all nullable fields that were cleared during this
  32743. // mutation.
  32744. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  32745. var fields []string
  32746. if m.FieldCleared(usagestatisticday.FieldStatus) {
  32747. fields = append(fields, usagestatisticday.FieldStatus)
  32748. }
  32749. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  32750. fields = append(fields, usagestatisticday.FieldDeletedAt)
  32751. }
  32752. if m.FieldCleared(usagestatisticday.FieldBotID) {
  32753. fields = append(fields, usagestatisticday.FieldBotID)
  32754. }
  32755. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  32756. fields = append(fields, usagestatisticday.FieldOrganizationID)
  32757. }
  32758. return fields
  32759. }
  32760. // FieldCleared returns a boolean indicating if a field with the given name was
  32761. // cleared in this mutation.
  32762. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  32763. _, ok := m.clearedFields[name]
  32764. return ok
  32765. }
  32766. // ClearField clears the value of the field with the given name. It returns an
  32767. // error if the field is not defined in the schema.
  32768. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  32769. switch name {
  32770. case usagestatisticday.FieldStatus:
  32771. m.ClearStatus()
  32772. return nil
  32773. case usagestatisticday.FieldDeletedAt:
  32774. m.ClearDeletedAt()
  32775. return nil
  32776. case usagestatisticday.FieldBotID:
  32777. m.ClearBotID()
  32778. return nil
  32779. case usagestatisticday.FieldOrganizationID:
  32780. m.ClearOrganizationID()
  32781. return nil
  32782. }
  32783. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  32784. }
  32785. // ResetField resets all changes in the mutation for the field with the given name.
  32786. // It returns an error if the field is not defined in the schema.
  32787. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  32788. switch name {
  32789. case usagestatisticday.FieldCreatedAt:
  32790. m.ResetCreatedAt()
  32791. return nil
  32792. case usagestatisticday.FieldUpdatedAt:
  32793. m.ResetUpdatedAt()
  32794. return nil
  32795. case usagestatisticday.FieldStatus:
  32796. m.ResetStatus()
  32797. return nil
  32798. case usagestatisticday.FieldDeletedAt:
  32799. m.ResetDeletedAt()
  32800. return nil
  32801. case usagestatisticday.FieldAddtime:
  32802. m.ResetAddtime()
  32803. return nil
  32804. case usagestatisticday.FieldType:
  32805. m.ResetType()
  32806. return nil
  32807. case usagestatisticday.FieldBotID:
  32808. m.ResetBotID()
  32809. return nil
  32810. case usagestatisticday.FieldOrganizationID:
  32811. m.ResetOrganizationID()
  32812. return nil
  32813. case usagestatisticday.FieldAiResponse:
  32814. m.ResetAiResponse()
  32815. return nil
  32816. case usagestatisticday.FieldSopRun:
  32817. m.ResetSopRun()
  32818. return nil
  32819. case usagestatisticday.FieldTotalFriend:
  32820. m.ResetTotalFriend()
  32821. return nil
  32822. case usagestatisticday.FieldTotalGroup:
  32823. m.ResetTotalGroup()
  32824. return nil
  32825. case usagestatisticday.FieldAccountBalance:
  32826. m.ResetAccountBalance()
  32827. return nil
  32828. case usagestatisticday.FieldConsumeToken:
  32829. m.ResetConsumeToken()
  32830. return nil
  32831. case usagestatisticday.FieldActiveUser:
  32832. m.ResetActiveUser()
  32833. return nil
  32834. case usagestatisticday.FieldNewUser:
  32835. m.ResetNewUser()
  32836. return nil
  32837. case usagestatisticday.FieldLabelDist:
  32838. m.ResetLabelDist()
  32839. return nil
  32840. }
  32841. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  32842. }
  32843. // AddedEdges returns all edge names that were set/added in this mutation.
  32844. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  32845. edges := make([]string, 0, 0)
  32846. return edges
  32847. }
  32848. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32849. // name in this mutation.
  32850. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  32851. return nil
  32852. }
  32853. // RemovedEdges returns all edge names that were removed in this mutation.
  32854. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  32855. edges := make([]string, 0, 0)
  32856. return edges
  32857. }
  32858. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32859. // the given name in this mutation.
  32860. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  32861. return nil
  32862. }
  32863. // ClearedEdges returns all edge names that were cleared in this mutation.
  32864. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  32865. edges := make([]string, 0, 0)
  32866. return edges
  32867. }
  32868. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32869. // was cleared in this mutation.
  32870. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  32871. return false
  32872. }
  32873. // ClearEdge clears the value of the edge with the given name. It returns an error
  32874. // if that edge is not defined in the schema.
  32875. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  32876. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  32877. }
  32878. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32879. // It returns an error if the edge is not defined in the schema.
  32880. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  32881. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  32882. }
  32883. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  32884. type UsageStatisticHourMutation struct {
  32885. config
  32886. op Op
  32887. typ string
  32888. id *uint64
  32889. created_at *time.Time
  32890. updated_at *time.Time
  32891. status *uint8
  32892. addstatus *int8
  32893. deleted_at *time.Time
  32894. addtime *uint64
  32895. addaddtime *int64
  32896. _type *int
  32897. add_type *int
  32898. bot_id *string
  32899. organization_id *uint64
  32900. addorganization_id *int64
  32901. ai_response *uint64
  32902. addai_response *int64
  32903. sop_run *uint64
  32904. addsop_run *int64
  32905. total_friend *uint64
  32906. addtotal_friend *int64
  32907. total_group *uint64
  32908. addtotal_group *int64
  32909. account_balance *uint64
  32910. addaccount_balance *int64
  32911. consume_token *uint64
  32912. addconsume_token *int64
  32913. active_user *uint64
  32914. addactive_user *int64
  32915. new_user *int64
  32916. addnew_user *int64
  32917. label_dist *[]custom_types.LabelDist
  32918. appendlabel_dist []custom_types.LabelDist
  32919. clearedFields map[string]struct{}
  32920. done bool
  32921. oldValue func(context.Context) (*UsageStatisticHour, error)
  32922. predicates []predicate.UsageStatisticHour
  32923. }
  32924. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  32925. // usagestatistichourOption allows management of the mutation configuration using functional options.
  32926. type usagestatistichourOption func(*UsageStatisticHourMutation)
  32927. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  32928. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  32929. m := &UsageStatisticHourMutation{
  32930. config: c,
  32931. op: op,
  32932. typ: TypeUsageStatisticHour,
  32933. clearedFields: make(map[string]struct{}),
  32934. }
  32935. for _, opt := range opts {
  32936. opt(m)
  32937. }
  32938. return m
  32939. }
  32940. // withUsageStatisticHourID sets the ID field of the mutation.
  32941. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  32942. return func(m *UsageStatisticHourMutation) {
  32943. var (
  32944. err error
  32945. once sync.Once
  32946. value *UsageStatisticHour
  32947. )
  32948. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  32949. once.Do(func() {
  32950. if m.done {
  32951. err = errors.New("querying old values post mutation is not allowed")
  32952. } else {
  32953. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  32954. }
  32955. })
  32956. return value, err
  32957. }
  32958. m.id = &id
  32959. }
  32960. }
  32961. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  32962. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  32963. return func(m *UsageStatisticHourMutation) {
  32964. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  32965. return node, nil
  32966. }
  32967. m.id = &node.ID
  32968. }
  32969. }
  32970. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32971. // executed in a transaction (ent.Tx), a transactional client is returned.
  32972. func (m UsageStatisticHourMutation) Client() *Client {
  32973. client := &Client{config: m.config}
  32974. client.init()
  32975. return client
  32976. }
  32977. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32978. // it returns an error otherwise.
  32979. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  32980. if _, ok := m.driver.(*txDriver); !ok {
  32981. return nil, errors.New("ent: mutation is not running in a transaction")
  32982. }
  32983. tx := &Tx{config: m.config}
  32984. tx.init()
  32985. return tx, nil
  32986. }
  32987. // SetID sets the value of the id field. Note that this
  32988. // operation is only accepted on creation of UsageStatisticHour entities.
  32989. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  32990. m.id = &id
  32991. }
  32992. // ID returns the ID value in the mutation. Note that the ID is only available
  32993. // if it was provided to the builder or after it was returned from the database.
  32994. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  32995. if m.id == nil {
  32996. return
  32997. }
  32998. return *m.id, true
  32999. }
  33000. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33001. // That means, if the mutation is applied within a transaction with an isolation level such
  33002. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33003. // or updated by the mutation.
  33004. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  33005. switch {
  33006. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33007. id, exists := m.ID()
  33008. if exists {
  33009. return []uint64{id}, nil
  33010. }
  33011. fallthrough
  33012. case m.op.Is(OpUpdate | OpDelete):
  33013. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  33014. default:
  33015. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33016. }
  33017. }
  33018. // SetCreatedAt sets the "created_at" field.
  33019. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  33020. m.created_at = &t
  33021. }
  33022. // CreatedAt returns the value of the "created_at" field in the mutation.
  33023. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  33024. v := m.created_at
  33025. if v == nil {
  33026. return
  33027. }
  33028. return *v, true
  33029. }
  33030. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  33031. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33033. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33034. if !m.op.Is(OpUpdateOne) {
  33035. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33036. }
  33037. if m.id == nil || m.oldValue == nil {
  33038. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33039. }
  33040. oldValue, err := m.oldValue(ctx)
  33041. if err != nil {
  33042. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33043. }
  33044. return oldValue.CreatedAt, nil
  33045. }
  33046. // ResetCreatedAt resets all changes to the "created_at" field.
  33047. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  33048. m.created_at = nil
  33049. }
  33050. // SetUpdatedAt sets the "updated_at" field.
  33051. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  33052. m.updated_at = &t
  33053. }
  33054. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33055. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  33056. v := m.updated_at
  33057. if v == nil {
  33058. return
  33059. }
  33060. return *v, true
  33061. }
  33062. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  33063. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33065. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33066. if !m.op.Is(OpUpdateOne) {
  33067. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33068. }
  33069. if m.id == nil || m.oldValue == nil {
  33070. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33071. }
  33072. oldValue, err := m.oldValue(ctx)
  33073. if err != nil {
  33074. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33075. }
  33076. return oldValue.UpdatedAt, nil
  33077. }
  33078. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33079. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  33080. m.updated_at = nil
  33081. }
  33082. // SetStatus sets the "status" field.
  33083. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  33084. m.status = &u
  33085. m.addstatus = nil
  33086. }
  33087. // Status returns the value of the "status" field in the mutation.
  33088. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  33089. v := m.status
  33090. if v == nil {
  33091. return
  33092. }
  33093. return *v, true
  33094. }
  33095. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  33096. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33098. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33099. if !m.op.Is(OpUpdateOne) {
  33100. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33101. }
  33102. if m.id == nil || m.oldValue == nil {
  33103. return v, errors.New("OldStatus requires an ID field in the mutation")
  33104. }
  33105. oldValue, err := m.oldValue(ctx)
  33106. if err != nil {
  33107. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33108. }
  33109. return oldValue.Status, nil
  33110. }
  33111. // AddStatus adds u to the "status" field.
  33112. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  33113. if m.addstatus != nil {
  33114. *m.addstatus += u
  33115. } else {
  33116. m.addstatus = &u
  33117. }
  33118. }
  33119. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33120. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  33121. v := m.addstatus
  33122. if v == nil {
  33123. return
  33124. }
  33125. return *v, true
  33126. }
  33127. // ClearStatus clears the value of the "status" field.
  33128. func (m *UsageStatisticHourMutation) ClearStatus() {
  33129. m.status = nil
  33130. m.addstatus = nil
  33131. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  33132. }
  33133. // StatusCleared returns if the "status" field was cleared in this mutation.
  33134. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  33135. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  33136. return ok
  33137. }
  33138. // ResetStatus resets all changes to the "status" field.
  33139. func (m *UsageStatisticHourMutation) ResetStatus() {
  33140. m.status = nil
  33141. m.addstatus = nil
  33142. delete(m.clearedFields, usagestatistichour.FieldStatus)
  33143. }
  33144. // SetDeletedAt sets the "deleted_at" field.
  33145. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  33146. m.deleted_at = &t
  33147. }
  33148. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33149. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  33150. v := m.deleted_at
  33151. if v == nil {
  33152. return
  33153. }
  33154. return *v, true
  33155. }
  33156. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  33157. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33159. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33160. if !m.op.Is(OpUpdateOne) {
  33161. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33162. }
  33163. if m.id == nil || m.oldValue == nil {
  33164. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33165. }
  33166. oldValue, err := m.oldValue(ctx)
  33167. if err != nil {
  33168. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33169. }
  33170. return oldValue.DeletedAt, nil
  33171. }
  33172. // ClearDeletedAt clears the value of the "deleted_at" field.
  33173. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  33174. m.deleted_at = nil
  33175. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  33176. }
  33177. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33178. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  33179. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  33180. return ok
  33181. }
  33182. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33183. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  33184. m.deleted_at = nil
  33185. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  33186. }
  33187. // SetAddtime sets the "addtime" field.
  33188. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  33189. m.addtime = &u
  33190. m.addaddtime = nil
  33191. }
  33192. // Addtime returns the value of the "addtime" field in the mutation.
  33193. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  33194. v := m.addtime
  33195. if v == nil {
  33196. return
  33197. }
  33198. return *v, true
  33199. }
  33200. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  33201. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33203. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  33204. if !m.op.Is(OpUpdateOne) {
  33205. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  33206. }
  33207. if m.id == nil || m.oldValue == nil {
  33208. return v, errors.New("OldAddtime requires an ID field in the mutation")
  33209. }
  33210. oldValue, err := m.oldValue(ctx)
  33211. if err != nil {
  33212. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  33213. }
  33214. return oldValue.Addtime, nil
  33215. }
  33216. // AddAddtime adds u to the "addtime" field.
  33217. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  33218. if m.addaddtime != nil {
  33219. *m.addaddtime += u
  33220. } else {
  33221. m.addaddtime = &u
  33222. }
  33223. }
  33224. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  33225. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  33226. v := m.addaddtime
  33227. if v == nil {
  33228. return
  33229. }
  33230. return *v, true
  33231. }
  33232. // ResetAddtime resets all changes to the "addtime" field.
  33233. func (m *UsageStatisticHourMutation) ResetAddtime() {
  33234. m.addtime = nil
  33235. m.addaddtime = nil
  33236. }
  33237. // SetType sets the "type" field.
  33238. func (m *UsageStatisticHourMutation) SetType(i int) {
  33239. m._type = &i
  33240. m.add_type = nil
  33241. }
  33242. // GetType returns the value of the "type" field in the mutation.
  33243. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  33244. v := m._type
  33245. if v == nil {
  33246. return
  33247. }
  33248. return *v, true
  33249. }
  33250. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  33251. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33253. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  33254. if !m.op.Is(OpUpdateOne) {
  33255. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33256. }
  33257. if m.id == nil || m.oldValue == nil {
  33258. return v, errors.New("OldType requires an ID field in the mutation")
  33259. }
  33260. oldValue, err := m.oldValue(ctx)
  33261. if err != nil {
  33262. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33263. }
  33264. return oldValue.Type, nil
  33265. }
  33266. // AddType adds i to the "type" field.
  33267. func (m *UsageStatisticHourMutation) AddType(i int) {
  33268. if m.add_type != nil {
  33269. *m.add_type += i
  33270. } else {
  33271. m.add_type = &i
  33272. }
  33273. }
  33274. // AddedType returns the value that was added to the "type" field in this mutation.
  33275. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  33276. v := m.add_type
  33277. if v == nil {
  33278. return
  33279. }
  33280. return *v, true
  33281. }
  33282. // ResetType resets all changes to the "type" field.
  33283. func (m *UsageStatisticHourMutation) ResetType() {
  33284. m._type = nil
  33285. m.add_type = nil
  33286. }
  33287. // SetBotID sets the "bot_id" field.
  33288. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  33289. m.bot_id = &s
  33290. }
  33291. // BotID returns the value of the "bot_id" field in the mutation.
  33292. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  33293. v := m.bot_id
  33294. if v == nil {
  33295. return
  33296. }
  33297. return *v, true
  33298. }
  33299. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  33300. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33302. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  33303. if !m.op.Is(OpUpdateOne) {
  33304. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33305. }
  33306. if m.id == nil || m.oldValue == nil {
  33307. return v, errors.New("OldBotID requires an ID field in the mutation")
  33308. }
  33309. oldValue, err := m.oldValue(ctx)
  33310. if err != nil {
  33311. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33312. }
  33313. return oldValue.BotID, nil
  33314. }
  33315. // ClearBotID clears the value of the "bot_id" field.
  33316. func (m *UsageStatisticHourMutation) ClearBotID() {
  33317. m.bot_id = nil
  33318. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  33319. }
  33320. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  33321. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  33322. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  33323. return ok
  33324. }
  33325. // ResetBotID resets all changes to the "bot_id" field.
  33326. func (m *UsageStatisticHourMutation) ResetBotID() {
  33327. m.bot_id = nil
  33328. delete(m.clearedFields, usagestatistichour.FieldBotID)
  33329. }
  33330. // SetOrganizationID sets the "organization_id" field.
  33331. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  33332. m.organization_id = &u
  33333. m.addorganization_id = nil
  33334. }
  33335. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33336. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  33337. v := m.organization_id
  33338. if v == nil {
  33339. return
  33340. }
  33341. return *v, true
  33342. }
  33343. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  33344. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33346. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33347. if !m.op.Is(OpUpdateOne) {
  33348. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33349. }
  33350. if m.id == nil || m.oldValue == nil {
  33351. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33352. }
  33353. oldValue, err := m.oldValue(ctx)
  33354. if err != nil {
  33355. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33356. }
  33357. return oldValue.OrganizationID, nil
  33358. }
  33359. // AddOrganizationID adds u to the "organization_id" field.
  33360. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  33361. if m.addorganization_id != nil {
  33362. *m.addorganization_id += u
  33363. } else {
  33364. m.addorganization_id = &u
  33365. }
  33366. }
  33367. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33368. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  33369. v := m.addorganization_id
  33370. if v == nil {
  33371. return
  33372. }
  33373. return *v, true
  33374. }
  33375. // ClearOrganizationID clears the value of the "organization_id" field.
  33376. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  33377. m.organization_id = nil
  33378. m.addorganization_id = nil
  33379. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  33380. }
  33381. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33382. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  33383. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  33384. return ok
  33385. }
  33386. // ResetOrganizationID resets all changes to the "organization_id" field.
  33387. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  33388. m.organization_id = nil
  33389. m.addorganization_id = nil
  33390. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  33391. }
  33392. // SetAiResponse sets the "ai_response" field.
  33393. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  33394. m.ai_response = &u
  33395. m.addai_response = nil
  33396. }
  33397. // AiResponse returns the value of the "ai_response" field in the mutation.
  33398. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  33399. v := m.ai_response
  33400. if v == nil {
  33401. return
  33402. }
  33403. return *v, true
  33404. }
  33405. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  33406. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33408. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  33409. if !m.op.Is(OpUpdateOne) {
  33410. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  33411. }
  33412. if m.id == nil || m.oldValue == nil {
  33413. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  33414. }
  33415. oldValue, err := m.oldValue(ctx)
  33416. if err != nil {
  33417. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  33418. }
  33419. return oldValue.AiResponse, nil
  33420. }
  33421. // AddAiResponse adds u to the "ai_response" field.
  33422. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  33423. if m.addai_response != nil {
  33424. *m.addai_response += u
  33425. } else {
  33426. m.addai_response = &u
  33427. }
  33428. }
  33429. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  33430. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  33431. v := m.addai_response
  33432. if v == nil {
  33433. return
  33434. }
  33435. return *v, true
  33436. }
  33437. // ResetAiResponse resets all changes to the "ai_response" field.
  33438. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  33439. m.ai_response = nil
  33440. m.addai_response = nil
  33441. }
  33442. // SetSopRun sets the "sop_run" field.
  33443. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  33444. m.sop_run = &u
  33445. m.addsop_run = nil
  33446. }
  33447. // SopRun returns the value of the "sop_run" field in the mutation.
  33448. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  33449. v := m.sop_run
  33450. if v == nil {
  33451. return
  33452. }
  33453. return *v, true
  33454. }
  33455. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  33456. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33458. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  33459. if !m.op.Is(OpUpdateOne) {
  33460. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  33461. }
  33462. if m.id == nil || m.oldValue == nil {
  33463. return v, errors.New("OldSopRun requires an ID field in the mutation")
  33464. }
  33465. oldValue, err := m.oldValue(ctx)
  33466. if err != nil {
  33467. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  33468. }
  33469. return oldValue.SopRun, nil
  33470. }
  33471. // AddSopRun adds u to the "sop_run" field.
  33472. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  33473. if m.addsop_run != nil {
  33474. *m.addsop_run += u
  33475. } else {
  33476. m.addsop_run = &u
  33477. }
  33478. }
  33479. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  33480. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  33481. v := m.addsop_run
  33482. if v == nil {
  33483. return
  33484. }
  33485. return *v, true
  33486. }
  33487. // ResetSopRun resets all changes to the "sop_run" field.
  33488. func (m *UsageStatisticHourMutation) ResetSopRun() {
  33489. m.sop_run = nil
  33490. m.addsop_run = nil
  33491. }
  33492. // SetTotalFriend sets the "total_friend" field.
  33493. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  33494. m.total_friend = &u
  33495. m.addtotal_friend = nil
  33496. }
  33497. // TotalFriend returns the value of the "total_friend" field in the mutation.
  33498. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  33499. v := m.total_friend
  33500. if v == nil {
  33501. return
  33502. }
  33503. return *v, true
  33504. }
  33505. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  33506. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33508. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  33509. if !m.op.Is(OpUpdateOne) {
  33510. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  33511. }
  33512. if m.id == nil || m.oldValue == nil {
  33513. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  33514. }
  33515. oldValue, err := m.oldValue(ctx)
  33516. if err != nil {
  33517. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  33518. }
  33519. return oldValue.TotalFriend, nil
  33520. }
  33521. // AddTotalFriend adds u to the "total_friend" field.
  33522. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  33523. if m.addtotal_friend != nil {
  33524. *m.addtotal_friend += u
  33525. } else {
  33526. m.addtotal_friend = &u
  33527. }
  33528. }
  33529. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  33530. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  33531. v := m.addtotal_friend
  33532. if v == nil {
  33533. return
  33534. }
  33535. return *v, true
  33536. }
  33537. // ResetTotalFriend resets all changes to the "total_friend" field.
  33538. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  33539. m.total_friend = nil
  33540. m.addtotal_friend = nil
  33541. }
  33542. // SetTotalGroup sets the "total_group" field.
  33543. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  33544. m.total_group = &u
  33545. m.addtotal_group = nil
  33546. }
  33547. // TotalGroup returns the value of the "total_group" field in the mutation.
  33548. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  33549. v := m.total_group
  33550. if v == nil {
  33551. return
  33552. }
  33553. return *v, true
  33554. }
  33555. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  33556. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33558. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  33559. if !m.op.Is(OpUpdateOne) {
  33560. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  33561. }
  33562. if m.id == nil || m.oldValue == nil {
  33563. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  33564. }
  33565. oldValue, err := m.oldValue(ctx)
  33566. if err != nil {
  33567. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  33568. }
  33569. return oldValue.TotalGroup, nil
  33570. }
  33571. // AddTotalGroup adds u to the "total_group" field.
  33572. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  33573. if m.addtotal_group != nil {
  33574. *m.addtotal_group += u
  33575. } else {
  33576. m.addtotal_group = &u
  33577. }
  33578. }
  33579. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  33580. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  33581. v := m.addtotal_group
  33582. if v == nil {
  33583. return
  33584. }
  33585. return *v, true
  33586. }
  33587. // ResetTotalGroup resets all changes to the "total_group" field.
  33588. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  33589. m.total_group = nil
  33590. m.addtotal_group = nil
  33591. }
  33592. // SetAccountBalance sets the "account_balance" field.
  33593. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  33594. m.account_balance = &u
  33595. m.addaccount_balance = nil
  33596. }
  33597. // AccountBalance returns the value of the "account_balance" field in the mutation.
  33598. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  33599. v := m.account_balance
  33600. if v == nil {
  33601. return
  33602. }
  33603. return *v, true
  33604. }
  33605. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  33606. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33608. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  33609. if !m.op.Is(OpUpdateOne) {
  33610. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  33611. }
  33612. if m.id == nil || m.oldValue == nil {
  33613. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  33614. }
  33615. oldValue, err := m.oldValue(ctx)
  33616. if err != nil {
  33617. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  33618. }
  33619. return oldValue.AccountBalance, nil
  33620. }
  33621. // AddAccountBalance adds u to the "account_balance" field.
  33622. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  33623. if m.addaccount_balance != nil {
  33624. *m.addaccount_balance += u
  33625. } else {
  33626. m.addaccount_balance = &u
  33627. }
  33628. }
  33629. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  33630. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  33631. v := m.addaccount_balance
  33632. if v == nil {
  33633. return
  33634. }
  33635. return *v, true
  33636. }
  33637. // ResetAccountBalance resets all changes to the "account_balance" field.
  33638. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  33639. m.account_balance = nil
  33640. m.addaccount_balance = nil
  33641. }
  33642. // SetConsumeToken sets the "consume_token" field.
  33643. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  33644. m.consume_token = &u
  33645. m.addconsume_token = nil
  33646. }
  33647. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  33648. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  33649. v := m.consume_token
  33650. if v == nil {
  33651. return
  33652. }
  33653. return *v, true
  33654. }
  33655. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  33656. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33658. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  33659. if !m.op.Is(OpUpdateOne) {
  33660. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  33661. }
  33662. if m.id == nil || m.oldValue == nil {
  33663. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  33664. }
  33665. oldValue, err := m.oldValue(ctx)
  33666. if err != nil {
  33667. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  33668. }
  33669. return oldValue.ConsumeToken, nil
  33670. }
  33671. // AddConsumeToken adds u to the "consume_token" field.
  33672. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  33673. if m.addconsume_token != nil {
  33674. *m.addconsume_token += u
  33675. } else {
  33676. m.addconsume_token = &u
  33677. }
  33678. }
  33679. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  33680. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  33681. v := m.addconsume_token
  33682. if v == nil {
  33683. return
  33684. }
  33685. return *v, true
  33686. }
  33687. // ResetConsumeToken resets all changes to the "consume_token" field.
  33688. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  33689. m.consume_token = nil
  33690. m.addconsume_token = nil
  33691. }
  33692. // SetActiveUser sets the "active_user" field.
  33693. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  33694. m.active_user = &u
  33695. m.addactive_user = nil
  33696. }
  33697. // ActiveUser returns the value of the "active_user" field in the mutation.
  33698. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  33699. v := m.active_user
  33700. if v == nil {
  33701. return
  33702. }
  33703. return *v, true
  33704. }
  33705. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  33706. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33708. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  33709. if !m.op.Is(OpUpdateOne) {
  33710. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  33711. }
  33712. if m.id == nil || m.oldValue == nil {
  33713. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  33714. }
  33715. oldValue, err := m.oldValue(ctx)
  33716. if err != nil {
  33717. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  33718. }
  33719. return oldValue.ActiveUser, nil
  33720. }
  33721. // AddActiveUser adds u to the "active_user" field.
  33722. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  33723. if m.addactive_user != nil {
  33724. *m.addactive_user += u
  33725. } else {
  33726. m.addactive_user = &u
  33727. }
  33728. }
  33729. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  33730. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  33731. v := m.addactive_user
  33732. if v == nil {
  33733. return
  33734. }
  33735. return *v, true
  33736. }
  33737. // ResetActiveUser resets all changes to the "active_user" field.
  33738. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  33739. m.active_user = nil
  33740. m.addactive_user = nil
  33741. }
  33742. // SetNewUser sets the "new_user" field.
  33743. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  33744. m.new_user = &i
  33745. m.addnew_user = nil
  33746. }
  33747. // NewUser returns the value of the "new_user" field in the mutation.
  33748. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  33749. v := m.new_user
  33750. if v == nil {
  33751. return
  33752. }
  33753. return *v, true
  33754. }
  33755. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  33756. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33758. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  33759. if !m.op.Is(OpUpdateOne) {
  33760. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  33761. }
  33762. if m.id == nil || m.oldValue == nil {
  33763. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33764. }
  33765. oldValue, err := m.oldValue(ctx)
  33766. if err != nil {
  33767. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33768. }
  33769. return oldValue.NewUser, nil
  33770. }
  33771. // AddNewUser adds i to the "new_user" field.
  33772. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  33773. if m.addnew_user != nil {
  33774. *m.addnew_user += i
  33775. } else {
  33776. m.addnew_user = &i
  33777. }
  33778. }
  33779. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33780. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  33781. v := m.addnew_user
  33782. if v == nil {
  33783. return
  33784. }
  33785. return *v, true
  33786. }
  33787. // ResetNewUser resets all changes to the "new_user" field.
  33788. func (m *UsageStatisticHourMutation) ResetNewUser() {
  33789. m.new_user = nil
  33790. m.addnew_user = nil
  33791. }
  33792. // SetLabelDist sets the "label_dist" field.
  33793. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33794. m.label_dist = &ctd
  33795. m.appendlabel_dist = nil
  33796. }
  33797. // LabelDist returns the value of the "label_dist" field in the mutation.
  33798. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33799. v := m.label_dist
  33800. if v == nil {
  33801. return
  33802. }
  33803. return *v, true
  33804. }
  33805. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  33806. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33808. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33809. if !m.op.Is(OpUpdateOne) {
  33810. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33811. }
  33812. if m.id == nil || m.oldValue == nil {
  33813. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33814. }
  33815. oldValue, err := m.oldValue(ctx)
  33816. if err != nil {
  33817. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33818. }
  33819. return oldValue.LabelDist, nil
  33820. }
  33821. // AppendLabelDist adds ctd to the "label_dist" field.
  33822. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33823. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33824. }
  33825. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33826. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33827. if len(m.appendlabel_dist) == 0 {
  33828. return nil, false
  33829. }
  33830. return m.appendlabel_dist, true
  33831. }
  33832. // ResetLabelDist resets all changes to the "label_dist" field.
  33833. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  33834. m.label_dist = nil
  33835. m.appendlabel_dist = nil
  33836. }
  33837. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  33838. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  33839. m.predicates = append(m.predicates, ps...)
  33840. }
  33841. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  33842. // users can use type-assertion to append predicates that do not depend on any generated package.
  33843. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  33844. p := make([]predicate.UsageStatisticHour, len(ps))
  33845. for i := range ps {
  33846. p[i] = ps[i]
  33847. }
  33848. m.Where(p...)
  33849. }
  33850. // Op returns the operation name.
  33851. func (m *UsageStatisticHourMutation) Op() Op {
  33852. return m.op
  33853. }
  33854. // SetOp allows setting the mutation operation.
  33855. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  33856. m.op = op
  33857. }
  33858. // Type returns the node type of this mutation (UsageStatisticHour).
  33859. func (m *UsageStatisticHourMutation) Type() string {
  33860. return m.typ
  33861. }
  33862. // Fields returns all fields that were changed during this mutation. Note that in
  33863. // order to get all numeric fields that were incremented/decremented, call
  33864. // AddedFields().
  33865. func (m *UsageStatisticHourMutation) Fields() []string {
  33866. fields := make([]string, 0, 17)
  33867. if m.created_at != nil {
  33868. fields = append(fields, usagestatistichour.FieldCreatedAt)
  33869. }
  33870. if m.updated_at != nil {
  33871. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  33872. }
  33873. if m.status != nil {
  33874. fields = append(fields, usagestatistichour.FieldStatus)
  33875. }
  33876. if m.deleted_at != nil {
  33877. fields = append(fields, usagestatistichour.FieldDeletedAt)
  33878. }
  33879. if m.addtime != nil {
  33880. fields = append(fields, usagestatistichour.FieldAddtime)
  33881. }
  33882. if m._type != nil {
  33883. fields = append(fields, usagestatistichour.FieldType)
  33884. }
  33885. if m.bot_id != nil {
  33886. fields = append(fields, usagestatistichour.FieldBotID)
  33887. }
  33888. if m.organization_id != nil {
  33889. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33890. }
  33891. if m.ai_response != nil {
  33892. fields = append(fields, usagestatistichour.FieldAiResponse)
  33893. }
  33894. if m.sop_run != nil {
  33895. fields = append(fields, usagestatistichour.FieldSopRun)
  33896. }
  33897. if m.total_friend != nil {
  33898. fields = append(fields, usagestatistichour.FieldTotalFriend)
  33899. }
  33900. if m.total_group != nil {
  33901. fields = append(fields, usagestatistichour.FieldTotalGroup)
  33902. }
  33903. if m.account_balance != nil {
  33904. fields = append(fields, usagestatistichour.FieldAccountBalance)
  33905. }
  33906. if m.consume_token != nil {
  33907. fields = append(fields, usagestatistichour.FieldConsumeToken)
  33908. }
  33909. if m.active_user != nil {
  33910. fields = append(fields, usagestatistichour.FieldActiveUser)
  33911. }
  33912. if m.new_user != nil {
  33913. fields = append(fields, usagestatistichour.FieldNewUser)
  33914. }
  33915. if m.label_dist != nil {
  33916. fields = append(fields, usagestatistichour.FieldLabelDist)
  33917. }
  33918. return fields
  33919. }
  33920. // Field returns the value of a field with the given name. The second boolean
  33921. // return value indicates that this field was not set, or was not defined in the
  33922. // schema.
  33923. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  33924. switch name {
  33925. case usagestatistichour.FieldCreatedAt:
  33926. return m.CreatedAt()
  33927. case usagestatistichour.FieldUpdatedAt:
  33928. return m.UpdatedAt()
  33929. case usagestatistichour.FieldStatus:
  33930. return m.Status()
  33931. case usagestatistichour.FieldDeletedAt:
  33932. return m.DeletedAt()
  33933. case usagestatistichour.FieldAddtime:
  33934. return m.Addtime()
  33935. case usagestatistichour.FieldType:
  33936. return m.GetType()
  33937. case usagestatistichour.FieldBotID:
  33938. return m.BotID()
  33939. case usagestatistichour.FieldOrganizationID:
  33940. return m.OrganizationID()
  33941. case usagestatistichour.FieldAiResponse:
  33942. return m.AiResponse()
  33943. case usagestatistichour.FieldSopRun:
  33944. return m.SopRun()
  33945. case usagestatistichour.FieldTotalFriend:
  33946. return m.TotalFriend()
  33947. case usagestatistichour.FieldTotalGroup:
  33948. return m.TotalGroup()
  33949. case usagestatistichour.FieldAccountBalance:
  33950. return m.AccountBalance()
  33951. case usagestatistichour.FieldConsumeToken:
  33952. return m.ConsumeToken()
  33953. case usagestatistichour.FieldActiveUser:
  33954. return m.ActiveUser()
  33955. case usagestatistichour.FieldNewUser:
  33956. return m.NewUser()
  33957. case usagestatistichour.FieldLabelDist:
  33958. return m.LabelDist()
  33959. }
  33960. return nil, false
  33961. }
  33962. // OldField returns the old value of the field from the database. An error is
  33963. // returned if the mutation operation is not UpdateOne, or the query to the
  33964. // database failed.
  33965. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33966. switch name {
  33967. case usagestatistichour.FieldCreatedAt:
  33968. return m.OldCreatedAt(ctx)
  33969. case usagestatistichour.FieldUpdatedAt:
  33970. return m.OldUpdatedAt(ctx)
  33971. case usagestatistichour.FieldStatus:
  33972. return m.OldStatus(ctx)
  33973. case usagestatistichour.FieldDeletedAt:
  33974. return m.OldDeletedAt(ctx)
  33975. case usagestatistichour.FieldAddtime:
  33976. return m.OldAddtime(ctx)
  33977. case usagestatistichour.FieldType:
  33978. return m.OldType(ctx)
  33979. case usagestatistichour.FieldBotID:
  33980. return m.OldBotID(ctx)
  33981. case usagestatistichour.FieldOrganizationID:
  33982. return m.OldOrganizationID(ctx)
  33983. case usagestatistichour.FieldAiResponse:
  33984. return m.OldAiResponse(ctx)
  33985. case usagestatistichour.FieldSopRun:
  33986. return m.OldSopRun(ctx)
  33987. case usagestatistichour.FieldTotalFriend:
  33988. return m.OldTotalFriend(ctx)
  33989. case usagestatistichour.FieldTotalGroup:
  33990. return m.OldTotalGroup(ctx)
  33991. case usagestatistichour.FieldAccountBalance:
  33992. return m.OldAccountBalance(ctx)
  33993. case usagestatistichour.FieldConsumeToken:
  33994. return m.OldConsumeToken(ctx)
  33995. case usagestatistichour.FieldActiveUser:
  33996. return m.OldActiveUser(ctx)
  33997. case usagestatistichour.FieldNewUser:
  33998. return m.OldNewUser(ctx)
  33999. case usagestatistichour.FieldLabelDist:
  34000. return m.OldLabelDist(ctx)
  34001. }
  34002. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34003. }
  34004. // SetField sets the value of a field with the given name. It returns an error if
  34005. // the field is not defined in the schema, or if the type mismatched the field
  34006. // type.
  34007. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  34008. switch name {
  34009. case usagestatistichour.FieldCreatedAt:
  34010. v, ok := value.(time.Time)
  34011. if !ok {
  34012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34013. }
  34014. m.SetCreatedAt(v)
  34015. return nil
  34016. case usagestatistichour.FieldUpdatedAt:
  34017. v, ok := value.(time.Time)
  34018. if !ok {
  34019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34020. }
  34021. m.SetUpdatedAt(v)
  34022. return nil
  34023. case usagestatistichour.FieldStatus:
  34024. v, ok := value.(uint8)
  34025. if !ok {
  34026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34027. }
  34028. m.SetStatus(v)
  34029. return nil
  34030. case usagestatistichour.FieldDeletedAt:
  34031. v, ok := value.(time.Time)
  34032. if !ok {
  34033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34034. }
  34035. m.SetDeletedAt(v)
  34036. return nil
  34037. case usagestatistichour.FieldAddtime:
  34038. v, ok := value.(uint64)
  34039. if !ok {
  34040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34041. }
  34042. m.SetAddtime(v)
  34043. return nil
  34044. case usagestatistichour.FieldType:
  34045. v, ok := value.(int)
  34046. if !ok {
  34047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34048. }
  34049. m.SetType(v)
  34050. return nil
  34051. case usagestatistichour.FieldBotID:
  34052. v, ok := value.(string)
  34053. if !ok {
  34054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34055. }
  34056. m.SetBotID(v)
  34057. return nil
  34058. case usagestatistichour.FieldOrganizationID:
  34059. v, ok := value.(uint64)
  34060. if !ok {
  34061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34062. }
  34063. m.SetOrganizationID(v)
  34064. return nil
  34065. case usagestatistichour.FieldAiResponse:
  34066. v, ok := value.(uint64)
  34067. if !ok {
  34068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34069. }
  34070. m.SetAiResponse(v)
  34071. return nil
  34072. case usagestatistichour.FieldSopRun:
  34073. v, ok := value.(uint64)
  34074. if !ok {
  34075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34076. }
  34077. m.SetSopRun(v)
  34078. return nil
  34079. case usagestatistichour.FieldTotalFriend:
  34080. v, ok := value.(uint64)
  34081. if !ok {
  34082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34083. }
  34084. m.SetTotalFriend(v)
  34085. return nil
  34086. case usagestatistichour.FieldTotalGroup:
  34087. v, ok := value.(uint64)
  34088. if !ok {
  34089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34090. }
  34091. m.SetTotalGroup(v)
  34092. return nil
  34093. case usagestatistichour.FieldAccountBalance:
  34094. v, ok := value.(uint64)
  34095. if !ok {
  34096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34097. }
  34098. m.SetAccountBalance(v)
  34099. return nil
  34100. case usagestatistichour.FieldConsumeToken:
  34101. v, ok := value.(uint64)
  34102. if !ok {
  34103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34104. }
  34105. m.SetConsumeToken(v)
  34106. return nil
  34107. case usagestatistichour.FieldActiveUser:
  34108. v, ok := value.(uint64)
  34109. if !ok {
  34110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34111. }
  34112. m.SetActiveUser(v)
  34113. return nil
  34114. case usagestatistichour.FieldNewUser:
  34115. v, ok := value.(int64)
  34116. if !ok {
  34117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34118. }
  34119. m.SetNewUser(v)
  34120. return nil
  34121. case usagestatistichour.FieldLabelDist:
  34122. v, ok := value.([]custom_types.LabelDist)
  34123. if !ok {
  34124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34125. }
  34126. m.SetLabelDist(v)
  34127. return nil
  34128. }
  34129. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34130. }
  34131. // AddedFields returns all numeric fields that were incremented/decremented during
  34132. // this mutation.
  34133. func (m *UsageStatisticHourMutation) AddedFields() []string {
  34134. var fields []string
  34135. if m.addstatus != nil {
  34136. fields = append(fields, usagestatistichour.FieldStatus)
  34137. }
  34138. if m.addaddtime != nil {
  34139. fields = append(fields, usagestatistichour.FieldAddtime)
  34140. }
  34141. if m.add_type != nil {
  34142. fields = append(fields, usagestatistichour.FieldType)
  34143. }
  34144. if m.addorganization_id != nil {
  34145. fields = append(fields, usagestatistichour.FieldOrganizationID)
  34146. }
  34147. if m.addai_response != nil {
  34148. fields = append(fields, usagestatistichour.FieldAiResponse)
  34149. }
  34150. if m.addsop_run != nil {
  34151. fields = append(fields, usagestatistichour.FieldSopRun)
  34152. }
  34153. if m.addtotal_friend != nil {
  34154. fields = append(fields, usagestatistichour.FieldTotalFriend)
  34155. }
  34156. if m.addtotal_group != nil {
  34157. fields = append(fields, usagestatistichour.FieldTotalGroup)
  34158. }
  34159. if m.addaccount_balance != nil {
  34160. fields = append(fields, usagestatistichour.FieldAccountBalance)
  34161. }
  34162. if m.addconsume_token != nil {
  34163. fields = append(fields, usagestatistichour.FieldConsumeToken)
  34164. }
  34165. if m.addactive_user != nil {
  34166. fields = append(fields, usagestatistichour.FieldActiveUser)
  34167. }
  34168. if m.addnew_user != nil {
  34169. fields = append(fields, usagestatistichour.FieldNewUser)
  34170. }
  34171. return fields
  34172. }
  34173. // AddedField returns the numeric value that was incremented/decremented on a field
  34174. // with the given name. The second boolean return value indicates that this field
  34175. // was not set, or was not defined in the schema.
  34176. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  34177. switch name {
  34178. case usagestatistichour.FieldStatus:
  34179. return m.AddedStatus()
  34180. case usagestatistichour.FieldAddtime:
  34181. return m.AddedAddtime()
  34182. case usagestatistichour.FieldType:
  34183. return m.AddedType()
  34184. case usagestatistichour.FieldOrganizationID:
  34185. return m.AddedOrganizationID()
  34186. case usagestatistichour.FieldAiResponse:
  34187. return m.AddedAiResponse()
  34188. case usagestatistichour.FieldSopRun:
  34189. return m.AddedSopRun()
  34190. case usagestatistichour.FieldTotalFriend:
  34191. return m.AddedTotalFriend()
  34192. case usagestatistichour.FieldTotalGroup:
  34193. return m.AddedTotalGroup()
  34194. case usagestatistichour.FieldAccountBalance:
  34195. return m.AddedAccountBalance()
  34196. case usagestatistichour.FieldConsumeToken:
  34197. return m.AddedConsumeToken()
  34198. case usagestatistichour.FieldActiveUser:
  34199. return m.AddedActiveUser()
  34200. case usagestatistichour.FieldNewUser:
  34201. return m.AddedNewUser()
  34202. }
  34203. return nil, false
  34204. }
  34205. // AddField adds the value to the field with the given name. It returns an error if
  34206. // the field is not defined in the schema, or if the type mismatched the field
  34207. // type.
  34208. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  34209. switch name {
  34210. case usagestatistichour.FieldStatus:
  34211. v, ok := value.(int8)
  34212. if !ok {
  34213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34214. }
  34215. m.AddStatus(v)
  34216. return nil
  34217. case usagestatistichour.FieldAddtime:
  34218. v, ok := value.(int64)
  34219. if !ok {
  34220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34221. }
  34222. m.AddAddtime(v)
  34223. return nil
  34224. case usagestatistichour.FieldType:
  34225. v, ok := value.(int)
  34226. if !ok {
  34227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34228. }
  34229. m.AddType(v)
  34230. return nil
  34231. case usagestatistichour.FieldOrganizationID:
  34232. v, ok := value.(int64)
  34233. if !ok {
  34234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34235. }
  34236. m.AddOrganizationID(v)
  34237. return nil
  34238. case usagestatistichour.FieldAiResponse:
  34239. v, ok := value.(int64)
  34240. if !ok {
  34241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34242. }
  34243. m.AddAiResponse(v)
  34244. return nil
  34245. case usagestatistichour.FieldSopRun:
  34246. v, ok := value.(int64)
  34247. if !ok {
  34248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34249. }
  34250. m.AddSopRun(v)
  34251. return nil
  34252. case usagestatistichour.FieldTotalFriend:
  34253. v, ok := value.(int64)
  34254. if !ok {
  34255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34256. }
  34257. m.AddTotalFriend(v)
  34258. return nil
  34259. case usagestatistichour.FieldTotalGroup:
  34260. v, ok := value.(int64)
  34261. if !ok {
  34262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34263. }
  34264. m.AddTotalGroup(v)
  34265. return nil
  34266. case usagestatistichour.FieldAccountBalance:
  34267. v, ok := value.(int64)
  34268. if !ok {
  34269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34270. }
  34271. m.AddAccountBalance(v)
  34272. return nil
  34273. case usagestatistichour.FieldConsumeToken:
  34274. v, ok := value.(int64)
  34275. if !ok {
  34276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34277. }
  34278. m.AddConsumeToken(v)
  34279. return nil
  34280. case usagestatistichour.FieldActiveUser:
  34281. v, ok := value.(int64)
  34282. if !ok {
  34283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34284. }
  34285. m.AddActiveUser(v)
  34286. return nil
  34287. case usagestatistichour.FieldNewUser:
  34288. v, ok := value.(int64)
  34289. if !ok {
  34290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34291. }
  34292. m.AddNewUser(v)
  34293. return nil
  34294. }
  34295. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  34296. }
  34297. // ClearedFields returns all nullable fields that were cleared during this
  34298. // mutation.
  34299. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  34300. var fields []string
  34301. if m.FieldCleared(usagestatistichour.FieldStatus) {
  34302. fields = append(fields, usagestatistichour.FieldStatus)
  34303. }
  34304. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  34305. fields = append(fields, usagestatistichour.FieldDeletedAt)
  34306. }
  34307. if m.FieldCleared(usagestatistichour.FieldBotID) {
  34308. fields = append(fields, usagestatistichour.FieldBotID)
  34309. }
  34310. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  34311. fields = append(fields, usagestatistichour.FieldOrganizationID)
  34312. }
  34313. return fields
  34314. }
  34315. // FieldCleared returns a boolean indicating if a field with the given name was
  34316. // cleared in this mutation.
  34317. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  34318. _, ok := m.clearedFields[name]
  34319. return ok
  34320. }
  34321. // ClearField clears the value of the field with the given name. It returns an
  34322. // error if the field is not defined in the schema.
  34323. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  34324. switch name {
  34325. case usagestatistichour.FieldStatus:
  34326. m.ClearStatus()
  34327. return nil
  34328. case usagestatistichour.FieldDeletedAt:
  34329. m.ClearDeletedAt()
  34330. return nil
  34331. case usagestatistichour.FieldBotID:
  34332. m.ClearBotID()
  34333. return nil
  34334. case usagestatistichour.FieldOrganizationID:
  34335. m.ClearOrganizationID()
  34336. return nil
  34337. }
  34338. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  34339. }
  34340. // ResetField resets all changes in the mutation for the field with the given name.
  34341. // It returns an error if the field is not defined in the schema.
  34342. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  34343. switch name {
  34344. case usagestatistichour.FieldCreatedAt:
  34345. m.ResetCreatedAt()
  34346. return nil
  34347. case usagestatistichour.FieldUpdatedAt:
  34348. m.ResetUpdatedAt()
  34349. return nil
  34350. case usagestatistichour.FieldStatus:
  34351. m.ResetStatus()
  34352. return nil
  34353. case usagestatistichour.FieldDeletedAt:
  34354. m.ResetDeletedAt()
  34355. return nil
  34356. case usagestatistichour.FieldAddtime:
  34357. m.ResetAddtime()
  34358. return nil
  34359. case usagestatistichour.FieldType:
  34360. m.ResetType()
  34361. return nil
  34362. case usagestatistichour.FieldBotID:
  34363. m.ResetBotID()
  34364. return nil
  34365. case usagestatistichour.FieldOrganizationID:
  34366. m.ResetOrganizationID()
  34367. return nil
  34368. case usagestatistichour.FieldAiResponse:
  34369. m.ResetAiResponse()
  34370. return nil
  34371. case usagestatistichour.FieldSopRun:
  34372. m.ResetSopRun()
  34373. return nil
  34374. case usagestatistichour.FieldTotalFriend:
  34375. m.ResetTotalFriend()
  34376. return nil
  34377. case usagestatistichour.FieldTotalGroup:
  34378. m.ResetTotalGroup()
  34379. return nil
  34380. case usagestatistichour.FieldAccountBalance:
  34381. m.ResetAccountBalance()
  34382. return nil
  34383. case usagestatistichour.FieldConsumeToken:
  34384. m.ResetConsumeToken()
  34385. return nil
  34386. case usagestatistichour.FieldActiveUser:
  34387. m.ResetActiveUser()
  34388. return nil
  34389. case usagestatistichour.FieldNewUser:
  34390. m.ResetNewUser()
  34391. return nil
  34392. case usagestatistichour.FieldLabelDist:
  34393. m.ResetLabelDist()
  34394. return nil
  34395. }
  34396. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34397. }
  34398. // AddedEdges returns all edge names that were set/added in this mutation.
  34399. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  34400. edges := make([]string, 0, 0)
  34401. return edges
  34402. }
  34403. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34404. // name in this mutation.
  34405. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  34406. return nil
  34407. }
  34408. // RemovedEdges returns all edge names that were removed in this mutation.
  34409. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  34410. edges := make([]string, 0, 0)
  34411. return edges
  34412. }
  34413. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34414. // the given name in this mutation.
  34415. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  34416. return nil
  34417. }
  34418. // ClearedEdges returns all edge names that were cleared in this mutation.
  34419. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  34420. edges := make([]string, 0, 0)
  34421. return edges
  34422. }
  34423. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34424. // was cleared in this mutation.
  34425. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  34426. return false
  34427. }
  34428. // ClearEdge clears the value of the edge with the given name. It returns an error
  34429. // if that edge is not defined in the schema.
  34430. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  34431. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  34432. }
  34433. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34434. // It returns an error if the edge is not defined in the schema.
  34435. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  34436. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  34437. }
  34438. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  34439. type UsageStatisticMonthMutation struct {
  34440. config
  34441. op Op
  34442. typ string
  34443. id *uint64
  34444. created_at *time.Time
  34445. updated_at *time.Time
  34446. status *uint8
  34447. addstatus *int8
  34448. deleted_at *time.Time
  34449. addtime *uint64
  34450. addaddtime *int64
  34451. _type *int
  34452. add_type *int
  34453. bot_id *string
  34454. organization_id *uint64
  34455. addorganization_id *int64
  34456. ai_response *uint64
  34457. addai_response *int64
  34458. sop_run *uint64
  34459. addsop_run *int64
  34460. total_friend *uint64
  34461. addtotal_friend *int64
  34462. total_group *uint64
  34463. addtotal_group *int64
  34464. account_balance *uint64
  34465. addaccount_balance *int64
  34466. consume_token *uint64
  34467. addconsume_token *int64
  34468. active_user *uint64
  34469. addactive_user *int64
  34470. new_user *int64
  34471. addnew_user *int64
  34472. label_dist *[]custom_types.LabelDist
  34473. appendlabel_dist []custom_types.LabelDist
  34474. clearedFields map[string]struct{}
  34475. done bool
  34476. oldValue func(context.Context) (*UsageStatisticMonth, error)
  34477. predicates []predicate.UsageStatisticMonth
  34478. }
  34479. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  34480. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  34481. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  34482. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  34483. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  34484. m := &UsageStatisticMonthMutation{
  34485. config: c,
  34486. op: op,
  34487. typ: TypeUsageStatisticMonth,
  34488. clearedFields: make(map[string]struct{}),
  34489. }
  34490. for _, opt := range opts {
  34491. opt(m)
  34492. }
  34493. return m
  34494. }
  34495. // withUsageStatisticMonthID sets the ID field of the mutation.
  34496. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  34497. return func(m *UsageStatisticMonthMutation) {
  34498. var (
  34499. err error
  34500. once sync.Once
  34501. value *UsageStatisticMonth
  34502. )
  34503. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  34504. once.Do(func() {
  34505. if m.done {
  34506. err = errors.New("querying old values post mutation is not allowed")
  34507. } else {
  34508. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  34509. }
  34510. })
  34511. return value, err
  34512. }
  34513. m.id = &id
  34514. }
  34515. }
  34516. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  34517. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  34518. return func(m *UsageStatisticMonthMutation) {
  34519. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  34520. return node, nil
  34521. }
  34522. m.id = &node.ID
  34523. }
  34524. }
  34525. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34526. // executed in a transaction (ent.Tx), a transactional client is returned.
  34527. func (m UsageStatisticMonthMutation) Client() *Client {
  34528. client := &Client{config: m.config}
  34529. client.init()
  34530. return client
  34531. }
  34532. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34533. // it returns an error otherwise.
  34534. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  34535. if _, ok := m.driver.(*txDriver); !ok {
  34536. return nil, errors.New("ent: mutation is not running in a transaction")
  34537. }
  34538. tx := &Tx{config: m.config}
  34539. tx.init()
  34540. return tx, nil
  34541. }
  34542. // SetID sets the value of the id field. Note that this
  34543. // operation is only accepted on creation of UsageStatisticMonth entities.
  34544. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  34545. m.id = &id
  34546. }
  34547. // ID returns the ID value in the mutation. Note that the ID is only available
  34548. // if it was provided to the builder or after it was returned from the database.
  34549. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  34550. if m.id == nil {
  34551. return
  34552. }
  34553. return *m.id, true
  34554. }
  34555. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34556. // That means, if the mutation is applied within a transaction with an isolation level such
  34557. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34558. // or updated by the mutation.
  34559. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  34560. switch {
  34561. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34562. id, exists := m.ID()
  34563. if exists {
  34564. return []uint64{id}, nil
  34565. }
  34566. fallthrough
  34567. case m.op.Is(OpUpdate | OpDelete):
  34568. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  34569. default:
  34570. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34571. }
  34572. }
  34573. // SetCreatedAt sets the "created_at" field.
  34574. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  34575. m.created_at = &t
  34576. }
  34577. // CreatedAt returns the value of the "created_at" field in the mutation.
  34578. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  34579. v := m.created_at
  34580. if v == nil {
  34581. return
  34582. }
  34583. return *v, true
  34584. }
  34585. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  34586. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34588. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34589. if !m.op.Is(OpUpdateOne) {
  34590. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34591. }
  34592. if m.id == nil || m.oldValue == nil {
  34593. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34594. }
  34595. oldValue, err := m.oldValue(ctx)
  34596. if err != nil {
  34597. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34598. }
  34599. return oldValue.CreatedAt, nil
  34600. }
  34601. // ResetCreatedAt resets all changes to the "created_at" field.
  34602. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  34603. m.created_at = nil
  34604. }
  34605. // SetUpdatedAt sets the "updated_at" field.
  34606. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  34607. m.updated_at = &t
  34608. }
  34609. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34610. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  34611. v := m.updated_at
  34612. if v == nil {
  34613. return
  34614. }
  34615. return *v, true
  34616. }
  34617. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  34618. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34620. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34621. if !m.op.Is(OpUpdateOne) {
  34622. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34623. }
  34624. if m.id == nil || m.oldValue == nil {
  34625. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34626. }
  34627. oldValue, err := m.oldValue(ctx)
  34628. if err != nil {
  34629. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34630. }
  34631. return oldValue.UpdatedAt, nil
  34632. }
  34633. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34634. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  34635. m.updated_at = nil
  34636. }
  34637. // SetStatus sets the "status" field.
  34638. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  34639. m.status = &u
  34640. m.addstatus = nil
  34641. }
  34642. // Status returns the value of the "status" field in the mutation.
  34643. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  34644. v := m.status
  34645. if v == nil {
  34646. return
  34647. }
  34648. return *v, true
  34649. }
  34650. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  34651. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34653. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34654. if !m.op.Is(OpUpdateOne) {
  34655. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34656. }
  34657. if m.id == nil || m.oldValue == nil {
  34658. return v, errors.New("OldStatus requires an ID field in the mutation")
  34659. }
  34660. oldValue, err := m.oldValue(ctx)
  34661. if err != nil {
  34662. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34663. }
  34664. return oldValue.Status, nil
  34665. }
  34666. // AddStatus adds u to the "status" field.
  34667. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  34668. if m.addstatus != nil {
  34669. *m.addstatus += u
  34670. } else {
  34671. m.addstatus = &u
  34672. }
  34673. }
  34674. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34675. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  34676. v := m.addstatus
  34677. if v == nil {
  34678. return
  34679. }
  34680. return *v, true
  34681. }
  34682. // ClearStatus clears the value of the "status" field.
  34683. func (m *UsageStatisticMonthMutation) ClearStatus() {
  34684. m.status = nil
  34685. m.addstatus = nil
  34686. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  34687. }
  34688. // StatusCleared returns if the "status" field was cleared in this mutation.
  34689. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  34690. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  34691. return ok
  34692. }
  34693. // ResetStatus resets all changes to the "status" field.
  34694. func (m *UsageStatisticMonthMutation) ResetStatus() {
  34695. m.status = nil
  34696. m.addstatus = nil
  34697. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  34698. }
  34699. // SetDeletedAt sets the "deleted_at" field.
  34700. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  34701. m.deleted_at = &t
  34702. }
  34703. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34704. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  34705. v := m.deleted_at
  34706. if v == nil {
  34707. return
  34708. }
  34709. return *v, true
  34710. }
  34711. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  34712. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34714. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34715. if !m.op.Is(OpUpdateOne) {
  34716. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34717. }
  34718. if m.id == nil || m.oldValue == nil {
  34719. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34720. }
  34721. oldValue, err := m.oldValue(ctx)
  34722. if err != nil {
  34723. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34724. }
  34725. return oldValue.DeletedAt, nil
  34726. }
  34727. // ClearDeletedAt clears the value of the "deleted_at" field.
  34728. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  34729. m.deleted_at = nil
  34730. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  34731. }
  34732. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34733. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  34734. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  34735. return ok
  34736. }
  34737. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34738. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  34739. m.deleted_at = nil
  34740. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  34741. }
  34742. // SetAddtime sets the "addtime" field.
  34743. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  34744. m.addtime = &u
  34745. m.addaddtime = nil
  34746. }
  34747. // Addtime returns the value of the "addtime" field in the mutation.
  34748. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  34749. v := m.addtime
  34750. if v == nil {
  34751. return
  34752. }
  34753. return *v, true
  34754. }
  34755. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  34756. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34758. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  34759. if !m.op.Is(OpUpdateOne) {
  34760. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  34761. }
  34762. if m.id == nil || m.oldValue == nil {
  34763. return v, errors.New("OldAddtime requires an ID field in the mutation")
  34764. }
  34765. oldValue, err := m.oldValue(ctx)
  34766. if err != nil {
  34767. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  34768. }
  34769. return oldValue.Addtime, nil
  34770. }
  34771. // AddAddtime adds u to the "addtime" field.
  34772. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  34773. if m.addaddtime != nil {
  34774. *m.addaddtime += u
  34775. } else {
  34776. m.addaddtime = &u
  34777. }
  34778. }
  34779. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  34780. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  34781. v := m.addaddtime
  34782. if v == nil {
  34783. return
  34784. }
  34785. return *v, true
  34786. }
  34787. // ResetAddtime resets all changes to the "addtime" field.
  34788. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  34789. m.addtime = nil
  34790. m.addaddtime = nil
  34791. }
  34792. // SetType sets the "type" field.
  34793. func (m *UsageStatisticMonthMutation) SetType(i int) {
  34794. m._type = &i
  34795. m.add_type = nil
  34796. }
  34797. // GetType returns the value of the "type" field in the mutation.
  34798. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  34799. v := m._type
  34800. if v == nil {
  34801. return
  34802. }
  34803. return *v, true
  34804. }
  34805. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  34806. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34808. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  34809. if !m.op.Is(OpUpdateOne) {
  34810. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34811. }
  34812. if m.id == nil || m.oldValue == nil {
  34813. return v, errors.New("OldType requires an ID field in the mutation")
  34814. }
  34815. oldValue, err := m.oldValue(ctx)
  34816. if err != nil {
  34817. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34818. }
  34819. return oldValue.Type, nil
  34820. }
  34821. // AddType adds i to the "type" field.
  34822. func (m *UsageStatisticMonthMutation) AddType(i int) {
  34823. if m.add_type != nil {
  34824. *m.add_type += i
  34825. } else {
  34826. m.add_type = &i
  34827. }
  34828. }
  34829. // AddedType returns the value that was added to the "type" field in this mutation.
  34830. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  34831. v := m.add_type
  34832. if v == nil {
  34833. return
  34834. }
  34835. return *v, true
  34836. }
  34837. // ResetType resets all changes to the "type" field.
  34838. func (m *UsageStatisticMonthMutation) ResetType() {
  34839. m._type = nil
  34840. m.add_type = nil
  34841. }
  34842. // SetBotID sets the "bot_id" field.
  34843. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  34844. m.bot_id = &s
  34845. }
  34846. // BotID returns the value of the "bot_id" field in the mutation.
  34847. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  34848. v := m.bot_id
  34849. if v == nil {
  34850. return
  34851. }
  34852. return *v, true
  34853. }
  34854. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  34855. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34857. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  34858. if !m.op.Is(OpUpdateOne) {
  34859. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34860. }
  34861. if m.id == nil || m.oldValue == nil {
  34862. return v, errors.New("OldBotID requires an ID field in the mutation")
  34863. }
  34864. oldValue, err := m.oldValue(ctx)
  34865. if err != nil {
  34866. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34867. }
  34868. return oldValue.BotID, nil
  34869. }
  34870. // ClearBotID clears the value of the "bot_id" field.
  34871. func (m *UsageStatisticMonthMutation) ClearBotID() {
  34872. m.bot_id = nil
  34873. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  34874. }
  34875. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  34876. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  34877. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  34878. return ok
  34879. }
  34880. // ResetBotID resets all changes to the "bot_id" field.
  34881. func (m *UsageStatisticMonthMutation) ResetBotID() {
  34882. m.bot_id = nil
  34883. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  34884. }
  34885. // SetOrganizationID sets the "organization_id" field.
  34886. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  34887. m.organization_id = &u
  34888. m.addorganization_id = nil
  34889. }
  34890. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34891. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  34892. v := m.organization_id
  34893. if v == nil {
  34894. return
  34895. }
  34896. return *v, true
  34897. }
  34898. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  34899. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34901. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34902. if !m.op.Is(OpUpdateOne) {
  34903. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34904. }
  34905. if m.id == nil || m.oldValue == nil {
  34906. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34907. }
  34908. oldValue, err := m.oldValue(ctx)
  34909. if err != nil {
  34910. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34911. }
  34912. return oldValue.OrganizationID, nil
  34913. }
  34914. // AddOrganizationID adds u to the "organization_id" field.
  34915. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  34916. if m.addorganization_id != nil {
  34917. *m.addorganization_id += u
  34918. } else {
  34919. m.addorganization_id = &u
  34920. }
  34921. }
  34922. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34923. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  34924. v := m.addorganization_id
  34925. if v == nil {
  34926. return
  34927. }
  34928. return *v, true
  34929. }
  34930. // ClearOrganizationID clears the value of the "organization_id" field.
  34931. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  34932. m.organization_id = nil
  34933. m.addorganization_id = nil
  34934. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  34935. }
  34936. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34937. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  34938. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  34939. return ok
  34940. }
  34941. // ResetOrganizationID resets all changes to the "organization_id" field.
  34942. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  34943. m.organization_id = nil
  34944. m.addorganization_id = nil
  34945. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  34946. }
  34947. // SetAiResponse sets the "ai_response" field.
  34948. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  34949. m.ai_response = &u
  34950. m.addai_response = nil
  34951. }
  34952. // AiResponse returns the value of the "ai_response" field in the mutation.
  34953. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  34954. v := m.ai_response
  34955. if v == nil {
  34956. return
  34957. }
  34958. return *v, true
  34959. }
  34960. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  34961. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34963. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  34964. if !m.op.Is(OpUpdateOne) {
  34965. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  34966. }
  34967. if m.id == nil || m.oldValue == nil {
  34968. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  34969. }
  34970. oldValue, err := m.oldValue(ctx)
  34971. if err != nil {
  34972. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  34973. }
  34974. return oldValue.AiResponse, nil
  34975. }
  34976. // AddAiResponse adds u to the "ai_response" field.
  34977. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  34978. if m.addai_response != nil {
  34979. *m.addai_response += u
  34980. } else {
  34981. m.addai_response = &u
  34982. }
  34983. }
  34984. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  34985. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  34986. v := m.addai_response
  34987. if v == nil {
  34988. return
  34989. }
  34990. return *v, true
  34991. }
  34992. // ResetAiResponse resets all changes to the "ai_response" field.
  34993. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  34994. m.ai_response = nil
  34995. m.addai_response = nil
  34996. }
  34997. // SetSopRun sets the "sop_run" field.
  34998. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  34999. m.sop_run = &u
  35000. m.addsop_run = nil
  35001. }
  35002. // SopRun returns the value of the "sop_run" field in the mutation.
  35003. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  35004. v := m.sop_run
  35005. if v == nil {
  35006. return
  35007. }
  35008. return *v, true
  35009. }
  35010. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  35011. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35013. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  35014. if !m.op.Is(OpUpdateOne) {
  35015. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  35016. }
  35017. if m.id == nil || m.oldValue == nil {
  35018. return v, errors.New("OldSopRun requires an ID field in the mutation")
  35019. }
  35020. oldValue, err := m.oldValue(ctx)
  35021. if err != nil {
  35022. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  35023. }
  35024. return oldValue.SopRun, nil
  35025. }
  35026. // AddSopRun adds u to the "sop_run" field.
  35027. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  35028. if m.addsop_run != nil {
  35029. *m.addsop_run += u
  35030. } else {
  35031. m.addsop_run = &u
  35032. }
  35033. }
  35034. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  35035. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  35036. v := m.addsop_run
  35037. if v == nil {
  35038. return
  35039. }
  35040. return *v, true
  35041. }
  35042. // ResetSopRun resets all changes to the "sop_run" field.
  35043. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  35044. m.sop_run = nil
  35045. m.addsop_run = nil
  35046. }
  35047. // SetTotalFriend sets the "total_friend" field.
  35048. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  35049. m.total_friend = &u
  35050. m.addtotal_friend = nil
  35051. }
  35052. // TotalFriend returns the value of the "total_friend" field in the mutation.
  35053. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  35054. v := m.total_friend
  35055. if v == nil {
  35056. return
  35057. }
  35058. return *v, true
  35059. }
  35060. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  35061. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35063. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  35064. if !m.op.Is(OpUpdateOne) {
  35065. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  35066. }
  35067. if m.id == nil || m.oldValue == nil {
  35068. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  35069. }
  35070. oldValue, err := m.oldValue(ctx)
  35071. if err != nil {
  35072. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  35073. }
  35074. return oldValue.TotalFriend, nil
  35075. }
  35076. // AddTotalFriend adds u to the "total_friend" field.
  35077. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  35078. if m.addtotal_friend != nil {
  35079. *m.addtotal_friend += u
  35080. } else {
  35081. m.addtotal_friend = &u
  35082. }
  35083. }
  35084. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  35085. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  35086. v := m.addtotal_friend
  35087. if v == nil {
  35088. return
  35089. }
  35090. return *v, true
  35091. }
  35092. // ResetTotalFriend resets all changes to the "total_friend" field.
  35093. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  35094. m.total_friend = nil
  35095. m.addtotal_friend = nil
  35096. }
  35097. // SetTotalGroup sets the "total_group" field.
  35098. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  35099. m.total_group = &u
  35100. m.addtotal_group = nil
  35101. }
  35102. // TotalGroup returns the value of the "total_group" field in the mutation.
  35103. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  35104. v := m.total_group
  35105. if v == nil {
  35106. return
  35107. }
  35108. return *v, true
  35109. }
  35110. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  35111. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35113. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  35114. if !m.op.Is(OpUpdateOne) {
  35115. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  35116. }
  35117. if m.id == nil || m.oldValue == nil {
  35118. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  35119. }
  35120. oldValue, err := m.oldValue(ctx)
  35121. if err != nil {
  35122. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  35123. }
  35124. return oldValue.TotalGroup, nil
  35125. }
  35126. // AddTotalGroup adds u to the "total_group" field.
  35127. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  35128. if m.addtotal_group != nil {
  35129. *m.addtotal_group += u
  35130. } else {
  35131. m.addtotal_group = &u
  35132. }
  35133. }
  35134. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  35135. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  35136. v := m.addtotal_group
  35137. if v == nil {
  35138. return
  35139. }
  35140. return *v, true
  35141. }
  35142. // ResetTotalGroup resets all changes to the "total_group" field.
  35143. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  35144. m.total_group = nil
  35145. m.addtotal_group = nil
  35146. }
  35147. // SetAccountBalance sets the "account_balance" field.
  35148. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  35149. m.account_balance = &u
  35150. m.addaccount_balance = nil
  35151. }
  35152. // AccountBalance returns the value of the "account_balance" field in the mutation.
  35153. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  35154. v := m.account_balance
  35155. if v == nil {
  35156. return
  35157. }
  35158. return *v, true
  35159. }
  35160. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  35161. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35163. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  35164. if !m.op.Is(OpUpdateOne) {
  35165. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  35166. }
  35167. if m.id == nil || m.oldValue == nil {
  35168. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  35169. }
  35170. oldValue, err := m.oldValue(ctx)
  35171. if err != nil {
  35172. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  35173. }
  35174. return oldValue.AccountBalance, nil
  35175. }
  35176. // AddAccountBalance adds u to the "account_balance" field.
  35177. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  35178. if m.addaccount_balance != nil {
  35179. *m.addaccount_balance += u
  35180. } else {
  35181. m.addaccount_balance = &u
  35182. }
  35183. }
  35184. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  35185. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  35186. v := m.addaccount_balance
  35187. if v == nil {
  35188. return
  35189. }
  35190. return *v, true
  35191. }
  35192. // ResetAccountBalance resets all changes to the "account_balance" field.
  35193. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  35194. m.account_balance = nil
  35195. m.addaccount_balance = nil
  35196. }
  35197. // SetConsumeToken sets the "consume_token" field.
  35198. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  35199. m.consume_token = &u
  35200. m.addconsume_token = nil
  35201. }
  35202. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  35203. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  35204. v := m.consume_token
  35205. if v == nil {
  35206. return
  35207. }
  35208. return *v, true
  35209. }
  35210. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  35211. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35213. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  35214. if !m.op.Is(OpUpdateOne) {
  35215. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  35216. }
  35217. if m.id == nil || m.oldValue == nil {
  35218. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  35219. }
  35220. oldValue, err := m.oldValue(ctx)
  35221. if err != nil {
  35222. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  35223. }
  35224. return oldValue.ConsumeToken, nil
  35225. }
  35226. // AddConsumeToken adds u to the "consume_token" field.
  35227. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  35228. if m.addconsume_token != nil {
  35229. *m.addconsume_token += u
  35230. } else {
  35231. m.addconsume_token = &u
  35232. }
  35233. }
  35234. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  35235. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  35236. v := m.addconsume_token
  35237. if v == nil {
  35238. return
  35239. }
  35240. return *v, true
  35241. }
  35242. // ResetConsumeToken resets all changes to the "consume_token" field.
  35243. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  35244. m.consume_token = nil
  35245. m.addconsume_token = nil
  35246. }
  35247. // SetActiveUser sets the "active_user" field.
  35248. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  35249. m.active_user = &u
  35250. m.addactive_user = nil
  35251. }
  35252. // ActiveUser returns the value of the "active_user" field in the mutation.
  35253. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  35254. v := m.active_user
  35255. if v == nil {
  35256. return
  35257. }
  35258. return *v, true
  35259. }
  35260. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  35261. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35263. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  35264. if !m.op.Is(OpUpdateOne) {
  35265. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  35266. }
  35267. if m.id == nil || m.oldValue == nil {
  35268. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  35269. }
  35270. oldValue, err := m.oldValue(ctx)
  35271. if err != nil {
  35272. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  35273. }
  35274. return oldValue.ActiveUser, nil
  35275. }
  35276. // AddActiveUser adds u to the "active_user" field.
  35277. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  35278. if m.addactive_user != nil {
  35279. *m.addactive_user += u
  35280. } else {
  35281. m.addactive_user = &u
  35282. }
  35283. }
  35284. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  35285. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  35286. v := m.addactive_user
  35287. if v == nil {
  35288. return
  35289. }
  35290. return *v, true
  35291. }
  35292. // ResetActiveUser resets all changes to the "active_user" field.
  35293. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  35294. m.active_user = nil
  35295. m.addactive_user = nil
  35296. }
  35297. // SetNewUser sets the "new_user" field.
  35298. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  35299. m.new_user = &i
  35300. m.addnew_user = nil
  35301. }
  35302. // NewUser returns the value of the "new_user" field in the mutation.
  35303. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  35304. v := m.new_user
  35305. if v == nil {
  35306. return
  35307. }
  35308. return *v, true
  35309. }
  35310. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  35311. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35313. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  35314. if !m.op.Is(OpUpdateOne) {
  35315. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  35316. }
  35317. if m.id == nil || m.oldValue == nil {
  35318. return v, errors.New("OldNewUser requires an ID field in the mutation")
  35319. }
  35320. oldValue, err := m.oldValue(ctx)
  35321. if err != nil {
  35322. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  35323. }
  35324. return oldValue.NewUser, nil
  35325. }
  35326. // AddNewUser adds i to the "new_user" field.
  35327. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  35328. if m.addnew_user != nil {
  35329. *m.addnew_user += i
  35330. } else {
  35331. m.addnew_user = &i
  35332. }
  35333. }
  35334. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  35335. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  35336. v := m.addnew_user
  35337. if v == nil {
  35338. return
  35339. }
  35340. return *v, true
  35341. }
  35342. // ResetNewUser resets all changes to the "new_user" field.
  35343. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  35344. m.new_user = nil
  35345. m.addnew_user = nil
  35346. }
  35347. // SetLabelDist sets the "label_dist" field.
  35348. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  35349. m.label_dist = &ctd
  35350. m.appendlabel_dist = nil
  35351. }
  35352. // LabelDist returns the value of the "label_dist" field in the mutation.
  35353. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  35354. v := m.label_dist
  35355. if v == nil {
  35356. return
  35357. }
  35358. return *v, true
  35359. }
  35360. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  35361. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35363. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  35364. if !m.op.Is(OpUpdateOne) {
  35365. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  35366. }
  35367. if m.id == nil || m.oldValue == nil {
  35368. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  35369. }
  35370. oldValue, err := m.oldValue(ctx)
  35371. if err != nil {
  35372. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  35373. }
  35374. return oldValue.LabelDist, nil
  35375. }
  35376. // AppendLabelDist adds ctd to the "label_dist" field.
  35377. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  35378. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  35379. }
  35380. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  35381. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  35382. if len(m.appendlabel_dist) == 0 {
  35383. return nil, false
  35384. }
  35385. return m.appendlabel_dist, true
  35386. }
  35387. // ResetLabelDist resets all changes to the "label_dist" field.
  35388. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  35389. m.label_dist = nil
  35390. m.appendlabel_dist = nil
  35391. }
  35392. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  35393. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  35394. m.predicates = append(m.predicates, ps...)
  35395. }
  35396. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  35397. // users can use type-assertion to append predicates that do not depend on any generated package.
  35398. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  35399. p := make([]predicate.UsageStatisticMonth, len(ps))
  35400. for i := range ps {
  35401. p[i] = ps[i]
  35402. }
  35403. m.Where(p...)
  35404. }
  35405. // Op returns the operation name.
  35406. func (m *UsageStatisticMonthMutation) Op() Op {
  35407. return m.op
  35408. }
  35409. // SetOp allows setting the mutation operation.
  35410. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  35411. m.op = op
  35412. }
  35413. // Type returns the node type of this mutation (UsageStatisticMonth).
  35414. func (m *UsageStatisticMonthMutation) Type() string {
  35415. return m.typ
  35416. }
  35417. // Fields returns all fields that were changed during this mutation. Note that in
  35418. // order to get all numeric fields that were incremented/decremented, call
  35419. // AddedFields().
  35420. func (m *UsageStatisticMonthMutation) Fields() []string {
  35421. fields := make([]string, 0, 17)
  35422. if m.created_at != nil {
  35423. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  35424. }
  35425. if m.updated_at != nil {
  35426. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  35427. }
  35428. if m.status != nil {
  35429. fields = append(fields, usagestatisticmonth.FieldStatus)
  35430. }
  35431. if m.deleted_at != nil {
  35432. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  35433. }
  35434. if m.addtime != nil {
  35435. fields = append(fields, usagestatisticmonth.FieldAddtime)
  35436. }
  35437. if m._type != nil {
  35438. fields = append(fields, usagestatisticmonth.FieldType)
  35439. }
  35440. if m.bot_id != nil {
  35441. fields = append(fields, usagestatisticmonth.FieldBotID)
  35442. }
  35443. if m.organization_id != nil {
  35444. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  35445. }
  35446. if m.ai_response != nil {
  35447. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  35448. }
  35449. if m.sop_run != nil {
  35450. fields = append(fields, usagestatisticmonth.FieldSopRun)
  35451. }
  35452. if m.total_friend != nil {
  35453. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  35454. }
  35455. if m.total_group != nil {
  35456. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  35457. }
  35458. if m.account_balance != nil {
  35459. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  35460. }
  35461. if m.consume_token != nil {
  35462. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  35463. }
  35464. if m.active_user != nil {
  35465. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  35466. }
  35467. if m.new_user != nil {
  35468. fields = append(fields, usagestatisticmonth.FieldNewUser)
  35469. }
  35470. if m.label_dist != nil {
  35471. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  35472. }
  35473. return fields
  35474. }
  35475. // Field returns the value of a field with the given name. The second boolean
  35476. // return value indicates that this field was not set, or was not defined in the
  35477. // schema.
  35478. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  35479. switch name {
  35480. case usagestatisticmonth.FieldCreatedAt:
  35481. return m.CreatedAt()
  35482. case usagestatisticmonth.FieldUpdatedAt:
  35483. return m.UpdatedAt()
  35484. case usagestatisticmonth.FieldStatus:
  35485. return m.Status()
  35486. case usagestatisticmonth.FieldDeletedAt:
  35487. return m.DeletedAt()
  35488. case usagestatisticmonth.FieldAddtime:
  35489. return m.Addtime()
  35490. case usagestatisticmonth.FieldType:
  35491. return m.GetType()
  35492. case usagestatisticmonth.FieldBotID:
  35493. return m.BotID()
  35494. case usagestatisticmonth.FieldOrganizationID:
  35495. return m.OrganizationID()
  35496. case usagestatisticmonth.FieldAiResponse:
  35497. return m.AiResponse()
  35498. case usagestatisticmonth.FieldSopRun:
  35499. return m.SopRun()
  35500. case usagestatisticmonth.FieldTotalFriend:
  35501. return m.TotalFriend()
  35502. case usagestatisticmonth.FieldTotalGroup:
  35503. return m.TotalGroup()
  35504. case usagestatisticmonth.FieldAccountBalance:
  35505. return m.AccountBalance()
  35506. case usagestatisticmonth.FieldConsumeToken:
  35507. return m.ConsumeToken()
  35508. case usagestatisticmonth.FieldActiveUser:
  35509. return m.ActiveUser()
  35510. case usagestatisticmonth.FieldNewUser:
  35511. return m.NewUser()
  35512. case usagestatisticmonth.FieldLabelDist:
  35513. return m.LabelDist()
  35514. }
  35515. return nil, false
  35516. }
  35517. // OldField returns the old value of the field from the database. An error is
  35518. // returned if the mutation operation is not UpdateOne, or the query to the
  35519. // database failed.
  35520. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35521. switch name {
  35522. case usagestatisticmonth.FieldCreatedAt:
  35523. return m.OldCreatedAt(ctx)
  35524. case usagestatisticmonth.FieldUpdatedAt:
  35525. return m.OldUpdatedAt(ctx)
  35526. case usagestatisticmonth.FieldStatus:
  35527. return m.OldStatus(ctx)
  35528. case usagestatisticmonth.FieldDeletedAt:
  35529. return m.OldDeletedAt(ctx)
  35530. case usagestatisticmonth.FieldAddtime:
  35531. return m.OldAddtime(ctx)
  35532. case usagestatisticmonth.FieldType:
  35533. return m.OldType(ctx)
  35534. case usagestatisticmonth.FieldBotID:
  35535. return m.OldBotID(ctx)
  35536. case usagestatisticmonth.FieldOrganizationID:
  35537. return m.OldOrganizationID(ctx)
  35538. case usagestatisticmonth.FieldAiResponse:
  35539. return m.OldAiResponse(ctx)
  35540. case usagestatisticmonth.FieldSopRun:
  35541. return m.OldSopRun(ctx)
  35542. case usagestatisticmonth.FieldTotalFriend:
  35543. return m.OldTotalFriend(ctx)
  35544. case usagestatisticmonth.FieldTotalGroup:
  35545. return m.OldTotalGroup(ctx)
  35546. case usagestatisticmonth.FieldAccountBalance:
  35547. return m.OldAccountBalance(ctx)
  35548. case usagestatisticmonth.FieldConsumeToken:
  35549. return m.OldConsumeToken(ctx)
  35550. case usagestatisticmonth.FieldActiveUser:
  35551. return m.OldActiveUser(ctx)
  35552. case usagestatisticmonth.FieldNewUser:
  35553. return m.OldNewUser(ctx)
  35554. case usagestatisticmonth.FieldLabelDist:
  35555. return m.OldLabelDist(ctx)
  35556. }
  35557. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  35558. }
  35559. // SetField sets the value of a field with the given name. It returns an error if
  35560. // the field is not defined in the schema, or if the type mismatched the field
  35561. // type.
  35562. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  35563. switch name {
  35564. case usagestatisticmonth.FieldCreatedAt:
  35565. v, ok := value.(time.Time)
  35566. if !ok {
  35567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35568. }
  35569. m.SetCreatedAt(v)
  35570. return nil
  35571. case usagestatisticmonth.FieldUpdatedAt:
  35572. v, ok := value.(time.Time)
  35573. if !ok {
  35574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35575. }
  35576. m.SetUpdatedAt(v)
  35577. return nil
  35578. case usagestatisticmonth.FieldStatus:
  35579. v, ok := value.(uint8)
  35580. if !ok {
  35581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35582. }
  35583. m.SetStatus(v)
  35584. return nil
  35585. case usagestatisticmonth.FieldDeletedAt:
  35586. v, ok := value.(time.Time)
  35587. if !ok {
  35588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35589. }
  35590. m.SetDeletedAt(v)
  35591. return nil
  35592. case usagestatisticmonth.FieldAddtime:
  35593. v, ok := value.(uint64)
  35594. if !ok {
  35595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35596. }
  35597. m.SetAddtime(v)
  35598. return nil
  35599. case usagestatisticmonth.FieldType:
  35600. v, ok := value.(int)
  35601. if !ok {
  35602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35603. }
  35604. m.SetType(v)
  35605. return nil
  35606. case usagestatisticmonth.FieldBotID:
  35607. v, ok := value.(string)
  35608. if !ok {
  35609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35610. }
  35611. m.SetBotID(v)
  35612. return nil
  35613. case usagestatisticmonth.FieldOrganizationID:
  35614. v, ok := value.(uint64)
  35615. if !ok {
  35616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35617. }
  35618. m.SetOrganizationID(v)
  35619. return nil
  35620. case usagestatisticmonth.FieldAiResponse:
  35621. v, ok := value.(uint64)
  35622. if !ok {
  35623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35624. }
  35625. m.SetAiResponse(v)
  35626. return nil
  35627. case usagestatisticmonth.FieldSopRun:
  35628. v, ok := value.(uint64)
  35629. if !ok {
  35630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35631. }
  35632. m.SetSopRun(v)
  35633. return nil
  35634. case usagestatisticmonth.FieldTotalFriend:
  35635. v, ok := value.(uint64)
  35636. if !ok {
  35637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35638. }
  35639. m.SetTotalFriend(v)
  35640. return nil
  35641. case usagestatisticmonth.FieldTotalGroup:
  35642. v, ok := value.(uint64)
  35643. if !ok {
  35644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35645. }
  35646. m.SetTotalGroup(v)
  35647. return nil
  35648. case usagestatisticmonth.FieldAccountBalance:
  35649. v, ok := value.(uint64)
  35650. if !ok {
  35651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35652. }
  35653. m.SetAccountBalance(v)
  35654. return nil
  35655. case usagestatisticmonth.FieldConsumeToken:
  35656. v, ok := value.(uint64)
  35657. if !ok {
  35658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35659. }
  35660. m.SetConsumeToken(v)
  35661. return nil
  35662. case usagestatisticmonth.FieldActiveUser:
  35663. v, ok := value.(uint64)
  35664. if !ok {
  35665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35666. }
  35667. m.SetActiveUser(v)
  35668. return nil
  35669. case usagestatisticmonth.FieldNewUser:
  35670. v, ok := value.(int64)
  35671. if !ok {
  35672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35673. }
  35674. m.SetNewUser(v)
  35675. return nil
  35676. case usagestatisticmonth.FieldLabelDist:
  35677. v, ok := value.([]custom_types.LabelDist)
  35678. if !ok {
  35679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35680. }
  35681. m.SetLabelDist(v)
  35682. return nil
  35683. }
  35684. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  35685. }
  35686. // AddedFields returns all numeric fields that were incremented/decremented during
  35687. // this mutation.
  35688. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  35689. var fields []string
  35690. if m.addstatus != nil {
  35691. fields = append(fields, usagestatisticmonth.FieldStatus)
  35692. }
  35693. if m.addaddtime != nil {
  35694. fields = append(fields, usagestatisticmonth.FieldAddtime)
  35695. }
  35696. if m.add_type != nil {
  35697. fields = append(fields, usagestatisticmonth.FieldType)
  35698. }
  35699. if m.addorganization_id != nil {
  35700. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  35701. }
  35702. if m.addai_response != nil {
  35703. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  35704. }
  35705. if m.addsop_run != nil {
  35706. fields = append(fields, usagestatisticmonth.FieldSopRun)
  35707. }
  35708. if m.addtotal_friend != nil {
  35709. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  35710. }
  35711. if m.addtotal_group != nil {
  35712. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  35713. }
  35714. if m.addaccount_balance != nil {
  35715. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  35716. }
  35717. if m.addconsume_token != nil {
  35718. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  35719. }
  35720. if m.addactive_user != nil {
  35721. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  35722. }
  35723. if m.addnew_user != nil {
  35724. fields = append(fields, usagestatisticmonth.FieldNewUser)
  35725. }
  35726. return fields
  35727. }
  35728. // AddedField returns the numeric value that was incremented/decremented on a field
  35729. // with the given name. The second boolean return value indicates that this field
  35730. // was not set, or was not defined in the schema.
  35731. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  35732. switch name {
  35733. case usagestatisticmonth.FieldStatus:
  35734. return m.AddedStatus()
  35735. case usagestatisticmonth.FieldAddtime:
  35736. return m.AddedAddtime()
  35737. case usagestatisticmonth.FieldType:
  35738. return m.AddedType()
  35739. case usagestatisticmonth.FieldOrganizationID:
  35740. return m.AddedOrganizationID()
  35741. case usagestatisticmonth.FieldAiResponse:
  35742. return m.AddedAiResponse()
  35743. case usagestatisticmonth.FieldSopRun:
  35744. return m.AddedSopRun()
  35745. case usagestatisticmonth.FieldTotalFriend:
  35746. return m.AddedTotalFriend()
  35747. case usagestatisticmonth.FieldTotalGroup:
  35748. return m.AddedTotalGroup()
  35749. case usagestatisticmonth.FieldAccountBalance:
  35750. return m.AddedAccountBalance()
  35751. case usagestatisticmonth.FieldConsumeToken:
  35752. return m.AddedConsumeToken()
  35753. case usagestatisticmonth.FieldActiveUser:
  35754. return m.AddedActiveUser()
  35755. case usagestatisticmonth.FieldNewUser:
  35756. return m.AddedNewUser()
  35757. }
  35758. return nil, false
  35759. }
  35760. // AddField adds the value to the field with the given name. It returns an error if
  35761. // the field is not defined in the schema, or if the type mismatched the field
  35762. // type.
  35763. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  35764. switch name {
  35765. case usagestatisticmonth.FieldStatus:
  35766. v, ok := value.(int8)
  35767. if !ok {
  35768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35769. }
  35770. m.AddStatus(v)
  35771. return nil
  35772. case usagestatisticmonth.FieldAddtime:
  35773. v, ok := value.(int64)
  35774. if !ok {
  35775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35776. }
  35777. m.AddAddtime(v)
  35778. return nil
  35779. case usagestatisticmonth.FieldType:
  35780. v, ok := value.(int)
  35781. if !ok {
  35782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35783. }
  35784. m.AddType(v)
  35785. return nil
  35786. case usagestatisticmonth.FieldOrganizationID:
  35787. v, ok := value.(int64)
  35788. if !ok {
  35789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35790. }
  35791. m.AddOrganizationID(v)
  35792. return nil
  35793. case usagestatisticmonth.FieldAiResponse:
  35794. v, ok := value.(int64)
  35795. if !ok {
  35796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35797. }
  35798. m.AddAiResponse(v)
  35799. return nil
  35800. case usagestatisticmonth.FieldSopRun:
  35801. v, ok := value.(int64)
  35802. if !ok {
  35803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35804. }
  35805. m.AddSopRun(v)
  35806. return nil
  35807. case usagestatisticmonth.FieldTotalFriend:
  35808. v, ok := value.(int64)
  35809. if !ok {
  35810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35811. }
  35812. m.AddTotalFriend(v)
  35813. return nil
  35814. case usagestatisticmonth.FieldTotalGroup:
  35815. v, ok := value.(int64)
  35816. if !ok {
  35817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35818. }
  35819. m.AddTotalGroup(v)
  35820. return nil
  35821. case usagestatisticmonth.FieldAccountBalance:
  35822. v, ok := value.(int64)
  35823. if !ok {
  35824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35825. }
  35826. m.AddAccountBalance(v)
  35827. return nil
  35828. case usagestatisticmonth.FieldConsumeToken:
  35829. v, ok := value.(int64)
  35830. if !ok {
  35831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35832. }
  35833. m.AddConsumeToken(v)
  35834. return nil
  35835. case usagestatisticmonth.FieldActiveUser:
  35836. v, ok := value.(int64)
  35837. if !ok {
  35838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35839. }
  35840. m.AddActiveUser(v)
  35841. return nil
  35842. case usagestatisticmonth.FieldNewUser:
  35843. v, ok := value.(int64)
  35844. if !ok {
  35845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35846. }
  35847. m.AddNewUser(v)
  35848. return nil
  35849. }
  35850. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  35851. }
  35852. // ClearedFields returns all nullable fields that were cleared during this
  35853. // mutation.
  35854. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  35855. var fields []string
  35856. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  35857. fields = append(fields, usagestatisticmonth.FieldStatus)
  35858. }
  35859. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  35860. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  35861. }
  35862. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  35863. fields = append(fields, usagestatisticmonth.FieldBotID)
  35864. }
  35865. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  35866. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  35867. }
  35868. return fields
  35869. }
  35870. // FieldCleared returns a boolean indicating if a field with the given name was
  35871. // cleared in this mutation.
  35872. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  35873. _, ok := m.clearedFields[name]
  35874. return ok
  35875. }
  35876. // ClearField clears the value of the field with the given name. It returns an
  35877. // error if the field is not defined in the schema.
  35878. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  35879. switch name {
  35880. case usagestatisticmonth.FieldStatus:
  35881. m.ClearStatus()
  35882. return nil
  35883. case usagestatisticmonth.FieldDeletedAt:
  35884. m.ClearDeletedAt()
  35885. return nil
  35886. case usagestatisticmonth.FieldBotID:
  35887. m.ClearBotID()
  35888. return nil
  35889. case usagestatisticmonth.FieldOrganizationID:
  35890. m.ClearOrganizationID()
  35891. return nil
  35892. }
  35893. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  35894. }
  35895. // ResetField resets all changes in the mutation for the field with the given name.
  35896. // It returns an error if the field is not defined in the schema.
  35897. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  35898. switch name {
  35899. case usagestatisticmonth.FieldCreatedAt:
  35900. m.ResetCreatedAt()
  35901. return nil
  35902. case usagestatisticmonth.FieldUpdatedAt:
  35903. m.ResetUpdatedAt()
  35904. return nil
  35905. case usagestatisticmonth.FieldStatus:
  35906. m.ResetStatus()
  35907. return nil
  35908. case usagestatisticmonth.FieldDeletedAt:
  35909. m.ResetDeletedAt()
  35910. return nil
  35911. case usagestatisticmonth.FieldAddtime:
  35912. m.ResetAddtime()
  35913. return nil
  35914. case usagestatisticmonth.FieldType:
  35915. m.ResetType()
  35916. return nil
  35917. case usagestatisticmonth.FieldBotID:
  35918. m.ResetBotID()
  35919. return nil
  35920. case usagestatisticmonth.FieldOrganizationID:
  35921. m.ResetOrganizationID()
  35922. return nil
  35923. case usagestatisticmonth.FieldAiResponse:
  35924. m.ResetAiResponse()
  35925. return nil
  35926. case usagestatisticmonth.FieldSopRun:
  35927. m.ResetSopRun()
  35928. return nil
  35929. case usagestatisticmonth.FieldTotalFriend:
  35930. m.ResetTotalFriend()
  35931. return nil
  35932. case usagestatisticmonth.FieldTotalGroup:
  35933. m.ResetTotalGroup()
  35934. return nil
  35935. case usagestatisticmonth.FieldAccountBalance:
  35936. m.ResetAccountBalance()
  35937. return nil
  35938. case usagestatisticmonth.FieldConsumeToken:
  35939. m.ResetConsumeToken()
  35940. return nil
  35941. case usagestatisticmonth.FieldActiveUser:
  35942. m.ResetActiveUser()
  35943. return nil
  35944. case usagestatisticmonth.FieldNewUser:
  35945. m.ResetNewUser()
  35946. return nil
  35947. case usagestatisticmonth.FieldLabelDist:
  35948. m.ResetLabelDist()
  35949. return nil
  35950. }
  35951. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  35952. }
  35953. // AddedEdges returns all edge names that were set/added in this mutation.
  35954. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  35955. edges := make([]string, 0, 0)
  35956. return edges
  35957. }
  35958. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35959. // name in this mutation.
  35960. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  35961. return nil
  35962. }
  35963. // RemovedEdges returns all edge names that were removed in this mutation.
  35964. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  35965. edges := make([]string, 0, 0)
  35966. return edges
  35967. }
  35968. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35969. // the given name in this mutation.
  35970. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  35971. return nil
  35972. }
  35973. // ClearedEdges returns all edge names that were cleared in this mutation.
  35974. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  35975. edges := make([]string, 0, 0)
  35976. return edges
  35977. }
  35978. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35979. // was cleared in this mutation.
  35980. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  35981. return false
  35982. }
  35983. // ClearEdge clears the value of the edge with the given name. It returns an error
  35984. // if that edge is not defined in the schema.
  35985. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  35986. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  35987. }
  35988. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35989. // It returns an error if the edge is not defined in the schema.
  35990. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  35991. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  35992. }
  35993. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  35994. type UsageTotalMutation struct {
  35995. config
  35996. op Op
  35997. typ string
  35998. id *uint64
  35999. created_at *time.Time
  36000. updated_at *time.Time
  36001. status *uint8
  36002. addstatus *int8
  36003. _type *int
  36004. add_type *int
  36005. bot_id *string
  36006. total_tokens *uint64
  36007. addtotal_tokens *int64
  36008. start_index *uint64
  36009. addstart_index *int64
  36010. end_index *uint64
  36011. addend_index *int64
  36012. organization_id *uint64
  36013. addorganization_id *int64
  36014. clearedFields map[string]struct{}
  36015. done bool
  36016. oldValue func(context.Context) (*UsageTotal, error)
  36017. predicates []predicate.UsageTotal
  36018. }
  36019. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  36020. // usagetotalOption allows management of the mutation configuration using functional options.
  36021. type usagetotalOption func(*UsageTotalMutation)
  36022. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  36023. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  36024. m := &UsageTotalMutation{
  36025. config: c,
  36026. op: op,
  36027. typ: TypeUsageTotal,
  36028. clearedFields: make(map[string]struct{}),
  36029. }
  36030. for _, opt := range opts {
  36031. opt(m)
  36032. }
  36033. return m
  36034. }
  36035. // withUsageTotalID sets the ID field of the mutation.
  36036. func withUsageTotalID(id uint64) usagetotalOption {
  36037. return func(m *UsageTotalMutation) {
  36038. var (
  36039. err error
  36040. once sync.Once
  36041. value *UsageTotal
  36042. )
  36043. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  36044. once.Do(func() {
  36045. if m.done {
  36046. err = errors.New("querying old values post mutation is not allowed")
  36047. } else {
  36048. value, err = m.Client().UsageTotal.Get(ctx, id)
  36049. }
  36050. })
  36051. return value, err
  36052. }
  36053. m.id = &id
  36054. }
  36055. }
  36056. // withUsageTotal sets the old UsageTotal of the mutation.
  36057. func withUsageTotal(node *UsageTotal) usagetotalOption {
  36058. return func(m *UsageTotalMutation) {
  36059. m.oldValue = func(context.Context) (*UsageTotal, error) {
  36060. return node, nil
  36061. }
  36062. m.id = &node.ID
  36063. }
  36064. }
  36065. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36066. // executed in a transaction (ent.Tx), a transactional client is returned.
  36067. func (m UsageTotalMutation) Client() *Client {
  36068. client := &Client{config: m.config}
  36069. client.init()
  36070. return client
  36071. }
  36072. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36073. // it returns an error otherwise.
  36074. func (m UsageTotalMutation) Tx() (*Tx, error) {
  36075. if _, ok := m.driver.(*txDriver); !ok {
  36076. return nil, errors.New("ent: mutation is not running in a transaction")
  36077. }
  36078. tx := &Tx{config: m.config}
  36079. tx.init()
  36080. return tx, nil
  36081. }
  36082. // SetID sets the value of the id field. Note that this
  36083. // operation is only accepted on creation of UsageTotal entities.
  36084. func (m *UsageTotalMutation) SetID(id uint64) {
  36085. m.id = &id
  36086. }
  36087. // ID returns the ID value in the mutation. Note that the ID is only available
  36088. // if it was provided to the builder or after it was returned from the database.
  36089. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  36090. if m.id == nil {
  36091. return
  36092. }
  36093. return *m.id, true
  36094. }
  36095. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36096. // That means, if the mutation is applied within a transaction with an isolation level such
  36097. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36098. // or updated by the mutation.
  36099. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  36100. switch {
  36101. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36102. id, exists := m.ID()
  36103. if exists {
  36104. return []uint64{id}, nil
  36105. }
  36106. fallthrough
  36107. case m.op.Is(OpUpdate | OpDelete):
  36108. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  36109. default:
  36110. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36111. }
  36112. }
  36113. // SetCreatedAt sets the "created_at" field.
  36114. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  36115. m.created_at = &t
  36116. }
  36117. // CreatedAt returns the value of the "created_at" field in the mutation.
  36118. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  36119. v := m.created_at
  36120. if v == nil {
  36121. return
  36122. }
  36123. return *v, true
  36124. }
  36125. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  36126. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36128. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36129. if !m.op.Is(OpUpdateOne) {
  36130. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36131. }
  36132. if m.id == nil || m.oldValue == nil {
  36133. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36134. }
  36135. oldValue, err := m.oldValue(ctx)
  36136. if err != nil {
  36137. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36138. }
  36139. return oldValue.CreatedAt, nil
  36140. }
  36141. // ResetCreatedAt resets all changes to the "created_at" field.
  36142. func (m *UsageTotalMutation) ResetCreatedAt() {
  36143. m.created_at = nil
  36144. }
  36145. // SetUpdatedAt sets the "updated_at" field.
  36146. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  36147. m.updated_at = &t
  36148. }
  36149. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36150. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  36151. v := m.updated_at
  36152. if v == nil {
  36153. return
  36154. }
  36155. return *v, true
  36156. }
  36157. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  36158. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36160. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36161. if !m.op.Is(OpUpdateOne) {
  36162. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36163. }
  36164. if m.id == nil || m.oldValue == nil {
  36165. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36166. }
  36167. oldValue, err := m.oldValue(ctx)
  36168. if err != nil {
  36169. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36170. }
  36171. return oldValue.UpdatedAt, nil
  36172. }
  36173. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36174. func (m *UsageTotalMutation) ResetUpdatedAt() {
  36175. m.updated_at = nil
  36176. }
  36177. // SetStatus sets the "status" field.
  36178. func (m *UsageTotalMutation) SetStatus(u uint8) {
  36179. m.status = &u
  36180. m.addstatus = nil
  36181. }
  36182. // Status returns the value of the "status" field in the mutation.
  36183. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  36184. v := m.status
  36185. if v == nil {
  36186. return
  36187. }
  36188. return *v, true
  36189. }
  36190. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  36191. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36193. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36194. if !m.op.Is(OpUpdateOne) {
  36195. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36196. }
  36197. if m.id == nil || m.oldValue == nil {
  36198. return v, errors.New("OldStatus requires an ID field in the mutation")
  36199. }
  36200. oldValue, err := m.oldValue(ctx)
  36201. if err != nil {
  36202. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36203. }
  36204. return oldValue.Status, nil
  36205. }
  36206. // AddStatus adds u to the "status" field.
  36207. func (m *UsageTotalMutation) AddStatus(u int8) {
  36208. if m.addstatus != nil {
  36209. *m.addstatus += u
  36210. } else {
  36211. m.addstatus = &u
  36212. }
  36213. }
  36214. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36215. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  36216. v := m.addstatus
  36217. if v == nil {
  36218. return
  36219. }
  36220. return *v, true
  36221. }
  36222. // ClearStatus clears the value of the "status" field.
  36223. func (m *UsageTotalMutation) ClearStatus() {
  36224. m.status = nil
  36225. m.addstatus = nil
  36226. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  36227. }
  36228. // StatusCleared returns if the "status" field was cleared in this mutation.
  36229. func (m *UsageTotalMutation) StatusCleared() bool {
  36230. _, ok := m.clearedFields[usagetotal.FieldStatus]
  36231. return ok
  36232. }
  36233. // ResetStatus resets all changes to the "status" field.
  36234. func (m *UsageTotalMutation) ResetStatus() {
  36235. m.status = nil
  36236. m.addstatus = nil
  36237. delete(m.clearedFields, usagetotal.FieldStatus)
  36238. }
  36239. // SetType sets the "type" field.
  36240. func (m *UsageTotalMutation) SetType(i int) {
  36241. m._type = &i
  36242. m.add_type = nil
  36243. }
  36244. // GetType returns the value of the "type" field in the mutation.
  36245. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  36246. v := m._type
  36247. if v == nil {
  36248. return
  36249. }
  36250. return *v, true
  36251. }
  36252. // OldType returns the old "type" field's value of the UsageTotal entity.
  36253. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36255. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  36256. if !m.op.Is(OpUpdateOne) {
  36257. return v, errors.New("OldType is only allowed on UpdateOne operations")
  36258. }
  36259. if m.id == nil || m.oldValue == nil {
  36260. return v, errors.New("OldType requires an ID field in the mutation")
  36261. }
  36262. oldValue, err := m.oldValue(ctx)
  36263. if err != nil {
  36264. return v, fmt.Errorf("querying old value for OldType: %w", err)
  36265. }
  36266. return oldValue.Type, nil
  36267. }
  36268. // AddType adds i to the "type" field.
  36269. func (m *UsageTotalMutation) AddType(i int) {
  36270. if m.add_type != nil {
  36271. *m.add_type += i
  36272. } else {
  36273. m.add_type = &i
  36274. }
  36275. }
  36276. // AddedType returns the value that was added to the "type" field in this mutation.
  36277. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  36278. v := m.add_type
  36279. if v == nil {
  36280. return
  36281. }
  36282. return *v, true
  36283. }
  36284. // ClearType clears the value of the "type" field.
  36285. func (m *UsageTotalMutation) ClearType() {
  36286. m._type = nil
  36287. m.add_type = nil
  36288. m.clearedFields[usagetotal.FieldType] = struct{}{}
  36289. }
  36290. // TypeCleared returns if the "type" field was cleared in this mutation.
  36291. func (m *UsageTotalMutation) TypeCleared() bool {
  36292. _, ok := m.clearedFields[usagetotal.FieldType]
  36293. return ok
  36294. }
  36295. // ResetType resets all changes to the "type" field.
  36296. func (m *UsageTotalMutation) ResetType() {
  36297. m._type = nil
  36298. m.add_type = nil
  36299. delete(m.clearedFields, usagetotal.FieldType)
  36300. }
  36301. // SetBotID sets the "bot_id" field.
  36302. func (m *UsageTotalMutation) SetBotID(s string) {
  36303. m.bot_id = &s
  36304. }
  36305. // BotID returns the value of the "bot_id" field in the mutation.
  36306. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  36307. v := m.bot_id
  36308. if v == nil {
  36309. return
  36310. }
  36311. return *v, true
  36312. }
  36313. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  36314. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36316. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  36317. if !m.op.Is(OpUpdateOne) {
  36318. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36319. }
  36320. if m.id == nil || m.oldValue == nil {
  36321. return v, errors.New("OldBotID requires an ID field in the mutation")
  36322. }
  36323. oldValue, err := m.oldValue(ctx)
  36324. if err != nil {
  36325. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36326. }
  36327. return oldValue.BotID, nil
  36328. }
  36329. // ResetBotID resets all changes to the "bot_id" field.
  36330. func (m *UsageTotalMutation) ResetBotID() {
  36331. m.bot_id = nil
  36332. }
  36333. // SetTotalTokens sets the "total_tokens" field.
  36334. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  36335. m.total_tokens = &u
  36336. m.addtotal_tokens = nil
  36337. }
  36338. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  36339. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  36340. v := m.total_tokens
  36341. if v == nil {
  36342. return
  36343. }
  36344. return *v, true
  36345. }
  36346. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  36347. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36349. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  36350. if !m.op.Is(OpUpdateOne) {
  36351. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  36352. }
  36353. if m.id == nil || m.oldValue == nil {
  36354. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  36355. }
  36356. oldValue, err := m.oldValue(ctx)
  36357. if err != nil {
  36358. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  36359. }
  36360. return oldValue.TotalTokens, nil
  36361. }
  36362. // AddTotalTokens adds u to the "total_tokens" field.
  36363. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  36364. if m.addtotal_tokens != nil {
  36365. *m.addtotal_tokens += u
  36366. } else {
  36367. m.addtotal_tokens = &u
  36368. }
  36369. }
  36370. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  36371. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  36372. v := m.addtotal_tokens
  36373. if v == nil {
  36374. return
  36375. }
  36376. return *v, true
  36377. }
  36378. // ClearTotalTokens clears the value of the "total_tokens" field.
  36379. func (m *UsageTotalMutation) ClearTotalTokens() {
  36380. m.total_tokens = nil
  36381. m.addtotal_tokens = nil
  36382. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  36383. }
  36384. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  36385. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  36386. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  36387. return ok
  36388. }
  36389. // ResetTotalTokens resets all changes to the "total_tokens" field.
  36390. func (m *UsageTotalMutation) ResetTotalTokens() {
  36391. m.total_tokens = nil
  36392. m.addtotal_tokens = nil
  36393. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  36394. }
  36395. // SetStartIndex sets the "start_index" field.
  36396. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  36397. m.start_index = &u
  36398. m.addstart_index = nil
  36399. }
  36400. // StartIndex returns the value of the "start_index" field in the mutation.
  36401. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  36402. v := m.start_index
  36403. if v == nil {
  36404. return
  36405. }
  36406. return *v, true
  36407. }
  36408. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  36409. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36411. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  36412. if !m.op.Is(OpUpdateOne) {
  36413. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  36414. }
  36415. if m.id == nil || m.oldValue == nil {
  36416. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  36417. }
  36418. oldValue, err := m.oldValue(ctx)
  36419. if err != nil {
  36420. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  36421. }
  36422. return oldValue.StartIndex, nil
  36423. }
  36424. // AddStartIndex adds u to the "start_index" field.
  36425. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  36426. if m.addstart_index != nil {
  36427. *m.addstart_index += u
  36428. } else {
  36429. m.addstart_index = &u
  36430. }
  36431. }
  36432. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  36433. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  36434. v := m.addstart_index
  36435. if v == nil {
  36436. return
  36437. }
  36438. return *v, true
  36439. }
  36440. // ClearStartIndex clears the value of the "start_index" field.
  36441. func (m *UsageTotalMutation) ClearStartIndex() {
  36442. m.start_index = nil
  36443. m.addstart_index = nil
  36444. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  36445. }
  36446. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  36447. func (m *UsageTotalMutation) StartIndexCleared() bool {
  36448. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  36449. return ok
  36450. }
  36451. // ResetStartIndex resets all changes to the "start_index" field.
  36452. func (m *UsageTotalMutation) ResetStartIndex() {
  36453. m.start_index = nil
  36454. m.addstart_index = nil
  36455. delete(m.clearedFields, usagetotal.FieldStartIndex)
  36456. }
  36457. // SetEndIndex sets the "end_index" field.
  36458. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  36459. m.end_index = &u
  36460. m.addend_index = nil
  36461. }
  36462. // EndIndex returns the value of the "end_index" field in the mutation.
  36463. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  36464. v := m.end_index
  36465. if v == nil {
  36466. return
  36467. }
  36468. return *v, true
  36469. }
  36470. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  36471. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36473. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  36474. if !m.op.Is(OpUpdateOne) {
  36475. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  36476. }
  36477. if m.id == nil || m.oldValue == nil {
  36478. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  36479. }
  36480. oldValue, err := m.oldValue(ctx)
  36481. if err != nil {
  36482. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  36483. }
  36484. return oldValue.EndIndex, nil
  36485. }
  36486. // AddEndIndex adds u to the "end_index" field.
  36487. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  36488. if m.addend_index != nil {
  36489. *m.addend_index += u
  36490. } else {
  36491. m.addend_index = &u
  36492. }
  36493. }
  36494. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  36495. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  36496. v := m.addend_index
  36497. if v == nil {
  36498. return
  36499. }
  36500. return *v, true
  36501. }
  36502. // ClearEndIndex clears the value of the "end_index" field.
  36503. func (m *UsageTotalMutation) ClearEndIndex() {
  36504. m.end_index = nil
  36505. m.addend_index = nil
  36506. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  36507. }
  36508. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  36509. func (m *UsageTotalMutation) EndIndexCleared() bool {
  36510. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  36511. return ok
  36512. }
  36513. // ResetEndIndex resets all changes to the "end_index" field.
  36514. func (m *UsageTotalMutation) ResetEndIndex() {
  36515. m.end_index = nil
  36516. m.addend_index = nil
  36517. delete(m.clearedFields, usagetotal.FieldEndIndex)
  36518. }
  36519. // SetOrganizationID sets the "organization_id" field.
  36520. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  36521. m.organization_id = &u
  36522. m.addorganization_id = nil
  36523. }
  36524. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36525. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  36526. v := m.organization_id
  36527. if v == nil {
  36528. return
  36529. }
  36530. return *v, true
  36531. }
  36532. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  36533. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36535. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36536. if !m.op.Is(OpUpdateOne) {
  36537. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36538. }
  36539. if m.id == nil || m.oldValue == nil {
  36540. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36541. }
  36542. oldValue, err := m.oldValue(ctx)
  36543. if err != nil {
  36544. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36545. }
  36546. return oldValue.OrganizationID, nil
  36547. }
  36548. // AddOrganizationID adds u to the "organization_id" field.
  36549. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  36550. if m.addorganization_id != nil {
  36551. *m.addorganization_id += u
  36552. } else {
  36553. m.addorganization_id = &u
  36554. }
  36555. }
  36556. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36557. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  36558. v := m.addorganization_id
  36559. if v == nil {
  36560. return
  36561. }
  36562. return *v, true
  36563. }
  36564. // ClearOrganizationID clears the value of the "organization_id" field.
  36565. func (m *UsageTotalMutation) ClearOrganizationID() {
  36566. m.organization_id = nil
  36567. m.addorganization_id = nil
  36568. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  36569. }
  36570. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36571. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  36572. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  36573. return ok
  36574. }
  36575. // ResetOrganizationID resets all changes to the "organization_id" field.
  36576. func (m *UsageTotalMutation) ResetOrganizationID() {
  36577. m.organization_id = nil
  36578. m.addorganization_id = nil
  36579. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  36580. }
  36581. // Where appends a list predicates to the UsageTotalMutation builder.
  36582. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  36583. m.predicates = append(m.predicates, ps...)
  36584. }
  36585. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  36586. // users can use type-assertion to append predicates that do not depend on any generated package.
  36587. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  36588. p := make([]predicate.UsageTotal, len(ps))
  36589. for i := range ps {
  36590. p[i] = ps[i]
  36591. }
  36592. m.Where(p...)
  36593. }
  36594. // Op returns the operation name.
  36595. func (m *UsageTotalMutation) Op() Op {
  36596. return m.op
  36597. }
  36598. // SetOp allows setting the mutation operation.
  36599. func (m *UsageTotalMutation) SetOp(op Op) {
  36600. m.op = op
  36601. }
  36602. // Type returns the node type of this mutation (UsageTotal).
  36603. func (m *UsageTotalMutation) Type() string {
  36604. return m.typ
  36605. }
  36606. // Fields returns all fields that were changed during this mutation. Note that in
  36607. // order to get all numeric fields that were incremented/decremented, call
  36608. // AddedFields().
  36609. func (m *UsageTotalMutation) Fields() []string {
  36610. fields := make([]string, 0, 9)
  36611. if m.created_at != nil {
  36612. fields = append(fields, usagetotal.FieldCreatedAt)
  36613. }
  36614. if m.updated_at != nil {
  36615. fields = append(fields, usagetotal.FieldUpdatedAt)
  36616. }
  36617. if m.status != nil {
  36618. fields = append(fields, usagetotal.FieldStatus)
  36619. }
  36620. if m._type != nil {
  36621. fields = append(fields, usagetotal.FieldType)
  36622. }
  36623. if m.bot_id != nil {
  36624. fields = append(fields, usagetotal.FieldBotID)
  36625. }
  36626. if m.total_tokens != nil {
  36627. fields = append(fields, usagetotal.FieldTotalTokens)
  36628. }
  36629. if m.start_index != nil {
  36630. fields = append(fields, usagetotal.FieldStartIndex)
  36631. }
  36632. if m.end_index != nil {
  36633. fields = append(fields, usagetotal.FieldEndIndex)
  36634. }
  36635. if m.organization_id != nil {
  36636. fields = append(fields, usagetotal.FieldOrganizationID)
  36637. }
  36638. return fields
  36639. }
  36640. // Field returns the value of a field with the given name. The second boolean
  36641. // return value indicates that this field was not set, or was not defined in the
  36642. // schema.
  36643. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  36644. switch name {
  36645. case usagetotal.FieldCreatedAt:
  36646. return m.CreatedAt()
  36647. case usagetotal.FieldUpdatedAt:
  36648. return m.UpdatedAt()
  36649. case usagetotal.FieldStatus:
  36650. return m.Status()
  36651. case usagetotal.FieldType:
  36652. return m.GetType()
  36653. case usagetotal.FieldBotID:
  36654. return m.BotID()
  36655. case usagetotal.FieldTotalTokens:
  36656. return m.TotalTokens()
  36657. case usagetotal.FieldStartIndex:
  36658. return m.StartIndex()
  36659. case usagetotal.FieldEndIndex:
  36660. return m.EndIndex()
  36661. case usagetotal.FieldOrganizationID:
  36662. return m.OrganizationID()
  36663. }
  36664. return nil, false
  36665. }
  36666. // OldField returns the old value of the field from the database. An error is
  36667. // returned if the mutation operation is not UpdateOne, or the query to the
  36668. // database failed.
  36669. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36670. switch name {
  36671. case usagetotal.FieldCreatedAt:
  36672. return m.OldCreatedAt(ctx)
  36673. case usagetotal.FieldUpdatedAt:
  36674. return m.OldUpdatedAt(ctx)
  36675. case usagetotal.FieldStatus:
  36676. return m.OldStatus(ctx)
  36677. case usagetotal.FieldType:
  36678. return m.OldType(ctx)
  36679. case usagetotal.FieldBotID:
  36680. return m.OldBotID(ctx)
  36681. case usagetotal.FieldTotalTokens:
  36682. return m.OldTotalTokens(ctx)
  36683. case usagetotal.FieldStartIndex:
  36684. return m.OldStartIndex(ctx)
  36685. case usagetotal.FieldEndIndex:
  36686. return m.OldEndIndex(ctx)
  36687. case usagetotal.FieldOrganizationID:
  36688. return m.OldOrganizationID(ctx)
  36689. }
  36690. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  36691. }
  36692. // SetField sets the value of a field with the given name. It returns an error if
  36693. // the field is not defined in the schema, or if the type mismatched the field
  36694. // type.
  36695. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  36696. switch name {
  36697. case usagetotal.FieldCreatedAt:
  36698. v, ok := value.(time.Time)
  36699. if !ok {
  36700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36701. }
  36702. m.SetCreatedAt(v)
  36703. return nil
  36704. case usagetotal.FieldUpdatedAt:
  36705. v, ok := value.(time.Time)
  36706. if !ok {
  36707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36708. }
  36709. m.SetUpdatedAt(v)
  36710. return nil
  36711. case usagetotal.FieldStatus:
  36712. v, ok := value.(uint8)
  36713. if !ok {
  36714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36715. }
  36716. m.SetStatus(v)
  36717. return nil
  36718. case usagetotal.FieldType:
  36719. v, ok := value.(int)
  36720. if !ok {
  36721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36722. }
  36723. m.SetType(v)
  36724. return nil
  36725. case usagetotal.FieldBotID:
  36726. v, ok := value.(string)
  36727. if !ok {
  36728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36729. }
  36730. m.SetBotID(v)
  36731. return nil
  36732. case usagetotal.FieldTotalTokens:
  36733. v, ok := value.(uint64)
  36734. if !ok {
  36735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36736. }
  36737. m.SetTotalTokens(v)
  36738. return nil
  36739. case usagetotal.FieldStartIndex:
  36740. v, ok := value.(uint64)
  36741. if !ok {
  36742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36743. }
  36744. m.SetStartIndex(v)
  36745. return nil
  36746. case usagetotal.FieldEndIndex:
  36747. v, ok := value.(uint64)
  36748. if !ok {
  36749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36750. }
  36751. m.SetEndIndex(v)
  36752. return nil
  36753. case usagetotal.FieldOrganizationID:
  36754. v, ok := value.(uint64)
  36755. if !ok {
  36756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36757. }
  36758. m.SetOrganizationID(v)
  36759. return nil
  36760. }
  36761. return fmt.Errorf("unknown UsageTotal field %s", name)
  36762. }
  36763. // AddedFields returns all numeric fields that were incremented/decremented during
  36764. // this mutation.
  36765. func (m *UsageTotalMutation) AddedFields() []string {
  36766. var fields []string
  36767. if m.addstatus != nil {
  36768. fields = append(fields, usagetotal.FieldStatus)
  36769. }
  36770. if m.add_type != nil {
  36771. fields = append(fields, usagetotal.FieldType)
  36772. }
  36773. if m.addtotal_tokens != nil {
  36774. fields = append(fields, usagetotal.FieldTotalTokens)
  36775. }
  36776. if m.addstart_index != nil {
  36777. fields = append(fields, usagetotal.FieldStartIndex)
  36778. }
  36779. if m.addend_index != nil {
  36780. fields = append(fields, usagetotal.FieldEndIndex)
  36781. }
  36782. if m.addorganization_id != nil {
  36783. fields = append(fields, usagetotal.FieldOrganizationID)
  36784. }
  36785. return fields
  36786. }
  36787. // AddedField returns the numeric value that was incremented/decremented on a field
  36788. // with the given name. The second boolean return value indicates that this field
  36789. // was not set, or was not defined in the schema.
  36790. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  36791. switch name {
  36792. case usagetotal.FieldStatus:
  36793. return m.AddedStatus()
  36794. case usagetotal.FieldType:
  36795. return m.AddedType()
  36796. case usagetotal.FieldTotalTokens:
  36797. return m.AddedTotalTokens()
  36798. case usagetotal.FieldStartIndex:
  36799. return m.AddedStartIndex()
  36800. case usagetotal.FieldEndIndex:
  36801. return m.AddedEndIndex()
  36802. case usagetotal.FieldOrganizationID:
  36803. return m.AddedOrganizationID()
  36804. }
  36805. return nil, false
  36806. }
  36807. // AddField adds the value to the field with the given name. It returns an error if
  36808. // the field is not defined in the schema, or if the type mismatched the field
  36809. // type.
  36810. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  36811. switch name {
  36812. case usagetotal.FieldStatus:
  36813. v, ok := value.(int8)
  36814. if !ok {
  36815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36816. }
  36817. m.AddStatus(v)
  36818. return nil
  36819. case usagetotal.FieldType:
  36820. v, ok := value.(int)
  36821. if !ok {
  36822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36823. }
  36824. m.AddType(v)
  36825. return nil
  36826. case usagetotal.FieldTotalTokens:
  36827. v, ok := value.(int64)
  36828. if !ok {
  36829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36830. }
  36831. m.AddTotalTokens(v)
  36832. return nil
  36833. case usagetotal.FieldStartIndex:
  36834. v, ok := value.(int64)
  36835. if !ok {
  36836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36837. }
  36838. m.AddStartIndex(v)
  36839. return nil
  36840. case usagetotal.FieldEndIndex:
  36841. v, ok := value.(int64)
  36842. if !ok {
  36843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36844. }
  36845. m.AddEndIndex(v)
  36846. return nil
  36847. case usagetotal.FieldOrganizationID:
  36848. v, ok := value.(int64)
  36849. if !ok {
  36850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36851. }
  36852. m.AddOrganizationID(v)
  36853. return nil
  36854. }
  36855. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  36856. }
  36857. // ClearedFields returns all nullable fields that were cleared during this
  36858. // mutation.
  36859. func (m *UsageTotalMutation) ClearedFields() []string {
  36860. var fields []string
  36861. if m.FieldCleared(usagetotal.FieldStatus) {
  36862. fields = append(fields, usagetotal.FieldStatus)
  36863. }
  36864. if m.FieldCleared(usagetotal.FieldType) {
  36865. fields = append(fields, usagetotal.FieldType)
  36866. }
  36867. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  36868. fields = append(fields, usagetotal.FieldTotalTokens)
  36869. }
  36870. if m.FieldCleared(usagetotal.FieldStartIndex) {
  36871. fields = append(fields, usagetotal.FieldStartIndex)
  36872. }
  36873. if m.FieldCleared(usagetotal.FieldEndIndex) {
  36874. fields = append(fields, usagetotal.FieldEndIndex)
  36875. }
  36876. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  36877. fields = append(fields, usagetotal.FieldOrganizationID)
  36878. }
  36879. return fields
  36880. }
  36881. // FieldCleared returns a boolean indicating if a field with the given name was
  36882. // cleared in this mutation.
  36883. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  36884. _, ok := m.clearedFields[name]
  36885. return ok
  36886. }
  36887. // ClearField clears the value of the field with the given name. It returns an
  36888. // error if the field is not defined in the schema.
  36889. func (m *UsageTotalMutation) ClearField(name string) error {
  36890. switch name {
  36891. case usagetotal.FieldStatus:
  36892. m.ClearStatus()
  36893. return nil
  36894. case usagetotal.FieldType:
  36895. m.ClearType()
  36896. return nil
  36897. case usagetotal.FieldTotalTokens:
  36898. m.ClearTotalTokens()
  36899. return nil
  36900. case usagetotal.FieldStartIndex:
  36901. m.ClearStartIndex()
  36902. return nil
  36903. case usagetotal.FieldEndIndex:
  36904. m.ClearEndIndex()
  36905. return nil
  36906. case usagetotal.FieldOrganizationID:
  36907. m.ClearOrganizationID()
  36908. return nil
  36909. }
  36910. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  36911. }
  36912. // ResetField resets all changes in the mutation for the field with the given name.
  36913. // It returns an error if the field is not defined in the schema.
  36914. func (m *UsageTotalMutation) ResetField(name string) error {
  36915. switch name {
  36916. case usagetotal.FieldCreatedAt:
  36917. m.ResetCreatedAt()
  36918. return nil
  36919. case usagetotal.FieldUpdatedAt:
  36920. m.ResetUpdatedAt()
  36921. return nil
  36922. case usagetotal.FieldStatus:
  36923. m.ResetStatus()
  36924. return nil
  36925. case usagetotal.FieldType:
  36926. m.ResetType()
  36927. return nil
  36928. case usagetotal.FieldBotID:
  36929. m.ResetBotID()
  36930. return nil
  36931. case usagetotal.FieldTotalTokens:
  36932. m.ResetTotalTokens()
  36933. return nil
  36934. case usagetotal.FieldStartIndex:
  36935. m.ResetStartIndex()
  36936. return nil
  36937. case usagetotal.FieldEndIndex:
  36938. m.ResetEndIndex()
  36939. return nil
  36940. case usagetotal.FieldOrganizationID:
  36941. m.ResetOrganizationID()
  36942. return nil
  36943. }
  36944. return fmt.Errorf("unknown UsageTotal field %s", name)
  36945. }
  36946. // AddedEdges returns all edge names that were set/added in this mutation.
  36947. func (m *UsageTotalMutation) AddedEdges() []string {
  36948. edges := make([]string, 0, 0)
  36949. return edges
  36950. }
  36951. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36952. // name in this mutation.
  36953. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  36954. return nil
  36955. }
  36956. // RemovedEdges returns all edge names that were removed in this mutation.
  36957. func (m *UsageTotalMutation) RemovedEdges() []string {
  36958. edges := make([]string, 0, 0)
  36959. return edges
  36960. }
  36961. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36962. // the given name in this mutation.
  36963. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  36964. return nil
  36965. }
  36966. // ClearedEdges returns all edge names that were cleared in this mutation.
  36967. func (m *UsageTotalMutation) ClearedEdges() []string {
  36968. edges := make([]string, 0, 0)
  36969. return edges
  36970. }
  36971. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36972. // was cleared in this mutation.
  36973. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  36974. return false
  36975. }
  36976. // ClearEdge clears the value of the edge with the given name. It returns an error
  36977. // if that edge is not defined in the schema.
  36978. func (m *UsageTotalMutation) ClearEdge(name string) error {
  36979. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  36980. }
  36981. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36982. // It returns an error if the edge is not defined in the schema.
  36983. func (m *UsageTotalMutation) ResetEdge(name string) error {
  36984. return fmt.Errorf("unknown UsageTotal edge %s", name)
  36985. }
  36986. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  36987. type WhatsappMutation struct {
  36988. config
  36989. op Op
  36990. typ string
  36991. id *uint64
  36992. created_at *time.Time
  36993. updated_at *time.Time
  36994. status *uint8
  36995. addstatus *int8
  36996. deleted_at *time.Time
  36997. wa_id *string
  36998. wa_name *string
  36999. callback *string
  37000. account *string
  37001. cc *string
  37002. phone *string
  37003. cc_phone *string
  37004. phone_name *string
  37005. phone_status *int8
  37006. addphone_status *int8
  37007. organization_id *uint64
  37008. addorganization_id *int64
  37009. api_base *string
  37010. api_key *string
  37011. allow_list *[]string
  37012. appendallow_list []string
  37013. group_allow_list *[]string
  37014. appendgroup_allow_list []string
  37015. block_list *[]string
  37016. appendblock_list []string
  37017. group_block_list *[]string
  37018. appendgroup_block_list []string
  37019. clearedFields map[string]struct{}
  37020. agent *uint64
  37021. clearedagent bool
  37022. done bool
  37023. oldValue func(context.Context) (*Whatsapp, error)
  37024. predicates []predicate.Whatsapp
  37025. }
  37026. var _ ent.Mutation = (*WhatsappMutation)(nil)
  37027. // whatsappOption allows management of the mutation configuration using functional options.
  37028. type whatsappOption func(*WhatsappMutation)
  37029. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  37030. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  37031. m := &WhatsappMutation{
  37032. config: c,
  37033. op: op,
  37034. typ: TypeWhatsapp,
  37035. clearedFields: make(map[string]struct{}),
  37036. }
  37037. for _, opt := range opts {
  37038. opt(m)
  37039. }
  37040. return m
  37041. }
  37042. // withWhatsappID sets the ID field of the mutation.
  37043. func withWhatsappID(id uint64) whatsappOption {
  37044. return func(m *WhatsappMutation) {
  37045. var (
  37046. err error
  37047. once sync.Once
  37048. value *Whatsapp
  37049. )
  37050. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  37051. once.Do(func() {
  37052. if m.done {
  37053. err = errors.New("querying old values post mutation is not allowed")
  37054. } else {
  37055. value, err = m.Client().Whatsapp.Get(ctx, id)
  37056. }
  37057. })
  37058. return value, err
  37059. }
  37060. m.id = &id
  37061. }
  37062. }
  37063. // withWhatsapp sets the old Whatsapp of the mutation.
  37064. func withWhatsapp(node *Whatsapp) whatsappOption {
  37065. return func(m *WhatsappMutation) {
  37066. m.oldValue = func(context.Context) (*Whatsapp, error) {
  37067. return node, nil
  37068. }
  37069. m.id = &node.ID
  37070. }
  37071. }
  37072. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37073. // executed in a transaction (ent.Tx), a transactional client is returned.
  37074. func (m WhatsappMutation) Client() *Client {
  37075. client := &Client{config: m.config}
  37076. client.init()
  37077. return client
  37078. }
  37079. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37080. // it returns an error otherwise.
  37081. func (m WhatsappMutation) Tx() (*Tx, error) {
  37082. if _, ok := m.driver.(*txDriver); !ok {
  37083. return nil, errors.New("ent: mutation is not running in a transaction")
  37084. }
  37085. tx := &Tx{config: m.config}
  37086. tx.init()
  37087. return tx, nil
  37088. }
  37089. // SetID sets the value of the id field. Note that this
  37090. // operation is only accepted on creation of Whatsapp entities.
  37091. func (m *WhatsappMutation) SetID(id uint64) {
  37092. m.id = &id
  37093. }
  37094. // ID returns the ID value in the mutation. Note that the ID is only available
  37095. // if it was provided to the builder or after it was returned from the database.
  37096. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  37097. if m.id == nil {
  37098. return
  37099. }
  37100. return *m.id, true
  37101. }
  37102. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37103. // That means, if the mutation is applied within a transaction with an isolation level such
  37104. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37105. // or updated by the mutation.
  37106. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  37107. switch {
  37108. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37109. id, exists := m.ID()
  37110. if exists {
  37111. return []uint64{id}, nil
  37112. }
  37113. fallthrough
  37114. case m.op.Is(OpUpdate | OpDelete):
  37115. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  37116. default:
  37117. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37118. }
  37119. }
  37120. // SetCreatedAt sets the "created_at" field.
  37121. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  37122. m.created_at = &t
  37123. }
  37124. // CreatedAt returns the value of the "created_at" field in the mutation.
  37125. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  37126. v := m.created_at
  37127. if v == nil {
  37128. return
  37129. }
  37130. return *v, true
  37131. }
  37132. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  37133. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37135. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37136. if !m.op.Is(OpUpdateOne) {
  37137. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37138. }
  37139. if m.id == nil || m.oldValue == nil {
  37140. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37141. }
  37142. oldValue, err := m.oldValue(ctx)
  37143. if err != nil {
  37144. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37145. }
  37146. return oldValue.CreatedAt, nil
  37147. }
  37148. // ResetCreatedAt resets all changes to the "created_at" field.
  37149. func (m *WhatsappMutation) ResetCreatedAt() {
  37150. m.created_at = nil
  37151. }
  37152. // SetUpdatedAt sets the "updated_at" field.
  37153. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  37154. m.updated_at = &t
  37155. }
  37156. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37157. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  37158. v := m.updated_at
  37159. if v == nil {
  37160. return
  37161. }
  37162. return *v, true
  37163. }
  37164. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  37165. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37167. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37168. if !m.op.Is(OpUpdateOne) {
  37169. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37170. }
  37171. if m.id == nil || m.oldValue == nil {
  37172. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37173. }
  37174. oldValue, err := m.oldValue(ctx)
  37175. if err != nil {
  37176. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37177. }
  37178. return oldValue.UpdatedAt, nil
  37179. }
  37180. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37181. func (m *WhatsappMutation) ResetUpdatedAt() {
  37182. m.updated_at = nil
  37183. }
  37184. // SetStatus sets the "status" field.
  37185. func (m *WhatsappMutation) SetStatus(u uint8) {
  37186. m.status = &u
  37187. m.addstatus = nil
  37188. }
  37189. // Status returns the value of the "status" field in the mutation.
  37190. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  37191. v := m.status
  37192. if v == nil {
  37193. return
  37194. }
  37195. return *v, true
  37196. }
  37197. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  37198. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37200. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37201. if !m.op.Is(OpUpdateOne) {
  37202. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37203. }
  37204. if m.id == nil || m.oldValue == nil {
  37205. return v, errors.New("OldStatus requires an ID field in the mutation")
  37206. }
  37207. oldValue, err := m.oldValue(ctx)
  37208. if err != nil {
  37209. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37210. }
  37211. return oldValue.Status, nil
  37212. }
  37213. // AddStatus adds u to the "status" field.
  37214. func (m *WhatsappMutation) AddStatus(u int8) {
  37215. if m.addstatus != nil {
  37216. *m.addstatus += u
  37217. } else {
  37218. m.addstatus = &u
  37219. }
  37220. }
  37221. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37222. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  37223. v := m.addstatus
  37224. if v == nil {
  37225. return
  37226. }
  37227. return *v, true
  37228. }
  37229. // ClearStatus clears the value of the "status" field.
  37230. func (m *WhatsappMutation) ClearStatus() {
  37231. m.status = nil
  37232. m.addstatus = nil
  37233. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  37234. }
  37235. // StatusCleared returns if the "status" field was cleared in this mutation.
  37236. func (m *WhatsappMutation) StatusCleared() bool {
  37237. _, ok := m.clearedFields[whatsapp.FieldStatus]
  37238. return ok
  37239. }
  37240. // ResetStatus resets all changes to the "status" field.
  37241. func (m *WhatsappMutation) ResetStatus() {
  37242. m.status = nil
  37243. m.addstatus = nil
  37244. delete(m.clearedFields, whatsapp.FieldStatus)
  37245. }
  37246. // SetDeletedAt sets the "deleted_at" field.
  37247. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  37248. m.deleted_at = &t
  37249. }
  37250. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37251. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  37252. v := m.deleted_at
  37253. if v == nil {
  37254. return
  37255. }
  37256. return *v, true
  37257. }
  37258. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  37259. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37261. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37262. if !m.op.Is(OpUpdateOne) {
  37263. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37264. }
  37265. if m.id == nil || m.oldValue == nil {
  37266. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37267. }
  37268. oldValue, err := m.oldValue(ctx)
  37269. if err != nil {
  37270. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37271. }
  37272. return oldValue.DeletedAt, nil
  37273. }
  37274. // ClearDeletedAt clears the value of the "deleted_at" field.
  37275. func (m *WhatsappMutation) ClearDeletedAt() {
  37276. m.deleted_at = nil
  37277. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  37278. }
  37279. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37280. func (m *WhatsappMutation) DeletedAtCleared() bool {
  37281. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  37282. return ok
  37283. }
  37284. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37285. func (m *WhatsappMutation) ResetDeletedAt() {
  37286. m.deleted_at = nil
  37287. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  37288. }
  37289. // SetWaID sets the "wa_id" field.
  37290. func (m *WhatsappMutation) SetWaID(s string) {
  37291. m.wa_id = &s
  37292. }
  37293. // WaID returns the value of the "wa_id" field in the mutation.
  37294. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  37295. v := m.wa_id
  37296. if v == nil {
  37297. return
  37298. }
  37299. return *v, true
  37300. }
  37301. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  37302. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37304. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  37305. if !m.op.Is(OpUpdateOne) {
  37306. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  37307. }
  37308. if m.id == nil || m.oldValue == nil {
  37309. return v, errors.New("OldWaID requires an ID field in the mutation")
  37310. }
  37311. oldValue, err := m.oldValue(ctx)
  37312. if err != nil {
  37313. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  37314. }
  37315. return oldValue.WaID, nil
  37316. }
  37317. // ClearWaID clears the value of the "wa_id" field.
  37318. func (m *WhatsappMutation) ClearWaID() {
  37319. m.wa_id = nil
  37320. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  37321. }
  37322. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  37323. func (m *WhatsappMutation) WaIDCleared() bool {
  37324. _, ok := m.clearedFields[whatsapp.FieldWaID]
  37325. return ok
  37326. }
  37327. // ResetWaID resets all changes to the "wa_id" field.
  37328. func (m *WhatsappMutation) ResetWaID() {
  37329. m.wa_id = nil
  37330. delete(m.clearedFields, whatsapp.FieldWaID)
  37331. }
  37332. // SetWaName sets the "wa_name" field.
  37333. func (m *WhatsappMutation) SetWaName(s string) {
  37334. m.wa_name = &s
  37335. }
  37336. // WaName returns the value of the "wa_name" field in the mutation.
  37337. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  37338. v := m.wa_name
  37339. if v == nil {
  37340. return
  37341. }
  37342. return *v, true
  37343. }
  37344. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  37345. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37347. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  37348. if !m.op.Is(OpUpdateOne) {
  37349. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  37350. }
  37351. if m.id == nil || m.oldValue == nil {
  37352. return v, errors.New("OldWaName requires an ID field in the mutation")
  37353. }
  37354. oldValue, err := m.oldValue(ctx)
  37355. if err != nil {
  37356. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  37357. }
  37358. return oldValue.WaName, nil
  37359. }
  37360. // ClearWaName clears the value of the "wa_name" field.
  37361. func (m *WhatsappMutation) ClearWaName() {
  37362. m.wa_name = nil
  37363. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  37364. }
  37365. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  37366. func (m *WhatsappMutation) WaNameCleared() bool {
  37367. _, ok := m.clearedFields[whatsapp.FieldWaName]
  37368. return ok
  37369. }
  37370. // ResetWaName resets all changes to the "wa_name" field.
  37371. func (m *WhatsappMutation) ResetWaName() {
  37372. m.wa_name = nil
  37373. delete(m.clearedFields, whatsapp.FieldWaName)
  37374. }
  37375. // SetCallback sets the "callback" field.
  37376. func (m *WhatsappMutation) SetCallback(s string) {
  37377. m.callback = &s
  37378. }
  37379. // Callback returns the value of the "callback" field in the mutation.
  37380. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  37381. v := m.callback
  37382. if v == nil {
  37383. return
  37384. }
  37385. return *v, true
  37386. }
  37387. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  37388. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37390. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  37391. if !m.op.Is(OpUpdateOne) {
  37392. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  37393. }
  37394. if m.id == nil || m.oldValue == nil {
  37395. return v, errors.New("OldCallback requires an ID field in the mutation")
  37396. }
  37397. oldValue, err := m.oldValue(ctx)
  37398. if err != nil {
  37399. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  37400. }
  37401. return oldValue.Callback, nil
  37402. }
  37403. // ClearCallback clears the value of the "callback" field.
  37404. func (m *WhatsappMutation) ClearCallback() {
  37405. m.callback = nil
  37406. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  37407. }
  37408. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  37409. func (m *WhatsappMutation) CallbackCleared() bool {
  37410. _, ok := m.clearedFields[whatsapp.FieldCallback]
  37411. return ok
  37412. }
  37413. // ResetCallback resets all changes to the "callback" field.
  37414. func (m *WhatsappMutation) ResetCallback() {
  37415. m.callback = nil
  37416. delete(m.clearedFields, whatsapp.FieldCallback)
  37417. }
  37418. // SetAgentID sets the "agent_id" field.
  37419. func (m *WhatsappMutation) SetAgentID(u uint64) {
  37420. m.agent = &u
  37421. }
  37422. // AgentID returns the value of the "agent_id" field in the mutation.
  37423. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  37424. v := m.agent
  37425. if v == nil {
  37426. return
  37427. }
  37428. return *v, true
  37429. }
  37430. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  37431. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37433. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  37434. if !m.op.Is(OpUpdateOne) {
  37435. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  37436. }
  37437. if m.id == nil || m.oldValue == nil {
  37438. return v, errors.New("OldAgentID requires an ID field in the mutation")
  37439. }
  37440. oldValue, err := m.oldValue(ctx)
  37441. if err != nil {
  37442. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  37443. }
  37444. return oldValue.AgentID, nil
  37445. }
  37446. // ResetAgentID resets all changes to the "agent_id" field.
  37447. func (m *WhatsappMutation) ResetAgentID() {
  37448. m.agent = nil
  37449. }
  37450. // SetAccount sets the "account" field.
  37451. func (m *WhatsappMutation) SetAccount(s string) {
  37452. m.account = &s
  37453. }
  37454. // Account returns the value of the "account" field in the mutation.
  37455. func (m *WhatsappMutation) Account() (r string, exists bool) {
  37456. v := m.account
  37457. if v == nil {
  37458. return
  37459. }
  37460. return *v, true
  37461. }
  37462. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  37463. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37465. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  37466. if !m.op.Is(OpUpdateOne) {
  37467. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  37468. }
  37469. if m.id == nil || m.oldValue == nil {
  37470. return v, errors.New("OldAccount requires an ID field in the mutation")
  37471. }
  37472. oldValue, err := m.oldValue(ctx)
  37473. if err != nil {
  37474. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  37475. }
  37476. return oldValue.Account, nil
  37477. }
  37478. // ClearAccount clears the value of the "account" field.
  37479. func (m *WhatsappMutation) ClearAccount() {
  37480. m.account = nil
  37481. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  37482. }
  37483. // AccountCleared returns if the "account" field was cleared in this mutation.
  37484. func (m *WhatsappMutation) AccountCleared() bool {
  37485. _, ok := m.clearedFields[whatsapp.FieldAccount]
  37486. return ok
  37487. }
  37488. // ResetAccount resets all changes to the "account" field.
  37489. func (m *WhatsappMutation) ResetAccount() {
  37490. m.account = nil
  37491. delete(m.clearedFields, whatsapp.FieldAccount)
  37492. }
  37493. // SetCc sets the "cc" field.
  37494. func (m *WhatsappMutation) SetCc(s string) {
  37495. m.cc = &s
  37496. }
  37497. // Cc returns the value of the "cc" field in the mutation.
  37498. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  37499. v := m.cc
  37500. if v == nil {
  37501. return
  37502. }
  37503. return *v, true
  37504. }
  37505. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  37506. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37508. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  37509. if !m.op.Is(OpUpdateOne) {
  37510. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  37511. }
  37512. if m.id == nil || m.oldValue == nil {
  37513. return v, errors.New("OldCc requires an ID field in the mutation")
  37514. }
  37515. oldValue, err := m.oldValue(ctx)
  37516. if err != nil {
  37517. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  37518. }
  37519. return oldValue.Cc, nil
  37520. }
  37521. // ResetCc resets all changes to the "cc" field.
  37522. func (m *WhatsappMutation) ResetCc() {
  37523. m.cc = nil
  37524. }
  37525. // SetPhone sets the "phone" field.
  37526. func (m *WhatsappMutation) SetPhone(s string) {
  37527. m.phone = &s
  37528. }
  37529. // Phone returns the value of the "phone" field in the mutation.
  37530. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  37531. v := m.phone
  37532. if v == nil {
  37533. return
  37534. }
  37535. return *v, true
  37536. }
  37537. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  37538. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37540. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  37541. if !m.op.Is(OpUpdateOne) {
  37542. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  37543. }
  37544. if m.id == nil || m.oldValue == nil {
  37545. return v, errors.New("OldPhone requires an ID field in the mutation")
  37546. }
  37547. oldValue, err := m.oldValue(ctx)
  37548. if err != nil {
  37549. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  37550. }
  37551. return oldValue.Phone, nil
  37552. }
  37553. // ResetPhone resets all changes to the "phone" field.
  37554. func (m *WhatsappMutation) ResetPhone() {
  37555. m.phone = nil
  37556. }
  37557. // SetCcPhone sets the "cc_phone" field.
  37558. func (m *WhatsappMutation) SetCcPhone(s string) {
  37559. m.cc_phone = &s
  37560. }
  37561. // CcPhone returns the value of the "cc_phone" field in the mutation.
  37562. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  37563. v := m.cc_phone
  37564. if v == nil {
  37565. return
  37566. }
  37567. return *v, true
  37568. }
  37569. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  37570. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37572. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  37573. if !m.op.Is(OpUpdateOne) {
  37574. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  37575. }
  37576. if m.id == nil || m.oldValue == nil {
  37577. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  37578. }
  37579. oldValue, err := m.oldValue(ctx)
  37580. if err != nil {
  37581. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  37582. }
  37583. return oldValue.CcPhone, nil
  37584. }
  37585. // ResetCcPhone resets all changes to the "cc_phone" field.
  37586. func (m *WhatsappMutation) ResetCcPhone() {
  37587. m.cc_phone = nil
  37588. }
  37589. // SetPhoneName sets the "phone_name" field.
  37590. func (m *WhatsappMutation) SetPhoneName(s string) {
  37591. m.phone_name = &s
  37592. }
  37593. // PhoneName returns the value of the "phone_name" field in the mutation.
  37594. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  37595. v := m.phone_name
  37596. if v == nil {
  37597. return
  37598. }
  37599. return *v, true
  37600. }
  37601. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  37602. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37604. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  37605. if !m.op.Is(OpUpdateOne) {
  37606. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  37607. }
  37608. if m.id == nil || m.oldValue == nil {
  37609. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  37610. }
  37611. oldValue, err := m.oldValue(ctx)
  37612. if err != nil {
  37613. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  37614. }
  37615. return oldValue.PhoneName, nil
  37616. }
  37617. // ResetPhoneName resets all changes to the "phone_name" field.
  37618. func (m *WhatsappMutation) ResetPhoneName() {
  37619. m.phone_name = nil
  37620. }
  37621. // SetPhoneStatus sets the "phone_status" field.
  37622. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  37623. m.phone_status = &i
  37624. m.addphone_status = nil
  37625. }
  37626. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  37627. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  37628. v := m.phone_status
  37629. if v == nil {
  37630. return
  37631. }
  37632. return *v, true
  37633. }
  37634. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  37635. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37637. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  37638. if !m.op.Is(OpUpdateOne) {
  37639. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  37640. }
  37641. if m.id == nil || m.oldValue == nil {
  37642. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  37643. }
  37644. oldValue, err := m.oldValue(ctx)
  37645. if err != nil {
  37646. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  37647. }
  37648. return oldValue.PhoneStatus, nil
  37649. }
  37650. // AddPhoneStatus adds i to the "phone_status" field.
  37651. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  37652. if m.addphone_status != nil {
  37653. *m.addphone_status += i
  37654. } else {
  37655. m.addphone_status = &i
  37656. }
  37657. }
  37658. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  37659. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  37660. v := m.addphone_status
  37661. if v == nil {
  37662. return
  37663. }
  37664. return *v, true
  37665. }
  37666. // ResetPhoneStatus resets all changes to the "phone_status" field.
  37667. func (m *WhatsappMutation) ResetPhoneStatus() {
  37668. m.phone_status = nil
  37669. m.addphone_status = nil
  37670. }
  37671. // SetOrganizationID sets the "organization_id" field.
  37672. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  37673. m.organization_id = &u
  37674. m.addorganization_id = nil
  37675. }
  37676. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37677. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  37678. v := m.organization_id
  37679. if v == nil {
  37680. return
  37681. }
  37682. return *v, true
  37683. }
  37684. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  37685. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37687. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37688. if !m.op.Is(OpUpdateOne) {
  37689. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37690. }
  37691. if m.id == nil || m.oldValue == nil {
  37692. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37693. }
  37694. oldValue, err := m.oldValue(ctx)
  37695. if err != nil {
  37696. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37697. }
  37698. return oldValue.OrganizationID, nil
  37699. }
  37700. // AddOrganizationID adds u to the "organization_id" field.
  37701. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  37702. if m.addorganization_id != nil {
  37703. *m.addorganization_id += u
  37704. } else {
  37705. m.addorganization_id = &u
  37706. }
  37707. }
  37708. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37709. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  37710. v := m.addorganization_id
  37711. if v == nil {
  37712. return
  37713. }
  37714. return *v, true
  37715. }
  37716. // ClearOrganizationID clears the value of the "organization_id" field.
  37717. func (m *WhatsappMutation) ClearOrganizationID() {
  37718. m.organization_id = nil
  37719. m.addorganization_id = nil
  37720. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  37721. }
  37722. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37723. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  37724. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  37725. return ok
  37726. }
  37727. // ResetOrganizationID resets all changes to the "organization_id" field.
  37728. func (m *WhatsappMutation) ResetOrganizationID() {
  37729. m.organization_id = nil
  37730. m.addorganization_id = nil
  37731. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  37732. }
  37733. // SetAPIBase sets the "api_base" field.
  37734. func (m *WhatsappMutation) SetAPIBase(s string) {
  37735. m.api_base = &s
  37736. }
  37737. // APIBase returns the value of the "api_base" field in the mutation.
  37738. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  37739. v := m.api_base
  37740. if v == nil {
  37741. return
  37742. }
  37743. return *v, true
  37744. }
  37745. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  37746. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37748. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  37749. if !m.op.Is(OpUpdateOne) {
  37750. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  37751. }
  37752. if m.id == nil || m.oldValue == nil {
  37753. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  37754. }
  37755. oldValue, err := m.oldValue(ctx)
  37756. if err != nil {
  37757. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  37758. }
  37759. return oldValue.APIBase, nil
  37760. }
  37761. // ClearAPIBase clears the value of the "api_base" field.
  37762. func (m *WhatsappMutation) ClearAPIBase() {
  37763. m.api_base = nil
  37764. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  37765. }
  37766. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  37767. func (m *WhatsappMutation) APIBaseCleared() bool {
  37768. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  37769. return ok
  37770. }
  37771. // ResetAPIBase resets all changes to the "api_base" field.
  37772. func (m *WhatsappMutation) ResetAPIBase() {
  37773. m.api_base = nil
  37774. delete(m.clearedFields, whatsapp.FieldAPIBase)
  37775. }
  37776. // SetAPIKey sets the "api_key" field.
  37777. func (m *WhatsappMutation) SetAPIKey(s string) {
  37778. m.api_key = &s
  37779. }
  37780. // APIKey returns the value of the "api_key" field in the mutation.
  37781. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  37782. v := m.api_key
  37783. if v == nil {
  37784. return
  37785. }
  37786. return *v, true
  37787. }
  37788. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  37789. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37791. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  37792. if !m.op.Is(OpUpdateOne) {
  37793. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  37794. }
  37795. if m.id == nil || m.oldValue == nil {
  37796. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  37797. }
  37798. oldValue, err := m.oldValue(ctx)
  37799. if err != nil {
  37800. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  37801. }
  37802. return oldValue.APIKey, nil
  37803. }
  37804. // ClearAPIKey clears the value of the "api_key" field.
  37805. func (m *WhatsappMutation) ClearAPIKey() {
  37806. m.api_key = nil
  37807. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  37808. }
  37809. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  37810. func (m *WhatsappMutation) APIKeyCleared() bool {
  37811. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  37812. return ok
  37813. }
  37814. // ResetAPIKey resets all changes to the "api_key" field.
  37815. func (m *WhatsappMutation) ResetAPIKey() {
  37816. m.api_key = nil
  37817. delete(m.clearedFields, whatsapp.FieldAPIKey)
  37818. }
  37819. // SetAllowList sets the "allow_list" field.
  37820. func (m *WhatsappMutation) SetAllowList(s []string) {
  37821. m.allow_list = &s
  37822. m.appendallow_list = nil
  37823. }
  37824. // AllowList returns the value of the "allow_list" field in the mutation.
  37825. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  37826. v := m.allow_list
  37827. if v == nil {
  37828. return
  37829. }
  37830. return *v, true
  37831. }
  37832. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  37833. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37835. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  37836. if !m.op.Is(OpUpdateOne) {
  37837. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  37838. }
  37839. if m.id == nil || m.oldValue == nil {
  37840. return v, errors.New("OldAllowList requires an ID field in the mutation")
  37841. }
  37842. oldValue, err := m.oldValue(ctx)
  37843. if err != nil {
  37844. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  37845. }
  37846. return oldValue.AllowList, nil
  37847. }
  37848. // AppendAllowList adds s to the "allow_list" field.
  37849. func (m *WhatsappMutation) AppendAllowList(s []string) {
  37850. m.appendallow_list = append(m.appendallow_list, s...)
  37851. }
  37852. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  37853. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  37854. if len(m.appendallow_list) == 0 {
  37855. return nil, false
  37856. }
  37857. return m.appendallow_list, true
  37858. }
  37859. // ClearAllowList clears the value of the "allow_list" field.
  37860. func (m *WhatsappMutation) ClearAllowList() {
  37861. m.allow_list = nil
  37862. m.appendallow_list = nil
  37863. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  37864. }
  37865. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  37866. func (m *WhatsappMutation) AllowListCleared() bool {
  37867. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  37868. return ok
  37869. }
  37870. // ResetAllowList resets all changes to the "allow_list" field.
  37871. func (m *WhatsappMutation) ResetAllowList() {
  37872. m.allow_list = nil
  37873. m.appendallow_list = nil
  37874. delete(m.clearedFields, whatsapp.FieldAllowList)
  37875. }
  37876. // SetGroupAllowList sets the "group_allow_list" field.
  37877. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  37878. m.group_allow_list = &s
  37879. m.appendgroup_allow_list = nil
  37880. }
  37881. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  37882. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  37883. v := m.group_allow_list
  37884. if v == nil {
  37885. return
  37886. }
  37887. return *v, true
  37888. }
  37889. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  37890. // If the Whatsapp 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 *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  37893. if !m.op.Is(OpUpdateOne) {
  37894. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  37895. }
  37896. if m.id == nil || m.oldValue == nil {
  37897. return v, errors.New("OldGroupAllowList 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 OldGroupAllowList: %w", err)
  37902. }
  37903. return oldValue.GroupAllowList, nil
  37904. }
  37905. // AppendGroupAllowList adds s to the "group_allow_list" field.
  37906. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  37907. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  37908. }
  37909. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  37910. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  37911. if len(m.appendgroup_allow_list) == 0 {
  37912. return nil, false
  37913. }
  37914. return m.appendgroup_allow_list, true
  37915. }
  37916. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  37917. func (m *WhatsappMutation) ClearGroupAllowList() {
  37918. m.group_allow_list = nil
  37919. m.appendgroup_allow_list = nil
  37920. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  37921. }
  37922. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  37923. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  37924. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  37925. return ok
  37926. }
  37927. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  37928. func (m *WhatsappMutation) ResetGroupAllowList() {
  37929. m.group_allow_list = nil
  37930. m.appendgroup_allow_list = nil
  37931. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  37932. }
  37933. // SetBlockList sets the "block_list" field.
  37934. func (m *WhatsappMutation) SetBlockList(s []string) {
  37935. m.block_list = &s
  37936. m.appendblock_list = nil
  37937. }
  37938. // BlockList returns the value of the "block_list" field in the mutation.
  37939. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  37940. v := m.block_list
  37941. if v == nil {
  37942. return
  37943. }
  37944. return *v, true
  37945. }
  37946. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  37947. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37949. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  37950. if !m.op.Is(OpUpdateOne) {
  37951. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  37952. }
  37953. if m.id == nil || m.oldValue == nil {
  37954. return v, errors.New("OldBlockList requires an ID field in the mutation")
  37955. }
  37956. oldValue, err := m.oldValue(ctx)
  37957. if err != nil {
  37958. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  37959. }
  37960. return oldValue.BlockList, nil
  37961. }
  37962. // AppendBlockList adds s to the "block_list" field.
  37963. func (m *WhatsappMutation) AppendBlockList(s []string) {
  37964. m.appendblock_list = append(m.appendblock_list, s...)
  37965. }
  37966. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  37967. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  37968. if len(m.appendblock_list) == 0 {
  37969. return nil, false
  37970. }
  37971. return m.appendblock_list, true
  37972. }
  37973. // ClearBlockList clears the value of the "block_list" field.
  37974. func (m *WhatsappMutation) ClearBlockList() {
  37975. m.block_list = nil
  37976. m.appendblock_list = nil
  37977. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  37978. }
  37979. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  37980. func (m *WhatsappMutation) BlockListCleared() bool {
  37981. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  37982. return ok
  37983. }
  37984. // ResetBlockList resets all changes to the "block_list" field.
  37985. func (m *WhatsappMutation) ResetBlockList() {
  37986. m.block_list = nil
  37987. m.appendblock_list = nil
  37988. delete(m.clearedFields, whatsapp.FieldBlockList)
  37989. }
  37990. // SetGroupBlockList sets the "group_block_list" field.
  37991. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  37992. m.group_block_list = &s
  37993. m.appendgroup_block_list = nil
  37994. }
  37995. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  37996. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  37997. v := m.group_block_list
  37998. if v == nil {
  37999. return
  38000. }
  38001. return *v, true
  38002. }
  38003. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  38004. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38006. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  38007. if !m.op.Is(OpUpdateOne) {
  38008. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  38009. }
  38010. if m.id == nil || m.oldValue == nil {
  38011. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  38012. }
  38013. oldValue, err := m.oldValue(ctx)
  38014. if err != nil {
  38015. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  38016. }
  38017. return oldValue.GroupBlockList, nil
  38018. }
  38019. // AppendGroupBlockList adds s to the "group_block_list" field.
  38020. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  38021. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  38022. }
  38023. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  38024. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  38025. if len(m.appendgroup_block_list) == 0 {
  38026. return nil, false
  38027. }
  38028. return m.appendgroup_block_list, true
  38029. }
  38030. // ClearGroupBlockList clears the value of the "group_block_list" field.
  38031. func (m *WhatsappMutation) ClearGroupBlockList() {
  38032. m.group_block_list = nil
  38033. m.appendgroup_block_list = nil
  38034. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  38035. }
  38036. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  38037. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  38038. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  38039. return ok
  38040. }
  38041. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  38042. func (m *WhatsappMutation) ResetGroupBlockList() {
  38043. m.group_block_list = nil
  38044. m.appendgroup_block_list = nil
  38045. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  38046. }
  38047. // ClearAgent clears the "agent" edge to the Agent entity.
  38048. func (m *WhatsappMutation) ClearAgent() {
  38049. m.clearedagent = true
  38050. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  38051. }
  38052. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  38053. func (m *WhatsappMutation) AgentCleared() bool {
  38054. return m.clearedagent
  38055. }
  38056. // AgentIDs returns the "agent" edge IDs in the mutation.
  38057. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38058. // AgentID instead. It exists only for internal usage by the builders.
  38059. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  38060. if id := m.agent; id != nil {
  38061. ids = append(ids, *id)
  38062. }
  38063. return
  38064. }
  38065. // ResetAgent resets all changes to the "agent" edge.
  38066. func (m *WhatsappMutation) ResetAgent() {
  38067. m.agent = nil
  38068. m.clearedagent = false
  38069. }
  38070. // Where appends a list predicates to the WhatsappMutation builder.
  38071. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  38072. m.predicates = append(m.predicates, ps...)
  38073. }
  38074. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  38075. // users can use type-assertion to append predicates that do not depend on any generated package.
  38076. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  38077. p := make([]predicate.Whatsapp, len(ps))
  38078. for i := range ps {
  38079. p[i] = ps[i]
  38080. }
  38081. m.Where(p...)
  38082. }
  38083. // Op returns the operation name.
  38084. func (m *WhatsappMutation) Op() Op {
  38085. return m.op
  38086. }
  38087. // SetOp allows setting the mutation operation.
  38088. func (m *WhatsappMutation) SetOp(op Op) {
  38089. m.op = op
  38090. }
  38091. // Type returns the node type of this mutation (Whatsapp).
  38092. func (m *WhatsappMutation) Type() string {
  38093. return m.typ
  38094. }
  38095. // Fields returns all fields that were changed during this mutation. Note that in
  38096. // order to get all numeric fields that were incremented/decremented, call
  38097. // AddedFields().
  38098. func (m *WhatsappMutation) Fields() []string {
  38099. fields := make([]string, 0, 21)
  38100. if m.created_at != nil {
  38101. fields = append(fields, whatsapp.FieldCreatedAt)
  38102. }
  38103. if m.updated_at != nil {
  38104. fields = append(fields, whatsapp.FieldUpdatedAt)
  38105. }
  38106. if m.status != nil {
  38107. fields = append(fields, whatsapp.FieldStatus)
  38108. }
  38109. if m.deleted_at != nil {
  38110. fields = append(fields, whatsapp.FieldDeletedAt)
  38111. }
  38112. if m.wa_id != nil {
  38113. fields = append(fields, whatsapp.FieldWaID)
  38114. }
  38115. if m.wa_name != nil {
  38116. fields = append(fields, whatsapp.FieldWaName)
  38117. }
  38118. if m.callback != nil {
  38119. fields = append(fields, whatsapp.FieldCallback)
  38120. }
  38121. if m.agent != nil {
  38122. fields = append(fields, whatsapp.FieldAgentID)
  38123. }
  38124. if m.account != nil {
  38125. fields = append(fields, whatsapp.FieldAccount)
  38126. }
  38127. if m.cc != nil {
  38128. fields = append(fields, whatsapp.FieldCc)
  38129. }
  38130. if m.phone != nil {
  38131. fields = append(fields, whatsapp.FieldPhone)
  38132. }
  38133. if m.cc_phone != nil {
  38134. fields = append(fields, whatsapp.FieldCcPhone)
  38135. }
  38136. if m.phone_name != nil {
  38137. fields = append(fields, whatsapp.FieldPhoneName)
  38138. }
  38139. if m.phone_status != nil {
  38140. fields = append(fields, whatsapp.FieldPhoneStatus)
  38141. }
  38142. if m.organization_id != nil {
  38143. fields = append(fields, whatsapp.FieldOrganizationID)
  38144. }
  38145. if m.api_base != nil {
  38146. fields = append(fields, whatsapp.FieldAPIBase)
  38147. }
  38148. if m.api_key != nil {
  38149. fields = append(fields, whatsapp.FieldAPIKey)
  38150. }
  38151. if m.allow_list != nil {
  38152. fields = append(fields, whatsapp.FieldAllowList)
  38153. }
  38154. if m.group_allow_list != nil {
  38155. fields = append(fields, whatsapp.FieldGroupAllowList)
  38156. }
  38157. if m.block_list != nil {
  38158. fields = append(fields, whatsapp.FieldBlockList)
  38159. }
  38160. if m.group_block_list != nil {
  38161. fields = append(fields, whatsapp.FieldGroupBlockList)
  38162. }
  38163. return fields
  38164. }
  38165. // Field returns the value of a field with the given name. The second boolean
  38166. // return value indicates that this field was not set, or was not defined in the
  38167. // schema.
  38168. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  38169. switch name {
  38170. case whatsapp.FieldCreatedAt:
  38171. return m.CreatedAt()
  38172. case whatsapp.FieldUpdatedAt:
  38173. return m.UpdatedAt()
  38174. case whatsapp.FieldStatus:
  38175. return m.Status()
  38176. case whatsapp.FieldDeletedAt:
  38177. return m.DeletedAt()
  38178. case whatsapp.FieldWaID:
  38179. return m.WaID()
  38180. case whatsapp.FieldWaName:
  38181. return m.WaName()
  38182. case whatsapp.FieldCallback:
  38183. return m.Callback()
  38184. case whatsapp.FieldAgentID:
  38185. return m.AgentID()
  38186. case whatsapp.FieldAccount:
  38187. return m.Account()
  38188. case whatsapp.FieldCc:
  38189. return m.Cc()
  38190. case whatsapp.FieldPhone:
  38191. return m.Phone()
  38192. case whatsapp.FieldCcPhone:
  38193. return m.CcPhone()
  38194. case whatsapp.FieldPhoneName:
  38195. return m.PhoneName()
  38196. case whatsapp.FieldPhoneStatus:
  38197. return m.PhoneStatus()
  38198. case whatsapp.FieldOrganizationID:
  38199. return m.OrganizationID()
  38200. case whatsapp.FieldAPIBase:
  38201. return m.APIBase()
  38202. case whatsapp.FieldAPIKey:
  38203. return m.APIKey()
  38204. case whatsapp.FieldAllowList:
  38205. return m.AllowList()
  38206. case whatsapp.FieldGroupAllowList:
  38207. return m.GroupAllowList()
  38208. case whatsapp.FieldBlockList:
  38209. return m.BlockList()
  38210. case whatsapp.FieldGroupBlockList:
  38211. return m.GroupBlockList()
  38212. }
  38213. return nil, false
  38214. }
  38215. // OldField returns the old value of the field from the database. An error is
  38216. // returned if the mutation operation is not UpdateOne, or the query to the
  38217. // database failed.
  38218. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38219. switch name {
  38220. case whatsapp.FieldCreatedAt:
  38221. return m.OldCreatedAt(ctx)
  38222. case whatsapp.FieldUpdatedAt:
  38223. return m.OldUpdatedAt(ctx)
  38224. case whatsapp.FieldStatus:
  38225. return m.OldStatus(ctx)
  38226. case whatsapp.FieldDeletedAt:
  38227. return m.OldDeletedAt(ctx)
  38228. case whatsapp.FieldWaID:
  38229. return m.OldWaID(ctx)
  38230. case whatsapp.FieldWaName:
  38231. return m.OldWaName(ctx)
  38232. case whatsapp.FieldCallback:
  38233. return m.OldCallback(ctx)
  38234. case whatsapp.FieldAgentID:
  38235. return m.OldAgentID(ctx)
  38236. case whatsapp.FieldAccount:
  38237. return m.OldAccount(ctx)
  38238. case whatsapp.FieldCc:
  38239. return m.OldCc(ctx)
  38240. case whatsapp.FieldPhone:
  38241. return m.OldPhone(ctx)
  38242. case whatsapp.FieldCcPhone:
  38243. return m.OldCcPhone(ctx)
  38244. case whatsapp.FieldPhoneName:
  38245. return m.OldPhoneName(ctx)
  38246. case whatsapp.FieldPhoneStatus:
  38247. return m.OldPhoneStatus(ctx)
  38248. case whatsapp.FieldOrganizationID:
  38249. return m.OldOrganizationID(ctx)
  38250. case whatsapp.FieldAPIBase:
  38251. return m.OldAPIBase(ctx)
  38252. case whatsapp.FieldAPIKey:
  38253. return m.OldAPIKey(ctx)
  38254. case whatsapp.FieldAllowList:
  38255. return m.OldAllowList(ctx)
  38256. case whatsapp.FieldGroupAllowList:
  38257. return m.OldGroupAllowList(ctx)
  38258. case whatsapp.FieldBlockList:
  38259. return m.OldBlockList(ctx)
  38260. case whatsapp.FieldGroupBlockList:
  38261. return m.OldGroupBlockList(ctx)
  38262. }
  38263. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  38264. }
  38265. // SetField sets the value of a field with the given name. It returns an error if
  38266. // the field is not defined in the schema, or if the type mismatched the field
  38267. // type.
  38268. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  38269. switch name {
  38270. case whatsapp.FieldCreatedAt:
  38271. v, ok := value.(time.Time)
  38272. if !ok {
  38273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38274. }
  38275. m.SetCreatedAt(v)
  38276. return nil
  38277. case whatsapp.FieldUpdatedAt:
  38278. v, ok := value.(time.Time)
  38279. if !ok {
  38280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38281. }
  38282. m.SetUpdatedAt(v)
  38283. return nil
  38284. case whatsapp.FieldStatus:
  38285. v, ok := value.(uint8)
  38286. if !ok {
  38287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38288. }
  38289. m.SetStatus(v)
  38290. return nil
  38291. case whatsapp.FieldDeletedAt:
  38292. v, ok := value.(time.Time)
  38293. if !ok {
  38294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38295. }
  38296. m.SetDeletedAt(v)
  38297. return nil
  38298. case whatsapp.FieldWaID:
  38299. v, ok := value.(string)
  38300. if !ok {
  38301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38302. }
  38303. m.SetWaID(v)
  38304. return nil
  38305. case whatsapp.FieldWaName:
  38306. v, ok := value.(string)
  38307. if !ok {
  38308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38309. }
  38310. m.SetWaName(v)
  38311. return nil
  38312. case whatsapp.FieldCallback:
  38313. v, ok := value.(string)
  38314. if !ok {
  38315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38316. }
  38317. m.SetCallback(v)
  38318. return nil
  38319. case whatsapp.FieldAgentID:
  38320. v, ok := value.(uint64)
  38321. if !ok {
  38322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38323. }
  38324. m.SetAgentID(v)
  38325. return nil
  38326. case whatsapp.FieldAccount:
  38327. v, ok := value.(string)
  38328. if !ok {
  38329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38330. }
  38331. m.SetAccount(v)
  38332. return nil
  38333. case whatsapp.FieldCc:
  38334. v, ok := value.(string)
  38335. if !ok {
  38336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38337. }
  38338. m.SetCc(v)
  38339. return nil
  38340. case whatsapp.FieldPhone:
  38341. v, ok := value.(string)
  38342. if !ok {
  38343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38344. }
  38345. m.SetPhone(v)
  38346. return nil
  38347. case whatsapp.FieldCcPhone:
  38348. v, ok := value.(string)
  38349. if !ok {
  38350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38351. }
  38352. m.SetCcPhone(v)
  38353. return nil
  38354. case whatsapp.FieldPhoneName:
  38355. v, ok := value.(string)
  38356. if !ok {
  38357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38358. }
  38359. m.SetPhoneName(v)
  38360. return nil
  38361. case whatsapp.FieldPhoneStatus:
  38362. v, ok := value.(int8)
  38363. if !ok {
  38364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38365. }
  38366. m.SetPhoneStatus(v)
  38367. return nil
  38368. case whatsapp.FieldOrganizationID:
  38369. v, ok := value.(uint64)
  38370. if !ok {
  38371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38372. }
  38373. m.SetOrganizationID(v)
  38374. return nil
  38375. case whatsapp.FieldAPIBase:
  38376. v, ok := value.(string)
  38377. if !ok {
  38378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38379. }
  38380. m.SetAPIBase(v)
  38381. return nil
  38382. case whatsapp.FieldAPIKey:
  38383. v, ok := value.(string)
  38384. if !ok {
  38385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38386. }
  38387. m.SetAPIKey(v)
  38388. return nil
  38389. case whatsapp.FieldAllowList:
  38390. v, ok := value.([]string)
  38391. if !ok {
  38392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38393. }
  38394. m.SetAllowList(v)
  38395. return nil
  38396. case whatsapp.FieldGroupAllowList:
  38397. v, ok := value.([]string)
  38398. if !ok {
  38399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38400. }
  38401. m.SetGroupAllowList(v)
  38402. return nil
  38403. case whatsapp.FieldBlockList:
  38404. v, ok := value.([]string)
  38405. if !ok {
  38406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38407. }
  38408. m.SetBlockList(v)
  38409. return nil
  38410. case whatsapp.FieldGroupBlockList:
  38411. v, ok := value.([]string)
  38412. if !ok {
  38413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38414. }
  38415. m.SetGroupBlockList(v)
  38416. return nil
  38417. }
  38418. return fmt.Errorf("unknown Whatsapp field %s", name)
  38419. }
  38420. // AddedFields returns all numeric fields that were incremented/decremented during
  38421. // this mutation.
  38422. func (m *WhatsappMutation) AddedFields() []string {
  38423. var fields []string
  38424. if m.addstatus != nil {
  38425. fields = append(fields, whatsapp.FieldStatus)
  38426. }
  38427. if m.addphone_status != nil {
  38428. fields = append(fields, whatsapp.FieldPhoneStatus)
  38429. }
  38430. if m.addorganization_id != nil {
  38431. fields = append(fields, whatsapp.FieldOrganizationID)
  38432. }
  38433. return fields
  38434. }
  38435. // AddedField returns the numeric value that was incremented/decremented on a field
  38436. // with the given name. The second boolean return value indicates that this field
  38437. // was not set, or was not defined in the schema.
  38438. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  38439. switch name {
  38440. case whatsapp.FieldStatus:
  38441. return m.AddedStatus()
  38442. case whatsapp.FieldPhoneStatus:
  38443. return m.AddedPhoneStatus()
  38444. case whatsapp.FieldOrganizationID:
  38445. return m.AddedOrganizationID()
  38446. }
  38447. return nil, false
  38448. }
  38449. // AddField adds the value to the field with the given name. It returns an error if
  38450. // the field is not defined in the schema, or if the type mismatched the field
  38451. // type.
  38452. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  38453. switch name {
  38454. case whatsapp.FieldStatus:
  38455. v, ok := value.(int8)
  38456. if !ok {
  38457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38458. }
  38459. m.AddStatus(v)
  38460. return nil
  38461. case whatsapp.FieldPhoneStatus:
  38462. v, ok := value.(int8)
  38463. if !ok {
  38464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38465. }
  38466. m.AddPhoneStatus(v)
  38467. return nil
  38468. case whatsapp.FieldOrganizationID:
  38469. v, ok := value.(int64)
  38470. if !ok {
  38471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38472. }
  38473. m.AddOrganizationID(v)
  38474. return nil
  38475. }
  38476. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  38477. }
  38478. // ClearedFields returns all nullable fields that were cleared during this
  38479. // mutation.
  38480. func (m *WhatsappMutation) ClearedFields() []string {
  38481. var fields []string
  38482. if m.FieldCleared(whatsapp.FieldStatus) {
  38483. fields = append(fields, whatsapp.FieldStatus)
  38484. }
  38485. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  38486. fields = append(fields, whatsapp.FieldDeletedAt)
  38487. }
  38488. if m.FieldCleared(whatsapp.FieldWaID) {
  38489. fields = append(fields, whatsapp.FieldWaID)
  38490. }
  38491. if m.FieldCleared(whatsapp.FieldWaName) {
  38492. fields = append(fields, whatsapp.FieldWaName)
  38493. }
  38494. if m.FieldCleared(whatsapp.FieldCallback) {
  38495. fields = append(fields, whatsapp.FieldCallback)
  38496. }
  38497. if m.FieldCleared(whatsapp.FieldAccount) {
  38498. fields = append(fields, whatsapp.FieldAccount)
  38499. }
  38500. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  38501. fields = append(fields, whatsapp.FieldOrganizationID)
  38502. }
  38503. if m.FieldCleared(whatsapp.FieldAPIBase) {
  38504. fields = append(fields, whatsapp.FieldAPIBase)
  38505. }
  38506. if m.FieldCleared(whatsapp.FieldAPIKey) {
  38507. fields = append(fields, whatsapp.FieldAPIKey)
  38508. }
  38509. if m.FieldCleared(whatsapp.FieldAllowList) {
  38510. fields = append(fields, whatsapp.FieldAllowList)
  38511. }
  38512. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  38513. fields = append(fields, whatsapp.FieldGroupAllowList)
  38514. }
  38515. if m.FieldCleared(whatsapp.FieldBlockList) {
  38516. fields = append(fields, whatsapp.FieldBlockList)
  38517. }
  38518. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  38519. fields = append(fields, whatsapp.FieldGroupBlockList)
  38520. }
  38521. return fields
  38522. }
  38523. // FieldCleared returns a boolean indicating if a field with the given name was
  38524. // cleared in this mutation.
  38525. func (m *WhatsappMutation) FieldCleared(name string) bool {
  38526. _, ok := m.clearedFields[name]
  38527. return ok
  38528. }
  38529. // ClearField clears the value of the field with the given name. It returns an
  38530. // error if the field is not defined in the schema.
  38531. func (m *WhatsappMutation) ClearField(name string) error {
  38532. switch name {
  38533. case whatsapp.FieldStatus:
  38534. m.ClearStatus()
  38535. return nil
  38536. case whatsapp.FieldDeletedAt:
  38537. m.ClearDeletedAt()
  38538. return nil
  38539. case whatsapp.FieldWaID:
  38540. m.ClearWaID()
  38541. return nil
  38542. case whatsapp.FieldWaName:
  38543. m.ClearWaName()
  38544. return nil
  38545. case whatsapp.FieldCallback:
  38546. m.ClearCallback()
  38547. return nil
  38548. case whatsapp.FieldAccount:
  38549. m.ClearAccount()
  38550. return nil
  38551. case whatsapp.FieldOrganizationID:
  38552. m.ClearOrganizationID()
  38553. return nil
  38554. case whatsapp.FieldAPIBase:
  38555. m.ClearAPIBase()
  38556. return nil
  38557. case whatsapp.FieldAPIKey:
  38558. m.ClearAPIKey()
  38559. return nil
  38560. case whatsapp.FieldAllowList:
  38561. m.ClearAllowList()
  38562. return nil
  38563. case whatsapp.FieldGroupAllowList:
  38564. m.ClearGroupAllowList()
  38565. return nil
  38566. case whatsapp.FieldBlockList:
  38567. m.ClearBlockList()
  38568. return nil
  38569. case whatsapp.FieldGroupBlockList:
  38570. m.ClearGroupBlockList()
  38571. return nil
  38572. }
  38573. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  38574. }
  38575. // ResetField resets all changes in the mutation for the field with the given name.
  38576. // It returns an error if the field is not defined in the schema.
  38577. func (m *WhatsappMutation) ResetField(name string) error {
  38578. switch name {
  38579. case whatsapp.FieldCreatedAt:
  38580. m.ResetCreatedAt()
  38581. return nil
  38582. case whatsapp.FieldUpdatedAt:
  38583. m.ResetUpdatedAt()
  38584. return nil
  38585. case whatsapp.FieldStatus:
  38586. m.ResetStatus()
  38587. return nil
  38588. case whatsapp.FieldDeletedAt:
  38589. m.ResetDeletedAt()
  38590. return nil
  38591. case whatsapp.FieldWaID:
  38592. m.ResetWaID()
  38593. return nil
  38594. case whatsapp.FieldWaName:
  38595. m.ResetWaName()
  38596. return nil
  38597. case whatsapp.FieldCallback:
  38598. m.ResetCallback()
  38599. return nil
  38600. case whatsapp.FieldAgentID:
  38601. m.ResetAgentID()
  38602. return nil
  38603. case whatsapp.FieldAccount:
  38604. m.ResetAccount()
  38605. return nil
  38606. case whatsapp.FieldCc:
  38607. m.ResetCc()
  38608. return nil
  38609. case whatsapp.FieldPhone:
  38610. m.ResetPhone()
  38611. return nil
  38612. case whatsapp.FieldCcPhone:
  38613. m.ResetCcPhone()
  38614. return nil
  38615. case whatsapp.FieldPhoneName:
  38616. m.ResetPhoneName()
  38617. return nil
  38618. case whatsapp.FieldPhoneStatus:
  38619. m.ResetPhoneStatus()
  38620. return nil
  38621. case whatsapp.FieldOrganizationID:
  38622. m.ResetOrganizationID()
  38623. return nil
  38624. case whatsapp.FieldAPIBase:
  38625. m.ResetAPIBase()
  38626. return nil
  38627. case whatsapp.FieldAPIKey:
  38628. m.ResetAPIKey()
  38629. return nil
  38630. case whatsapp.FieldAllowList:
  38631. m.ResetAllowList()
  38632. return nil
  38633. case whatsapp.FieldGroupAllowList:
  38634. m.ResetGroupAllowList()
  38635. return nil
  38636. case whatsapp.FieldBlockList:
  38637. m.ResetBlockList()
  38638. return nil
  38639. case whatsapp.FieldGroupBlockList:
  38640. m.ResetGroupBlockList()
  38641. return nil
  38642. }
  38643. return fmt.Errorf("unknown Whatsapp field %s", name)
  38644. }
  38645. // AddedEdges returns all edge names that were set/added in this mutation.
  38646. func (m *WhatsappMutation) AddedEdges() []string {
  38647. edges := make([]string, 0, 1)
  38648. if m.agent != nil {
  38649. edges = append(edges, whatsapp.EdgeAgent)
  38650. }
  38651. return edges
  38652. }
  38653. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38654. // name in this mutation.
  38655. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  38656. switch name {
  38657. case whatsapp.EdgeAgent:
  38658. if id := m.agent; id != nil {
  38659. return []ent.Value{*id}
  38660. }
  38661. }
  38662. return nil
  38663. }
  38664. // RemovedEdges returns all edge names that were removed in this mutation.
  38665. func (m *WhatsappMutation) RemovedEdges() []string {
  38666. edges := make([]string, 0, 1)
  38667. return edges
  38668. }
  38669. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38670. // the given name in this mutation.
  38671. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  38672. return nil
  38673. }
  38674. // ClearedEdges returns all edge names that were cleared in this mutation.
  38675. func (m *WhatsappMutation) ClearedEdges() []string {
  38676. edges := make([]string, 0, 1)
  38677. if m.clearedagent {
  38678. edges = append(edges, whatsapp.EdgeAgent)
  38679. }
  38680. return edges
  38681. }
  38682. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38683. // was cleared in this mutation.
  38684. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  38685. switch name {
  38686. case whatsapp.EdgeAgent:
  38687. return m.clearedagent
  38688. }
  38689. return false
  38690. }
  38691. // ClearEdge clears the value of the edge with the given name. It returns an error
  38692. // if that edge is not defined in the schema.
  38693. func (m *WhatsappMutation) ClearEdge(name string) error {
  38694. switch name {
  38695. case whatsapp.EdgeAgent:
  38696. m.ClearAgent()
  38697. return nil
  38698. }
  38699. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  38700. }
  38701. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38702. // It returns an error if the edge is not defined in the schema.
  38703. func (m *WhatsappMutation) ResetEdge(name string) error {
  38704. switch name {
  38705. case whatsapp.EdgeAgent:
  38706. m.ResetAgent()
  38707. return nil
  38708. }
  38709. return fmt.Errorf("unknown Whatsapp edge %s", name)
  38710. }
  38711. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  38712. type WhatsappChannelMutation struct {
  38713. config
  38714. op Op
  38715. typ string
  38716. id *uint64
  38717. created_at *time.Time
  38718. updated_at *time.Time
  38719. status *uint8
  38720. addstatus *int8
  38721. deleted_at *time.Time
  38722. ak *string
  38723. sk *string
  38724. wa_id *string
  38725. wa_name *string
  38726. waba_id *uint64
  38727. addwaba_id *int64
  38728. business_id *uint64
  38729. addbusiness_id *int64
  38730. organization_id *uint64
  38731. addorganization_id *int64
  38732. verify_account *string
  38733. clearedFields map[string]struct{}
  38734. done bool
  38735. oldValue func(context.Context) (*WhatsappChannel, error)
  38736. predicates []predicate.WhatsappChannel
  38737. }
  38738. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  38739. // whatsappchannelOption allows management of the mutation configuration using functional options.
  38740. type whatsappchannelOption func(*WhatsappChannelMutation)
  38741. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  38742. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  38743. m := &WhatsappChannelMutation{
  38744. config: c,
  38745. op: op,
  38746. typ: TypeWhatsappChannel,
  38747. clearedFields: make(map[string]struct{}),
  38748. }
  38749. for _, opt := range opts {
  38750. opt(m)
  38751. }
  38752. return m
  38753. }
  38754. // withWhatsappChannelID sets the ID field of the mutation.
  38755. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  38756. return func(m *WhatsappChannelMutation) {
  38757. var (
  38758. err error
  38759. once sync.Once
  38760. value *WhatsappChannel
  38761. )
  38762. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  38763. once.Do(func() {
  38764. if m.done {
  38765. err = errors.New("querying old values post mutation is not allowed")
  38766. } else {
  38767. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  38768. }
  38769. })
  38770. return value, err
  38771. }
  38772. m.id = &id
  38773. }
  38774. }
  38775. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  38776. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  38777. return func(m *WhatsappChannelMutation) {
  38778. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  38779. return node, nil
  38780. }
  38781. m.id = &node.ID
  38782. }
  38783. }
  38784. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38785. // executed in a transaction (ent.Tx), a transactional client is returned.
  38786. func (m WhatsappChannelMutation) Client() *Client {
  38787. client := &Client{config: m.config}
  38788. client.init()
  38789. return client
  38790. }
  38791. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38792. // it returns an error otherwise.
  38793. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  38794. if _, ok := m.driver.(*txDriver); !ok {
  38795. return nil, errors.New("ent: mutation is not running in a transaction")
  38796. }
  38797. tx := &Tx{config: m.config}
  38798. tx.init()
  38799. return tx, nil
  38800. }
  38801. // SetID sets the value of the id field. Note that this
  38802. // operation is only accepted on creation of WhatsappChannel entities.
  38803. func (m *WhatsappChannelMutation) SetID(id uint64) {
  38804. m.id = &id
  38805. }
  38806. // ID returns the ID value in the mutation. Note that the ID is only available
  38807. // if it was provided to the builder or after it was returned from the database.
  38808. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  38809. if m.id == nil {
  38810. return
  38811. }
  38812. return *m.id, true
  38813. }
  38814. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38815. // That means, if the mutation is applied within a transaction with an isolation level such
  38816. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38817. // or updated by the mutation.
  38818. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  38819. switch {
  38820. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38821. id, exists := m.ID()
  38822. if exists {
  38823. return []uint64{id}, nil
  38824. }
  38825. fallthrough
  38826. case m.op.Is(OpUpdate | OpDelete):
  38827. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  38828. default:
  38829. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38830. }
  38831. }
  38832. // SetCreatedAt sets the "created_at" field.
  38833. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  38834. m.created_at = &t
  38835. }
  38836. // CreatedAt returns the value of the "created_at" field in the mutation.
  38837. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  38838. v := m.created_at
  38839. if v == nil {
  38840. return
  38841. }
  38842. return *v, true
  38843. }
  38844. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  38845. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38847. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38848. if !m.op.Is(OpUpdateOne) {
  38849. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38850. }
  38851. if m.id == nil || m.oldValue == nil {
  38852. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38853. }
  38854. oldValue, err := m.oldValue(ctx)
  38855. if err != nil {
  38856. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38857. }
  38858. return oldValue.CreatedAt, nil
  38859. }
  38860. // ResetCreatedAt resets all changes to the "created_at" field.
  38861. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  38862. m.created_at = nil
  38863. }
  38864. // SetUpdatedAt sets the "updated_at" field.
  38865. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  38866. m.updated_at = &t
  38867. }
  38868. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38869. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  38870. v := m.updated_at
  38871. if v == nil {
  38872. return
  38873. }
  38874. return *v, true
  38875. }
  38876. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  38877. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38879. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38880. if !m.op.Is(OpUpdateOne) {
  38881. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38882. }
  38883. if m.id == nil || m.oldValue == nil {
  38884. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38885. }
  38886. oldValue, err := m.oldValue(ctx)
  38887. if err != nil {
  38888. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38889. }
  38890. return oldValue.UpdatedAt, nil
  38891. }
  38892. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38893. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  38894. m.updated_at = nil
  38895. }
  38896. // SetStatus sets the "status" field.
  38897. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  38898. m.status = &u
  38899. m.addstatus = nil
  38900. }
  38901. // Status returns the value of the "status" field in the mutation.
  38902. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  38903. v := m.status
  38904. if v == nil {
  38905. return
  38906. }
  38907. return *v, true
  38908. }
  38909. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  38910. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38912. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38913. if !m.op.Is(OpUpdateOne) {
  38914. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38915. }
  38916. if m.id == nil || m.oldValue == nil {
  38917. return v, errors.New("OldStatus requires an ID field in the mutation")
  38918. }
  38919. oldValue, err := m.oldValue(ctx)
  38920. if err != nil {
  38921. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38922. }
  38923. return oldValue.Status, nil
  38924. }
  38925. // AddStatus adds u to the "status" field.
  38926. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  38927. if m.addstatus != nil {
  38928. *m.addstatus += u
  38929. } else {
  38930. m.addstatus = &u
  38931. }
  38932. }
  38933. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38934. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  38935. v := m.addstatus
  38936. if v == nil {
  38937. return
  38938. }
  38939. return *v, true
  38940. }
  38941. // ClearStatus clears the value of the "status" field.
  38942. func (m *WhatsappChannelMutation) ClearStatus() {
  38943. m.status = nil
  38944. m.addstatus = nil
  38945. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  38946. }
  38947. // StatusCleared returns if the "status" field was cleared in this mutation.
  38948. func (m *WhatsappChannelMutation) StatusCleared() bool {
  38949. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  38950. return ok
  38951. }
  38952. // ResetStatus resets all changes to the "status" field.
  38953. func (m *WhatsappChannelMutation) ResetStatus() {
  38954. m.status = nil
  38955. m.addstatus = nil
  38956. delete(m.clearedFields, whatsappchannel.FieldStatus)
  38957. }
  38958. // SetDeletedAt sets the "deleted_at" field.
  38959. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  38960. m.deleted_at = &t
  38961. }
  38962. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38963. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  38964. v := m.deleted_at
  38965. if v == nil {
  38966. return
  38967. }
  38968. return *v, true
  38969. }
  38970. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  38971. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38973. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38974. if !m.op.Is(OpUpdateOne) {
  38975. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38976. }
  38977. if m.id == nil || m.oldValue == nil {
  38978. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38979. }
  38980. oldValue, err := m.oldValue(ctx)
  38981. if err != nil {
  38982. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38983. }
  38984. return oldValue.DeletedAt, nil
  38985. }
  38986. // ClearDeletedAt clears the value of the "deleted_at" field.
  38987. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  38988. m.deleted_at = nil
  38989. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  38990. }
  38991. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38992. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  38993. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  38994. return ok
  38995. }
  38996. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38997. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  38998. m.deleted_at = nil
  38999. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  39000. }
  39001. // SetAk sets the "ak" field.
  39002. func (m *WhatsappChannelMutation) SetAk(s string) {
  39003. m.ak = &s
  39004. }
  39005. // Ak returns the value of the "ak" field in the mutation.
  39006. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  39007. v := m.ak
  39008. if v == nil {
  39009. return
  39010. }
  39011. return *v, true
  39012. }
  39013. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  39014. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39016. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  39017. if !m.op.Is(OpUpdateOne) {
  39018. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  39019. }
  39020. if m.id == nil || m.oldValue == nil {
  39021. return v, errors.New("OldAk requires an ID field in the mutation")
  39022. }
  39023. oldValue, err := m.oldValue(ctx)
  39024. if err != nil {
  39025. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  39026. }
  39027. return oldValue.Ak, nil
  39028. }
  39029. // ClearAk clears the value of the "ak" field.
  39030. func (m *WhatsappChannelMutation) ClearAk() {
  39031. m.ak = nil
  39032. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  39033. }
  39034. // AkCleared returns if the "ak" field was cleared in this mutation.
  39035. func (m *WhatsappChannelMutation) AkCleared() bool {
  39036. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  39037. return ok
  39038. }
  39039. // ResetAk resets all changes to the "ak" field.
  39040. func (m *WhatsappChannelMutation) ResetAk() {
  39041. m.ak = nil
  39042. delete(m.clearedFields, whatsappchannel.FieldAk)
  39043. }
  39044. // SetSk sets the "sk" field.
  39045. func (m *WhatsappChannelMutation) SetSk(s string) {
  39046. m.sk = &s
  39047. }
  39048. // Sk returns the value of the "sk" field in the mutation.
  39049. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  39050. v := m.sk
  39051. if v == nil {
  39052. return
  39053. }
  39054. return *v, true
  39055. }
  39056. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  39057. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39059. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  39060. if !m.op.Is(OpUpdateOne) {
  39061. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  39062. }
  39063. if m.id == nil || m.oldValue == nil {
  39064. return v, errors.New("OldSk requires an ID field in the mutation")
  39065. }
  39066. oldValue, err := m.oldValue(ctx)
  39067. if err != nil {
  39068. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  39069. }
  39070. return oldValue.Sk, nil
  39071. }
  39072. // ResetSk resets all changes to the "sk" field.
  39073. func (m *WhatsappChannelMutation) ResetSk() {
  39074. m.sk = nil
  39075. }
  39076. // SetWaID sets the "wa_id" field.
  39077. func (m *WhatsappChannelMutation) SetWaID(s string) {
  39078. m.wa_id = &s
  39079. }
  39080. // WaID returns the value of the "wa_id" field in the mutation.
  39081. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  39082. v := m.wa_id
  39083. if v == nil {
  39084. return
  39085. }
  39086. return *v, true
  39087. }
  39088. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  39089. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39091. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  39092. if !m.op.Is(OpUpdateOne) {
  39093. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  39094. }
  39095. if m.id == nil || m.oldValue == nil {
  39096. return v, errors.New("OldWaID requires an ID field in the mutation")
  39097. }
  39098. oldValue, err := m.oldValue(ctx)
  39099. if err != nil {
  39100. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  39101. }
  39102. return oldValue.WaID, nil
  39103. }
  39104. // ClearWaID clears the value of the "wa_id" field.
  39105. func (m *WhatsappChannelMutation) ClearWaID() {
  39106. m.wa_id = nil
  39107. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  39108. }
  39109. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  39110. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  39111. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  39112. return ok
  39113. }
  39114. // ResetWaID resets all changes to the "wa_id" field.
  39115. func (m *WhatsappChannelMutation) ResetWaID() {
  39116. m.wa_id = nil
  39117. delete(m.clearedFields, whatsappchannel.FieldWaID)
  39118. }
  39119. // SetWaName sets the "wa_name" field.
  39120. func (m *WhatsappChannelMutation) SetWaName(s string) {
  39121. m.wa_name = &s
  39122. }
  39123. // WaName returns the value of the "wa_name" field in the mutation.
  39124. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  39125. v := m.wa_name
  39126. if v == nil {
  39127. return
  39128. }
  39129. return *v, true
  39130. }
  39131. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  39132. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39134. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  39135. if !m.op.Is(OpUpdateOne) {
  39136. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  39137. }
  39138. if m.id == nil || m.oldValue == nil {
  39139. return v, errors.New("OldWaName requires an ID field in the mutation")
  39140. }
  39141. oldValue, err := m.oldValue(ctx)
  39142. if err != nil {
  39143. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  39144. }
  39145. return oldValue.WaName, nil
  39146. }
  39147. // ClearWaName clears the value of the "wa_name" field.
  39148. func (m *WhatsappChannelMutation) ClearWaName() {
  39149. m.wa_name = nil
  39150. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  39151. }
  39152. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  39153. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  39154. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  39155. return ok
  39156. }
  39157. // ResetWaName resets all changes to the "wa_name" field.
  39158. func (m *WhatsappChannelMutation) ResetWaName() {
  39159. m.wa_name = nil
  39160. delete(m.clearedFields, whatsappchannel.FieldWaName)
  39161. }
  39162. // SetWabaID sets the "waba_id" field.
  39163. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  39164. m.waba_id = &u
  39165. m.addwaba_id = nil
  39166. }
  39167. // WabaID returns the value of the "waba_id" field in the mutation.
  39168. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  39169. v := m.waba_id
  39170. if v == nil {
  39171. return
  39172. }
  39173. return *v, true
  39174. }
  39175. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  39176. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39178. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  39179. if !m.op.Is(OpUpdateOne) {
  39180. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  39181. }
  39182. if m.id == nil || m.oldValue == nil {
  39183. return v, errors.New("OldWabaID requires an ID field in the mutation")
  39184. }
  39185. oldValue, err := m.oldValue(ctx)
  39186. if err != nil {
  39187. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  39188. }
  39189. return oldValue.WabaID, nil
  39190. }
  39191. // AddWabaID adds u to the "waba_id" field.
  39192. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  39193. if m.addwaba_id != nil {
  39194. *m.addwaba_id += u
  39195. } else {
  39196. m.addwaba_id = &u
  39197. }
  39198. }
  39199. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  39200. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  39201. v := m.addwaba_id
  39202. if v == nil {
  39203. return
  39204. }
  39205. return *v, true
  39206. }
  39207. // ResetWabaID resets all changes to the "waba_id" field.
  39208. func (m *WhatsappChannelMutation) ResetWabaID() {
  39209. m.waba_id = nil
  39210. m.addwaba_id = nil
  39211. }
  39212. // SetBusinessID sets the "business_id" field.
  39213. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  39214. m.business_id = &u
  39215. m.addbusiness_id = nil
  39216. }
  39217. // BusinessID returns the value of the "business_id" field in the mutation.
  39218. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  39219. v := m.business_id
  39220. if v == nil {
  39221. return
  39222. }
  39223. return *v, true
  39224. }
  39225. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  39226. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39228. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  39229. if !m.op.Is(OpUpdateOne) {
  39230. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  39231. }
  39232. if m.id == nil || m.oldValue == nil {
  39233. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  39234. }
  39235. oldValue, err := m.oldValue(ctx)
  39236. if err != nil {
  39237. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  39238. }
  39239. return oldValue.BusinessID, nil
  39240. }
  39241. // AddBusinessID adds u to the "business_id" field.
  39242. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  39243. if m.addbusiness_id != nil {
  39244. *m.addbusiness_id += u
  39245. } else {
  39246. m.addbusiness_id = &u
  39247. }
  39248. }
  39249. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  39250. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  39251. v := m.addbusiness_id
  39252. if v == nil {
  39253. return
  39254. }
  39255. return *v, true
  39256. }
  39257. // ResetBusinessID resets all changes to the "business_id" field.
  39258. func (m *WhatsappChannelMutation) ResetBusinessID() {
  39259. m.business_id = nil
  39260. m.addbusiness_id = nil
  39261. }
  39262. // SetOrganizationID sets the "organization_id" field.
  39263. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  39264. m.organization_id = &u
  39265. m.addorganization_id = nil
  39266. }
  39267. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39268. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  39269. v := m.organization_id
  39270. if v == nil {
  39271. return
  39272. }
  39273. return *v, true
  39274. }
  39275. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  39276. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39278. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39279. if !m.op.Is(OpUpdateOne) {
  39280. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39281. }
  39282. if m.id == nil || m.oldValue == nil {
  39283. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39284. }
  39285. oldValue, err := m.oldValue(ctx)
  39286. if err != nil {
  39287. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39288. }
  39289. return oldValue.OrganizationID, nil
  39290. }
  39291. // AddOrganizationID adds u to the "organization_id" field.
  39292. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  39293. if m.addorganization_id != nil {
  39294. *m.addorganization_id += u
  39295. } else {
  39296. m.addorganization_id = &u
  39297. }
  39298. }
  39299. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39300. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  39301. v := m.addorganization_id
  39302. if v == nil {
  39303. return
  39304. }
  39305. return *v, true
  39306. }
  39307. // ClearOrganizationID clears the value of the "organization_id" field.
  39308. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  39309. m.organization_id = nil
  39310. m.addorganization_id = nil
  39311. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  39312. }
  39313. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39314. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  39315. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  39316. return ok
  39317. }
  39318. // ResetOrganizationID resets all changes to the "organization_id" field.
  39319. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  39320. m.organization_id = nil
  39321. m.addorganization_id = nil
  39322. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  39323. }
  39324. // SetVerifyAccount sets the "verify_account" field.
  39325. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  39326. m.verify_account = &s
  39327. }
  39328. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  39329. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  39330. v := m.verify_account
  39331. if v == nil {
  39332. return
  39333. }
  39334. return *v, true
  39335. }
  39336. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  39337. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39339. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  39340. if !m.op.Is(OpUpdateOne) {
  39341. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  39342. }
  39343. if m.id == nil || m.oldValue == nil {
  39344. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  39345. }
  39346. oldValue, err := m.oldValue(ctx)
  39347. if err != nil {
  39348. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  39349. }
  39350. return oldValue.VerifyAccount, nil
  39351. }
  39352. // ResetVerifyAccount resets all changes to the "verify_account" field.
  39353. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  39354. m.verify_account = nil
  39355. }
  39356. // Where appends a list predicates to the WhatsappChannelMutation builder.
  39357. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  39358. m.predicates = append(m.predicates, ps...)
  39359. }
  39360. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  39361. // users can use type-assertion to append predicates that do not depend on any generated package.
  39362. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  39363. p := make([]predicate.WhatsappChannel, len(ps))
  39364. for i := range ps {
  39365. p[i] = ps[i]
  39366. }
  39367. m.Where(p...)
  39368. }
  39369. // Op returns the operation name.
  39370. func (m *WhatsappChannelMutation) Op() Op {
  39371. return m.op
  39372. }
  39373. // SetOp allows setting the mutation operation.
  39374. func (m *WhatsappChannelMutation) SetOp(op Op) {
  39375. m.op = op
  39376. }
  39377. // Type returns the node type of this mutation (WhatsappChannel).
  39378. func (m *WhatsappChannelMutation) Type() string {
  39379. return m.typ
  39380. }
  39381. // Fields returns all fields that were changed during this mutation. Note that in
  39382. // order to get all numeric fields that were incremented/decremented, call
  39383. // AddedFields().
  39384. func (m *WhatsappChannelMutation) Fields() []string {
  39385. fields := make([]string, 0, 12)
  39386. if m.created_at != nil {
  39387. fields = append(fields, whatsappchannel.FieldCreatedAt)
  39388. }
  39389. if m.updated_at != nil {
  39390. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  39391. }
  39392. if m.status != nil {
  39393. fields = append(fields, whatsappchannel.FieldStatus)
  39394. }
  39395. if m.deleted_at != nil {
  39396. fields = append(fields, whatsappchannel.FieldDeletedAt)
  39397. }
  39398. if m.ak != nil {
  39399. fields = append(fields, whatsappchannel.FieldAk)
  39400. }
  39401. if m.sk != nil {
  39402. fields = append(fields, whatsappchannel.FieldSk)
  39403. }
  39404. if m.wa_id != nil {
  39405. fields = append(fields, whatsappchannel.FieldWaID)
  39406. }
  39407. if m.wa_name != nil {
  39408. fields = append(fields, whatsappchannel.FieldWaName)
  39409. }
  39410. if m.waba_id != nil {
  39411. fields = append(fields, whatsappchannel.FieldWabaID)
  39412. }
  39413. if m.business_id != nil {
  39414. fields = append(fields, whatsappchannel.FieldBusinessID)
  39415. }
  39416. if m.organization_id != nil {
  39417. fields = append(fields, whatsappchannel.FieldOrganizationID)
  39418. }
  39419. if m.verify_account != nil {
  39420. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  39421. }
  39422. return fields
  39423. }
  39424. // Field returns the value of a field with the given name. The second boolean
  39425. // return value indicates that this field was not set, or was not defined in the
  39426. // schema.
  39427. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  39428. switch name {
  39429. case whatsappchannel.FieldCreatedAt:
  39430. return m.CreatedAt()
  39431. case whatsappchannel.FieldUpdatedAt:
  39432. return m.UpdatedAt()
  39433. case whatsappchannel.FieldStatus:
  39434. return m.Status()
  39435. case whatsappchannel.FieldDeletedAt:
  39436. return m.DeletedAt()
  39437. case whatsappchannel.FieldAk:
  39438. return m.Ak()
  39439. case whatsappchannel.FieldSk:
  39440. return m.Sk()
  39441. case whatsappchannel.FieldWaID:
  39442. return m.WaID()
  39443. case whatsappchannel.FieldWaName:
  39444. return m.WaName()
  39445. case whatsappchannel.FieldWabaID:
  39446. return m.WabaID()
  39447. case whatsappchannel.FieldBusinessID:
  39448. return m.BusinessID()
  39449. case whatsappchannel.FieldOrganizationID:
  39450. return m.OrganizationID()
  39451. case whatsappchannel.FieldVerifyAccount:
  39452. return m.VerifyAccount()
  39453. }
  39454. return nil, false
  39455. }
  39456. // OldField returns the old value of the field from the database. An error is
  39457. // returned if the mutation operation is not UpdateOne, or the query to the
  39458. // database failed.
  39459. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39460. switch name {
  39461. case whatsappchannel.FieldCreatedAt:
  39462. return m.OldCreatedAt(ctx)
  39463. case whatsappchannel.FieldUpdatedAt:
  39464. return m.OldUpdatedAt(ctx)
  39465. case whatsappchannel.FieldStatus:
  39466. return m.OldStatus(ctx)
  39467. case whatsappchannel.FieldDeletedAt:
  39468. return m.OldDeletedAt(ctx)
  39469. case whatsappchannel.FieldAk:
  39470. return m.OldAk(ctx)
  39471. case whatsappchannel.FieldSk:
  39472. return m.OldSk(ctx)
  39473. case whatsappchannel.FieldWaID:
  39474. return m.OldWaID(ctx)
  39475. case whatsappchannel.FieldWaName:
  39476. return m.OldWaName(ctx)
  39477. case whatsappchannel.FieldWabaID:
  39478. return m.OldWabaID(ctx)
  39479. case whatsappchannel.FieldBusinessID:
  39480. return m.OldBusinessID(ctx)
  39481. case whatsappchannel.FieldOrganizationID:
  39482. return m.OldOrganizationID(ctx)
  39483. case whatsappchannel.FieldVerifyAccount:
  39484. return m.OldVerifyAccount(ctx)
  39485. }
  39486. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  39487. }
  39488. // SetField sets the value of a field with the given name. It returns an error if
  39489. // the field is not defined in the schema, or if the type mismatched the field
  39490. // type.
  39491. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  39492. switch name {
  39493. case whatsappchannel.FieldCreatedAt:
  39494. v, ok := value.(time.Time)
  39495. if !ok {
  39496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39497. }
  39498. m.SetCreatedAt(v)
  39499. return nil
  39500. case whatsappchannel.FieldUpdatedAt:
  39501. v, ok := value.(time.Time)
  39502. if !ok {
  39503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39504. }
  39505. m.SetUpdatedAt(v)
  39506. return nil
  39507. case whatsappchannel.FieldStatus:
  39508. v, ok := value.(uint8)
  39509. if !ok {
  39510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39511. }
  39512. m.SetStatus(v)
  39513. return nil
  39514. case whatsappchannel.FieldDeletedAt:
  39515. v, ok := value.(time.Time)
  39516. if !ok {
  39517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39518. }
  39519. m.SetDeletedAt(v)
  39520. return nil
  39521. case whatsappchannel.FieldAk:
  39522. v, ok := value.(string)
  39523. if !ok {
  39524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39525. }
  39526. m.SetAk(v)
  39527. return nil
  39528. case whatsappchannel.FieldSk:
  39529. v, ok := value.(string)
  39530. if !ok {
  39531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39532. }
  39533. m.SetSk(v)
  39534. return nil
  39535. case whatsappchannel.FieldWaID:
  39536. v, ok := value.(string)
  39537. if !ok {
  39538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39539. }
  39540. m.SetWaID(v)
  39541. return nil
  39542. case whatsappchannel.FieldWaName:
  39543. v, ok := value.(string)
  39544. if !ok {
  39545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39546. }
  39547. m.SetWaName(v)
  39548. return nil
  39549. case whatsappchannel.FieldWabaID:
  39550. v, ok := value.(uint64)
  39551. if !ok {
  39552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39553. }
  39554. m.SetWabaID(v)
  39555. return nil
  39556. case whatsappchannel.FieldBusinessID:
  39557. v, ok := value.(uint64)
  39558. if !ok {
  39559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39560. }
  39561. m.SetBusinessID(v)
  39562. return nil
  39563. case whatsappchannel.FieldOrganizationID:
  39564. v, ok := value.(uint64)
  39565. if !ok {
  39566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39567. }
  39568. m.SetOrganizationID(v)
  39569. return nil
  39570. case whatsappchannel.FieldVerifyAccount:
  39571. v, ok := value.(string)
  39572. if !ok {
  39573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39574. }
  39575. m.SetVerifyAccount(v)
  39576. return nil
  39577. }
  39578. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  39579. }
  39580. // AddedFields returns all numeric fields that were incremented/decremented during
  39581. // this mutation.
  39582. func (m *WhatsappChannelMutation) AddedFields() []string {
  39583. var fields []string
  39584. if m.addstatus != nil {
  39585. fields = append(fields, whatsappchannel.FieldStatus)
  39586. }
  39587. if m.addwaba_id != nil {
  39588. fields = append(fields, whatsappchannel.FieldWabaID)
  39589. }
  39590. if m.addbusiness_id != nil {
  39591. fields = append(fields, whatsappchannel.FieldBusinessID)
  39592. }
  39593. if m.addorganization_id != nil {
  39594. fields = append(fields, whatsappchannel.FieldOrganizationID)
  39595. }
  39596. return fields
  39597. }
  39598. // AddedField returns the numeric value that was incremented/decremented on a field
  39599. // with the given name. The second boolean return value indicates that this field
  39600. // was not set, or was not defined in the schema.
  39601. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  39602. switch name {
  39603. case whatsappchannel.FieldStatus:
  39604. return m.AddedStatus()
  39605. case whatsappchannel.FieldWabaID:
  39606. return m.AddedWabaID()
  39607. case whatsappchannel.FieldBusinessID:
  39608. return m.AddedBusinessID()
  39609. case whatsappchannel.FieldOrganizationID:
  39610. return m.AddedOrganizationID()
  39611. }
  39612. return nil, false
  39613. }
  39614. // AddField adds the value to the field with the given name. It returns an error if
  39615. // the field is not defined in the schema, or if the type mismatched the field
  39616. // type.
  39617. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  39618. switch name {
  39619. case whatsappchannel.FieldStatus:
  39620. v, ok := value.(int8)
  39621. if !ok {
  39622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39623. }
  39624. m.AddStatus(v)
  39625. return nil
  39626. case whatsappchannel.FieldWabaID:
  39627. v, ok := value.(int64)
  39628. if !ok {
  39629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39630. }
  39631. m.AddWabaID(v)
  39632. return nil
  39633. case whatsappchannel.FieldBusinessID:
  39634. v, ok := value.(int64)
  39635. if !ok {
  39636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39637. }
  39638. m.AddBusinessID(v)
  39639. return nil
  39640. case whatsappchannel.FieldOrganizationID:
  39641. v, ok := value.(int64)
  39642. if !ok {
  39643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39644. }
  39645. m.AddOrganizationID(v)
  39646. return nil
  39647. }
  39648. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  39649. }
  39650. // ClearedFields returns all nullable fields that were cleared during this
  39651. // mutation.
  39652. func (m *WhatsappChannelMutation) ClearedFields() []string {
  39653. var fields []string
  39654. if m.FieldCleared(whatsappchannel.FieldStatus) {
  39655. fields = append(fields, whatsappchannel.FieldStatus)
  39656. }
  39657. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  39658. fields = append(fields, whatsappchannel.FieldDeletedAt)
  39659. }
  39660. if m.FieldCleared(whatsappchannel.FieldAk) {
  39661. fields = append(fields, whatsappchannel.FieldAk)
  39662. }
  39663. if m.FieldCleared(whatsappchannel.FieldWaID) {
  39664. fields = append(fields, whatsappchannel.FieldWaID)
  39665. }
  39666. if m.FieldCleared(whatsappchannel.FieldWaName) {
  39667. fields = append(fields, whatsappchannel.FieldWaName)
  39668. }
  39669. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  39670. fields = append(fields, whatsappchannel.FieldOrganizationID)
  39671. }
  39672. return fields
  39673. }
  39674. // FieldCleared returns a boolean indicating if a field with the given name was
  39675. // cleared in this mutation.
  39676. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  39677. _, ok := m.clearedFields[name]
  39678. return ok
  39679. }
  39680. // ClearField clears the value of the field with the given name. It returns an
  39681. // error if the field is not defined in the schema.
  39682. func (m *WhatsappChannelMutation) ClearField(name string) error {
  39683. switch name {
  39684. case whatsappchannel.FieldStatus:
  39685. m.ClearStatus()
  39686. return nil
  39687. case whatsappchannel.FieldDeletedAt:
  39688. m.ClearDeletedAt()
  39689. return nil
  39690. case whatsappchannel.FieldAk:
  39691. m.ClearAk()
  39692. return nil
  39693. case whatsappchannel.FieldWaID:
  39694. m.ClearWaID()
  39695. return nil
  39696. case whatsappchannel.FieldWaName:
  39697. m.ClearWaName()
  39698. return nil
  39699. case whatsappchannel.FieldOrganizationID:
  39700. m.ClearOrganizationID()
  39701. return nil
  39702. }
  39703. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  39704. }
  39705. // ResetField resets all changes in the mutation for the field with the given name.
  39706. // It returns an error if the field is not defined in the schema.
  39707. func (m *WhatsappChannelMutation) ResetField(name string) error {
  39708. switch name {
  39709. case whatsappchannel.FieldCreatedAt:
  39710. m.ResetCreatedAt()
  39711. return nil
  39712. case whatsappchannel.FieldUpdatedAt:
  39713. m.ResetUpdatedAt()
  39714. return nil
  39715. case whatsappchannel.FieldStatus:
  39716. m.ResetStatus()
  39717. return nil
  39718. case whatsappchannel.FieldDeletedAt:
  39719. m.ResetDeletedAt()
  39720. return nil
  39721. case whatsappchannel.FieldAk:
  39722. m.ResetAk()
  39723. return nil
  39724. case whatsappchannel.FieldSk:
  39725. m.ResetSk()
  39726. return nil
  39727. case whatsappchannel.FieldWaID:
  39728. m.ResetWaID()
  39729. return nil
  39730. case whatsappchannel.FieldWaName:
  39731. m.ResetWaName()
  39732. return nil
  39733. case whatsappchannel.FieldWabaID:
  39734. m.ResetWabaID()
  39735. return nil
  39736. case whatsappchannel.FieldBusinessID:
  39737. m.ResetBusinessID()
  39738. return nil
  39739. case whatsappchannel.FieldOrganizationID:
  39740. m.ResetOrganizationID()
  39741. return nil
  39742. case whatsappchannel.FieldVerifyAccount:
  39743. m.ResetVerifyAccount()
  39744. return nil
  39745. }
  39746. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  39747. }
  39748. // AddedEdges returns all edge names that were set/added in this mutation.
  39749. func (m *WhatsappChannelMutation) AddedEdges() []string {
  39750. edges := make([]string, 0, 0)
  39751. return edges
  39752. }
  39753. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39754. // name in this mutation.
  39755. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  39756. return nil
  39757. }
  39758. // RemovedEdges returns all edge names that were removed in this mutation.
  39759. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  39760. edges := make([]string, 0, 0)
  39761. return edges
  39762. }
  39763. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39764. // the given name in this mutation.
  39765. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  39766. return nil
  39767. }
  39768. // ClearedEdges returns all edge names that were cleared in this mutation.
  39769. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  39770. edges := make([]string, 0, 0)
  39771. return edges
  39772. }
  39773. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39774. // was cleared in this mutation.
  39775. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  39776. return false
  39777. }
  39778. // ClearEdge clears the value of the edge with the given name. It returns an error
  39779. // if that edge is not defined in the schema.
  39780. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  39781. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  39782. }
  39783. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39784. // It returns an error if the edge is not defined in the schema.
  39785. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  39786. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  39787. }
  39788. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  39789. type WorkExperienceMutation struct {
  39790. config
  39791. op Op
  39792. typ string
  39793. id *uint64
  39794. created_at *time.Time
  39795. updated_at *time.Time
  39796. deleted_at *time.Time
  39797. start_date *time.Time
  39798. end_date *time.Time
  39799. company *string
  39800. experience *string
  39801. organization_id *uint64
  39802. addorganization_id *int64
  39803. clearedFields map[string]struct{}
  39804. employee *uint64
  39805. clearedemployee bool
  39806. done bool
  39807. oldValue func(context.Context) (*WorkExperience, error)
  39808. predicates []predicate.WorkExperience
  39809. }
  39810. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  39811. // workexperienceOption allows management of the mutation configuration using functional options.
  39812. type workexperienceOption func(*WorkExperienceMutation)
  39813. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  39814. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  39815. m := &WorkExperienceMutation{
  39816. config: c,
  39817. op: op,
  39818. typ: TypeWorkExperience,
  39819. clearedFields: make(map[string]struct{}),
  39820. }
  39821. for _, opt := range opts {
  39822. opt(m)
  39823. }
  39824. return m
  39825. }
  39826. // withWorkExperienceID sets the ID field of the mutation.
  39827. func withWorkExperienceID(id uint64) workexperienceOption {
  39828. return func(m *WorkExperienceMutation) {
  39829. var (
  39830. err error
  39831. once sync.Once
  39832. value *WorkExperience
  39833. )
  39834. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  39835. once.Do(func() {
  39836. if m.done {
  39837. err = errors.New("querying old values post mutation is not allowed")
  39838. } else {
  39839. value, err = m.Client().WorkExperience.Get(ctx, id)
  39840. }
  39841. })
  39842. return value, err
  39843. }
  39844. m.id = &id
  39845. }
  39846. }
  39847. // withWorkExperience sets the old WorkExperience of the mutation.
  39848. func withWorkExperience(node *WorkExperience) workexperienceOption {
  39849. return func(m *WorkExperienceMutation) {
  39850. m.oldValue = func(context.Context) (*WorkExperience, error) {
  39851. return node, nil
  39852. }
  39853. m.id = &node.ID
  39854. }
  39855. }
  39856. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39857. // executed in a transaction (ent.Tx), a transactional client is returned.
  39858. func (m WorkExperienceMutation) Client() *Client {
  39859. client := &Client{config: m.config}
  39860. client.init()
  39861. return client
  39862. }
  39863. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39864. // it returns an error otherwise.
  39865. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  39866. if _, ok := m.driver.(*txDriver); !ok {
  39867. return nil, errors.New("ent: mutation is not running in a transaction")
  39868. }
  39869. tx := &Tx{config: m.config}
  39870. tx.init()
  39871. return tx, nil
  39872. }
  39873. // SetID sets the value of the id field. Note that this
  39874. // operation is only accepted on creation of WorkExperience entities.
  39875. func (m *WorkExperienceMutation) SetID(id uint64) {
  39876. m.id = &id
  39877. }
  39878. // ID returns the ID value in the mutation. Note that the ID is only available
  39879. // if it was provided to the builder or after it was returned from the database.
  39880. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  39881. if m.id == nil {
  39882. return
  39883. }
  39884. return *m.id, true
  39885. }
  39886. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39887. // That means, if the mutation is applied within a transaction with an isolation level such
  39888. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39889. // or updated by the mutation.
  39890. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  39891. switch {
  39892. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39893. id, exists := m.ID()
  39894. if exists {
  39895. return []uint64{id}, nil
  39896. }
  39897. fallthrough
  39898. case m.op.Is(OpUpdate | OpDelete):
  39899. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  39900. default:
  39901. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39902. }
  39903. }
  39904. // SetCreatedAt sets the "created_at" field.
  39905. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  39906. m.created_at = &t
  39907. }
  39908. // CreatedAt returns the value of the "created_at" field in the mutation.
  39909. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  39910. v := m.created_at
  39911. if v == nil {
  39912. return
  39913. }
  39914. return *v, true
  39915. }
  39916. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  39917. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39919. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39920. if !m.op.Is(OpUpdateOne) {
  39921. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39922. }
  39923. if m.id == nil || m.oldValue == nil {
  39924. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39925. }
  39926. oldValue, err := m.oldValue(ctx)
  39927. if err != nil {
  39928. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39929. }
  39930. return oldValue.CreatedAt, nil
  39931. }
  39932. // ResetCreatedAt resets all changes to the "created_at" field.
  39933. func (m *WorkExperienceMutation) ResetCreatedAt() {
  39934. m.created_at = nil
  39935. }
  39936. // SetUpdatedAt sets the "updated_at" field.
  39937. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  39938. m.updated_at = &t
  39939. }
  39940. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39941. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  39942. v := m.updated_at
  39943. if v == nil {
  39944. return
  39945. }
  39946. return *v, true
  39947. }
  39948. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  39949. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39951. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39952. if !m.op.Is(OpUpdateOne) {
  39953. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39954. }
  39955. if m.id == nil || m.oldValue == nil {
  39956. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39957. }
  39958. oldValue, err := m.oldValue(ctx)
  39959. if err != nil {
  39960. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39961. }
  39962. return oldValue.UpdatedAt, nil
  39963. }
  39964. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39965. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  39966. m.updated_at = nil
  39967. }
  39968. // SetDeletedAt sets the "deleted_at" field.
  39969. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  39970. m.deleted_at = &t
  39971. }
  39972. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39973. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  39974. v := m.deleted_at
  39975. if v == nil {
  39976. return
  39977. }
  39978. return *v, true
  39979. }
  39980. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  39981. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39983. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39984. if !m.op.Is(OpUpdateOne) {
  39985. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39986. }
  39987. if m.id == nil || m.oldValue == nil {
  39988. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39989. }
  39990. oldValue, err := m.oldValue(ctx)
  39991. if err != nil {
  39992. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39993. }
  39994. return oldValue.DeletedAt, nil
  39995. }
  39996. // ClearDeletedAt clears the value of the "deleted_at" field.
  39997. func (m *WorkExperienceMutation) ClearDeletedAt() {
  39998. m.deleted_at = nil
  39999. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  40000. }
  40001. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40002. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  40003. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  40004. return ok
  40005. }
  40006. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40007. func (m *WorkExperienceMutation) ResetDeletedAt() {
  40008. m.deleted_at = nil
  40009. delete(m.clearedFields, workexperience.FieldDeletedAt)
  40010. }
  40011. // SetEmployeeID sets the "employee_id" field.
  40012. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  40013. m.employee = &u
  40014. }
  40015. // EmployeeID returns the value of the "employee_id" field in the mutation.
  40016. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  40017. v := m.employee
  40018. if v == nil {
  40019. return
  40020. }
  40021. return *v, true
  40022. }
  40023. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  40024. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40026. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  40027. if !m.op.Is(OpUpdateOne) {
  40028. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  40029. }
  40030. if m.id == nil || m.oldValue == nil {
  40031. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  40032. }
  40033. oldValue, err := m.oldValue(ctx)
  40034. if err != nil {
  40035. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  40036. }
  40037. return oldValue.EmployeeID, nil
  40038. }
  40039. // ResetEmployeeID resets all changes to the "employee_id" field.
  40040. func (m *WorkExperienceMutation) ResetEmployeeID() {
  40041. m.employee = nil
  40042. }
  40043. // SetStartDate sets the "start_date" field.
  40044. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  40045. m.start_date = &t
  40046. }
  40047. // StartDate returns the value of the "start_date" field in the mutation.
  40048. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  40049. v := m.start_date
  40050. if v == nil {
  40051. return
  40052. }
  40053. return *v, true
  40054. }
  40055. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  40056. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40058. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  40059. if !m.op.Is(OpUpdateOne) {
  40060. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  40061. }
  40062. if m.id == nil || m.oldValue == nil {
  40063. return v, errors.New("OldStartDate requires an ID field in the mutation")
  40064. }
  40065. oldValue, err := m.oldValue(ctx)
  40066. if err != nil {
  40067. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  40068. }
  40069. return oldValue.StartDate, nil
  40070. }
  40071. // ResetStartDate resets all changes to the "start_date" field.
  40072. func (m *WorkExperienceMutation) ResetStartDate() {
  40073. m.start_date = nil
  40074. }
  40075. // SetEndDate sets the "end_date" field.
  40076. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  40077. m.end_date = &t
  40078. }
  40079. // EndDate returns the value of the "end_date" field in the mutation.
  40080. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  40081. v := m.end_date
  40082. if v == nil {
  40083. return
  40084. }
  40085. return *v, true
  40086. }
  40087. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  40088. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40090. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  40091. if !m.op.Is(OpUpdateOne) {
  40092. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  40093. }
  40094. if m.id == nil || m.oldValue == nil {
  40095. return v, errors.New("OldEndDate requires an ID field in the mutation")
  40096. }
  40097. oldValue, err := m.oldValue(ctx)
  40098. if err != nil {
  40099. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  40100. }
  40101. return oldValue.EndDate, nil
  40102. }
  40103. // ResetEndDate resets all changes to the "end_date" field.
  40104. func (m *WorkExperienceMutation) ResetEndDate() {
  40105. m.end_date = nil
  40106. }
  40107. // SetCompany sets the "company" field.
  40108. func (m *WorkExperienceMutation) SetCompany(s string) {
  40109. m.company = &s
  40110. }
  40111. // Company returns the value of the "company" field in the mutation.
  40112. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  40113. v := m.company
  40114. if v == nil {
  40115. return
  40116. }
  40117. return *v, true
  40118. }
  40119. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  40120. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40122. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  40123. if !m.op.Is(OpUpdateOne) {
  40124. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  40125. }
  40126. if m.id == nil || m.oldValue == nil {
  40127. return v, errors.New("OldCompany requires an ID field in the mutation")
  40128. }
  40129. oldValue, err := m.oldValue(ctx)
  40130. if err != nil {
  40131. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  40132. }
  40133. return oldValue.Company, nil
  40134. }
  40135. // ResetCompany resets all changes to the "company" field.
  40136. func (m *WorkExperienceMutation) ResetCompany() {
  40137. m.company = nil
  40138. }
  40139. // SetExperience sets the "experience" field.
  40140. func (m *WorkExperienceMutation) SetExperience(s string) {
  40141. m.experience = &s
  40142. }
  40143. // Experience returns the value of the "experience" field in the mutation.
  40144. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  40145. v := m.experience
  40146. if v == nil {
  40147. return
  40148. }
  40149. return *v, true
  40150. }
  40151. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  40152. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40154. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  40155. if !m.op.Is(OpUpdateOne) {
  40156. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  40157. }
  40158. if m.id == nil || m.oldValue == nil {
  40159. return v, errors.New("OldExperience requires an ID field in the mutation")
  40160. }
  40161. oldValue, err := m.oldValue(ctx)
  40162. if err != nil {
  40163. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  40164. }
  40165. return oldValue.Experience, nil
  40166. }
  40167. // ResetExperience resets all changes to the "experience" field.
  40168. func (m *WorkExperienceMutation) ResetExperience() {
  40169. m.experience = nil
  40170. }
  40171. // SetOrganizationID sets the "organization_id" field.
  40172. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  40173. m.organization_id = &u
  40174. m.addorganization_id = nil
  40175. }
  40176. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40177. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  40178. v := m.organization_id
  40179. if v == nil {
  40180. return
  40181. }
  40182. return *v, true
  40183. }
  40184. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  40185. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40187. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40188. if !m.op.Is(OpUpdateOne) {
  40189. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40190. }
  40191. if m.id == nil || m.oldValue == nil {
  40192. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40193. }
  40194. oldValue, err := m.oldValue(ctx)
  40195. if err != nil {
  40196. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40197. }
  40198. return oldValue.OrganizationID, nil
  40199. }
  40200. // AddOrganizationID adds u to the "organization_id" field.
  40201. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  40202. if m.addorganization_id != nil {
  40203. *m.addorganization_id += u
  40204. } else {
  40205. m.addorganization_id = &u
  40206. }
  40207. }
  40208. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40209. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  40210. v := m.addorganization_id
  40211. if v == nil {
  40212. return
  40213. }
  40214. return *v, true
  40215. }
  40216. // ResetOrganizationID resets all changes to the "organization_id" field.
  40217. func (m *WorkExperienceMutation) ResetOrganizationID() {
  40218. m.organization_id = nil
  40219. m.addorganization_id = nil
  40220. }
  40221. // ClearEmployee clears the "employee" edge to the Employee entity.
  40222. func (m *WorkExperienceMutation) ClearEmployee() {
  40223. m.clearedemployee = true
  40224. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  40225. }
  40226. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  40227. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  40228. return m.clearedemployee
  40229. }
  40230. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  40231. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40232. // EmployeeID instead. It exists only for internal usage by the builders.
  40233. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  40234. if id := m.employee; id != nil {
  40235. ids = append(ids, *id)
  40236. }
  40237. return
  40238. }
  40239. // ResetEmployee resets all changes to the "employee" edge.
  40240. func (m *WorkExperienceMutation) ResetEmployee() {
  40241. m.employee = nil
  40242. m.clearedemployee = false
  40243. }
  40244. // Where appends a list predicates to the WorkExperienceMutation builder.
  40245. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  40246. m.predicates = append(m.predicates, ps...)
  40247. }
  40248. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  40249. // users can use type-assertion to append predicates that do not depend on any generated package.
  40250. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  40251. p := make([]predicate.WorkExperience, len(ps))
  40252. for i := range ps {
  40253. p[i] = ps[i]
  40254. }
  40255. m.Where(p...)
  40256. }
  40257. // Op returns the operation name.
  40258. func (m *WorkExperienceMutation) Op() Op {
  40259. return m.op
  40260. }
  40261. // SetOp allows setting the mutation operation.
  40262. func (m *WorkExperienceMutation) SetOp(op Op) {
  40263. m.op = op
  40264. }
  40265. // Type returns the node type of this mutation (WorkExperience).
  40266. func (m *WorkExperienceMutation) Type() string {
  40267. return m.typ
  40268. }
  40269. // Fields returns all fields that were changed during this mutation. Note that in
  40270. // order to get all numeric fields that were incremented/decremented, call
  40271. // AddedFields().
  40272. func (m *WorkExperienceMutation) Fields() []string {
  40273. fields := make([]string, 0, 9)
  40274. if m.created_at != nil {
  40275. fields = append(fields, workexperience.FieldCreatedAt)
  40276. }
  40277. if m.updated_at != nil {
  40278. fields = append(fields, workexperience.FieldUpdatedAt)
  40279. }
  40280. if m.deleted_at != nil {
  40281. fields = append(fields, workexperience.FieldDeletedAt)
  40282. }
  40283. if m.employee != nil {
  40284. fields = append(fields, workexperience.FieldEmployeeID)
  40285. }
  40286. if m.start_date != nil {
  40287. fields = append(fields, workexperience.FieldStartDate)
  40288. }
  40289. if m.end_date != nil {
  40290. fields = append(fields, workexperience.FieldEndDate)
  40291. }
  40292. if m.company != nil {
  40293. fields = append(fields, workexperience.FieldCompany)
  40294. }
  40295. if m.experience != nil {
  40296. fields = append(fields, workexperience.FieldExperience)
  40297. }
  40298. if m.organization_id != nil {
  40299. fields = append(fields, workexperience.FieldOrganizationID)
  40300. }
  40301. return fields
  40302. }
  40303. // Field returns the value of a field with the given name. The second boolean
  40304. // return value indicates that this field was not set, or was not defined in the
  40305. // schema.
  40306. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  40307. switch name {
  40308. case workexperience.FieldCreatedAt:
  40309. return m.CreatedAt()
  40310. case workexperience.FieldUpdatedAt:
  40311. return m.UpdatedAt()
  40312. case workexperience.FieldDeletedAt:
  40313. return m.DeletedAt()
  40314. case workexperience.FieldEmployeeID:
  40315. return m.EmployeeID()
  40316. case workexperience.FieldStartDate:
  40317. return m.StartDate()
  40318. case workexperience.FieldEndDate:
  40319. return m.EndDate()
  40320. case workexperience.FieldCompany:
  40321. return m.Company()
  40322. case workexperience.FieldExperience:
  40323. return m.Experience()
  40324. case workexperience.FieldOrganizationID:
  40325. return m.OrganizationID()
  40326. }
  40327. return nil, false
  40328. }
  40329. // OldField returns the old value of the field from the database. An error is
  40330. // returned if the mutation operation is not UpdateOne, or the query to the
  40331. // database failed.
  40332. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40333. switch name {
  40334. case workexperience.FieldCreatedAt:
  40335. return m.OldCreatedAt(ctx)
  40336. case workexperience.FieldUpdatedAt:
  40337. return m.OldUpdatedAt(ctx)
  40338. case workexperience.FieldDeletedAt:
  40339. return m.OldDeletedAt(ctx)
  40340. case workexperience.FieldEmployeeID:
  40341. return m.OldEmployeeID(ctx)
  40342. case workexperience.FieldStartDate:
  40343. return m.OldStartDate(ctx)
  40344. case workexperience.FieldEndDate:
  40345. return m.OldEndDate(ctx)
  40346. case workexperience.FieldCompany:
  40347. return m.OldCompany(ctx)
  40348. case workexperience.FieldExperience:
  40349. return m.OldExperience(ctx)
  40350. case workexperience.FieldOrganizationID:
  40351. return m.OldOrganizationID(ctx)
  40352. }
  40353. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  40354. }
  40355. // SetField sets the value of a field with the given name. It returns an error if
  40356. // the field is not defined in the schema, or if the type mismatched the field
  40357. // type.
  40358. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  40359. switch name {
  40360. case workexperience.FieldCreatedAt:
  40361. v, ok := value.(time.Time)
  40362. if !ok {
  40363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40364. }
  40365. m.SetCreatedAt(v)
  40366. return nil
  40367. case workexperience.FieldUpdatedAt:
  40368. v, ok := value.(time.Time)
  40369. if !ok {
  40370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40371. }
  40372. m.SetUpdatedAt(v)
  40373. return nil
  40374. case workexperience.FieldDeletedAt:
  40375. v, ok := value.(time.Time)
  40376. if !ok {
  40377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40378. }
  40379. m.SetDeletedAt(v)
  40380. return nil
  40381. case workexperience.FieldEmployeeID:
  40382. v, ok := value.(uint64)
  40383. if !ok {
  40384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40385. }
  40386. m.SetEmployeeID(v)
  40387. return nil
  40388. case workexperience.FieldStartDate:
  40389. v, ok := value.(time.Time)
  40390. if !ok {
  40391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40392. }
  40393. m.SetStartDate(v)
  40394. return nil
  40395. case workexperience.FieldEndDate:
  40396. v, ok := value.(time.Time)
  40397. if !ok {
  40398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40399. }
  40400. m.SetEndDate(v)
  40401. return nil
  40402. case workexperience.FieldCompany:
  40403. v, ok := value.(string)
  40404. if !ok {
  40405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40406. }
  40407. m.SetCompany(v)
  40408. return nil
  40409. case workexperience.FieldExperience:
  40410. v, ok := value.(string)
  40411. if !ok {
  40412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40413. }
  40414. m.SetExperience(v)
  40415. return nil
  40416. case workexperience.FieldOrganizationID:
  40417. v, ok := value.(uint64)
  40418. if !ok {
  40419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40420. }
  40421. m.SetOrganizationID(v)
  40422. return nil
  40423. }
  40424. return fmt.Errorf("unknown WorkExperience field %s", name)
  40425. }
  40426. // AddedFields returns all numeric fields that were incremented/decremented during
  40427. // this mutation.
  40428. func (m *WorkExperienceMutation) AddedFields() []string {
  40429. var fields []string
  40430. if m.addorganization_id != nil {
  40431. fields = append(fields, workexperience.FieldOrganizationID)
  40432. }
  40433. return fields
  40434. }
  40435. // AddedField returns the numeric value that was incremented/decremented on a field
  40436. // with the given name. The second boolean return value indicates that this field
  40437. // was not set, or was not defined in the schema.
  40438. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  40439. switch name {
  40440. case workexperience.FieldOrganizationID:
  40441. return m.AddedOrganizationID()
  40442. }
  40443. return nil, false
  40444. }
  40445. // AddField adds the value to the field with the given name. It returns an error if
  40446. // the field is not defined in the schema, or if the type mismatched the field
  40447. // type.
  40448. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  40449. switch name {
  40450. case workexperience.FieldOrganizationID:
  40451. v, ok := value.(int64)
  40452. if !ok {
  40453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40454. }
  40455. m.AddOrganizationID(v)
  40456. return nil
  40457. }
  40458. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  40459. }
  40460. // ClearedFields returns all nullable fields that were cleared during this
  40461. // mutation.
  40462. func (m *WorkExperienceMutation) ClearedFields() []string {
  40463. var fields []string
  40464. if m.FieldCleared(workexperience.FieldDeletedAt) {
  40465. fields = append(fields, workexperience.FieldDeletedAt)
  40466. }
  40467. return fields
  40468. }
  40469. // FieldCleared returns a boolean indicating if a field with the given name was
  40470. // cleared in this mutation.
  40471. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  40472. _, ok := m.clearedFields[name]
  40473. return ok
  40474. }
  40475. // ClearField clears the value of the field with the given name. It returns an
  40476. // error if the field is not defined in the schema.
  40477. func (m *WorkExperienceMutation) ClearField(name string) error {
  40478. switch name {
  40479. case workexperience.FieldDeletedAt:
  40480. m.ClearDeletedAt()
  40481. return nil
  40482. }
  40483. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  40484. }
  40485. // ResetField resets all changes in the mutation for the field with the given name.
  40486. // It returns an error if the field is not defined in the schema.
  40487. func (m *WorkExperienceMutation) ResetField(name string) error {
  40488. switch name {
  40489. case workexperience.FieldCreatedAt:
  40490. m.ResetCreatedAt()
  40491. return nil
  40492. case workexperience.FieldUpdatedAt:
  40493. m.ResetUpdatedAt()
  40494. return nil
  40495. case workexperience.FieldDeletedAt:
  40496. m.ResetDeletedAt()
  40497. return nil
  40498. case workexperience.FieldEmployeeID:
  40499. m.ResetEmployeeID()
  40500. return nil
  40501. case workexperience.FieldStartDate:
  40502. m.ResetStartDate()
  40503. return nil
  40504. case workexperience.FieldEndDate:
  40505. m.ResetEndDate()
  40506. return nil
  40507. case workexperience.FieldCompany:
  40508. m.ResetCompany()
  40509. return nil
  40510. case workexperience.FieldExperience:
  40511. m.ResetExperience()
  40512. return nil
  40513. case workexperience.FieldOrganizationID:
  40514. m.ResetOrganizationID()
  40515. return nil
  40516. }
  40517. return fmt.Errorf("unknown WorkExperience field %s", name)
  40518. }
  40519. // AddedEdges returns all edge names that were set/added in this mutation.
  40520. func (m *WorkExperienceMutation) AddedEdges() []string {
  40521. edges := make([]string, 0, 1)
  40522. if m.employee != nil {
  40523. edges = append(edges, workexperience.EdgeEmployee)
  40524. }
  40525. return edges
  40526. }
  40527. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40528. // name in this mutation.
  40529. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  40530. switch name {
  40531. case workexperience.EdgeEmployee:
  40532. if id := m.employee; id != nil {
  40533. return []ent.Value{*id}
  40534. }
  40535. }
  40536. return nil
  40537. }
  40538. // RemovedEdges returns all edge names that were removed in this mutation.
  40539. func (m *WorkExperienceMutation) RemovedEdges() []string {
  40540. edges := make([]string, 0, 1)
  40541. return edges
  40542. }
  40543. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40544. // the given name in this mutation.
  40545. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  40546. return nil
  40547. }
  40548. // ClearedEdges returns all edge names that were cleared in this mutation.
  40549. func (m *WorkExperienceMutation) ClearedEdges() []string {
  40550. edges := make([]string, 0, 1)
  40551. if m.clearedemployee {
  40552. edges = append(edges, workexperience.EdgeEmployee)
  40553. }
  40554. return edges
  40555. }
  40556. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40557. // was cleared in this mutation.
  40558. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  40559. switch name {
  40560. case workexperience.EdgeEmployee:
  40561. return m.clearedemployee
  40562. }
  40563. return false
  40564. }
  40565. // ClearEdge clears the value of the edge with the given name. It returns an error
  40566. // if that edge is not defined in the schema.
  40567. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  40568. switch name {
  40569. case workexperience.EdgeEmployee:
  40570. m.ClearEmployee()
  40571. return nil
  40572. }
  40573. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  40574. }
  40575. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40576. // It returns an error if the edge is not defined in the schema.
  40577. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  40578. switch name {
  40579. case workexperience.EdgeEmployee:
  40580. m.ResetEmployee()
  40581. return nil
  40582. }
  40583. return fmt.Errorf("unknown WorkExperience edge %s", name)
  40584. }
  40585. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  40586. type WpChatroomMutation struct {
  40587. config
  40588. op Op
  40589. typ string
  40590. id *uint64
  40591. created_at *time.Time
  40592. updated_at *time.Time
  40593. status *uint8
  40594. addstatus *int8
  40595. wx_wxid *string
  40596. chatroom_id *string
  40597. nickname *string
  40598. owner *string
  40599. avatar *string
  40600. member_list *[]string
  40601. appendmember_list []string
  40602. clearedFields map[string]struct{}
  40603. done bool
  40604. oldValue func(context.Context) (*WpChatroom, error)
  40605. predicates []predicate.WpChatroom
  40606. }
  40607. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  40608. // wpchatroomOption allows management of the mutation configuration using functional options.
  40609. type wpchatroomOption func(*WpChatroomMutation)
  40610. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  40611. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  40612. m := &WpChatroomMutation{
  40613. config: c,
  40614. op: op,
  40615. typ: TypeWpChatroom,
  40616. clearedFields: make(map[string]struct{}),
  40617. }
  40618. for _, opt := range opts {
  40619. opt(m)
  40620. }
  40621. return m
  40622. }
  40623. // withWpChatroomID sets the ID field of the mutation.
  40624. func withWpChatroomID(id uint64) wpchatroomOption {
  40625. return func(m *WpChatroomMutation) {
  40626. var (
  40627. err error
  40628. once sync.Once
  40629. value *WpChatroom
  40630. )
  40631. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  40632. once.Do(func() {
  40633. if m.done {
  40634. err = errors.New("querying old values post mutation is not allowed")
  40635. } else {
  40636. value, err = m.Client().WpChatroom.Get(ctx, id)
  40637. }
  40638. })
  40639. return value, err
  40640. }
  40641. m.id = &id
  40642. }
  40643. }
  40644. // withWpChatroom sets the old WpChatroom of the mutation.
  40645. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  40646. return func(m *WpChatroomMutation) {
  40647. m.oldValue = func(context.Context) (*WpChatroom, error) {
  40648. return node, nil
  40649. }
  40650. m.id = &node.ID
  40651. }
  40652. }
  40653. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40654. // executed in a transaction (ent.Tx), a transactional client is returned.
  40655. func (m WpChatroomMutation) Client() *Client {
  40656. client := &Client{config: m.config}
  40657. client.init()
  40658. return client
  40659. }
  40660. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40661. // it returns an error otherwise.
  40662. func (m WpChatroomMutation) Tx() (*Tx, error) {
  40663. if _, ok := m.driver.(*txDriver); !ok {
  40664. return nil, errors.New("ent: mutation is not running in a transaction")
  40665. }
  40666. tx := &Tx{config: m.config}
  40667. tx.init()
  40668. return tx, nil
  40669. }
  40670. // SetID sets the value of the id field. Note that this
  40671. // operation is only accepted on creation of WpChatroom entities.
  40672. func (m *WpChatroomMutation) SetID(id uint64) {
  40673. m.id = &id
  40674. }
  40675. // ID returns the ID value in the mutation. Note that the ID is only available
  40676. // if it was provided to the builder or after it was returned from the database.
  40677. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  40678. if m.id == nil {
  40679. return
  40680. }
  40681. return *m.id, true
  40682. }
  40683. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40684. // That means, if the mutation is applied within a transaction with an isolation level such
  40685. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40686. // or updated by the mutation.
  40687. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  40688. switch {
  40689. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40690. id, exists := m.ID()
  40691. if exists {
  40692. return []uint64{id}, nil
  40693. }
  40694. fallthrough
  40695. case m.op.Is(OpUpdate | OpDelete):
  40696. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  40697. default:
  40698. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40699. }
  40700. }
  40701. // SetCreatedAt sets the "created_at" field.
  40702. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  40703. m.created_at = &t
  40704. }
  40705. // CreatedAt returns the value of the "created_at" field in the mutation.
  40706. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  40707. v := m.created_at
  40708. if v == nil {
  40709. return
  40710. }
  40711. return *v, true
  40712. }
  40713. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  40714. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40716. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40717. if !m.op.Is(OpUpdateOne) {
  40718. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40719. }
  40720. if m.id == nil || m.oldValue == nil {
  40721. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40722. }
  40723. oldValue, err := m.oldValue(ctx)
  40724. if err != nil {
  40725. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40726. }
  40727. return oldValue.CreatedAt, nil
  40728. }
  40729. // ResetCreatedAt resets all changes to the "created_at" field.
  40730. func (m *WpChatroomMutation) ResetCreatedAt() {
  40731. m.created_at = nil
  40732. }
  40733. // SetUpdatedAt sets the "updated_at" field.
  40734. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  40735. m.updated_at = &t
  40736. }
  40737. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40738. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  40739. v := m.updated_at
  40740. if v == nil {
  40741. return
  40742. }
  40743. return *v, true
  40744. }
  40745. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  40746. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40748. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40749. if !m.op.Is(OpUpdateOne) {
  40750. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40751. }
  40752. if m.id == nil || m.oldValue == nil {
  40753. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40754. }
  40755. oldValue, err := m.oldValue(ctx)
  40756. if err != nil {
  40757. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40758. }
  40759. return oldValue.UpdatedAt, nil
  40760. }
  40761. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40762. func (m *WpChatroomMutation) ResetUpdatedAt() {
  40763. m.updated_at = nil
  40764. }
  40765. // SetStatus sets the "status" field.
  40766. func (m *WpChatroomMutation) SetStatus(u uint8) {
  40767. m.status = &u
  40768. m.addstatus = nil
  40769. }
  40770. // Status returns the value of the "status" field in the mutation.
  40771. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  40772. v := m.status
  40773. if v == nil {
  40774. return
  40775. }
  40776. return *v, true
  40777. }
  40778. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  40779. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40781. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40782. if !m.op.Is(OpUpdateOne) {
  40783. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40784. }
  40785. if m.id == nil || m.oldValue == nil {
  40786. return v, errors.New("OldStatus requires an ID field in the mutation")
  40787. }
  40788. oldValue, err := m.oldValue(ctx)
  40789. if err != nil {
  40790. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40791. }
  40792. return oldValue.Status, nil
  40793. }
  40794. // AddStatus adds u to the "status" field.
  40795. func (m *WpChatroomMutation) AddStatus(u int8) {
  40796. if m.addstatus != nil {
  40797. *m.addstatus += u
  40798. } else {
  40799. m.addstatus = &u
  40800. }
  40801. }
  40802. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40803. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  40804. v := m.addstatus
  40805. if v == nil {
  40806. return
  40807. }
  40808. return *v, true
  40809. }
  40810. // ClearStatus clears the value of the "status" field.
  40811. func (m *WpChatroomMutation) ClearStatus() {
  40812. m.status = nil
  40813. m.addstatus = nil
  40814. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  40815. }
  40816. // StatusCleared returns if the "status" field was cleared in this mutation.
  40817. func (m *WpChatroomMutation) StatusCleared() bool {
  40818. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  40819. return ok
  40820. }
  40821. // ResetStatus resets all changes to the "status" field.
  40822. func (m *WpChatroomMutation) ResetStatus() {
  40823. m.status = nil
  40824. m.addstatus = nil
  40825. delete(m.clearedFields, wpchatroom.FieldStatus)
  40826. }
  40827. // SetWxWxid sets the "wx_wxid" field.
  40828. func (m *WpChatroomMutation) SetWxWxid(s string) {
  40829. m.wx_wxid = &s
  40830. }
  40831. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  40832. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  40833. v := m.wx_wxid
  40834. if v == nil {
  40835. return
  40836. }
  40837. return *v, true
  40838. }
  40839. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  40840. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40842. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  40843. if !m.op.Is(OpUpdateOne) {
  40844. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  40845. }
  40846. if m.id == nil || m.oldValue == nil {
  40847. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  40848. }
  40849. oldValue, err := m.oldValue(ctx)
  40850. if err != nil {
  40851. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  40852. }
  40853. return oldValue.WxWxid, nil
  40854. }
  40855. // ResetWxWxid resets all changes to the "wx_wxid" field.
  40856. func (m *WpChatroomMutation) ResetWxWxid() {
  40857. m.wx_wxid = nil
  40858. }
  40859. // SetChatroomID sets the "chatroom_id" field.
  40860. func (m *WpChatroomMutation) SetChatroomID(s string) {
  40861. m.chatroom_id = &s
  40862. }
  40863. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  40864. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  40865. v := m.chatroom_id
  40866. if v == nil {
  40867. return
  40868. }
  40869. return *v, true
  40870. }
  40871. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  40872. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40874. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  40875. if !m.op.Is(OpUpdateOne) {
  40876. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  40877. }
  40878. if m.id == nil || m.oldValue == nil {
  40879. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  40880. }
  40881. oldValue, err := m.oldValue(ctx)
  40882. if err != nil {
  40883. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  40884. }
  40885. return oldValue.ChatroomID, nil
  40886. }
  40887. // ResetChatroomID resets all changes to the "chatroom_id" field.
  40888. func (m *WpChatroomMutation) ResetChatroomID() {
  40889. m.chatroom_id = nil
  40890. }
  40891. // SetNickname sets the "nickname" field.
  40892. func (m *WpChatroomMutation) SetNickname(s string) {
  40893. m.nickname = &s
  40894. }
  40895. // Nickname returns the value of the "nickname" field in the mutation.
  40896. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  40897. v := m.nickname
  40898. if v == nil {
  40899. return
  40900. }
  40901. return *v, true
  40902. }
  40903. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  40904. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40906. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  40907. if !m.op.Is(OpUpdateOne) {
  40908. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40909. }
  40910. if m.id == nil || m.oldValue == nil {
  40911. return v, errors.New("OldNickname requires an ID field in the mutation")
  40912. }
  40913. oldValue, err := m.oldValue(ctx)
  40914. if err != nil {
  40915. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40916. }
  40917. return oldValue.Nickname, nil
  40918. }
  40919. // ResetNickname resets all changes to the "nickname" field.
  40920. func (m *WpChatroomMutation) ResetNickname() {
  40921. m.nickname = nil
  40922. }
  40923. // SetOwner sets the "owner" field.
  40924. func (m *WpChatroomMutation) SetOwner(s string) {
  40925. m.owner = &s
  40926. }
  40927. // Owner returns the value of the "owner" field in the mutation.
  40928. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  40929. v := m.owner
  40930. if v == nil {
  40931. return
  40932. }
  40933. return *v, true
  40934. }
  40935. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  40936. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40938. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  40939. if !m.op.Is(OpUpdateOne) {
  40940. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  40941. }
  40942. if m.id == nil || m.oldValue == nil {
  40943. return v, errors.New("OldOwner requires an ID field in the mutation")
  40944. }
  40945. oldValue, err := m.oldValue(ctx)
  40946. if err != nil {
  40947. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  40948. }
  40949. return oldValue.Owner, nil
  40950. }
  40951. // ResetOwner resets all changes to the "owner" field.
  40952. func (m *WpChatroomMutation) ResetOwner() {
  40953. m.owner = nil
  40954. }
  40955. // SetAvatar sets the "avatar" field.
  40956. func (m *WpChatroomMutation) SetAvatar(s string) {
  40957. m.avatar = &s
  40958. }
  40959. // Avatar returns the value of the "avatar" field in the mutation.
  40960. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  40961. v := m.avatar
  40962. if v == nil {
  40963. return
  40964. }
  40965. return *v, true
  40966. }
  40967. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  40968. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40970. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40971. if !m.op.Is(OpUpdateOne) {
  40972. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40973. }
  40974. if m.id == nil || m.oldValue == nil {
  40975. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40976. }
  40977. oldValue, err := m.oldValue(ctx)
  40978. if err != nil {
  40979. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40980. }
  40981. return oldValue.Avatar, nil
  40982. }
  40983. // ResetAvatar resets all changes to the "avatar" field.
  40984. func (m *WpChatroomMutation) ResetAvatar() {
  40985. m.avatar = nil
  40986. }
  40987. // SetMemberList sets the "member_list" field.
  40988. func (m *WpChatroomMutation) SetMemberList(s []string) {
  40989. m.member_list = &s
  40990. m.appendmember_list = nil
  40991. }
  40992. // MemberList returns the value of the "member_list" field in the mutation.
  40993. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  40994. v := m.member_list
  40995. if v == nil {
  40996. return
  40997. }
  40998. return *v, true
  40999. }
  41000. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  41001. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41003. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  41004. if !m.op.Is(OpUpdateOne) {
  41005. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  41006. }
  41007. if m.id == nil || m.oldValue == nil {
  41008. return v, errors.New("OldMemberList requires an ID field in the mutation")
  41009. }
  41010. oldValue, err := m.oldValue(ctx)
  41011. if err != nil {
  41012. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  41013. }
  41014. return oldValue.MemberList, nil
  41015. }
  41016. // AppendMemberList adds s to the "member_list" field.
  41017. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  41018. m.appendmember_list = append(m.appendmember_list, s...)
  41019. }
  41020. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  41021. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  41022. if len(m.appendmember_list) == 0 {
  41023. return nil, false
  41024. }
  41025. return m.appendmember_list, true
  41026. }
  41027. // ResetMemberList resets all changes to the "member_list" field.
  41028. func (m *WpChatroomMutation) ResetMemberList() {
  41029. m.member_list = nil
  41030. m.appendmember_list = nil
  41031. }
  41032. // Where appends a list predicates to the WpChatroomMutation builder.
  41033. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  41034. m.predicates = append(m.predicates, ps...)
  41035. }
  41036. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  41037. // users can use type-assertion to append predicates that do not depend on any generated package.
  41038. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  41039. p := make([]predicate.WpChatroom, len(ps))
  41040. for i := range ps {
  41041. p[i] = ps[i]
  41042. }
  41043. m.Where(p...)
  41044. }
  41045. // Op returns the operation name.
  41046. func (m *WpChatroomMutation) Op() Op {
  41047. return m.op
  41048. }
  41049. // SetOp allows setting the mutation operation.
  41050. func (m *WpChatroomMutation) SetOp(op Op) {
  41051. m.op = op
  41052. }
  41053. // Type returns the node type of this mutation (WpChatroom).
  41054. func (m *WpChatroomMutation) Type() string {
  41055. return m.typ
  41056. }
  41057. // Fields returns all fields that were changed during this mutation. Note that in
  41058. // order to get all numeric fields that were incremented/decremented, call
  41059. // AddedFields().
  41060. func (m *WpChatroomMutation) Fields() []string {
  41061. fields := make([]string, 0, 9)
  41062. if m.created_at != nil {
  41063. fields = append(fields, wpchatroom.FieldCreatedAt)
  41064. }
  41065. if m.updated_at != nil {
  41066. fields = append(fields, wpchatroom.FieldUpdatedAt)
  41067. }
  41068. if m.status != nil {
  41069. fields = append(fields, wpchatroom.FieldStatus)
  41070. }
  41071. if m.wx_wxid != nil {
  41072. fields = append(fields, wpchatroom.FieldWxWxid)
  41073. }
  41074. if m.chatroom_id != nil {
  41075. fields = append(fields, wpchatroom.FieldChatroomID)
  41076. }
  41077. if m.nickname != nil {
  41078. fields = append(fields, wpchatroom.FieldNickname)
  41079. }
  41080. if m.owner != nil {
  41081. fields = append(fields, wpchatroom.FieldOwner)
  41082. }
  41083. if m.avatar != nil {
  41084. fields = append(fields, wpchatroom.FieldAvatar)
  41085. }
  41086. if m.member_list != nil {
  41087. fields = append(fields, wpchatroom.FieldMemberList)
  41088. }
  41089. return fields
  41090. }
  41091. // Field returns the value of a field with the given name. The second boolean
  41092. // return value indicates that this field was not set, or was not defined in the
  41093. // schema.
  41094. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  41095. switch name {
  41096. case wpchatroom.FieldCreatedAt:
  41097. return m.CreatedAt()
  41098. case wpchatroom.FieldUpdatedAt:
  41099. return m.UpdatedAt()
  41100. case wpchatroom.FieldStatus:
  41101. return m.Status()
  41102. case wpchatroom.FieldWxWxid:
  41103. return m.WxWxid()
  41104. case wpchatroom.FieldChatroomID:
  41105. return m.ChatroomID()
  41106. case wpchatroom.FieldNickname:
  41107. return m.Nickname()
  41108. case wpchatroom.FieldOwner:
  41109. return m.Owner()
  41110. case wpchatroom.FieldAvatar:
  41111. return m.Avatar()
  41112. case wpchatroom.FieldMemberList:
  41113. return m.MemberList()
  41114. }
  41115. return nil, false
  41116. }
  41117. // OldField returns the old value of the field from the database. An error is
  41118. // returned if the mutation operation is not UpdateOne, or the query to the
  41119. // database failed.
  41120. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41121. switch name {
  41122. case wpchatroom.FieldCreatedAt:
  41123. return m.OldCreatedAt(ctx)
  41124. case wpchatroom.FieldUpdatedAt:
  41125. return m.OldUpdatedAt(ctx)
  41126. case wpchatroom.FieldStatus:
  41127. return m.OldStatus(ctx)
  41128. case wpchatroom.FieldWxWxid:
  41129. return m.OldWxWxid(ctx)
  41130. case wpchatroom.FieldChatroomID:
  41131. return m.OldChatroomID(ctx)
  41132. case wpchatroom.FieldNickname:
  41133. return m.OldNickname(ctx)
  41134. case wpchatroom.FieldOwner:
  41135. return m.OldOwner(ctx)
  41136. case wpchatroom.FieldAvatar:
  41137. return m.OldAvatar(ctx)
  41138. case wpchatroom.FieldMemberList:
  41139. return m.OldMemberList(ctx)
  41140. }
  41141. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  41142. }
  41143. // SetField sets the value of a field with the given name. It returns an error if
  41144. // the field is not defined in the schema, or if the type mismatched the field
  41145. // type.
  41146. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  41147. switch name {
  41148. case wpchatroom.FieldCreatedAt:
  41149. v, ok := value.(time.Time)
  41150. if !ok {
  41151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41152. }
  41153. m.SetCreatedAt(v)
  41154. return nil
  41155. case wpchatroom.FieldUpdatedAt:
  41156. v, ok := value.(time.Time)
  41157. if !ok {
  41158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41159. }
  41160. m.SetUpdatedAt(v)
  41161. return nil
  41162. case wpchatroom.FieldStatus:
  41163. v, ok := value.(uint8)
  41164. if !ok {
  41165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41166. }
  41167. m.SetStatus(v)
  41168. return nil
  41169. case wpchatroom.FieldWxWxid:
  41170. v, ok := value.(string)
  41171. if !ok {
  41172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41173. }
  41174. m.SetWxWxid(v)
  41175. return nil
  41176. case wpchatroom.FieldChatroomID:
  41177. v, ok := value.(string)
  41178. if !ok {
  41179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41180. }
  41181. m.SetChatroomID(v)
  41182. return nil
  41183. case wpchatroom.FieldNickname:
  41184. v, ok := value.(string)
  41185. if !ok {
  41186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41187. }
  41188. m.SetNickname(v)
  41189. return nil
  41190. case wpchatroom.FieldOwner:
  41191. v, ok := value.(string)
  41192. if !ok {
  41193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41194. }
  41195. m.SetOwner(v)
  41196. return nil
  41197. case wpchatroom.FieldAvatar:
  41198. v, ok := value.(string)
  41199. if !ok {
  41200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41201. }
  41202. m.SetAvatar(v)
  41203. return nil
  41204. case wpchatroom.FieldMemberList:
  41205. v, ok := value.([]string)
  41206. if !ok {
  41207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41208. }
  41209. m.SetMemberList(v)
  41210. return nil
  41211. }
  41212. return fmt.Errorf("unknown WpChatroom field %s", name)
  41213. }
  41214. // AddedFields returns all numeric fields that were incremented/decremented during
  41215. // this mutation.
  41216. func (m *WpChatroomMutation) AddedFields() []string {
  41217. var fields []string
  41218. if m.addstatus != nil {
  41219. fields = append(fields, wpchatroom.FieldStatus)
  41220. }
  41221. return fields
  41222. }
  41223. // AddedField returns the numeric value that was incremented/decremented on a field
  41224. // with the given name. The second boolean return value indicates that this field
  41225. // was not set, or was not defined in the schema.
  41226. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  41227. switch name {
  41228. case wpchatroom.FieldStatus:
  41229. return m.AddedStatus()
  41230. }
  41231. return nil, false
  41232. }
  41233. // AddField adds the value to the field with the given name. It returns an error if
  41234. // the field is not defined in the schema, or if the type mismatched the field
  41235. // type.
  41236. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  41237. switch name {
  41238. case wpchatroom.FieldStatus:
  41239. v, ok := value.(int8)
  41240. if !ok {
  41241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41242. }
  41243. m.AddStatus(v)
  41244. return nil
  41245. }
  41246. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  41247. }
  41248. // ClearedFields returns all nullable fields that were cleared during this
  41249. // mutation.
  41250. func (m *WpChatroomMutation) ClearedFields() []string {
  41251. var fields []string
  41252. if m.FieldCleared(wpchatroom.FieldStatus) {
  41253. fields = append(fields, wpchatroom.FieldStatus)
  41254. }
  41255. return fields
  41256. }
  41257. // FieldCleared returns a boolean indicating if a field with the given name was
  41258. // cleared in this mutation.
  41259. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  41260. _, ok := m.clearedFields[name]
  41261. return ok
  41262. }
  41263. // ClearField clears the value of the field with the given name. It returns an
  41264. // error if the field is not defined in the schema.
  41265. func (m *WpChatroomMutation) ClearField(name string) error {
  41266. switch name {
  41267. case wpchatroom.FieldStatus:
  41268. m.ClearStatus()
  41269. return nil
  41270. }
  41271. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  41272. }
  41273. // ResetField resets all changes in the mutation for the field with the given name.
  41274. // It returns an error if the field is not defined in the schema.
  41275. func (m *WpChatroomMutation) ResetField(name string) error {
  41276. switch name {
  41277. case wpchatroom.FieldCreatedAt:
  41278. m.ResetCreatedAt()
  41279. return nil
  41280. case wpchatroom.FieldUpdatedAt:
  41281. m.ResetUpdatedAt()
  41282. return nil
  41283. case wpchatroom.FieldStatus:
  41284. m.ResetStatus()
  41285. return nil
  41286. case wpchatroom.FieldWxWxid:
  41287. m.ResetWxWxid()
  41288. return nil
  41289. case wpchatroom.FieldChatroomID:
  41290. m.ResetChatroomID()
  41291. return nil
  41292. case wpchatroom.FieldNickname:
  41293. m.ResetNickname()
  41294. return nil
  41295. case wpchatroom.FieldOwner:
  41296. m.ResetOwner()
  41297. return nil
  41298. case wpchatroom.FieldAvatar:
  41299. m.ResetAvatar()
  41300. return nil
  41301. case wpchatroom.FieldMemberList:
  41302. m.ResetMemberList()
  41303. return nil
  41304. }
  41305. return fmt.Errorf("unknown WpChatroom field %s", name)
  41306. }
  41307. // AddedEdges returns all edge names that were set/added in this mutation.
  41308. func (m *WpChatroomMutation) AddedEdges() []string {
  41309. edges := make([]string, 0, 0)
  41310. return edges
  41311. }
  41312. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41313. // name in this mutation.
  41314. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  41315. return nil
  41316. }
  41317. // RemovedEdges returns all edge names that were removed in this mutation.
  41318. func (m *WpChatroomMutation) RemovedEdges() []string {
  41319. edges := make([]string, 0, 0)
  41320. return edges
  41321. }
  41322. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41323. // the given name in this mutation.
  41324. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  41325. return nil
  41326. }
  41327. // ClearedEdges returns all edge names that were cleared in this mutation.
  41328. func (m *WpChatroomMutation) ClearedEdges() []string {
  41329. edges := make([]string, 0, 0)
  41330. return edges
  41331. }
  41332. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41333. // was cleared in this mutation.
  41334. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  41335. return false
  41336. }
  41337. // ClearEdge clears the value of the edge with the given name. It returns an error
  41338. // if that edge is not defined in the schema.
  41339. func (m *WpChatroomMutation) ClearEdge(name string) error {
  41340. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  41341. }
  41342. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41343. // It returns an error if the edge is not defined in the schema.
  41344. func (m *WpChatroomMutation) ResetEdge(name string) error {
  41345. return fmt.Errorf("unknown WpChatroom edge %s", name)
  41346. }
  41347. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  41348. type WpChatroomMemberMutation struct {
  41349. config
  41350. op Op
  41351. typ string
  41352. id *uint64
  41353. created_at *time.Time
  41354. updated_at *time.Time
  41355. status *uint8
  41356. addstatus *int8
  41357. wx_wxid *string
  41358. wxid *string
  41359. nickname *string
  41360. avatar *string
  41361. clearedFields map[string]struct{}
  41362. done bool
  41363. oldValue func(context.Context) (*WpChatroomMember, error)
  41364. predicates []predicate.WpChatroomMember
  41365. }
  41366. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  41367. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  41368. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  41369. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  41370. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  41371. m := &WpChatroomMemberMutation{
  41372. config: c,
  41373. op: op,
  41374. typ: TypeWpChatroomMember,
  41375. clearedFields: make(map[string]struct{}),
  41376. }
  41377. for _, opt := range opts {
  41378. opt(m)
  41379. }
  41380. return m
  41381. }
  41382. // withWpChatroomMemberID sets the ID field of the mutation.
  41383. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  41384. return func(m *WpChatroomMemberMutation) {
  41385. var (
  41386. err error
  41387. once sync.Once
  41388. value *WpChatroomMember
  41389. )
  41390. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  41391. once.Do(func() {
  41392. if m.done {
  41393. err = errors.New("querying old values post mutation is not allowed")
  41394. } else {
  41395. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  41396. }
  41397. })
  41398. return value, err
  41399. }
  41400. m.id = &id
  41401. }
  41402. }
  41403. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  41404. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  41405. return func(m *WpChatroomMemberMutation) {
  41406. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  41407. return node, nil
  41408. }
  41409. m.id = &node.ID
  41410. }
  41411. }
  41412. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41413. // executed in a transaction (ent.Tx), a transactional client is returned.
  41414. func (m WpChatroomMemberMutation) Client() *Client {
  41415. client := &Client{config: m.config}
  41416. client.init()
  41417. return client
  41418. }
  41419. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41420. // it returns an error otherwise.
  41421. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  41422. if _, ok := m.driver.(*txDriver); !ok {
  41423. return nil, errors.New("ent: mutation is not running in a transaction")
  41424. }
  41425. tx := &Tx{config: m.config}
  41426. tx.init()
  41427. return tx, nil
  41428. }
  41429. // SetID sets the value of the id field. Note that this
  41430. // operation is only accepted on creation of WpChatroomMember entities.
  41431. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  41432. m.id = &id
  41433. }
  41434. // ID returns the ID value in the mutation. Note that the ID is only available
  41435. // if it was provided to the builder or after it was returned from the database.
  41436. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  41437. if m.id == nil {
  41438. return
  41439. }
  41440. return *m.id, true
  41441. }
  41442. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41443. // That means, if the mutation is applied within a transaction with an isolation level such
  41444. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41445. // or updated by the mutation.
  41446. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  41447. switch {
  41448. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41449. id, exists := m.ID()
  41450. if exists {
  41451. return []uint64{id}, nil
  41452. }
  41453. fallthrough
  41454. case m.op.Is(OpUpdate | OpDelete):
  41455. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  41456. default:
  41457. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41458. }
  41459. }
  41460. // SetCreatedAt sets the "created_at" field.
  41461. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  41462. m.created_at = &t
  41463. }
  41464. // CreatedAt returns the value of the "created_at" field in the mutation.
  41465. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  41466. v := m.created_at
  41467. if v == nil {
  41468. return
  41469. }
  41470. return *v, true
  41471. }
  41472. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  41473. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41475. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41476. if !m.op.Is(OpUpdateOne) {
  41477. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41478. }
  41479. if m.id == nil || m.oldValue == nil {
  41480. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41481. }
  41482. oldValue, err := m.oldValue(ctx)
  41483. if err != nil {
  41484. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41485. }
  41486. return oldValue.CreatedAt, nil
  41487. }
  41488. // ResetCreatedAt resets all changes to the "created_at" field.
  41489. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  41490. m.created_at = nil
  41491. }
  41492. // SetUpdatedAt sets the "updated_at" field.
  41493. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  41494. m.updated_at = &t
  41495. }
  41496. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41497. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  41498. v := m.updated_at
  41499. if v == nil {
  41500. return
  41501. }
  41502. return *v, true
  41503. }
  41504. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  41505. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41507. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41508. if !m.op.Is(OpUpdateOne) {
  41509. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41510. }
  41511. if m.id == nil || m.oldValue == nil {
  41512. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41513. }
  41514. oldValue, err := m.oldValue(ctx)
  41515. if err != nil {
  41516. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41517. }
  41518. return oldValue.UpdatedAt, nil
  41519. }
  41520. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41521. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  41522. m.updated_at = nil
  41523. }
  41524. // SetStatus sets the "status" field.
  41525. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  41526. m.status = &u
  41527. m.addstatus = nil
  41528. }
  41529. // Status returns the value of the "status" field in the mutation.
  41530. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  41531. v := m.status
  41532. if v == nil {
  41533. return
  41534. }
  41535. return *v, true
  41536. }
  41537. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  41538. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41540. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41541. if !m.op.Is(OpUpdateOne) {
  41542. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41543. }
  41544. if m.id == nil || m.oldValue == nil {
  41545. return v, errors.New("OldStatus requires an ID field in the mutation")
  41546. }
  41547. oldValue, err := m.oldValue(ctx)
  41548. if err != nil {
  41549. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41550. }
  41551. return oldValue.Status, nil
  41552. }
  41553. // AddStatus adds u to the "status" field.
  41554. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  41555. if m.addstatus != nil {
  41556. *m.addstatus += u
  41557. } else {
  41558. m.addstatus = &u
  41559. }
  41560. }
  41561. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41562. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  41563. v := m.addstatus
  41564. if v == nil {
  41565. return
  41566. }
  41567. return *v, true
  41568. }
  41569. // ClearStatus clears the value of the "status" field.
  41570. func (m *WpChatroomMemberMutation) ClearStatus() {
  41571. m.status = nil
  41572. m.addstatus = nil
  41573. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  41574. }
  41575. // StatusCleared returns if the "status" field was cleared in this mutation.
  41576. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  41577. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  41578. return ok
  41579. }
  41580. // ResetStatus resets all changes to the "status" field.
  41581. func (m *WpChatroomMemberMutation) ResetStatus() {
  41582. m.status = nil
  41583. m.addstatus = nil
  41584. delete(m.clearedFields, wpchatroommember.FieldStatus)
  41585. }
  41586. // SetWxWxid sets the "wx_wxid" field.
  41587. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  41588. m.wx_wxid = &s
  41589. }
  41590. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  41591. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  41592. v := m.wx_wxid
  41593. if v == nil {
  41594. return
  41595. }
  41596. return *v, true
  41597. }
  41598. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  41599. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41601. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  41602. if !m.op.Is(OpUpdateOne) {
  41603. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  41604. }
  41605. if m.id == nil || m.oldValue == nil {
  41606. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  41607. }
  41608. oldValue, err := m.oldValue(ctx)
  41609. if err != nil {
  41610. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  41611. }
  41612. return oldValue.WxWxid, nil
  41613. }
  41614. // ResetWxWxid resets all changes to the "wx_wxid" field.
  41615. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  41616. m.wx_wxid = nil
  41617. }
  41618. // SetWxid sets the "wxid" field.
  41619. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  41620. m.wxid = &s
  41621. }
  41622. // Wxid returns the value of the "wxid" field in the mutation.
  41623. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  41624. v := m.wxid
  41625. if v == nil {
  41626. return
  41627. }
  41628. return *v, true
  41629. }
  41630. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  41631. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41633. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  41634. if !m.op.Is(OpUpdateOne) {
  41635. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41636. }
  41637. if m.id == nil || m.oldValue == nil {
  41638. return v, errors.New("OldWxid requires an ID field in the mutation")
  41639. }
  41640. oldValue, err := m.oldValue(ctx)
  41641. if err != nil {
  41642. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41643. }
  41644. return oldValue.Wxid, nil
  41645. }
  41646. // ResetWxid resets all changes to the "wxid" field.
  41647. func (m *WpChatroomMemberMutation) ResetWxid() {
  41648. m.wxid = nil
  41649. }
  41650. // SetNickname sets the "nickname" field.
  41651. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  41652. m.nickname = &s
  41653. }
  41654. // Nickname returns the value of the "nickname" field in the mutation.
  41655. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  41656. v := m.nickname
  41657. if v == nil {
  41658. return
  41659. }
  41660. return *v, true
  41661. }
  41662. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  41663. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41665. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  41666. if !m.op.Is(OpUpdateOne) {
  41667. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41668. }
  41669. if m.id == nil || m.oldValue == nil {
  41670. return v, errors.New("OldNickname requires an ID field in the mutation")
  41671. }
  41672. oldValue, err := m.oldValue(ctx)
  41673. if err != nil {
  41674. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41675. }
  41676. return oldValue.Nickname, nil
  41677. }
  41678. // ResetNickname resets all changes to the "nickname" field.
  41679. func (m *WpChatroomMemberMutation) ResetNickname() {
  41680. m.nickname = nil
  41681. }
  41682. // SetAvatar sets the "avatar" field.
  41683. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  41684. m.avatar = &s
  41685. }
  41686. // Avatar returns the value of the "avatar" field in the mutation.
  41687. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  41688. v := m.avatar
  41689. if v == nil {
  41690. return
  41691. }
  41692. return *v, true
  41693. }
  41694. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  41695. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41697. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41698. if !m.op.Is(OpUpdateOne) {
  41699. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41700. }
  41701. if m.id == nil || m.oldValue == nil {
  41702. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41703. }
  41704. oldValue, err := m.oldValue(ctx)
  41705. if err != nil {
  41706. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41707. }
  41708. return oldValue.Avatar, nil
  41709. }
  41710. // ResetAvatar resets all changes to the "avatar" field.
  41711. func (m *WpChatroomMemberMutation) ResetAvatar() {
  41712. m.avatar = nil
  41713. }
  41714. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  41715. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  41716. m.predicates = append(m.predicates, ps...)
  41717. }
  41718. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  41719. // users can use type-assertion to append predicates that do not depend on any generated package.
  41720. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  41721. p := make([]predicate.WpChatroomMember, len(ps))
  41722. for i := range ps {
  41723. p[i] = ps[i]
  41724. }
  41725. m.Where(p...)
  41726. }
  41727. // Op returns the operation name.
  41728. func (m *WpChatroomMemberMutation) Op() Op {
  41729. return m.op
  41730. }
  41731. // SetOp allows setting the mutation operation.
  41732. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  41733. m.op = op
  41734. }
  41735. // Type returns the node type of this mutation (WpChatroomMember).
  41736. func (m *WpChatroomMemberMutation) Type() string {
  41737. return m.typ
  41738. }
  41739. // Fields returns all fields that were changed during this mutation. Note that in
  41740. // order to get all numeric fields that were incremented/decremented, call
  41741. // AddedFields().
  41742. func (m *WpChatroomMemberMutation) Fields() []string {
  41743. fields := make([]string, 0, 7)
  41744. if m.created_at != nil {
  41745. fields = append(fields, wpchatroommember.FieldCreatedAt)
  41746. }
  41747. if m.updated_at != nil {
  41748. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  41749. }
  41750. if m.status != nil {
  41751. fields = append(fields, wpchatroommember.FieldStatus)
  41752. }
  41753. if m.wx_wxid != nil {
  41754. fields = append(fields, wpchatroommember.FieldWxWxid)
  41755. }
  41756. if m.wxid != nil {
  41757. fields = append(fields, wpchatroommember.FieldWxid)
  41758. }
  41759. if m.nickname != nil {
  41760. fields = append(fields, wpchatroommember.FieldNickname)
  41761. }
  41762. if m.avatar != nil {
  41763. fields = append(fields, wpchatroommember.FieldAvatar)
  41764. }
  41765. return fields
  41766. }
  41767. // Field returns the value of a field with the given name. The second boolean
  41768. // return value indicates that this field was not set, or was not defined in the
  41769. // schema.
  41770. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  41771. switch name {
  41772. case wpchatroommember.FieldCreatedAt:
  41773. return m.CreatedAt()
  41774. case wpchatroommember.FieldUpdatedAt:
  41775. return m.UpdatedAt()
  41776. case wpchatroommember.FieldStatus:
  41777. return m.Status()
  41778. case wpchatroommember.FieldWxWxid:
  41779. return m.WxWxid()
  41780. case wpchatroommember.FieldWxid:
  41781. return m.Wxid()
  41782. case wpchatroommember.FieldNickname:
  41783. return m.Nickname()
  41784. case wpchatroommember.FieldAvatar:
  41785. return m.Avatar()
  41786. }
  41787. return nil, false
  41788. }
  41789. // OldField returns the old value of the field from the database. An error is
  41790. // returned if the mutation operation is not UpdateOne, or the query to the
  41791. // database failed.
  41792. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41793. switch name {
  41794. case wpchatroommember.FieldCreatedAt:
  41795. return m.OldCreatedAt(ctx)
  41796. case wpchatroommember.FieldUpdatedAt:
  41797. return m.OldUpdatedAt(ctx)
  41798. case wpchatroommember.FieldStatus:
  41799. return m.OldStatus(ctx)
  41800. case wpchatroommember.FieldWxWxid:
  41801. return m.OldWxWxid(ctx)
  41802. case wpchatroommember.FieldWxid:
  41803. return m.OldWxid(ctx)
  41804. case wpchatroommember.FieldNickname:
  41805. return m.OldNickname(ctx)
  41806. case wpchatroommember.FieldAvatar:
  41807. return m.OldAvatar(ctx)
  41808. }
  41809. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  41810. }
  41811. // SetField sets the value of a field with the given name. It returns an error if
  41812. // the field is not defined in the schema, or if the type mismatched the field
  41813. // type.
  41814. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  41815. switch name {
  41816. case wpchatroommember.FieldCreatedAt:
  41817. v, ok := value.(time.Time)
  41818. if !ok {
  41819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41820. }
  41821. m.SetCreatedAt(v)
  41822. return nil
  41823. case wpchatroommember.FieldUpdatedAt:
  41824. v, ok := value.(time.Time)
  41825. if !ok {
  41826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41827. }
  41828. m.SetUpdatedAt(v)
  41829. return nil
  41830. case wpchatroommember.FieldStatus:
  41831. v, ok := value.(uint8)
  41832. if !ok {
  41833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41834. }
  41835. m.SetStatus(v)
  41836. return nil
  41837. case wpchatroommember.FieldWxWxid:
  41838. v, ok := value.(string)
  41839. if !ok {
  41840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41841. }
  41842. m.SetWxWxid(v)
  41843. return nil
  41844. case wpchatroommember.FieldWxid:
  41845. v, ok := value.(string)
  41846. if !ok {
  41847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41848. }
  41849. m.SetWxid(v)
  41850. return nil
  41851. case wpchatroommember.FieldNickname:
  41852. v, ok := value.(string)
  41853. if !ok {
  41854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41855. }
  41856. m.SetNickname(v)
  41857. return nil
  41858. case wpchatroommember.FieldAvatar:
  41859. v, ok := value.(string)
  41860. if !ok {
  41861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41862. }
  41863. m.SetAvatar(v)
  41864. return nil
  41865. }
  41866. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  41867. }
  41868. // AddedFields returns all numeric fields that were incremented/decremented during
  41869. // this mutation.
  41870. func (m *WpChatroomMemberMutation) AddedFields() []string {
  41871. var fields []string
  41872. if m.addstatus != nil {
  41873. fields = append(fields, wpchatroommember.FieldStatus)
  41874. }
  41875. return fields
  41876. }
  41877. // AddedField returns the numeric value that was incremented/decremented on a field
  41878. // with the given name. The second boolean return value indicates that this field
  41879. // was not set, or was not defined in the schema.
  41880. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  41881. switch name {
  41882. case wpchatroommember.FieldStatus:
  41883. return m.AddedStatus()
  41884. }
  41885. return nil, false
  41886. }
  41887. // AddField adds the value to the field with the given name. It returns an error if
  41888. // the field is not defined in the schema, or if the type mismatched the field
  41889. // type.
  41890. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  41891. switch name {
  41892. case wpchatroommember.FieldStatus:
  41893. v, ok := value.(int8)
  41894. if !ok {
  41895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41896. }
  41897. m.AddStatus(v)
  41898. return nil
  41899. }
  41900. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  41901. }
  41902. // ClearedFields returns all nullable fields that were cleared during this
  41903. // mutation.
  41904. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  41905. var fields []string
  41906. if m.FieldCleared(wpchatroommember.FieldStatus) {
  41907. fields = append(fields, wpchatroommember.FieldStatus)
  41908. }
  41909. return fields
  41910. }
  41911. // FieldCleared returns a boolean indicating if a field with the given name was
  41912. // cleared in this mutation.
  41913. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  41914. _, ok := m.clearedFields[name]
  41915. return ok
  41916. }
  41917. // ClearField clears the value of the field with the given name. It returns an
  41918. // error if the field is not defined in the schema.
  41919. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  41920. switch name {
  41921. case wpchatroommember.FieldStatus:
  41922. m.ClearStatus()
  41923. return nil
  41924. }
  41925. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  41926. }
  41927. // ResetField resets all changes in the mutation for the field with the given name.
  41928. // It returns an error if the field is not defined in the schema.
  41929. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  41930. switch name {
  41931. case wpchatroommember.FieldCreatedAt:
  41932. m.ResetCreatedAt()
  41933. return nil
  41934. case wpchatroommember.FieldUpdatedAt:
  41935. m.ResetUpdatedAt()
  41936. return nil
  41937. case wpchatroommember.FieldStatus:
  41938. m.ResetStatus()
  41939. return nil
  41940. case wpchatroommember.FieldWxWxid:
  41941. m.ResetWxWxid()
  41942. return nil
  41943. case wpchatroommember.FieldWxid:
  41944. m.ResetWxid()
  41945. return nil
  41946. case wpchatroommember.FieldNickname:
  41947. m.ResetNickname()
  41948. return nil
  41949. case wpchatroommember.FieldAvatar:
  41950. m.ResetAvatar()
  41951. return nil
  41952. }
  41953. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  41954. }
  41955. // AddedEdges returns all edge names that were set/added in this mutation.
  41956. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  41957. edges := make([]string, 0, 0)
  41958. return edges
  41959. }
  41960. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41961. // name in this mutation.
  41962. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  41963. return nil
  41964. }
  41965. // RemovedEdges returns all edge names that were removed in this mutation.
  41966. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  41967. edges := make([]string, 0, 0)
  41968. return edges
  41969. }
  41970. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41971. // the given name in this mutation.
  41972. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  41973. return nil
  41974. }
  41975. // ClearedEdges returns all edge names that were cleared in this mutation.
  41976. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  41977. edges := make([]string, 0, 0)
  41978. return edges
  41979. }
  41980. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41981. // was cleared in this mutation.
  41982. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  41983. return false
  41984. }
  41985. // ClearEdge clears the value of the edge with the given name. It returns an error
  41986. // if that edge is not defined in the schema.
  41987. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  41988. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  41989. }
  41990. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41991. // It returns an error if the edge is not defined in the schema.
  41992. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  41993. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  41994. }
  41995. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  41996. type WxMutation struct {
  41997. config
  41998. op Op
  41999. typ string
  42000. id *uint64
  42001. created_at *time.Time
  42002. updated_at *time.Time
  42003. status *uint8
  42004. addstatus *int8
  42005. deleted_at *time.Time
  42006. port *string
  42007. process_id *string
  42008. callback *string
  42009. wxid *string
  42010. account *string
  42011. nickname *string
  42012. tel *string
  42013. head_big *string
  42014. organization_id *uint64
  42015. addorganization_id *int64
  42016. api_base *string
  42017. api_key *string
  42018. allow_list *[]string
  42019. appendallow_list []string
  42020. group_allow_list *[]string
  42021. appendgroup_allow_list []string
  42022. block_list *[]string
  42023. appendblock_list []string
  42024. group_block_list *[]string
  42025. appendgroup_block_list []string
  42026. ctype *uint64
  42027. addctype *int64
  42028. clearedFields map[string]struct{}
  42029. server *uint64
  42030. clearedserver bool
  42031. agent *uint64
  42032. clearedagent bool
  42033. done bool
  42034. oldValue func(context.Context) (*Wx, error)
  42035. predicates []predicate.Wx
  42036. }
  42037. var _ ent.Mutation = (*WxMutation)(nil)
  42038. // wxOption allows management of the mutation configuration using functional options.
  42039. type wxOption func(*WxMutation)
  42040. // newWxMutation creates new mutation for the Wx entity.
  42041. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  42042. m := &WxMutation{
  42043. config: c,
  42044. op: op,
  42045. typ: TypeWx,
  42046. clearedFields: make(map[string]struct{}),
  42047. }
  42048. for _, opt := range opts {
  42049. opt(m)
  42050. }
  42051. return m
  42052. }
  42053. // withWxID sets the ID field of the mutation.
  42054. func withWxID(id uint64) wxOption {
  42055. return func(m *WxMutation) {
  42056. var (
  42057. err error
  42058. once sync.Once
  42059. value *Wx
  42060. )
  42061. m.oldValue = func(ctx context.Context) (*Wx, error) {
  42062. once.Do(func() {
  42063. if m.done {
  42064. err = errors.New("querying old values post mutation is not allowed")
  42065. } else {
  42066. value, err = m.Client().Wx.Get(ctx, id)
  42067. }
  42068. })
  42069. return value, err
  42070. }
  42071. m.id = &id
  42072. }
  42073. }
  42074. // withWx sets the old Wx of the mutation.
  42075. func withWx(node *Wx) wxOption {
  42076. return func(m *WxMutation) {
  42077. m.oldValue = func(context.Context) (*Wx, error) {
  42078. return node, nil
  42079. }
  42080. m.id = &node.ID
  42081. }
  42082. }
  42083. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42084. // executed in a transaction (ent.Tx), a transactional client is returned.
  42085. func (m WxMutation) Client() *Client {
  42086. client := &Client{config: m.config}
  42087. client.init()
  42088. return client
  42089. }
  42090. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42091. // it returns an error otherwise.
  42092. func (m WxMutation) Tx() (*Tx, error) {
  42093. if _, ok := m.driver.(*txDriver); !ok {
  42094. return nil, errors.New("ent: mutation is not running in a transaction")
  42095. }
  42096. tx := &Tx{config: m.config}
  42097. tx.init()
  42098. return tx, nil
  42099. }
  42100. // SetID sets the value of the id field. Note that this
  42101. // operation is only accepted on creation of Wx entities.
  42102. func (m *WxMutation) SetID(id uint64) {
  42103. m.id = &id
  42104. }
  42105. // ID returns the ID value in the mutation. Note that the ID is only available
  42106. // if it was provided to the builder or after it was returned from the database.
  42107. func (m *WxMutation) ID() (id uint64, exists bool) {
  42108. if m.id == nil {
  42109. return
  42110. }
  42111. return *m.id, true
  42112. }
  42113. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42114. // That means, if the mutation is applied within a transaction with an isolation level such
  42115. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42116. // or updated by the mutation.
  42117. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  42118. switch {
  42119. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42120. id, exists := m.ID()
  42121. if exists {
  42122. return []uint64{id}, nil
  42123. }
  42124. fallthrough
  42125. case m.op.Is(OpUpdate | OpDelete):
  42126. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  42127. default:
  42128. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42129. }
  42130. }
  42131. // SetCreatedAt sets the "created_at" field.
  42132. func (m *WxMutation) SetCreatedAt(t time.Time) {
  42133. m.created_at = &t
  42134. }
  42135. // CreatedAt returns the value of the "created_at" field in the mutation.
  42136. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  42137. v := m.created_at
  42138. if v == nil {
  42139. return
  42140. }
  42141. return *v, true
  42142. }
  42143. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  42144. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42146. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42147. if !m.op.Is(OpUpdateOne) {
  42148. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42149. }
  42150. if m.id == nil || m.oldValue == nil {
  42151. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42152. }
  42153. oldValue, err := m.oldValue(ctx)
  42154. if err != nil {
  42155. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42156. }
  42157. return oldValue.CreatedAt, nil
  42158. }
  42159. // ResetCreatedAt resets all changes to the "created_at" field.
  42160. func (m *WxMutation) ResetCreatedAt() {
  42161. m.created_at = nil
  42162. }
  42163. // SetUpdatedAt sets the "updated_at" field.
  42164. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  42165. m.updated_at = &t
  42166. }
  42167. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42168. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  42169. v := m.updated_at
  42170. if v == nil {
  42171. return
  42172. }
  42173. return *v, true
  42174. }
  42175. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  42176. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42178. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42179. if !m.op.Is(OpUpdateOne) {
  42180. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42181. }
  42182. if m.id == nil || m.oldValue == nil {
  42183. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42184. }
  42185. oldValue, err := m.oldValue(ctx)
  42186. if err != nil {
  42187. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42188. }
  42189. return oldValue.UpdatedAt, nil
  42190. }
  42191. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42192. func (m *WxMutation) ResetUpdatedAt() {
  42193. m.updated_at = nil
  42194. }
  42195. // SetStatus sets the "status" field.
  42196. func (m *WxMutation) SetStatus(u uint8) {
  42197. m.status = &u
  42198. m.addstatus = nil
  42199. }
  42200. // Status returns the value of the "status" field in the mutation.
  42201. func (m *WxMutation) Status() (r uint8, exists bool) {
  42202. v := m.status
  42203. if v == nil {
  42204. return
  42205. }
  42206. return *v, true
  42207. }
  42208. // OldStatus returns the old "status" field's value of the Wx entity.
  42209. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42211. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42212. if !m.op.Is(OpUpdateOne) {
  42213. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42214. }
  42215. if m.id == nil || m.oldValue == nil {
  42216. return v, errors.New("OldStatus requires an ID field in the mutation")
  42217. }
  42218. oldValue, err := m.oldValue(ctx)
  42219. if err != nil {
  42220. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42221. }
  42222. return oldValue.Status, nil
  42223. }
  42224. // AddStatus adds u to the "status" field.
  42225. func (m *WxMutation) AddStatus(u int8) {
  42226. if m.addstatus != nil {
  42227. *m.addstatus += u
  42228. } else {
  42229. m.addstatus = &u
  42230. }
  42231. }
  42232. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42233. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  42234. v := m.addstatus
  42235. if v == nil {
  42236. return
  42237. }
  42238. return *v, true
  42239. }
  42240. // ClearStatus clears the value of the "status" field.
  42241. func (m *WxMutation) ClearStatus() {
  42242. m.status = nil
  42243. m.addstatus = nil
  42244. m.clearedFields[wx.FieldStatus] = struct{}{}
  42245. }
  42246. // StatusCleared returns if the "status" field was cleared in this mutation.
  42247. func (m *WxMutation) StatusCleared() bool {
  42248. _, ok := m.clearedFields[wx.FieldStatus]
  42249. return ok
  42250. }
  42251. // ResetStatus resets all changes to the "status" field.
  42252. func (m *WxMutation) ResetStatus() {
  42253. m.status = nil
  42254. m.addstatus = nil
  42255. delete(m.clearedFields, wx.FieldStatus)
  42256. }
  42257. // SetDeletedAt sets the "deleted_at" field.
  42258. func (m *WxMutation) SetDeletedAt(t time.Time) {
  42259. m.deleted_at = &t
  42260. }
  42261. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42262. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  42263. v := m.deleted_at
  42264. if v == nil {
  42265. return
  42266. }
  42267. return *v, true
  42268. }
  42269. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  42270. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42272. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42273. if !m.op.Is(OpUpdateOne) {
  42274. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42275. }
  42276. if m.id == nil || m.oldValue == nil {
  42277. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42278. }
  42279. oldValue, err := m.oldValue(ctx)
  42280. if err != nil {
  42281. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42282. }
  42283. return oldValue.DeletedAt, nil
  42284. }
  42285. // ClearDeletedAt clears the value of the "deleted_at" field.
  42286. func (m *WxMutation) ClearDeletedAt() {
  42287. m.deleted_at = nil
  42288. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  42289. }
  42290. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42291. func (m *WxMutation) DeletedAtCleared() bool {
  42292. _, ok := m.clearedFields[wx.FieldDeletedAt]
  42293. return ok
  42294. }
  42295. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42296. func (m *WxMutation) ResetDeletedAt() {
  42297. m.deleted_at = nil
  42298. delete(m.clearedFields, wx.FieldDeletedAt)
  42299. }
  42300. // SetServerID sets the "server_id" field.
  42301. func (m *WxMutation) SetServerID(u uint64) {
  42302. m.server = &u
  42303. }
  42304. // ServerID returns the value of the "server_id" field in the mutation.
  42305. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  42306. v := m.server
  42307. if v == nil {
  42308. return
  42309. }
  42310. return *v, true
  42311. }
  42312. // OldServerID returns the old "server_id" field's value of the Wx entity.
  42313. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42315. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  42316. if !m.op.Is(OpUpdateOne) {
  42317. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  42318. }
  42319. if m.id == nil || m.oldValue == nil {
  42320. return v, errors.New("OldServerID requires an ID field in the mutation")
  42321. }
  42322. oldValue, err := m.oldValue(ctx)
  42323. if err != nil {
  42324. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  42325. }
  42326. return oldValue.ServerID, nil
  42327. }
  42328. // ClearServerID clears the value of the "server_id" field.
  42329. func (m *WxMutation) ClearServerID() {
  42330. m.server = nil
  42331. m.clearedFields[wx.FieldServerID] = struct{}{}
  42332. }
  42333. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  42334. func (m *WxMutation) ServerIDCleared() bool {
  42335. _, ok := m.clearedFields[wx.FieldServerID]
  42336. return ok
  42337. }
  42338. // ResetServerID resets all changes to the "server_id" field.
  42339. func (m *WxMutation) ResetServerID() {
  42340. m.server = nil
  42341. delete(m.clearedFields, wx.FieldServerID)
  42342. }
  42343. // SetPort sets the "port" field.
  42344. func (m *WxMutation) SetPort(s string) {
  42345. m.port = &s
  42346. }
  42347. // Port returns the value of the "port" field in the mutation.
  42348. func (m *WxMutation) Port() (r string, exists bool) {
  42349. v := m.port
  42350. if v == nil {
  42351. return
  42352. }
  42353. return *v, true
  42354. }
  42355. // OldPort returns the old "port" field's value of the Wx entity.
  42356. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42358. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  42359. if !m.op.Is(OpUpdateOne) {
  42360. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  42361. }
  42362. if m.id == nil || m.oldValue == nil {
  42363. return v, errors.New("OldPort requires an ID field in the mutation")
  42364. }
  42365. oldValue, err := m.oldValue(ctx)
  42366. if err != nil {
  42367. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  42368. }
  42369. return oldValue.Port, nil
  42370. }
  42371. // ResetPort resets all changes to the "port" field.
  42372. func (m *WxMutation) ResetPort() {
  42373. m.port = nil
  42374. }
  42375. // SetProcessID sets the "process_id" field.
  42376. func (m *WxMutation) SetProcessID(s string) {
  42377. m.process_id = &s
  42378. }
  42379. // ProcessID returns the value of the "process_id" field in the mutation.
  42380. func (m *WxMutation) ProcessID() (r string, exists bool) {
  42381. v := m.process_id
  42382. if v == nil {
  42383. return
  42384. }
  42385. return *v, true
  42386. }
  42387. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  42388. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42390. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  42391. if !m.op.Is(OpUpdateOne) {
  42392. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  42393. }
  42394. if m.id == nil || m.oldValue == nil {
  42395. return v, errors.New("OldProcessID requires an ID field in the mutation")
  42396. }
  42397. oldValue, err := m.oldValue(ctx)
  42398. if err != nil {
  42399. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  42400. }
  42401. return oldValue.ProcessID, nil
  42402. }
  42403. // ResetProcessID resets all changes to the "process_id" field.
  42404. func (m *WxMutation) ResetProcessID() {
  42405. m.process_id = nil
  42406. }
  42407. // SetCallback sets the "callback" field.
  42408. func (m *WxMutation) SetCallback(s string) {
  42409. m.callback = &s
  42410. }
  42411. // Callback returns the value of the "callback" field in the mutation.
  42412. func (m *WxMutation) Callback() (r string, exists bool) {
  42413. v := m.callback
  42414. if v == nil {
  42415. return
  42416. }
  42417. return *v, true
  42418. }
  42419. // OldCallback returns the old "callback" field's value of the Wx entity.
  42420. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42422. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  42423. if !m.op.Is(OpUpdateOne) {
  42424. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  42425. }
  42426. if m.id == nil || m.oldValue == nil {
  42427. return v, errors.New("OldCallback requires an ID field in the mutation")
  42428. }
  42429. oldValue, err := m.oldValue(ctx)
  42430. if err != nil {
  42431. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  42432. }
  42433. return oldValue.Callback, nil
  42434. }
  42435. // ResetCallback resets all changes to the "callback" field.
  42436. func (m *WxMutation) ResetCallback() {
  42437. m.callback = nil
  42438. }
  42439. // SetWxid sets the "wxid" field.
  42440. func (m *WxMutation) SetWxid(s string) {
  42441. m.wxid = &s
  42442. }
  42443. // Wxid returns the value of the "wxid" field in the mutation.
  42444. func (m *WxMutation) Wxid() (r string, exists bool) {
  42445. v := m.wxid
  42446. if v == nil {
  42447. return
  42448. }
  42449. return *v, true
  42450. }
  42451. // OldWxid returns the old "wxid" field's value of the Wx entity.
  42452. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42454. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  42455. if !m.op.Is(OpUpdateOne) {
  42456. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  42457. }
  42458. if m.id == nil || m.oldValue == nil {
  42459. return v, errors.New("OldWxid requires an ID field in the mutation")
  42460. }
  42461. oldValue, err := m.oldValue(ctx)
  42462. if err != nil {
  42463. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  42464. }
  42465. return oldValue.Wxid, nil
  42466. }
  42467. // ResetWxid resets all changes to the "wxid" field.
  42468. func (m *WxMutation) ResetWxid() {
  42469. m.wxid = nil
  42470. }
  42471. // SetAccount sets the "account" field.
  42472. func (m *WxMutation) SetAccount(s string) {
  42473. m.account = &s
  42474. }
  42475. // Account returns the value of the "account" field in the mutation.
  42476. func (m *WxMutation) Account() (r string, exists bool) {
  42477. v := m.account
  42478. if v == nil {
  42479. return
  42480. }
  42481. return *v, true
  42482. }
  42483. // OldAccount returns the old "account" field's value of the Wx entity.
  42484. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42486. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  42487. if !m.op.Is(OpUpdateOne) {
  42488. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  42489. }
  42490. if m.id == nil || m.oldValue == nil {
  42491. return v, errors.New("OldAccount requires an ID field in the mutation")
  42492. }
  42493. oldValue, err := m.oldValue(ctx)
  42494. if err != nil {
  42495. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  42496. }
  42497. return oldValue.Account, nil
  42498. }
  42499. // ResetAccount resets all changes to the "account" field.
  42500. func (m *WxMutation) ResetAccount() {
  42501. m.account = nil
  42502. }
  42503. // SetNickname sets the "nickname" field.
  42504. func (m *WxMutation) SetNickname(s string) {
  42505. m.nickname = &s
  42506. }
  42507. // Nickname returns the value of the "nickname" field in the mutation.
  42508. func (m *WxMutation) Nickname() (r string, exists bool) {
  42509. v := m.nickname
  42510. if v == nil {
  42511. return
  42512. }
  42513. return *v, true
  42514. }
  42515. // OldNickname returns the old "nickname" field's value of the Wx entity.
  42516. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42518. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  42519. if !m.op.Is(OpUpdateOne) {
  42520. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  42521. }
  42522. if m.id == nil || m.oldValue == nil {
  42523. return v, errors.New("OldNickname requires an ID field in the mutation")
  42524. }
  42525. oldValue, err := m.oldValue(ctx)
  42526. if err != nil {
  42527. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  42528. }
  42529. return oldValue.Nickname, nil
  42530. }
  42531. // ResetNickname resets all changes to the "nickname" field.
  42532. func (m *WxMutation) ResetNickname() {
  42533. m.nickname = nil
  42534. }
  42535. // SetTel sets the "tel" field.
  42536. func (m *WxMutation) SetTel(s string) {
  42537. m.tel = &s
  42538. }
  42539. // Tel returns the value of the "tel" field in the mutation.
  42540. func (m *WxMutation) Tel() (r string, exists bool) {
  42541. v := m.tel
  42542. if v == nil {
  42543. return
  42544. }
  42545. return *v, true
  42546. }
  42547. // OldTel returns the old "tel" field's value of the Wx entity.
  42548. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42550. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  42551. if !m.op.Is(OpUpdateOne) {
  42552. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  42553. }
  42554. if m.id == nil || m.oldValue == nil {
  42555. return v, errors.New("OldTel requires an ID field in the mutation")
  42556. }
  42557. oldValue, err := m.oldValue(ctx)
  42558. if err != nil {
  42559. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  42560. }
  42561. return oldValue.Tel, nil
  42562. }
  42563. // ResetTel resets all changes to the "tel" field.
  42564. func (m *WxMutation) ResetTel() {
  42565. m.tel = nil
  42566. }
  42567. // SetHeadBig sets the "head_big" field.
  42568. func (m *WxMutation) SetHeadBig(s string) {
  42569. m.head_big = &s
  42570. }
  42571. // HeadBig returns the value of the "head_big" field in the mutation.
  42572. func (m *WxMutation) HeadBig() (r string, exists bool) {
  42573. v := m.head_big
  42574. if v == nil {
  42575. return
  42576. }
  42577. return *v, true
  42578. }
  42579. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  42580. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42582. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  42583. if !m.op.Is(OpUpdateOne) {
  42584. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  42585. }
  42586. if m.id == nil || m.oldValue == nil {
  42587. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  42588. }
  42589. oldValue, err := m.oldValue(ctx)
  42590. if err != nil {
  42591. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  42592. }
  42593. return oldValue.HeadBig, nil
  42594. }
  42595. // ResetHeadBig resets all changes to the "head_big" field.
  42596. func (m *WxMutation) ResetHeadBig() {
  42597. m.head_big = nil
  42598. }
  42599. // SetOrganizationID sets the "organization_id" field.
  42600. func (m *WxMutation) SetOrganizationID(u uint64) {
  42601. m.organization_id = &u
  42602. m.addorganization_id = nil
  42603. }
  42604. // OrganizationID returns the value of the "organization_id" field in the mutation.
  42605. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  42606. v := m.organization_id
  42607. if v == nil {
  42608. return
  42609. }
  42610. return *v, true
  42611. }
  42612. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  42613. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42615. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  42616. if !m.op.Is(OpUpdateOne) {
  42617. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  42618. }
  42619. if m.id == nil || m.oldValue == nil {
  42620. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  42621. }
  42622. oldValue, err := m.oldValue(ctx)
  42623. if err != nil {
  42624. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  42625. }
  42626. return oldValue.OrganizationID, nil
  42627. }
  42628. // AddOrganizationID adds u to the "organization_id" field.
  42629. func (m *WxMutation) AddOrganizationID(u int64) {
  42630. if m.addorganization_id != nil {
  42631. *m.addorganization_id += u
  42632. } else {
  42633. m.addorganization_id = &u
  42634. }
  42635. }
  42636. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  42637. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  42638. v := m.addorganization_id
  42639. if v == nil {
  42640. return
  42641. }
  42642. return *v, true
  42643. }
  42644. // ClearOrganizationID clears the value of the "organization_id" field.
  42645. func (m *WxMutation) ClearOrganizationID() {
  42646. m.organization_id = nil
  42647. m.addorganization_id = nil
  42648. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  42649. }
  42650. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  42651. func (m *WxMutation) OrganizationIDCleared() bool {
  42652. _, ok := m.clearedFields[wx.FieldOrganizationID]
  42653. return ok
  42654. }
  42655. // ResetOrganizationID resets all changes to the "organization_id" field.
  42656. func (m *WxMutation) ResetOrganizationID() {
  42657. m.organization_id = nil
  42658. m.addorganization_id = nil
  42659. delete(m.clearedFields, wx.FieldOrganizationID)
  42660. }
  42661. // SetAgentID sets the "agent_id" field.
  42662. func (m *WxMutation) SetAgentID(u uint64) {
  42663. m.agent = &u
  42664. }
  42665. // AgentID returns the value of the "agent_id" field in the mutation.
  42666. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  42667. v := m.agent
  42668. if v == nil {
  42669. return
  42670. }
  42671. return *v, true
  42672. }
  42673. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  42674. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42676. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  42677. if !m.op.Is(OpUpdateOne) {
  42678. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  42679. }
  42680. if m.id == nil || m.oldValue == nil {
  42681. return v, errors.New("OldAgentID requires an ID field in the mutation")
  42682. }
  42683. oldValue, err := m.oldValue(ctx)
  42684. if err != nil {
  42685. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  42686. }
  42687. return oldValue.AgentID, nil
  42688. }
  42689. // ResetAgentID resets all changes to the "agent_id" field.
  42690. func (m *WxMutation) ResetAgentID() {
  42691. m.agent = nil
  42692. }
  42693. // SetAPIBase sets the "api_base" field.
  42694. func (m *WxMutation) SetAPIBase(s string) {
  42695. m.api_base = &s
  42696. }
  42697. // APIBase returns the value of the "api_base" field in the mutation.
  42698. func (m *WxMutation) APIBase() (r string, exists bool) {
  42699. v := m.api_base
  42700. if v == nil {
  42701. return
  42702. }
  42703. return *v, true
  42704. }
  42705. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  42706. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42708. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42709. if !m.op.Is(OpUpdateOne) {
  42710. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42711. }
  42712. if m.id == nil || m.oldValue == nil {
  42713. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42714. }
  42715. oldValue, err := m.oldValue(ctx)
  42716. if err != nil {
  42717. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42718. }
  42719. return oldValue.APIBase, nil
  42720. }
  42721. // ClearAPIBase clears the value of the "api_base" field.
  42722. func (m *WxMutation) ClearAPIBase() {
  42723. m.api_base = nil
  42724. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  42725. }
  42726. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42727. func (m *WxMutation) APIBaseCleared() bool {
  42728. _, ok := m.clearedFields[wx.FieldAPIBase]
  42729. return ok
  42730. }
  42731. // ResetAPIBase resets all changes to the "api_base" field.
  42732. func (m *WxMutation) ResetAPIBase() {
  42733. m.api_base = nil
  42734. delete(m.clearedFields, wx.FieldAPIBase)
  42735. }
  42736. // SetAPIKey sets the "api_key" field.
  42737. func (m *WxMutation) SetAPIKey(s string) {
  42738. m.api_key = &s
  42739. }
  42740. // APIKey returns the value of the "api_key" field in the mutation.
  42741. func (m *WxMutation) APIKey() (r string, exists bool) {
  42742. v := m.api_key
  42743. if v == nil {
  42744. return
  42745. }
  42746. return *v, true
  42747. }
  42748. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  42749. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42751. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42752. if !m.op.Is(OpUpdateOne) {
  42753. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42754. }
  42755. if m.id == nil || m.oldValue == nil {
  42756. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42757. }
  42758. oldValue, err := m.oldValue(ctx)
  42759. if err != nil {
  42760. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42761. }
  42762. return oldValue.APIKey, nil
  42763. }
  42764. // ClearAPIKey clears the value of the "api_key" field.
  42765. func (m *WxMutation) ClearAPIKey() {
  42766. m.api_key = nil
  42767. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  42768. }
  42769. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42770. func (m *WxMutation) APIKeyCleared() bool {
  42771. _, ok := m.clearedFields[wx.FieldAPIKey]
  42772. return ok
  42773. }
  42774. // ResetAPIKey resets all changes to the "api_key" field.
  42775. func (m *WxMutation) ResetAPIKey() {
  42776. m.api_key = nil
  42777. delete(m.clearedFields, wx.FieldAPIKey)
  42778. }
  42779. // SetAllowList sets the "allow_list" field.
  42780. func (m *WxMutation) SetAllowList(s []string) {
  42781. m.allow_list = &s
  42782. m.appendallow_list = nil
  42783. }
  42784. // AllowList returns the value of the "allow_list" field in the mutation.
  42785. func (m *WxMutation) AllowList() (r []string, exists bool) {
  42786. v := m.allow_list
  42787. if v == nil {
  42788. return
  42789. }
  42790. return *v, true
  42791. }
  42792. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  42793. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42795. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  42796. if !m.op.Is(OpUpdateOne) {
  42797. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  42798. }
  42799. if m.id == nil || m.oldValue == nil {
  42800. return v, errors.New("OldAllowList requires an ID field in the mutation")
  42801. }
  42802. oldValue, err := m.oldValue(ctx)
  42803. if err != nil {
  42804. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  42805. }
  42806. return oldValue.AllowList, nil
  42807. }
  42808. // AppendAllowList adds s to the "allow_list" field.
  42809. func (m *WxMutation) AppendAllowList(s []string) {
  42810. m.appendallow_list = append(m.appendallow_list, s...)
  42811. }
  42812. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  42813. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  42814. if len(m.appendallow_list) == 0 {
  42815. return nil, false
  42816. }
  42817. return m.appendallow_list, true
  42818. }
  42819. // ResetAllowList resets all changes to the "allow_list" field.
  42820. func (m *WxMutation) ResetAllowList() {
  42821. m.allow_list = nil
  42822. m.appendallow_list = nil
  42823. }
  42824. // SetGroupAllowList sets the "group_allow_list" field.
  42825. func (m *WxMutation) SetGroupAllowList(s []string) {
  42826. m.group_allow_list = &s
  42827. m.appendgroup_allow_list = nil
  42828. }
  42829. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  42830. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  42831. v := m.group_allow_list
  42832. if v == nil {
  42833. return
  42834. }
  42835. return *v, true
  42836. }
  42837. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  42838. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42840. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  42841. if !m.op.Is(OpUpdateOne) {
  42842. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  42843. }
  42844. if m.id == nil || m.oldValue == nil {
  42845. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  42846. }
  42847. oldValue, err := m.oldValue(ctx)
  42848. if err != nil {
  42849. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  42850. }
  42851. return oldValue.GroupAllowList, nil
  42852. }
  42853. // AppendGroupAllowList adds s to the "group_allow_list" field.
  42854. func (m *WxMutation) AppendGroupAllowList(s []string) {
  42855. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  42856. }
  42857. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  42858. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  42859. if len(m.appendgroup_allow_list) == 0 {
  42860. return nil, false
  42861. }
  42862. return m.appendgroup_allow_list, true
  42863. }
  42864. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  42865. func (m *WxMutation) ResetGroupAllowList() {
  42866. m.group_allow_list = nil
  42867. m.appendgroup_allow_list = nil
  42868. }
  42869. // SetBlockList sets the "block_list" field.
  42870. func (m *WxMutation) SetBlockList(s []string) {
  42871. m.block_list = &s
  42872. m.appendblock_list = nil
  42873. }
  42874. // BlockList returns the value of the "block_list" field in the mutation.
  42875. func (m *WxMutation) BlockList() (r []string, exists bool) {
  42876. v := m.block_list
  42877. if v == nil {
  42878. return
  42879. }
  42880. return *v, true
  42881. }
  42882. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  42883. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42885. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  42886. if !m.op.Is(OpUpdateOne) {
  42887. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  42888. }
  42889. if m.id == nil || m.oldValue == nil {
  42890. return v, errors.New("OldBlockList requires an ID field in the mutation")
  42891. }
  42892. oldValue, err := m.oldValue(ctx)
  42893. if err != nil {
  42894. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  42895. }
  42896. return oldValue.BlockList, nil
  42897. }
  42898. // AppendBlockList adds s to the "block_list" field.
  42899. func (m *WxMutation) AppendBlockList(s []string) {
  42900. m.appendblock_list = append(m.appendblock_list, s...)
  42901. }
  42902. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  42903. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  42904. if len(m.appendblock_list) == 0 {
  42905. return nil, false
  42906. }
  42907. return m.appendblock_list, true
  42908. }
  42909. // ResetBlockList resets all changes to the "block_list" field.
  42910. func (m *WxMutation) ResetBlockList() {
  42911. m.block_list = nil
  42912. m.appendblock_list = nil
  42913. }
  42914. // SetGroupBlockList sets the "group_block_list" field.
  42915. func (m *WxMutation) SetGroupBlockList(s []string) {
  42916. m.group_block_list = &s
  42917. m.appendgroup_block_list = nil
  42918. }
  42919. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  42920. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  42921. v := m.group_block_list
  42922. if v == nil {
  42923. return
  42924. }
  42925. return *v, true
  42926. }
  42927. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  42928. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42930. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  42931. if !m.op.Is(OpUpdateOne) {
  42932. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  42933. }
  42934. if m.id == nil || m.oldValue == nil {
  42935. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  42936. }
  42937. oldValue, err := m.oldValue(ctx)
  42938. if err != nil {
  42939. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  42940. }
  42941. return oldValue.GroupBlockList, nil
  42942. }
  42943. // AppendGroupBlockList adds s to the "group_block_list" field.
  42944. func (m *WxMutation) AppendGroupBlockList(s []string) {
  42945. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  42946. }
  42947. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  42948. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  42949. if len(m.appendgroup_block_list) == 0 {
  42950. return nil, false
  42951. }
  42952. return m.appendgroup_block_list, true
  42953. }
  42954. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  42955. func (m *WxMutation) ResetGroupBlockList() {
  42956. m.group_block_list = nil
  42957. m.appendgroup_block_list = nil
  42958. }
  42959. // SetCtype sets the "ctype" field.
  42960. func (m *WxMutation) SetCtype(u uint64) {
  42961. m.ctype = &u
  42962. m.addctype = nil
  42963. }
  42964. // Ctype returns the value of the "ctype" field in the mutation.
  42965. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  42966. v := m.ctype
  42967. if v == nil {
  42968. return
  42969. }
  42970. return *v, true
  42971. }
  42972. // OldCtype returns the old "ctype" field's value of the Wx entity.
  42973. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42975. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  42976. if !m.op.Is(OpUpdateOne) {
  42977. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  42978. }
  42979. if m.id == nil || m.oldValue == nil {
  42980. return v, errors.New("OldCtype requires an ID field in the mutation")
  42981. }
  42982. oldValue, err := m.oldValue(ctx)
  42983. if err != nil {
  42984. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  42985. }
  42986. return oldValue.Ctype, nil
  42987. }
  42988. // AddCtype adds u to the "ctype" field.
  42989. func (m *WxMutation) AddCtype(u int64) {
  42990. if m.addctype != nil {
  42991. *m.addctype += u
  42992. } else {
  42993. m.addctype = &u
  42994. }
  42995. }
  42996. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  42997. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  42998. v := m.addctype
  42999. if v == nil {
  43000. return
  43001. }
  43002. return *v, true
  43003. }
  43004. // ClearCtype clears the value of the "ctype" field.
  43005. func (m *WxMutation) ClearCtype() {
  43006. m.ctype = nil
  43007. m.addctype = nil
  43008. m.clearedFields[wx.FieldCtype] = struct{}{}
  43009. }
  43010. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  43011. func (m *WxMutation) CtypeCleared() bool {
  43012. _, ok := m.clearedFields[wx.FieldCtype]
  43013. return ok
  43014. }
  43015. // ResetCtype resets all changes to the "ctype" field.
  43016. func (m *WxMutation) ResetCtype() {
  43017. m.ctype = nil
  43018. m.addctype = nil
  43019. delete(m.clearedFields, wx.FieldCtype)
  43020. }
  43021. // ClearServer clears the "server" edge to the Server entity.
  43022. func (m *WxMutation) ClearServer() {
  43023. m.clearedserver = true
  43024. m.clearedFields[wx.FieldServerID] = struct{}{}
  43025. }
  43026. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  43027. func (m *WxMutation) ServerCleared() bool {
  43028. return m.ServerIDCleared() || m.clearedserver
  43029. }
  43030. // ServerIDs returns the "server" edge IDs in the mutation.
  43031. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43032. // ServerID instead. It exists only for internal usage by the builders.
  43033. func (m *WxMutation) ServerIDs() (ids []uint64) {
  43034. if id := m.server; id != nil {
  43035. ids = append(ids, *id)
  43036. }
  43037. return
  43038. }
  43039. // ResetServer resets all changes to the "server" edge.
  43040. func (m *WxMutation) ResetServer() {
  43041. m.server = nil
  43042. m.clearedserver = false
  43043. }
  43044. // ClearAgent clears the "agent" edge to the Agent entity.
  43045. func (m *WxMutation) ClearAgent() {
  43046. m.clearedagent = true
  43047. m.clearedFields[wx.FieldAgentID] = struct{}{}
  43048. }
  43049. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  43050. func (m *WxMutation) AgentCleared() bool {
  43051. return m.clearedagent
  43052. }
  43053. // AgentIDs returns the "agent" edge IDs in the mutation.
  43054. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43055. // AgentID instead. It exists only for internal usage by the builders.
  43056. func (m *WxMutation) AgentIDs() (ids []uint64) {
  43057. if id := m.agent; id != nil {
  43058. ids = append(ids, *id)
  43059. }
  43060. return
  43061. }
  43062. // ResetAgent resets all changes to the "agent" edge.
  43063. func (m *WxMutation) ResetAgent() {
  43064. m.agent = nil
  43065. m.clearedagent = false
  43066. }
  43067. // Where appends a list predicates to the WxMutation builder.
  43068. func (m *WxMutation) Where(ps ...predicate.Wx) {
  43069. m.predicates = append(m.predicates, ps...)
  43070. }
  43071. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  43072. // users can use type-assertion to append predicates that do not depend on any generated package.
  43073. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  43074. p := make([]predicate.Wx, len(ps))
  43075. for i := range ps {
  43076. p[i] = ps[i]
  43077. }
  43078. m.Where(p...)
  43079. }
  43080. // Op returns the operation name.
  43081. func (m *WxMutation) Op() Op {
  43082. return m.op
  43083. }
  43084. // SetOp allows setting the mutation operation.
  43085. func (m *WxMutation) SetOp(op Op) {
  43086. m.op = op
  43087. }
  43088. // Type returns the node type of this mutation (Wx).
  43089. func (m *WxMutation) Type() string {
  43090. return m.typ
  43091. }
  43092. // Fields returns all fields that were changed during this mutation. Note that in
  43093. // order to get all numeric fields that were incremented/decremented, call
  43094. // AddedFields().
  43095. func (m *WxMutation) Fields() []string {
  43096. fields := make([]string, 0, 22)
  43097. if m.created_at != nil {
  43098. fields = append(fields, wx.FieldCreatedAt)
  43099. }
  43100. if m.updated_at != nil {
  43101. fields = append(fields, wx.FieldUpdatedAt)
  43102. }
  43103. if m.status != nil {
  43104. fields = append(fields, wx.FieldStatus)
  43105. }
  43106. if m.deleted_at != nil {
  43107. fields = append(fields, wx.FieldDeletedAt)
  43108. }
  43109. if m.server != nil {
  43110. fields = append(fields, wx.FieldServerID)
  43111. }
  43112. if m.port != nil {
  43113. fields = append(fields, wx.FieldPort)
  43114. }
  43115. if m.process_id != nil {
  43116. fields = append(fields, wx.FieldProcessID)
  43117. }
  43118. if m.callback != nil {
  43119. fields = append(fields, wx.FieldCallback)
  43120. }
  43121. if m.wxid != nil {
  43122. fields = append(fields, wx.FieldWxid)
  43123. }
  43124. if m.account != nil {
  43125. fields = append(fields, wx.FieldAccount)
  43126. }
  43127. if m.nickname != nil {
  43128. fields = append(fields, wx.FieldNickname)
  43129. }
  43130. if m.tel != nil {
  43131. fields = append(fields, wx.FieldTel)
  43132. }
  43133. if m.head_big != nil {
  43134. fields = append(fields, wx.FieldHeadBig)
  43135. }
  43136. if m.organization_id != nil {
  43137. fields = append(fields, wx.FieldOrganizationID)
  43138. }
  43139. if m.agent != nil {
  43140. fields = append(fields, wx.FieldAgentID)
  43141. }
  43142. if m.api_base != nil {
  43143. fields = append(fields, wx.FieldAPIBase)
  43144. }
  43145. if m.api_key != nil {
  43146. fields = append(fields, wx.FieldAPIKey)
  43147. }
  43148. if m.allow_list != nil {
  43149. fields = append(fields, wx.FieldAllowList)
  43150. }
  43151. if m.group_allow_list != nil {
  43152. fields = append(fields, wx.FieldGroupAllowList)
  43153. }
  43154. if m.block_list != nil {
  43155. fields = append(fields, wx.FieldBlockList)
  43156. }
  43157. if m.group_block_list != nil {
  43158. fields = append(fields, wx.FieldGroupBlockList)
  43159. }
  43160. if m.ctype != nil {
  43161. fields = append(fields, wx.FieldCtype)
  43162. }
  43163. return fields
  43164. }
  43165. // Field returns the value of a field with the given name. The second boolean
  43166. // return value indicates that this field was not set, or was not defined in the
  43167. // schema.
  43168. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  43169. switch name {
  43170. case wx.FieldCreatedAt:
  43171. return m.CreatedAt()
  43172. case wx.FieldUpdatedAt:
  43173. return m.UpdatedAt()
  43174. case wx.FieldStatus:
  43175. return m.Status()
  43176. case wx.FieldDeletedAt:
  43177. return m.DeletedAt()
  43178. case wx.FieldServerID:
  43179. return m.ServerID()
  43180. case wx.FieldPort:
  43181. return m.Port()
  43182. case wx.FieldProcessID:
  43183. return m.ProcessID()
  43184. case wx.FieldCallback:
  43185. return m.Callback()
  43186. case wx.FieldWxid:
  43187. return m.Wxid()
  43188. case wx.FieldAccount:
  43189. return m.Account()
  43190. case wx.FieldNickname:
  43191. return m.Nickname()
  43192. case wx.FieldTel:
  43193. return m.Tel()
  43194. case wx.FieldHeadBig:
  43195. return m.HeadBig()
  43196. case wx.FieldOrganizationID:
  43197. return m.OrganizationID()
  43198. case wx.FieldAgentID:
  43199. return m.AgentID()
  43200. case wx.FieldAPIBase:
  43201. return m.APIBase()
  43202. case wx.FieldAPIKey:
  43203. return m.APIKey()
  43204. case wx.FieldAllowList:
  43205. return m.AllowList()
  43206. case wx.FieldGroupAllowList:
  43207. return m.GroupAllowList()
  43208. case wx.FieldBlockList:
  43209. return m.BlockList()
  43210. case wx.FieldGroupBlockList:
  43211. return m.GroupBlockList()
  43212. case wx.FieldCtype:
  43213. return m.Ctype()
  43214. }
  43215. return nil, false
  43216. }
  43217. // OldField returns the old value of the field from the database. An error is
  43218. // returned if the mutation operation is not UpdateOne, or the query to the
  43219. // database failed.
  43220. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43221. switch name {
  43222. case wx.FieldCreatedAt:
  43223. return m.OldCreatedAt(ctx)
  43224. case wx.FieldUpdatedAt:
  43225. return m.OldUpdatedAt(ctx)
  43226. case wx.FieldStatus:
  43227. return m.OldStatus(ctx)
  43228. case wx.FieldDeletedAt:
  43229. return m.OldDeletedAt(ctx)
  43230. case wx.FieldServerID:
  43231. return m.OldServerID(ctx)
  43232. case wx.FieldPort:
  43233. return m.OldPort(ctx)
  43234. case wx.FieldProcessID:
  43235. return m.OldProcessID(ctx)
  43236. case wx.FieldCallback:
  43237. return m.OldCallback(ctx)
  43238. case wx.FieldWxid:
  43239. return m.OldWxid(ctx)
  43240. case wx.FieldAccount:
  43241. return m.OldAccount(ctx)
  43242. case wx.FieldNickname:
  43243. return m.OldNickname(ctx)
  43244. case wx.FieldTel:
  43245. return m.OldTel(ctx)
  43246. case wx.FieldHeadBig:
  43247. return m.OldHeadBig(ctx)
  43248. case wx.FieldOrganizationID:
  43249. return m.OldOrganizationID(ctx)
  43250. case wx.FieldAgentID:
  43251. return m.OldAgentID(ctx)
  43252. case wx.FieldAPIBase:
  43253. return m.OldAPIBase(ctx)
  43254. case wx.FieldAPIKey:
  43255. return m.OldAPIKey(ctx)
  43256. case wx.FieldAllowList:
  43257. return m.OldAllowList(ctx)
  43258. case wx.FieldGroupAllowList:
  43259. return m.OldGroupAllowList(ctx)
  43260. case wx.FieldBlockList:
  43261. return m.OldBlockList(ctx)
  43262. case wx.FieldGroupBlockList:
  43263. return m.OldGroupBlockList(ctx)
  43264. case wx.FieldCtype:
  43265. return m.OldCtype(ctx)
  43266. }
  43267. return nil, fmt.Errorf("unknown Wx field %s", name)
  43268. }
  43269. // SetField sets the value of a field with the given name. It returns an error if
  43270. // the field is not defined in the schema, or if the type mismatched the field
  43271. // type.
  43272. func (m *WxMutation) SetField(name string, value ent.Value) error {
  43273. switch name {
  43274. case wx.FieldCreatedAt:
  43275. v, ok := value.(time.Time)
  43276. if !ok {
  43277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43278. }
  43279. m.SetCreatedAt(v)
  43280. return nil
  43281. case wx.FieldUpdatedAt:
  43282. v, ok := value.(time.Time)
  43283. if !ok {
  43284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43285. }
  43286. m.SetUpdatedAt(v)
  43287. return nil
  43288. case wx.FieldStatus:
  43289. v, ok := value.(uint8)
  43290. if !ok {
  43291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43292. }
  43293. m.SetStatus(v)
  43294. return nil
  43295. case wx.FieldDeletedAt:
  43296. v, ok := value.(time.Time)
  43297. if !ok {
  43298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43299. }
  43300. m.SetDeletedAt(v)
  43301. return nil
  43302. case wx.FieldServerID:
  43303. v, ok := value.(uint64)
  43304. if !ok {
  43305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43306. }
  43307. m.SetServerID(v)
  43308. return nil
  43309. case wx.FieldPort:
  43310. v, ok := value.(string)
  43311. if !ok {
  43312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43313. }
  43314. m.SetPort(v)
  43315. return nil
  43316. case wx.FieldProcessID:
  43317. v, ok := value.(string)
  43318. if !ok {
  43319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43320. }
  43321. m.SetProcessID(v)
  43322. return nil
  43323. case wx.FieldCallback:
  43324. v, ok := value.(string)
  43325. if !ok {
  43326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43327. }
  43328. m.SetCallback(v)
  43329. return nil
  43330. case wx.FieldWxid:
  43331. v, ok := value.(string)
  43332. if !ok {
  43333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43334. }
  43335. m.SetWxid(v)
  43336. return nil
  43337. case wx.FieldAccount:
  43338. v, ok := value.(string)
  43339. if !ok {
  43340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43341. }
  43342. m.SetAccount(v)
  43343. return nil
  43344. case wx.FieldNickname:
  43345. v, ok := value.(string)
  43346. if !ok {
  43347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43348. }
  43349. m.SetNickname(v)
  43350. return nil
  43351. case wx.FieldTel:
  43352. v, ok := value.(string)
  43353. if !ok {
  43354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43355. }
  43356. m.SetTel(v)
  43357. return nil
  43358. case wx.FieldHeadBig:
  43359. v, ok := value.(string)
  43360. if !ok {
  43361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43362. }
  43363. m.SetHeadBig(v)
  43364. return nil
  43365. case wx.FieldOrganizationID:
  43366. v, ok := value.(uint64)
  43367. if !ok {
  43368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43369. }
  43370. m.SetOrganizationID(v)
  43371. return nil
  43372. case wx.FieldAgentID:
  43373. v, ok := value.(uint64)
  43374. if !ok {
  43375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43376. }
  43377. m.SetAgentID(v)
  43378. return nil
  43379. case wx.FieldAPIBase:
  43380. v, ok := value.(string)
  43381. if !ok {
  43382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43383. }
  43384. m.SetAPIBase(v)
  43385. return nil
  43386. case wx.FieldAPIKey:
  43387. v, ok := value.(string)
  43388. if !ok {
  43389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43390. }
  43391. m.SetAPIKey(v)
  43392. return nil
  43393. case wx.FieldAllowList:
  43394. v, ok := value.([]string)
  43395. if !ok {
  43396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43397. }
  43398. m.SetAllowList(v)
  43399. return nil
  43400. case wx.FieldGroupAllowList:
  43401. v, ok := value.([]string)
  43402. if !ok {
  43403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43404. }
  43405. m.SetGroupAllowList(v)
  43406. return nil
  43407. case wx.FieldBlockList:
  43408. v, ok := value.([]string)
  43409. if !ok {
  43410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43411. }
  43412. m.SetBlockList(v)
  43413. return nil
  43414. case wx.FieldGroupBlockList:
  43415. v, ok := value.([]string)
  43416. if !ok {
  43417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43418. }
  43419. m.SetGroupBlockList(v)
  43420. return nil
  43421. case wx.FieldCtype:
  43422. v, ok := value.(uint64)
  43423. if !ok {
  43424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43425. }
  43426. m.SetCtype(v)
  43427. return nil
  43428. }
  43429. return fmt.Errorf("unknown Wx field %s", name)
  43430. }
  43431. // AddedFields returns all numeric fields that were incremented/decremented during
  43432. // this mutation.
  43433. func (m *WxMutation) AddedFields() []string {
  43434. var fields []string
  43435. if m.addstatus != nil {
  43436. fields = append(fields, wx.FieldStatus)
  43437. }
  43438. if m.addorganization_id != nil {
  43439. fields = append(fields, wx.FieldOrganizationID)
  43440. }
  43441. if m.addctype != nil {
  43442. fields = append(fields, wx.FieldCtype)
  43443. }
  43444. return fields
  43445. }
  43446. // AddedField returns the numeric value that was incremented/decremented on a field
  43447. // with the given name. The second boolean return value indicates that this field
  43448. // was not set, or was not defined in the schema.
  43449. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  43450. switch name {
  43451. case wx.FieldStatus:
  43452. return m.AddedStatus()
  43453. case wx.FieldOrganizationID:
  43454. return m.AddedOrganizationID()
  43455. case wx.FieldCtype:
  43456. return m.AddedCtype()
  43457. }
  43458. return nil, false
  43459. }
  43460. // AddField adds the value to the field with the given name. It returns an error if
  43461. // the field is not defined in the schema, or if the type mismatched the field
  43462. // type.
  43463. func (m *WxMutation) AddField(name string, value ent.Value) error {
  43464. switch name {
  43465. case wx.FieldStatus:
  43466. v, ok := value.(int8)
  43467. if !ok {
  43468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43469. }
  43470. m.AddStatus(v)
  43471. return nil
  43472. case wx.FieldOrganizationID:
  43473. v, ok := value.(int64)
  43474. if !ok {
  43475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43476. }
  43477. m.AddOrganizationID(v)
  43478. return nil
  43479. case wx.FieldCtype:
  43480. v, ok := value.(int64)
  43481. if !ok {
  43482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43483. }
  43484. m.AddCtype(v)
  43485. return nil
  43486. }
  43487. return fmt.Errorf("unknown Wx numeric field %s", name)
  43488. }
  43489. // ClearedFields returns all nullable fields that were cleared during this
  43490. // mutation.
  43491. func (m *WxMutation) ClearedFields() []string {
  43492. var fields []string
  43493. if m.FieldCleared(wx.FieldStatus) {
  43494. fields = append(fields, wx.FieldStatus)
  43495. }
  43496. if m.FieldCleared(wx.FieldDeletedAt) {
  43497. fields = append(fields, wx.FieldDeletedAt)
  43498. }
  43499. if m.FieldCleared(wx.FieldServerID) {
  43500. fields = append(fields, wx.FieldServerID)
  43501. }
  43502. if m.FieldCleared(wx.FieldOrganizationID) {
  43503. fields = append(fields, wx.FieldOrganizationID)
  43504. }
  43505. if m.FieldCleared(wx.FieldAPIBase) {
  43506. fields = append(fields, wx.FieldAPIBase)
  43507. }
  43508. if m.FieldCleared(wx.FieldAPIKey) {
  43509. fields = append(fields, wx.FieldAPIKey)
  43510. }
  43511. if m.FieldCleared(wx.FieldCtype) {
  43512. fields = append(fields, wx.FieldCtype)
  43513. }
  43514. return fields
  43515. }
  43516. // FieldCleared returns a boolean indicating if a field with the given name was
  43517. // cleared in this mutation.
  43518. func (m *WxMutation) FieldCleared(name string) bool {
  43519. _, ok := m.clearedFields[name]
  43520. return ok
  43521. }
  43522. // ClearField clears the value of the field with the given name. It returns an
  43523. // error if the field is not defined in the schema.
  43524. func (m *WxMutation) ClearField(name string) error {
  43525. switch name {
  43526. case wx.FieldStatus:
  43527. m.ClearStatus()
  43528. return nil
  43529. case wx.FieldDeletedAt:
  43530. m.ClearDeletedAt()
  43531. return nil
  43532. case wx.FieldServerID:
  43533. m.ClearServerID()
  43534. return nil
  43535. case wx.FieldOrganizationID:
  43536. m.ClearOrganizationID()
  43537. return nil
  43538. case wx.FieldAPIBase:
  43539. m.ClearAPIBase()
  43540. return nil
  43541. case wx.FieldAPIKey:
  43542. m.ClearAPIKey()
  43543. return nil
  43544. case wx.FieldCtype:
  43545. m.ClearCtype()
  43546. return nil
  43547. }
  43548. return fmt.Errorf("unknown Wx nullable field %s", name)
  43549. }
  43550. // ResetField resets all changes in the mutation for the field with the given name.
  43551. // It returns an error if the field is not defined in the schema.
  43552. func (m *WxMutation) ResetField(name string) error {
  43553. switch name {
  43554. case wx.FieldCreatedAt:
  43555. m.ResetCreatedAt()
  43556. return nil
  43557. case wx.FieldUpdatedAt:
  43558. m.ResetUpdatedAt()
  43559. return nil
  43560. case wx.FieldStatus:
  43561. m.ResetStatus()
  43562. return nil
  43563. case wx.FieldDeletedAt:
  43564. m.ResetDeletedAt()
  43565. return nil
  43566. case wx.FieldServerID:
  43567. m.ResetServerID()
  43568. return nil
  43569. case wx.FieldPort:
  43570. m.ResetPort()
  43571. return nil
  43572. case wx.FieldProcessID:
  43573. m.ResetProcessID()
  43574. return nil
  43575. case wx.FieldCallback:
  43576. m.ResetCallback()
  43577. return nil
  43578. case wx.FieldWxid:
  43579. m.ResetWxid()
  43580. return nil
  43581. case wx.FieldAccount:
  43582. m.ResetAccount()
  43583. return nil
  43584. case wx.FieldNickname:
  43585. m.ResetNickname()
  43586. return nil
  43587. case wx.FieldTel:
  43588. m.ResetTel()
  43589. return nil
  43590. case wx.FieldHeadBig:
  43591. m.ResetHeadBig()
  43592. return nil
  43593. case wx.FieldOrganizationID:
  43594. m.ResetOrganizationID()
  43595. return nil
  43596. case wx.FieldAgentID:
  43597. m.ResetAgentID()
  43598. return nil
  43599. case wx.FieldAPIBase:
  43600. m.ResetAPIBase()
  43601. return nil
  43602. case wx.FieldAPIKey:
  43603. m.ResetAPIKey()
  43604. return nil
  43605. case wx.FieldAllowList:
  43606. m.ResetAllowList()
  43607. return nil
  43608. case wx.FieldGroupAllowList:
  43609. m.ResetGroupAllowList()
  43610. return nil
  43611. case wx.FieldBlockList:
  43612. m.ResetBlockList()
  43613. return nil
  43614. case wx.FieldGroupBlockList:
  43615. m.ResetGroupBlockList()
  43616. return nil
  43617. case wx.FieldCtype:
  43618. m.ResetCtype()
  43619. return nil
  43620. }
  43621. return fmt.Errorf("unknown Wx field %s", name)
  43622. }
  43623. // AddedEdges returns all edge names that were set/added in this mutation.
  43624. func (m *WxMutation) AddedEdges() []string {
  43625. edges := make([]string, 0, 2)
  43626. if m.server != nil {
  43627. edges = append(edges, wx.EdgeServer)
  43628. }
  43629. if m.agent != nil {
  43630. edges = append(edges, wx.EdgeAgent)
  43631. }
  43632. return edges
  43633. }
  43634. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43635. // name in this mutation.
  43636. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  43637. switch name {
  43638. case wx.EdgeServer:
  43639. if id := m.server; id != nil {
  43640. return []ent.Value{*id}
  43641. }
  43642. case wx.EdgeAgent:
  43643. if id := m.agent; id != nil {
  43644. return []ent.Value{*id}
  43645. }
  43646. }
  43647. return nil
  43648. }
  43649. // RemovedEdges returns all edge names that were removed in this mutation.
  43650. func (m *WxMutation) RemovedEdges() []string {
  43651. edges := make([]string, 0, 2)
  43652. return edges
  43653. }
  43654. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43655. // the given name in this mutation.
  43656. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  43657. return nil
  43658. }
  43659. // ClearedEdges returns all edge names that were cleared in this mutation.
  43660. func (m *WxMutation) ClearedEdges() []string {
  43661. edges := make([]string, 0, 2)
  43662. if m.clearedserver {
  43663. edges = append(edges, wx.EdgeServer)
  43664. }
  43665. if m.clearedagent {
  43666. edges = append(edges, wx.EdgeAgent)
  43667. }
  43668. return edges
  43669. }
  43670. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43671. // was cleared in this mutation.
  43672. func (m *WxMutation) EdgeCleared(name string) bool {
  43673. switch name {
  43674. case wx.EdgeServer:
  43675. return m.clearedserver
  43676. case wx.EdgeAgent:
  43677. return m.clearedagent
  43678. }
  43679. return false
  43680. }
  43681. // ClearEdge clears the value of the edge with the given name. It returns an error
  43682. // if that edge is not defined in the schema.
  43683. func (m *WxMutation) ClearEdge(name string) error {
  43684. switch name {
  43685. case wx.EdgeServer:
  43686. m.ClearServer()
  43687. return nil
  43688. case wx.EdgeAgent:
  43689. m.ClearAgent()
  43690. return nil
  43691. }
  43692. return fmt.Errorf("unknown Wx unique edge %s", name)
  43693. }
  43694. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43695. // It returns an error if the edge is not defined in the schema.
  43696. func (m *WxMutation) ResetEdge(name string) error {
  43697. switch name {
  43698. case wx.EdgeServer:
  43699. m.ResetServer()
  43700. return nil
  43701. case wx.EdgeAgent:
  43702. m.ResetAgent()
  43703. return nil
  43704. }
  43705. return fmt.Errorf("unknown Wx edge %s", name)
  43706. }
  43707. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  43708. type WxCardMutation struct {
  43709. config
  43710. op Op
  43711. typ string
  43712. id *uint64
  43713. created_at *time.Time
  43714. updated_at *time.Time
  43715. deleted_at *time.Time
  43716. user_id *uint64
  43717. adduser_id *int64
  43718. wx_user_id *uint64
  43719. addwx_user_id *int64
  43720. avatar *string
  43721. logo *string
  43722. name *string
  43723. company *string
  43724. address *string
  43725. phone *string
  43726. official_account *string
  43727. wechat_account *string
  43728. email *string
  43729. api_base *string
  43730. api_key *string
  43731. ai_info *string
  43732. intro *string
  43733. clearedFields map[string]struct{}
  43734. done bool
  43735. oldValue func(context.Context) (*WxCard, error)
  43736. predicates []predicate.WxCard
  43737. }
  43738. var _ ent.Mutation = (*WxCardMutation)(nil)
  43739. // wxcardOption allows management of the mutation configuration using functional options.
  43740. type wxcardOption func(*WxCardMutation)
  43741. // newWxCardMutation creates new mutation for the WxCard entity.
  43742. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  43743. m := &WxCardMutation{
  43744. config: c,
  43745. op: op,
  43746. typ: TypeWxCard,
  43747. clearedFields: make(map[string]struct{}),
  43748. }
  43749. for _, opt := range opts {
  43750. opt(m)
  43751. }
  43752. return m
  43753. }
  43754. // withWxCardID sets the ID field of the mutation.
  43755. func withWxCardID(id uint64) wxcardOption {
  43756. return func(m *WxCardMutation) {
  43757. var (
  43758. err error
  43759. once sync.Once
  43760. value *WxCard
  43761. )
  43762. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  43763. once.Do(func() {
  43764. if m.done {
  43765. err = errors.New("querying old values post mutation is not allowed")
  43766. } else {
  43767. value, err = m.Client().WxCard.Get(ctx, id)
  43768. }
  43769. })
  43770. return value, err
  43771. }
  43772. m.id = &id
  43773. }
  43774. }
  43775. // withWxCard sets the old WxCard of the mutation.
  43776. func withWxCard(node *WxCard) wxcardOption {
  43777. return func(m *WxCardMutation) {
  43778. m.oldValue = func(context.Context) (*WxCard, error) {
  43779. return node, nil
  43780. }
  43781. m.id = &node.ID
  43782. }
  43783. }
  43784. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43785. // executed in a transaction (ent.Tx), a transactional client is returned.
  43786. func (m WxCardMutation) Client() *Client {
  43787. client := &Client{config: m.config}
  43788. client.init()
  43789. return client
  43790. }
  43791. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43792. // it returns an error otherwise.
  43793. func (m WxCardMutation) Tx() (*Tx, error) {
  43794. if _, ok := m.driver.(*txDriver); !ok {
  43795. return nil, errors.New("ent: mutation is not running in a transaction")
  43796. }
  43797. tx := &Tx{config: m.config}
  43798. tx.init()
  43799. return tx, nil
  43800. }
  43801. // SetID sets the value of the id field. Note that this
  43802. // operation is only accepted on creation of WxCard entities.
  43803. func (m *WxCardMutation) SetID(id uint64) {
  43804. m.id = &id
  43805. }
  43806. // ID returns the ID value in the mutation. Note that the ID is only available
  43807. // if it was provided to the builder or after it was returned from the database.
  43808. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  43809. if m.id == nil {
  43810. return
  43811. }
  43812. return *m.id, true
  43813. }
  43814. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43815. // That means, if the mutation is applied within a transaction with an isolation level such
  43816. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43817. // or updated by the mutation.
  43818. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  43819. switch {
  43820. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43821. id, exists := m.ID()
  43822. if exists {
  43823. return []uint64{id}, nil
  43824. }
  43825. fallthrough
  43826. case m.op.Is(OpUpdate | OpDelete):
  43827. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  43828. default:
  43829. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43830. }
  43831. }
  43832. // SetCreatedAt sets the "created_at" field.
  43833. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  43834. m.created_at = &t
  43835. }
  43836. // CreatedAt returns the value of the "created_at" field in the mutation.
  43837. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  43838. v := m.created_at
  43839. if v == nil {
  43840. return
  43841. }
  43842. return *v, true
  43843. }
  43844. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  43845. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43847. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43848. if !m.op.Is(OpUpdateOne) {
  43849. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43850. }
  43851. if m.id == nil || m.oldValue == nil {
  43852. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43853. }
  43854. oldValue, err := m.oldValue(ctx)
  43855. if err != nil {
  43856. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43857. }
  43858. return oldValue.CreatedAt, nil
  43859. }
  43860. // ResetCreatedAt resets all changes to the "created_at" field.
  43861. func (m *WxCardMutation) ResetCreatedAt() {
  43862. m.created_at = nil
  43863. }
  43864. // SetUpdatedAt sets the "updated_at" field.
  43865. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  43866. m.updated_at = &t
  43867. }
  43868. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43869. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  43870. v := m.updated_at
  43871. if v == nil {
  43872. return
  43873. }
  43874. return *v, true
  43875. }
  43876. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  43877. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43879. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43880. if !m.op.Is(OpUpdateOne) {
  43881. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43882. }
  43883. if m.id == nil || m.oldValue == nil {
  43884. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43885. }
  43886. oldValue, err := m.oldValue(ctx)
  43887. if err != nil {
  43888. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43889. }
  43890. return oldValue.UpdatedAt, nil
  43891. }
  43892. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43893. func (m *WxCardMutation) ResetUpdatedAt() {
  43894. m.updated_at = nil
  43895. }
  43896. // SetDeletedAt sets the "deleted_at" field.
  43897. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  43898. m.deleted_at = &t
  43899. }
  43900. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43901. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  43902. v := m.deleted_at
  43903. if v == nil {
  43904. return
  43905. }
  43906. return *v, true
  43907. }
  43908. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  43909. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43911. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43912. if !m.op.Is(OpUpdateOne) {
  43913. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43914. }
  43915. if m.id == nil || m.oldValue == nil {
  43916. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43917. }
  43918. oldValue, err := m.oldValue(ctx)
  43919. if err != nil {
  43920. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43921. }
  43922. return oldValue.DeletedAt, nil
  43923. }
  43924. // ClearDeletedAt clears the value of the "deleted_at" field.
  43925. func (m *WxCardMutation) ClearDeletedAt() {
  43926. m.deleted_at = nil
  43927. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  43928. }
  43929. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43930. func (m *WxCardMutation) DeletedAtCleared() bool {
  43931. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  43932. return ok
  43933. }
  43934. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43935. func (m *WxCardMutation) ResetDeletedAt() {
  43936. m.deleted_at = nil
  43937. delete(m.clearedFields, wxcard.FieldDeletedAt)
  43938. }
  43939. // SetUserID sets the "user_id" field.
  43940. func (m *WxCardMutation) SetUserID(u uint64) {
  43941. m.user_id = &u
  43942. m.adduser_id = nil
  43943. }
  43944. // UserID returns the value of the "user_id" field in the mutation.
  43945. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  43946. v := m.user_id
  43947. if v == nil {
  43948. return
  43949. }
  43950. return *v, true
  43951. }
  43952. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  43953. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43955. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  43956. if !m.op.Is(OpUpdateOne) {
  43957. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  43958. }
  43959. if m.id == nil || m.oldValue == nil {
  43960. return v, errors.New("OldUserID requires an ID field in the mutation")
  43961. }
  43962. oldValue, err := m.oldValue(ctx)
  43963. if err != nil {
  43964. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  43965. }
  43966. return oldValue.UserID, nil
  43967. }
  43968. // AddUserID adds u to the "user_id" field.
  43969. func (m *WxCardMutation) AddUserID(u int64) {
  43970. if m.adduser_id != nil {
  43971. *m.adduser_id += u
  43972. } else {
  43973. m.adduser_id = &u
  43974. }
  43975. }
  43976. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  43977. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  43978. v := m.adduser_id
  43979. if v == nil {
  43980. return
  43981. }
  43982. return *v, true
  43983. }
  43984. // ClearUserID clears the value of the "user_id" field.
  43985. func (m *WxCardMutation) ClearUserID() {
  43986. m.user_id = nil
  43987. m.adduser_id = nil
  43988. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  43989. }
  43990. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  43991. func (m *WxCardMutation) UserIDCleared() bool {
  43992. _, ok := m.clearedFields[wxcard.FieldUserID]
  43993. return ok
  43994. }
  43995. // ResetUserID resets all changes to the "user_id" field.
  43996. func (m *WxCardMutation) ResetUserID() {
  43997. m.user_id = nil
  43998. m.adduser_id = nil
  43999. delete(m.clearedFields, wxcard.FieldUserID)
  44000. }
  44001. // SetWxUserID sets the "wx_user_id" field.
  44002. func (m *WxCardMutation) SetWxUserID(u uint64) {
  44003. m.wx_user_id = &u
  44004. m.addwx_user_id = nil
  44005. }
  44006. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  44007. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  44008. v := m.wx_user_id
  44009. if v == nil {
  44010. return
  44011. }
  44012. return *v, true
  44013. }
  44014. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  44015. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44017. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  44018. if !m.op.Is(OpUpdateOne) {
  44019. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  44020. }
  44021. if m.id == nil || m.oldValue == nil {
  44022. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  44023. }
  44024. oldValue, err := m.oldValue(ctx)
  44025. if err != nil {
  44026. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  44027. }
  44028. return oldValue.WxUserID, nil
  44029. }
  44030. // AddWxUserID adds u to the "wx_user_id" field.
  44031. func (m *WxCardMutation) AddWxUserID(u int64) {
  44032. if m.addwx_user_id != nil {
  44033. *m.addwx_user_id += u
  44034. } else {
  44035. m.addwx_user_id = &u
  44036. }
  44037. }
  44038. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  44039. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  44040. v := m.addwx_user_id
  44041. if v == nil {
  44042. return
  44043. }
  44044. return *v, true
  44045. }
  44046. // ClearWxUserID clears the value of the "wx_user_id" field.
  44047. func (m *WxCardMutation) ClearWxUserID() {
  44048. m.wx_user_id = nil
  44049. m.addwx_user_id = nil
  44050. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  44051. }
  44052. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  44053. func (m *WxCardMutation) WxUserIDCleared() bool {
  44054. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  44055. return ok
  44056. }
  44057. // ResetWxUserID resets all changes to the "wx_user_id" field.
  44058. func (m *WxCardMutation) ResetWxUserID() {
  44059. m.wx_user_id = nil
  44060. m.addwx_user_id = nil
  44061. delete(m.clearedFields, wxcard.FieldWxUserID)
  44062. }
  44063. // SetAvatar sets the "avatar" field.
  44064. func (m *WxCardMutation) SetAvatar(s string) {
  44065. m.avatar = &s
  44066. }
  44067. // Avatar returns the value of the "avatar" field in the mutation.
  44068. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  44069. v := m.avatar
  44070. if v == nil {
  44071. return
  44072. }
  44073. return *v, true
  44074. }
  44075. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  44076. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44078. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44079. if !m.op.Is(OpUpdateOne) {
  44080. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44081. }
  44082. if m.id == nil || m.oldValue == nil {
  44083. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44084. }
  44085. oldValue, err := m.oldValue(ctx)
  44086. if err != nil {
  44087. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44088. }
  44089. return oldValue.Avatar, nil
  44090. }
  44091. // ResetAvatar resets all changes to the "avatar" field.
  44092. func (m *WxCardMutation) ResetAvatar() {
  44093. m.avatar = nil
  44094. }
  44095. // SetLogo sets the "logo" field.
  44096. func (m *WxCardMutation) SetLogo(s string) {
  44097. m.logo = &s
  44098. }
  44099. // Logo returns the value of the "logo" field in the mutation.
  44100. func (m *WxCardMutation) Logo() (r string, exists bool) {
  44101. v := m.logo
  44102. if v == nil {
  44103. return
  44104. }
  44105. return *v, true
  44106. }
  44107. // OldLogo returns the old "logo" field's value of the WxCard entity.
  44108. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44110. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  44111. if !m.op.Is(OpUpdateOne) {
  44112. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  44113. }
  44114. if m.id == nil || m.oldValue == nil {
  44115. return v, errors.New("OldLogo requires an ID field in the mutation")
  44116. }
  44117. oldValue, err := m.oldValue(ctx)
  44118. if err != nil {
  44119. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  44120. }
  44121. return oldValue.Logo, nil
  44122. }
  44123. // ResetLogo resets all changes to the "logo" field.
  44124. func (m *WxCardMutation) ResetLogo() {
  44125. m.logo = nil
  44126. }
  44127. // SetName sets the "name" field.
  44128. func (m *WxCardMutation) SetName(s string) {
  44129. m.name = &s
  44130. }
  44131. // Name returns the value of the "name" field in the mutation.
  44132. func (m *WxCardMutation) Name() (r string, exists bool) {
  44133. v := m.name
  44134. if v == nil {
  44135. return
  44136. }
  44137. return *v, true
  44138. }
  44139. // OldName returns the old "name" field's value of the WxCard entity.
  44140. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44142. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  44143. if !m.op.Is(OpUpdateOne) {
  44144. return v, errors.New("OldName is only allowed on UpdateOne operations")
  44145. }
  44146. if m.id == nil || m.oldValue == nil {
  44147. return v, errors.New("OldName requires an ID field in the mutation")
  44148. }
  44149. oldValue, err := m.oldValue(ctx)
  44150. if err != nil {
  44151. return v, fmt.Errorf("querying old value for OldName: %w", err)
  44152. }
  44153. return oldValue.Name, nil
  44154. }
  44155. // ResetName resets all changes to the "name" field.
  44156. func (m *WxCardMutation) ResetName() {
  44157. m.name = nil
  44158. }
  44159. // SetCompany sets the "company" field.
  44160. func (m *WxCardMutation) SetCompany(s string) {
  44161. m.company = &s
  44162. }
  44163. // Company returns the value of the "company" field in the mutation.
  44164. func (m *WxCardMutation) Company() (r string, exists bool) {
  44165. v := m.company
  44166. if v == nil {
  44167. return
  44168. }
  44169. return *v, true
  44170. }
  44171. // OldCompany returns the old "company" field's value of the WxCard entity.
  44172. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44174. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  44175. if !m.op.Is(OpUpdateOne) {
  44176. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  44177. }
  44178. if m.id == nil || m.oldValue == nil {
  44179. return v, errors.New("OldCompany requires an ID field in the mutation")
  44180. }
  44181. oldValue, err := m.oldValue(ctx)
  44182. if err != nil {
  44183. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  44184. }
  44185. return oldValue.Company, nil
  44186. }
  44187. // ResetCompany resets all changes to the "company" field.
  44188. func (m *WxCardMutation) ResetCompany() {
  44189. m.company = nil
  44190. }
  44191. // SetAddress sets the "address" field.
  44192. func (m *WxCardMutation) SetAddress(s string) {
  44193. m.address = &s
  44194. }
  44195. // Address returns the value of the "address" field in the mutation.
  44196. func (m *WxCardMutation) Address() (r string, exists bool) {
  44197. v := m.address
  44198. if v == nil {
  44199. return
  44200. }
  44201. return *v, true
  44202. }
  44203. // OldAddress returns the old "address" field's value of the WxCard entity.
  44204. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44206. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  44207. if !m.op.Is(OpUpdateOne) {
  44208. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  44209. }
  44210. if m.id == nil || m.oldValue == nil {
  44211. return v, errors.New("OldAddress requires an ID field in the mutation")
  44212. }
  44213. oldValue, err := m.oldValue(ctx)
  44214. if err != nil {
  44215. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  44216. }
  44217. return oldValue.Address, nil
  44218. }
  44219. // ResetAddress resets all changes to the "address" field.
  44220. func (m *WxCardMutation) ResetAddress() {
  44221. m.address = nil
  44222. }
  44223. // SetPhone sets the "phone" field.
  44224. func (m *WxCardMutation) SetPhone(s string) {
  44225. m.phone = &s
  44226. }
  44227. // Phone returns the value of the "phone" field in the mutation.
  44228. func (m *WxCardMutation) Phone() (r string, exists bool) {
  44229. v := m.phone
  44230. if v == nil {
  44231. return
  44232. }
  44233. return *v, true
  44234. }
  44235. // OldPhone returns the old "phone" field's value of the WxCard entity.
  44236. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44238. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  44239. if !m.op.Is(OpUpdateOne) {
  44240. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  44241. }
  44242. if m.id == nil || m.oldValue == nil {
  44243. return v, errors.New("OldPhone requires an ID field in the mutation")
  44244. }
  44245. oldValue, err := m.oldValue(ctx)
  44246. if err != nil {
  44247. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  44248. }
  44249. return oldValue.Phone, nil
  44250. }
  44251. // ResetPhone resets all changes to the "phone" field.
  44252. func (m *WxCardMutation) ResetPhone() {
  44253. m.phone = nil
  44254. }
  44255. // SetOfficialAccount sets the "official_account" field.
  44256. func (m *WxCardMutation) SetOfficialAccount(s string) {
  44257. m.official_account = &s
  44258. }
  44259. // OfficialAccount returns the value of the "official_account" field in the mutation.
  44260. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  44261. v := m.official_account
  44262. if v == nil {
  44263. return
  44264. }
  44265. return *v, true
  44266. }
  44267. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  44268. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44270. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  44271. if !m.op.Is(OpUpdateOne) {
  44272. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  44273. }
  44274. if m.id == nil || m.oldValue == nil {
  44275. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  44276. }
  44277. oldValue, err := m.oldValue(ctx)
  44278. if err != nil {
  44279. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  44280. }
  44281. return oldValue.OfficialAccount, nil
  44282. }
  44283. // ResetOfficialAccount resets all changes to the "official_account" field.
  44284. func (m *WxCardMutation) ResetOfficialAccount() {
  44285. m.official_account = nil
  44286. }
  44287. // SetWechatAccount sets the "wechat_account" field.
  44288. func (m *WxCardMutation) SetWechatAccount(s string) {
  44289. m.wechat_account = &s
  44290. }
  44291. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  44292. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  44293. v := m.wechat_account
  44294. if v == nil {
  44295. return
  44296. }
  44297. return *v, true
  44298. }
  44299. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  44300. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44302. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  44303. if !m.op.Is(OpUpdateOne) {
  44304. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  44305. }
  44306. if m.id == nil || m.oldValue == nil {
  44307. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  44308. }
  44309. oldValue, err := m.oldValue(ctx)
  44310. if err != nil {
  44311. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  44312. }
  44313. return oldValue.WechatAccount, nil
  44314. }
  44315. // ResetWechatAccount resets all changes to the "wechat_account" field.
  44316. func (m *WxCardMutation) ResetWechatAccount() {
  44317. m.wechat_account = nil
  44318. }
  44319. // SetEmail sets the "email" field.
  44320. func (m *WxCardMutation) SetEmail(s string) {
  44321. m.email = &s
  44322. }
  44323. // Email returns the value of the "email" field in the mutation.
  44324. func (m *WxCardMutation) Email() (r string, exists bool) {
  44325. v := m.email
  44326. if v == nil {
  44327. return
  44328. }
  44329. return *v, true
  44330. }
  44331. // OldEmail returns the old "email" field's value of the WxCard entity.
  44332. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44334. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  44335. if !m.op.Is(OpUpdateOne) {
  44336. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  44337. }
  44338. if m.id == nil || m.oldValue == nil {
  44339. return v, errors.New("OldEmail requires an ID field in the mutation")
  44340. }
  44341. oldValue, err := m.oldValue(ctx)
  44342. if err != nil {
  44343. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  44344. }
  44345. return oldValue.Email, nil
  44346. }
  44347. // ClearEmail clears the value of the "email" field.
  44348. func (m *WxCardMutation) ClearEmail() {
  44349. m.email = nil
  44350. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  44351. }
  44352. // EmailCleared returns if the "email" field was cleared in this mutation.
  44353. func (m *WxCardMutation) EmailCleared() bool {
  44354. _, ok := m.clearedFields[wxcard.FieldEmail]
  44355. return ok
  44356. }
  44357. // ResetEmail resets all changes to the "email" field.
  44358. func (m *WxCardMutation) ResetEmail() {
  44359. m.email = nil
  44360. delete(m.clearedFields, wxcard.FieldEmail)
  44361. }
  44362. // SetAPIBase sets the "api_base" field.
  44363. func (m *WxCardMutation) SetAPIBase(s string) {
  44364. m.api_base = &s
  44365. }
  44366. // APIBase returns the value of the "api_base" field in the mutation.
  44367. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  44368. v := m.api_base
  44369. if v == nil {
  44370. return
  44371. }
  44372. return *v, true
  44373. }
  44374. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  44375. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44377. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  44378. if !m.op.Is(OpUpdateOne) {
  44379. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  44380. }
  44381. if m.id == nil || m.oldValue == nil {
  44382. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  44383. }
  44384. oldValue, err := m.oldValue(ctx)
  44385. if err != nil {
  44386. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  44387. }
  44388. return oldValue.APIBase, nil
  44389. }
  44390. // ClearAPIBase clears the value of the "api_base" field.
  44391. func (m *WxCardMutation) ClearAPIBase() {
  44392. m.api_base = nil
  44393. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  44394. }
  44395. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  44396. func (m *WxCardMutation) APIBaseCleared() bool {
  44397. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  44398. return ok
  44399. }
  44400. // ResetAPIBase resets all changes to the "api_base" field.
  44401. func (m *WxCardMutation) ResetAPIBase() {
  44402. m.api_base = nil
  44403. delete(m.clearedFields, wxcard.FieldAPIBase)
  44404. }
  44405. // SetAPIKey sets the "api_key" field.
  44406. func (m *WxCardMutation) SetAPIKey(s string) {
  44407. m.api_key = &s
  44408. }
  44409. // APIKey returns the value of the "api_key" field in the mutation.
  44410. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  44411. v := m.api_key
  44412. if v == nil {
  44413. return
  44414. }
  44415. return *v, true
  44416. }
  44417. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  44418. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44420. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  44421. if !m.op.Is(OpUpdateOne) {
  44422. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  44423. }
  44424. if m.id == nil || m.oldValue == nil {
  44425. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  44426. }
  44427. oldValue, err := m.oldValue(ctx)
  44428. if err != nil {
  44429. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  44430. }
  44431. return oldValue.APIKey, nil
  44432. }
  44433. // ClearAPIKey clears the value of the "api_key" field.
  44434. func (m *WxCardMutation) ClearAPIKey() {
  44435. m.api_key = nil
  44436. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  44437. }
  44438. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  44439. func (m *WxCardMutation) APIKeyCleared() bool {
  44440. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  44441. return ok
  44442. }
  44443. // ResetAPIKey resets all changes to the "api_key" field.
  44444. func (m *WxCardMutation) ResetAPIKey() {
  44445. m.api_key = nil
  44446. delete(m.clearedFields, wxcard.FieldAPIKey)
  44447. }
  44448. // SetAiInfo sets the "ai_info" field.
  44449. func (m *WxCardMutation) SetAiInfo(s string) {
  44450. m.ai_info = &s
  44451. }
  44452. // AiInfo returns the value of the "ai_info" field in the mutation.
  44453. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  44454. v := m.ai_info
  44455. if v == nil {
  44456. return
  44457. }
  44458. return *v, true
  44459. }
  44460. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  44461. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44463. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  44464. if !m.op.Is(OpUpdateOne) {
  44465. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  44466. }
  44467. if m.id == nil || m.oldValue == nil {
  44468. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  44469. }
  44470. oldValue, err := m.oldValue(ctx)
  44471. if err != nil {
  44472. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  44473. }
  44474. return oldValue.AiInfo, nil
  44475. }
  44476. // ClearAiInfo clears the value of the "ai_info" field.
  44477. func (m *WxCardMutation) ClearAiInfo() {
  44478. m.ai_info = nil
  44479. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  44480. }
  44481. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  44482. func (m *WxCardMutation) AiInfoCleared() bool {
  44483. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  44484. return ok
  44485. }
  44486. // ResetAiInfo resets all changes to the "ai_info" field.
  44487. func (m *WxCardMutation) ResetAiInfo() {
  44488. m.ai_info = nil
  44489. delete(m.clearedFields, wxcard.FieldAiInfo)
  44490. }
  44491. // SetIntro sets the "intro" field.
  44492. func (m *WxCardMutation) SetIntro(s string) {
  44493. m.intro = &s
  44494. }
  44495. // Intro returns the value of the "intro" field in the mutation.
  44496. func (m *WxCardMutation) Intro() (r string, exists bool) {
  44497. v := m.intro
  44498. if v == nil {
  44499. return
  44500. }
  44501. return *v, true
  44502. }
  44503. // OldIntro returns the old "intro" field's value of the WxCard entity.
  44504. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44506. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  44507. if !m.op.Is(OpUpdateOne) {
  44508. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  44509. }
  44510. if m.id == nil || m.oldValue == nil {
  44511. return v, errors.New("OldIntro requires an ID field in the mutation")
  44512. }
  44513. oldValue, err := m.oldValue(ctx)
  44514. if err != nil {
  44515. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  44516. }
  44517. return oldValue.Intro, nil
  44518. }
  44519. // ClearIntro clears the value of the "intro" field.
  44520. func (m *WxCardMutation) ClearIntro() {
  44521. m.intro = nil
  44522. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  44523. }
  44524. // IntroCleared returns if the "intro" field was cleared in this mutation.
  44525. func (m *WxCardMutation) IntroCleared() bool {
  44526. _, ok := m.clearedFields[wxcard.FieldIntro]
  44527. return ok
  44528. }
  44529. // ResetIntro resets all changes to the "intro" field.
  44530. func (m *WxCardMutation) ResetIntro() {
  44531. m.intro = nil
  44532. delete(m.clearedFields, wxcard.FieldIntro)
  44533. }
  44534. // Where appends a list predicates to the WxCardMutation builder.
  44535. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  44536. m.predicates = append(m.predicates, ps...)
  44537. }
  44538. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  44539. // users can use type-assertion to append predicates that do not depend on any generated package.
  44540. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  44541. p := make([]predicate.WxCard, len(ps))
  44542. for i := range ps {
  44543. p[i] = ps[i]
  44544. }
  44545. m.Where(p...)
  44546. }
  44547. // Op returns the operation name.
  44548. func (m *WxCardMutation) Op() Op {
  44549. return m.op
  44550. }
  44551. // SetOp allows setting the mutation operation.
  44552. func (m *WxCardMutation) SetOp(op Op) {
  44553. m.op = op
  44554. }
  44555. // Type returns the node type of this mutation (WxCard).
  44556. func (m *WxCardMutation) Type() string {
  44557. return m.typ
  44558. }
  44559. // Fields returns all fields that were changed during this mutation. Note that in
  44560. // order to get all numeric fields that were incremented/decremented, call
  44561. // AddedFields().
  44562. func (m *WxCardMutation) Fields() []string {
  44563. fields := make([]string, 0, 18)
  44564. if m.created_at != nil {
  44565. fields = append(fields, wxcard.FieldCreatedAt)
  44566. }
  44567. if m.updated_at != nil {
  44568. fields = append(fields, wxcard.FieldUpdatedAt)
  44569. }
  44570. if m.deleted_at != nil {
  44571. fields = append(fields, wxcard.FieldDeletedAt)
  44572. }
  44573. if m.user_id != nil {
  44574. fields = append(fields, wxcard.FieldUserID)
  44575. }
  44576. if m.wx_user_id != nil {
  44577. fields = append(fields, wxcard.FieldWxUserID)
  44578. }
  44579. if m.avatar != nil {
  44580. fields = append(fields, wxcard.FieldAvatar)
  44581. }
  44582. if m.logo != nil {
  44583. fields = append(fields, wxcard.FieldLogo)
  44584. }
  44585. if m.name != nil {
  44586. fields = append(fields, wxcard.FieldName)
  44587. }
  44588. if m.company != nil {
  44589. fields = append(fields, wxcard.FieldCompany)
  44590. }
  44591. if m.address != nil {
  44592. fields = append(fields, wxcard.FieldAddress)
  44593. }
  44594. if m.phone != nil {
  44595. fields = append(fields, wxcard.FieldPhone)
  44596. }
  44597. if m.official_account != nil {
  44598. fields = append(fields, wxcard.FieldOfficialAccount)
  44599. }
  44600. if m.wechat_account != nil {
  44601. fields = append(fields, wxcard.FieldWechatAccount)
  44602. }
  44603. if m.email != nil {
  44604. fields = append(fields, wxcard.FieldEmail)
  44605. }
  44606. if m.api_base != nil {
  44607. fields = append(fields, wxcard.FieldAPIBase)
  44608. }
  44609. if m.api_key != nil {
  44610. fields = append(fields, wxcard.FieldAPIKey)
  44611. }
  44612. if m.ai_info != nil {
  44613. fields = append(fields, wxcard.FieldAiInfo)
  44614. }
  44615. if m.intro != nil {
  44616. fields = append(fields, wxcard.FieldIntro)
  44617. }
  44618. return fields
  44619. }
  44620. // Field returns the value of a field with the given name. The second boolean
  44621. // return value indicates that this field was not set, or was not defined in the
  44622. // schema.
  44623. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  44624. switch name {
  44625. case wxcard.FieldCreatedAt:
  44626. return m.CreatedAt()
  44627. case wxcard.FieldUpdatedAt:
  44628. return m.UpdatedAt()
  44629. case wxcard.FieldDeletedAt:
  44630. return m.DeletedAt()
  44631. case wxcard.FieldUserID:
  44632. return m.UserID()
  44633. case wxcard.FieldWxUserID:
  44634. return m.WxUserID()
  44635. case wxcard.FieldAvatar:
  44636. return m.Avatar()
  44637. case wxcard.FieldLogo:
  44638. return m.Logo()
  44639. case wxcard.FieldName:
  44640. return m.Name()
  44641. case wxcard.FieldCompany:
  44642. return m.Company()
  44643. case wxcard.FieldAddress:
  44644. return m.Address()
  44645. case wxcard.FieldPhone:
  44646. return m.Phone()
  44647. case wxcard.FieldOfficialAccount:
  44648. return m.OfficialAccount()
  44649. case wxcard.FieldWechatAccount:
  44650. return m.WechatAccount()
  44651. case wxcard.FieldEmail:
  44652. return m.Email()
  44653. case wxcard.FieldAPIBase:
  44654. return m.APIBase()
  44655. case wxcard.FieldAPIKey:
  44656. return m.APIKey()
  44657. case wxcard.FieldAiInfo:
  44658. return m.AiInfo()
  44659. case wxcard.FieldIntro:
  44660. return m.Intro()
  44661. }
  44662. return nil, false
  44663. }
  44664. // OldField returns the old value of the field from the database. An error is
  44665. // returned if the mutation operation is not UpdateOne, or the query to the
  44666. // database failed.
  44667. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44668. switch name {
  44669. case wxcard.FieldCreatedAt:
  44670. return m.OldCreatedAt(ctx)
  44671. case wxcard.FieldUpdatedAt:
  44672. return m.OldUpdatedAt(ctx)
  44673. case wxcard.FieldDeletedAt:
  44674. return m.OldDeletedAt(ctx)
  44675. case wxcard.FieldUserID:
  44676. return m.OldUserID(ctx)
  44677. case wxcard.FieldWxUserID:
  44678. return m.OldWxUserID(ctx)
  44679. case wxcard.FieldAvatar:
  44680. return m.OldAvatar(ctx)
  44681. case wxcard.FieldLogo:
  44682. return m.OldLogo(ctx)
  44683. case wxcard.FieldName:
  44684. return m.OldName(ctx)
  44685. case wxcard.FieldCompany:
  44686. return m.OldCompany(ctx)
  44687. case wxcard.FieldAddress:
  44688. return m.OldAddress(ctx)
  44689. case wxcard.FieldPhone:
  44690. return m.OldPhone(ctx)
  44691. case wxcard.FieldOfficialAccount:
  44692. return m.OldOfficialAccount(ctx)
  44693. case wxcard.FieldWechatAccount:
  44694. return m.OldWechatAccount(ctx)
  44695. case wxcard.FieldEmail:
  44696. return m.OldEmail(ctx)
  44697. case wxcard.FieldAPIBase:
  44698. return m.OldAPIBase(ctx)
  44699. case wxcard.FieldAPIKey:
  44700. return m.OldAPIKey(ctx)
  44701. case wxcard.FieldAiInfo:
  44702. return m.OldAiInfo(ctx)
  44703. case wxcard.FieldIntro:
  44704. return m.OldIntro(ctx)
  44705. }
  44706. return nil, fmt.Errorf("unknown WxCard field %s", name)
  44707. }
  44708. // SetField sets the value of a field with the given name. It returns an error if
  44709. // the field is not defined in the schema, or if the type mismatched the field
  44710. // type.
  44711. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  44712. switch name {
  44713. case wxcard.FieldCreatedAt:
  44714. v, ok := value.(time.Time)
  44715. if !ok {
  44716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44717. }
  44718. m.SetCreatedAt(v)
  44719. return nil
  44720. case wxcard.FieldUpdatedAt:
  44721. v, ok := value.(time.Time)
  44722. if !ok {
  44723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44724. }
  44725. m.SetUpdatedAt(v)
  44726. return nil
  44727. case wxcard.FieldDeletedAt:
  44728. v, ok := value.(time.Time)
  44729. if !ok {
  44730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44731. }
  44732. m.SetDeletedAt(v)
  44733. return nil
  44734. case wxcard.FieldUserID:
  44735. v, ok := value.(uint64)
  44736. if !ok {
  44737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44738. }
  44739. m.SetUserID(v)
  44740. return nil
  44741. case wxcard.FieldWxUserID:
  44742. v, ok := value.(uint64)
  44743. if !ok {
  44744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44745. }
  44746. m.SetWxUserID(v)
  44747. return nil
  44748. case wxcard.FieldAvatar:
  44749. v, ok := value.(string)
  44750. if !ok {
  44751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44752. }
  44753. m.SetAvatar(v)
  44754. return nil
  44755. case wxcard.FieldLogo:
  44756. v, ok := value.(string)
  44757. if !ok {
  44758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44759. }
  44760. m.SetLogo(v)
  44761. return nil
  44762. case wxcard.FieldName:
  44763. v, ok := value.(string)
  44764. if !ok {
  44765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44766. }
  44767. m.SetName(v)
  44768. return nil
  44769. case wxcard.FieldCompany:
  44770. v, ok := value.(string)
  44771. if !ok {
  44772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44773. }
  44774. m.SetCompany(v)
  44775. return nil
  44776. case wxcard.FieldAddress:
  44777. v, ok := value.(string)
  44778. if !ok {
  44779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44780. }
  44781. m.SetAddress(v)
  44782. return nil
  44783. case wxcard.FieldPhone:
  44784. v, ok := value.(string)
  44785. if !ok {
  44786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44787. }
  44788. m.SetPhone(v)
  44789. return nil
  44790. case wxcard.FieldOfficialAccount:
  44791. v, ok := value.(string)
  44792. if !ok {
  44793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44794. }
  44795. m.SetOfficialAccount(v)
  44796. return nil
  44797. case wxcard.FieldWechatAccount:
  44798. v, ok := value.(string)
  44799. if !ok {
  44800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44801. }
  44802. m.SetWechatAccount(v)
  44803. return nil
  44804. case wxcard.FieldEmail:
  44805. v, ok := value.(string)
  44806. if !ok {
  44807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44808. }
  44809. m.SetEmail(v)
  44810. return nil
  44811. case wxcard.FieldAPIBase:
  44812. v, ok := value.(string)
  44813. if !ok {
  44814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44815. }
  44816. m.SetAPIBase(v)
  44817. return nil
  44818. case wxcard.FieldAPIKey:
  44819. v, ok := value.(string)
  44820. if !ok {
  44821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44822. }
  44823. m.SetAPIKey(v)
  44824. return nil
  44825. case wxcard.FieldAiInfo:
  44826. v, ok := value.(string)
  44827. if !ok {
  44828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44829. }
  44830. m.SetAiInfo(v)
  44831. return nil
  44832. case wxcard.FieldIntro:
  44833. v, ok := value.(string)
  44834. if !ok {
  44835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44836. }
  44837. m.SetIntro(v)
  44838. return nil
  44839. }
  44840. return fmt.Errorf("unknown WxCard field %s", name)
  44841. }
  44842. // AddedFields returns all numeric fields that were incremented/decremented during
  44843. // this mutation.
  44844. func (m *WxCardMutation) AddedFields() []string {
  44845. var fields []string
  44846. if m.adduser_id != nil {
  44847. fields = append(fields, wxcard.FieldUserID)
  44848. }
  44849. if m.addwx_user_id != nil {
  44850. fields = append(fields, wxcard.FieldWxUserID)
  44851. }
  44852. return fields
  44853. }
  44854. // AddedField returns the numeric value that was incremented/decremented on a field
  44855. // with the given name. The second boolean return value indicates that this field
  44856. // was not set, or was not defined in the schema.
  44857. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  44858. switch name {
  44859. case wxcard.FieldUserID:
  44860. return m.AddedUserID()
  44861. case wxcard.FieldWxUserID:
  44862. return m.AddedWxUserID()
  44863. }
  44864. return nil, false
  44865. }
  44866. // AddField adds the value to the field with the given name. It returns an error if
  44867. // the field is not defined in the schema, or if the type mismatched the field
  44868. // type.
  44869. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  44870. switch name {
  44871. case wxcard.FieldUserID:
  44872. v, ok := value.(int64)
  44873. if !ok {
  44874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44875. }
  44876. m.AddUserID(v)
  44877. return nil
  44878. case wxcard.FieldWxUserID:
  44879. v, ok := value.(int64)
  44880. if !ok {
  44881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44882. }
  44883. m.AddWxUserID(v)
  44884. return nil
  44885. }
  44886. return fmt.Errorf("unknown WxCard numeric field %s", name)
  44887. }
  44888. // ClearedFields returns all nullable fields that were cleared during this
  44889. // mutation.
  44890. func (m *WxCardMutation) ClearedFields() []string {
  44891. var fields []string
  44892. if m.FieldCleared(wxcard.FieldDeletedAt) {
  44893. fields = append(fields, wxcard.FieldDeletedAt)
  44894. }
  44895. if m.FieldCleared(wxcard.FieldUserID) {
  44896. fields = append(fields, wxcard.FieldUserID)
  44897. }
  44898. if m.FieldCleared(wxcard.FieldWxUserID) {
  44899. fields = append(fields, wxcard.FieldWxUserID)
  44900. }
  44901. if m.FieldCleared(wxcard.FieldEmail) {
  44902. fields = append(fields, wxcard.FieldEmail)
  44903. }
  44904. if m.FieldCleared(wxcard.FieldAPIBase) {
  44905. fields = append(fields, wxcard.FieldAPIBase)
  44906. }
  44907. if m.FieldCleared(wxcard.FieldAPIKey) {
  44908. fields = append(fields, wxcard.FieldAPIKey)
  44909. }
  44910. if m.FieldCleared(wxcard.FieldAiInfo) {
  44911. fields = append(fields, wxcard.FieldAiInfo)
  44912. }
  44913. if m.FieldCleared(wxcard.FieldIntro) {
  44914. fields = append(fields, wxcard.FieldIntro)
  44915. }
  44916. return fields
  44917. }
  44918. // FieldCleared returns a boolean indicating if a field with the given name was
  44919. // cleared in this mutation.
  44920. func (m *WxCardMutation) FieldCleared(name string) bool {
  44921. _, ok := m.clearedFields[name]
  44922. return ok
  44923. }
  44924. // ClearField clears the value of the field with the given name. It returns an
  44925. // error if the field is not defined in the schema.
  44926. func (m *WxCardMutation) ClearField(name string) error {
  44927. switch name {
  44928. case wxcard.FieldDeletedAt:
  44929. m.ClearDeletedAt()
  44930. return nil
  44931. case wxcard.FieldUserID:
  44932. m.ClearUserID()
  44933. return nil
  44934. case wxcard.FieldWxUserID:
  44935. m.ClearWxUserID()
  44936. return nil
  44937. case wxcard.FieldEmail:
  44938. m.ClearEmail()
  44939. return nil
  44940. case wxcard.FieldAPIBase:
  44941. m.ClearAPIBase()
  44942. return nil
  44943. case wxcard.FieldAPIKey:
  44944. m.ClearAPIKey()
  44945. return nil
  44946. case wxcard.FieldAiInfo:
  44947. m.ClearAiInfo()
  44948. return nil
  44949. case wxcard.FieldIntro:
  44950. m.ClearIntro()
  44951. return nil
  44952. }
  44953. return fmt.Errorf("unknown WxCard nullable field %s", name)
  44954. }
  44955. // ResetField resets all changes in the mutation for the field with the given name.
  44956. // It returns an error if the field is not defined in the schema.
  44957. func (m *WxCardMutation) ResetField(name string) error {
  44958. switch name {
  44959. case wxcard.FieldCreatedAt:
  44960. m.ResetCreatedAt()
  44961. return nil
  44962. case wxcard.FieldUpdatedAt:
  44963. m.ResetUpdatedAt()
  44964. return nil
  44965. case wxcard.FieldDeletedAt:
  44966. m.ResetDeletedAt()
  44967. return nil
  44968. case wxcard.FieldUserID:
  44969. m.ResetUserID()
  44970. return nil
  44971. case wxcard.FieldWxUserID:
  44972. m.ResetWxUserID()
  44973. return nil
  44974. case wxcard.FieldAvatar:
  44975. m.ResetAvatar()
  44976. return nil
  44977. case wxcard.FieldLogo:
  44978. m.ResetLogo()
  44979. return nil
  44980. case wxcard.FieldName:
  44981. m.ResetName()
  44982. return nil
  44983. case wxcard.FieldCompany:
  44984. m.ResetCompany()
  44985. return nil
  44986. case wxcard.FieldAddress:
  44987. m.ResetAddress()
  44988. return nil
  44989. case wxcard.FieldPhone:
  44990. m.ResetPhone()
  44991. return nil
  44992. case wxcard.FieldOfficialAccount:
  44993. m.ResetOfficialAccount()
  44994. return nil
  44995. case wxcard.FieldWechatAccount:
  44996. m.ResetWechatAccount()
  44997. return nil
  44998. case wxcard.FieldEmail:
  44999. m.ResetEmail()
  45000. return nil
  45001. case wxcard.FieldAPIBase:
  45002. m.ResetAPIBase()
  45003. return nil
  45004. case wxcard.FieldAPIKey:
  45005. m.ResetAPIKey()
  45006. return nil
  45007. case wxcard.FieldAiInfo:
  45008. m.ResetAiInfo()
  45009. return nil
  45010. case wxcard.FieldIntro:
  45011. m.ResetIntro()
  45012. return nil
  45013. }
  45014. return fmt.Errorf("unknown WxCard field %s", name)
  45015. }
  45016. // AddedEdges returns all edge names that were set/added in this mutation.
  45017. func (m *WxCardMutation) AddedEdges() []string {
  45018. edges := make([]string, 0, 0)
  45019. return edges
  45020. }
  45021. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45022. // name in this mutation.
  45023. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  45024. return nil
  45025. }
  45026. // RemovedEdges returns all edge names that were removed in this mutation.
  45027. func (m *WxCardMutation) RemovedEdges() []string {
  45028. edges := make([]string, 0, 0)
  45029. return edges
  45030. }
  45031. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45032. // the given name in this mutation.
  45033. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  45034. return nil
  45035. }
  45036. // ClearedEdges returns all edge names that were cleared in this mutation.
  45037. func (m *WxCardMutation) ClearedEdges() []string {
  45038. edges := make([]string, 0, 0)
  45039. return edges
  45040. }
  45041. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45042. // was cleared in this mutation.
  45043. func (m *WxCardMutation) EdgeCleared(name string) bool {
  45044. return false
  45045. }
  45046. // ClearEdge clears the value of the edge with the given name. It returns an error
  45047. // if that edge is not defined in the schema.
  45048. func (m *WxCardMutation) ClearEdge(name string) error {
  45049. return fmt.Errorf("unknown WxCard unique edge %s", name)
  45050. }
  45051. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45052. // It returns an error if the edge is not defined in the schema.
  45053. func (m *WxCardMutation) ResetEdge(name string) error {
  45054. return fmt.Errorf("unknown WxCard edge %s", name)
  45055. }
  45056. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  45057. type WxCardUserMutation struct {
  45058. config
  45059. op Op
  45060. typ string
  45061. id *uint64
  45062. created_at *time.Time
  45063. updated_at *time.Time
  45064. deleted_at *time.Time
  45065. wxid *string
  45066. account *string
  45067. avatar *string
  45068. nickname *string
  45069. remark *string
  45070. phone *string
  45071. open_id *string
  45072. union_id *string
  45073. session_key *string
  45074. is_vip *int
  45075. addis_vip *int
  45076. clearedFields map[string]struct{}
  45077. done bool
  45078. oldValue func(context.Context) (*WxCardUser, error)
  45079. predicates []predicate.WxCardUser
  45080. }
  45081. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  45082. // wxcarduserOption allows management of the mutation configuration using functional options.
  45083. type wxcarduserOption func(*WxCardUserMutation)
  45084. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  45085. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  45086. m := &WxCardUserMutation{
  45087. config: c,
  45088. op: op,
  45089. typ: TypeWxCardUser,
  45090. clearedFields: make(map[string]struct{}),
  45091. }
  45092. for _, opt := range opts {
  45093. opt(m)
  45094. }
  45095. return m
  45096. }
  45097. // withWxCardUserID sets the ID field of the mutation.
  45098. func withWxCardUserID(id uint64) wxcarduserOption {
  45099. return func(m *WxCardUserMutation) {
  45100. var (
  45101. err error
  45102. once sync.Once
  45103. value *WxCardUser
  45104. )
  45105. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  45106. once.Do(func() {
  45107. if m.done {
  45108. err = errors.New("querying old values post mutation is not allowed")
  45109. } else {
  45110. value, err = m.Client().WxCardUser.Get(ctx, id)
  45111. }
  45112. })
  45113. return value, err
  45114. }
  45115. m.id = &id
  45116. }
  45117. }
  45118. // withWxCardUser sets the old WxCardUser of the mutation.
  45119. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  45120. return func(m *WxCardUserMutation) {
  45121. m.oldValue = func(context.Context) (*WxCardUser, error) {
  45122. return node, nil
  45123. }
  45124. m.id = &node.ID
  45125. }
  45126. }
  45127. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45128. // executed in a transaction (ent.Tx), a transactional client is returned.
  45129. func (m WxCardUserMutation) Client() *Client {
  45130. client := &Client{config: m.config}
  45131. client.init()
  45132. return client
  45133. }
  45134. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45135. // it returns an error otherwise.
  45136. func (m WxCardUserMutation) Tx() (*Tx, error) {
  45137. if _, ok := m.driver.(*txDriver); !ok {
  45138. return nil, errors.New("ent: mutation is not running in a transaction")
  45139. }
  45140. tx := &Tx{config: m.config}
  45141. tx.init()
  45142. return tx, nil
  45143. }
  45144. // SetID sets the value of the id field. Note that this
  45145. // operation is only accepted on creation of WxCardUser entities.
  45146. func (m *WxCardUserMutation) SetID(id uint64) {
  45147. m.id = &id
  45148. }
  45149. // ID returns the ID value in the mutation. Note that the ID is only available
  45150. // if it was provided to the builder or after it was returned from the database.
  45151. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  45152. if m.id == nil {
  45153. return
  45154. }
  45155. return *m.id, true
  45156. }
  45157. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45158. // That means, if the mutation is applied within a transaction with an isolation level such
  45159. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45160. // or updated by the mutation.
  45161. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  45162. switch {
  45163. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45164. id, exists := m.ID()
  45165. if exists {
  45166. return []uint64{id}, nil
  45167. }
  45168. fallthrough
  45169. case m.op.Is(OpUpdate | OpDelete):
  45170. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  45171. default:
  45172. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45173. }
  45174. }
  45175. // SetCreatedAt sets the "created_at" field.
  45176. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  45177. m.created_at = &t
  45178. }
  45179. // CreatedAt returns the value of the "created_at" field in the mutation.
  45180. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  45181. v := m.created_at
  45182. if v == nil {
  45183. return
  45184. }
  45185. return *v, true
  45186. }
  45187. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  45188. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45190. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45191. if !m.op.Is(OpUpdateOne) {
  45192. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45193. }
  45194. if m.id == nil || m.oldValue == nil {
  45195. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45196. }
  45197. oldValue, err := m.oldValue(ctx)
  45198. if err != nil {
  45199. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45200. }
  45201. return oldValue.CreatedAt, nil
  45202. }
  45203. // ResetCreatedAt resets all changes to the "created_at" field.
  45204. func (m *WxCardUserMutation) ResetCreatedAt() {
  45205. m.created_at = nil
  45206. }
  45207. // SetUpdatedAt sets the "updated_at" field.
  45208. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  45209. m.updated_at = &t
  45210. }
  45211. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45212. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  45213. v := m.updated_at
  45214. if v == nil {
  45215. return
  45216. }
  45217. return *v, true
  45218. }
  45219. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  45220. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45222. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45223. if !m.op.Is(OpUpdateOne) {
  45224. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45225. }
  45226. if m.id == nil || m.oldValue == nil {
  45227. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45228. }
  45229. oldValue, err := m.oldValue(ctx)
  45230. if err != nil {
  45231. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45232. }
  45233. return oldValue.UpdatedAt, nil
  45234. }
  45235. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45236. func (m *WxCardUserMutation) ResetUpdatedAt() {
  45237. m.updated_at = nil
  45238. }
  45239. // SetDeletedAt sets the "deleted_at" field.
  45240. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  45241. m.deleted_at = &t
  45242. }
  45243. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45244. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  45245. v := m.deleted_at
  45246. if v == nil {
  45247. return
  45248. }
  45249. return *v, true
  45250. }
  45251. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  45252. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45254. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45255. if !m.op.Is(OpUpdateOne) {
  45256. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45257. }
  45258. if m.id == nil || m.oldValue == nil {
  45259. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45260. }
  45261. oldValue, err := m.oldValue(ctx)
  45262. if err != nil {
  45263. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45264. }
  45265. return oldValue.DeletedAt, nil
  45266. }
  45267. // ClearDeletedAt clears the value of the "deleted_at" field.
  45268. func (m *WxCardUserMutation) ClearDeletedAt() {
  45269. m.deleted_at = nil
  45270. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  45271. }
  45272. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45273. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  45274. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  45275. return ok
  45276. }
  45277. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45278. func (m *WxCardUserMutation) ResetDeletedAt() {
  45279. m.deleted_at = nil
  45280. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  45281. }
  45282. // SetWxid sets the "wxid" field.
  45283. func (m *WxCardUserMutation) SetWxid(s string) {
  45284. m.wxid = &s
  45285. }
  45286. // Wxid returns the value of the "wxid" field in the mutation.
  45287. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  45288. v := m.wxid
  45289. if v == nil {
  45290. return
  45291. }
  45292. return *v, true
  45293. }
  45294. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  45295. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45297. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  45298. if !m.op.Is(OpUpdateOne) {
  45299. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  45300. }
  45301. if m.id == nil || m.oldValue == nil {
  45302. return v, errors.New("OldWxid requires an ID field in the mutation")
  45303. }
  45304. oldValue, err := m.oldValue(ctx)
  45305. if err != nil {
  45306. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  45307. }
  45308. return oldValue.Wxid, nil
  45309. }
  45310. // ResetWxid resets all changes to the "wxid" field.
  45311. func (m *WxCardUserMutation) ResetWxid() {
  45312. m.wxid = nil
  45313. }
  45314. // SetAccount sets the "account" field.
  45315. func (m *WxCardUserMutation) SetAccount(s string) {
  45316. m.account = &s
  45317. }
  45318. // Account returns the value of the "account" field in the mutation.
  45319. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  45320. v := m.account
  45321. if v == nil {
  45322. return
  45323. }
  45324. return *v, true
  45325. }
  45326. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  45327. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45329. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  45330. if !m.op.Is(OpUpdateOne) {
  45331. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  45332. }
  45333. if m.id == nil || m.oldValue == nil {
  45334. return v, errors.New("OldAccount requires an ID field in the mutation")
  45335. }
  45336. oldValue, err := m.oldValue(ctx)
  45337. if err != nil {
  45338. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  45339. }
  45340. return oldValue.Account, nil
  45341. }
  45342. // ResetAccount resets all changes to the "account" field.
  45343. func (m *WxCardUserMutation) ResetAccount() {
  45344. m.account = nil
  45345. }
  45346. // SetAvatar sets the "avatar" field.
  45347. func (m *WxCardUserMutation) SetAvatar(s string) {
  45348. m.avatar = &s
  45349. }
  45350. // Avatar returns the value of the "avatar" field in the mutation.
  45351. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  45352. v := m.avatar
  45353. if v == nil {
  45354. return
  45355. }
  45356. return *v, true
  45357. }
  45358. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  45359. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45361. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45362. if !m.op.Is(OpUpdateOne) {
  45363. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45364. }
  45365. if m.id == nil || m.oldValue == nil {
  45366. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45367. }
  45368. oldValue, err := m.oldValue(ctx)
  45369. if err != nil {
  45370. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45371. }
  45372. return oldValue.Avatar, nil
  45373. }
  45374. // ResetAvatar resets all changes to the "avatar" field.
  45375. func (m *WxCardUserMutation) ResetAvatar() {
  45376. m.avatar = nil
  45377. }
  45378. // SetNickname sets the "nickname" field.
  45379. func (m *WxCardUserMutation) SetNickname(s string) {
  45380. m.nickname = &s
  45381. }
  45382. // Nickname returns the value of the "nickname" field in the mutation.
  45383. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  45384. v := m.nickname
  45385. if v == nil {
  45386. return
  45387. }
  45388. return *v, true
  45389. }
  45390. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  45391. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45393. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  45394. if !m.op.Is(OpUpdateOne) {
  45395. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45396. }
  45397. if m.id == nil || m.oldValue == nil {
  45398. return v, errors.New("OldNickname requires an ID field in the mutation")
  45399. }
  45400. oldValue, err := m.oldValue(ctx)
  45401. if err != nil {
  45402. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45403. }
  45404. return oldValue.Nickname, nil
  45405. }
  45406. // ResetNickname resets all changes to the "nickname" field.
  45407. func (m *WxCardUserMutation) ResetNickname() {
  45408. m.nickname = nil
  45409. }
  45410. // SetRemark sets the "remark" field.
  45411. func (m *WxCardUserMutation) SetRemark(s string) {
  45412. m.remark = &s
  45413. }
  45414. // Remark returns the value of the "remark" field in the mutation.
  45415. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  45416. v := m.remark
  45417. if v == nil {
  45418. return
  45419. }
  45420. return *v, true
  45421. }
  45422. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  45423. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45425. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  45426. if !m.op.Is(OpUpdateOne) {
  45427. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  45428. }
  45429. if m.id == nil || m.oldValue == nil {
  45430. return v, errors.New("OldRemark requires an ID field in the mutation")
  45431. }
  45432. oldValue, err := m.oldValue(ctx)
  45433. if err != nil {
  45434. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  45435. }
  45436. return oldValue.Remark, nil
  45437. }
  45438. // ResetRemark resets all changes to the "remark" field.
  45439. func (m *WxCardUserMutation) ResetRemark() {
  45440. m.remark = nil
  45441. }
  45442. // SetPhone sets the "phone" field.
  45443. func (m *WxCardUserMutation) SetPhone(s string) {
  45444. m.phone = &s
  45445. }
  45446. // Phone returns the value of the "phone" field in the mutation.
  45447. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  45448. v := m.phone
  45449. if v == nil {
  45450. return
  45451. }
  45452. return *v, true
  45453. }
  45454. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  45455. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45457. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  45458. if !m.op.Is(OpUpdateOne) {
  45459. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  45460. }
  45461. if m.id == nil || m.oldValue == nil {
  45462. return v, errors.New("OldPhone requires an ID field in the mutation")
  45463. }
  45464. oldValue, err := m.oldValue(ctx)
  45465. if err != nil {
  45466. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  45467. }
  45468. return oldValue.Phone, nil
  45469. }
  45470. // ResetPhone resets all changes to the "phone" field.
  45471. func (m *WxCardUserMutation) ResetPhone() {
  45472. m.phone = nil
  45473. }
  45474. // SetOpenID sets the "open_id" field.
  45475. func (m *WxCardUserMutation) SetOpenID(s string) {
  45476. m.open_id = &s
  45477. }
  45478. // OpenID returns the value of the "open_id" field in the mutation.
  45479. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  45480. v := m.open_id
  45481. if v == nil {
  45482. return
  45483. }
  45484. return *v, true
  45485. }
  45486. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  45487. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45489. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  45490. if !m.op.Is(OpUpdateOne) {
  45491. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  45492. }
  45493. if m.id == nil || m.oldValue == nil {
  45494. return v, errors.New("OldOpenID requires an ID field in the mutation")
  45495. }
  45496. oldValue, err := m.oldValue(ctx)
  45497. if err != nil {
  45498. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  45499. }
  45500. return oldValue.OpenID, nil
  45501. }
  45502. // ResetOpenID resets all changes to the "open_id" field.
  45503. func (m *WxCardUserMutation) ResetOpenID() {
  45504. m.open_id = nil
  45505. }
  45506. // SetUnionID sets the "union_id" field.
  45507. func (m *WxCardUserMutation) SetUnionID(s string) {
  45508. m.union_id = &s
  45509. }
  45510. // UnionID returns the value of the "union_id" field in the mutation.
  45511. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  45512. v := m.union_id
  45513. if v == nil {
  45514. return
  45515. }
  45516. return *v, true
  45517. }
  45518. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  45519. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45521. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  45522. if !m.op.Is(OpUpdateOne) {
  45523. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  45524. }
  45525. if m.id == nil || m.oldValue == nil {
  45526. return v, errors.New("OldUnionID requires an ID field in the mutation")
  45527. }
  45528. oldValue, err := m.oldValue(ctx)
  45529. if err != nil {
  45530. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  45531. }
  45532. return oldValue.UnionID, nil
  45533. }
  45534. // ResetUnionID resets all changes to the "union_id" field.
  45535. func (m *WxCardUserMutation) ResetUnionID() {
  45536. m.union_id = nil
  45537. }
  45538. // SetSessionKey sets the "session_key" field.
  45539. func (m *WxCardUserMutation) SetSessionKey(s string) {
  45540. m.session_key = &s
  45541. }
  45542. // SessionKey returns the value of the "session_key" field in the mutation.
  45543. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  45544. v := m.session_key
  45545. if v == nil {
  45546. return
  45547. }
  45548. return *v, true
  45549. }
  45550. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  45551. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45553. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  45554. if !m.op.Is(OpUpdateOne) {
  45555. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  45556. }
  45557. if m.id == nil || m.oldValue == nil {
  45558. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  45559. }
  45560. oldValue, err := m.oldValue(ctx)
  45561. if err != nil {
  45562. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  45563. }
  45564. return oldValue.SessionKey, nil
  45565. }
  45566. // ResetSessionKey resets all changes to the "session_key" field.
  45567. func (m *WxCardUserMutation) ResetSessionKey() {
  45568. m.session_key = nil
  45569. }
  45570. // SetIsVip sets the "is_vip" field.
  45571. func (m *WxCardUserMutation) SetIsVip(i int) {
  45572. m.is_vip = &i
  45573. m.addis_vip = nil
  45574. }
  45575. // IsVip returns the value of the "is_vip" field in the mutation.
  45576. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  45577. v := m.is_vip
  45578. if v == nil {
  45579. return
  45580. }
  45581. return *v, true
  45582. }
  45583. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  45584. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45586. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  45587. if !m.op.Is(OpUpdateOne) {
  45588. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  45589. }
  45590. if m.id == nil || m.oldValue == nil {
  45591. return v, errors.New("OldIsVip requires an ID field in the mutation")
  45592. }
  45593. oldValue, err := m.oldValue(ctx)
  45594. if err != nil {
  45595. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  45596. }
  45597. return oldValue.IsVip, nil
  45598. }
  45599. // AddIsVip adds i to the "is_vip" field.
  45600. func (m *WxCardUserMutation) AddIsVip(i int) {
  45601. if m.addis_vip != nil {
  45602. *m.addis_vip += i
  45603. } else {
  45604. m.addis_vip = &i
  45605. }
  45606. }
  45607. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  45608. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  45609. v := m.addis_vip
  45610. if v == nil {
  45611. return
  45612. }
  45613. return *v, true
  45614. }
  45615. // ResetIsVip resets all changes to the "is_vip" field.
  45616. func (m *WxCardUserMutation) ResetIsVip() {
  45617. m.is_vip = nil
  45618. m.addis_vip = nil
  45619. }
  45620. // Where appends a list predicates to the WxCardUserMutation builder.
  45621. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  45622. m.predicates = append(m.predicates, ps...)
  45623. }
  45624. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  45625. // users can use type-assertion to append predicates that do not depend on any generated package.
  45626. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  45627. p := make([]predicate.WxCardUser, len(ps))
  45628. for i := range ps {
  45629. p[i] = ps[i]
  45630. }
  45631. m.Where(p...)
  45632. }
  45633. // Op returns the operation name.
  45634. func (m *WxCardUserMutation) Op() Op {
  45635. return m.op
  45636. }
  45637. // SetOp allows setting the mutation operation.
  45638. func (m *WxCardUserMutation) SetOp(op Op) {
  45639. m.op = op
  45640. }
  45641. // Type returns the node type of this mutation (WxCardUser).
  45642. func (m *WxCardUserMutation) Type() string {
  45643. return m.typ
  45644. }
  45645. // Fields returns all fields that were changed during this mutation. Note that in
  45646. // order to get all numeric fields that were incremented/decremented, call
  45647. // AddedFields().
  45648. func (m *WxCardUserMutation) Fields() []string {
  45649. fields := make([]string, 0, 13)
  45650. if m.created_at != nil {
  45651. fields = append(fields, wxcarduser.FieldCreatedAt)
  45652. }
  45653. if m.updated_at != nil {
  45654. fields = append(fields, wxcarduser.FieldUpdatedAt)
  45655. }
  45656. if m.deleted_at != nil {
  45657. fields = append(fields, wxcarduser.FieldDeletedAt)
  45658. }
  45659. if m.wxid != nil {
  45660. fields = append(fields, wxcarduser.FieldWxid)
  45661. }
  45662. if m.account != nil {
  45663. fields = append(fields, wxcarduser.FieldAccount)
  45664. }
  45665. if m.avatar != nil {
  45666. fields = append(fields, wxcarduser.FieldAvatar)
  45667. }
  45668. if m.nickname != nil {
  45669. fields = append(fields, wxcarduser.FieldNickname)
  45670. }
  45671. if m.remark != nil {
  45672. fields = append(fields, wxcarduser.FieldRemark)
  45673. }
  45674. if m.phone != nil {
  45675. fields = append(fields, wxcarduser.FieldPhone)
  45676. }
  45677. if m.open_id != nil {
  45678. fields = append(fields, wxcarduser.FieldOpenID)
  45679. }
  45680. if m.union_id != nil {
  45681. fields = append(fields, wxcarduser.FieldUnionID)
  45682. }
  45683. if m.session_key != nil {
  45684. fields = append(fields, wxcarduser.FieldSessionKey)
  45685. }
  45686. if m.is_vip != nil {
  45687. fields = append(fields, wxcarduser.FieldIsVip)
  45688. }
  45689. return fields
  45690. }
  45691. // Field returns the value of a field with the given name. The second boolean
  45692. // return value indicates that this field was not set, or was not defined in the
  45693. // schema.
  45694. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  45695. switch name {
  45696. case wxcarduser.FieldCreatedAt:
  45697. return m.CreatedAt()
  45698. case wxcarduser.FieldUpdatedAt:
  45699. return m.UpdatedAt()
  45700. case wxcarduser.FieldDeletedAt:
  45701. return m.DeletedAt()
  45702. case wxcarduser.FieldWxid:
  45703. return m.Wxid()
  45704. case wxcarduser.FieldAccount:
  45705. return m.Account()
  45706. case wxcarduser.FieldAvatar:
  45707. return m.Avatar()
  45708. case wxcarduser.FieldNickname:
  45709. return m.Nickname()
  45710. case wxcarduser.FieldRemark:
  45711. return m.Remark()
  45712. case wxcarduser.FieldPhone:
  45713. return m.Phone()
  45714. case wxcarduser.FieldOpenID:
  45715. return m.OpenID()
  45716. case wxcarduser.FieldUnionID:
  45717. return m.UnionID()
  45718. case wxcarduser.FieldSessionKey:
  45719. return m.SessionKey()
  45720. case wxcarduser.FieldIsVip:
  45721. return m.IsVip()
  45722. }
  45723. return nil, false
  45724. }
  45725. // OldField returns the old value of the field from the database. An error is
  45726. // returned if the mutation operation is not UpdateOne, or the query to the
  45727. // database failed.
  45728. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45729. switch name {
  45730. case wxcarduser.FieldCreatedAt:
  45731. return m.OldCreatedAt(ctx)
  45732. case wxcarduser.FieldUpdatedAt:
  45733. return m.OldUpdatedAt(ctx)
  45734. case wxcarduser.FieldDeletedAt:
  45735. return m.OldDeletedAt(ctx)
  45736. case wxcarduser.FieldWxid:
  45737. return m.OldWxid(ctx)
  45738. case wxcarduser.FieldAccount:
  45739. return m.OldAccount(ctx)
  45740. case wxcarduser.FieldAvatar:
  45741. return m.OldAvatar(ctx)
  45742. case wxcarduser.FieldNickname:
  45743. return m.OldNickname(ctx)
  45744. case wxcarduser.FieldRemark:
  45745. return m.OldRemark(ctx)
  45746. case wxcarduser.FieldPhone:
  45747. return m.OldPhone(ctx)
  45748. case wxcarduser.FieldOpenID:
  45749. return m.OldOpenID(ctx)
  45750. case wxcarduser.FieldUnionID:
  45751. return m.OldUnionID(ctx)
  45752. case wxcarduser.FieldSessionKey:
  45753. return m.OldSessionKey(ctx)
  45754. case wxcarduser.FieldIsVip:
  45755. return m.OldIsVip(ctx)
  45756. }
  45757. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  45758. }
  45759. // SetField sets the value of a field with the given name. It returns an error if
  45760. // the field is not defined in the schema, or if the type mismatched the field
  45761. // type.
  45762. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  45763. switch name {
  45764. case wxcarduser.FieldCreatedAt:
  45765. v, ok := value.(time.Time)
  45766. if !ok {
  45767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45768. }
  45769. m.SetCreatedAt(v)
  45770. return nil
  45771. case wxcarduser.FieldUpdatedAt:
  45772. v, ok := value.(time.Time)
  45773. if !ok {
  45774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45775. }
  45776. m.SetUpdatedAt(v)
  45777. return nil
  45778. case wxcarduser.FieldDeletedAt:
  45779. v, ok := value.(time.Time)
  45780. if !ok {
  45781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45782. }
  45783. m.SetDeletedAt(v)
  45784. return nil
  45785. case wxcarduser.FieldWxid:
  45786. v, ok := value.(string)
  45787. if !ok {
  45788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45789. }
  45790. m.SetWxid(v)
  45791. return nil
  45792. case wxcarduser.FieldAccount:
  45793. v, ok := value.(string)
  45794. if !ok {
  45795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45796. }
  45797. m.SetAccount(v)
  45798. return nil
  45799. case wxcarduser.FieldAvatar:
  45800. v, ok := value.(string)
  45801. if !ok {
  45802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45803. }
  45804. m.SetAvatar(v)
  45805. return nil
  45806. case wxcarduser.FieldNickname:
  45807. v, ok := value.(string)
  45808. if !ok {
  45809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45810. }
  45811. m.SetNickname(v)
  45812. return nil
  45813. case wxcarduser.FieldRemark:
  45814. v, ok := value.(string)
  45815. if !ok {
  45816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45817. }
  45818. m.SetRemark(v)
  45819. return nil
  45820. case wxcarduser.FieldPhone:
  45821. v, ok := value.(string)
  45822. if !ok {
  45823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45824. }
  45825. m.SetPhone(v)
  45826. return nil
  45827. case wxcarduser.FieldOpenID:
  45828. v, ok := value.(string)
  45829. if !ok {
  45830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45831. }
  45832. m.SetOpenID(v)
  45833. return nil
  45834. case wxcarduser.FieldUnionID:
  45835. v, ok := value.(string)
  45836. if !ok {
  45837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45838. }
  45839. m.SetUnionID(v)
  45840. return nil
  45841. case wxcarduser.FieldSessionKey:
  45842. v, ok := value.(string)
  45843. if !ok {
  45844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45845. }
  45846. m.SetSessionKey(v)
  45847. return nil
  45848. case wxcarduser.FieldIsVip:
  45849. v, ok := value.(int)
  45850. if !ok {
  45851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45852. }
  45853. m.SetIsVip(v)
  45854. return nil
  45855. }
  45856. return fmt.Errorf("unknown WxCardUser field %s", name)
  45857. }
  45858. // AddedFields returns all numeric fields that were incremented/decremented during
  45859. // this mutation.
  45860. func (m *WxCardUserMutation) AddedFields() []string {
  45861. var fields []string
  45862. if m.addis_vip != nil {
  45863. fields = append(fields, wxcarduser.FieldIsVip)
  45864. }
  45865. return fields
  45866. }
  45867. // AddedField returns the numeric value that was incremented/decremented on a field
  45868. // with the given name. The second boolean return value indicates that this field
  45869. // was not set, or was not defined in the schema.
  45870. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  45871. switch name {
  45872. case wxcarduser.FieldIsVip:
  45873. return m.AddedIsVip()
  45874. }
  45875. return nil, false
  45876. }
  45877. // AddField adds the value to the field with the given name. It returns an error if
  45878. // the field is not defined in the schema, or if the type mismatched the field
  45879. // type.
  45880. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  45881. switch name {
  45882. case wxcarduser.FieldIsVip:
  45883. v, ok := value.(int)
  45884. if !ok {
  45885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45886. }
  45887. m.AddIsVip(v)
  45888. return nil
  45889. }
  45890. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  45891. }
  45892. // ClearedFields returns all nullable fields that were cleared during this
  45893. // mutation.
  45894. func (m *WxCardUserMutation) ClearedFields() []string {
  45895. var fields []string
  45896. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  45897. fields = append(fields, wxcarduser.FieldDeletedAt)
  45898. }
  45899. return fields
  45900. }
  45901. // FieldCleared returns a boolean indicating if a field with the given name was
  45902. // cleared in this mutation.
  45903. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  45904. _, ok := m.clearedFields[name]
  45905. return ok
  45906. }
  45907. // ClearField clears the value of the field with the given name. It returns an
  45908. // error if the field is not defined in the schema.
  45909. func (m *WxCardUserMutation) ClearField(name string) error {
  45910. switch name {
  45911. case wxcarduser.FieldDeletedAt:
  45912. m.ClearDeletedAt()
  45913. return nil
  45914. }
  45915. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  45916. }
  45917. // ResetField resets all changes in the mutation for the field with the given name.
  45918. // It returns an error if the field is not defined in the schema.
  45919. func (m *WxCardUserMutation) ResetField(name string) error {
  45920. switch name {
  45921. case wxcarduser.FieldCreatedAt:
  45922. m.ResetCreatedAt()
  45923. return nil
  45924. case wxcarduser.FieldUpdatedAt:
  45925. m.ResetUpdatedAt()
  45926. return nil
  45927. case wxcarduser.FieldDeletedAt:
  45928. m.ResetDeletedAt()
  45929. return nil
  45930. case wxcarduser.FieldWxid:
  45931. m.ResetWxid()
  45932. return nil
  45933. case wxcarduser.FieldAccount:
  45934. m.ResetAccount()
  45935. return nil
  45936. case wxcarduser.FieldAvatar:
  45937. m.ResetAvatar()
  45938. return nil
  45939. case wxcarduser.FieldNickname:
  45940. m.ResetNickname()
  45941. return nil
  45942. case wxcarduser.FieldRemark:
  45943. m.ResetRemark()
  45944. return nil
  45945. case wxcarduser.FieldPhone:
  45946. m.ResetPhone()
  45947. return nil
  45948. case wxcarduser.FieldOpenID:
  45949. m.ResetOpenID()
  45950. return nil
  45951. case wxcarduser.FieldUnionID:
  45952. m.ResetUnionID()
  45953. return nil
  45954. case wxcarduser.FieldSessionKey:
  45955. m.ResetSessionKey()
  45956. return nil
  45957. case wxcarduser.FieldIsVip:
  45958. m.ResetIsVip()
  45959. return nil
  45960. }
  45961. return fmt.Errorf("unknown WxCardUser field %s", name)
  45962. }
  45963. // AddedEdges returns all edge names that were set/added in this mutation.
  45964. func (m *WxCardUserMutation) AddedEdges() []string {
  45965. edges := make([]string, 0, 0)
  45966. return edges
  45967. }
  45968. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45969. // name in this mutation.
  45970. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  45971. return nil
  45972. }
  45973. // RemovedEdges returns all edge names that were removed in this mutation.
  45974. func (m *WxCardUserMutation) RemovedEdges() []string {
  45975. edges := make([]string, 0, 0)
  45976. return edges
  45977. }
  45978. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45979. // the given name in this mutation.
  45980. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  45981. return nil
  45982. }
  45983. // ClearedEdges returns all edge names that were cleared in this mutation.
  45984. func (m *WxCardUserMutation) ClearedEdges() []string {
  45985. edges := make([]string, 0, 0)
  45986. return edges
  45987. }
  45988. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45989. // was cleared in this mutation.
  45990. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  45991. return false
  45992. }
  45993. // ClearEdge clears the value of the edge with the given name. It returns an error
  45994. // if that edge is not defined in the schema.
  45995. func (m *WxCardUserMutation) ClearEdge(name string) error {
  45996. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  45997. }
  45998. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45999. // It returns an error if the edge is not defined in the schema.
  46000. func (m *WxCardUserMutation) ResetEdge(name string) error {
  46001. return fmt.Errorf("unknown WxCardUser edge %s", name)
  46002. }
  46003. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  46004. type WxCardVisitMutation struct {
  46005. config
  46006. op Op
  46007. typ string
  46008. id *uint64
  46009. created_at *time.Time
  46010. updated_at *time.Time
  46011. deleted_at *time.Time
  46012. user_id *uint64
  46013. adduser_id *int64
  46014. bot_id *uint64
  46015. addbot_id *int64
  46016. bot_type *uint8
  46017. addbot_type *int8
  46018. clearedFields map[string]struct{}
  46019. done bool
  46020. oldValue func(context.Context) (*WxCardVisit, error)
  46021. predicates []predicate.WxCardVisit
  46022. }
  46023. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  46024. // wxcardvisitOption allows management of the mutation configuration using functional options.
  46025. type wxcardvisitOption func(*WxCardVisitMutation)
  46026. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  46027. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  46028. m := &WxCardVisitMutation{
  46029. config: c,
  46030. op: op,
  46031. typ: TypeWxCardVisit,
  46032. clearedFields: make(map[string]struct{}),
  46033. }
  46034. for _, opt := range opts {
  46035. opt(m)
  46036. }
  46037. return m
  46038. }
  46039. // withWxCardVisitID sets the ID field of the mutation.
  46040. func withWxCardVisitID(id uint64) wxcardvisitOption {
  46041. return func(m *WxCardVisitMutation) {
  46042. var (
  46043. err error
  46044. once sync.Once
  46045. value *WxCardVisit
  46046. )
  46047. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  46048. once.Do(func() {
  46049. if m.done {
  46050. err = errors.New("querying old values post mutation is not allowed")
  46051. } else {
  46052. value, err = m.Client().WxCardVisit.Get(ctx, id)
  46053. }
  46054. })
  46055. return value, err
  46056. }
  46057. m.id = &id
  46058. }
  46059. }
  46060. // withWxCardVisit sets the old WxCardVisit of the mutation.
  46061. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  46062. return func(m *WxCardVisitMutation) {
  46063. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  46064. return node, nil
  46065. }
  46066. m.id = &node.ID
  46067. }
  46068. }
  46069. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46070. // executed in a transaction (ent.Tx), a transactional client is returned.
  46071. func (m WxCardVisitMutation) Client() *Client {
  46072. client := &Client{config: m.config}
  46073. client.init()
  46074. return client
  46075. }
  46076. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46077. // it returns an error otherwise.
  46078. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  46079. if _, ok := m.driver.(*txDriver); !ok {
  46080. return nil, errors.New("ent: mutation is not running in a transaction")
  46081. }
  46082. tx := &Tx{config: m.config}
  46083. tx.init()
  46084. return tx, nil
  46085. }
  46086. // SetID sets the value of the id field. Note that this
  46087. // operation is only accepted on creation of WxCardVisit entities.
  46088. func (m *WxCardVisitMutation) SetID(id uint64) {
  46089. m.id = &id
  46090. }
  46091. // ID returns the ID value in the mutation. Note that the ID is only available
  46092. // if it was provided to the builder or after it was returned from the database.
  46093. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  46094. if m.id == nil {
  46095. return
  46096. }
  46097. return *m.id, true
  46098. }
  46099. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46100. // That means, if the mutation is applied within a transaction with an isolation level such
  46101. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46102. // or updated by the mutation.
  46103. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  46104. switch {
  46105. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46106. id, exists := m.ID()
  46107. if exists {
  46108. return []uint64{id}, nil
  46109. }
  46110. fallthrough
  46111. case m.op.Is(OpUpdate | OpDelete):
  46112. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  46113. default:
  46114. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46115. }
  46116. }
  46117. // SetCreatedAt sets the "created_at" field.
  46118. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  46119. m.created_at = &t
  46120. }
  46121. // CreatedAt returns the value of the "created_at" field in the mutation.
  46122. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  46123. v := m.created_at
  46124. if v == nil {
  46125. return
  46126. }
  46127. return *v, true
  46128. }
  46129. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  46130. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46132. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46133. if !m.op.Is(OpUpdateOne) {
  46134. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46135. }
  46136. if m.id == nil || m.oldValue == nil {
  46137. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46138. }
  46139. oldValue, err := m.oldValue(ctx)
  46140. if err != nil {
  46141. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46142. }
  46143. return oldValue.CreatedAt, nil
  46144. }
  46145. // ResetCreatedAt resets all changes to the "created_at" field.
  46146. func (m *WxCardVisitMutation) ResetCreatedAt() {
  46147. m.created_at = nil
  46148. }
  46149. // SetUpdatedAt sets the "updated_at" field.
  46150. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  46151. m.updated_at = &t
  46152. }
  46153. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46154. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  46155. v := m.updated_at
  46156. if v == nil {
  46157. return
  46158. }
  46159. return *v, true
  46160. }
  46161. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  46162. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46164. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46165. if !m.op.Is(OpUpdateOne) {
  46166. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46167. }
  46168. if m.id == nil || m.oldValue == nil {
  46169. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46170. }
  46171. oldValue, err := m.oldValue(ctx)
  46172. if err != nil {
  46173. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46174. }
  46175. return oldValue.UpdatedAt, nil
  46176. }
  46177. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46178. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  46179. m.updated_at = nil
  46180. }
  46181. // SetDeletedAt sets the "deleted_at" field.
  46182. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  46183. m.deleted_at = &t
  46184. }
  46185. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46186. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  46187. v := m.deleted_at
  46188. if v == nil {
  46189. return
  46190. }
  46191. return *v, true
  46192. }
  46193. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  46194. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46196. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46197. if !m.op.Is(OpUpdateOne) {
  46198. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46199. }
  46200. if m.id == nil || m.oldValue == nil {
  46201. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46202. }
  46203. oldValue, err := m.oldValue(ctx)
  46204. if err != nil {
  46205. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46206. }
  46207. return oldValue.DeletedAt, nil
  46208. }
  46209. // ClearDeletedAt clears the value of the "deleted_at" field.
  46210. func (m *WxCardVisitMutation) ClearDeletedAt() {
  46211. m.deleted_at = nil
  46212. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  46213. }
  46214. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46215. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  46216. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  46217. return ok
  46218. }
  46219. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46220. func (m *WxCardVisitMutation) ResetDeletedAt() {
  46221. m.deleted_at = nil
  46222. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  46223. }
  46224. // SetUserID sets the "user_id" field.
  46225. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  46226. m.user_id = &u
  46227. m.adduser_id = nil
  46228. }
  46229. // UserID returns the value of the "user_id" field in the mutation.
  46230. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  46231. v := m.user_id
  46232. if v == nil {
  46233. return
  46234. }
  46235. return *v, true
  46236. }
  46237. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  46238. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46240. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  46241. if !m.op.Is(OpUpdateOne) {
  46242. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  46243. }
  46244. if m.id == nil || m.oldValue == nil {
  46245. return v, errors.New("OldUserID requires an ID field in the mutation")
  46246. }
  46247. oldValue, err := m.oldValue(ctx)
  46248. if err != nil {
  46249. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  46250. }
  46251. return oldValue.UserID, nil
  46252. }
  46253. // AddUserID adds u to the "user_id" field.
  46254. func (m *WxCardVisitMutation) AddUserID(u int64) {
  46255. if m.adduser_id != nil {
  46256. *m.adduser_id += u
  46257. } else {
  46258. m.adduser_id = &u
  46259. }
  46260. }
  46261. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  46262. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  46263. v := m.adduser_id
  46264. if v == nil {
  46265. return
  46266. }
  46267. return *v, true
  46268. }
  46269. // ClearUserID clears the value of the "user_id" field.
  46270. func (m *WxCardVisitMutation) ClearUserID() {
  46271. m.user_id = nil
  46272. m.adduser_id = nil
  46273. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  46274. }
  46275. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  46276. func (m *WxCardVisitMutation) UserIDCleared() bool {
  46277. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  46278. return ok
  46279. }
  46280. // ResetUserID resets all changes to the "user_id" field.
  46281. func (m *WxCardVisitMutation) ResetUserID() {
  46282. m.user_id = nil
  46283. m.adduser_id = nil
  46284. delete(m.clearedFields, wxcardvisit.FieldUserID)
  46285. }
  46286. // SetBotID sets the "bot_id" field.
  46287. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  46288. m.bot_id = &u
  46289. m.addbot_id = nil
  46290. }
  46291. // BotID returns the value of the "bot_id" field in the mutation.
  46292. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  46293. v := m.bot_id
  46294. if v == nil {
  46295. return
  46296. }
  46297. return *v, true
  46298. }
  46299. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  46300. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46302. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  46303. if !m.op.Is(OpUpdateOne) {
  46304. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  46305. }
  46306. if m.id == nil || m.oldValue == nil {
  46307. return v, errors.New("OldBotID requires an ID field in the mutation")
  46308. }
  46309. oldValue, err := m.oldValue(ctx)
  46310. if err != nil {
  46311. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  46312. }
  46313. return oldValue.BotID, nil
  46314. }
  46315. // AddBotID adds u to the "bot_id" field.
  46316. func (m *WxCardVisitMutation) AddBotID(u int64) {
  46317. if m.addbot_id != nil {
  46318. *m.addbot_id += u
  46319. } else {
  46320. m.addbot_id = &u
  46321. }
  46322. }
  46323. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  46324. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  46325. v := m.addbot_id
  46326. if v == nil {
  46327. return
  46328. }
  46329. return *v, true
  46330. }
  46331. // ResetBotID resets all changes to the "bot_id" field.
  46332. func (m *WxCardVisitMutation) ResetBotID() {
  46333. m.bot_id = nil
  46334. m.addbot_id = nil
  46335. }
  46336. // SetBotType sets the "bot_type" field.
  46337. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  46338. m.bot_type = &u
  46339. m.addbot_type = nil
  46340. }
  46341. // BotType returns the value of the "bot_type" field in the mutation.
  46342. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  46343. v := m.bot_type
  46344. if v == nil {
  46345. return
  46346. }
  46347. return *v, true
  46348. }
  46349. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  46350. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46352. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  46353. if !m.op.Is(OpUpdateOne) {
  46354. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  46355. }
  46356. if m.id == nil || m.oldValue == nil {
  46357. return v, errors.New("OldBotType requires an ID field in the mutation")
  46358. }
  46359. oldValue, err := m.oldValue(ctx)
  46360. if err != nil {
  46361. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  46362. }
  46363. return oldValue.BotType, nil
  46364. }
  46365. // AddBotType adds u to the "bot_type" field.
  46366. func (m *WxCardVisitMutation) AddBotType(u int8) {
  46367. if m.addbot_type != nil {
  46368. *m.addbot_type += u
  46369. } else {
  46370. m.addbot_type = &u
  46371. }
  46372. }
  46373. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  46374. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  46375. v := m.addbot_type
  46376. if v == nil {
  46377. return
  46378. }
  46379. return *v, true
  46380. }
  46381. // ResetBotType resets all changes to the "bot_type" field.
  46382. func (m *WxCardVisitMutation) ResetBotType() {
  46383. m.bot_type = nil
  46384. m.addbot_type = nil
  46385. }
  46386. // Where appends a list predicates to the WxCardVisitMutation builder.
  46387. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  46388. m.predicates = append(m.predicates, ps...)
  46389. }
  46390. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  46391. // users can use type-assertion to append predicates that do not depend on any generated package.
  46392. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  46393. p := make([]predicate.WxCardVisit, len(ps))
  46394. for i := range ps {
  46395. p[i] = ps[i]
  46396. }
  46397. m.Where(p...)
  46398. }
  46399. // Op returns the operation name.
  46400. func (m *WxCardVisitMutation) Op() Op {
  46401. return m.op
  46402. }
  46403. // SetOp allows setting the mutation operation.
  46404. func (m *WxCardVisitMutation) SetOp(op Op) {
  46405. m.op = op
  46406. }
  46407. // Type returns the node type of this mutation (WxCardVisit).
  46408. func (m *WxCardVisitMutation) Type() string {
  46409. return m.typ
  46410. }
  46411. // Fields returns all fields that were changed during this mutation. Note that in
  46412. // order to get all numeric fields that were incremented/decremented, call
  46413. // AddedFields().
  46414. func (m *WxCardVisitMutation) Fields() []string {
  46415. fields := make([]string, 0, 6)
  46416. if m.created_at != nil {
  46417. fields = append(fields, wxcardvisit.FieldCreatedAt)
  46418. }
  46419. if m.updated_at != nil {
  46420. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  46421. }
  46422. if m.deleted_at != nil {
  46423. fields = append(fields, wxcardvisit.FieldDeletedAt)
  46424. }
  46425. if m.user_id != nil {
  46426. fields = append(fields, wxcardvisit.FieldUserID)
  46427. }
  46428. if m.bot_id != nil {
  46429. fields = append(fields, wxcardvisit.FieldBotID)
  46430. }
  46431. if m.bot_type != nil {
  46432. fields = append(fields, wxcardvisit.FieldBotType)
  46433. }
  46434. return fields
  46435. }
  46436. // Field returns the value of a field with the given name. The second boolean
  46437. // return value indicates that this field was not set, or was not defined in the
  46438. // schema.
  46439. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  46440. switch name {
  46441. case wxcardvisit.FieldCreatedAt:
  46442. return m.CreatedAt()
  46443. case wxcardvisit.FieldUpdatedAt:
  46444. return m.UpdatedAt()
  46445. case wxcardvisit.FieldDeletedAt:
  46446. return m.DeletedAt()
  46447. case wxcardvisit.FieldUserID:
  46448. return m.UserID()
  46449. case wxcardvisit.FieldBotID:
  46450. return m.BotID()
  46451. case wxcardvisit.FieldBotType:
  46452. return m.BotType()
  46453. }
  46454. return nil, false
  46455. }
  46456. // OldField returns the old value of the field from the database. An error is
  46457. // returned if the mutation operation is not UpdateOne, or the query to the
  46458. // database failed.
  46459. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46460. switch name {
  46461. case wxcardvisit.FieldCreatedAt:
  46462. return m.OldCreatedAt(ctx)
  46463. case wxcardvisit.FieldUpdatedAt:
  46464. return m.OldUpdatedAt(ctx)
  46465. case wxcardvisit.FieldDeletedAt:
  46466. return m.OldDeletedAt(ctx)
  46467. case wxcardvisit.FieldUserID:
  46468. return m.OldUserID(ctx)
  46469. case wxcardvisit.FieldBotID:
  46470. return m.OldBotID(ctx)
  46471. case wxcardvisit.FieldBotType:
  46472. return m.OldBotType(ctx)
  46473. }
  46474. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  46475. }
  46476. // SetField sets the value of a field with the given name. It returns an error if
  46477. // the field is not defined in the schema, or if the type mismatched the field
  46478. // type.
  46479. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  46480. switch name {
  46481. case wxcardvisit.FieldCreatedAt:
  46482. v, ok := value.(time.Time)
  46483. if !ok {
  46484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46485. }
  46486. m.SetCreatedAt(v)
  46487. return nil
  46488. case wxcardvisit.FieldUpdatedAt:
  46489. v, ok := value.(time.Time)
  46490. if !ok {
  46491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46492. }
  46493. m.SetUpdatedAt(v)
  46494. return nil
  46495. case wxcardvisit.FieldDeletedAt:
  46496. v, ok := value.(time.Time)
  46497. if !ok {
  46498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46499. }
  46500. m.SetDeletedAt(v)
  46501. return nil
  46502. case wxcardvisit.FieldUserID:
  46503. v, ok := value.(uint64)
  46504. if !ok {
  46505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46506. }
  46507. m.SetUserID(v)
  46508. return nil
  46509. case wxcardvisit.FieldBotID:
  46510. v, ok := value.(uint64)
  46511. if !ok {
  46512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46513. }
  46514. m.SetBotID(v)
  46515. return nil
  46516. case wxcardvisit.FieldBotType:
  46517. v, ok := value.(uint8)
  46518. if !ok {
  46519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46520. }
  46521. m.SetBotType(v)
  46522. return nil
  46523. }
  46524. return fmt.Errorf("unknown WxCardVisit field %s", name)
  46525. }
  46526. // AddedFields returns all numeric fields that were incremented/decremented during
  46527. // this mutation.
  46528. func (m *WxCardVisitMutation) AddedFields() []string {
  46529. var fields []string
  46530. if m.adduser_id != nil {
  46531. fields = append(fields, wxcardvisit.FieldUserID)
  46532. }
  46533. if m.addbot_id != nil {
  46534. fields = append(fields, wxcardvisit.FieldBotID)
  46535. }
  46536. if m.addbot_type != nil {
  46537. fields = append(fields, wxcardvisit.FieldBotType)
  46538. }
  46539. return fields
  46540. }
  46541. // AddedField returns the numeric value that was incremented/decremented on a field
  46542. // with the given name. The second boolean return value indicates that this field
  46543. // was not set, or was not defined in the schema.
  46544. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  46545. switch name {
  46546. case wxcardvisit.FieldUserID:
  46547. return m.AddedUserID()
  46548. case wxcardvisit.FieldBotID:
  46549. return m.AddedBotID()
  46550. case wxcardvisit.FieldBotType:
  46551. return m.AddedBotType()
  46552. }
  46553. return nil, false
  46554. }
  46555. // AddField adds the value to the field with the given name. It returns an error if
  46556. // the field is not defined in the schema, or if the type mismatched the field
  46557. // type.
  46558. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  46559. switch name {
  46560. case wxcardvisit.FieldUserID:
  46561. v, ok := value.(int64)
  46562. if !ok {
  46563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46564. }
  46565. m.AddUserID(v)
  46566. return nil
  46567. case wxcardvisit.FieldBotID:
  46568. v, ok := value.(int64)
  46569. if !ok {
  46570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46571. }
  46572. m.AddBotID(v)
  46573. return nil
  46574. case wxcardvisit.FieldBotType:
  46575. v, ok := value.(int8)
  46576. if !ok {
  46577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46578. }
  46579. m.AddBotType(v)
  46580. return nil
  46581. }
  46582. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  46583. }
  46584. // ClearedFields returns all nullable fields that were cleared during this
  46585. // mutation.
  46586. func (m *WxCardVisitMutation) ClearedFields() []string {
  46587. var fields []string
  46588. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  46589. fields = append(fields, wxcardvisit.FieldDeletedAt)
  46590. }
  46591. if m.FieldCleared(wxcardvisit.FieldUserID) {
  46592. fields = append(fields, wxcardvisit.FieldUserID)
  46593. }
  46594. return fields
  46595. }
  46596. // FieldCleared returns a boolean indicating if a field with the given name was
  46597. // cleared in this mutation.
  46598. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  46599. _, ok := m.clearedFields[name]
  46600. return ok
  46601. }
  46602. // ClearField clears the value of the field with the given name. It returns an
  46603. // error if the field is not defined in the schema.
  46604. func (m *WxCardVisitMutation) ClearField(name string) error {
  46605. switch name {
  46606. case wxcardvisit.FieldDeletedAt:
  46607. m.ClearDeletedAt()
  46608. return nil
  46609. case wxcardvisit.FieldUserID:
  46610. m.ClearUserID()
  46611. return nil
  46612. }
  46613. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  46614. }
  46615. // ResetField resets all changes in the mutation for the field with the given name.
  46616. // It returns an error if the field is not defined in the schema.
  46617. func (m *WxCardVisitMutation) ResetField(name string) error {
  46618. switch name {
  46619. case wxcardvisit.FieldCreatedAt:
  46620. m.ResetCreatedAt()
  46621. return nil
  46622. case wxcardvisit.FieldUpdatedAt:
  46623. m.ResetUpdatedAt()
  46624. return nil
  46625. case wxcardvisit.FieldDeletedAt:
  46626. m.ResetDeletedAt()
  46627. return nil
  46628. case wxcardvisit.FieldUserID:
  46629. m.ResetUserID()
  46630. return nil
  46631. case wxcardvisit.FieldBotID:
  46632. m.ResetBotID()
  46633. return nil
  46634. case wxcardvisit.FieldBotType:
  46635. m.ResetBotType()
  46636. return nil
  46637. }
  46638. return fmt.Errorf("unknown WxCardVisit field %s", name)
  46639. }
  46640. // AddedEdges returns all edge names that were set/added in this mutation.
  46641. func (m *WxCardVisitMutation) AddedEdges() []string {
  46642. edges := make([]string, 0, 0)
  46643. return edges
  46644. }
  46645. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46646. // name in this mutation.
  46647. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  46648. return nil
  46649. }
  46650. // RemovedEdges returns all edge names that were removed in this mutation.
  46651. func (m *WxCardVisitMutation) RemovedEdges() []string {
  46652. edges := make([]string, 0, 0)
  46653. return edges
  46654. }
  46655. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46656. // the given name in this mutation.
  46657. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  46658. return nil
  46659. }
  46660. // ClearedEdges returns all edge names that were cleared in this mutation.
  46661. func (m *WxCardVisitMutation) ClearedEdges() []string {
  46662. edges := make([]string, 0, 0)
  46663. return edges
  46664. }
  46665. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46666. // was cleared in this mutation.
  46667. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  46668. return false
  46669. }
  46670. // ClearEdge clears the value of the edge with the given name. It returns an error
  46671. // if that edge is not defined in the schema.
  46672. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  46673. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  46674. }
  46675. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46676. // It returns an error if the edge is not defined in the schema.
  46677. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  46678. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  46679. }