mutation.go 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/apikey"
  14. "wechat-api/ent/batchmsg"
  15. "wechat-api/ent/category"
  16. "wechat-api/ent/chatrecords"
  17. "wechat-api/ent/chatsession"
  18. "wechat-api/ent/contact"
  19. "wechat-api/ent/creditbalance"
  20. "wechat-api/ent/creditusage"
  21. "wechat-api/ent/custom_types"
  22. "wechat-api/ent/employee"
  23. "wechat-api/ent/employeeconfig"
  24. "wechat-api/ent/label"
  25. "wechat-api/ent/labelrelationship"
  26. "wechat-api/ent/labeltagging"
  27. "wechat-api/ent/message"
  28. "wechat-api/ent/messagerecords"
  29. "wechat-api/ent/msg"
  30. "wechat-api/ent/payrecharge"
  31. "wechat-api/ent/predicate"
  32. "wechat-api/ent/server"
  33. "wechat-api/ent/sopnode"
  34. "wechat-api/ent/sopstage"
  35. "wechat-api/ent/soptask"
  36. "wechat-api/ent/token"
  37. "wechat-api/ent/tutorial"
  38. "wechat-api/ent/usagedetail"
  39. "wechat-api/ent/usagestatisticday"
  40. "wechat-api/ent/usagestatistichour"
  41. "wechat-api/ent/usagestatisticmonth"
  42. "wechat-api/ent/usagetotal"
  43. "wechat-api/ent/whatsapp"
  44. "wechat-api/ent/whatsappchannel"
  45. "wechat-api/ent/workexperience"
  46. "wechat-api/ent/wpchatroom"
  47. "wechat-api/ent/wpchatroommember"
  48. "wechat-api/ent/wx"
  49. "wechat-api/ent/wxcard"
  50. "wechat-api/ent/wxcarduser"
  51. "wechat-api/ent/wxcardvisit"
  52. "wechat-api/ent/xunji"
  53. "wechat-api/ent/xunjiservice"
  54. "entgo.io/ent"
  55. "entgo.io/ent/dialect/sql"
  56. )
  57. const (
  58. // Operation types.
  59. OpCreate = ent.OpCreate
  60. OpDelete = ent.OpDelete
  61. OpDeleteOne = ent.OpDeleteOne
  62. OpUpdate = ent.OpUpdate
  63. OpUpdateOne = ent.OpUpdateOne
  64. // Node types.
  65. TypeAgent = "Agent"
  66. TypeAgentBase = "AgentBase"
  67. TypeAliyunAvatar = "AliyunAvatar"
  68. TypeAllocAgent = "AllocAgent"
  69. TypeApiKey = "ApiKey"
  70. TypeBatchMsg = "BatchMsg"
  71. TypeCategory = "Category"
  72. TypeChatRecords = "ChatRecords"
  73. TypeChatSession = "ChatSession"
  74. TypeContact = "Contact"
  75. TypeCreditBalance = "CreditBalance"
  76. TypeCreditUsage = "CreditUsage"
  77. TypeEmployee = "Employee"
  78. TypeEmployeeConfig = "EmployeeConfig"
  79. TypeLabel = "Label"
  80. TypeLabelRelationship = "LabelRelationship"
  81. TypeLabelTagging = "LabelTagging"
  82. TypeMessage = "Message"
  83. TypeMessageRecords = "MessageRecords"
  84. TypeMsg = "Msg"
  85. TypePayRecharge = "PayRecharge"
  86. TypeServer = "Server"
  87. TypeSopNode = "SopNode"
  88. TypeSopStage = "SopStage"
  89. TypeSopTask = "SopTask"
  90. TypeToken = "Token"
  91. TypeTutorial = "Tutorial"
  92. TypeUsageDetail = "UsageDetail"
  93. TypeUsageStatisticDay = "UsageStatisticDay"
  94. TypeUsageStatisticHour = "UsageStatisticHour"
  95. TypeUsageStatisticMonth = "UsageStatisticMonth"
  96. TypeUsageTotal = "UsageTotal"
  97. TypeWhatsapp = "Whatsapp"
  98. TypeWhatsappChannel = "WhatsappChannel"
  99. TypeWorkExperience = "WorkExperience"
  100. TypeWpChatroom = "WpChatroom"
  101. TypeWpChatroomMember = "WpChatroomMember"
  102. TypeWx = "Wx"
  103. TypeWxCard = "WxCard"
  104. TypeWxCardUser = "WxCardUser"
  105. TypeWxCardVisit = "WxCardVisit"
  106. TypeXunji = "Xunji"
  107. TypeXunjiService = "XunjiService"
  108. )
  109. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  110. type AgentMutation struct {
  111. config
  112. op Op
  113. typ string
  114. id *uint64
  115. created_at *time.Time
  116. updated_at *time.Time
  117. deleted_at *time.Time
  118. name *string
  119. role *string
  120. status *int
  121. addstatus *int
  122. background *string
  123. examples *string
  124. organization_id *uint64
  125. addorganization_id *int64
  126. dataset_id *string
  127. collection_id *string
  128. clearedFields map[string]struct{}
  129. wx_agent map[uint64]struct{}
  130. removedwx_agent map[uint64]struct{}
  131. clearedwx_agent bool
  132. token_agent map[uint64]struct{}
  133. removedtoken_agent map[uint64]struct{}
  134. clearedtoken_agent bool
  135. wa_agent map[uint64]struct{}
  136. removedwa_agent map[uint64]struct{}
  137. clearedwa_agent bool
  138. key_agent map[uint64]struct{}
  139. removedkey_agent map[uint64]struct{}
  140. clearedkey_agent bool
  141. xjs_agent map[uint64]struct{}
  142. removedxjs_agent map[uint64]struct{}
  143. clearedxjs_agent bool
  144. done bool
  145. oldValue func(context.Context) (*Agent, error)
  146. predicates []predicate.Agent
  147. }
  148. var _ ent.Mutation = (*AgentMutation)(nil)
  149. // agentOption allows management of the mutation configuration using functional options.
  150. type agentOption func(*AgentMutation)
  151. // newAgentMutation creates new mutation for the Agent entity.
  152. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  153. m := &AgentMutation{
  154. config: c,
  155. op: op,
  156. typ: TypeAgent,
  157. clearedFields: make(map[string]struct{}),
  158. }
  159. for _, opt := range opts {
  160. opt(m)
  161. }
  162. return m
  163. }
  164. // withAgentID sets the ID field of the mutation.
  165. func withAgentID(id uint64) agentOption {
  166. return func(m *AgentMutation) {
  167. var (
  168. err error
  169. once sync.Once
  170. value *Agent
  171. )
  172. m.oldValue = func(ctx context.Context) (*Agent, error) {
  173. once.Do(func() {
  174. if m.done {
  175. err = errors.New("querying old values post mutation is not allowed")
  176. } else {
  177. value, err = m.Client().Agent.Get(ctx, id)
  178. }
  179. })
  180. return value, err
  181. }
  182. m.id = &id
  183. }
  184. }
  185. // withAgent sets the old Agent of the mutation.
  186. func withAgent(node *Agent) agentOption {
  187. return func(m *AgentMutation) {
  188. m.oldValue = func(context.Context) (*Agent, error) {
  189. return node, nil
  190. }
  191. m.id = &node.ID
  192. }
  193. }
  194. // Client returns a new `ent.Client` from the mutation. If the mutation was
  195. // executed in a transaction (ent.Tx), a transactional client is returned.
  196. func (m AgentMutation) Client() *Client {
  197. client := &Client{config: m.config}
  198. client.init()
  199. return client
  200. }
  201. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  202. // it returns an error otherwise.
  203. func (m AgentMutation) Tx() (*Tx, error) {
  204. if _, ok := m.driver.(*txDriver); !ok {
  205. return nil, errors.New("ent: mutation is not running in a transaction")
  206. }
  207. tx := &Tx{config: m.config}
  208. tx.init()
  209. return tx, nil
  210. }
  211. // SetID sets the value of the id field. Note that this
  212. // operation is only accepted on creation of Agent entities.
  213. func (m *AgentMutation) SetID(id uint64) {
  214. m.id = &id
  215. }
  216. // ID returns the ID value in the mutation. Note that the ID is only available
  217. // if it was provided to the builder or after it was returned from the database.
  218. func (m *AgentMutation) ID() (id uint64, exists bool) {
  219. if m.id == nil {
  220. return
  221. }
  222. return *m.id, true
  223. }
  224. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  225. // That means, if the mutation is applied within a transaction with an isolation level such
  226. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  227. // or updated by the mutation.
  228. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  229. switch {
  230. case m.op.Is(OpUpdateOne | OpDeleteOne):
  231. id, exists := m.ID()
  232. if exists {
  233. return []uint64{id}, nil
  234. }
  235. fallthrough
  236. case m.op.Is(OpUpdate | OpDelete):
  237. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  238. default:
  239. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  240. }
  241. }
  242. // SetCreatedAt sets the "created_at" field.
  243. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  244. m.created_at = &t
  245. }
  246. // CreatedAt returns the value of the "created_at" field in the mutation.
  247. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  248. v := m.created_at
  249. if v == nil {
  250. return
  251. }
  252. return *v, true
  253. }
  254. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  255. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  257. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  258. if !m.op.Is(OpUpdateOne) {
  259. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  260. }
  261. if m.id == nil || m.oldValue == nil {
  262. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  263. }
  264. oldValue, err := m.oldValue(ctx)
  265. if err != nil {
  266. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  267. }
  268. return oldValue.CreatedAt, nil
  269. }
  270. // ResetCreatedAt resets all changes to the "created_at" field.
  271. func (m *AgentMutation) ResetCreatedAt() {
  272. m.created_at = nil
  273. }
  274. // SetUpdatedAt sets the "updated_at" field.
  275. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  276. m.updated_at = &t
  277. }
  278. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  279. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  280. v := m.updated_at
  281. if v == nil {
  282. return
  283. }
  284. return *v, true
  285. }
  286. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  287. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  289. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  290. if !m.op.Is(OpUpdateOne) {
  291. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  292. }
  293. if m.id == nil || m.oldValue == nil {
  294. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  295. }
  296. oldValue, err := m.oldValue(ctx)
  297. if err != nil {
  298. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  299. }
  300. return oldValue.UpdatedAt, nil
  301. }
  302. // ResetUpdatedAt resets all changes to the "updated_at" field.
  303. func (m *AgentMutation) ResetUpdatedAt() {
  304. m.updated_at = nil
  305. }
  306. // SetDeletedAt sets the "deleted_at" field.
  307. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  308. m.deleted_at = &t
  309. }
  310. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  311. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  312. v := m.deleted_at
  313. if v == nil {
  314. return
  315. }
  316. return *v, true
  317. }
  318. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  319. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  321. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  322. if !m.op.Is(OpUpdateOne) {
  323. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  324. }
  325. if m.id == nil || m.oldValue == nil {
  326. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  327. }
  328. oldValue, err := m.oldValue(ctx)
  329. if err != nil {
  330. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  331. }
  332. return oldValue.DeletedAt, nil
  333. }
  334. // ClearDeletedAt clears the value of the "deleted_at" field.
  335. func (m *AgentMutation) ClearDeletedAt() {
  336. m.deleted_at = nil
  337. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  338. }
  339. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  340. func (m *AgentMutation) DeletedAtCleared() bool {
  341. _, ok := m.clearedFields[agent.FieldDeletedAt]
  342. return ok
  343. }
  344. // ResetDeletedAt resets all changes to the "deleted_at" field.
  345. func (m *AgentMutation) ResetDeletedAt() {
  346. m.deleted_at = nil
  347. delete(m.clearedFields, agent.FieldDeletedAt)
  348. }
  349. // SetName sets the "name" field.
  350. func (m *AgentMutation) SetName(s string) {
  351. m.name = &s
  352. }
  353. // Name returns the value of the "name" field in the mutation.
  354. func (m *AgentMutation) Name() (r string, exists bool) {
  355. v := m.name
  356. if v == nil {
  357. return
  358. }
  359. return *v, true
  360. }
  361. // OldName returns the old "name" field's value of the Agent entity.
  362. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  364. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  365. if !m.op.Is(OpUpdateOne) {
  366. return v, errors.New("OldName is only allowed on UpdateOne operations")
  367. }
  368. if m.id == nil || m.oldValue == nil {
  369. return v, errors.New("OldName requires an ID field in the mutation")
  370. }
  371. oldValue, err := m.oldValue(ctx)
  372. if err != nil {
  373. return v, fmt.Errorf("querying old value for OldName: %w", err)
  374. }
  375. return oldValue.Name, nil
  376. }
  377. // ResetName resets all changes to the "name" field.
  378. func (m *AgentMutation) ResetName() {
  379. m.name = nil
  380. }
  381. // SetRole sets the "role" field.
  382. func (m *AgentMutation) SetRole(s string) {
  383. m.role = &s
  384. }
  385. // Role returns the value of the "role" field in the mutation.
  386. func (m *AgentMutation) Role() (r string, exists bool) {
  387. v := m.role
  388. if v == nil {
  389. return
  390. }
  391. return *v, true
  392. }
  393. // OldRole returns the old "role" field's value of the Agent entity.
  394. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  396. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  397. if !m.op.Is(OpUpdateOne) {
  398. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  399. }
  400. if m.id == nil || m.oldValue == nil {
  401. return v, errors.New("OldRole requires an ID field in the mutation")
  402. }
  403. oldValue, err := m.oldValue(ctx)
  404. if err != nil {
  405. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  406. }
  407. return oldValue.Role, nil
  408. }
  409. // ResetRole resets all changes to the "role" field.
  410. func (m *AgentMutation) ResetRole() {
  411. m.role = nil
  412. }
  413. // SetStatus sets the "status" field.
  414. func (m *AgentMutation) SetStatus(i int) {
  415. m.status = &i
  416. m.addstatus = nil
  417. }
  418. // Status returns the value of the "status" field in the mutation.
  419. func (m *AgentMutation) Status() (r int, exists bool) {
  420. v := m.status
  421. if v == nil {
  422. return
  423. }
  424. return *v, true
  425. }
  426. // OldStatus returns the old "status" field's value of the Agent entity.
  427. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  429. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  430. if !m.op.Is(OpUpdateOne) {
  431. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  432. }
  433. if m.id == nil || m.oldValue == nil {
  434. return v, errors.New("OldStatus requires an ID field in the mutation")
  435. }
  436. oldValue, err := m.oldValue(ctx)
  437. if err != nil {
  438. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  439. }
  440. return oldValue.Status, nil
  441. }
  442. // AddStatus adds i to the "status" field.
  443. func (m *AgentMutation) AddStatus(i int) {
  444. if m.addstatus != nil {
  445. *m.addstatus += i
  446. } else {
  447. m.addstatus = &i
  448. }
  449. }
  450. // AddedStatus returns the value that was added to the "status" field in this mutation.
  451. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  452. v := m.addstatus
  453. if v == nil {
  454. return
  455. }
  456. return *v, true
  457. }
  458. // ClearStatus clears the value of the "status" field.
  459. func (m *AgentMutation) ClearStatus() {
  460. m.status = nil
  461. m.addstatus = nil
  462. m.clearedFields[agent.FieldStatus] = struct{}{}
  463. }
  464. // StatusCleared returns if the "status" field was cleared in this mutation.
  465. func (m *AgentMutation) StatusCleared() bool {
  466. _, ok := m.clearedFields[agent.FieldStatus]
  467. return ok
  468. }
  469. // ResetStatus resets all changes to the "status" field.
  470. func (m *AgentMutation) ResetStatus() {
  471. m.status = nil
  472. m.addstatus = nil
  473. delete(m.clearedFields, agent.FieldStatus)
  474. }
  475. // SetBackground sets the "background" field.
  476. func (m *AgentMutation) SetBackground(s string) {
  477. m.background = &s
  478. }
  479. // Background returns the value of the "background" field in the mutation.
  480. func (m *AgentMutation) Background() (r string, exists bool) {
  481. v := m.background
  482. if v == nil {
  483. return
  484. }
  485. return *v, true
  486. }
  487. // OldBackground returns the old "background" field's value of the Agent entity.
  488. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  490. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  491. if !m.op.Is(OpUpdateOne) {
  492. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  493. }
  494. if m.id == nil || m.oldValue == nil {
  495. return v, errors.New("OldBackground requires an ID field in the mutation")
  496. }
  497. oldValue, err := m.oldValue(ctx)
  498. if err != nil {
  499. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  500. }
  501. return oldValue.Background, nil
  502. }
  503. // ClearBackground clears the value of the "background" field.
  504. func (m *AgentMutation) ClearBackground() {
  505. m.background = nil
  506. m.clearedFields[agent.FieldBackground] = struct{}{}
  507. }
  508. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  509. func (m *AgentMutation) BackgroundCleared() bool {
  510. _, ok := m.clearedFields[agent.FieldBackground]
  511. return ok
  512. }
  513. // ResetBackground resets all changes to the "background" field.
  514. func (m *AgentMutation) ResetBackground() {
  515. m.background = nil
  516. delete(m.clearedFields, agent.FieldBackground)
  517. }
  518. // SetExamples sets the "examples" field.
  519. func (m *AgentMutation) SetExamples(s string) {
  520. m.examples = &s
  521. }
  522. // Examples returns the value of the "examples" field in the mutation.
  523. func (m *AgentMutation) Examples() (r string, exists bool) {
  524. v := m.examples
  525. if v == nil {
  526. return
  527. }
  528. return *v, true
  529. }
  530. // OldExamples returns the old "examples" field's value of the Agent entity.
  531. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  533. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  534. if !m.op.Is(OpUpdateOne) {
  535. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  536. }
  537. if m.id == nil || m.oldValue == nil {
  538. return v, errors.New("OldExamples requires an ID field in the mutation")
  539. }
  540. oldValue, err := m.oldValue(ctx)
  541. if err != nil {
  542. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  543. }
  544. return oldValue.Examples, nil
  545. }
  546. // ClearExamples clears the value of the "examples" field.
  547. func (m *AgentMutation) ClearExamples() {
  548. m.examples = nil
  549. m.clearedFields[agent.FieldExamples] = struct{}{}
  550. }
  551. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  552. func (m *AgentMutation) ExamplesCleared() bool {
  553. _, ok := m.clearedFields[agent.FieldExamples]
  554. return ok
  555. }
  556. // ResetExamples resets all changes to the "examples" field.
  557. func (m *AgentMutation) ResetExamples() {
  558. m.examples = nil
  559. delete(m.clearedFields, agent.FieldExamples)
  560. }
  561. // SetOrganizationID sets the "organization_id" field.
  562. func (m *AgentMutation) SetOrganizationID(u uint64) {
  563. m.organization_id = &u
  564. m.addorganization_id = nil
  565. }
  566. // OrganizationID returns the value of the "organization_id" field in the mutation.
  567. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  568. v := m.organization_id
  569. if v == nil {
  570. return
  571. }
  572. return *v, true
  573. }
  574. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  575. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  577. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  578. if !m.op.Is(OpUpdateOne) {
  579. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  580. }
  581. if m.id == nil || m.oldValue == nil {
  582. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  583. }
  584. oldValue, err := m.oldValue(ctx)
  585. if err != nil {
  586. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  587. }
  588. return oldValue.OrganizationID, nil
  589. }
  590. // AddOrganizationID adds u to the "organization_id" field.
  591. func (m *AgentMutation) AddOrganizationID(u int64) {
  592. if m.addorganization_id != nil {
  593. *m.addorganization_id += u
  594. } else {
  595. m.addorganization_id = &u
  596. }
  597. }
  598. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  599. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  600. v := m.addorganization_id
  601. if v == nil {
  602. return
  603. }
  604. return *v, true
  605. }
  606. // ResetOrganizationID resets all changes to the "organization_id" field.
  607. func (m *AgentMutation) ResetOrganizationID() {
  608. m.organization_id = nil
  609. m.addorganization_id = nil
  610. }
  611. // SetDatasetID sets the "dataset_id" field.
  612. func (m *AgentMutation) SetDatasetID(s string) {
  613. m.dataset_id = &s
  614. }
  615. // DatasetID returns the value of the "dataset_id" field in the mutation.
  616. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  617. v := m.dataset_id
  618. if v == nil {
  619. return
  620. }
  621. return *v, true
  622. }
  623. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  624. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  626. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  627. if !m.op.Is(OpUpdateOne) {
  628. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  629. }
  630. if m.id == nil || m.oldValue == nil {
  631. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  632. }
  633. oldValue, err := m.oldValue(ctx)
  634. if err != nil {
  635. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  636. }
  637. return oldValue.DatasetID, nil
  638. }
  639. // ResetDatasetID resets all changes to the "dataset_id" field.
  640. func (m *AgentMutation) ResetDatasetID() {
  641. m.dataset_id = nil
  642. }
  643. // SetCollectionID sets the "collection_id" field.
  644. func (m *AgentMutation) SetCollectionID(s string) {
  645. m.collection_id = &s
  646. }
  647. // CollectionID returns the value of the "collection_id" field in the mutation.
  648. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  649. v := m.collection_id
  650. if v == nil {
  651. return
  652. }
  653. return *v, true
  654. }
  655. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  656. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  658. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  659. if !m.op.Is(OpUpdateOne) {
  660. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  661. }
  662. if m.id == nil || m.oldValue == nil {
  663. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  664. }
  665. oldValue, err := m.oldValue(ctx)
  666. if err != nil {
  667. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  668. }
  669. return oldValue.CollectionID, nil
  670. }
  671. // ResetCollectionID resets all changes to the "collection_id" field.
  672. func (m *AgentMutation) ResetCollectionID() {
  673. m.collection_id = nil
  674. }
  675. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  676. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  677. if m.wx_agent == nil {
  678. m.wx_agent = make(map[uint64]struct{})
  679. }
  680. for i := range ids {
  681. m.wx_agent[ids[i]] = struct{}{}
  682. }
  683. }
  684. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  685. func (m *AgentMutation) ClearWxAgent() {
  686. m.clearedwx_agent = true
  687. }
  688. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  689. func (m *AgentMutation) WxAgentCleared() bool {
  690. return m.clearedwx_agent
  691. }
  692. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  693. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  694. if m.removedwx_agent == nil {
  695. m.removedwx_agent = make(map[uint64]struct{})
  696. }
  697. for i := range ids {
  698. delete(m.wx_agent, ids[i])
  699. m.removedwx_agent[ids[i]] = struct{}{}
  700. }
  701. }
  702. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  703. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  704. for id := range m.removedwx_agent {
  705. ids = append(ids, id)
  706. }
  707. return
  708. }
  709. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  710. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  711. for id := range m.wx_agent {
  712. ids = append(ids, id)
  713. }
  714. return
  715. }
  716. // ResetWxAgent resets all changes to the "wx_agent" edge.
  717. func (m *AgentMutation) ResetWxAgent() {
  718. m.wx_agent = nil
  719. m.clearedwx_agent = false
  720. m.removedwx_agent = nil
  721. }
  722. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  723. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  724. if m.token_agent == nil {
  725. m.token_agent = make(map[uint64]struct{})
  726. }
  727. for i := range ids {
  728. m.token_agent[ids[i]] = struct{}{}
  729. }
  730. }
  731. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  732. func (m *AgentMutation) ClearTokenAgent() {
  733. m.clearedtoken_agent = true
  734. }
  735. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  736. func (m *AgentMutation) TokenAgentCleared() bool {
  737. return m.clearedtoken_agent
  738. }
  739. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  740. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  741. if m.removedtoken_agent == nil {
  742. m.removedtoken_agent = make(map[uint64]struct{})
  743. }
  744. for i := range ids {
  745. delete(m.token_agent, ids[i])
  746. m.removedtoken_agent[ids[i]] = struct{}{}
  747. }
  748. }
  749. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  750. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  751. for id := range m.removedtoken_agent {
  752. ids = append(ids, id)
  753. }
  754. return
  755. }
  756. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  757. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  758. for id := range m.token_agent {
  759. ids = append(ids, id)
  760. }
  761. return
  762. }
  763. // ResetTokenAgent resets all changes to the "token_agent" edge.
  764. func (m *AgentMutation) ResetTokenAgent() {
  765. m.token_agent = nil
  766. m.clearedtoken_agent = false
  767. m.removedtoken_agent = nil
  768. }
  769. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  770. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  771. if m.wa_agent == nil {
  772. m.wa_agent = make(map[uint64]struct{})
  773. }
  774. for i := range ids {
  775. m.wa_agent[ids[i]] = struct{}{}
  776. }
  777. }
  778. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  779. func (m *AgentMutation) ClearWaAgent() {
  780. m.clearedwa_agent = true
  781. }
  782. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  783. func (m *AgentMutation) WaAgentCleared() bool {
  784. return m.clearedwa_agent
  785. }
  786. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  787. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  788. if m.removedwa_agent == nil {
  789. m.removedwa_agent = make(map[uint64]struct{})
  790. }
  791. for i := range ids {
  792. delete(m.wa_agent, ids[i])
  793. m.removedwa_agent[ids[i]] = struct{}{}
  794. }
  795. }
  796. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  797. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  798. for id := range m.removedwa_agent {
  799. ids = append(ids, id)
  800. }
  801. return
  802. }
  803. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  804. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  805. for id := range m.wa_agent {
  806. ids = append(ids, id)
  807. }
  808. return
  809. }
  810. // ResetWaAgent resets all changes to the "wa_agent" edge.
  811. func (m *AgentMutation) ResetWaAgent() {
  812. m.wa_agent = nil
  813. m.clearedwa_agent = false
  814. m.removedwa_agent = nil
  815. }
  816. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  817. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  818. if m.key_agent == nil {
  819. m.key_agent = make(map[uint64]struct{})
  820. }
  821. for i := range ids {
  822. m.key_agent[ids[i]] = struct{}{}
  823. }
  824. }
  825. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  826. func (m *AgentMutation) ClearKeyAgent() {
  827. m.clearedkey_agent = true
  828. }
  829. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  830. func (m *AgentMutation) KeyAgentCleared() bool {
  831. return m.clearedkey_agent
  832. }
  833. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  834. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  835. if m.removedkey_agent == nil {
  836. m.removedkey_agent = make(map[uint64]struct{})
  837. }
  838. for i := range ids {
  839. delete(m.key_agent, ids[i])
  840. m.removedkey_agent[ids[i]] = struct{}{}
  841. }
  842. }
  843. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  844. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  845. for id := range m.removedkey_agent {
  846. ids = append(ids, id)
  847. }
  848. return
  849. }
  850. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  851. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  852. for id := range m.key_agent {
  853. ids = append(ids, id)
  854. }
  855. return
  856. }
  857. // ResetKeyAgent resets all changes to the "key_agent" edge.
  858. func (m *AgentMutation) ResetKeyAgent() {
  859. m.key_agent = nil
  860. m.clearedkey_agent = false
  861. m.removedkey_agent = nil
  862. }
  863. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  864. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  865. if m.xjs_agent == nil {
  866. m.xjs_agent = make(map[uint64]struct{})
  867. }
  868. for i := range ids {
  869. m.xjs_agent[ids[i]] = struct{}{}
  870. }
  871. }
  872. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  873. func (m *AgentMutation) ClearXjsAgent() {
  874. m.clearedxjs_agent = true
  875. }
  876. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  877. func (m *AgentMutation) XjsAgentCleared() bool {
  878. return m.clearedxjs_agent
  879. }
  880. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  881. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  882. if m.removedxjs_agent == nil {
  883. m.removedxjs_agent = make(map[uint64]struct{})
  884. }
  885. for i := range ids {
  886. delete(m.xjs_agent, ids[i])
  887. m.removedxjs_agent[ids[i]] = struct{}{}
  888. }
  889. }
  890. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  891. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  892. for id := range m.removedxjs_agent {
  893. ids = append(ids, id)
  894. }
  895. return
  896. }
  897. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  898. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  899. for id := range m.xjs_agent {
  900. ids = append(ids, id)
  901. }
  902. return
  903. }
  904. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  905. func (m *AgentMutation) ResetXjsAgent() {
  906. m.xjs_agent = nil
  907. m.clearedxjs_agent = false
  908. m.removedxjs_agent = nil
  909. }
  910. // Where appends a list predicates to the AgentMutation builder.
  911. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  912. m.predicates = append(m.predicates, ps...)
  913. }
  914. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  915. // users can use type-assertion to append predicates that do not depend on any generated package.
  916. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  917. p := make([]predicate.Agent, len(ps))
  918. for i := range ps {
  919. p[i] = ps[i]
  920. }
  921. m.Where(p...)
  922. }
  923. // Op returns the operation name.
  924. func (m *AgentMutation) Op() Op {
  925. return m.op
  926. }
  927. // SetOp allows setting the mutation operation.
  928. func (m *AgentMutation) SetOp(op Op) {
  929. m.op = op
  930. }
  931. // Type returns the node type of this mutation (Agent).
  932. func (m *AgentMutation) Type() string {
  933. return m.typ
  934. }
  935. // Fields returns all fields that were changed during this mutation. Note that in
  936. // order to get all numeric fields that were incremented/decremented, call
  937. // AddedFields().
  938. func (m *AgentMutation) Fields() []string {
  939. fields := make([]string, 0, 11)
  940. if m.created_at != nil {
  941. fields = append(fields, agent.FieldCreatedAt)
  942. }
  943. if m.updated_at != nil {
  944. fields = append(fields, agent.FieldUpdatedAt)
  945. }
  946. if m.deleted_at != nil {
  947. fields = append(fields, agent.FieldDeletedAt)
  948. }
  949. if m.name != nil {
  950. fields = append(fields, agent.FieldName)
  951. }
  952. if m.role != nil {
  953. fields = append(fields, agent.FieldRole)
  954. }
  955. if m.status != nil {
  956. fields = append(fields, agent.FieldStatus)
  957. }
  958. if m.background != nil {
  959. fields = append(fields, agent.FieldBackground)
  960. }
  961. if m.examples != nil {
  962. fields = append(fields, agent.FieldExamples)
  963. }
  964. if m.organization_id != nil {
  965. fields = append(fields, agent.FieldOrganizationID)
  966. }
  967. if m.dataset_id != nil {
  968. fields = append(fields, agent.FieldDatasetID)
  969. }
  970. if m.collection_id != nil {
  971. fields = append(fields, agent.FieldCollectionID)
  972. }
  973. return fields
  974. }
  975. // Field returns the value of a field with the given name. The second boolean
  976. // return value indicates that this field was not set, or was not defined in the
  977. // schema.
  978. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  979. switch name {
  980. case agent.FieldCreatedAt:
  981. return m.CreatedAt()
  982. case agent.FieldUpdatedAt:
  983. return m.UpdatedAt()
  984. case agent.FieldDeletedAt:
  985. return m.DeletedAt()
  986. case agent.FieldName:
  987. return m.Name()
  988. case agent.FieldRole:
  989. return m.Role()
  990. case agent.FieldStatus:
  991. return m.Status()
  992. case agent.FieldBackground:
  993. return m.Background()
  994. case agent.FieldExamples:
  995. return m.Examples()
  996. case agent.FieldOrganizationID:
  997. return m.OrganizationID()
  998. case agent.FieldDatasetID:
  999. return m.DatasetID()
  1000. case agent.FieldCollectionID:
  1001. return m.CollectionID()
  1002. }
  1003. return nil, false
  1004. }
  1005. // OldField returns the old value of the field from the database. An error is
  1006. // returned if the mutation operation is not UpdateOne, or the query to the
  1007. // database failed.
  1008. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1009. switch name {
  1010. case agent.FieldCreatedAt:
  1011. return m.OldCreatedAt(ctx)
  1012. case agent.FieldUpdatedAt:
  1013. return m.OldUpdatedAt(ctx)
  1014. case agent.FieldDeletedAt:
  1015. return m.OldDeletedAt(ctx)
  1016. case agent.FieldName:
  1017. return m.OldName(ctx)
  1018. case agent.FieldRole:
  1019. return m.OldRole(ctx)
  1020. case agent.FieldStatus:
  1021. return m.OldStatus(ctx)
  1022. case agent.FieldBackground:
  1023. return m.OldBackground(ctx)
  1024. case agent.FieldExamples:
  1025. return m.OldExamples(ctx)
  1026. case agent.FieldOrganizationID:
  1027. return m.OldOrganizationID(ctx)
  1028. case agent.FieldDatasetID:
  1029. return m.OldDatasetID(ctx)
  1030. case agent.FieldCollectionID:
  1031. return m.OldCollectionID(ctx)
  1032. }
  1033. return nil, fmt.Errorf("unknown Agent field %s", name)
  1034. }
  1035. // SetField sets the value of a field with the given name. It returns an error if
  1036. // the field is not defined in the schema, or if the type mismatched the field
  1037. // type.
  1038. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1039. switch name {
  1040. case agent.FieldCreatedAt:
  1041. v, ok := value.(time.Time)
  1042. if !ok {
  1043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1044. }
  1045. m.SetCreatedAt(v)
  1046. return nil
  1047. case agent.FieldUpdatedAt:
  1048. v, ok := value.(time.Time)
  1049. if !ok {
  1050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1051. }
  1052. m.SetUpdatedAt(v)
  1053. return nil
  1054. case agent.FieldDeletedAt:
  1055. v, ok := value.(time.Time)
  1056. if !ok {
  1057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1058. }
  1059. m.SetDeletedAt(v)
  1060. return nil
  1061. case agent.FieldName:
  1062. v, ok := value.(string)
  1063. if !ok {
  1064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1065. }
  1066. m.SetName(v)
  1067. return nil
  1068. case agent.FieldRole:
  1069. v, ok := value.(string)
  1070. if !ok {
  1071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1072. }
  1073. m.SetRole(v)
  1074. return nil
  1075. case agent.FieldStatus:
  1076. v, ok := value.(int)
  1077. if !ok {
  1078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1079. }
  1080. m.SetStatus(v)
  1081. return nil
  1082. case agent.FieldBackground:
  1083. v, ok := value.(string)
  1084. if !ok {
  1085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1086. }
  1087. m.SetBackground(v)
  1088. return nil
  1089. case agent.FieldExamples:
  1090. v, ok := value.(string)
  1091. if !ok {
  1092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1093. }
  1094. m.SetExamples(v)
  1095. return nil
  1096. case agent.FieldOrganizationID:
  1097. v, ok := value.(uint64)
  1098. if !ok {
  1099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1100. }
  1101. m.SetOrganizationID(v)
  1102. return nil
  1103. case agent.FieldDatasetID:
  1104. v, ok := value.(string)
  1105. if !ok {
  1106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1107. }
  1108. m.SetDatasetID(v)
  1109. return nil
  1110. case agent.FieldCollectionID:
  1111. v, ok := value.(string)
  1112. if !ok {
  1113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1114. }
  1115. m.SetCollectionID(v)
  1116. return nil
  1117. }
  1118. return fmt.Errorf("unknown Agent field %s", name)
  1119. }
  1120. // AddedFields returns all numeric fields that were incremented/decremented during
  1121. // this mutation.
  1122. func (m *AgentMutation) AddedFields() []string {
  1123. var fields []string
  1124. if m.addstatus != nil {
  1125. fields = append(fields, agent.FieldStatus)
  1126. }
  1127. if m.addorganization_id != nil {
  1128. fields = append(fields, agent.FieldOrganizationID)
  1129. }
  1130. return fields
  1131. }
  1132. // AddedField returns the numeric value that was incremented/decremented on a field
  1133. // with the given name. The second boolean return value indicates that this field
  1134. // was not set, or was not defined in the schema.
  1135. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1136. switch name {
  1137. case agent.FieldStatus:
  1138. return m.AddedStatus()
  1139. case agent.FieldOrganizationID:
  1140. return m.AddedOrganizationID()
  1141. }
  1142. return nil, false
  1143. }
  1144. // AddField adds the value to the field with the given name. It returns an error if
  1145. // the field is not defined in the schema, or if the type mismatched the field
  1146. // type.
  1147. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1148. switch name {
  1149. case agent.FieldStatus:
  1150. v, ok := value.(int)
  1151. if !ok {
  1152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1153. }
  1154. m.AddStatus(v)
  1155. return nil
  1156. case agent.FieldOrganizationID:
  1157. v, ok := value.(int64)
  1158. if !ok {
  1159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1160. }
  1161. m.AddOrganizationID(v)
  1162. return nil
  1163. }
  1164. return fmt.Errorf("unknown Agent numeric field %s", name)
  1165. }
  1166. // ClearedFields returns all nullable fields that were cleared during this
  1167. // mutation.
  1168. func (m *AgentMutation) ClearedFields() []string {
  1169. var fields []string
  1170. if m.FieldCleared(agent.FieldDeletedAt) {
  1171. fields = append(fields, agent.FieldDeletedAt)
  1172. }
  1173. if m.FieldCleared(agent.FieldStatus) {
  1174. fields = append(fields, agent.FieldStatus)
  1175. }
  1176. if m.FieldCleared(agent.FieldBackground) {
  1177. fields = append(fields, agent.FieldBackground)
  1178. }
  1179. if m.FieldCleared(agent.FieldExamples) {
  1180. fields = append(fields, agent.FieldExamples)
  1181. }
  1182. return fields
  1183. }
  1184. // FieldCleared returns a boolean indicating if a field with the given name was
  1185. // cleared in this mutation.
  1186. func (m *AgentMutation) FieldCleared(name string) bool {
  1187. _, ok := m.clearedFields[name]
  1188. return ok
  1189. }
  1190. // ClearField clears the value of the field with the given name. It returns an
  1191. // error if the field is not defined in the schema.
  1192. func (m *AgentMutation) ClearField(name string) error {
  1193. switch name {
  1194. case agent.FieldDeletedAt:
  1195. m.ClearDeletedAt()
  1196. return nil
  1197. case agent.FieldStatus:
  1198. m.ClearStatus()
  1199. return nil
  1200. case agent.FieldBackground:
  1201. m.ClearBackground()
  1202. return nil
  1203. case agent.FieldExamples:
  1204. m.ClearExamples()
  1205. return nil
  1206. }
  1207. return fmt.Errorf("unknown Agent nullable field %s", name)
  1208. }
  1209. // ResetField resets all changes in the mutation for the field with the given name.
  1210. // It returns an error if the field is not defined in the schema.
  1211. func (m *AgentMutation) ResetField(name string) error {
  1212. switch name {
  1213. case agent.FieldCreatedAt:
  1214. m.ResetCreatedAt()
  1215. return nil
  1216. case agent.FieldUpdatedAt:
  1217. m.ResetUpdatedAt()
  1218. return nil
  1219. case agent.FieldDeletedAt:
  1220. m.ResetDeletedAt()
  1221. return nil
  1222. case agent.FieldName:
  1223. m.ResetName()
  1224. return nil
  1225. case agent.FieldRole:
  1226. m.ResetRole()
  1227. return nil
  1228. case agent.FieldStatus:
  1229. m.ResetStatus()
  1230. return nil
  1231. case agent.FieldBackground:
  1232. m.ResetBackground()
  1233. return nil
  1234. case agent.FieldExamples:
  1235. m.ResetExamples()
  1236. return nil
  1237. case agent.FieldOrganizationID:
  1238. m.ResetOrganizationID()
  1239. return nil
  1240. case agent.FieldDatasetID:
  1241. m.ResetDatasetID()
  1242. return nil
  1243. case agent.FieldCollectionID:
  1244. m.ResetCollectionID()
  1245. return nil
  1246. }
  1247. return fmt.Errorf("unknown Agent field %s", name)
  1248. }
  1249. // AddedEdges returns all edge names that were set/added in this mutation.
  1250. func (m *AgentMutation) AddedEdges() []string {
  1251. edges := make([]string, 0, 5)
  1252. if m.wx_agent != nil {
  1253. edges = append(edges, agent.EdgeWxAgent)
  1254. }
  1255. if m.token_agent != nil {
  1256. edges = append(edges, agent.EdgeTokenAgent)
  1257. }
  1258. if m.wa_agent != nil {
  1259. edges = append(edges, agent.EdgeWaAgent)
  1260. }
  1261. if m.key_agent != nil {
  1262. edges = append(edges, agent.EdgeKeyAgent)
  1263. }
  1264. if m.xjs_agent != nil {
  1265. edges = append(edges, agent.EdgeXjsAgent)
  1266. }
  1267. return edges
  1268. }
  1269. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1270. // name in this mutation.
  1271. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1272. switch name {
  1273. case agent.EdgeWxAgent:
  1274. ids := make([]ent.Value, 0, len(m.wx_agent))
  1275. for id := range m.wx_agent {
  1276. ids = append(ids, id)
  1277. }
  1278. return ids
  1279. case agent.EdgeTokenAgent:
  1280. ids := make([]ent.Value, 0, len(m.token_agent))
  1281. for id := range m.token_agent {
  1282. ids = append(ids, id)
  1283. }
  1284. return ids
  1285. case agent.EdgeWaAgent:
  1286. ids := make([]ent.Value, 0, len(m.wa_agent))
  1287. for id := range m.wa_agent {
  1288. ids = append(ids, id)
  1289. }
  1290. return ids
  1291. case agent.EdgeKeyAgent:
  1292. ids := make([]ent.Value, 0, len(m.key_agent))
  1293. for id := range m.key_agent {
  1294. ids = append(ids, id)
  1295. }
  1296. return ids
  1297. case agent.EdgeXjsAgent:
  1298. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1299. for id := range m.xjs_agent {
  1300. ids = append(ids, id)
  1301. }
  1302. return ids
  1303. }
  1304. return nil
  1305. }
  1306. // RemovedEdges returns all edge names that were removed in this mutation.
  1307. func (m *AgentMutation) RemovedEdges() []string {
  1308. edges := make([]string, 0, 5)
  1309. if m.removedwx_agent != nil {
  1310. edges = append(edges, agent.EdgeWxAgent)
  1311. }
  1312. if m.removedtoken_agent != nil {
  1313. edges = append(edges, agent.EdgeTokenAgent)
  1314. }
  1315. if m.removedwa_agent != nil {
  1316. edges = append(edges, agent.EdgeWaAgent)
  1317. }
  1318. if m.removedkey_agent != nil {
  1319. edges = append(edges, agent.EdgeKeyAgent)
  1320. }
  1321. if m.removedxjs_agent != nil {
  1322. edges = append(edges, agent.EdgeXjsAgent)
  1323. }
  1324. return edges
  1325. }
  1326. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1327. // the given name in this mutation.
  1328. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1329. switch name {
  1330. case agent.EdgeWxAgent:
  1331. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1332. for id := range m.removedwx_agent {
  1333. ids = append(ids, id)
  1334. }
  1335. return ids
  1336. case agent.EdgeTokenAgent:
  1337. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1338. for id := range m.removedtoken_agent {
  1339. ids = append(ids, id)
  1340. }
  1341. return ids
  1342. case agent.EdgeWaAgent:
  1343. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1344. for id := range m.removedwa_agent {
  1345. ids = append(ids, id)
  1346. }
  1347. return ids
  1348. case agent.EdgeKeyAgent:
  1349. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1350. for id := range m.removedkey_agent {
  1351. ids = append(ids, id)
  1352. }
  1353. return ids
  1354. case agent.EdgeXjsAgent:
  1355. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1356. for id := range m.removedxjs_agent {
  1357. ids = append(ids, id)
  1358. }
  1359. return ids
  1360. }
  1361. return nil
  1362. }
  1363. // ClearedEdges returns all edge names that were cleared in this mutation.
  1364. func (m *AgentMutation) ClearedEdges() []string {
  1365. edges := make([]string, 0, 5)
  1366. if m.clearedwx_agent {
  1367. edges = append(edges, agent.EdgeWxAgent)
  1368. }
  1369. if m.clearedtoken_agent {
  1370. edges = append(edges, agent.EdgeTokenAgent)
  1371. }
  1372. if m.clearedwa_agent {
  1373. edges = append(edges, agent.EdgeWaAgent)
  1374. }
  1375. if m.clearedkey_agent {
  1376. edges = append(edges, agent.EdgeKeyAgent)
  1377. }
  1378. if m.clearedxjs_agent {
  1379. edges = append(edges, agent.EdgeXjsAgent)
  1380. }
  1381. return edges
  1382. }
  1383. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1384. // was cleared in this mutation.
  1385. func (m *AgentMutation) EdgeCleared(name string) bool {
  1386. switch name {
  1387. case agent.EdgeWxAgent:
  1388. return m.clearedwx_agent
  1389. case agent.EdgeTokenAgent:
  1390. return m.clearedtoken_agent
  1391. case agent.EdgeWaAgent:
  1392. return m.clearedwa_agent
  1393. case agent.EdgeKeyAgent:
  1394. return m.clearedkey_agent
  1395. case agent.EdgeXjsAgent:
  1396. return m.clearedxjs_agent
  1397. }
  1398. return false
  1399. }
  1400. // ClearEdge clears the value of the edge with the given name. It returns an error
  1401. // if that edge is not defined in the schema.
  1402. func (m *AgentMutation) ClearEdge(name string) error {
  1403. switch name {
  1404. }
  1405. return fmt.Errorf("unknown Agent unique edge %s", name)
  1406. }
  1407. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1408. // It returns an error if the edge is not defined in the schema.
  1409. func (m *AgentMutation) ResetEdge(name string) error {
  1410. switch name {
  1411. case agent.EdgeWxAgent:
  1412. m.ResetWxAgent()
  1413. return nil
  1414. case agent.EdgeTokenAgent:
  1415. m.ResetTokenAgent()
  1416. return nil
  1417. case agent.EdgeWaAgent:
  1418. m.ResetWaAgent()
  1419. return nil
  1420. case agent.EdgeKeyAgent:
  1421. m.ResetKeyAgent()
  1422. return nil
  1423. case agent.EdgeXjsAgent:
  1424. m.ResetXjsAgent()
  1425. return nil
  1426. }
  1427. return fmt.Errorf("unknown Agent edge %s", name)
  1428. }
  1429. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1430. type AgentBaseMutation struct {
  1431. config
  1432. op Op
  1433. typ string
  1434. id *string
  1435. q *string
  1436. a *string
  1437. chunk_index *uint64
  1438. addchunk_index *int64
  1439. indexes *[]string
  1440. appendindexes []string
  1441. dataset_id *string
  1442. collection_id *string
  1443. source_name *string
  1444. can_write *[]bool
  1445. appendcan_write []bool
  1446. is_owner *[]bool
  1447. appendis_owner []bool
  1448. clearedFields map[string]struct{}
  1449. wx_agent map[uint64]struct{}
  1450. removedwx_agent map[uint64]struct{}
  1451. clearedwx_agent bool
  1452. done bool
  1453. oldValue func(context.Context) (*AgentBase, error)
  1454. predicates []predicate.AgentBase
  1455. }
  1456. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1457. // agentbaseOption allows management of the mutation configuration using functional options.
  1458. type agentbaseOption func(*AgentBaseMutation)
  1459. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1460. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1461. m := &AgentBaseMutation{
  1462. config: c,
  1463. op: op,
  1464. typ: TypeAgentBase,
  1465. clearedFields: make(map[string]struct{}),
  1466. }
  1467. for _, opt := range opts {
  1468. opt(m)
  1469. }
  1470. return m
  1471. }
  1472. // withAgentBaseID sets the ID field of the mutation.
  1473. func withAgentBaseID(id string) agentbaseOption {
  1474. return func(m *AgentBaseMutation) {
  1475. var (
  1476. err error
  1477. once sync.Once
  1478. value *AgentBase
  1479. )
  1480. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1481. once.Do(func() {
  1482. if m.done {
  1483. err = errors.New("querying old values post mutation is not allowed")
  1484. } else {
  1485. value, err = m.Client().AgentBase.Get(ctx, id)
  1486. }
  1487. })
  1488. return value, err
  1489. }
  1490. m.id = &id
  1491. }
  1492. }
  1493. // withAgentBase sets the old AgentBase of the mutation.
  1494. func withAgentBase(node *AgentBase) agentbaseOption {
  1495. return func(m *AgentBaseMutation) {
  1496. m.oldValue = func(context.Context) (*AgentBase, error) {
  1497. return node, nil
  1498. }
  1499. m.id = &node.ID
  1500. }
  1501. }
  1502. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1503. // executed in a transaction (ent.Tx), a transactional client is returned.
  1504. func (m AgentBaseMutation) Client() *Client {
  1505. client := &Client{config: m.config}
  1506. client.init()
  1507. return client
  1508. }
  1509. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1510. // it returns an error otherwise.
  1511. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1512. if _, ok := m.driver.(*txDriver); !ok {
  1513. return nil, errors.New("ent: mutation is not running in a transaction")
  1514. }
  1515. tx := &Tx{config: m.config}
  1516. tx.init()
  1517. return tx, nil
  1518. }
  1519. // SetID sets the value of the id field. Note that this
  1520. // operation is only accepted on creation of AgentBase entities.
  1521. func (m *AgentBaseMutation) SetID(id string) {
  1522. m.id = &id
  1523. }
  1524. // ID returns the ID value in the mutation. Note that the ID is only available
  1525. // if it was provided to the builder or after it was returned from the database.
  1526. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1527. if m.id == nil {
  1528. return
  1529. }
  1530. return *m.id, true
  1531. }
  1532. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1533. // That means, if the mutation is applied within a transaction with an isolation level such
  1534. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1535. // or updated by the mutation.
  1536. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1537. switch {
  1538. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1539. id, exists := m.ID()
  1540. if exists {
  1541. return []string{id}, nil
  1542. }
  1543. fallthrough
  1544. case m.op.Is(OpUpdate | OpDelete):
  1545. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1546. default:
  1547. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1548. }
  1549. }
  1550. // SetQ sets the "q" field.
  1551. func (m *AgentBaseMutation) SetQ(s string) {
  1552. m.q = &s
  1553. }
  1554. // Q returns the value of the "q" field in the mutation.
  1555. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1556. v := m.q
  1557. if v == nil {
  1558. return
  1559. }
  1560. return *v, true
  1561. }
  1562. // OldQ returns the old "q" field's value of the AgentBase entity.
  1563. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1565. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1566. if !m.op.Is(OpUpdateOne) {
  1567. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1568. }
  1569. if m.id == nil || m.oldValue == nil {
  1570. return v, errors.New("OldQ requires an ID field in the mutation")
  1571. }
  1572. oldValue, err := m.oldValue(ctx)
  1573. if err != nil {
  1574. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1575. }
  1576. return oldValue.Q, nil
  1577. }
  1578. // ClearQ clears the value of the "q" field.
  1579. func (m *AgentBaseMutation) ClearQ() {
  1580. m.q = nil
  1581. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1582. }
  1583. // QCleared returns if the "q" field was cleared in this mutation.
  1584. func (m *AgentBaseMutation) QCleared() bool {
  1585. _, ok := m.clearedFields[agentbase.FieldQ]
  1586. return ok
  1587. }
  1588. // ResetQ resets all changes to the "q" field.
  1589. func (m *AgentBaseMutation) ResetQ() {
  1590. m.q = nil
  1591. delete(m.clearedFields, agentbase.FieldQ)
  1592. }
  1593. // SetA sets the "a" field.
  1594. func (m *AgentBaseMutation) SetA(s string) {
  1595. m.a = &s
  1596. }
  1597. // A returns the value of the "a" field in the mutation.
  1598. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1599. v := m.a
  1600. if v == nil {
  1601. return
  1602. }
  1603. return *v, true
  1604. }
  1605. // OldA returns the old "a" field's value of the AgentBase entity.
  1606. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1608. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1609. if !m.op.Is(OpUpdateOne) {
  1610. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1611. }
  1612. if m.id == nil || m.oldValue == nil {
  1613. return v, errors.New("OldA requires an ID field in the mutation")
  1614. }
  1615. oldValue, err := m.oldValue(ctx)
  1616. if err != nil {
  1617. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1618. }
  1619. return oldValue.A, nil
  1620. }
  1621. // ClearA clears the value of the "a" field.
  1622. func (m *AgentBaseMutation) ClearA() {
  1623. m.a = nil
  1624. m.clearedFields[agentbase.FieldA] = struct{}{}
  1625. }
  1626. // ACleared returns if the "a" field was cleared in this mutation.
  1627. func (m *AgentBaseMutation) ACleared() bool {
  1628. _, ok := m.clearedFields[agentbase.FieldA]
  1629. return ok
  1630. }
  1631. // ResetA resets all changes to the "a" field.
  1632. func (m *AgentBaseMutation) ResetA() {
  1633. m.a = nil
  1634. delete(m.clearedFields, agentbase.FieldA)
  1635. }
  1636. // SetChunkIndex sets the "chunk_index" field.
  1637. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1638. m.chunk_index = &u
  1639. m.addchunk_index = nil
  1640. }
  1641. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1642. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1643. v := m.chunk_index
  1644. if v == nil {
  1645. return
  1646. }
  1647. return *v, true
  1648. }
  1649. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1650. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1652. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1653. if !m.op.Is(OpUpdateOne) {
  1654. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1655. }
  1656. if m.id == nil || m.oldValue == nil {
  1657. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1658. }
  1659. oldValue, err := m.oldValue(ctx)
  1660. if err != nil {
  1661. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1662. }
  1663. return oldValue.ChunkIndex, nil
  1664. }
  1665. // AddChunkIndex adds u to the "chunk_index" field.
  1666. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1667. if m.addchunk_index != nil {
  1668. *m.addchunk_index += u
  1669. } else {
  1670. m.addchunk_index = &u
  1671. }
  1672. }
  1673. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1674. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1675. v := m.addchunk_index
  1676. if v == nil {
  1677. return
  1678. }
  1679. return *v, true
  1680. }
  1681. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1682. func (m *AgentBaseMutation) ResetChunkIndex() {
  1683. m.chunk_index = nil
  1684. m.addchunk_index = nil
  1685. }
  1686. // SetIndexes sets the "indexes" field.
  1687. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1688. m.indexes = &s
  1689. m.appendindexes = nil
  1690. }
  1691. // Indexes returns the value of the "indexes" field in the mutation.
  1692. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1693. v := m.indexes
  1694. if v == nil {
  1695. return
  1696. }
  1697. return *v, true
  1698. }
  1699. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1700. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1702. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1703. if !m.op.Is(OpUpdateOne) {
  1704. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1705. }
  1706. if m.id == nil || m.oldValue == nil {
  1707. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1708. }
  1709. oldValue, err := m.oldValue(ctx)
  1710. if err != nil {
  1711. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1712. }
  1713. return oldValue.Indexes, nil
  1714. }
  1715. // AppendIndexes adds s to the "indexes" field.
  1716. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1717. m.appendindexes = append(m.appendindexes, s...)
  1718. }
  1719. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1720. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1721. if len(m.appendindexes) == 0 {
  1722. return nil, false
  1723. }
  1724. return m.appendindexes, true
  1725. }
  1726. // ClearIndexes clears the value of the "indexes" field.
  1727. func (m *AgentBaseMutation) ClearIndexes() {
  1728. m.indexes = nil
  1729. m.appendindexes = nil
  1730. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1731. }
  1732. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1733. func (m *AgentBaseMutation) IndexesCleared() bool {
  1734. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1735. return ok
  1736. }
  1737. // ResetIndexes resets all changes to the "indexes" field.
  1738. func (m *AgentBaseMutation) ResetIndexes() {
  1739. m.indexes = nil
  1740. m.appendindexes = nil
  1741. delete(m.clearedFields, agentbase.FieldIndexes)
  1742. }
  1743. // SetDatasetID sets the "dataset_id" field.
  1744. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1745. m.dataset_id = &s
  1746. }
  1747. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1748. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1749. v := m.dataset_id
  1750. if v == nil {
  1751. return
  1752. }
  1753. return *v, true
  1754. }
  1755. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1756. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1758. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1759. if !m.op.Is(OpUpdateOne) {
  1760. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1761. }
  1762. if m.id == nil || m.oldValue == nil {
  1763. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1764. }
  1765. oldValue, err := m.oldValue(ctx)
  1766. if err != nil {
  1767. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1768. }
  1769. return oldValue.DatasetID, nil
  1770. }
  1771. // ClearDatasetID clears the value of the "dataset_id" field.
  1772. func (m *AgentBaseMutation) ClearDatasetID() {
  1773. m.dataset_id = nil
  1774. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1775. }
  1776. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1777. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1778. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1779. return ok
  1780. }
  1781. // ResetDatasetID resets all changes to the "dataset_id" field.
  1782. func (m *AgentBaseMutation) ResetDatasetID() {
  1783. m.dataset_id = nil
  1784. delete(m.clearedFields, agentbase.FieldDatasetID)
  1785. }
  1786. // SetCollectionID sets the "collection_id" field.
  1787. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1788. m.collection_id = &s
  1789. }
  1790. // CollectionID returns the value of the "collection_id" field in the mutation.
  1791. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1792. v := m.collection_id
  1793. if v == nil {
  1794. return
  1795. }
  1796. return *v, true
  1797. }
  1798. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1799. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1801. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1802. if !m.op.Is(OpUpdateOne) {
  1803. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1804. }
  1805. if m.id == nil || m.oldValue == nil {
  1806. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1807. }
  1808. oldValue, err := m.oldValue(ctx)
  1809. if err != nil {
  1810. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1811. }
  1812. return oldValue.CollectionID, nil
  1813. }
  1814. // ClearCollectionID clears the value of the "collection_id" field.
  1815. func (m *AgentBaseMutation) ClearCollectionID() {
  1816. m.collection_id = nil
  1817. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1818. }
  1819. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1820. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1821. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1822. return ok
  1823. }
  1824. // ResetCollectionID resets all changes to the "collection_id" field.
  1825. func (m *AgentBaseMutation) ResetCollectionID() {
  1826. m.collection_id = nil
  1827. delete(m.clearedFields, agentbase.FieldCollectionID)
  1828. }
  1829. // SetSourceName sets the "source_name" field.
  1830. func (m *AgentBaseMutation) SetSourceName(s string) {
  1831. m.source_name = &s
  1832. }
  1833. // SourceName returns the value of the "source_name" field in the mutation.
  1834. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1835. v := m.source_name
  1836. if v == nil {
  1837. return
  1838. }
  1839. return *v, true
  1840. }
  1841. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1842. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1844. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1845. if !m.op.Is(OpUpdateOne) {
  1846. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1847. }
  1848. if m.id == nil || m.oldValue == nil {
  1849. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1850. }
  1851. oldValue, err := m.oldValue(ctx)
  1852. if err != nil {
  1853. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1854. }
  1855. return oldValue.SourceName, nil
  1856. }
  1857. // ClearSourceName clears the value of the "source_name" field.
  1858. func (m *AgentBaseMutation) ClearSourceName() {
  1859. m.source_name = nil
  1860. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1861. }
  1862. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1863. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1864. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1865. return ok
  1866. }
  1867. // ResetSourceName resets all changes to the "source_name" field.
  1868. func (m *AgentBaseMutation) ResetSourceName() {
  1869. m.source_name = nil
  1870. delete(m.clearedFields, agentbase.FieldSourceName)
  1871. }
  1872. // SetCanWrite sets the "can_write" field.
  1873. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1874. m.can_write = &b
  1875. m.appendcan_write = nil
  1876. }
  1877. // CanWrite returns the value of the "can_write" field in the mutation.
  1878. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1879. v := m.can_write
  1880. if v == nil {
  1881. return
  1882. }
  1883. return *v, true
  1884. }
  1885. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1886. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1888. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1889. if !m.op.Is(OpUpdateOne) {
  1890. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1891. }
  1892. if m.id == nil || m.oldValue == nil {
  1893. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1894. }
  1895. oldValue, err := m.oldValue(ctx)
  1896. if err != nil {
  1897. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1898. }
  1899. return oldValue.CanWrite, nil
  1900. }
  1901. // AppendCanWrite adds b to the "can_write" field.
  1902. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1903. m.appendcan_write = append(m.appendcan_write, b...)
  1904. }
  1905. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1906. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1907. if len(m.appendcan_write) == 0 {
  1908. return nil, false
  1909. }
  1910. return m.appendcan_write, true
  1911. }
  1912. // ClearCanWrite clears the value of the "can_write" field.
  1913. func (m *AgentBaseMutation) ClearCanWrite() {
  1914. m.can_write = nil
  1915. m.appendcan_write = nil
  1916. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1917. }
  1918. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1919. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1920. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1921. return ok
  1922. }
  1923. // ResetCanWrite resets all changes to the "can_write" field.
  1924. func (m *AgentBaseMutation) ResetCanWrite() {
  1925. m.can_write = nil
  1926. m.appendcan_write = nil
  1927. delete(m.clearedFields, agentbase.FieldCanWrite)
  1928. }
  1929. // SetIsOwner sets the "is_owner" field.
  1930. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1931. m.is_owner = &b
  1932. m.appendis_owner = nil
  1933. }
  1934. // IsOwner returns the value of the "is_owner" field in the mutation.
  1935. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1936. v := m.is_owner
  1937. if v == nil {
  1938. return
  1939. }
  1940. return *v, true
  1941. }
  1942. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1943. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1945. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1946. if !m.op.Is(OpUpdateOne) {
  1947. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1948. }
  1949. if m.id == nil || m.oldValue == nil {
  1950. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1951. }
  1952. oldValue, err := m.oldValue(ctx)
  1953. if err != nil {
  1954. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1955. }
  1956. return oldValue.IsOwner, nil
  1957. }
  1958. // AppendIsOwner adds b to the "is_owner" field.
  1959. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1960. m.appendis_owner = append(m.appendis_owner, b...)
  1961. }
  1962. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1963. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1964. if len(m.appendis_owner) == 0 {
  1965. return nil, false
  1966. }
  1967. return m.appendis_owner, true
  1968. }
  1969. // ClearIsOwner clears the value of the "is_owner" field.
  1970. func (m *AgentBaseMutation) ClearIsOwner() {
  1971. m.is_owner = nil
  1972. m.appendis_owner = nil
  1973. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1974. }
  1975. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1976. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1977. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1978. return ok
  1979. }
  1980. // ResetIsOwner resets all changes to the "is_owner" field.
  1981. func (m *AgentBaseMutation) ResetIsOwner() {
  1982. m.is_owner = nil
  1983. m.appendis_owner = nil
  1984. delete(m.clearedFields, agentbase.FieldIsOwner)
  1985. }
  1986. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1987. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1988. if m.wx_agent == nil {
  1989. m.wx_agent = make(map[uint64]struct{})
  1990. }
  1991. for i := range ids {
  1992. m.wx_agent[ids[i]] = struct{}{}
  1993. }
  1994. }
  1995. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1996. func (m *AgentBaseMutation) ClearWxAgent() {
  1997. m.clearedwx_agent = true
  1998. }
  1999. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2000. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2001. return m.clearedwx_agent
  2002. }
  2003. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2004. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2005. if m.removedwx_agent == nil {
  2006. m.removedwx_agent = make(map[uint64]struct{})
  2007. }
  2008. for i := range ids {
  2009. delete(m.wx_agent, ids[i])
  2010. m.removedwx_agent[ids[i]] = struct{}{}
  2011. }
  2012. }
  2013. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2014. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2015. for id := range m.removedwx_agent {
  2016. ids = append(ids, id)
  2017. }
  2018. return
  2019. }
  2020. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2021. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2022. for id := range m.wx_agent {
  2023. ids = append(ids, id)
  2024. }
  2025. return
  2026. }
  2027. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2028. func (m *AgentBaseMutation) ResetWxAgent() {
  2029. m.wx_agent = nil
  2030. m.clearedwx_agent = false
  2031. m.removedwx_agent = nil
  2032. }
  2033. // Where appends a list predicates to the AgentBaseMutation builder.
  2034. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2035. m.predicates = append(m.predicates, ps...)
  2036. }
  2037. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2038. // users can use type-assertion to append predicates that do not depend on any generated package.
  2039. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2040. p := make([]predicate.AgentBase, len(ps))
  2041. for i := range ps {
  2042. p[i] = ps[i]
  2043. }
  2044. m.Where(p...)
  2045. }
  2046. // Op returns the operation name.
  2047. func (m *AgentBaseMutation) Op() Op {
  2048. return m.op
  2049. }
  2050. // SetOp allows setting the mutation operation.
  2051. func (m *AgentBaseMutation) SetOp(op Op) {
  2052. m.op = op
  2053. }
  2054. // Type returns the node type of this mutation (AgentBase).
  2055. func (m *AgentBaseMutation) Type() string {
  2056. return m.typ
  2057. }
  2058. // Fields returns all fields that were changed during this mutation. Note that in
  2059. // order to get all numeric fields that were incremented/decremented, call
  2060. // AddedFields().
  2061. func (m *AgentBaseMutation) Fields() []string {
  2062. fields := make([]string, 0, 9)
  2063. if m.q != nil {
  2064. fields = append(fields, agentbase.FieldQ)
  2065. }
  2066. if m.a != nil {
  2067. fields = append(fields, agentbase.FieldA)
  2068. }
  2069. if m.chunk_index != nil {
  2070. fields = append(fields, agentbase.FieldChunkIndex)
  2071. }
  2072. if m.indexes != nil {
  2073. fields = append(fields, agentbase.FieldIndexes)
  2074. }
  2075. if m.dataset_id != nil {
  2076. fields = append(fields, agentbase.FieldDatasetID)
  2077. }
  2078. if m.collection_id != nil {
  2079. fields = append(fields, agentbase.FieldCollectionID)
  2080. }
  2081. if m.source_name != nil {
  2082. fields = append(fields, agentbase.FieldSourceName)
  2083. }
  2084. if m.can_write != nil {
  2085. fields = append(fields, agentbase.FieldCanWrite)
  2086. }
  2087. if m.is_owner != nil {
  2088. fields = append(fields, agentbase.FieldIsOwner)
  2089. }
  2090. return fields
  2091. }
  2092. // Field returns the value of a field with the given name. The second boolean
  2093. // return value indicates that this field was not set, or was not defined in the
  2094. // schema.
  2095. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2096. switch name {
  2097. case agentbase.FieldQ:
  2098. return m.Q()
  2099. case agentbase.FieldA:
  2100. return m.A()
  2101. case agentbase.FieldChunkIndex:
  2102. return m.ChunkIndex()
  2103. case agentbase.FieldIndexes:
  2104. return m.Indexes()
  2105. case agentbase.FieldDatasetID:
  2106. return m.DatasetID()
  2107. case agentbase.FieldCollectionID:
  2108. return m.CollectionID()
  2109. case agentbase.FieldSourceName:
  2110. return m.SourceName()
  2111. case agentbase.FieldCanWrite:
  2112. return m.CanWrite()
  2113. case agentbase.FieldIsOwner:
  2114. return m.IsOwner()
  2115. }
  2116. return nil, false
  2117. }
  2118. // OldField returns the old value of the field from the database. An error is
  2119. // returned if the mutation operation is not UpdateOne, or the query to the
  2120. // database failed.
  2121. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2122. switch name {
  2123. case agentbase.FieldQ:
  2124. return m.OldQ(ctx)
  2125. case agentbase.FieldA:
  2126. return m.OldA(ctx)
  2127. case agentbase.FieldChunkIndex:
  2128. return m.OldChunkIndex(ctx)
  2129. case agentbase.FieldIndexes:
  2130. return m.OldIndexes(ctx)
  2131. case agentbase.FieldDatasetID:
  2132. return m.OldDatasetID(ctx)
  2133. case agentbase.FieldCollectionID:
  2134. return m.OldCollectionID(ctx)
  2135. case agentbase.FieldSourceName:
  2136. return m.OldSourceName(ctx)
  2137. case agentbase.FieldCanWrite:
  2138. return m.OldCanWrite(ctx)
  2139. case agentbase.FieldIsOwner:
  2140. return m.OldIsOwner(ctx)
  2141. }
  2142. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2143. }
  2144. // SetField sets the value of a field with the given name. It returns an error if
  2145. // the field is not defined in the schema, or if the type mismatched the field
  2146. // type.
  2147. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2148. switch name {
  2149. case agentbase.FieldQ:
  2150. v, ok := value.(string)
  2151. if !ok {
  2152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2153. }
  2154. m.SetQ(v)
  2155. return nil
  2156. case agentbase.FieldA:
  2157. v, ok := value.(string)
  2158. if !ok {
  2159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2160. }
  2161. m.SetA(v)
  2162. return nil
  2163. case agentbase.FieldChunkIndex:
  2164. v, ok := value.(uint64)
  2165. if !ok {
  2166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2167. }
  2168. m.SetChunkIndex(v)
  2169. return nil
  2170. case agentbase.FieldIndexes:
  2171. v, ok := value.([]string)
  2172. if !ok {
  2173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2174. }
  2175. m.SetIndexes(v)
  2176. return nil
  2177. case agentbase.FieldDatasetID:
  2178. v, ok := value.(string)
  2179. if !ok {
  2180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2181. }
  2182. m.SetDatasetID(v)
  2183. return nil
  2184. case agentbase.FieldCollectionID:
  2185. v, ok := value.(string)
  2186. if !ok {
  2187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2188. }
  2189. m.SetCollectionID(v)
  2190. return nil
  2191. case agentbase.FieldSourceName:
  2192. v, ok := value.(string)
  2193. if !ok {
  2194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2195. }
  2196. m.SetSourceName(v)
  2197. return nil
  2198. case agentbase.FieldCanWrite:
  2199. v, ok := value.([]bool)
  2200. if !ok {
  2201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2202. }
  2203. m.SetCanWrite(v)
  2204. return nil
  2205. case agentbase.FieldIsOwner:
  2206. v, ok := value.([]bool)
  2207. if !ok {
  2208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2209. }
  2210. m.SetIsOwner(v)
  2211. return nil
  2212. }
  2213. return fmt.Errorf("unknown AgentBase field %s", name)
  2214. }
  2215. // AddedFields returns all numeric fields that were incremented/decremented during
  2216. // this mutation.
  2217. func (m *AgentBaseMutation) AddedFields() []string {
  2218. var fields []string
  2219. if m.addchunk_index != nil {
  2220. fields = append(fields, agentbase.FieldChunkIndex)
  2221. }
  2222. return fields
  2223. }
  2224. // AddedField returns the numeric value that was incremented/decremented on a field
  2225. // with the given name. The second boolean return value indicates that this field
  2226. // was not set, or was not defined in the schema.
  2227. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2228. switch name {
  2229. case agentbase.FieldChunkIndex:
  2230. return m.AddedChunkIndex()
  2231. }
  2232. return nil, false
  2233. }
  2234. // AddField adds the value to the field with the given name. It returns an error if
  2235. // the field is not defined in the schema, or if the type mismatched the field
  2236. // type.
  2237. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2238. switch name {
  2239. case agentbase.FieldChunkIndex:
  2240. v, ok := value.(int64)
  2241. if !ok {
  2242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2243. }
  2244. m.AddChunkIndex(v)
  2245. return nil
  2246. }
  2247. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2248. }
  2249. // ClearedFields returns all nullable fields that were cleared during this
  2250. // mutation.
  2251. func (m *AgentBaseMutation) ClearedFields() []string {
  2252. var fields []string
  2253. if m.FieldCleared(agentbase.FieldQ) {
  2254. fields = append(fields, agentbase.FieldQ)
  2255. }
  2256. if m.FieldCleared(agentbase.FieldA) {
  2257. fields = append(fields, agentbase.FieldA)
  2258. }
  2259. if m.FieldCleared(agentbase.FieldIndexes) {
  2260. fields = append(fields, agentbase.FieldIndexes)
  2261. }
  2262. if m.FieldCleared(agentbase.FieldDatasetID) {
  2263. fields = append(fields, agentbase.FieldDatasetID)
  2264. }
  2265. if m.FieldCleared(agentbase.FieldCollectionID) {
  2266. fields = append(fields, agentbase.FieldCollectionID)
  2267. }
  2268. if m.FieldCleared(agentbase.FieldSourceName) {
  2269. fields = append(fields, agentbase.FieldSourceName)
  2270. }
  2271. if m.FieldCleared(agentbase.FieldCanWrite) {
  2272. fields = append(fields, agentbase.FieldCanWrite)
  2273. }
  2274. if m.FieldCleared(agentbase.FieldIsOwner) {
  2275. fields = append(fields, agentbase.FieldIsOwner)
  2276. }
  2277. return fields
  2278. }
  2279. // FieldCleared returns a boolean indicating if a field with the given name was
  2280. // cleared in this mutation.
  2281. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2282. _, ok := m.clearedFields[name]
  2283. return ok
  2284. }
  2285. // ClearField clears the value of the field with the given name. It returns an
  2286. // error if the field is not defined in the schema.
  2287. func (m *AgentBaseMutation) ClearField(name string) error {
  2288. switch name {
  2289. case agentbase.FieldQ:
  2290. m.ClearQ()
  2291. return nil
  2292. case agentbase.FieldA:
  2293. m.ClearA()
  2294. return nil
  2295. case agentbase.FieldIndexes:
  2296. m.ClearIndexes()
  2297. return nil
  2298. case agentbase.FieldDatasetID:
  2299. m.ClearDatasetID()
  2300. return nil
  2301. case agentbase.FieldCollectionID:
  2302. m.ClearCollectionID()
  2303. return nil
  2304. case agentbase.FieldSourceName:
  2305. m.ClearSourceName()
  2306. return nil
  2307. case agentbase.FieldCanWrite:
  2308. m.ClearCanWrite()
  2309. return nil
  2310. case agentbase.FieldIsOwner:
  2311. m.ClearIsOwner()
  2312. return nil
  2313. }
  2314. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2315. }
  2316. // ResetField resets all changes in the mutation for the field with the given name.
  2317. // It returns an error if the field is not defined in the schema.
  2318. func (m *AgentBaseMutation) ResetField(name string) error {
  2319. switch name {
  2320. case agentbase.FieldQ:
  2321. m.ResetQ()
  2322. return nil
  2323. case agentbase.FieldA:
  2324. m.ResetA()
  2325. return nil
  2326. case agentbase.FieldChunkIndex:
  2327. m.ResetChunkIndex()
  2328. return nil
  2329. case agentbase.FieldIndexes:
  2330. m.ResetIndexes()
  2331. return nil
  2332. case agentbase.FieldDatasetID:
  2333. m.ResetDatasetID()
  2334. return nil
  2335. case agentbase.FieldCollectionID:
  2336. m.ResetCollectionID()
  2337. return nil
  2338. case agentbase.FieldSourceName:
  2339. m.ResetSourceName()
  2340. return nil
  2341. case agentbase.FieldCanWrite:
  2342. m.ResetCanWrite()
  2343. return nil
  2344. case agentbase.FieldIsOwner:
  2345. m.ResetIsOwner()
  2346. return nil
  2347. }
  2348. return fmt.Errorf("unknown AgentBase field %s", name)
  2349. }
  2350. // AddedEdges returns all edge names that were set/added in this mutation.
  2351. func (m *AgentBaseMutation) AddedEdges() []string {
  2352. edges := make([]string, 0, 1)
  2353. if m.wx_agent != nil {
  2354. edges = append(edges, agentbase.EdgeWxAgent)
  2355. }
  2356. return edges
  2357. }
  2358. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2359. // name in this mutation.
  2360. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2361. switch name {
  2362. case agentbase.EdgeWxAgent:
  2363. ids := make([]ent.Value, 0, len(m.wx_agent))
  2364. for id := range m.wx_agent {
  2365. ids = append(ids, id)
  2366. }
  2367. return ids
  2368. }
  2369. return nil
  2370. }
  2371. // RemovedEdges returns all edge names that were removed in this mutation.
  2372. func (m *AgentBaseMutation) RemovedEdges() []string {
  2373. edges := make([]string, 0, 1)
  2374. if m.removedwx_agent != nil {
  2375. edges = append(edges, agentbase.EdgeWxAgent)
  2376. }
  2377. return edges
  2378. }
  2379. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2380. // the given name in this mutation.
  2381. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2382. switch name {
  2383. case agentbase.EdgeWxAgent:
  2384. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2385. for id := range m.removedwx_agent {
  2386. ids = append(ids, id)
  2387. }
  2388. return ids
  2389. }
  2390. return nil
  2391. }
  2392. // ClearedEdges returns all edge names that were cleared in this mutation.
  2393. func (m *AgentBaseMutation) ClearedEdges() []string {
  2394. edges := make([]string, 0, 1)
  2395. if m.clearedwx_agent {
  2396. edges = append(edges, agentbase.EdgeWxAgent)
  2397. }
  2398. return edges
  2399. }
  2400. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2401. // was cleared in this mutation.
  2402. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2403. switch name {
  2404. case agentbase.EdgeWxAgent:
  2405. return m.clearedwx_agent
  2406. }
  2407. return false
  2408. }
  2409. // ClearEdge clears the value of the edge with the given name. It returns an error
  2410. // if that edge is not defined in the schema.
  2411. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2412. switch name {
  2413. }
  2414. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2415. }
  2416. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2417. // It returns an error if the edge is not defined in the schema.
  2418. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2419. switch name {
  2420. case agentbase.EdgeWxAgent:
  2421. m.ResetWxAgent()
  2422. return nil
  2423. }
  2424. return fmt.Errorf("unknown AgentBase edge %s", name)
  2425. }
  2426. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2427. type AliyunAvatarMutation struct {
  2428. config
  2429. op Op
  2430. typ string
  2431. id *uint64
  2432. created_at *time.Time
  2433. updated_at *time.Time
  2434. deleted_at *time.Time
  2435. user_id *uint64
  2436. adduser_id *int64
  2437. biz_id *string
  2438. access_key_id *string
  2439. access_key_secret *string
  2440. app_id *string
  2441. tenant_id *uint64
  2442. addtenant_id *int64
  2443. response *string
  2444. token *string
  2445. session_id *string
  2446. clearedFields map[string]struct{}
  2447. done bool
  2448. oldValue func(context.Context) (*AliyunAvatar, error)
  2449. predicates []predicate.AliyunAvatar
  2450. }
  2451. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2452. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2453. type aliyunavatarOption func(*AliyunAvatarMutation)
  2454. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2455. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2456. m := &AliyunAvatarMutation{
  2457. config: c,
  2458. op: op,
  2459. typ: TypeAliyunAvatar,
  2460. clearedFields: make(map[string]struct{}),
  2461. }
  2462. for _, opt := range opts {
  2463. opt(m)
  2464. }
  2465. return m
  2466. }
  2467. // withAliyunAvatarID sets the ID field of the mutation.
  2468. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2469. return func(m *AliyunAvatarMutation) {
  2470. var (
  2471. err error
  2472. once sync.Once
  2473. value *AliyunAvatar
  2474. )
  2475. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2476. once.Do(func() {
  2477. if m.done {
  2478. err = errors.New("querying old values post mutation is not allowed")
  2479. } else {
  2480. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2481. }
  2482. })
  2483. return value, err
  2484. }
  2485. m.id = &id
  2486. }
  2487. }
  2488. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2489. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2490. return func(m *AliyunAvatarMutation) {
  2491. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2492. return node, nil
  2493. }
  2494. m.id = &node.ID
  2495. }
  2496. }
  2497. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2498. // executed in a transaction (ent.Tx), a transactional client is returned.
  2499. func (m AliyunAvatarMutation) Client() *Client {
  2500. client := &Client{config: m.config}
  2501. client.init()
  2502. return client
  2503. }
  2504. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2505. // it returns an error otherwise.
  2506. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2507. if _, ok := m.driver.(*txDriver); !ok {
  2508. return nil, errors.New("ent: mutation is not running in a transaction")
  2509. }
  2510. tx := &Tx{config: m.config}
  2511. tx.init()
  2512. return tx, nil
  2513. }
  2514. // SetID sets the value of the id field. Note that this
  2515. // operation is only accepted on creation of AliyunAvatar entities.
  2516. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2517. m.id = &id
  2518. }
  2519. // ID returns the ID value in the mutation. Note that the ID is only available
  2520. // if it was provided to the builder or after it was returned from the database.
  2521. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2522. if m.id == nil {
  2523. return
  2524. }
  2525. return *m.id, true
  2526. }
  2527. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2528. // That means, if the mutation is applied within a transaction with an isolation level such
  2529. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2530. // or updated by the mutation.
  2531. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2532. switch {
  2533. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2534. id, exists := m.ID()
  2535. if exists {
  2536. return []uint64{id}, nil
  2537. }
  2538. fallthrough
  2539. case m.op.Is(OpUpdate | OpDelete):
  2540. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2541. default:
  2542. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2543. }
  2544. }
  2545. // SetCreatedAt sets the "created_at" field.
  2546. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2547. m.created_at = &t
  2548. }
  2549. // CreatedAt returns the value of the "created_at" field in the mutation.
  2550. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2551. v := m.created_at
  2552. if v == nil {
  2553. return
  2554. }
  2555. return *v, true
  2556. }
  2557. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2558. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2560. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2561. if !m.op.Is(OpUpdateOne) {
  2562. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2563. }
  2564. if m.id == nil || m.oldValue == nil {
  2565. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2566. }
  2567. oldValue, err := m.oldValue(ctx)
  2568. if err != nil {
  2569. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2570. }
  2571. return oldValue.CreatedAt, nil
  2572. }
  2573. // ResetCreatedAt resets all changes to the "created_at" field.
  2574. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2575. m.created_at = nil
  2576. }
  2577. // SetUpdatedAt sets the "updated_at" field.
  2578. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2579. m.updated_at = &t
  2580. }
  2581. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2582. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2583. v := m.updated_at
  2584. if v == nil {
  2585. return
  2586. }
  2587. return *v, true
  2588. }
  2589. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2590. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2592. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2593. if !m.op.Is(OpUpdateOne) {
  2594. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2595. }
  2596. if m.id == nil || m.oldValue == nil {
  2597. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2598. }
  2599. oldValue, err := m.oldValue(ctx)
  2600. if err != nil {
  2601. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2602. }
  2603. return oldValue.UpdatedAt, nil
  2604. }
  2605. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2606. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2607. m.updated_at = nil
  2608. }
  2609. // SetDeletedAt sets the "deleted_at" field.
  2610. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2611. m.deleted_at = &t
  2612. }
  2613. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2614. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2615. v := m.deleted_at
  2616. if v == nil {
  2617. return
  2618. }
  2619. return *v, true
  2620. }
  2621. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2622. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2624. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2625. if !m.op.Is(OpUpdateOne) {
  2626. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2627. }
  2628. if m.id == nil || m.oldValue == nil {
  2629. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2630. }
  2631. oldValue, err := m.oldValue(ctx)
  2632. if err != nil {
  2633. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2634. }
  2635. return oldValue.DeletedAt, nil
  2636. }
  2637. // ClearDeletedAt clears the value of the "deleted_at" field.
  2638. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2639. m.deleted_at = nil
  2640. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2641. }
  2642. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2643. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2644. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2645. return ok
  2646. }
  2647. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2648. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2649. m.deleted_at = nil
  2650. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2651. }
  2652. // SetUserID sets the "user_id" field.
  2653. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2654. m.user_id = &u
  2655. m.adduser_id = nil
  2656. }
  2657. // UserID returns the value of the "user_id" field in the mutation.
  2658. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2659. v := m.user_id
  2660. if v == nil {
  2661. return
  2662. }
  2663. return *v, true
  2664. }
  2665. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2666. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2668. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2669. if !m.op.Is(OpUpdateOne) {
  2670. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2671. }
  2672. if m.id == nil || m.oldValue == nil {
  2673. return v, errors.New("OldUserID requires an ID field in the mutation")
  2674. }
  2675. oldValue, err := m.oldValue(ctx)
  2676. if err != nil {
  2677. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2678. }
  2679. return oldValue.UserID, nil
  2680. }
  2681. // AddUserID adds u to the "user_id" field.
  2682. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2683. if m.adduser_id != nil {
  2684. *m.adduser_id += u
  2685. } else {
  2686. m.adduser_id = &u
  2687. }
  2688. }
  2689. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2690. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2691. v := m.adduser_id
  2692. if v == nil {
  2693. return
  2694. }
  2695. return *v, true
  2696. }
  2697. // ResetUserID resets all changes to the "user_id" field.
  2698. func (m *AliyunAvatarMutation) ResetUserID() {
  2699. m.user_id = nil
  2700. m.adduser_id = nil
  2701. }
  2702. // SetBizID sets the "biz_id" field.
  2703. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2704. m.biz_id = &s
  2705. }
  2706. // BizID returns the value of the "biz_id" field in the mutation.
  2707. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2708. v := m.biz_id
  2709. if v == nil {
  2710. return
  2711. }
  2712. return *v, true
  2713. }
  2714. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2715. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2717. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2718. if !m.op.Is(OpUpdateOne) {
  2719. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2720. }
  2721. if m.id == nil || m.oldValue == nil {
  2722. return v, errors.New("OldBizID requires an ID field in the mutation")
  2723. }
  2724. oldValue, err := m.oldValue(ctx)
  2725. if err != nil {
  2726. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2727. }
  2728. return oldValue.BizID, nil
  2729. }
  2730. // ResetBizID resets all changes to the "biz_id" field.
  2731. func (m *AliyunAvatarMutation) ResetBizID() {
  2732. m.biz_id = nil
  2733. }
  2734. // SetAccessKeyID sets the "access_key_id" field.
  2735. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2736. m.access_key_id = &s
  2737. }
  2738. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2739. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2740. v := m.access_key_id
  2741. if v == nil {
  2742. return
  2743. }
  2744. return *v, true
  2745. }
  2746. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2747. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2749. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2750. if !m.op.Is(OpUpdateOne) {
  2751. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2752. }
  2753. if m.id == nil || m.oldValue == nil {
  2754. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2755. }
  2756. oldValue, err := m.oldValue(ctx)
  2757. if err != nil {
  2758. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2759. }
  2760. return oldValue.AccessKeyID, nil
  2761. }
  2762. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2763. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2764. m.access_key_id = nil
  2765. }
  2766. // SetAccessKeySecret sets the "access_key_secret" field.
  2767. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2768. m.access_key_secret = &s
  2769. }
  2770. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2771. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2772. v := m.access_key_secret
  2773. if v == nil {
  2774. return
  2775. }
  2776. return *v, true
  2777. }
  2778. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2779. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2781. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2782. if !m.op.Is(OpUpdateOne) {
  2783. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2784. }
  2785. if m.id == nil || m.oldValue == nil {
  2786. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2787. }
  2788. oldValue, err := m.oldValue(ctx)
  2789. if err != nil {
  2790. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2791. }
  2792. return oldValue.AccessKeySecret, nil
  2793. }
  2794. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2795. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2796. m.access_key_secret = nil
  2797. }
  2798. // SetAppID sets the "app_id" field.
  2799. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2800. m.app_id = &s
  2801. }
  2802. // AppID returns the value of the "app_id" field in the mutation.
  2803. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2804. v := m.app_id
  2805. if v == nil {
  2806. return
  2807. }
  2808. return *v, true
  2809. }
  2810. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2811. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2813. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2814. if !m.op.Is(OpUpdateOne) {
  2815. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2816. }
  2817. if m.id == nil || m.oldValue == nil {
  2818. return v, errors.New("OldAppID requires an ID field in the mutation")
  2819. }
  2820. oldValue, err := m.oldValue(ctx)
  2821. if err != nil {
  2822. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2823. }
  2824. return oldValue.AppID, nil
  2825. }
  2826. // ClearAppID clears the value of the "app_id" field.
  2827. func (m *AliyunAvatarMutation) ClearAppID() {
  2828. m.app_id = nil
  2829. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2830. }
  2831. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2832. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2833. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2834. return ok
  2835. }
  2836. // ResetAppID resets all changes to the "app_id" field.
  2837. func (m *AliyunAvatarMutation) ResetAppID() {
  2838. m.app_id = nil
  2839. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2840. }
  2841. // SetTenantID sets the "tenant_id" field.
  2842. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2843. m.tenant_id = &u
  2844. m.addtenant_id = nil
  2845. }
  2846. // TenantID returns the value of the "tenant_id" field in the mutation.
  2847. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2848. v := m.tenant_id
  2849. if v == nil {
  2850. return
  2851. }
  2852. return *v, true
  2853. }
  2854. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2855. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2857. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2858. if !m.op.Is(OpUpdateOne) {
  2859. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2860. }
  2861. if m.id == nil || m.oldValue == nil {
  2862. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2863. }
  2864. oldValue, err := m.oldValue(ctx)
  2865. if err != nil {
  2866. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2867. }
  2868. return oldValue.TenantID, nil
  2869. }
  2870. // AddTenantID adds u to the "tenant_id" field.
  2871. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2872. if m.addtenant_id != nil {
  2873. *m.addtenant_id += u
  2874. } else {
  2875. m.addtenant_id = &u
  2876. }
  2877. }
  2878. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2879. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2880. v := m.addtenant_id
  2881. if v == nil {
  2882. return
  2883. }
  2884. return *v, true
  2885. }
  2886. // ResetTenantID resets all changes to the "tenant_id" field.
  2887. func (m *AliyunAvatarMutation) ResetTenantID() {
  2888. m.tenant_id = nil
  2889. m.addtenant_id = nil
  2890. }
  2891. // SetResponse sets the "response" field.
  2892. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2893. m.response = &s
  2894. }
  2895. // Response returns the value of the "response" field in the mutation.
  2896. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2897. v := m.response
  2898. if v == nil {
  2899. return
  2900. }
  2901. return *v, true
  2902. }
  2903. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2904. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2906. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2907. if !m.op.Is(OpUpdateOne) {
  2908. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2909. }
  2910. if m.id == nil || m.oldValue == nil {
  2911. return v, errors.New("OldResponse requires an ID field in the mutation")
  2912. }
  2913. oldValue, err := m.oldValue(ctx)
  2914. if err != nil {
  2915. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2916. }
  2917. return oldValue.Response, nil
  2918. }
  2919. // ResetResponse resets all changes to the "response" field.
  2920. func (m *AliyunAvatarMutation) ResetResponse() {
  2921. m.response = nil
  2922. }
  2923. // SetToken sets the "token" field.
  2924. func (m *AliyunAvatarMutation) SetToken(s string) {
  2925. m.token = &s
  2926. }
  2927. // Token returns the value of the "token" field in the mutation.
  2928. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2929. v := m.token
  2930. if v == nil {
  2931. return
  2932. }
  2933. return *v, true
  2934. }
  2935. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2936. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2938. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2939. if !m.op.Is(OpUpdateOne) {
  2940. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2941. }
  2942. if m.id == nil || m.oldValue == nil {
  2943. return v, errors.New("OldToken requires an ID field in the mutation")
  2944. }
  2945. oldValue, err := m.oldValue(ctx)
  2946. if err != nil {
  2947. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2948. }
  2949. return oldValue.Token, nil
  2950. }
  2951. // ResetToken resets all changes to the "token" field.
  2952. func (m *AliyunAvatarMutation) ResetToken() {
  2953. m.token = nil
  2954. }
  2955. // SetSessionID sets the "session_id" field.
  2956. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2957. m.session_id = &s
  2958. }
  2959. // SessionID returns the value of the "session_id" field in the mutation.
  2960. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2961. v := m.session_id
  2962. if v == nil {
  2963. return
  2964. }
  2965. return *v, true
  2966. }
  2967. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2968. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2970. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2971. if !m.op.Is(OpUpdateOne) {
  2972. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2973. }
  2974. if m.id == nil || m.oldValue == nil {
  2975. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2976. }
  2977. oldValue, err := m.oldValue(ctx)
  2978. if err != nil {
  2979. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2980. }
  2981. return oldValue.SessionID, nil
  2982. }
  2983. // ResetSessionID resets all changes to the "session_id" field.
  2984. func (m *AliyunAvatarMutation) ResetSessionID() {
  2985. m.session_id = nil
  2986. }
  2987. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2988. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2989. m.predicates = append(m.predicates, ps...)
  2990. }
  2991. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2992. // users can use type-assertion to append predicates that do not depend on any generated package.
  2993. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2994. p := make([]predicate.AliyunAvatar, len(ps))
  2995. for i := range ps {
  2996. p[i] = ps[i]
  2997. }
  2998. m.Where(p...)
  2999. }
  3000. // Op returns the operation name.
  3001. func (m *AliyunAvatarMutation) Op() Op {
  3002. return m.op
  3003. }
  3004. // SetOp allows setting the mutation operation.
  3005. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3006. m.op = op
  3007. }
  3008. // Type returns the node type of this mutation (AliyunAvatar).
  3009. func (m *AliyunAvatarMutation) Type() string {
  3010. return m.typ
  3011. }
  3012. // Fields returns all fields that were changed during this mutation. Note that in
  3013. // order to get all numeric fields that were incremented/decremented, call
  3014. // AddedFields().
  3015. func (m *AliyunAvatarMutation) Fields() []string {
  3016. fields := make([]string, 0, 12)
  3017. if m.created_at != nil {
  3018. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3019. }
  3020. if m.updated_at != nil {
  3021. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3022. }
  3023. if m.deleted_at != nil {
  3024. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3025. }
  3026. if m.user_id != nil {
  3027. fields = append(fields, aliyunavatar.FieldUserID)
  3028. }
  3029. if m.biz_id != nil {
  3030. fields = append(fields, aliyunavatar.FieldBizID)
  3031. }
  3032. if m.access_key_id != nil {
  3033. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3034. }
  3035. if m.access_key_secret != nil {
  3036. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3037. }
  3038. if m.app_id != nil {
  3039. fields = append(fields, aliyunavatar.FieldAppID)
  3040. }
  3041. if m.tenant_id != nil {
  3042. fields = append(fields, aliyunavatar.FieldTenantID)
  3043. }
  3044. if m.response != nil {
  3045. fields = append(fields, aliyunavatar.FieldResponse)
  3046. }
  3047. if m.token != nil {
  3048. fields = append(fields, aliyunavatar.FieldToken)
  3049. }
  3050. if m.session_id != nil {
  3051. fields = append(fields, aliyunavatar.FieldSessionID)
  3052. }
  3053. return fields
  3054. }
  3055. // Field returns the value of a field with the given name. The second boolean
  3056. // return value indicates that this field was not set, or was not defined in the
  3057. // schema.
  3058. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3059. switch name {
  3060. case aliyunavatar.FieldCreatedAt:
  3061. return m.CreatedAt()
  3062. case aliyunavatar.FieldUpdatedAt:
  3063. return m.UpdatedAt()
  3064. case aliyunavatar.FieldDeletedAt:
  3065. return m.DeletedAt()
  3066. case aliyunavatar.FieldUserID:
  3067. return m.UserID()
  3068. case aliyunavatar.FieldBizID:
  3069. return m.BizID()
  3070. case aliyunavatar.FieldAccessKeyID:
  3071. return m.AccessKeyID()
  3072. case aliyunavatar.FieldAccessKeySecret:
  3073. return m.AccessKeySecret()
  3074. case aliyunavatar.FieldAppID:
  3075. return m.AppID()
  3076. case aliyunavatar.FieldTenantID:
  3077. return m.TenantID()
  3078. case aliyunavatar.FieldResponse:
  3079. return m.Response()
  3080. case aliyunavatar.FieldToken:
  3081. return m.Token()
  3082. case aliyunavatar.FieldSessionID:
  3083. return m.SessionID()
  3084. }
  3085. return nil, false
  3086. }
  3087. // OldField returns the old value of the field from the database. An error is
  3088. // returned if the mutation operation is not UpdateOne, or the query to the
  3089. // database failed.
  3090. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3091. switch name {
  3092. case aliyunavatar.FieldCreatedAt:
  3093. return m.OldCreatedAt(ctx)
  3094. case aliyunavatar.FieldUpdatedAt:
  3095. return m.OldUpdatedAt(ctx)
  3096. case aliyunavatar.FieldDeletedAt:
  3097. return m.OldDeletedAt(ctx)
  3098. case aliyunavatar.FieldUserID:
  3099. return m.OldUserID(ctx)
  3100. case aliyunavatar.FieldBizID:
  3101. return m.OldBizID(ctx)
  3102. case aliyunavatar.FieldAccessKeyID:
  3103. return m.OldAccessKeyID(ctx)
  3104. case aliyunavatar.FieldAccessKeySecret:
  3105. return m.OldAccessKeySecret(ctx)
  3106. case aliyunavatar.FieldAppID:
  3107. return m.OldAppID(ctx)
  3108. case aliyunavatar.FieldTenantID:
  3109. return m.OldTenantID(ctx)
  3110. case aliyunavatar.FieldResponse:
  3111. return m.OldResponse(ctx)
  3112. case aliyunavatar.FieldToken:
  3113. return m.OldToken(ctx)
  3114. case aliyunavatar.FieldSessionID:
  3115. return m.OldSessionID(ctx)
  3116. }
  3117. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3118. }
  3119. // SetField sets the value of a field with the given name. It returns an error if
  3120. // the field is not defined in the schema, or if the type mismatched the field
  3121. // type.
  3122. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3123. switch name {
  3124. case aliyunavatar.FieldCreatedAt:
  3125. v, ok := value.(time.Time)
  3126. if !ok {
  3127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3128. }
  3129. m.SetCreatedAt(v)
  3130. return nil
  3131. case aliyunavatar.FieldUpdatedAt:
  3132. v, ok := value.(time.Time)
  3133. if !ok {
  3134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3135. }
  3136. m.SetUpdatedAt(v)
  3137. return nil
  3138. case aliyunavatar.FieldDeletedAt:
  3139. v, ok := value.(time.Time)
  3140. if !ok {
  3141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3142. }
  3143. m.SetDeletedAt(v)
  3144. return nil
  3145. case aliyunavatar.FieldUserID:
  3146. v, ok := value.(uint64)
  3147. if !ok {
  3148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3149. }
  3150. m.SetUserID(v)
  3151. return nil
  3152. case aliyunavatar.FieldBizID:
  3153. v, ok := value.(string)
  3154. if !ok {
  3155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3156. }
  3157. m.SetBizID(v)
  3158. return nil
  3159. case aliyunavatar.FieldAccessKeyID:
  3160. v, ok := value.(string)
  3161. if !ok {
  3162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3163. }
  3164. m.SetAccessKeyID(v)
  3165. return nil
  3166. case aliyunavatar.FieldAccessKeySecret:
  3167. v, ok := value.(string)
  3168. if !ok {
  3169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3170. }
  3171. m.SetAccessKeySecret(v)
  3172. return nil
  3173. case aliyunavatar.FieldAppID:
  3174. v, ok := value.(string)
  3175. if !ok {
  3176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3177. }
  3178. m.SetAppID(v)
  3179. return nil
  3180. case aliyunavatar.FieldTenantID:
  3181. v, ok := value.(uint64)
  3182. if !ok {
  3183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3184. }
  3185. m.SetTenantID(v)
  3186. return nil
  3187. case aliyunavatar.FieldResponse:
  3188. v, ok := value.(string)
  3189. if !ok {
  3190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3191. }
  3192. m.SetResponse(v)
  3193. return nil
  3194. case aliyunavatar.FieldToken:
  3195. v, ok := value.(string)
  3196. if !ok {
  3197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3198. }
  3199. m.SetToken(v)
  3200. return nil
  3201. case aliyunavatar.FieldSessionID:
  3202. v, ok := value.(string)
  3203. if !ok {
  3204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3205. }
  3206. m.SetSessionID(v)
  3207. return nil
  3208. }
  3209. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3210. }
  3211. // AddedFields returns all numeric fields that were incremented/decremented during
  3212. // this mutation.
  3213. func (m *AliyunAvatarMutation) AddedFields() []string {
  3214. var fields []string
  3215. if m.adduser_id != nil {
  3216. fields = append(fields, aliyunavatar.FieldUserID)
  3217. }
  3218. if m.addtenant_id != nil {
  3219. fields = append(fields, aliyunavatar.FieldTenantID)
  3220. }
  3221. return fields
  3222. }
  3223. // AddedField returns the numeric value that was incremented/decremented on a field
  3224. // with the given name. The second boolean return value indicates that this field
  3225. // was not set, or was not defined in the schema.
  3226. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3227. switch name {
  3228. case aliyunavatar.FieldUserID:
  3229. return m.AddedUserID()
  3230. case aliyunavatar.FieldTenantID:
  3231. return m.AddedTenantID()
  3232. }
  3233. return nil, false
  3234. }
  3235. // AddField adds the value to the field with the given name. It returns an error if
  3236. // the field is not defined in the schema, or if the type mismatched the field
  3237. // type.
  3238. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3239. switch name {
  3240. case aliyunavatar.FieldUserID:
  3241. v, ok := value.(int64)
  3242. if !ok {
  3243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3244. }
  3245. m.AddUserID(v)
  3246. return nil
  3247. case aliyunavatar.FieldTenantID:
  3248. v, ok := value.(int64)
  3249. if !ok {
  3250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3251. }
  3252. m.AddTenantID(v)
  3253. return nil
  3254. }
  3255. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3256. }
  3257. // ClearedFields returns all nullable fields that were cleared during this
  3258. // mutation.
  3259. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3260. var fields []string
  3261. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3262. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3263. }
  3264. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3265. fields = append(fields, aliyunavatar.FieldAppID)
  3266. }
  3267. return fields
  3268. }
  3269. // FieldCleared returns a boolean indicating if a field with the given name was
  3270. // cleared in this mutation.
  3271. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3272. _, ok := m.clearedFields[name]
  3273. return ok
  3274. }
  3275. // ClearField clears the value of the field with the given name. It returns an
  3276. // error if the field is not defined in the schema.
  3277. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3278. switch name {
  3279. case aliyunavatar.FieldDeletedAt:
  3280. m.ClearDeletedAt()
  3281. return nil
  3282. case aliyunavatar.FieldAppID:
  3283. m.ClearAppID()
  3284. return nil
  3285. }
  3286. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3287. }
  3288. // ResetField resets all changes in the mutation for the field with the given name.
  3289. // It returns an error if the field is not defined in the schema.
  3290. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3291. switch name {
  3292. case aliyunavatar.FieldCreatedAt:
  3293. m.ResetCreatedAt()
  3294. return nil
  3295. case aliyunavatar.FieldUpdatedAt:
  3296. m.ResetUpdatedAt()
  3297. return nil
  3298. case aliyunavatar.FieldDeletedAt:
  3299. m.ResetDeletedAt()
  3300. return nil
  3301. case aliyunavatar.FieldUserID:
  3302. m.ResetUserID()
  3303. return nil
  3304. case aliyunavatar.FieldBizID:
  3305. m.ResetBizID()
  3306. return nil
  3307. case aliyunavatar.FieldAccessKeyID:
  3308. m.ResetAccessKeyID()
  3309. return nil
  3310. case aliyunavatar.FieldAccessKeySecret:
  3311. m.ResetAccessKeySecret()
  3312. return nil
  3313. case aliyunavatar.FieldAppID:
  3314. m.ResetAppID()
  3315. return nil
  3316. case aliyunavatar.FieldTenantID:
  3317. m.ResetTenantID()
  3318. return nil
  3319. case aliyunavatar.FieldResponse:
  3320. m.ResetResponse()
  3321. return nil
  3322. case aliyunavatar.FieldToken:
  3323. m.ResetToken()
  3324. return nil
  3325. case aliyunavatar.FieldSessionID:
  3326. m.ResetSessionID()
  3327. return nil
  3328. }
  3329. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3330. }
  3331. // AddedEdges returns all edge names that were set/added in this mutation.
  3332. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3333. edges := make([]string, 0, 0)
  3334. return edges
  3335. }
  3336. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3337. // name in this mutation.
  3338. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3339. return nil
  3340. }
  3341. // RemovedEdges returns all edge names that were removed in this mutation.
  3342. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3343. edges := make([]string, 0, 0)
  3344. return edges
  3345. }
  3346. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3347. // the given name in this mutation.
  3348. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3349. return nil
  3350. }
  3351. // ClearedEdges returns all edge names that were cleared in this mutation.
  3352. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3353. edges := make([]string, 0, 0)
  3354. return edges
  3355. }
  3356. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3357. // was cleared in this mutation.
  3358. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3359. return false
  3360. }
  3361. // ClearEdge clears the value of the edge with the given name. It returns an error
  3362. // if that edge is not defined in the schema.
  3363. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3364. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3365. }
  3366. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3367. // It returns an error if the edge is not defined in the schema.
  3368. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3369. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3370. }
  3371. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3372. type AllocAgentMutation struct {
  3373. config
  3374. op Op
  3375. typ string
  3376. id *uint64
  3377. created_at *time.Time
  3378. updated_at *time.Time
  3379. deleted_at *time.Time
  3380. user_id *string
  3381. organization_id *uint64
  3382. addorganization_id *int64
  3383. agents *[]uint64
  3384. appendagents []uint64
  3385. status *int
  3386. addstatus *int
  3387. clearedFields map[string]struct{}
  3388. done bool
  3389. oldValue func(context.Context) (*AllocAgent, error)
  3390. predicates []predicate.AllocAgent
  3391. }
  3392. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3393. // allocagentOption allows management of the mutation configuration using functional options.
  3394. type allocagentOption func(*AllocAgentMutation)
  3395. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3396. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3397. m := &AllocAgentMutation{
  3398. config: c,
  3399. op: op,
  3400. typ: TypeAllocAgent,
  3401. clearedFields: make(map[string]struct{}),
  3402. }
  3403. for _, opt := range opts {
  3404. opt(m)
  3405. }
  3406. return m
  3407. }
  3408. // withAllocAgentID sets the ID field of the mutation.
  3409. func withAllocAgentID(id uint64) allocagentOption {
  3410. return func(m *AllocAgentMutation) {
  3411. var (
  3412. err error
  3413. once sync.Once
  3414. value *AllocAgent
  3415. )
  3416. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3417. once.Do(func() {
  3418. if m.done {
  3419. err = errors.New("querying old values post mutation is not allowed")
  3420. } else {
  3421. value, err = m.Client().AllocAgent.Get(ctx, id)
  3422. }
  3423. })
  3424. return value, err
  3425. }
  3426. m.id = &id
  3427. }
  3428. }
  3429. // withAllocAgent sets the old AllocAgent of the mutation.
  3430. func withAllocAgent(node *AllocAgent) allocagentOption {
  3431. return func(m *AllocAgentMutation) {
  3432. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3433. return node, nil
  3434. }
  3435. m.id = &node.ID
  3436. }
  3437. }
  3438. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3439. // executed in a transaction (ent.Tx), a transactional client is returned.
  3440. func (m AllocAgentMutation) Client() *Client {
  3441. client := &Client{config: m.config}
  3442. client.init()
  3443. return client
  3444. }
  3445. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3446. // it returns an error otherwise.
  3447. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3448. if _, ok := m.driver.(*txDriver); !ok {
  3449. return nil, errors.New("ent: mutation is not running in a transaction")
  3450. }
  3451. tx := &Tx{config: m.config}
  3452. tx.init()
  3453. return tx, nil
  3454. }
  3455. // SetID sets the value of the id field. Note that this
  3456. // operation is only accepted on creation of AllocAgent entities.
  3457. func (m *AllocAgentMutation) SetID(id uint64) {
  3458. m.id = &id
  3459. }
  3460. // ID returns the ID value in the mutation. Note that the ID is only available
  3461. // if it was provided to the builder or after it was returned from the database.
  3462. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3463. if m.id == nil {
  3464. return
  3465. }
  3466. return *m.id, true
  3467. }
  3468. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3469. // That means, if the mutation is applied within a transaction with an isolation level such
  3470. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3471. // or updated by the mutation.
  3472. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3473. switch {
  3474. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3475. id, exists := m.ID()
  3476. if exists {
  3477. return []uint64{id}, nil
  3478. }
  3479. fallthrough
  3480. case m.op.Is(OpUpdate | OpDelete):
  3481. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3482. default:
  3483. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3484. }
  3485. }
  3486. // SetCreatedAt sets the "created_at" field.
  3487. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3488. m.created_at = &t
  3489. }
  3490. // CreatedAt returns the value of the "created_at" field in the mutation.
  3491. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3492. v := m.created_at
  3493. if v == nil {
  3494. return
  3495. }
  3496. return *v, true
  3497. }
  3498. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3499. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3501. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3502. if !m.op.Is(OpUpdateOne) {
  3503. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3504. }
  3505. if m.id == nil || m.oldValue == nil {
  3506. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3507. }
  3508. oldValue, err := m.oldValue(ctx)
  3509. if err != nil {
  3510. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3511. }
  3512. return oldValue.CreatedAt, nil
  3513. }
  3514. // ResetCreatedAt resets all changes to the "created_at" field.
  3515. func (m *AllocAgentMutation) ResetCreatedAt() {
  3516. m.created_at = nil
  3517. }
  3518. // SetUpdatedAt sets the "updated_at" field.
  3519. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3520. m.updated_at = &t
  3521. }
  3522. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3523. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3524. v := m.updated_at
  3525. if v == nil {
  3526. return
  3527. }
  3528. return *v, true
  3529. }
  3530. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3531. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3533. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3534. if !m.op.Is(OpUpdateOne) {
  3535. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3536. }
  3537. if m.id == nil || m.oldValue == nil {
  3538. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3539. }
  3540. oldValue, err := m.oldValue(ctx)
  3541. if err != nil {
  3542. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3543. }
  3544. return oldValue.UpdatedAt, nil
  3545. }
  3546. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3547. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3548. m.updated_at = nil
  3549. }
  3550. // SetDeletedAt sets the "deleted_at" field.
  3551. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3552. m.deleted_at = &t
  3553. }
  3554. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3555. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3556. v := m.deleted_at
  3557. if v == nil {
  3558. return
  3559. }
  3560. return *v, true
  3561. }
  3562. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3563. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3565. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3566. if !m.op.Is(OpUpdateOne) {
  3567. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3568. }
  3569. if m.id == nil || m.oldValue == nil {
  3570. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3571. }
  3572. oldValue, err := m.oldValue(ctx)
  3573. if err != nil {
  3574. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3575. }
  3576. return oldValue.DeletedAt, nil
  3577. }
  3578. // ClearDeletedAt clears the value of the "deleted_at" field.
  3579. func (m *AllocAgentMutation) ClearDeletedAt() {
  3580. m.deleted_at = nil
  3581. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3582. }
  3583. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3584. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3585. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3586. return ok
  3587. }
  3588. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3589. func (m *AllocAgentMutation) ResetDeletedAt() {
  3590. m.deleted_at = nil
  3591. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3592. }
  3593. // SetUserID sets the "user_id" field.
  3594. func (m *AllocAgentMutation) SetUserID(s string) {
  3595. m.user_id = &s
  3596. }
  3597. // UserID returns the value of the "user_id" field in the mutation.
  3598. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3599. v := m.user_id
  3600. if v == nil {
  3601. return
  3602. }
  3603. return *v, true
  3604. }
  3605. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3606. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3608. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3609. if !m.op.Is(OpUpdateOne) {
  3610. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3611. }
  3612. if m.id == nil || m.oldValue == nil {
  3613. return v, errors.New("OldUserID requires an ID field in the mutation")
  3614. }
  3615. oldValue, err := m.oldValue(ctx)
  3616. if err != nil {
  3617. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3618. }
  3619. return oldValue.UserID, nil
  3620. }
  3621. // ClearUserID clears the value of the "user_id" field.
  3622. func (m *AllocAgentMutation) ClearUserID() {
  3623. m.user_id = nil
  3624. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3625. }
  3626. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3627. func (m *AllocAgentMutation) UserIDCleared() bool {
  3628. _, ok := m.clearedFields[allocagent.FieldUserID]
  3629. return ok
  3630. }
  3631. // ResetUserID resets all changes to the "user_id" field.
  3632. func (m *AllocAgentMutation) ResetUserID() {
  3633. m.user_id = nil
  3634. delete(m.clearedFields, allocagent.FieldUserID)
  3635. }
  3636. // SetOrganizationID sets the "organization_id" field.
  3637. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3638. m.organization_id = &u
  3639. m.addorganization_id = nil
  3640. }
  3641. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3642. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3643. v := m.organization_id
  3644. if v == nil {
  3645. return
  3646. }
  3647. return *v, true
  3648. }
  3649. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3650. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3652. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3653. if !m.op.Is(OpUpdateOne) {
  3654. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3655. }
  3656. if m.id == nil || m.oldValue == nil {
  3657. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3658. }
  3659. oldValue, err := m.oldValue(ctx)
  3660. if err != nil {
  3661. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3662. }
  3663. return oldValue.OrganizationID, nil
  3664. }
  3665. // AddOrganizationID adds u to the "organization_id" field.
  3666. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3667. if m.addorganization_id != nil {
  3668. *m.addorganization_id += u
  3669. } else {
  3670. m.addorganization_id = &u
  3671. }
  3672. }
  3673. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3674. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3675. v := m.addorganization_id
  3676. if v == nil {
  3677. return
  3678. }
  3679. return *v, true
  3680. }
  3681. // ClearOrganizationID clears the value of the "organization_id" field.
  3682. func (m *AllocAgentMutation) ClearOrganizationID() {
  3683. m.organization_id = nil
  3684. m.addorganization_id = nil
  3685. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3686. }
  3687. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3688. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3689. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3690. return ok
  3691. }
  3692. // ResetOrganizationID resets all changes to the "organization_id" field.
  3693. func (m *AllocAgentMutation) ResetOrganizationID() {
  3694. m.organization_id = nil
  3695. m.addorganization_id = nil
  3696. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3697. }
  3698. // SetAgents sets the "agents" field.
  3699. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3700. m.agents = &u
  3701. m.appendagents = nil
  3702. }
  3703. // Agents returns the value of the "agents" field in the mutation.
  3704. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3705. v := m.agents
  3706. if v == nil {
  3707. return
  3708. }
  3709. return *v, true
  3710. }
  3711. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3712. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3714. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3715. if !m.op.Is(OpUpdateOne) {
  3716. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3717. }
  3718. if m.id == nil || m.oldValue == nil {
  3719. return v, errors.New("OldAgents requires an ID field in the mutation")
  3720. }
  3721. oldValue, err := m.oldValue(ctx)
  3722. if err != nil {
  3723. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3724. }
  3725. return oldValue.Agents, nil
  3726. }
  3727. // AppendAgents adds u to the "agents" field.
  3728. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3729. m.appendagents = append(m.appendagents, u...)
  3730. }
  3731. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3732. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3733. if len(m.appendagents) == 0 {
  3734. return nil, false
  3735. }
  3736. return m.appendagents, true
  3737. }
  3738. // ResetAgents resets all changes to the "agents" field.
  3739. func (m *AllocAgentMutation) ResetAgents() {
  3740. m.agents = nil
  3741. m.appendagents = nil
  3742. }
  3743. // SetStatus sets the "status" field.
  3744. func (m *AllocAgentMutation) SetStatus(i int) {
  3745. m.status = &i
  3746. m.addstatus = nil
  3747. }
  3748. // Status returns the value of the "status" field in the mutation.
  3749. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3750. v := m.status
  3751. if v == nil {
  3752. return
  3753. }
  3754. return *v, true
  3755. }
  3756. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3757. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3759. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3760. if !m.op.Is(OpUpdateOne) {
  3761. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3762. }
  3763. if m.id == nil || m.oldValue == nil {
  3764. return v, errors.New("OldStatus requires an ID field in the mutation")
  3765. }
  3766. oldValue, err := m.oldValue(ctx)
  3767. if err != nil {
  3768. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3769. }
  3770. return oldValue.Status, nil
  3771. }
  3772. // AddStatus adds i to the "status" field.
  3773. func (m *AllocAgentMutation) AddStatus(i int) {
  3774. if m.addstatus != nil {
  3775. *m.addstatus += i
  3776. } else {
  3777. m.addstatus = &i
  3778. }
  3779. }
  3780. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3781. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3782. v := m.addstatus
  3783. if v == nil {
  3784. return
  3785. }
  3786. return *v, true
  3787. }
  3788. // ClearStatus clears the value of the "status" field.
  3789. func (m *AllocAgentMutation) ClearStatus() {
  3790. m.status = nil
  3791. m.addstatus = nil
  3792. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3793. }
  3794. // StatusCleared returns if the "status" field was cleared in this mutation.
  3795. func (m *AllocAgentMutation) StatusCleared() bool {
  3796. _, ok := m.clearedFields[allocagent.FieldStatus]
  3797. return ok
  3798. }
  3799. // ResetStatus resets all changes to the "status" field.
  3800. func (m *AllocAgentMutation) ResetStatus() {
  3801. m.status = nil
  3802. m.addstatus = nil
  3803. delete(m.clearedFields, allocagent.FieldStatus)
  3804. }
  3805. // Where appends a list predicates to the AllocAgentMutation builder.
  3806. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3807. m.predicates = append(m.predicates, ps...)
  3808. }
  3809. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3810. // users can use type-assertion to append predicates that do not depend on any generated package.
  3811. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3812. p := make([]predicate.AllocAgent, len(ps))
  3813. for i := range ps {
  3814. p[i] = ps[i]
  3815. }
  3816. m.Where(p...)
  3817. }
  3818. // Op returns the operation name.
  3819. func (m *AllocAgentMutation) Op() Op {
  3820. return m.op
  3821. }
  3822. // SetOp allows setting the mutation operation.
  3823. func (m *AllocAgentMutation) SetOp(op Op) {
  3824. m.op = op
  3825. }
  3826. // Type returns the node type of this mutation (AllocAgent).
  3827. func (m *AllocAgentMutation) Type() string {
  3828. return m.typ
  3829. }
  3830. // Fields returns all fields that were changed during this mutation. Note that in
  3831. // order to get all numeric fields that were incremented/decremented, call
  3832. // AddedFields().
  3833. func (m *AllocAgentMutation) Fields() []string {
  3834. fields := make([]string, 0, 7)
  3835. if m.created_at != nil {
  3836. fields = append(fields, allocagent.FieldCreatedAt)
  3837. }
  3838. if m.updated_at != nil {
  3839. fields = append(fields, allocagent.FieldUpdatedAt)
  3840. }
  3841. if m.deleted_at != nil {
  3842. fields = append(fields, allocagent.FieldDeletedAt)
  3843. }
  3844. if m.user_id != nil {
  3845. fields = append(fields, allocagent.FieldUserID)
  3846. }
  3847. if m.organization_id != nil {
  3848. fields = append(fields, allocagent.FieldOrganizationID)
  3849. }
  3850. if m.agents != nil {
  3851. fields = append(fields, allocagent.FieldAgents)
  3852. }
  3853. if m.status != nil {
  3854. fields = append(fields, allocagent.FieldStatus)
  3855. }
  3856. return fields
  3857. }
  3858. // Field returns the value of a field with the given name. The second boolean
  3859. // return value indicates that this field was not set, or was not defined in the
  3860. // schema.
  3861. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3862. switch name {
  3863. case allocagent.FieldCreatedAt:
  3864. return m.CreatedAt()
  3865. case allocagent.FieldUpdatedAt:
  3866. return m.UpdatedAt()
  3867. case allocagent.FieldDeletedAt:
  3868. return m.DeletedAt()
  3869. case allocagent.FieldUserID:
  3870. return m.UserID()
  3871. case allocagent.FieldOrganizationID:
  3872. return m.OrganizationID()
  3873. case allocagent.FieldAgents:
  3874. return m.Agents()
  3875. case allocagent.FieldStatus:
  3876. return m.Status()
  3877. }
  3878. return nil, false
  3879. }
  3880. // OldField returns the old value of the field from the database. An error is
  3881. // returned if the mutation operation is not UpdateOne, or the query to the
  3882. // database failed.
  3883. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3884. switch name {
  3885. case allocagent.FieldCreatedAt:
  3886. return m.OldCreatedAt(ctx)
  3887. case allocagent.FieldUpdatedAt:
  3888. return m.OldUpdatedAt(ctx)
  3889. case allocagent.FieldDeletedAt:
  3890. return m.OldDeletedAt(ctx)
  3891. case allocagent.FieldUserID:
  3892. return m.OldUserID(ctx)
  3893. case allocagent.FieldOrganizationID:
  3894. return m.OldOrganizationID(ctx)
  3895. case allocagent.FieldAgents:
  3896. return m.OldAgents(ctx)
  3897. case allocagent.FieldStatus:
  3898. return m.OldStatus(ctx)
  3899. }
  3900. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3901. }
  3902. // SetField sets the value of a field with the given name. It returns an error if
  3903. // the field is not defined in the schema, or if the type mismatched the field
  3904. // type.
  3905. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3906. switch name {
  3907. case allocagent.FieldCreatedAt:
  3908. v, ok := value.(time.Time)
  3909. if !ok {
  3910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3911. }
  3912. m.SetCreatedAt(v)
  3913. return nil
  3914. case allocagent.FieldUpdatedAt:
  3915. v, ok := value.(time.Time)
  3916. if !ok {
  3917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3918. }
  3919. m.SetUpdatedAt(v)
  3920. return nil
  3921. case allocagent.FieldDeletedAt:
  3922. v, ok := value.(time.Time)
  3923. if !ok {
  3924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3925. }
  3926. m.SetDeletedAt(v)
  3927. return nil
  3928. case allocagent.FieldUserID:
  3929. v, ok := value.(string)
  3930. if !ok {
  3931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3932. }
  3933. m.SetUserID(v)
  3934. return nil
  3935. case allocagent.FieldOrganizationID:
  3936. v, ok := value.(uint64)
  3937. if !ok {
  3938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3939. }
  3940. m.SetOrganizationID(v)
  3941. return nil
  3942. case allocagent.FieldAgents:
  3943. v, ok := value.([]uint64)
  3944. if !ok {
  3945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3946. }
  3947. m.SetAgents(v)
  3948. return nil
  3949. case allocagent.FieldStatus:
  3950. v, ok := value.(int)
  3951. if !ok {
  3952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3953. }
  3954. m.SetStatus(v)
  3955. return nil
  3956. }
  3957. return fmt.Errorf("unknown AllocAgent field %s", name)
  3958. }
  3959. // AddedFields returns all numeric fields that were incremented/decremented during
  3960. // this mutation.
  3961. func (m *AllocAgentMutation) AddedFields() []string {
  3962. var fields []string
  3963. if m.addorganization_id != nil {
  3964. fields = append(fields, allocagent.FieldOrganizationID)
  3965. }
  3966. if m.addstatus != nil {
  3967. fields = append(fields, allocagent.FieldStatus)
  3968. }
  3969. return fields
  3970. }
  3971. // AddedField returns the numeric value that was incremented/decremented on a field
  3972. // with the given name. The second boolean return value indicates that this field
  3973. // was not set, or was not defined in the schema.
  3974. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3975. switch name {
  3976. case allocagent.FieldOrganizationID:
  3977. return m.AddedOrganizationID()
  3978. case allocagent.FieldStatus:
  3979. return m.AddedStatus()
  3980. }
  3981. return nil, false
  3982. }
  3983. // AddField adds the value to the field with the given name. It returns an error if
  3984. // the field is not defined in the schema, or if the type mismatched the field
  3985. // type.
  3986. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3987. switch name {
  3988. case allocagent.FieldOrganizationID:
  3989. v, ok := value.(int64)
  3990. if !ok {
  3991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3992. }
  3993. m.AddOrganizationID(v)
  3994. return nil
  3995. case allocagent.FieldStatus:
  3996. v, ok := value.(int)
  3997. if !ok {
  3998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3999. }
  4000. m.AddStatus(v)
  4001. return nil
  4002. }
  4003. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4004. }
  4005. // ClearedFields returns all nullable fields that were cleared during this
  4006. // mutation.
  4007. func (m *AllocAgentMutation) ClearedFields() []string {
  4008. var fields []string
  4009. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4010. fields = append(fields, allocagent.FieldDeletedAt)
  4011. }
  4012. if m.FieldCleared(allocagent.FieldUserID) {
  4013. fields = append(fields, allocagent.FieldUserID)
  4014. }
  4015. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4016. fields = append(fields, allocagent.FieldOrganizationID)
  4017. }
  4018. if m.FieldCleared(allocagent.FieldStatus) {
  4019. fields = append(fields, allocagent.FieldStatus)
  4020. }
  4021. return fields
  4022. }
  4023. // FieldCleared returns a boolean indicating if a field with the given name was
  4024. // cleared in this mutation.
  4025. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4026. _, ok := m.clearedFields[name]
  4027. return ok
  4028. }
  4029. // ClearField clears the value of the field with the given name. It returns an
  4030. // error if the field is not defined in the schema.
  4031. func (m *AllocAgentMutation) ClearField(name string) error {
  4032. switch name {
  4033. case allocagent.FieldDeletedAt:
  4034. m.ClearDeletedAt()
  4035. return nil
  4036. case allocagent.FieldUserID:
  4037. m.ClearUserID()
  4038. return nil
  4039. case allocagent.FieldOrganizationID:
  4040. m.ClearOrganizationID()
  4041. return nil
  4042. case allocagent.FieldStatus:
  4043. m.ClearStatus()
  4044. return nil
  4045. }
  4046. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4047. }
  4048. // ResetField resets all changes in the mutation for the field with the given name.
  4049. // It returns an error if the field is not defined in the schema.
  4050. func (m *AllocAgentMutation) ResetField(name string) error {
  4051. switch name {
  4052. case allocagent.FieldCreatedAt:
  4053. m.ResetCreatedAt()
  4054. return nil
  4055. case allocagent.FieldUpdatedAt:
  4056. m.ResetUpdatedAt()
  4057. return nil
  4058. case allocagent.FieldDeletedAt:
  4059. m.ResetDeletedAt()
  4060. return nil
  4061. case allocagent.FieldUserID:
  4062. m.ResetUserID()
  4063. return nil
  4064. case allocagent.FieldOrganizationID:
  4065. m.ResetOrganizationID()
  4066. return nil
  4067. case allocagent.FieldAgents:
  4068. m.ResetAgents()
  4069. return nil
  4070. case allocagent.FieldStatus:
  4071. m.ResetStatus()
  4072. return nil
  4073. }
  4074. return fmt.Errorf("unknown AllocAgent field %s", name)
  4075. }
  4076. // AddedEdges returns all edge names that were set/added in this mutation.
  4077. func (m *AllocAgentMutation) AddedEdges() []string {
  4078. edges := make([]string, 0, 0)
  4079. return edges
  4080. }
  4081. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4082. // name in this mutation.
  4083. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4084. return nil
  4085. }
  4086. // RemovedEdges returns all edge names that were removed in this mutation.
  4087. func (m *AllocAgentMutation) RemovedEdges() []string {
  4088. edges := make([]string, 0, 0)
  4089. return edges
  4090. }
  4091. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4092. // the given name in this mutation.
  4093. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4094. return nil
  4095. }
  4096. // ClearedEdges returns all edge names that were cleared in this mutation.
  4097. func (m *AllocAgentMutation) ClearedEdges() []string {
  4098. edges := make([]string, 0, 0)
  4099. return edges
  4100. }
  4101. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4102. // was cleared in this mutation.
  4103. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4104. return false
  4105. }
  4106. // ClearEdge clears the value of the edge with the given name. It returns an error
  4107. // if that edge is not defined in the schema.
  4108. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4109. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4110. }
  4111. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4112. // It returns an error if the edge is not defined in the schema.
  4113. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4114. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4115. }
  4116. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4117. type ApiKeyMutation struct {
  4118. config
  4119. op Op
  4120. typ string
  4121. id *uint64
  4122. created_at *time.Time
  4123. updated_at *time.Time
  4124. deleted_at *time.Time
  4125. title *string
  4126. key *string
  4127. organization_id *uint64
  4128. addorganization_id *int64
  4129. custom_agent_base *string
  4130. custom_agent_key *string
  4131. openai_base *string
  4132. openai_key *string
  4133. clearedFields map[string]struct{}
  4134. agent *uint64
  4135. clearedagent bool
  4136. done bool
  4137. oldValue func(context.Context) (*ApiKey, error)
  4138. predicates []predicate.ApiKey
  4139. }
  4140. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4141. // apikeyOption allows management of the mutation configuration using functional options.
  4142. type apikeyOption func(*ApiKeyMutation)
  4143. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4144. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4145. m := &ApiKeyMutation{
  4146. config: c,
  4147. op: op,
  4148. typ: TypeApiKey,
  4149. clearedFields: make(map[string]struct{}),
  4150. }
  4151. for _, opt := range opts {
  4152. opt(m)
  4153. }
  4154. return m
  4155. }
  4156. // withApiKeyID sets the ID field of the mutation.
  4157. func withApiKeyID(id uint64) apikeyOption {
  4158. return func(m *ApiKeyMutation) {
  4159. var (
  4160. err error
  4161. once sync.Once
  4162. value *ApiKey
  4163. )
  4164. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4165. once.Do(func() {
  4166. if m.done {
  4167. err = errors.New("querying old values post mutation is not allowed")
  4168. } else {
  4169. value, err = m.Client().ApiKey.Get(ctx, id)
  4170. }
  4171. })
  4172. return value, err
  4173. }
  4174. m.id = &id
  4175. }
  4176. }
  4177. // withApiKey sets the old ApiKey of the mutation.
  4178. func withApiKey(node *ApiKey) apikeyOption {
  4179. return func(m *ApiKeyMutation) {
  4180. m.oldValue = func(context.Context) (*ApiKey, error) {
  4181. return node, nil
  4182. }
  4183. m.id = &node.ID
  4184. }
  4185. }
  4186. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4187. // executed in a transaction (ent.Tx), a transactional client is returned.
  4188. func (m ApiKeyMutation) Client() *Client {
  4189. client := &Client{config: m.config}
  4190. client.init()
  4191. return client
  4192. }
  4193. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4194. // it returns an error otherwise.
  4195. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4196. if _, ok := m.driver.(*txDriver); !ok {
  4197. return nil, errors.New("ent: mutation is not running in a transaction")
  4198. }
  4199. tx := &Tx{config: m.config}
  4200. tx.init()
  4201. return tx, nil
  4202. }
  4203. // SetID sets the value of the id field. Note that this
  4204. // operation is only accepted on creation of ApiKey entities.
  4205. func (m *ApiKeyMutation) SetID(id uint64) {
  4206. m.id = &id
  4207. }
  4208. // ID returns the ID value in the mutation. Note that the ID is only available
  4209. // if it was provided to the builder or after it was returned from the database.
  4210. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4211. if m.id == nil {
  4212. return
  4213. }
  4214. return *m.id, true
  4215. }
  4216. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4217. // That means, if the mutation is applied within a transaction with an isolation level such
  4218. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4219. // or updated by the mutation.
  4220. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4221. switch {
  4222. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4223. id, exists := m.ID()
  4224. if exists {
  4225. return []uint64{id}, nil
  4226. }
  4227. fallthrough
  4228. case m.op.Is(OpUpdate | OpDelete):
  4229. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4230. default:
  4231. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4232. }
  4233. }
  4234. // SetCreatedAt sets the "created_at" field.
  4235. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4236. m.created_at = &t
  4237. }
  4238. // CreatedAt returns the value of the "created_at" field in the mutation.
  4239. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4240. v := m.created_at
  4241. if v == nil {
  4242. return
  4243. }
  4244. return *v, true
  4245. }
  4246. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4247. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4249. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4250. if !m.op.Is(OpUpdateOne) {
  4251. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4252. }
  4253. if m.id == nil || m.oldValue == nil {
  4254. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4255. }
  4256. oldValue, err := m.oldValue(ctx)
  4257. if err != nil {
  4258. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4259. }
  4260. return oldValue.CreatedAt, nil
  4261. }
  4262. // ResetCreatedAt resets all changes to the "created_at" field.
  4263. func (m *ApiKeyMutation) ResetCreatedAt() {
  4264. m.created_at = nil
  4265. }
  4266. // SetUpdatedAt sets the "updated_at" field.
  4267. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4268. m.updated_at = &t
  4269. }
  4270. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4271. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4272. v := m.updated_at
  4273. if v == nil {
  4274. return
  4275. }
  4276. return *v, true
  4277. }
  4278. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4279. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4281. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4282. if !m.op.Is(OpUpdateOne) {
  4283. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4284. }
  4285. if m.id == nil || m.oldValue == nil {
  4286. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4287. }
  4288. oldValue, err := m.oldValue(ctx)
  4289. if err != nil {
  4290. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4291. }
  4292. return oldValue.UpdatedAt, nil
  4293. }
  4294. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4295. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4296. m.updated_at = nil
  4297. }
  4298. // SetDeletedAt sets the "deleted_at" field.
  4299. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4300. m.deleted_at = &t
  4301. }
  4302. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4303. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4304. v := m.deleted_at
  4305. if v == nil {
  4306. return
  4307. }
  4308. return *v, true
  4309. }
  4310. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4311. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4313. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4314. if !m.op.Is(OpUpdateOne) {
  4315. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4316. }
  4317. if m.id == nil || m.oldValue == nil {
  4318. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4319. }
  4320. oldValue, err := m.oldValue(ctx)
  4321. if err != nil {
  4322. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4323. }
  4324. return oldValue.DeletedAt, nil
  4325. }
  4326. // ClearDeletedAt clears the value of the "deleted_at" field.
  4327. func (m *ApiKeyMutation) ClearDeletedAt() {
  4328. m.deleted_at = nil
  4329. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4330. }
  4331. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4332. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4333. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4334. return ok
  4335. }
  4336. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4337. func (m *ApiKeyMutation) ResetDeletedAt() {
  4338. m.deleted_at = nil
  4339. delete(m.clearedFields, apikey.FieldDeletedAt)
  4340. }
  4341. // SetTitle sets the "title" field.
  4342. func (m *ApiKeyMutation) SetTitle(s string) {
  4343. m.title = &s
  4344. }
  4345. // Title returns the value of the "title" field in the mutation.
  4346. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4347. v := m.title
  4348. if v == nil {
  4349. return
  4350. }
  4351. return *v, true
  4352. }
  4353. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4354. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4356. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4357. if !m.op.Is(OpUpdateOne) {
  4358. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4359. }
  4360. if m.id == nil || m.oldValue == nil {
  4361. return v, errors.New("OldTitle requires an ID field in the mutation")
  4362. }
  4363. oldValue, err := m.oldValue(ctx)
  4364. if err != nil {
  4365. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4366. }
  4367. return oldValue.Title, nil
  4368. }
  4369. // ClearTitle clears the value of the "title" field.
  4370. func (m *ApiKeyMutation) ClearTitle() {
  4371. m.title = nil
  4372. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4373. }
  4374. // TitleCleared returns if the "title" field was cleared in this mutation.
  4375. func (m *ApiKeyMutation) TitleCleared() bool {
  4376. _, ok := m.clearedFields[apikey.FieldTitle]
  4377. return ok
  4378. }
  4379. // ResetTitle resets all changes to the "title" field.
  4380. func (m *ApiKeyMutation) ResetTitle() {
  4381. m.title = nil
  4382. delete(m.clearedFields, apikey.FieldTitle)
  4383. }
  4384. // SetKey sets the "key" field.
  4385. func (m *ApiKeyMutation) SetKey(s string) {
  4386. m.key = &s
  4387. }
  4388. // Key returns the value of the "key" field in the mutation.
  4389. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4390. v := m.key
  4391. if v == nil {
  4392. return
  4393. }
  4394. return *v, true
  4395. }
  4396. // OldKey returns the old "key" field's value of the ApiKey entity.
  4397. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4399. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4400. if !m.op.Is(OpUpdateOne) {
  4401. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4402. }
  4403. if m.id == nil || m.oldValue == nil {
  4404. return v, errors.New("OldKey requires an ID field in the mutation")
  4405. }
  4406. oldValue, err := m.oldValue(ctx)
  4407. if err != nil {
  4408. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4409. }
  4410. return oldValue.Key, nil
  4411. }
  4412. // ClearKey clears the value of the "key" field.
  4413. func (m *ApiKeyMutation) ClearKey() {
  4414. m.key = nil
  4415. m.clearedFields[apikey.FieldKey] = struct{}{}
  4416. }
  4417. // KeyCleared returns if the "key" field was cleared in this mutation.
  4418. func (m *ApiKeyMutation) KeyCleared() bool {
  4419. _, ok := m.clearedFields[apikey.FieldKey]
  4420. return ok
  4421. }
  4422. // ResetKey resets all changes to the "key" field.
  4423. func (m *ApiKeyMutation) ResetKey() {
  4424. m.key = nil
  4425. delete(m.clearedFields, apikey.FieldKey)
  4426. }
  4427. // SetOrganizationID sets the "organization_id" field.
  4428. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4429. m.organization_id = &u
  4430. m.addorganization_id = nil
  4431. }
  4432. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4433. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4434. v := m.organization_id
  4435. if v == nil {
  4436. return
  4437. }
  4438. return *v, true
  4439. }
  4440. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4441. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4443. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4444. if !m.op.Is(OpUpdateOne) {
  4445. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4446. }
  4447. if m.id == nil || m.oldValue == nil {
  4448. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4449. }
  4450. oldValue, err := m.oldValue(ctx)
  4451. if err != nil {
  4452. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4453. }
  4454. return oldValue.OrganizationID, nil
  4455. }
  4456. // AddOrganizationID adds u to the "organization_id" field.
  4457. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4458. if m.addorganization_id != nil {
  4459. *m.addorganization_id += u
  4460. } else {
  4461. m.addorganization_id = &u
  4462. }
  4463. }
  4464. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4465. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4466. v := m.addorganization_id
  4467. if v == nil {
  4468. return
  4469. }
  4470. return *v, true
  4471. }
  4472. // ResetOrganizationID resets all changes to the "organization_id" field.
  4473. func (m *ApiKeyMutation) ResetOrganizationID() {
  4474. m.organization_id = nil
  4475. m.addorganization_id = nil
  4476. }
  4477. // SetAgentID sets the "agent_id" field.
  4478. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4479. m.agent = &u
  4480. }
  4481. // AgentID returns the value of the "agent_id" field in the mutation.
  4482. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4483. v := m.agent
  4484. if v == nil {
  4485. return
  4486. }
  4487. return *v, true
  4488. }
  4489. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4490. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4492. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4493. if !m.op.Is(OpUpdateOne) {
  4494. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4495. }
  4496. if m.id == nil || m.oldValue == nil {
  4497. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4498. }
  4499. oldValue, err := m.oldValue(ctx)
  4500. if err != nil {
  4501. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4502. }
  4503. return oldValue.AgentID, nil
  4504. }
  4505. // ResetAgentID resets all changes to the "agent_id" field.
  4506. func (m *ApiKeyMutation) ResetAgentID() {
  4507. m.agent = nil
  4508. }
  4509. // SetCustomAgentBase sets the "custom_agent_base" field.
  4510. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4511. m.custom_agent_base = &s
  4512. }
  4513. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4514. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4515. v := m.custom_agent_base
  4516. if v == nil {
  4517. return
  4518. }
  4519. return *v, true
  4520. }
  4521. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4522. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4524. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4525. if !m.op.Is(OpUpdateOne) {
  4526. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4527. }
  4528. if m.id == nil || m.oldValue == nil {
  4529. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4530. }
  4531. oldValue, err := m.oldValue(ctx)
  4532. if err != nil {
  4533. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4534. }
  4535. return oldValue.CustomAgentBase, nil
  4536. }
  4537. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4538. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4539. m.custom_agent_base = nil
  4540. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4541. }
  4542. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4543. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4544. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4545. return ok
  4546. }
  4547. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4548. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4549. m.custom_agent_base = nil
  4550. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4551. }
  4552. // SetCustomAgentKey sets the "custom_agent_key" field.
  4553. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4554. m.custom_agent_key = &s
  4555. }
  4556. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4557. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4558. v := m.custom_agent_key
  4559. if v == nil {
  4560. return
  4561. }
  4562. return *v, true
  4563. }
  4564. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4565. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4567. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4568. if !m.op.Is(OpUpdateOne) {
  4569. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4570. }
  4571. if m.id == nil || m.oldValue == nil {
  4572. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4573. }
  4574. oldValue, err := m.oldValue(ctx)
  4575. if err != nil {
  4576. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4577. }
  4578. return oldValue.CustomAgentKey, nil
  4579. }
  4580. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4581. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4582. m.custom_agent_key = nil
  4583. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4584. }
  4585. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4586. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4587. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4588. return ok
  4589. }
  4590. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4591. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4592. m.custom_agent_key = nil
  4593. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4594. }
  4595. // SetOpenaiBase sets the "openai_base" field.
  4596. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4597. m.openai_base = &s
  4598. }
  4599. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4600. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4601. v := m.openai_base
  4602. if v == nil {
  4603. return
  4604. }
  4605. return *v, true
  4606. }
  4607. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4608. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4610. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4611. if !m.op.Is(OpUpdateOne) {
  4612. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4613. }
  4614. if m.id == nil || m.oldValue == nil {
  4615. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4616. }
  4617. oldValue, err := m.oldValue(ctx)
  4618. if err != nil {
  4619. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4620. }
  4621. return oldValue.OpenaiBase, nil
  4622. }
  4623. // ClearOpenaiBase clears the value of the "openai_base" field.
  4624. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4625. m.openai_base = nil
  4626. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4627. }
  4628. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4629. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4630. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4631. return ok
  4632. }
  4633. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4634. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4635. m.openai_base = nil
  4636. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4637. }
  4638. // SetOpenaiKey sets the "openai_key" field.
  4639. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4640. m.openai_key = &s
  4641. }
  4642. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4643. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4644. v := m.openai_key
  4645. if v == nil {
  4646. return
  4647. }
  4648. return *v, true
  4649. }
  4650. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4651. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4653. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4654. if !m.op.Is(OpUpdateOne) {
  4655. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4656. }
  4657. if m.id == nil || m.oldValue == nil {
  4658. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4659. }
  4660. oldValue, err := m.oldValue(ctx)
  4661. if err != nil {
  4662. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4663. }
  4664. return oldValue.OpenaiKey, nil
  4665. }
  4666. // ClearOpenaiKey clears the value of the "openai_key" field.
  4667. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4668. m.openai_key = nil
  4669. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4670. }
  4671. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4672. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4673. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4674. return ok
  4675. }
  4676. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4677. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4678. m.openai_key = nil
  4679. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4680. }
  4681. // ClearAgent clears the "agent" edge to the Agent entity.
  4682. func (m *ApiKeyMutation) ClearAgent() {
  4683. m.clearedagent = true
  4684. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4685. }
  4686. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4687. func (m *ApiKeyMutation) AgentCleared() bool {
  4688. return m.clearedagent
  4689. }
  4690. // AgentIDs returns the "agent" edge IDs in the mutation.
  4691. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4692. // AgentID instead. It exists only for internal usage by the builders.
  4693. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4694. if id := m.agent; id != nil {
  4695. ids = append(ids, *id)
  4696. }
  4697. return
  4698. }
  4699. // ResetAgent resets all changes to the "agent" edge.
  4700. func (m *ApiKeyMutation) ResetAgent() {
  4701. m.agent = nil
  4702. m.clearedagent = false
  4703. }
  4704. // Where appends a list predicates to the ApiKeyMutation builder.
  4705. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4706. m.predicates = append(m.predicates, ps...)
  4707. }
  4708. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4709. // users can use type-assertion to append predicates that do not depend on any generated package.
  4710. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4711. p := make([]predicate.ApiKey, len(ps))
  4712. for i := range ps {
  4713. p[i] = ps[i]
  4714. }
  4715. m.Where(p...)
  4716. }
  4717. // Op returns the operation name.
  4718. func (m *ApiKeyMutation) Op() Op {
  4719. return m.op
  4720. }
  4721. // SetOp allows setting the mutation operation.
  4722. func (m *ApiKeyMutation) SetOp(op Op) {
  4723. m.op = op
  4724. }
  4725. // Type returns the node type of this mutation (ApiKey).
  4726. func (m *ApiKeyMutation) Type() string {
  4727. return m.typ
  4728. }
  4729. // Fields returns all fields that were changed during this mutation. Note that in
  4730. // order to get all numeric fields that were incremented/decremented, call
  4731. // AddedFields().
  4732. func (m *ApiKeyMutation) Fields() []string {
  4733. fields := make([]string, 0, 11)
  4734. if m.created_at != nil {
  4735. fields = append(fields, apikey.FieldCreatedAt)
  4736. }
  4737. if m.updated_at != nil {
  4738. fields = append(fields, apikey.FieldUpdatedAt)
  4739. }
  4740. if m.deleted_at != nil {
  4741. fields = append(fields, apikey.FieldDeletedAt)
  4742. }
  4743. if m.title != nil {
  4744. fields = append(fields, apikey.FieldTitle)
  4745. }
  4746. if m.key != nil {
  4747. fields = append(fields, apikey.FieldKey)
  4748. }
  4749. if m.organization_id != nil {
  4750. fields = append(fields, apikey.FieldOrganizationID)
  4751. }
  4752. if m.agent != nil {
  4753. fields = append(fields, apikey.FieldAgentID)
  4754. }
  4755. if m.custom_agent_base != nil {
  4756. fields = append(fields, apikey.FieldCustomAgentBase)
  4757. }
  4758. if m.custom_agent_key != nil {
  4759. fields = append(fields, apikey.FieldCustomAgentKey)
  4760. }
  4761. if m.openai_base != nil {
  4762. fields = append(fields, apikey.FieldOpenaiBase)
  4763. }
  4764. if m.openai_key != nil {
  4765. fields = append(fields, apikey.FieldOpenaiKey)
  4766. }
  4767. return fields
  4768. }
  4769. // Field returns the value of a field with the given name. The second boolean
  4770. // return value indicates that this field was not set, or was not defined in the
  4771. // schema.
  4772. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  4773. switch name {
  4774. case apikey.FieldCreatedAt:
  4775. return m.CreatedAt()
  4776. case apikey.FieldUpdatedAt:
  4777. return m.UpdatedAt()
  4778. case apikey.FieldDeletedAt:
  4779. return m.DeletedAt()
  4780. case apikey.FieldTitle:
  4781. return m.Title()
  4782. case apikey.FieldKey:
  4783. return m.Key()
  4784. case apikey.FieldOrganizationID:
  4785. return m.OrganizationID()
  4786. case apikey.FieldAgentID:
  4787. return m.AgentID()
  4788. case apikey.FieldCustomAgentBase:
  4789. return m.CustomAgentBase()
  4790. case apikey.FieldCustomAgentKey:
  4791. return m.CustomAgentKey()
  4792. case apikey.FieldOpenaiBase:
  4793. return m.OpenaiBase()
  4794. case apikey.FieldOpenaiKey:
  4795. return m.OpenaiKey()
  4796. }
  4797. return nil, false
  4798. }
  4799. // OldField returns the old value of the field from the database. An error is
  4800. // returned if the mutation operation is not UpdateOne, or the query to the
  4801. // database failed.
  4802. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4803. switch name {
  4804. case apikey.FieldCreatedAt:
  4805. return m.OldCreatedAt(ctx)
  4806. case apikey.FieldUpdatedAt:
  4807. return m.OldUpdatedAt(ctx)
  4808. case apikey.FieldDeletedAt:
  4809. return m.OldDeletedAt(ctx)
  4810. case apikey.FieldTitle:
  4811. return m.OldTitle(ctx)
  4812. case apikey.FieldKey:
  4813. return m.OldKey(ctx)
  4814. case apikey.FieldOrganizationID:
  4815. return m.OldOrganizationID(ctx)
  4816. case apikey.FieldAgentID:
  4817. return m.OldAgentID(ctx)
  4818. case apikey.FieldCustomAgentBase:
  4819. return m.OldCustomAgentBase(ctx)
  4820. case apikey.FieldCustomAgentKey:
  4821. return m.OldCustomAgentKey(ctx)
  4822. case apikey.FieldOpenaiBase:
  4823. return m.OldOpenaiBase(ctx)
  4824. case apikey.FieldOpenaiKey:
  4825. return m.OldOpenaiKey(ctx)
  4826. }
  4827. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  4828. }
  4829. // SetField sets the value of a field with the given name. It returns an error if
  4830. // the field is not defined in the schema, or if the type mismatched the field
  4831. // type.
  4832. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  4833. switch name {
  4834. case apikey.FieldCreatedAt:
  4835. v, ok := value.(time.Time)
  4836. if !ok {
  4837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4838. }
  4839. m.SetCreatedAt(v)
  4840. return nil
  4841. case apikey.FieldUpdatedAt:
  4842. v, ok := value.(time.Time)
  4843. if !ok {
  4844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4845. }
  4846. m.SetUpdatedAt(v)
  4847. return nil
  4848. case apikey.FieldDeletedAt:
  4849. v, ok := value.(time.Time)
  4850. if !ok {
  4851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4852. }
  4853. m.SetDeletedAt(v)
  4854. return nil
  4855. case apikey.FieldTitle:
  4856. v, ok := value.(string)
  4857. if !ok {
  4858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4859. }
  4860. m.SetTitle(v)
  4861. return nil
  4862. case apikey.FieldKey:
  4863. v, ok := value.(string)
  4864. if !ok {
  4865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4866. }
  4867. m.SetKey(v)
  4868. return nil
  4869. case apikey.FieldOrganizationID:
  4870. v, ok := value.(uint64)
  4871. if !ok {
  4872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4873. }
  4874. m.SetOrganizationID(v)
  4875. return nil
  4876. case apikey.FieldAgentID:
  4877. v, ok := value.(uint64)
  4878. if !ok {
  4879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4880. }
  4881. m.SetAgentID(v)
  4882. return nil
  4883. case apikey.FieldCustomAgentBase:
  4884. v, ok := value.(string)
  4885. if !ok {
  4886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4887. }
  4888. m.SetCustomAgentBase(v)
  4889. return nil
  4890. case apikey.FieldCustomAgentKey:
  4891. v, ok := value.(string)
  4892. if !ok {
  4893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4894. }
  4895. m.SetCustomAgentKey(v)
  4896. return nil
  4897. case apikey.FieldOpenaiBase:
  4898. v, ok := value.(string)
  4899. if !ok {
  4900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4901. }
  4902. m.SetOpenaiBase(v)
  4903. return nil
  4904. case apikey.FieldOpenaiKey:
  4905. v, ok := value.(string)
  4906. if !ok {
  4907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4908. }
  4909. m.SetOpenaiKey(v)
  4910. return nil
  4911. }
  4912. return fmt.Errorf("unknown ApiKey field %s", name)
  4913. }
  4914. // AddedFields returns all numeric fields that were incremented/decremented during
  4915. // this mutation.
  4916. func (m *ApiKeyMutation) AddedFields() []string {
  4917. var fields []string
  4918. if m.addorganization_id != nil {
  4919. fields = append(fields, apikey.FieldOrganizationID)
  4920. }
  4921. return fields
  4922. }
  4923. // AddedField returns the numeric value that was incremented/decremented on a field
  4924. // with the given name. The second boolean return value indicates that this field
  4925. // was not set, or was not defined in the schema.
  4926. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  4927. switch name {
  4928. case apikey.FieldOrganizationID:
  4929. return m.AddedOrganizationID()
  4930. }
  4931. return nil, false
  4932. }
  4933. // AddField adds the value to the field with the given name. It returns an error if
  4934. // the field is not defined in the schema, or if the type mismatched the field
  4935. // type.
  4936. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  4937. switch name {
  4938. case apikey.FieldOrganizationID:
  4939. v, ok := value.(int64)
  4940. if !ok {
  4941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4942. }
  4943. m.AddOrganizationID(v)
  4944. return nil
  4945. }
  4946. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  4947. }
  4948. // ClearedFields returns all nullable fields that were cleared during this
  4949. // mutation.
  4950. func (m *ApiKeyMutation) ClearedFields() []string {
  4951. var fields []string
  4952. if m.FieldCleared(apikey.FieldDeletedAt) {
  4953. fields = append(fields, apikey.FieldDeletedAt)
  4954. }
  4955. if m.FieldCleared(apikey.FieldTitle) {
  4956. fields = append(fields, apikey.FieldTitle)
  4957. }
  4958. if m.FieldCleared(apikey.FieldKey) {
  4959. fields = append(fields, apikey.FieldKey)
  4960. }
  4961. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  4962. fields = append(fields, apikey.FieldCustomAgentBase)
  4963. }
  4964. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  4965. fields = append(fields, apikey.FieldCustomAgentKey)
  4966. }
  4967. if m.FieldCleared(apikey.FieldOpenaiBase) {
  4968. fields = append(fields, apikey.FieldOpenaiBase)
  4969. }
  4970. if m.FieldCleared(apikey.FieldOpenaiKey) {
  4971. fields = append(fields, apikey.FieldOpenaiKey)
  4972. }
  4973. return fields
  4974. }
  4975. // FieldCleared returns a boolean indicating if a field with the given name was
  4976. // cleared in this mutation.
  4977. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  4978. _, ok := m.clearedFields[name]
  4979. return ok
  4980. }
  4981. // ClearField clears the value of the field with the given name. It returns an
  4982. // error if the field is not defined in the schema.
  4983. func (m *ApiKeyMutation) ClearField(name string) error {
  4984. switch name {
  4985. case apikey.FieldDeletedAt:
  4986. m.ClearDeletedAt()
  4987. return nil
  4988. case apikey.FieldTitle:
  4989. m.ClearTitle()
  4990. return nil
  4991. case apikey.FieldKey:
  4992. m.ClearKey()
  4993. return nil
  4994. case apikey.FieldCustomAgentBase:
  4995. m.ClearCustomAgentBase()
  4996. return nil
  4997. case apikey.FieldCustomAgentKey:
  4998. m.ClearCustomAgentKey()
  4999. return nil
  5000. case apikey.FieldOpenaiBase:
  5001. m.ClearOpenaiBase()
  5002. return nil
  5003. case apikey.FieldOpenaiKey:
  5004. m.ClearOpenaiKey()
  5005. return nil
  5006. }
  5007. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5008. }
  5009. // ResetField resets all changes in the mutation for the field with the given name.
  5010. // It returns an error if the field is not defined in the schema.
  5011. func (m *ApiKeyMutation) ResetField(name string) error {
  5012. switch name {
  5013. case apikey.FieldCreatedAt:
  5014. m.ResetCreatedAt()
  5015. return nil
  5016. case apikey.FieldUpdatedAt:
  5017. m.ResetUpdatedAt()
  5018. return nil
  5019. case apikey.FieldDeletedAt:
  5020. m.ResetDeletedAt()
  5021. return nil
  5022. case apikey.FieldTitle:
  5023. m.ResetTitle()
  5024. return nil
  5025. case apikey.FieldKey:
  5026. m.ResetKey()
  5027. return nil
  5028. case apikey.FieldOrganizationID:
  5029. m.ResetOrganizationID()
  5030. return nil
  5031. case apikey.FieldAgentID:
  5032. m.ResetAgentID()
  5033. return nil
  5034. case apikey.FieldCustomAgentBase:
  5035. m.ResetCustomAgentBase()
  5036. return nil
  5037. case apikey.FieldCustomAgentKey:
  5038. m.ResetCustomAgentKey()
  5039. return nil
  5040. case apikey.FieldOpenaiBase:
  5041. m.ResetOpenaiBase()
  5042. return nil
  5043. case apikey.FieldOpenaiKey:
  5044. m.ResetOpenaiKey()
  5045. return nil
  5046. }
  5047. return fmt.Errorf("unknown ApiKey field %s", name)
  5048. }
  5049. // AddedEdges returns all edge names that were set/added in this mutation.
  5050. func (m *ApiKeyMutation) AddedEdges() []string {
  5051. edges := make([]string, 0, 1)
  5052. if m.agent != nil {
  5053. edges = append(edges, apikey.EdgeAgent)
  5054. }
  5055. return edges
  5056. }
  5057. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5058. // name in this mutation.
  5059. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5060. switch name {
  5061. case apikey.EdgeAgent:
  5062. if id := m.agent; id != nil {
  5063. return []ent.Value{*id}
  5064. }
  5065. }
  5066. return nil
  5067. }
  5068. // RemovedEdges returns all edge names that were removed in this mutation.
  5069. func (m *ApiKeyMutation) RemovedEdges() []string {
  5070. edges := make([]string, 0, 1)
  5071. return edges
  5072. }
  5073. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5074. // the given name in this mutation.
  5075. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5076. return nil
  5077. }
  5078. // ClearedEdges returns all edge names that were cleared in this mutation.
  5079. func (m *ApiKeyMutation) ClearedEdges() []string {
  5080. edges := make([]string, 0, 1)
  5081. if m.clearedagent {
  5082. edges = append(edges, apikey.EdgeAgent)
  5083. }
  5084. return edges
  5085. }
  5086. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5087. // was cleared in this mutation.
  5088. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5089. switch name {
  5090. case apikey.EdgeAgent:
  5091. return m.clearedagent
  5092. }
  5093. return false
  5094. }
  5095. // ClearEdge clears the value of the edge with the given name. It returns an error
  5096. // if that edge is not defined in the schema.
  5097. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5098. switch name {
  5099. case apikey.EdgeAgent:
  5100. m.ClearAgent()
  5101. return nil
  5102. }
  5103. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5104. }
  5105. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5106. // It returns an error if the edge is not defined in the schema.
  5107. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5108. switch name {
  5109. case apikey.EdgeAgent:
  5110. m.ResetAgent()
  5111. return nil
  5112. }
  5113. return fmt.Errorf("unknown ApiKey edge %s", name)
  5114. }
  5115. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5116. type BatchMsgMutation struct {
  5117. config
  5118. op Op
  5119. typ string
  5120. id *uint64
  5121. created_at *time.Time
  5122. updated_at *time.Time
  5123. deleted_at *time.Time
  5124. status *uint8
  5125. addstatus *int8
  5126. batch_no *string
  5127. task_name *string
  5128. fromwxid *string
  5129. msg *string
  5130. tag *string
  5131. tagids *string
  5132. total *int32
  5133. addtotal *int32
  5134. success *int32
  5135. addsuccess *int32
  5136. fail *int32
  5137. addfail *int32
  5138. start_time *time.Time
  5139. stop_time *time.Time
  5140. send_time *time.Time
  5141. _type *int32
  5142. add_type *int32
  5143. organization_id *uint64
  5144. addorganization_id *int64
  5145. ctype *uint64
  5146. addctype *int64
  5147. cc *string
  5148. phone *string
  5149. template_name *string
  5150. template_code *string
  5151. lang *string
  5152. clearedFields map[string]struct{}
  5153. done bool
  5154. oldValue func(context.Context) (*BatchMsg, error)
  5155. predicates []predicate.BatchMsg
  5156. }
  5157. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5158. // batchmsgOption allows management of the mutation configuration using functional options.
  5159. type batchmsgOption func(*BatchMsgMutation)
  5160. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5161. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5162. m := &BatchMsgMutation{
  5163. config: c,
  5164. op: op,
  5165. typ: TypeBatchMsg,
  5166. clearedFields: make(map[string]struct{}),
  5167. }
  5168. for _, opt := range opts {
  5169. opt(m)
  5170. }
  5171. return m
  5172. }
  5173. // withBatchMsgID sets the ID field of the mutation.
  5174. func withBatchMsgID(id uint64) batchmsgOption {
  5175. return func(m *BatchMsgMutation) {
  5176. var (
  5177. err error
  5178. once sync.Once
  5179. value *BatchMsg
  5180. )
  5181. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5182. once.Do(func() {
  5183. if m.done {
  5184. err = errors.New("querying old values post mutation is not allowed")
  5185. } else {
  5186. value, err = m.Client().BatchMsg.Get(ctx, id)
  5187. }
  5188. })
  5189. return value, err
  5190. }
  5191. m.id = &id
  5192. }
  5193. }
  5194. // withBatchMsg sets the old BatchMsg of the mutation.
  5195. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5196. return func(m *BatchMsgMutation) {
  5197. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5198. return node, nil
  5199. }
  5200. m.id = &node.ID
  5201. }
  5202. }
  5203. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5204. // executed in a transaction (ent.Tx), a transactional client is returned.
  5205. func (m BatchMsgMutation) Client() *Client {
  5206. client := &Client{config: m.config}
  5207. client.init()
  5208. return client
  5209. }
  5210. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5211. // it returns an error otherwise.
  5212. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5213. if _, ok := m.driver.(*txDriver); !ok {
  5214. return nil, errors.New("ent: mutation is not running in a transaction")
  5215. }
  5216. tx := &Tx{config: m.config}
  5217. tx.init()
  5218. return tx, nil
  5219. }
  5220. // SetID sets the value of the id field. Note that this
  5221. // operation is only accepted on creation of BatchMsg entities.
  5222. func (m *BatchMsgMutation) SetID(id uint64) {
  5223. m.id = &id
  5224. }
  5225. // ID returns the ID value in the mutation. Note that the ID is only available
  5226. // if it was provided to the builder or after it was returned from the database.
  5227. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5228. if m.id == nil {
  5229. return
  5230. }
  5231. return *m.id, true
  5232. }
  5233. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5234. // That means, if the mutation is applied within a transaction with an isolation level such
  5235. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5236. // or updated by the mutation.
  5237. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5238. switch {
  5239. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5240. id, exists := m.ID()
  5241. if exists {
  5242. return []uint64{id}, nil
  5243. }
  5244. fallthrough
  5245. case m.op.Is(OpUpdate | OpDelete):
  5246. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5247. default:
  5248. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5249. }
  5250. }
  5251. // SetCreatedAt sets the "created_at" field.
  5252. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5253. m.created_at = &t
  5254. }
  5255. // CreatedAt returns the value of the "created_at" field in the mutation.
  5256. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5257. v := m.created_at
  5258. if v == nil {
  5259. return
  5260. }
  5261. return *v, true
  5262. }
  5263. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5264. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5266. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5267. if !m.op.Is(OpUpdateOne) {
  5268. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5269. }
  5270. if m.id == nil || m.oldValue == nil {
  5271. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5272. }
  5273. oldValue, err := m.oldValue(ctx)
  5274. if err != nil {
  5275. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5276. }
  5277. return oldValue.CreatedAt, nil
  5278. }
  5279. // ResetCreatedAt resets all changes to the "created_at" field.
  5280. func (m *BatchMsgMutation) ResetCreatedAt() {
  5281. m.created_at = nil
  5282. }
  5283. // SetUpdatedAt sets the "updated_at" field.
  5284. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5285. m.updated_at = &t
  5286. }
  5287. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5288. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5289. v := m.updated_at
  5290. if v == nil {
  5291. return
  5292. }
  5293. return *v, true
  5294. }
  5295. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5296. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5298. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5299. if !m.op.Is(OpUpdateOne) {
  5300. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5301. }
  5302. if m.id == nil || m.oldValue == nil {
  5303. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5304. }
  5305. oldValue, err := m.oldValue(ctx)
  5306. if err != nil {
  5307. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5308. }
  5309. return oldValue.UpdatedAt, nil
  5310. }
  5311. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5312. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5313. m.updated_at = nil
  5314. }
  5315. // SetDeletedAt sets the "deleted_at" field.
  5316. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5317. m.deleted_at = &t
  5318. }
  5319. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5320. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5321. v := m.deleted_at
  5322. if v == nil {
  5323. return
  5324. }
  5325. return *v, true
  5326. }
  5327. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5328. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5330. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5331. if !m.op.Is(OpUpdateOne) {
  5332. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5333. }
  5334. if m.id == nil || m.oldValue == nil {
  5335. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5336. }
  5337. oldValue, err := m.oldValue(ctx)
  5338. if err != nil {
  5339. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5340. }
  5341. return oldValue.DeletedAt, nil
  5342. }
  5343. // ClearDeletedAt clears the value of the "deleted_at" field.
  5344. func (m *BatchMsgMutation) ClearDeletedAt() {
  5345. m.deleted_at = nil
  5346. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5347. }
  5348. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5349. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5350. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5351. return ok
  5352. }
  5353. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5354. func (m *BatchMsgMutation) ResetDeletedAt() {
  5355. m.deleted_at = nil
  5356. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5357. }
  5358. // SetStatus sets the "status" field.
  5359. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5360. m.status = &u
  5361. m.addstatus = nil
  5362. }
  5363. // Status returns the value of the "status" field in the mutation.
  5364. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5365. v := m.status
  5366. if v == nil {
  5367. return
  5368. }
  5369. return *v, true
  5370. }
  5371. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5372. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5374. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5375. if !m.op.Is(OpUpdateOne) {
  5376. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5377. }
  5378. if m.id == nil || m.oldValue == nil {
  5379. return v, errors.New("OldStatus requires an ID field in the mutation")
  5380. }
  5381. oldValue, err := m.oldValue(ctx)
  5382. if err != nil {
  5383. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5384. }
  5385. return oldValue.Status, nil
  5386. }
  5387. // AddStatus adds u to the "status" field.
  5388. func (m *BatchMsgMutation) AddStatus(u int8) {
  5389. if m.addstatus != nil {
  5390. *m.addstatus += u
  5391. } else {
  5392. m.addstatus = &u
  5393. }
  5394. }
  5395. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5396. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5397. v := m.addstatus
  5398. if v == nil {
  5399. return
  5400. }
  5401. return *v, true
  5402. }
  5403. // ClearStatus clears the value of the "status" field.
  5404. func (m *BatchMsgMutation) ClearStatus() {
  5405. m.status = nil
  5406. m.addstatus = nil
  5407. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5408. }
  5409. // StatusCleared returns if the "status" field was cleared in this mutation.
  5410. func (m *BatchMsgMutation) StatusCleared() bool {
  5411. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5412. return ok
  5413. }
  5414. // ResetStatus resets all changes to the "status" field.
  5415. func (m *BatchMsgMutation) ResetStatus() {
  5416. m.status = nil
  5417. m.addstatus = nil
  5418. delete(m.clearedFields, batchmsg.FieldStatus)
  5419. }
  5420. // SetBatchNo sets the "batch_no" field.
  5421. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5422. m.batch_no = &s
  5423. }
  5424. // BatchNo returns the value of the "batch_no" field in the mutation.
  5425. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5426. v := m.batch_no
  5427. if v == nil {
  5428. return
  5429. }
  5430. return *v, true
  5431. }
  5432. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5433. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5435. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5436. if !m.op.Is(OpUpdateOne) {
  5437. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5438. }
  5439. if m.id == nil || m.oldValue == nil {
  5440. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5441. }
  5442. oldValue, err := m.oldValue(ctx)
  5443. if err != nil {
  5444. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5445. }
  5446. return oldValue.BatchNo, nil
  5447. }
  5448. // ClearBatchNo clears the value of the "batch_no" field.
  5449. func (m *BatchMsgMutation) ClearBatchNo() {
  5450. m.batch_no = nil
  5451. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5452. }
  5453. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5454. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5455. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5456. return ok
  5457. }
  5458. // ResetBatchNo resets all changes to the "batch_no" field.
  5459. func (m *BatchMsgMutation) ResetBatchNo() {
  5460. m.batch_no = nil
  5461. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5462. }
  5463. // SetTaskName sets the "task_name" field.
  5464. func (m *BatchMsgMutation) SetTaskName(s string) {
  5465. m.task_name = &s
  5466. }
  5467. // TaskName returns the value of the "task_name" field in the mutation.
  5468. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5469. v := m.task_name
  5470. if v == nil {
  5471. return
  5472. }
  5473. return *v, true
  5474. }
  5475. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5476. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5478. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5479. if !m.op.Is(OpUpdateOne) {
  5480. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5481. }
  5482. if m.id == nil || m.oldValue == nil {
  5483. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5484. }
  5485. oldValue, err := m.oldValue(ctx)
  5486. if err != nil {
  5487. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5488. }
  5489. return oldValue.TaskName, nil
  5490. }
  5491. // ClearTaskName clears the value of the "task_name" field.
  5492. func (m *BatchMsgMutation) ClearTaskName() {
  5493. m.task_name = nil
  5494. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5495. }
  5496. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5497. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5498. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5499. return ok
  5500. }
  5501. // ResetTaskName resets all changes to the "task_name" field.
  5502. func (m *BatchMsgMutation) ResetTaskName() {
  5503. m.task_name = nil
  5504. delete(m.clearedFields, batchmsg.FieldTaskName)
  5505. }
  5506. // SetFromwxid sets the "fromwxid" field.
  5507. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5508. m.fromwxid = &s
  5509. }
  5510. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5511. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5512. v := m.fromwxid
  5513. if v == nil {
  5514. return
  5515. }
  5516. return *v, true
  5517. }
  5518. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5519. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5521. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5522. if !m.op.Is(OpUpdateOne) {
  5523. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5524. }
  5525. if m.id == nil || m.oldValue == nil {
  5526. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5527. }
  5528. oldValue, err := m.oldValue(ctx)
  5529. if err != nil {
  5530. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5531. }
  5532. return oldValue.Fromwxid, nil
  5533. }
  5534. // ClearFromwxid clears the value of the "fromwxid" field.
  5535. func (m *BatchMsgMutation) ClearFromwxid() {
  5536. m.fromwxid = nil
  5537. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5538. }
  5539. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5540. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5541. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5542. return ok
  5543. }
  5544. // ResetFromwxid resets all changes to the "fromwxid" field.
  5545. func (m *BatchMsgMutation) ResetFromwxid() {
  5546. m.fromwxid = nil
  5547. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5548. }
  5549. // SetMsg sets the "msg" field.
  5550. func (m *BatchMsgMutation) SetMsg(s string) {
  5551. m.msg = &s
  5552. }
  5553. // Msg returns the value of the "msg" field in the mutation.
  5554. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5555. v := m.msg
  5556. if v == nil {
  5557. return
  5558. }
  5559. return *v, true
  5560. }
  5561. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5562. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5564. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5565. if !m.op.Is(OpUpdateOne) {
  5566. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5567. }
  5568. if m.id == nil || m.oldValue == nil {
  5569. return v, errors.New("OldMsg requires an ID field in the mutation")
  5570. }
  5571. oldValue, err := m.oldValue(ctx)
  5572. if err != nil {
  5573. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5574. }
  5575. return oldValue.Msg, nil
  5576. }
  5577. // ClearMsg clears the value of the "msg" field.
  5578. func (m *BatchMsgMutation) ClearMsg() {
  5579. m.msg = nil
  5580. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5581. }
  5582. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5583. func (m *BatchMsgMutation) MsgCleared() bool {
  5584. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5585. return ok
  5586. }
  5587. // ResetMsg resets all changes to the "msg" field.
  5588. func (m *BatchMsgMutation) ResetMsg() {
  5589. m.msg = nil
  5590. delete(m.clearedFields, batchmsg.FieldMsg)
  5591. }
  5592. // SetTag sets the "tag" field.
  5593. func (m *BatchMsgMutation) SetTag(s string) {
  5594. m.tag = &s
  5595. }
  5596. // Tag returns the value of the "tag" field in the mutation.
  5597. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5598. v := m.tag
  5599. if v == nil {
  5600. return
  5601. }
  5602. return *v, true
  5603. }
  5604. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5605. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5607. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5608. if !m.op.Is(OpUpdateOne) {
  5609. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5610. }
  5611. if m.id == nil || m.oldValue == nil {
  5612. return v, errors.New("OldTag requires an ID field in the mutation")
  5613. }
  5614. oldValue, err := m.oldValue(ctx)
  5615. if err != nil {
  5616. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5617. }
  5618. return oldValue.Tag, nil
  5619. }
  5620. // ClearTag clears the value of the "tag" field.
  5621. func (m *BatchMsgMutation) ClearTag() {
  5622. m.tag = nil
  5623. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5624. }
  5625. // TagCleared returns if the "tag" field was cleared in this mutation.
  5626. func (m *BatchMsgMutation) TagCleared() bool {
  5627. _, ok := m.clearedFields[batchmsg.FieldTag]
  5628. return ok
  5629. }
  5630. // ResetTag resets all changes to the "tag" field.
  5631. func (m *BatchMsgMutation) ResetTag() {
  5632. m.tag = nil
  5633. delete(m.clearedFields, batchmsg.FieldTag)
  5634. }
  5635. // SetTagids sets the "tagids" field.
  5636. func (m *BatchMsgMutation) SetTagids(s string) {
  5637. m.tagids = &s
  5638. }
  5639. // Tagids returns the value of the "tagids" field in the mutation.
  5640. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5641. v := m.tagids
  5642. if v == nil {
  5643. return
  5644. }
  5645. return *v, true
  5646. }
  5647. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5648. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5650. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5651. if !m.op.Is(OpUpdateOne) {
  5652. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5653. }
  5654. if m.id == nil || m.oldValue == nil {
  5655. return v, errors.New("OldTagids requires an ID field in the mutation")
  5656. }
  5657. oldValue, err := m.oldValue(ctx)
  5658. if err != nil {
  5659. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5660. }
  5661. return oldValue.Tagids, nil
  5662. }
  5663. // ClearTagids clears the value of the "tagids" field.
  5664. func (m *BatchMsgMutation) ClearTagids() {
  5665. m.tagids = nil
  5666. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5667. }
  5668. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5669. func (m *BatchMsgMutation) TagidsCleared() bool {
  5670. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5671. return ok
  5672. }
  5673. // ResetTagids resets all changes to the "tagids" field.
  5674. func (m *BatchMsgMutation) ResetTagids() {
  5675. m.tagids = nil
  5676. delete(m.clearedFields, batchmsg.FieldTagids)
  5677. }
  5678. // SetTotal sets the "total" field.
  5679. func (m *BatchMsgMutation) SetTotal(i int32) {
  5680. m.total = &i
  5681. m.addtotal = nil
  5682. }
  5683. // Total returns the value of the "total" field in the mutation.
  5684. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5685. v := m.total
  5686. if v == nil {
  5687. return
  5688. }
  5689. return *v, true
  5690. }
  5691. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5692. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5694. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5695. if !m.op.Is(OpUpdateOne) {
  5696. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5697. }
  5698. if m.id == nil || m.oldValue == nil {
  5699. return v, errors.New("OldTotal requires an ID field in the mutation")
  5700. }
  5701. oldValue, err := m.oldValue(ctx)
  5702. if err != nil {
  5703. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5704. }
  5705. return oldValue.Total, nil
  5706. }
  5707. // AddTotal adds i to the "total" field.
  5708. func (m *BatchMsgMutation) AddTotal(i int32) {
  5709. if m.addtotal != nil {
  5710. *m.addtotal += i
  5711. } else {
  5712. m.addtotal = &i
  5713. }
  5714. }
  5715. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5716. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5717. v := m.addtotal
  5718. if v == nil {
  5719. return
  5720. }
  5721. return *v, true
  5722. }
  5723. // ClearTotal clears the value of the "total" field.
  5724. func (m *BatchMsgMutation) ClearTotal() {
  5725. m.total = nil
  5726. m.addtotal = nil
  5727. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5728. }
  5729. // TotalCleared returns if the "total" field was cleared in this mutation.
  5730. func (m *BatchMsgMutation) TotalCleared() bool {
  5731. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5732. return ok
  5733. }
  5734. // ResetTotal resets all changes to the "total" field.
  5735. func (m *BatchMsgMutation) ResetTotal() {
  5736. m.total = nil
  5737. m.addtotal = nil
  5738. delete(m.clearedFields, batchmsg.FieldTotal)
  5739. }
  5740. // SetSuccess sets the "success" field.
  5741. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5742. m.success = &i
  5743. m.addsuccess = nil
  5744. }
  5745. // Success returns the value of the "success" field in the mutation.
  5746. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5747. v := m.success
  5748. if v == nil {
  5749. return
  5750. }
  5751. return *v, true
  5752. }
  5753. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5754. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5756. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  5757. if !m.op.Is(OpUpdateOne) {
  5758. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  5759. }
  5760. if m.id == nil || m.oldValue == nil {
  5761. return v, errors.New("OldSuccess requires an ID field in the mutation")
  5762. }
  5763. oldValue, err := m.oldValue(ctx)
  5764. if err != nil {
  5765. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  5766. }
  5767. return oldValue.Success, nil
  5768. }
  5769. // AddSuccess adds i to the "success" field.
  5770. func (m *BatchMsgMutation) AddSuccess(i int32) {
  5771. if m.addsuccess != nil {
  5772. *m.addsuccess += i
  5773. } else {
  5774. m.addsuccess = &i
  5775. }
  5776. }
  5777. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  5778. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  5779. v := m.addsuccess
  5780. if v == nil {
  5781. return
  5782. }
  5783. return *v, true
  5784. }
  5785. // ClearSuccess clears the value of the "success" field.
  5786. func (m *BatchMsgMutation) ClearSuccess() {
  5787. m.success = nil
  5788. m.addsuccess = nil
  5789. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  5790. }
  5791. // SuccessCleared returns if the "success" field was cleared in this mutation.
  5792. func (m *BatchMsgMutation) SuccessCleared() bool {
  5793. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  5794. return ok
  5795. }
  5796. // ResetSuccess resets all changes to the "success" field.
  5797. func (m *BatchMsgMutation) ResetSuccess() {
  5798. m.success = nil
  5799. m.addsuccess = nil
  5800. delete(m.clearedFields, batchmsg.FieldSuccess)
  5801. }
  5802. // SetFail sets the "fail" field.
  5803. func (m *BatchMsgMutation) SetFail(i int32) {
  5804. m.fail = &i
  5805. m.addfail = nil
  5806. }
  5807. // Fail returns the value of the "fail" field in the mutation.
  5808. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  5809. v := m.fail
  5810. if v == nil {
  5811. return
  5812. }
  5813. return *v, true
  5814. }
  5815. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  5816. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5818. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  5819. if !m.op.Is(OpUpdateOne) {
  5820. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  5821. }
  5822. if m.id == nil || m.oldValue == nil {
  5823. return v, errors.New("OldFail requires an ID field in the mutation")
  5824. }
  5825. oldValue, err := m.oldValue(ctx)
  5826. if err != nil {
  5827. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  5828. }
  5829. return oldValue.Fail, nil
  5830. }
  5831. // AddFail adds i to the "fail" field.
  5832. func (m *BatchMsgMutation) AddFail(i int32) {
  5833. if m.addfail != nil {
  5834. *m.addfail += i
  5835. } else {
  5836. m.addfail = &i
  5837. }
  5838. }
  5839. // AddedFail returns the value that was added to the "fail" field in this mutation.
  5840. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  5841. v := m.addfail
  5842. if v == nil {
  5843. return
  5844. }
  5845. return *v, true
  5846. }
  5847. // ClearFail clears the value of the "fail" field.
  5848. func (m *BatchMsgMutation) ClearFail() {
  5849. m.fail = nil
  5850. m.addfail = nil
  5851. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  5852. }
  5853. // FailCleared returns if the "fail" field was cleared in this mutation.
  5854. func (m *BatchMsgMutation) FailCleared() bool {
  5855. _, ok := m.clearedFields[batchmsg.FieldFail]
  5856. return ok
  5857. }
  5858. // ResetFail resets all changes to the "fail" field.
  5859. func (m *BatchMsgMutation) ResetFail() {
  5860. m.fail = nil
  5861. m.addfail = nil
  5862. delete(m.clearedFields, batchmsg.FieldFail)
  5863. }
  5864. // SetStartTime sets the "start_time" field.
  5865. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  5866. m.start_time = &t
  5867. }
  5868. // StartTime returns the value of the "start_time" field in the mutation.
  5869. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  5870. v := m.start_time
  5871. if v == nil {
  5872. return
  5873. }
  5874. return *v, true
  5875. }
  5876. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  5877. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5879. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  5880. if !m.op.Is(OpUpdateOne) {
  5881. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  5882. }
  5883. if m.id == nil || m.oldValue == nil {
  5884. return v, errors.New("OldStartTime requires an ID field in the mutation")
  5885. }
  5886. oldValue, err := m.oldValue(ctx)
  5887. if err != nil {
  5888. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  5889. }
  5890. return oldValue.StartTime, nil
  5891. }
  5892. // ClearStartTime clears the value of the "start_time" field.
  5893. func (m *BatchMsgMutation) ClearStartTime() {
  5894. m.start_time = nil
  5895. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  5896. }
  5897. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  5898. func (m *BatchMsgMutation) StartTimeCleared() bool {
  5899. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  5900. return ok
  5901. }
  5902. // ResetStartTime resets all changes to the "start_time" field.
  5903. func (m *BatchMsgMutation) ResetStartTime() {
  5904. m.start_time = nil
  5905. delete(m.clearedFields, batchmsg.FieldStartTime)
  5906. }
  5907. // SetStopTime sets the "stop_time" field.
  5908. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  5909. m.stop_time = &t
  5910. }
  5911. // StopTime returns the value of the "stop_time" field in the mutation.
  5912. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  5913. v := m.stop_time
  5914. if v == nil {
  5915. return
  5916. }
  5917. return *v, true
  5918. }
  5919. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  5920. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5922. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  5923. if !m.op.Is(OpUpdateOne) {
  5924. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  5925. }
  5926. if m.id == nil || m.oldValue == nil {
  5927. return v, errors.New("OldStopTime requires an ID field in the mutation")
  5928. }
  5929. oldValue, err := m.oldValue(ctx)
  5930. if err != nil {
  5931. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  5932. }
  5933. return oldValue.StopTime, nil
  5934. }
  5935. // ClearStopTime clears the value of the "stop_time" field.
  5936. func (m *BatchMsgMutation) ClearStopTime() {
  5937. m.stop_time = nil
  5938. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  5939. }
  5940. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  5941. func (m *BatchMsgMutation) StopTimeCleared() bool {
  5942. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  5943. return ok
  5944. }
  5945. // ResetStopTime resets all changes to the "stop_time" field.
  5946. func (m *BatchMsgMutation) ResetStopTime() {
  5947. m.stop_time = nil
  5948. delete(m.clearedFields, batchmsg.FieldStopTime)
  5949. }
  5950. // SetSendTime sets the "send_time" field.
  5951. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  5952. m.send_time = &t
  5953. }
  5954. // SendTime returns the value of the "send_time" field in the mutation.
  5955. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  5956. v := m.send_time
  5957. if v == nil {
  5958. return
  5959. }
  5960. return *v, true
  5961. }
  5962. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  5963. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5965. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  5966. if !m.op.Is(OpUpdateOne) {
  5967. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  5968. }
  5969. if m.id == nil || m.oldValue == nil {
  5970. return v, errors.New("OldSendTime requires an ID field in the mutation")
  5971. }
  5972. oldValue, err := m.oldValue(ctx)
  5973. if err != nil {
  5974. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  5975. }
  5976. return oldValue.SendTime, nil
  5977. }
  5978. // ClearSendTime clears the value of the "send_time" field.
  5979. func (m *BatchMsgMutation) ClearSendTime() {
  5980. m.send_time = nil
  5981. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  5982. }
  5983. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  5984. func (m *BatchMsgMutation) SendTimeCleared() bool {
  5985. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  5986. return ok
  5987. }
  5988. // ResetSendTime resets all changes to the "send_time" field.
  5989. func (m *BatchMsgMutation) ResetSendTime() {
  5990. m.send_time = nil
  5991. delete(m.clearedFields, batchmsg.FieldSendTime)
  5992. }
  5993. // SetType sets the "type" field.
  5994. func (m *BatchMsgMutation) SetType(i int32) {
  5995. m._type = &i
  5996. m.add_type = nil
  5997. }
  5998. // GetType returns the value of the "type" field in the mutation.
  5999. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6000. v := m._type
  6001. if v == nil {
  6002. return
  6003. }
  6004. return *v, true
  6005. }
  6006. // OldType returns the old "type" field's value of the BatchMsg entity.
  6007. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6009. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6010. if !m.op.Is(OpUpdateOne) {
  6011. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6012. }
  6013. if m.id == nil || m.oldValue == nil {
  6014. return v, errors.New("OldType requires an ID field in the mutation")
  6015. }
  6016. oldValue, err := m.oldValue(ctx)
  6017. if err != nil {
  6018. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6019. }
  6020. return oldValue.Type, nil
  6021. }
  6022. // AddType adds i to the "type" field.
  6023. func (m *BatchMsgMutation) AddType(i int32) {
  6024. if m.add_type != nil {
  6025. *m.add_type += i
  6026. } else {
  6027. m.add_type = &i
  6028. }
  6029. }
  6030. // AddedType returns the value that was added to the "type" field in this mutation.
  6031. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6032. v := m.add_type
  6033. if v == nil {
  6034. return
  6035. }
  6036. return *v, true
  6037. }
  6038. // ClearType clears the value of the "type" field.
  6039. func (m *BatchMsgMutation) ClearType() {
  6040. m._type = nil
  6041. m.add_type = nil
  6042. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6043. }
  6044. // TypeCleared returns if the "type" field was cleared in this mutation.
  6045. func (m *BatchMsgMutation) TypeCleared() bool {
  6046. _, ok := m.clearedFields[batchmsg.FieldType]
  6047. return ok
  6048. }
  6049. // ResetType resets all changes to the "type" field.
  6050. func (m *BatchMsgMutation) ResetType() {
  6051. m._type = nil
  6052. m.add_type = nil
  6053. delete(m.clearedFields, batchmsg.FieldType)
  6054. }
  6055. // SetOrganizationID sets the "organization_id" field.
  6056. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6057. m.organization_id = &u
  6058. m.addorganization_id = nil
  6059. }
  6060. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6061. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6062. v := m.organization_id
  6063. if v == nil {
  6064. return
  6065. }
  6066. return *v, true
  6067. }
  6068. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6069. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6071. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6072. if !m.op.Is(OpUpdateOne) {
  6073. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6074. }
  6075. if m.id == nil || m.oldValue == nil {
  6076. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6077. }
  6078. oldValue, err := m.oldValue(ctx)
  6079. if err != nil {
  6080. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6081. }
  6082. return oldValue.OrganizationID, nil
  6083. }
  6084. // AddOrganizationID adds u to the "organization_id" field.
  6085. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6086. if m.addorganization_id != nil {
  6087. *m.addorganization_id += u
  6088. } else {
  6089. m.addorganization_id = &u
  6090. }
  6091. }
  6092. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6093. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6094. v := m.addorganization_id
  6095. if v == nil {
  6096. return
  6097. }
  6098. return *v, true
  6099. }
  6100. // ResetOrganizationID resets all changes to the "organization_id" field.
  6101. func (m *BatchMsgMutation) ResetOrganizationID() {
  6102. m.organization_id = nil
  6103. m.addorganization_id = nil
  6104. }
  6105. // SetCtype sets the "ctype" field.
  6106. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6107. m.ctype = &u
  6108. m.addctype = nil
  6109. }
  6110. // Ctype returns the value of the "ctype" field in the mutation.
  6111. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6112. v := m.ctype
  6113. if v == nil {
  6114. return
  6115. }
  6116. return *v, true
  6117. }
  6118. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6119. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6121. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6122. if !m.op.Is(OpUpdateOne) {
  6123. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6124. }
  6125. if m.id == nil || m.oldValue == nil {
  6126. return v, errors.New("OldCtype requires an ID field in the mutation")
  6127. }
  6128. oldValue, err := m.oldValue(ctx)
  6129. if err != nil {
  6130. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6131. }
  6132. return oldValue.Ctype, nil
  6133. }
  6134. // AddCtype adds u to the "ctype" field.
  6135. func (m *BatchMsgMutation) AddCtype(u int64) {
  6136. if m.addctype != nil {
  6137. *m.addctype += u
  6138. } else {
  6139. m.addctype = &u
  6140. }
  6141. }
  6142. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6143. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6144. v := m.addctype
  6145. if v == nil {
  6146. return
  6147. }
  6148. return *v, true
  6149. }
  6150. // ResetCtype resets all changes to the "ctype" field.
  6151. func (m *BatchMsgMutation) ResetCtype() {
  6152. m.ctype = nil
  6153. m.addctype = nil
  6154. }
  6155. // SetCc sets the "cc" field.
  6156. func (m *BatchMsgMutation) SetCc(s string) {
  6157. m.cc = &s
  6158. }
  6159. // Cc returns the value of the "cc" field in the mutation.
  6160. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6161. v := m.cc
  6162. if v == nil {
  6163. return
  6164. }
  6165. return *v, true
  6166. }
  6167. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6168. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6170. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6171. if !m.op.Is(OpUpdateOne) {
  6172. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6173. }
  6174. if m.id == nil || m.oldValue == nil {
  6175. return v, errors.New("OldCc requires an ID field in the mutation")
  6176. }
  6177. oldValue, err := m.oldValue(ctx)
  6178. if err != nil {
  6179. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6180. }
  6181. return oldValue.Cc, nil
  6182. }
  6183. // ClearCc clears the value of the "cc" field.
  6184. func (m *BatchMsgMutation) ClearCc() {
  6185. m.cc = nil
  6186. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6187. }
  6188. // CcCleared returns if the "cc" field was cleared in this mutation.
  6189. func (m *BatchMsgMutation) CcCleared() bool {
  6190. _, ok := m.clearedFields[batchmsg.FieldCc]
  6191. return ok
  6192. }
  6193. // ResetCc resets all changes to the "cc" field.
  6194. func (m *BatchMsgMutation) ResetCc() {
  6195. m.cc = nil
  6196. delete(m.clearedFields, batchmsg.FieldCc)
  6197. }
  6198. // SetPhone sets the "phone" field.
  6199. func (m *BatchMsgMutation) SetPhone(s string) {
  6200. m.phone = &s
  6201. }
  6202. // Phone returns the value of the "phone" field in the mutation.
  6203. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6204. v := m.phone
  6205. if v == nil {
  6206. return
  6207. }
  6208. return *v, true
  6209. }
  6210. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6211. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6213. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6214. if !m.op.Is(OpUpdateOne) {
  6215. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6216. }
  6217. if m.id == nil || m.oldValue == nil {
  6218. return v, errors.New("OldPhone requires an ID field in the mutation")
  6219. }
  6220. oldValue, err := m.oldValue(ctx)
  6221. if err != nil {
  6222. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6223. }
  6224. return oldValue.Phone, nil
  6225. }
  6226. // ClearPhone clears the value of the "phone" field.
  6227. func (m *BatchMsgMutation) ClearPhone() {
  6228. m.phone = nil
  6229. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6230. }
  6231. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6232. func (m *BatchMsgMutation) PhoneCleared() bool {
  6233. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6234. return ok
  6235. }
  6236. // ResetPhone resets all changes to the "phone" field.
  6237. func (m *BatchMsgMutation) ResetPhone() {
  6238. m.phone = nil
  6239. delete(m.clearedFields, batchmsg.FieldPhone)
  6240. }
  6241. // SetTemplateName sets the "template_name" field.
  6242. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6243. m.template_name = &s
  6244. }
  6245. // TemplateName returns the value of the "template_name" field in the mutation.
  6246. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6247. v := m.template_name
  6248. if v == nil {
  6249. return
  6250. }
  6251. return *v, true
  6252. }
  6253. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6254. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6256. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6257. if !m.op.Is(OpUpdateOne) {
  6258. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6259. }
  6260. if m.id == nil || m.oldValue == nil {
  6261. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6262. }
  6263. oldValue, err := m.oldValue(ctx)
  6264. if err != nil {
  6265. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6266. }
  6267. return oldValue.TemplateName, nil
  6268. }
  6269. // ClearTemplateName clears the value of the "template_name" field.
  6270. func (m *BatchMsgMutation) ClearTemplateName() {
  6271. m.template_name = nil
  6272. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6273. }
  6274. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6275. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6276. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6277. return ok
  6278. }
  6279. // ResetTemplateName resets all changes to the "template_name" field.
  6280. func (m *BatchMsgMutation) ResetTemplateName() {
  6281. m.template_name = nil
  6282. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6283. }
  6284. // SetTemplateCode sets the "template_code" field.
  6285. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6286. m.template_code = &s
  6287. }
  6288. // TemplateCode returns the value of the "template_code" field in the mutation.
  6289. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6290. v := m.template_code
  6291. if v == nil {
  6292. return
  6293. }
  6294. return *v, true
  6295. }
  6296. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6297. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6299. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6300. if !m.op.Is(OpUpdateOne) {
  6301. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6302. }
  6303. if m.id == nil || m.oldValue == nil {
  6304. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6305. }
  6306. oldValue, err := m.oldValue(ctx)
  6307. if err != nil {
  6308. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6309. }
  6310. return oldValue.TemplateCode, nil
  6311. }
  6312. // ClearTemplateCode clears the value of the "template_code" field.
  6313. func (m *BatchMsgMutation) ClearTemplateCode() {
  6314. m.template_code = nil
  6315. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6316. }
  6317. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6318. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6319. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6320. return ok
  6321. }
  6322. // ResetTemplateCode resets all changes to the "template_code" field.
  6323. func (m *BatchMsgMutation) ResetTemplateCode() {
  6324. m.template_code = nil
  6325. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6326. }
  6327. // SetLang sets the "lang" field.
  6328. func (m *BatchMsgMutation) SetLang(s string) {
  6329. m.lang = &s
  6330. }
  6331. // Lang returns the value of the "lang" field in the mutation.
  6332. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6333. v := m.lang
  6334. if v == nil {
  6335. return
  6336. }
  6337. return *v, true
  6338. }
  6339. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6340. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6342. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6343. if !m.op.Is(OpUpdateOne) {
  6344. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6345. }
  6346. if m.id == nil || m.oldValue == nil {
  6347. return v, errors.New("OldLang requires an ID field in the mutation")
  6348. }
  6349. oldValue, err := m.oldValue(ctx)
  6350. if err != nil {
  6351. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6352. }
  6353. return oldValue.Lang, nil
  6354. }
  6355. // ClearLang clears the value of the "lang" field.
  6356. func (m *BatchMsgMutation) ClearLang() {
  6357. m.lang = nil
  6358. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6359. }
  6360. // LangCleared returns if the "lang" field was cleared in this mutation.
  6361. func (m *BatchMsgMutation) LangCleared() bool {
  6362. _, ok := m.clearedFields[batchmsg.FieldLang]
  6363. return ok
  6364. }
  6365. // ResetLang resets all changes to the "lang" field.
  6366. func (m *BatchMsgMutation) ResetLang() {
  6367. m.lang = nil
  6368. delete(m.clearedFields, batchmsg.FieldLang)
  6369. }
  6370. // Where appends a list predicates to the BatchMsgMutation builder.
  6371. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6372. m.predicates = append(m.predicates, ps...)
  6373. }
  6374. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6375. // users can use type-assertion to append predicates that do not depend on any generated package.
  6376. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6377. p := make([]predicate.BatchMsg, len(ps))
  6378. for i := range ps {
  6379. p[i] = ps[i]
  6380. }
  6381. m.Where(p...)
  6382. }
  6383. // Op returns the operation name.
  6384. func (m *BatchMsgMutation) Op() Op {
  6385. return m.op
  6386. }
  6387. // SetOp allows setting the mutation operation.
  6388. func (m *BatchMsgMutation) SetOp(op Op) {
  6389. m.op = op
  6390. }
  6391. // Type returns the node type of this mutation (BatchMsg).
  6392. func (m *BatchMsgMutation) Type() string {
  6393. return m.typ
  6394. }
  6395. // Fields returns all fields that were changed during this mutation. Note that in
  6396. // order to get all numeric fields that were incremented/decremented, call
  6397. // AddedFields().
  6398. func (m *BatchMsgMutation) Fields() []string {
  6399. fields := make([]string, 0, 24)
  6400. if m.created_at != nil {
  6401. fields = append(fields, batchmsg.FieldCreatedAt)
  6402. }
  6403. if m.updated_at != nil {
  6404. fields = append(fields, batchmsg.FieldUpdatedAt)
  6405. }
  6406. if m.deleted_at != nil {
  6407. fields = append(fields, batchmsg.FieldDeletedAt)
  6408. }
  6409. if m.status != nil {
  6410. fields = append(fields, batchmsg.FieldStatus)
  6411. }
  6412. if m.batch_no != nil {
  6413. fields = append(fields, batchmsg.FieldBatchNo)
  6414. }
  6415. if m.task_name != nil {
  6416. fields = append(fields, batchmsg.FieldTaskName)
  6417. }
  6418. if m.fromwxid != nil {
  6419. fields = append(fields, batchmsg.FieldFromwxid)
  6420. }
  6421. if m.msg != nil {
  6422. fields = append(fields, batchmsg.FieldMsg)
  6423. }
  6424. if m.tag != nil {
  6425. fields = append(fields, batchmsg.FieldTag)
  6426. }
  6427. if m.tagids != nil {
  6428. fields = append(fields, batchmsg.FieldTagids)
  6429. }
  6430. if m.total != nil {
  6431. fields = append(fields, batchmsg.FieldTotal)
  6432. }
  6433. if m.success != nil {
  6434. fields = append(fields, batchmsg.FieldSuccess)
  6435. }
  6436. if m.fail != nil {
  6437. fields = append(fields, batchmsg.FieldFail)
  6438. }
  6439. if m.start_time != nil {
  6440. fields = append(fields, batchmsg.FieldStartTime)
  6441. }
  6442. if m.stop_time != nil {
  6443. fields = append(fields, batchmsg.FieldStopTime)
  6444. }
  6445. if m.send_time != nil {
  6446. fields = append(fields, batchmsg.FieldSendTime)
  6447. }
  6448. if m._type != nil {
  6449. fields = append(fields, batchmsg.FieldType)
  6450. }
  6451. if m.organization_id != nil {
  6452. fields = append(fields, batchmsg.FieldOrganizationID)
  6453. }
  6454. if m.ctype != nil {
  6455. fields = append(fields, batchmsg.FieldCtype)
  6456. }
  6457. if m.cc != nil {
  6458. fields = append(fields, batchmsg.FieldCc)
  6459. }
  6460. if m.phone != nil {
  6461. fields = append(fields, batchmsg.FieldPhone)
  6462. }
  6463. if m.template_name != nil {
  6464. fields = append(fields, batchmsg.FieldTemplateName)
  6465. }
  6466. if m.template_code != nil {
  6467. fields = append(fields, batchmsg.FieldTemplateCode)
  6468. }
  6469. if m.lang != nil {
  6470. fields = append(fields, batchmsg.FieldLang)
  6471. }
  6472. return fields
  6473. }
  6474. // Field returns the value of a field with the given name. The second boolean
  6475. // return value indicates that this field was not set, or was not defined in the
  6476. // schema.
  6477. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6478. switch name {
  6479. case batchmsg.FieldCreatedAt:
  6480. return m.CreatedAt()
  6481. case batchmsg.FieldUpdatedAt:
  6482. return m.UpdatedAt()
  6483. case batchmsg.FieldDeletedAt:
  6484. return m.DeletedAt()
  6485. case batchmsg.FieldStatus:
  6486. return m.Status()
  6487. case batchmsg.FieldBatchNo:
  6488. return m.BatchNo()
  6489. case batchmsg.FieldTaskName:
  6490. return m.TaskName()
  6491. case batchmsg.FieldFromwxid:
  6492. return m.Fromwxid()
  6493. case batchmsg.FieldMsg:
  6494. return m.Msg()
  6495. case batchmsg.FieldTag:
  6496. return m.Tag()
  6497. case batchmsg.FieldTagids:
  6498. return m.Tagids()
  6499. case batchmsg.FieldTotal:
  6500. return m.Total()
  6501. case batchmsg.FieldSuccess:
  6502. return m.Success()
  6503. case batchmsg.FieldFail:
  6504. return m.Fail()
  6505. case batchmsg.FieldStartTime:
  6506. return m.StartTime()
  6507. case batchmsg.FieldStopTime:
  6508. return m.StopTime()
  6509. case batchmsg.FieldSendTime:
  6510. return m.SendTime()
  6511. case batchmsg.FieldType:
  6512. return m.GetType()
  6513. case batchmsg.FieldOrganizationID:
  6514. return m.OrganizationID()
  6515. case batchmsg.FieldCtype:
  6516. return m.Ctype()
  6517. case batchmsg.FieldCc:
  6518. return m.Cc()
  6519. case batchmsg.FieldPhone:
  6520. return m.Phone()
  6521. case batchmsg.FieldTemplateName:
  6522. return m.TemplateName()
  6523. case batchmsg.FieldTemplateCode:
  6524. return m.TemplateCode()
  6525. case batchmsg.FieldLang:
  6526. return m.Lang()
  6527. }
  6528. return nil, false
  6529. }
  6530. // OldField returns the old value of the field from the database. An error is
  6531. // returned if the mutation operation is not UpdateOne, or the query to the
  6532. // database failed.
  6533. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6534. switch name {
  6535. case batchmsg.FieldCreatedAt:
  6536. return m.OldCreatedAt(ctx)
  6537. case batchmsg.FieldUpdatedAt:
  6538. return m.OldUpdatedAt(ctx)
  6539. case batchmsg.FieldDeletedAt:
  6540. return m.OldDeletedAt(ctx)
  6541. case batchmsg.FieldStatus:
  6542. return m.OldStatus(ctx)
  6543. case batchmsg.FieldBatchNo:
  6544. return m.OldBatchNo(ctx)
  6545. case batchmsg.FieldTaskName:
  6546. return m.OldTaskName(ctx)
  6547. case batchmsg.FieldFromwxid:
  6548. return m.OldFromwxid(ctx)
  6549. case batchmsg.FieldMsg:
  6550. return m.OldMsg(ctx)
  6551. case batchmsg.FieldTag:
  6552. return m.OldTag(ctx)
  6553. case batchmsg.FieldTagids:
  6554. return m.OldTagids(ctx)
  6555. case batchmsg.FieldTotal:
  6556. return m.OldTotal(ctx)
  6557. case batchmsg.FieldSuccess:
  6558. return m.OldSuccess(ctx)
  6559. case batchmsg.FieldFail:
  6560. return m.OldFail(ctx)
  6561. case batchmsg.FieldStartTime:
  6562. return m.OldStartTime(ctx)
  6563. case batchmsg.FieldStopTime:
  6564. return m.OldStopTime(ctx)
  6565. case batchmsg.FieldSendTime:
  6566. return m.OldSendTime(ctx)
  6567. case batchmsg.FieldType:
  6568. return m.OldType(ctx)
  6569. case batchmsg.FieldOrganizationID:
  6570. return m.OldOrganizationID(ctx)
  6571. case batchmsg.FieldCtype:
  6572. return m.OldCtype(ctx)
  6573. case batchmsg.FieldCc:
  6574. return m.OldCc(ctx)
  6575. case batchmsg.FieldPhone:
  6576. return m.OldPhone(ctx)
  6577. case batchmsg.FieldTemplateName:
  6578. return m.OldTemplateName(ctx)
  6579. case batchmsg.FieldTemplateCode:
  6580. return m.OldTemplateCode(ctx)
  6581. case batchmsg.FieldLang:
  6582. return m.OldLang(ctx)
  6583. }
  6584. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6585. }
  6586. // SetField sets the value of a field with the given name. It returns an error if
  6587. // the field is not defined in the schema, or if the type mismatched the field
  6588. // type.
  6589. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6590. switch name {
  6591. case batchmsg.FieldCreatedAt:
  6592. v, ok := value.(time.Time)
  6593. if !ok {
  6594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6595. }
  6596. m.SetCreatedAt(v)
  6597. return nil
  6598. case batchmsg.FieldUpdatedAt:
  6599. v, ok := value.(time.Time)
  6600. if !ok {
  6601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6602. }
  6603. m.SetUpdatedAt(v)
  6604. return nil
  6605. case batchmsg.FieldDeletedAt:
  6606. v, ok := value.(time.Time)
  6607. if !ok {
  6608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6609. }
  6610. m.SetDeletedAt(v)
  6611. return nil
  6612. case batchmsg.FieldStatus:
  6613. v, ok := value.(uint8)
  6614. if !ok {
  6615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6616. }
  6617. m.SetStatus(v)
  6618. return nil
  6619. case batchmsg.FieldBatchNo:
  6620. v, ok := value.(string)
  6621. if !ok {
  6622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6623. }
  6624. m.SetBatchNo(v)
  6625. return nil
  6626. case batchmsg.FieldTaskName:
  6627. v, ok := value.(string)
  6628. if !ok {
  6629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6630. }
  6631. m.SetTaskName(v)
  6632. return nil
  6633. case batchmsg.FieldFromwxid:
  6634. v, ok := value.(string)
  6635. if !ok {
  6636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6637. }
  6638. m.SetFromwxid(v)
  6639. return nil
  6640. case batchmsg.FieldMsg:
  6641. v, ok := value.(string)
  6642. if !ok {
  6643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6644. }
  6645. m.SetMsg(v)
  6646. return nil
  6647. case batchmsg.FieldTag:
  6648. v, ok := value.(string)
  6649. if !ok {
  6650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6651. }
  6652. m.SetTag(v)
  6653. return nil
  6654. case batchmsg.FieldTagids:
  6655. v, ok := value.(string)
  6656. if !ok {
  6657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6658. }
  6659. m.SetTagids(v)
  6660. return nil
  6661. case batchmsg.FieldTotal:
  6662. v, ok := value.(int32)
  6663. if !ok {
  6664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6665. }
  6666. m.SetTotal(v)
  6667. return nil
  6668. case batchmsg.FieldSuccess:
  6669. v, ok := value.(int32)
  6670. if !ok {
  6671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6672. }
  6673. m.SetSuccess(v)
  6674. return nil
  6675. case batchmsg.FieldFail:
  6676. v, ok := value.(int32)
  6677. if !ok {
  6678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6679. }
  6680. m.SetFail(v)
  6681. return nil
  6682. case batchmsg.FieldStartTime:
  6683. v, ok := value.(time.Time)
  6684. if !ok {
  6685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6686. }
  6687. m.SetStartTime(v)
  6688. return nil
  6689. case batchmsg.FieldStopTime:
  6690. v, ok := value.(time.Time)
  6691. if !ok {
  6692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6693. }
  6694. m.SetStopTime(v)
  6695. return nil
  6696. case batchmsg.FieldSendTime:
  6697. v, ok := value.(time.Time)
  6698. if !ok {
  6699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6700. }
  6701. m.SetSendTime(v)
  6702. return nil
  6703. case batchmsg.FieldType:
  6704. v, ok := value.(int32)
  6705. if !ok {
  6706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6707. }
  6708. m.SetType(v)
  6709. return nil
  6710. case batchmsg.FieldOrganizationID:
  6711. v, ok := value.(uint64)
  6712. if !ok {
  6713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6714. }
  6715. m.SetOrganizationID(v)
  6716. return nil
  6717. case batchmsg.FieldCtype:
  6718. v, ok := value.(uint64)
  6719. if !ok {
  6720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6721. }
  6722. m.SetCtype(v)
  6723. return nil
  6724. case batchmsg.FieldCc:
  6725. v, ok := value.(string)
  6726. if !ok {
  6727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6728. }
  6729. m.SetCc(v)
  6730. return nil
  6731. case batchmsg.FieldPhone:
  6732. v, ok := value.(string)
  6733. if !ok {
  6734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6735. }
  6736. m.SetPhone(v)
  6737. return nil
  6738. case batchmsg.FieldTemplateName:
  6739. v, ok := value.(string)
  6740. if !ok {
  6741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6742. }
  6743. m.SetTemplateName(v)
  6744. return nil
  6745. case batchmsg.FieldTemplateCode:
  6746. v, ok := value.(string)
  6747. if !ok {
  6748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6749. }
  6750. m.SetTemplateCode(v)
  6751. return nil
  6752. case batchmsg.FieldLang:
  6753. v, ok := value.(string)
  6754. if !ok {
  6755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6756. }
  6757. m.SetLang(v)
  6758. return nil
  6759. }
  6760. return fmt.Errorf("unknown BatchMsg field %s", name)
  6761. }
  6762. // AddedFields returns all numeric fields that were incremented/decremented during
  6763. // this mutation.
  6764. func (m *BatchMsgMutation) AddedFields() []string {
  6765. var fields []string
  6766. if m.addstatus != nil {
  6767. fields = append(fields, batchmsg.FieldStatus)
  6768. }
  6769. if m.addtotal != nil {
  6770. fields = append(fields, batchmsg.FieldTotal)
  6771. }
  6772. if m.addsuccess != nil {
  6773. fields = append(fields, batchmsg.FieldSuccess)
  6774. }
  6775. if m.addfail != nil {
  6776. fields = append(fields, batchmsg.FieldFail)
  6777. }
  6778. if m.add_type != nil {
  6779. fields = append(fields, batchmsg.FieldType)
  6780. }
  6781. if m.addorganization_id != nil {
  6782. fields = append(fields, batchmsg.FieldOrganizationID)
  6783. }
  6784. if m.addctype != nil {
  6785. fields = append(fields, batchmsg.FieldCtype)
  6786. }
  6787. return fields
  6788. }
  6789. // AddedField returns the numeric value that was incremented/decremented on a field
  6790. // with the given name. The second boolean return value indicates that this field
  6791. // was not set, or was not defined in the schema.
  6792. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  6793. switch name {
  6794. case batchmsg.FieldStatus:
  6795. return m.AddedStatus()
  6796. case batchmsg.FieldTotal:
  6797. return m.AddedTotal()
  6798. case batchmsg.FieldSuccess:
  6799. return m.AddedSuccess()
  6800. case batchmsg.FieldFail:
  6801. return m.AddedFail()
  6802. case batchmsg.FieldType:
  6803. return m.AddedType()
  6804. case batchmsg.FieldOrganizationID:
  6805. return m.AddedOrganizationID()
  6806. case batchmsg.FieldCtype:
  6807. return m.AddedCtype()
  6808. }
  6809. return nil, false
  6810. }
  6811. // AddField adds the value to the field with the given name. It returns an error if
  6812. // the field is not defined in the schema, or if the type mismatched the field
  6813. // type.
  6814. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  6815. switch name {
  6816. case batchmsg.FieldStatus:
  6817. v, ok := value.(int8)
  6818. if !ok {
  6819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6820. }
  6821. m.AddStatus(v)
  6822. return nil
  6823. case batchmsg.FieldTotal:
  6824. v, ok := value.(int32)
  6825. if !ok {
  6826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6827. }
  6828. m.AddTotal(v)
  6829. return nil
  6830. case batchmsg.FieldSuccess:
  6831. v, ok := value.(int32)
  6832. if !ok {
  6833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6834. }
  6835. m.AddSuccess(v)
  6836. return nil
  6837. case batchmsg.FieldFail:
  6838. v, ok := value.(int32)
  6839. if !ok {
  6840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6841. }
  6842. m.AddFail(v)
  6843. return nil
  6844. case batchmsg.FieldType:
  6845. v, ok := value.(int32)
  6846. if !ok {
  6847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6848. }
  6849. m.AddType(v)
  6850. return nil
  6851. case batchmsg.FieldOrganizationID:
  6852. v, ok := value.(int64)
  6853. if !ok {
  6854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6855. }
  6856. m.AddOrganizationID(v)
  6857. return nil
  6858. case batchmsg.FieldCtype:
  6859. v, ok := value.(int64)
  6860. if !ok {
  6861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6862. }
  6863. m.AddCtype(v)
  6864. return nil
  6865. }
  6866. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  6867. }
  6868. // ClearedFields returns all nullable fields that were cleared during this
  6869. // mutation.
  6870. func (m *BatchMsgMutation) ClearedFields() []string {
  6871. var fields []string
  6872. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  6873. fields = append(fields, batchmsg.FieldDeletedAt)
  6874. }
  6875. if m.FieldCleared(batchmsg.FieldStatus) {
  6876. fields = append(fields, batchmsg.FieldStatus)
  6877. }
  6878. if m.FieldCleared(batchmsg.FieldBatchNo) {
  6879. fields = append(fields, batchmsg.FieldBatchNo)
  6880. }
  6881. if m.FieldCleared(batchmsg.FieldTaskName) {
  6882. fields = append(fields, batchmsg.FieldTaskName)
  6883. }
  6884. if m.FieldCleared(batchmsg.FieldFromwxid) {
  6885. fields = append(fields, batchmsg.FieldFromwxid)
  6886. }
  6887. if m.FieldCleared(batchmsg.FieldMsg) {
  6888. fields = append(fields, batchmsg.FieldMsg)
  6889. }
  6890. if m.FieldCleared(batchmsg.FieldTag) {
  6891. fields = append(fields, batchmsg.FieldTag)
  6892. }
  6893. if m.FieldCleared(batchmsg.FieldTagids) {
  6894. fields = append(fields, batchmsg.FieldTagids)
  6895. }
  6896. if m.FieldCleared(batchmsg.FieldTotal) {
  6897. fields = append(fields, batchmsg.FieldTotal)
  6898. }
  6899. if m.FieldCleared(batchmsg.FieldSuccess) {
  6900. fields = append(fields, batchmsg.FieldSuccess)
  6901. }
  6902. if m.FieldCleared(batchmsg.FieldFail) {
  6903. fields = append(fields, batchmsg.FieldFail)
  6904. }
  6905. if m.FieldCleared(batchmsg.FieldStartTime) {
  6906. fields = append(fields, batchmsg.FieldStartTime)
  6907. }
  6908. if m.FieldCleared(batchmsg.FieldStopTime) {
  6909. fields = append(fields, batchmsg.FieldStopTime)
  6910. }
  6911. if m.FieldCleared(batchmsg.FieldSendTime) {
  6912. fields = append(fields, batchmsg.FieldSendTime)
  6913. }
  6914. if m.FieldCleared(batchmsg.FieldType) {
  6915. fields = append(fields, batchmsg.FieldType)
  6916. }
  6917. if m.FieldCleared(batchmsg.FieldCc) {
  6918. fields = append(fields, batchmsg.FieldCc)
  6919. }
  6920. if m.FieldCleared(batchmsg.FieldPhone) {
  6921. fields = append(fields, batchmsg.FieldPhone)
  6922. }
  6923. if m.FieldCleared(batchmsg.FieldTemplateName) {
  6924. fields = append(fields, batchmsg.FieldTemplateName)
  6925. }
  6926. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  6927. fields = append(fields, batchmsg.FieldTemplateCode)
  6928. }
  6929. if m.FieldCleared(batchmsg.FieldLang) {
  6930. fields = append(fields, batchmsg.FieldLang)
  6931. }
  6932. return fields
  6933. }
  6934. // FieldCleared returns a boolean indicating if a field with the given name was
  6935. // cleared in this mutation.
  6936. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  6937. _, ok := m.clearedFields[name]
  6938. return ok
  6939. }
  6940. // ClearField clears the value of the field with the given name. It returns an
  6941. // error if the field is not defined in the schema.
  6942. func (m *BatchMsgMutation) ClearField(name string) error {
  6943. switch name {
  6944. case batchmsg.FieldDeletedAt:
  6945. m.ClearDeletedAt()
  6946. return nil
  6947. case batchmsg.FieldStatus:
  6948. m.ClearStatus()
  6949. return nil
  6950. case batchmsg.FieldBatchNo:
  6951. m.ClearBatchNo()
  6952. return nil
  6953. case batchmsg.FieldTaskName:
  6954. m.ClearTaskName()
  6955. return nil
  6956. case batchmsg.FieldFromwxid:
  6957. m.ClearFromwxid()
  6958. return nil
  6959. case batchmsg.FieldMsg:
  6960. m.ClearMsg()
  6961. return nil
  6962. case batchmsg.FieldTag:
  6963. m.ClearTag()
  6964. return nil
  6965. case batchmsg.FieldTagids:
  6966. m.ClearTagids()
  6967. return nil
  6968. case batchmsg.FieldTotal:
  6969. m.ClearTotal()
  6970. return nil
  6971. case batchmsg.FieldSuccess:
  6972. m.ClearSuccess()
  6973. return nil
  6974. case batchmsg.FieldFail:
  6975. m.ClearFail()
  6976. return nil
  6977. case batchmsg.FieldStartTime:
  6978. m.ClearStartTime()
  6979. return nil
  6980. case batchmsg.FieldStopTime:
  6981. m.ClearStopTime()
  6982. return nil
  6983. case batchmsg.FieldSendTime:
  6984. m.ClearSendTime()
  6985. return nil
  6986. case batchmsg.FieldType:
  6987. m.ClearType()
  6988. return nil
  6989. case batchmsg.FieldCc:
  6990. m.ClearCc()
  6991. return nil
  6992. case batchmsg.FieldPhone:
  6993. m.ClearPhone()
  6994. return nil
  6995. case batchmsg.FieldTemplateName:
  6996. m.ClearTemplateName()
  6997. return nil
  6998. case batchmsg.FieldTemplateCode:
  6999. m.ClearTemplateCode()
  7000. return nil
  7001. case batchmsg.FieldLang:
  7002. m.ClearLang()
  7003. return nil
  7004. }
  7005. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7006. }
  7007. // ResetField resets all changes in the mutation for the field with the given name.
  7008. // It returns an error if the field is not defined in the schema.
  7009. func (m *BatchMsgMutation) ResetField(name string) error {
  7010. switch name {
  7011. case batchmsg.FieldCreatedAt:
  7012. m.ResetCreatedAt()
  7013. return nil
  7014. case batchmsg.FieldUpdatedAt:
  7015. m.ResetUpdatedAt()
  7016. return nil
  7017. case batchmsg.FieldDeletedAt:
  7018. m.ResetDeletedAt()
  7019. return nil
  7020. case batchmsg.FieldStatus:
  7021. m.ResetStatus()
  7022. return nil
  7023. case batchmsg.FieldBatchNo:
  7024. m.ResetBatchNo()
  7025. return nil
  7026. case batchmsg.FieldTaskName:
  7027. m.ResetTaskName()
  7028. return nil
  7029. case batchmsg.FieldFromwxid:
  7030. m.ResetFromwxid()
  7031. return nil
  7032. case batchmsg.FieldMsg:
  7033. m.ResetMsg()
  7034. return nil
  7035. case batchmsg.FieldTag:
  7036. m.ResetTag()
  7037. return nil
  7038. case batchmsg.FieldTagids:
  7039. m.ResetTagids()
  7040. return nil
  7041. case batchmsg.FieldTotal:
  7042. m.ResetTotal()
  7043. return nil
  7044. case batchmsg.FieldSuccess:
  7045. m.ResetSuccess()
  7046. return nil
  7047. case batchmsg.FieldFail:
  7048. m.ResetFail()
  7049. return nil
  7050. case batchmsg.FieldStartTime:
  7051. m.ResetStartTime()
  7052. return nil
  7053. case batchmsg.FieldStopTime:
  7054. m.ResetStopTime()
  7055. return nil
  7056. case batchmsg.FieldSendTime:
  7057. m.ResetSendTime()
  7058. return nil
  7059. case batchmsg.FieldType:
  7060. m.ResetType()
  7061. return nil
  7062. case batchmsg.FieldOrganizationID:
  7063. m.ResetOrganizationID()
  7064. return nil
  7065. case batchmsg.FieldCtype:
  7066. m.ResetCtype()
  7067. return nil
  7068. case batchmsg.FieldCc:
  7069. m.ResetCc()
  7070. return nil
  7071. case batchmsg.FieldPhone:
  7072. m.ResetPhone()
  7073. return nil
  7074. case batchmsg.FieldTemplateName:
  7075. m.ResetTemplateName()
  7076. return nil
  7077. case batchmsg.FieldTemplateCode:
  7078. m.ResetTemplateCode()
  7079. return nil
  7080. case batchmsg.FieldLang:
  7081. m.ResetLang()
  7082. return nil
  7083. }
  7084. return fmt.Errorf("unknown BatchMsg field %s", name)
  7085. }
  7086. // AddedEdges returns all edge names that were set/added in this mutation.
  7087. func (m *BatchMsgMutation) AddedEdges() []string {
  7088. edges := make([]string, 0, 0)
  7089. return edges
  7090. }
  7091. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7092. // name in this mutation.
  7093. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7094. return nil
  7095. }
  7096. // RemovedEdges returns all edge names that were removed in this mutation.
  7097. func (m *BatchMsgMutation) RemovedEdges() []string {
  7098. edges := make([]string, 0, 0)
  7099. return edges
  7100. }
  7101. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7102. // the given name in this mutation.
  7103. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7104. return nil
  7105. }
  7106. // ClearedEdges returns all edge names that were cleared in this mutation.
  7107. func (m *BatchMsgMutation) ClearedEdges() []string {
  7108. edges := make([]string, 0, 0)
  7109. return edges
  7110. }
  7111. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7112. // was cleared in this mutation.
  7113. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7114. return false
  7115. }
  7116. // ClearEdge clears the value of the edge with the given name. It returns an error
  7117. // if that edge is not defined in the schema.
  7118. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7119. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7120. }
  7121. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7122. // It returns an error if the edge is not defined in the schema.
  7123. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7124. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7125. }
  7126. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7127. type CategoryMutation struct {
  7128. config
  7129. op Op
  7130. typ string
  7131. id *uint64
  7132. created_at *time.Time
  7133. updated_at *time.Time
  7134. deleted_at *time.Time
  7135. name *string
  7136. organization_id *uint64
  7137. addorganization_id *int64
  7138. clearedFields map[string]struct{}
  7139. done bool
  7140. oldValue func(context.Context) (*Category, error)
  7141. predicates []predicate.Category
  7142. }
  7143. var _ ent.Mutation = (*CategoryMutation)(nil)
  7144. // categoryOption allows management of the mutation configuration using functional options.
  7145. type categoryOption func(*CategoryMutation)
  7146. // newCategoryMutation creates new mutation for the Category entity.
  7147. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7148. m := &CategoryMutation{
  7149. config: c,
  7150. op: op,
  7151. typ: TypeCategory,
  7152. clearedFields: make(map[string]struct{}),
  7153. }
  7154. for _, opt := range opts {
  7155. opt(m)
  7156. }
  7157. return m
  7158. }
  7159. // withCategoryID sets the ID field of the mutation.
  7160. func withCategoryID(id uint64) categoryOption {
  7161. return func(m *CategoryMutation) {
  7162. var (
  7163. err error
  7164. once sync.Once
  7165. value *Category
  7166. )
  7167. m.oldValue = func(ctx context.Context) (*Category, error) {
  7168. once.Do(func() {
  7169. if m.done {
  7170. err = errors.New("querying old values post mutation is not allowed")
  7171. } else {
  7172. value, err = m.Client().Category.Get(ctx, id)
  7173. }
  7174. })
  7175. return value, err
  7176. }
  7177. m.id = &id
  7178. }
  7179. }
  7180. // withCategory sets the old Category of the mutation.
  7181. func withCategory(node *Category) categoryOption {
  7182. return func(m *CategoryMutation) {
  7183. m.oldValue = func(context.Context) (*Category, error) {
  7184. return node, nil
  7185. }
  7186. m.id = &node.ID
  7187. }
  7188. }
  7189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7190. // executed in a transaction (ent.Tx), a transactional client is returned.
  7191. func (m CategoryMutation) Client() *Client {
  7192. client := &Client{config: m.config}
  7193. client.init()
  7194. return client
  7195. }
  7196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7197. // it returns an error otherwise.
  7198. func (m CategoryMutation) Tx() (*Tx, error) {
  7199. if _, ok := m.driver.(*txDriver); !ok {
  7200. return nil, errors.New("ent: mutation is not running in a transaction")
  7201. }
  7202. tx := &Tx{config: m.config}
  7203. tx.init()
  7204. return tx, nil
  7205. }
  7206. // SetID sets the value of the id field. Note that this
  7207. // operation is only accepted on creation of Category entities.
  7208. func (m *CategoryMutation) SetID(id uint64) {
  7209. m.id = &id
  7210. }
  7211. // ID returns the ID value in the mutation. Note that the ID is only available
  7212. // if it was provided to the builder or after it was returned from the database.
  7213. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7214. if m.id == nil {
  7215. return
  7216. }
  7217. return *m.id, true
  7218. }
  7219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7220. // That means, if the mutation is applied within a transaction with an isolation level such
  7221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7222. // or updated by the mutation.
  7223. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7224. switch {
  7225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7226. id, exists := m.ID()
  7227. if exists {
  7228. return []uint64{id}, nil
  7229. }
  7230. fallthrough
  7231. case m.op.Is(OpUpdate | OpDelete):
  7232. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7233. default:
  7234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7235. }
  7236. }
  7237. // SetCreatedAt sets the "created_at" field.
  7238. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7239. m.created_at = &t
  7240. }
  7241. // CreatedAt returns the value of the "created_at" field in the mutation.
  7242. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7243. v := m.created_at
  7244. if v == nil {
  7245. return
  7246. }
  7247. return *v, true
  7248. }
  7249. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7250. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7252. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7253. if !m.op.Is(OpUpdateOne) {
  7254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7255. }
  7256. if m.id == nil || m.oldValue == nil {
  7257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7258. }
  7259. oldValue, err := m.oldValue(ctx)
  7260. if err != nil {
  7261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7262. }
  7263. return oldValue.CreatedAt, nil
  7264. }
  7265. // ResetCreatedAt resets all changes to the "created_at" field.
  7266. func (m *CategoryMutation) ResetCreatedAt() {
  7267. m.created_at = nil
  7268. }
  7269. // SetUpdatedAt sets the "updated_at" field.
  7270. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7271. m.updated_at = &t
  7272. }
  7273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7274. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7275. v := m.updated_at
  7276. if v == nil {
  7277. return
  7278. }
  7279. return *v, true
  7280. }
  7281. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7282. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7284. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7285. if !m.op.Is(OpUpdateOne) {
  7286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7287. }
  7288. if m.id == nil || m.oldValue == nil {
  7289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7290. }
  7291. oldValue, err := m.oldValue(ctx)
  7292. if err != nil {
  7293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7294. }
  7295. return oldValue.UpdatedAt, nil
  7296. }
  7297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7298. func (m *CategoryMutation) ResetUpdatedAt() {
  7299. m.updated_at = nil
  7300. }
  7301. // SetDeletedAt sets the "deleted_at" field.
  7302. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7303. m.deleted_at = &t
  7304. }
  7305. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7306. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7307. v := m.deleted_at
  7308. if v == nil {
  7309. return
  7310. }
  7311. return *v, true
  7312. }
  7313. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7314. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7316. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7317. if !m.op.Is(OpUpdateOne) {
  7318. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7319. }
  7320. if m.id == nil || m.oldValue == nil {
  7321. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7322. }
  7323. oldValue, err := m.oldValue(ctx)
  7324. if err != nil {
  7325. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7326. }
  7327. return oldValue.DeletedAt, nil
  7328. }
  7329. // ClearDeletedAt clears the value of the "deleted_at" field.
  7330. func (m *CategoryMutation) ClearDeletedAt() {
  7331. m.deleted_at = nil
  7332. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7333. }
  7334. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7335. func (m *CategoryMutation) DeletedAtCleared() bool {
  7336. _, ok := m.clearedFields[category.FieldDeletedAt]
  7337. return ok
  7338. }
  7339. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7340. func (m *CategoryMutation) ResetDeletedAt() {
  7341. m.deleted_at = nil
  7342. delete(m.clearedFields, category.FieldDeletedAt)
  7343. }
  7344. // SetName sets the "name" field.
  7345. func (m *CategoryMutation) SetName(s string) {
  7346. m.name = &s
  7347. }
  7348. // Name returns the value of the "name" field in the mutation.
  7349. func (m *CategoryMutation) Name() (r string, exists bool) {
  7350. v := m.name
  7351. if v == nil {
  7352. return
  7353. }
  7354. return *v, true
  7355. }
  7356. // OldName returns the old "name" field's value of the Category entity.
  7357. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7359. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7360. if !m.op.Is(OpUpdateOne) {
  7361. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7362. }
  7363. if m.id == nil || m.oldValue == nil {
  7364. return v, errors.New("OldName requires an ID field in the mutation")
  7365. }
  7366. oldValue, err := m.oldValue(ctx)
  7367. if err != nil {
  7368. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7369. }
  7370. return oldValue.Name, nil
  7371. }
  7372. // ResetName resets all changes to the "name" field.
  7373. func (m *CategoryMutation) ResetName() {
  7374. m.name = nil
  7375. }
  7376. // SetOrganizationID sets the "organization_id" field.
  7377. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7378. m.organization_id = &u
  7379. m.addorganization_id = nil
  7380. }
  7381. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7382. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7383. v := m.organization_id
  7384. if v == nil {
  7385. return
  7386. }
  7387. return *v, true
  7388. }
  7389. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7390. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7392. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7393. if !m.op.Is(OpUpdateOne) {
  7394. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7395. }
  7396. if m.id == nil || m.oldValue == nil {
  7397. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7398. }
  7399. oldValue, err := m.oldValue(ctx)
  7400. if err != nil {
  7401. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7402. }
  7403. return oldValue.OrganizationID, nil
  7404. }
  7405. // AddOrganizationID adds u to the "organization_id" field.
  7406. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7407. if m.addorganization_id != nil {
  7408. *m.addorganization_id += u
  7409. } else {
  7410. m.addorganization_id = &u
  7411. }
  7412. }
  7413. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7414. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7415. v := m.addorganization_id
  7416. if v == nil {
  7417. return
  7418. }
  7419. return *v, true
  7420. }
  7421. // ResetOrganizationID resets all changes to the "organization_id" field.
  7422. func (m *CategoryMutation) ResetOrganizationID() {
  7423. m.organization_id = nil
  7424. m.addorganization_id = nil
  7425. }
  7426. // Where appends a list predicates to the CategoryMutation builder.
  7427. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7428. m.predicates = append(m.predicates, ps...)
  7429. }
  7430. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7431. // users can use type-assertion to append predicates that do not depend on any generated package.
  7432. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7433. p := make([]predicate.Category, len(ps))
  7434. for i := range ps {
  7435. p[i] = ps[i]
  7436. }
  7437. m.Where(p...)
  7438. }
  7439. // Op returns the operation name.
  7440. func (m *CategoryMutation) Op() Op {
  7441. return m.op
  7442. }
  7443. // SetOp allows setting the mutation operation.
  7444. func (m *CategoryMutation) SetOp(op Op) {
  7445. m.op = op
  7446. }
  7447. // Type returns the node type of this mutation (Category).
  7448. func (m *CategoryMutation) Type() string {
  7449. return m.typ
  7450. }
  7451. // Fields returns all fields that were changed during this mutation. Note that in
  7452. // order to get all numeric fields that were incremented/decremented, call
  7453. // AddedFields().
  7454. func (m *CategoryMutation) Fields() []string {
  7455. fields := make([]string, 0, 5)
  7456. if m.created_at != nil {
  7457. fields = append(fields, category.FieldCreatedAt)
  7458. }
  7459. if m.updated_at != nil {
  7460. fields = append(fields, category.FieldUpdatedAt)
  7461. }
  7462. if m.deleted_at != nil {
  7463. fields = append(fields, category.FieldDeletedAt)
  7464. }
  7465. if m.name != nil {
  7466. fields = append(fields, category.FieldName)
  7467. }
  7468. if m.organization_id != nil {
  7469. fields = append(fields, category.FieldOrganizationID)
  7470. }
  7471. return fields
  7472. }
  7473. // Field returns the value of a field with the given name. The second boolean
  7474. // return value indicates that this field was not set, or was not defined in the
  7475. // schema.
  7476. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7477. switch name {
  7478. case category.FieldCreatedAt:
  7479. return m.CreatedAt()
  7480. case category.FieldUpdatedAt:
  7481. return m.UpdatedAt()
  7482. case category.FieldDeletedAt:
  7483. return m.DeletedAt()
  7484. case category.FieldName:
  7485. return m.Name()
  7486. case category.FieldOrganizationID:
  7487. return m.OrganizationID()
  7488. }
  7489. return nil, false
  7490. }
  7491. // OldField returns the old value of the field from the database. An error is
  7492. // returned if the mutation operation is not UpdateOne, or the query to the
  7493. // database failed.
  7494. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7495. switch name {
  7496. case category.FieldCreatedAt:
  7497. return m.OldCreatedAt(ctx)
  7498. case category.FieldUpdatedAt:
  7499. return m.OldUpdatedAt(ctx)
  7500. case category.FieldDeletedAt:
  7501. return m.OldDeletedAt(ctx)
  7502. case category.FieldName:
  7503. return m.OldName(ctx)
  7504. case category.FieldOrganizationID:
  7505. return m.OldOrganizationID(ctx)
  7506. }
  7507. return nil, fmt.Errorf("unknown Category field %s", name)
  7508. }
  7509. // SetField sets the value of a field with the given name. It returns an error if
  7510. // the field is not defined in the schema, or if the type mismatched the field
  7511. // type.
  7512. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7513. switch name {
  7514. case category.FieldCreatedAt:
  7515. v, ok := value.(time.Time)
  7516. if !ok {
  7517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7518. }
  7519. m.SetCreatedAt(v)
  7520. return nil
  7521. case category.FieldUpdatedAt:
  7522. v, ok := value.(time.Time)
  7523. if !ok {
  7524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7525. }
  7526. m.SetUpdatedAt(v)
  7527. return nil
  7528. case category.FieldDeletedAt:
  7529. v, ok := value.(time.Time)
  7530. if !ok {
  7531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7532. }
  7533. m.SetDeletedAt(v)
  7534. return nil
  7535. case category.FieldName:
  7536. v, ok := value.(string)
  7537. if !ok {
  7538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7539. }
  7540. m.SetName(v)
  7541. return nil
  7542. case category.FieldOrganizationID:
  7543. v, ok := value.(uint64)
  7544. if !ok {
  7545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7546. }
  7547. m.SetOrganizationID(v)
  7548. return nil
  7549. }
  7550. return fmt.Errorf("unknown Category field %s", name)
  7551. }
  7552. // AddedFields returns all numeric fields that were incremented/decremented during
  7553. // this mutation.
  7554. func (m *CategoryMutation) AddedFields() []string {
  7555. var fields []string
  7556. if m.addorganization_id != nil {
  7557. fields = append(fields, category.FieldOrganizationID)
  7558. }
  7559. return fields
  7560. }
  7561. // AddedField returns the numeric value that was incremented/decremented on a field
  7562. // with the given name. The second boolean return value indicates that this field
  7563. // was not set, or was not defined in the schema.
  7564. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7565. switch name {
  7566. case category.FieldOrganizationID:
  7567. return m.AddedOrganizationID()
  7568. }
  7569. return nil, false
  7570. }
  7571. // AddField adds the value to the field with the given name. It returns an error if
  7572. // the field is not defined in the schema, or if the type mismatched the field
  7573. // type.
  7574. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7575. switch name {
  7576. case category.FieldOrganizationID:
  7577. v, ok := value.(int64)
  7578. if !ok {
  7579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7580. }
  7581. m.AddOrganizationID(v)
  7582. return nil
  7583. }
  7584. return fmt.Errorf("unknown Category numeric field %s", name)
  7585. }
  7586. // ClearedFields returns all nullable fields that were cleared during this
  7587. // mutation.
  7588. func (m *CategoryMutation) ClearedFields() []string {
  7589. var fields []string
  7590. if m.FieldCleared(category.FieldDeletedAt) {
  7591. fields = append(fields, category.FieldDeletedAt)
  7592. }
  7593. return fields
  7594. }
  7595. // FieldCleared returns a boolean indicating if a field with the given name was
  7596. // cleared in this mutation.
  7597. func (m *CategoryMutation) FieldCleared(name string) bool {
  7598. _, ok := m.clearedFields[name]
  7599. return ok
  7600. }
  7601. // ClearField clears the value of the field with the given name. It returns an
  7602. // error if the field is not defined in the schema.
  7603. func (m *CategoryMutation) ClearField(name string) error {
  7604. switch name {
  7605. case category.FieldDeletedAt:
  7606. m.ClearDeletedAt()
  7607. return nil
  7608. }
  7609. return fmt.Errorf("unknown Category nullable field %s", name)
  7610. }
  7611. // ResetField resets all changes in the mutation for the field with the given name.
  7612. // It returns an error if the field is not defined in the schema.
  7613. func (m *CategoryMutation) ResetField(name string) error {
  7614. switch name {
  7615. case category.FieldCreatedAt:
  7616. m.ResetCreatedAt()
  7617. return nil
  7618. case category.FieldUpdatedAt:
  7619. m.ResetUpdatedAt()
  7620. return nil
  7621. case category.FieldDeletedAt:
  7622. m.ResetDeletedAt()
  7623. return nil
  7624. case category.FieldName:
  7625. m.ResetName()
  7626. return nil
  7627. case category.FieldOrganizationID:
  7628. m.ResetOrganizationID()
  7629. return nil
  7630. }
  7631. return fmt.Errorf("unknown Category field %s", name)
  7632. }
  7633. // AddedEdges returns all edge names that were set/added in this mutation.
  7634. func (m *CategoryMutation) AddedEdges() []string {
  7635. edges := make([]string, 0, 0)
  7636. return edges
  7637. }
  7638. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7639. // name in this mutation.
  7640. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7641. return nil
  7642. }
  7643. // RemovedEdges returns all edge names that were removed in this mutation.
  7644. func (m *CategoryMutation) RemovedEdges() []string {
  7645. edges := make([]string, 0, 0)
  7646. return edges
  7647. }
  7648. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7649. // the given name in this mutation.
  7650. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7651. return nil
  7652. }
  7653. // ClearedEdges returns all edge names that were cleared in this mutation.
  7654. func (m *CategoryMutation) ClearedEdges() []string {
  7655. edges := make([]string, 0, 0)
  7656. return edges
  7657. }
  7658. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7659. // was cleared in this mutation.
  7660. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7661. return false
  7662. }
  7663. // ClearEdge clears the value of the edge with the given name. It returns an error
  7664. // if that edge is not defined in the schema.
  7665. func (m *CategoryMutation) ClearEdge(name string) error {
  7666. return fmt.Errorf("unknown Category unique edge %s", name)
  7667. }
  7668. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7669. // It returns an error if the edge is not defined in the schema.
  7670. func (m *CategoryMutation) ResetEdge(name string) error {
  7671. return fmt.Errorf("unknown Category edge %s", name)
  7672. }
  7673. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7674. type ChatRecordsMutation struct {
  7675. config
  7676. op Op
  7677. typ string
  7678. id *uint64
  7679. created_at *time.Time
  7680. updated_at *time.Time
  7681. deleted_at *time.Time
  7682. content *string
  7683. content_type *uint8
  7684. addcontent_type *int8
  7685. session_id *uint64
  7686. addsession_id *int64
  7687. user_id *uint64
  7688. adduser_id *int64
  7689. bot_id *uint64
  7690. addbot_id *int64
  7691. bot_type *uint8
  7692. addbot_type *int8
  7693. clearedFields map[string]struct{}
  7694. done bool
  7695. oldValue func(context.Context) (*ChatRecords, error)
  7696. predicates []predicate.ChatRecords
  7697. }
  7698. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7699. // chatrecordsOption allows management of the mutation configuration using functional options.
  7700. type chatrecordsOption func(*ChatRecordsMutation)
  7701. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7702. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7703. m := &ChatRecordsMutation{
  7704. config: c,
  7705. op: op,
  7706. typ: TypeChatRecords,
  7707. clearedFields: make(map[string]struct{}),
  7708. }
  7709. for _, opt := range opts {
  7710. opt(m)
  7711. }
  7712. return m
  7713. }
  7714. // withChatRecordsID sets the ID field of the mutation.
  7715. func withChatRecordsID(id uint64) chatrecordsOption {
  7716. return func(m *ChatRecordsMutation) {
  7717. var (
  7718. err error
  7719. once sync.Once
  7720. value *ChatRecords
  7721. )
  7722. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7723. once.Do(func() {
  7724. if m.done {
  7725. err = errors.New("querying old values post mutation is not allowed")
  7726. } else {
  7727. value, err = m.Client().ChatRecords.Get(ctx, id)
  7728. }
  7729. })
  7730. return value, err
  7731. }
  7732. m.id = &id
  7733. }
  7734. }
  7735. // withChatRecords sets the old ChatRecords of the mutation.
  7736. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7737. return func(m *ChatRecordsMutation) {
  7738. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7739. return node, nil
  7740. }
  7741. m.id = &node.ID
  7742. }
  7743. }
  7744. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7745. // executed in a transaction (ent.Tx), a transactional client is returned.
  7746. func (m ChatRecordsMutation) Client() *Client {
  7747. client := &Client{config: m.config}
  7748. client.init()
  7749. return client
  7750. }
  7751. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7752. // it returns an error otherwise.
  7753. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7754. if _, ok := m.driver.(*txDriver); !ok {
  7755. return nil, errors.New("ent: mutation is not running in a transaction")
  7756. }
  7757. tx := &Tx{config: m.config}
  7758. tx.init()
  7759. return tx, nil
  7760. }
  7761. // SetID sets the value of the id field. Note that this
  7762. // operation is only accepted on creation of ChatRecords entities.
  7763. func (m *ChatRecordsMutation) SetID(id uint64) {
  7764. m.id = &id
  7765. }
  7766. // ID returns the ID value in the mutation. Note that the ID is only available
  7767. // if it was provided to the builder or after it was returned from the database.
  7768. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  7769. if m.id == nil {
  7770. return
  7771. }
  7772. return *m.id, true
  7773. }
  7774. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7775. // That means, if the mutation is applied within a transaction with an isolation level such
  7776. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7777. // or updated by the mutation.
  7778. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7779. switch {
  7780. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7781. id, exists := m.ID()
  7782. if exists {
  7783. return []uint64{id}, nil
  7784. }
  7785. fallthrough
  7786. case m.op.Is(OpUpdate | OpDelete):
  7787. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  7788. default:
  7789. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7790. }
  7791. }
  7792. // SetCreatedAt sets the "created_at" field.
  7793. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  7794. m.created_at = &t
  7795. }
  7796. // CreatedAt returns the value of the "created_at" field in the mutation.
  7797. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7798. v := m.created_at
  7799. if v == nil {
  7800. return
  7801. }
  7802. return *v, true
  7803. }
  7804. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  7805. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7807. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7808. if !m.op.Is(OpUpdateOne) {
  7809. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7810. }
  7811. if m.id == nil || m.oldValue == nil {
  7812. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7813. }
  7814. oldValue, err := m.oldValue(ctx)
  7815. if err != nil {
  7816. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7817. }
  7818. return oldValue.CreatedAt, nil
  7819. }
  7820. // ResetCreatedAt resets all changes to the "created_at" field.
  7821. func (m *ChatRecordsMutation) ResetCreatedAt() {
  7822. m.created_at = nil
  7823. }
  7824. // SetUpdatedAt sets the "updated_at" field.
  7825. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  7826. m.updated_at = &t
  7827. }
  7828. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7829. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7830. v := m.updated_at
  7831. if v == nil {
  7832. return
  7833. }
  7834. return *v, true
  7835. }
  7836. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  7837. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7839. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7840. if !m.op.Is(OpUpdateOne) {
  7841. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7842. }
  7843. if m.id == nil || m.oldValue == nil {
  7844. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7845. }
  7846. oldValue, err := m.oldValue(ctx)
  7847. if err != nil {
  7848. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7849. }
  7850. return oldValue.UpdatedAt, nil
  7851. }
  7852. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7853. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  7854. m.updated_at = nil
  7855. }
  7856. // SetDeletedAt sets the "deleted_at" field.
  7857. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  7858. m.deleted_at = &t
  7859. }
  7860. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7861. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  7862. v := m.deleted_at
  7863. if v == nil {
  7864. return
  7865. }
  7866. return *v, true
  7867. }
  7868. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  7869. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7871. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7872. if !m.op.Is(OpUpdateOne) {
  7873. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7874. }
  7875. if m.id == nil || m.oldValue == nil {
  7876. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7877. }
  7878. oldValue, err := m.oldValue(ctx)
  7879. if err != nil {
  7880. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7881. }
  7882. return oldValue.DeletedAt, nil
  7883. }
  7884. // ClearDeletedAt clears the value of the "deleted_at" field.
  7885. func (m *ChatRecordsMutation) ClearDeletedAt() {
  7886. m.deleted_at = nil
  7887. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  7888. }
  7889. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7890. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  7891. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  7892. return ok
  7893. }
  7894. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7895. func (m *ChatRecordsMutation) ResetDeletedAt() {
  7896. m.deleted_at = nil
  7897. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  7898. }
  7899. // SetContent sets the "content" field.
  7900. func (m *ChatRecordsMutation) SetContent(s string) {
  7901. m.content = &s
  7902. }
  7903. // Content returns the value of the "content" field in the mutation.
  7904. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  7905. v := m.content
  7906. if v == nil {
  7907. return
  7908. }
  7909. return *v, true
  7910. }
  7911. // OldContent returns the old "content" field's value of the ChatRecords entity.
  7912. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7914. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  7915. if !m.op.Is(OpUpdateOne) {
  7916. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7917. }
  7918. if m.id == nil || m.oldValue == nil {
  7919. return v, errors.New("OldContent requires an ID field in the mutation")
  7920. }
  7921. oldValue, err := m.oldValue(ctx)
  7922. if err != nil {
  7923. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  7924. }
  7925. return oldValue.Content, nil
  7926. }
  7927. // ResetContent resets all changes to the "content" field.
  7928. func (m *ChatRecordsMutation) ResetContent() {
  7929. m.content = nil
  7930. }
  7931. // SetContentType sets the "content_type" field.
  7932. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  7933. m.content_type = &u
  7934. m.addcontent_type = nil
  7935. }
  7936. // ContentType returns the value of the "content_type" field in the mutation.
  7937. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  7938. v := m.content_type
  7939. if v == nil {
  7940. return
  7941. }
  7942. return *v, true
  7943. }
  7944. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  7945. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7947. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  7948. if !m.op.Is(OpUpdateOne) {
  7949. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  7950. }
  7951. if m.id == nil || m.oldValue == nil {
  7952. return v, errors.New("OldContentType requires an ID field in the mutation")
  7953. }
  7954. oldValue, err := m.oldValue(ctx)
  7955. if err != nil {
  7956. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  7957. }
  7958. return oldValue.ContentType, nil
  7959. }
  7960. // AddContentType adds u to the "content_type" field.
  7961. func (m *ChatRecordsMutation) AddContentType(u int8) {
  7962. if m.addcontent_type != nil {
  7963. *m.addcontent_type += u
  7964. } else {
  7965. m.addcontent_type = &u
  7966. }
  7967. }
  7968. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  7969. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  7970. v := m.addcontent_type
  7971. if v == nil {
  7972. return
  7973. }
  7974. return *v, true
  7975. }
  7976. // ResetContentType resets all changes to the "content_type" field.
  7977. func (m *ChatRecordsMutation) ResetContentType() {
  7978. m.content_type = nil
  7979. m.addcontent_type = nil
  7980. }
  7981. // SetSessionID sets the "session_id" field.
  7982. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  7983. m.session_id = &u
  7984. m.addsession_id = nil
  7985. }
  7986. // SessionID returns the value of the "session_id" field in the mutation.
  7987. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  7988. v := m.session_id
  7989. if v == nil {
  7990. return
  7991. }
  7992. return *v, true
  7993. }
  7994. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  7995. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7997. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  7998. if !m.op.Is(OpUpdateOne) {
  7999. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8000. }
  8001. if m.id == nil || m.oldValue == nil {
  8002. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8003. }
  8004. oldValue, err := m.oldValue(ctx)
  8005. if err != nil {
  8006. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8007. }
  8008. return oldValue.SessionID, nil
  8009. }
  8010. // AddSessionID adds u to the "session_id" field.
  8011. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8012. if m.addsession_id != nil {
  8013. *m.addsession_id += u
  8014. } else {
  8015. m.addsession_id = &u
  8016. }
  8017. }
  8018. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8019. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8020. v := m.addsession_id
  8021. if v == nil {
  8022. return
  8023. }
  8024. return *v, true
  8025. }
  8026. // ResetSessionID resets all changes to the "session_id" field.
  8027. func (m *ChatRecordsMutation) ResetSessionID() {
  8028. m.session_id = nil
  8029. m.addsession_id = nil
  8030. }
  8031. // SetUserID sets the "user_id" field.
  8032. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8033. m.user_id = &u
  8034. m.adduser_id = nil
  8035. }
  8036. // UserID returns the value of the "user_id" field in the mutation.
  8037. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8038. v := m.user_id
  8039. if v == nil {
  8040. return
  8041. }
  8042. return *v, true
  8043. }
  8044. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8045. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8047. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8048. if !m.op.Is(OpUpdateOne) {
  8049. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8050. }
  8051. if m.id == nil || m.oldValue == nil {
  8052. return v, errors.New("OldUserID requires an ID field in the mutation")
  8053. }
  8054. oldValue, err := m.oldValue(ctx)
  8055. if err != nil {
  8056. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8057. }
  8058. return oldValue.UserID, nil
  8059. }
  8060. // AddUserID adds u to the "user_id" field.
  8061. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8062. if m.adduser_id != nil {
  8063. *m.adduser_id += u
  8064. } else {
  8065. m.adduser_id = &u
  8066. }
  8067. }
  8068. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8069. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8070. v := m.adduser_id
  8071. if v == nil {
  8072. return
  8073. }
  8074. return *v, true
  8075. }
  8076. // ResetUserID resets all changes to the "user_id" field.
  8077. func (m *ChatRecordsMutation) ResetUserID() {
  8078. m.user_id = nil
  8079. m.adduser_id = nil
  8080. }
  8081. // SetBotID sets the "bot_id" field.
  8082. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8083. m.bot_id = &u
  8084. m.addbot_id = nil
  8085. }
  8086. // BotID returns the value of the "bot_id" field in the mutation.
  8087. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8088. v := m.bot_id
  8089. if v == nil {
  8090. return
  8091. }
  8092. return *v, true
  8093. }
  8094. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8095. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8097. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8098. if !m.op.Is(OpUpdateOne) {
  8099. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8100. }
  8101. if m.id == nil || m.oldValue == nil {
  8102. return v, errors.New("OldBotID requires an ID field in the mutation")
  8103. }
  8104. oldValue, err := m.oldValue(ctx)
  8105. if err != nil {
  8106. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8107. }
  8108. return oldValue.BotID, nil
  8109. }
  8110. // AddBotID adds u to the "bot_id" field.
  8111. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8112. if m.addbot_id != nil {
  8113. *m.addbot_id += u
  8114. } else {
  8115. m.addbot_id = &u
  8116. }
  8117. }
  8118. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8119. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8120. v := m.addbot_id
  8121. if v == nil {
  8122. return
  8123. }
  8124. return *v, true
  8125. }
  8126. // ResetBotID resets all changes to the "bot_id" field.
  8127. func (m *ChatRecordsMutation) ResetBotID() {
  8128. m.bot_id = nil
  8129. m.addbot_id = nil
  8130. }
  8131. // SetBotType sets the "bot_type" field.
  8132. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8133. m.bot_type = &u
  8134. m.addbot_type = nil
  8135. }
  8136. // BotType returns the value of the "bot_type" field in the mutation.
  8137. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8138. v := m.bot_type
  8139. if v == nil {
  8140. return
  8141. }
  8142. return *v, true
  8143. }
  8144. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8145. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8147. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8148. if !m.op.Is(OpUpdateOne) {
  8149. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8150. }
  8151. if m.id == nil || m.oldValue == nil {
  8152. return v, errors.New("OldBotType requires an ID field in the mutation")
  8153. }
  8154. oldValue, err := m.oldValue(ctx)
  8155. if err != nil {
  8156. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8157. }
  8158. return oldValue.BotType, nil
  8159. }
  8160. // AddBotType adds u to the "bot_type" field.
  8161. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8162. if m.addbot_type != nil {
  8163. *m.addbot_type += u
  8164. } else {
  8165. m.addbot_type = &u
  8166. }
  8167. }
  8168. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8169. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8170. v := m.addbot_type
  8171. if v == nil {
  8172. return
  8173. }
  8174. return *v, true
  8175. }
  8176. // ResetBotType resets all changes to the "bot_type" field.
  8177. func (m *ChatRecordsMutation) ResetBotType() {
  8178. m.bot_type = nil
  8179. m.addbot_type = nil
  8180. }
  8181. // Where appends a list predicates to the ChatRecordsMutation builder.
  8182. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8183. m.predicates = append(m.predicates, ps...)
  8184. }
  8185. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8186. // users can use type-assertion to append predicates that do not depend on any generated package.
  8187. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8188. p := make([]predicate.ChatRecords, len(ps))
  8189. for i := range ps {
  8190. p[i] = ps[i]
  8191. }
  8192. m.Where(p...)
  8193. }
  8194. // Op returns the operation name.
  8195. func (m *ChatRecordsMutation) Op() Op {
  8196. return m.op
  8197. }
  8198. // SetOp allows setting the mutation operation.
  8199. func (m *ChatRecordsMutation) SetOp(op Op) {
  8200. m.op = op
  8201. }
  8202. // Type returns the node type of this mutation (ChatRecords).
  8203. func (m *ChatRecordsMutation) Type() string {
  8204. return m.typ
  8205. }
  8206. // Fields returns all fields that were changed during this mutation. Note that in
  8207. // order to get all numeric fields that were incremented/decremented, call
  8208. // AddedFields().
  8209. func (m *ChatRecordsMutation) Fields() []string {
  8210. fields := make([]string, 0, 9)
  8211. if m.created_at != nil {
  8212. fields = append(fields, chatrecords.FieldCreatedAt)
  8213. }
  8214. if m.updated_at != nil {
  8215. fields = append(fields, chatrecords.FieldUpdatedAt)
  8216. }
  8217. if m.deleted_at != nil {
  8218. fields = append(fields, chatrecords.FieldDeletedAt)
  8219. }
  8220. if m.content != nil {
  8221. fields = append(fields, chatrecords.FieldContent)
  8222. }
  8223. if m.content_type != nil {
  8224. fields = append(fields, chatrecords.FieldContentType)
  8225. }
  8226. if m.session_id != nil {
  8227. fields = append(fields, chatrecords.FieldSessionID)
  8228. }
  8229. if m.user_id != nil {
  8230. fields = append(fields, chatrecords.FieldUserID)
  8231. }
  8232. if m.bot_id != nil {
  8233. fields = append(fields, chatrecords.FieldBotID)
  8234. }
  8235. if m.bot_type != nil {
  8236. fields = append(fields, chatrecords.FieldBotType)
  8237. }
  8238. return fields
  8239. }
  8240. // Field returns the value of a field with the given name. The second boolean
  8241. // return value indicates that this field was not set, or was not defined in the
  8242. // schema.
  8243. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8244. switch name {
  8245. case chatrecords.FieldCreatedAt:
  8246. return m.CreatedAt()
  8247. case chatrecords.FieldUpdatedAt:
  8248. return m.UpdatedAt()
  8249. case chatrecords.FieldDeletedAt:
  8250. return m.DeletedAt()
  8251. case chatrecords.FieldContent:
  8252. return m.Content()
  8253. case chatrecords.FieldContentType:
  8254. return m.ContentType()
  8255. case chatrecords.FieldSessionID:
  8256. return m.SessionID()
  8257. case chatrecords.FieldUserID:
  8258. return m.UserID()
  8259. case chatrecords.FieldBotID:
  8260. return m.BotID()
  8261. case chatrecords.FieldBotType:
  8262. return m.BotType()
  8263. }
  8264. return nil, false
  8265. }
  8266. // OldField returns the old value of the field from the database. An error is
  8267. // returned if the mutation operation is not UpdateOne, or the query to the
  8268. // database failed.
  8269. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8270. switch name {
  8271. case chatrecords.FieldCreatedAt:
  8272. return m.OldCreatedAt(ctx)
  8273. case chatrecords.FieldUpdatedAt:
  8274. return m.OldUpdatedAt(ctx)
  8275. case chatrecords.FieldDeletedAt:
  8276. return m.OldDeletedAt(ctx)
  8277. case chatrecords.FieldContent:
  8278. return m.OldContent(ctx)
  8279. case chatrecords.FieldContentType:
  8280. return m.OldContentType(ctx)
  8281. case chatrecords.FieldSessionID:
  8282. return m.OldSessionID(ctx)
  8283. case chatrecords.FieldUserID:
  8284. return m.OldUserID(ctx)
  8285. case chatrecords.FieldBotID:
  8286. return m.OldBotID(ctx)
  8287. case chatrecords.FieldBotType:
  8288. return m.OldBotType(ctx)
  8289. }
  8290. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8291. }
  8292. // SetField sets the value of a field with the given name. It returns an error if
  8293. // the field is not defined in the schema, or if the type mismatched the field
  8294. // type.
  8295. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8296. switch name {
  8297. case chatrecords.FieldCreatedAt:
  8298. v, ok := value.(time.Time)
  8299. if !ok {
  8300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8301. }
  8302. m.SetCreatedAt(v)
  8303. return nil
  8304. case chatrecords.FieldUpdatedAt:
  8305. v, ok := value.(time.Time)
  8306. if !ok {
  8307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8308. }
  8309. m.SetUpdatedAt(v)
  8310. return nil
  8311. case chatrecords.FieldDeletedAt:
  8312. v, ok := value.(time.Time)
  8313. if !ok {
  8314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8315. }
  8316. m.SetDeletedAt(v)
  8317. return nil
  8318. case chatrecords.FieldContent:
  8319. v, ok := value.(string)
  8320. if !ok {
  8321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8322. }
  8323. m.SetContent(v)
  8324. return nil
  8325. case chatrecords.FieldContentType:
  8326. v, ok := value.(uint8)
  8327. if !ok {
  8328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8329. }
  8330. m.SetContentType(v)
  8331. return nil
  8332. case chatrecords.FieldSessionID:
  8333. v, ok := value.(uint64)
  8334. if !ok {
  8335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8336. }
  8337. m.SetSessionID(v)
  8338. return nil
  8339. case chatrecords.FieldUserID:
  8340. v, ok := value.(uint64)
  8341. if !ok {
  8342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8343. }
  8344. m.SetUserID(v)
  8345. return nil
  8346. case chatrecords.FieldBotID:
  8347. v, ok := value.(uint64)
  8348. if !ok {
  8349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8350. }
  8351. m.SetBotID(v)
  8352. return nil
  8353. case chatrecords.FieldBotType:
  8354. v, ok := value.(uint8)
  8355. if !ok {
  8356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8357. }
  8358. m.SetBotType(v)
  8359. return nil
  8360. }
  8361. return fmt.Errorf("unknown ChatRecords field %s", name)
  8362. }
  8363. // AddedFields returns all numeric fields that were incremented/decremented during
  8364. // this mutation.
  8365. func (m *ChatRecordsMutation) AddedFields() []string {
  8366. var fields []string
  8367. if m.addcontent_type != nil {
  8368. fields = append(fields, chatrecords.FieldContentType)
  8369. }
  8370. if m.addsession_id != nil {
  8371. fields = append(fields, chatrecords.FieldSessionID)
  8372. }
  8373. if m.adduser_id != nil {
  8374. fields = append(fields, chatrecords.FieldUserID)
  8375. }
  8376. if m.addbot_id != nil {
  8377. fields = append(fields, chatrecords.FieldBotID)
  8378. }
  8379. if m.addbot_type != nil {
  8380. fields = append(fields, chatrecords.FieldBotType)
  8381. }
  8382. return fields
  8383. }
  8384. // AddedField returns the numeric value that was incremented/decremented on a field
  8385. // with the given name. The second boolean return value indicates that this field
  8386. // was not set, or was not defined in the schema.
  8387. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8388. switch name {
  8389. case chatrecords.FieldContentType:
  8390. return m.AddedContentType()
  8391. case chatrecords.FieldSessionID:
  8392. return m.AddedSessionID()
  8393. case chatrecords.FieldUserID:
  8394. return m.AddedUserID()
  8395. case chatrecords.FieldBotID:
  8396. return m.AddedBotID()
  8397. case chatrecords.FieldBotType:
  8398. return m.AddedBotType()
  8399. }
  8400. return nil, false
  8401. }
  8402. // AddField adds the value to the field with the given name. It returns an error if
  8403. // the field is not defined in the schema, or if the type mismatched the field
  8404. // type.
  8405. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8406. switch name {
  8407. case chatrecords.FieldContentType:
  8408. v, ok := value.(int8)
  8409. if !ok {
  8410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8411. }
  8412. m.AddContentType(v)
  8413. return nil
  8414. case chatrecords.FieldSessionID:
  8415. v, ok := value.(int64)
  8416. if !ok {
  8417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8418. }
  8419. m.AddSessionID(v)
  8420. return nil
  8421. case chatrecords.FieldUserID:
  8422. v, ok := value.(int64)
  8423. if !ok {
  8424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8425. }
  8426. m.AddUserID(v)
  8427. return nil
  8428. case chatrecords.FieldBotID:
  8429. v, ok := value.(int64)
  8430. if !ok {
  8431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8432. }
  8433. m.AddBotID(v)
  8434. return nil
  8435. case chatrecords.FieldBotType:
  8436. v, ok := value.(int8)
  8437. if !ok {
  8438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8439. }
  8440. m.AddBotType(v)
  8441. return nil
  8442. }
  8443. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8444. }
  8445. // ClearedFields returns all nullable fields that were cleared during this
  8446. // mutation.
  8447. func (m *ChatRecordsMutation) ClearedFields() []string {
  8448. var fields []string
  8449. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8450. fields = append(fields, chatrecords.FieldDeletedAt)
  8451. }
  8452. return fields
  8453. }
  8454. // FieldCleared returns a boolean indicating if a field with the given name was
  8455. // cleared in this mutation.
  8456. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8457. _, ok := m.clearedFields[name]
  8458. return ok
  8459. }
  8460. // ClearField clears the value of the field with the given name. It returns an
  8461. // error if the field is not defined in the schema.
  8462. func (m *ChatRecordsMutation) ClearField(name string) error {
  8463. switch name {
  8464. case chatrecords.FieldDeletedAt:
  8465. m.ClearDeletedAt()
  8466. return nil
  8467. }
  8468. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8469. }
  8470. // ResetField resets all changes in the mutation for the field with the given name.
  8471. // It returns an error if the field is not defined in the schema.
  8472. func (m *ChatRecordsMutation) ResetField(name string) error {
  8473. switch name {
  8474. case chatrecords.FieldCreatedAt:
  8475. m.ResetCreatedAt()
  8476. return nil
  8477. case chatrecords.FieldUpdatedAt:
  8478. m.ResetUpdatedAt()
  8479. return nil
  8480. case chatrecords.FieldDeletedAt:
  8481. m.ResetDeletedAt()
  8482. return nil
  8483. case chatrecords.FieldContent:
  8484. m.ResetContent()
  8485. return nil
  8486. case chatrecords.FieldContentType:
  8487. m.ResetContentType()
  8488. return nil
  8489. case chatrecords.FieldSessionID:
  8490. m.ResetSessionID()
  8491. return nil
  8492. case chatrecords.FieldUserID:
  8493. m.ResetUserID()
  8494. return nil
  8495. case chatrecords.FieldBotID:
  8496. m.ResetBotID()
  8497. return nil
  8498. case chatrecords.FieldBotType:
  8499. m.ResetBotType()
  8500. return nil
  8501. }
  8502. return fmt.Errorf("unknown ChatRecords field %s", name)
  8503. }
  8504. // AddedEdges returns all edge names that were set/added in this mutation.
  8505. func (m *ChatRecordsMutation) AddedEdges() []string {
  8506. edges := make([]string, 0, 0)
  8507. return edges
  8508. }
  8509. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8510. // name in this mutation.
  8511. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8512. return nil
  8513. }
  8514. // RemovedEdges returns all edge names that were removed in this mutation.
  8515. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8516. edges := make([]string, 0, 0)
  8517. return edges
  8518. }
  8519. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8520. // the given name in this mutation.
  8521. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8522. return nil
  8523. }
  8524. // ClearedEdges returns all edge names that were cleared in this mutation.
  8525. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8526. edges := make([]string, 0, 0)
  8527. return edges
  8528. }
  8529. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8530. // was cleared in this mutation.
  8531. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8532. return false
  8533. }
  8534. // ClearEdge clears the value of the edge with the given name. It returns an error
  8535. // if that edge is not defined in the schema.
  8536. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8537. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8538. }
  8539. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8540. // It returns an error if the edge is not defined in the schema.
  8541. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8542. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8543. }
  8544. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8545. type ChatSessionMutation struct {
  8546. config
  8547. op Op
  8548. typ string
  8549. id *uint64
  8550. created_at *time.Time
  8551. updated_at *time.Time
  8552. deleted_at *time.Time
  8553. name *string
  8554. user_id *uint64
  8555. adduser_id *int64
  8556. bot_id *uint64
  8557. addbot_id *int64
  8558. bot_type *uint8
  8559. addbot_type *int8
  8560. clearedFields map[string]struct{}
  8561. done bool
  8562. oldValue func(context.Context) (*ChatSession, error)
  8563. predicates []predicate.ChatSession
  8564. }
  8565. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8566. // chatsessionOption allows management of the mutation configuration using functional options.
  8567. type chatsessionOption func(*ChatSessionMutation)
  8568. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8569. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8570. m := &ChatSessionMutation{
  8571. config: c,
  8572. op: op,
  8573. typ: TypeChatSession,
  8574. clearedFields: make(map[string]struct{}),
  8575. }
  8576. for _, opt := range opts {
  8577. opt(m)
  8578. }
  8579. return m
  8580. }
  8581. // withChatSessionID sets the ID field of the mutation.
  8582. func withChatSessionID(id uint64) chatsessionOption {
  8583. return func(m *ChatSessionMutation) {
  8584. var (
  8585. err error
  8586. once sync.Once
  8587. value *ChatSession
  8588. )
  8589. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8590. once.Do(func() {
  8591. if m.done {
  8592. err = errors.New("querying old values post mutation is not allowed")
  8593. } else {
  8594. value, err = m.Client().ChatSession.Get(ctx, id)
  8595. }
  8596. })
  8597. return value, err
  8598. }
  8599. m.id = &id
  8600. }
  8601. }
  8602. // withChatSession sets the old ChatSession of the mutation.
  8603. func withChatSession(node *ChatSession) chatsessionOption {
  8604. return func(m *ChatSessionMutation) {
  8605. m.oldValue = func(context.Context) (*ChatSession, error) {
  8606. return node, nil
  8607. }
  8608. m.id = &node.ID
  8609. }
  8610. }
  8611. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8612. // executed in a transaction (ent.Tx), a transactional client is returned.
  8613. func (m ChatSessionMutation) Client() *Client {
  8614. client := &Client{config: m.config}
  8615. client.init()
  8616. return client
  8617. }
  8618. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8619. // it returns an error otherwise.
  8620. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8621. if _, ok := m.driver.(*txDriver); !ok {
  8622. return nil, errors.New("ent: mutation is not running in a transaction")
  8623. }
  8624. tx := &Tx{config: m.config}
  8625. tx.init()
  8626. return tx, nil
  8627. }
  8628. // SetID sets the value of the id field. Note that this
  8629. // operation is only accepted on creation of ChatSession entities.
  8630. func (m *ChatSessionMutation) SetID(id uint64) {
  8631. m.id = &id
  8632. }
  8633. // ID returns the ID value in the mutation. Note that the ID is only available
  8634. // if it was provided to the builder or after it was returned from the database.
  8635. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8636. if m.id == nil {
  8637. return
  8638. }
  8639. return *m.id, true
  8640. }
  8641. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8642. // That means, if the mutation is applied within a transaction with an isolation level such
  8643. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8644. // or updated by the mutation.
  8645. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8646. switch {
  8647. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8648. id, exists := m.ID()
  8649. if exists {
  8650. return []uint64{id}, nil
  8651. }
  8652. fallthrough
  8653. case m.op.Is(OpUpdate | OpDelete):
  8654. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8655. default:
  8656. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8657. }
  8658. }
  8659. // SetCreatedAt sets the "created_at" field.
  8660. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8661. m.created_at = &t
  8662. }
  8663. // CreatedAt returns the value of the "created_at" field in the mutation.
  8664. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8665. v := m.created_at
  8666. if v == nil {
  8667. return
  8668. }
  8669. return *v, true
  8670. }
  8671. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8672. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8674. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8675. if !m.op.Is(OpUpdateOne) {
  8676. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8677. }
  8678. if m.id == nil || m.oldValue == nil {
  8679. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8680. }
  8681. oldValue, err := m.oldValue(ctx)
  8682. if err != nil {
  8683. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8684. }
  8685. return oldValue.CreatedAt, nil
  8686. }
  8687. // ResetCreatedAt resets all changes to the "created_at" field.
  8688. func (m *ChatSessionMutation) ResetCreatedAt() {
  8689. m.created_at = nil
  8690. }
  8691. // SetUpdatedAt sets the "updated_at" field.
  8692. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8693. m.updated_at = &t
  8694. }
  8695. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8696. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8697. v := m.updated_at
  8698. if v == nil {
  8699. return
  8700. }
  8701. return *v, true
  8702. }
  8703. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8704. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8706. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8707. if !m.op.Is(OpUpdateOne) {
  8708. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8709. }
  8710. if m.id == nil || m.oldValue == nil {
  8711. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8712. }
  8713. oldValue, err := m.oldValue(ctx)
  8714. if err != nil {
  8715. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8716. }
  8717. return oldValue.UpdatedAt, nil
  8718. }
  8719. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8720. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8721. m.updated_at = nil
  8722. }
  8723. // SetDeletedAt sets the "deleted_at" field.
  8724. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8725. m.deleted_at = &t
  8726. }
  8727. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8728. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8729. v := m.deleted_at
  8730. if v == nil {
  8731. return
  8732. }
  8733. return *v, true
  8734. }
  8735. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8736. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8738. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8739. if !m.op.Is(OpUpdateOne) {
  8740. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8741. }
  8742. if m.id == nil || m.oldValue == nil {
  8743. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8744. }
  8745. oldValue, err := m.oldValue(ctx)
  8746. if err != nil {
  8747. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8748. }
  8749. return oldValue.DeletedAt, nil
  8750. }
  8751. // ClearDeletedAt clears the value of the "deleted_at" field.
  8752. func (m *ChatSessionMutation) ClearDeletedAt() {
  8753. m.deleted_at = nil
  8754. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8755. }
  8756. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8757. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  8758. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  8759. return ok
  8760. }
  8761. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8762. func (m *ChatSessionMutation) ResetDeletedAt() {
  8763. m.deleted_at = nil
  8764. delete(m.clearedFields, chatsession.FieldDeletedAt)
  8765. }
  8766. // SetName sets the "name" field.
  8767. func (m *ChatSessionMutation) SetName(s string) {
  8768. m.name = &s
  8769. }
  8770. // Name returns the value of the "name" field in the mutation.
  8771. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  8772. v := m.name
  8773. if v == nil {
  8774. return
  8775. }
  8776. return *v, true
  8777. }
  8778. // OldName returns the old "name" field's value of the ChatSession entity.
  8779. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8781. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  8782. if !m.op.Is(OpUpdateOne) {
  8783. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8784. }
  8785. if m.id == nil || m.oldValue == nil {
  8786. return v, errors.New("OldName requires an ID field in the mutation")
  8787. }
  8788. oldValue, err := m.oldValue(ctx)
  8789. if err != nil {
  8790. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8791. }
  8792. return oldValue.Name, nil
  8793. }
  8794. // ResetName resets all changes to the "name" field.
  8795. func (m *ChatSessionMutation) ResetName() {
  8796. m.name = nil
  8797. }
  8798. // SetUserID sets the "user_id" field.
  8799. func (m *ChatSessionMutation) SetUserID(u uint64) {
  8800. m.user_id = &u
  8801. m.adduser_id = nil
  8802. }
  8803. // UserID returns the value of the "user_id" field in the mutation.
  8804. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  8805. v := m.user_id
  8806. if v == nil {
  8807. return
  8808. }
  8809. return *v, true
  8810. }
  8811. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  8812. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8814. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8815. if !m.op.Is(OpUpdateOne) {
  8816. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8817. }
  8818. if m.id == nil || m.oldValue == nil {
  8819. return v, errors.New("OldUserID requires an ID field in the mutation")
  8820. }
  8821. oldValue, err := m.oldValue(ctx)
  8822. if err != nil {
  8823. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8824. }
  8825. return oldValue.UserID, nil
  8826. }
  8827. // AddUserID adds u to the "user_id" field.
  8828. func (m *ChatSessionMutation) AddUserID(u int64) {
  8829. if m.adduser_id != nil {
  8830. *m.adduser_id += u
  8831. } else {
  8832. m.adduser_id = &u
  8833. }
  8834. }
  8835. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8836. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  8837. v := m.adduser_id
  8838. if v == nil {
  8839. return
  8840. }
  8841. return *v, true
  8842. }
  8843. // ResetUserID resets all changes to the "user_id" field.
  8844. func (m *ChatSessionMutation) ResetUserID() {
  8845. m.user_id = nil
  8846. m.adduser_id = nil
  8847. }
  8848. // SetBotID sets the "bot_id" field.
  8849. func (m *ChatSessionMutation) SetBotID(u uint64) {
  8850. m.bot_id = &u
  8851. m.addbot_id = nil
  8852. }
  8853. // BotID returns the value of the "bot_id" field in the mutation.
  8854. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  8855. v := m.bot_id
  8856. if v == nil {
  8857. return
  8858. }
  8859. return *v, true
  8860. }
  8861. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  8862. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8864. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8865. if !m.op.Is(OpUpdateOne) {
  8866. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8867. }
  8868. if m.id == nil || m.oldValue == nil {
  8869. return v, errors.New("OldBotID requires an ID field in the mutation")
  8870. }
  8871. oldValue, err := m.oldValue(ctx)
  8872. if err != nil {
  8873. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8874. }
  8875. return oldValue.BotID, nil
  8876. }
  8877. // AddBotID adds u to the "bot_id" field.
  8878. func (m *ChatSessionMutation) AddBotID(u int64) {
  8879. if m.addbot_id != nil {
  8880. *m.addbot_id += u
  8881. } else {
  8882. m.addbot_id = &u
  8883. }
  8884. }
  8885. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8886. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  8887. v := m.addbot_id
  8888. if v == nil {
  8889. return
  8890. }
  8891. return *v, true
  8892. }
  8893. // ResetBotID resets all changes to the "bot_id" field.
  8894. func (m *ChatSessionMutation) ResetBotID() {
  8895. m.bot_id = nil
  8896. m.addbot_id = nil
  8897. }
  8898. // SetBotType sets the "bot_type" field.
  8899. func (m *ChatSessionMutation) SetBotType(u uint8) {
  8900. m.bot_type = &u
  8901. m.addbot_type = nil
  8902. }
  8903. // BotType returns the value of the "bot_type" field in the mutation.
  8904. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  8905. v := m.bot_type
  8906. if v == nil {
  8907. return
  8908. }
  8909. return *v, true
  8910. }
  8911. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  8912. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8914. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8915. if !m.op.Is(OpUpdateOne) {
  8916. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8917. }
  8918. if m.id == nil || m.oldValue == nil {
  8919. return v, errors.New("OldBotType requires an ID field in the mutation")
  8920. }
  8921. oldValue, err := m.oldValue(ctx)
  8922. if err != nil {
  8923. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8924. }
  8925. return oldValue.BotType, nil
  8926. }
  8927. // AddBotType adds u to the "bot_type" field.
  8928. func (m *ChatSessionMutation) AddBotType(u int8) {
  8929. if m.addbot_type != nil {
  8930. *m.addbot_type += u
  8931. } else {
  8932. m.addbot_type = &u
  8933. }
  8934. }
  8935. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8936. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  8937. v := m.addbot_type
  8938. if v == nil {
  8939. return
  8940. }
  8941. return *v, true
  8942. }
  8943. // ResetBotType resets all changes to the "bot_type" field.
  8944. func (m *ChatSessionMutation) ResetBotType() {
  8945. m.bot_type = nil
  8946. m.addbot_type = nil
  8947. }
  8948. // Where appends a list predicates to the ChatSessionMutation builder.
  8949. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  8950. m.predicates = append(m.predicates, ps...)
  8951. }
  8952. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  8953. // users can use type-assertion to append predicates that do not depend on any generated package.
  8954. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  8955. p := make([]predicate.ChatSession, len(ps))
  8956. for i := range ps {
  8957. p[i] = ps[i]
  8958. }
  8959. m.Where(p...)
  8960. }
  8961. // Op returns the operation name.
  8962. func (m *ChatSessionMutation) Op() Op {
  8963. return m.op
  8964. }
  8965. // SetOp allows setting the mutation operation.
  8966. func (m *ChatSessionMutation) SetOp(op Op) {
  8967. m.op = op
  8968. }
  8969. // Type returns the node type of this mutation (ChatSession).
  8970. func (m *ChatSessionMutation) Type() string {
  8971. return m.typ
  8972. }
  8973. // Fields returns all fields that were changed during this mutation. Note that in
  8974. // order to get all numeric fields that were incremented/decremented, call
  8975. // AddedFields().
  8976. func (m *ChatSessionMutation) Fields() []string {
  8977. fields := make([]string, 0, 7)
  8978. if m.created_at != nil {
  8979. fields = append(fields, chatsession.FieldCreatedAt)
  8980. }
  8981. if m.updated_at != nil {
  8982. fields = append(fields, chatsession.FieldUpdatedAt)
  8983. }
  8984. if m.deleted_at != nil {
  8985. fields = append(fields, chatsession.FieldDeletedAt)
  8986. }
  8987. if m.name != nil {
  8988. fields = append(fields, chatsession.FieldName)
  8989. }
  8990. if m.user_id != nil {
  8991. fields = append(fields, chatsession.FieldUserID)
  8992. }
  8993. if m.bot_id != nil {
  8994. fields = append(fields, chatsession.FieldBotID)
  8995. }
  8996. if m.bot_type != nil {
  8997. fields = append(fields, chatsession.FieldBotType)
  8998. }
  8999. return fields
  9000. }
  9001. // Field returns the value of a field with the given name. The second boolean
  9002. // return value indicates that this field was not set, or was not defined in the
  9003. // schema.
  9004. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9005. switch name {
  9006. case chatsession.FieldCreatedAt:
  9007. return m.CreatedAt()
  9008. case chatsession.FieldUpdatedAt:
  9009. return m.UpdatedAt()
  9010. case chatsession.FieldDeletedAt:
  9011. return m.DeletedAt()
  9012. case chatsession.FieldName:
  9013. return m.Name()
  9014. case chatsession.FieldUserID:
  9015. return m.UserID()
  9016. case chatsession.FieldBotID:
  9017. return m.BotID()
  9018. case chatsession.FieldBotType:
  9019. return m.BotType()
  9020. }
  9021. return nil, false
  9022. }
  9023. // OldField returns the old value of the field from the database. An error is
  9024. // returned if the mutation operation is not UpdateOne, or the query to the
  9025. // database failed.
  9026. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9027. switch name {
  9028. case chatsession.FieldCreatedAt:
  9029. return m.OldCreatedAt(ctx)
  9030. case chatsession.FieldUpdatedAt:
  9031. return m.OldUpdatedAt(ctx)
  9032. case chatsession.FieldDeletedAt:
  9033. return m.OldDeletedAt(ctx)
  9034. case chatsession.FieldName:
  9035. return m.OldName(ctx)
  9036. case chatsession.FieldUserID:
  9037. return m.OldUserID(ctx)
  9038. case chatsession.FieldBotID:
  9039. return m.OldBotID(ctx)
  9040. case chatsession.FieldBotType:
  9041. return m.OldBotType(ctx)
  9042. }
  9043. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9044. }
  9045. // SetField sets the value of a field with the given name. It returns an error if
  9046. // the field is not defined in the schema, or if the type mismatched the field
  9047. // type.
  9048. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9049. switch name {
  9050. case chatsession.FieldCreatedAt:
  9051. v, ok := value.(time.Time)
  9052. if !ok {
  9053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9054. }
  9055. m.SetCreatedAt(v)
  9056. return nil
  9057. case chatsession.FieldUpdatedAt:
  9058. v, ok := value.(time.Time)
  9059. if !ok {
  9060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9061. }
  9062. m.SetUpdatedAt(v)
  9063. return nil
  9064. case chatsession.FieldDeletedAt:
  9065. v, ok := value.(time.Time)
  9066. if !ok {
  9067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9068. }
  9069. m.SetDeletedAt(v)
  9070. return nil
  9071. case chatsession.FieldName:
  9072. v, ok := value.(string)
  9073. if !ok {
  9074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9075. }
  9076. m.SetName(v)
  9077. return nil
  9078. case chatsession.FieldUserID:
  9079. v, ok := value.(uint64)
  9080. if !ok {
  9081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9082. }
  9083. m.SetUserID(v)
  9084. return nil
  9085. case chatsession.FieldBotID:
  9086. v, ok := value.(uint64)
  9087. if !ok {
  9088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9089. }
  9090. m.SetBotID(v)
  9091. return nil
  9092. case chatsession.FieldBotType:
  9093. v, ok := value.(uint8)
  9094. if !ok {
  9095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9096. }
  9097. m.SetBotType(v)
  9098. return nil
  9099. }
  9100. return fmt.Errorf("unknown ChatSession field %s", name)
  9101. }
  9102. // AddedFields returns all numeric fields that were incremented/decremented during
  9103. // this mutation.
  9104. func (m *ChatSessionMutation) AddedFields() []string {
  9105. var fields []string
  9106. if m.adduser_id != nil {
  9107. fields = append(fields, chatsession.FieldUserID)
  9108. }
  9109. if m.addbot_id != nil {
  9110. fields = append(fields, chatsession.FieldBotID)
  9111. }
  9112. if m.addbot_type != nil {
  9113. fields = append(fields, chatsession.FieldBotType)
  9114. }
  9115. return fields
  9116. }
  9117. // AddedField returns the numeric value that was incremented/decremented on a field
  9118. // with the given name. The second boolean return value indicates that this field
  9119. // was not set, or was not defined in the schema.
  9120. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9121. switch name {
  9122. case chatsession.FieldUserID:
  9123. return m.AddedUserID()
  9124. case chatsession.FieldBotID:
  9125. return m.AddedBotID()
  9126. case chatsession.FieldBotType:
  9127. return m.AddedBotType()
  9128. }
  9129. return nil, false
  9130. }
  9131. // AddField adds the value to the field with the given name. It returns an error if
  9132. // the field is not defined in the schema, or if the type mismatched the field
  9133. // type.
  9134. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9135. switch name {
  9136. case chatsession.FieldUserID:
  9137. v, ok := value.(int64)
  9138. if !ok {
  9139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9140. }
  9141. m.AddUserID(v)
  9142. return nil
  9143. case chatsession.FieldBotID:
  9144. v, ok := value.(int64)
  9145. if !ok {
  9146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9147. }
  9148. m.AddBotID(v)
  9149. return nil
  9150. case chatsession.FieldBotType:
  9151. v, ok := value.(int8)
  9152. if !ok {
  9153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9154. }
  9155. m.AddBotType(v)
  9156. return nil
  9157. }
  9158. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9159. }
  9160. // ClearedFields returns all nullable fields that were cleared during this
  9161. // mutation.
  9162. func (m *ChatSessionMutation) ClearedFields() []string {
  9163. var fields []string
  9164. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9165. fields = append(fields, chatsession.FieldDeletedAt)
  9166. }
  9167. return fields
  9168. }
  9169. // FieldCleared returns a boolean indicating if a field with the given name was
  9170. // cleared in this mutation.
  9171. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9172. _, ok := m.clearedFields[name]
  9173. return ok
  9174. }
  9175. // ClearField clears the value of the field with the given name. It returns an
  9176. // error if the field is not defined in the schema.
  9177. func (m *ChatSessionMutation) ClearField(name string) error {
  9178. switch name {
  9179. case chatsession.FieldDeletedAt:
  9180. m.ClearDeletedAt()
  9181. return nil
  9182. }
  9183. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9184. }
  9185. // ResetField resets all changes in the mutation for the field with the given name.
  9186. // It returns an error if the field is not defined in the schema.
  9187. func (m *ChatSessionMutation) ResetField(name string) error {
  9188. switch name {
  9189. case chatsession.FieldCreatedAt:
  9190. m.ResetCreatedAt()
  9191. return nil
  9192. case chatsession.FieldUpdatedAt:
  9193. m.ResetUpdatedAt()
  9194. return nil
  9195. case chatsession.FieldDeletedAt:
  9196. m.ResetDeletedAt()
  9197. return nil
  9198. case chatsession.FieldName:
  9199. m.ResetName()
  9200. return nil
  9201. case chatsession.FieldUserID:
  9202. m.ResetUserID()
  9203. return nil
  9204. case chatsession.FieldBotID:
  9205. m.ResetBotID()
  9206. return nil
  9207. case chatsession.FieldBotType:
  9208. m.ResetBotType()
  9209. return nil
  9210. }
  9211. return fmt.Errorf("unknown ChatSession field %s", name)
  9212. }
  9213. // AddedEdges returns all edge names that were set/added in this mutation.
  9214. func (m *ChatSessionMutation) AddedEdges() []string {
  9215. edges := make([]string, 0, 0)
  9216. return edges
  9217. }
  9218. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9219. // name in this mutation.
  9220. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9221. return nil
  9222. }
  9223. // RemovedEdges returns all edge names that were removed in this mutation.
  9224. func (m *ChatSessionMutation) RemovedEdges() []string {
  9225. edges := make([]string, 0, 0)
  9226. return edges
  9227. }
  9228. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9229. // the given name in this mutation.
  9230. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9231. return nil
  9232. }
  9233. // ClearedEdges returns all edge names that were cleared in this mutation.
  9234. func (m *ChatSessionMutation) ClearedEdges() []string {
  9235. edges := make([]string, 0, 0)
  9236. return edges
  9237. }
  9238. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9239. // was cleared in this mutation.
  9240. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9241. return false
  9242. }
  9243. // ClearEdge clears the value of the edge with the given name. It returns an error
  9244. // if that edge is not defined in the schema.
  9245. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9246. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9247. }
  9248. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9249. // It returns an error if the edge is not defined in the schema.
  9250. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9251. return fmt.Errorf("unknown ChatSession edge %s", name)
  9252. }
  9253. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  9254. type ContactMutation struct {
  9255. config
  9256. op Op
  9257. typ string
  9258. id *uint64
  9259. created_at *time.Time
  9260. updated_at *time.Time
  9261. status *uint8
  9262. addstatus *int8
  9263. deleted_at *time.Time
  9264. wx_wxid *string
  9265. _type *int
  9266. add_type *int
  9267. wxid *string
  9268. account *string
  9269. nickname *string
  9270. markname *string
  9271. headimg *string
  9272. sex *int
  9273. addsex *int
  9274. starrole *string
  9275. dontseeit *int
  9276. adddontseeit *int
  9277. dontseeme *int
  9278. adddontseeme *int
  9279. lag *string
  9280. gid *string
  9281. gname *string
  9282. v3 *string
  9283. organization_id *uint64
  9284. addorganization_id *int64
  9285. ctype *uint64
  9286. addctype *int64
  9287. cage *int
  9288. addcage *int
  9289. cname *string
  9290. carea *string
  9291. cbirthday *string
  9292. cbirtharea *string
  9293. cidcard_no *string
  9294. ctitle *string
  9295. cc *string
  9296. phone *string
  9297. clearedFields map[string]struct{}
  9298. contact_relationships map[uint64]struct{}
  9299. removedcontact_relationships map[uint64]struct{}
  9300. clearedcontact_relationships bool
  9301. contact_messages map[uint64]struct{}
  9302. removedcontact_messages map[uint64]struct{}
  9303. clearedcontact_messages bool
  9304. done bool
  9305. oldValue func(context.Context) (*Contact, error)
  9306. predicates []predicate.Contact
  9307. }
  9308. var _ ent.Mutation = (*ContactMutation)(nil)
  9309. // contactOption allows management of the mutation configuration using functional options.
  9310. type contactOption func(*ContactMutation)
  9311. // newContactMutation creates new mutation for the Contact entity.
  9312. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  9313. m := &ContactMutation{
  9314. config: c,
  9315. op: op,
  9316. typ: TypeContact,
  9317. clearedFields: make(map[string]struct{}),
  9318. }
  9319. for _, opt := range opts {
  9320. opt(m)
  9321. }
  9322. return m
  9323. }
  9324. // withContactID sets the ID field of the mutation.
  9325. func withContactID(id uint64) contactOption {
  9326. return func(m *ContactMutation) {
  9327. var (
  9328. err error
  9329. once sync.Once
  9330. value *Contact
  9331. )
  9332. m.oldValue = func(ctx context.Context) (*Contact, error) {
  9333. once.Do(func() {
  9334. if m.done {
  9335. err = errors.New("querying old values post mutation is not allowed")
  9336. } else {
  9337. value, err = m.Client().Contact.Get(ctx, id)
  9338. }
  9339. })
  9340. return value, err
  9341. }
  9342. m.id = &id
  9343. }
  9344. }
  9345. // withContact sets the old Contact of the mutation.
  9346. func withContact(node *Contact) contactOption {
  9347. return func(m *ContactMutation) {
  9348. m.oldValue = func(context.Context) (*Contact, error) {
  9349. return node, nil
  9350. }
  9351. m.id = &node.ID
  9352. }
  9353. }
  9354. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9355. // executed in a transaction (ent.Tx), a transactional client is returned.
  9356. func (m ContactMutation) Client() *Client {
  9357. client := &Client{config: m.config}
  9358. client.init()
  9359. return client
  9360. }
  9361. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9362. // it returns an error otherwise.
  9363. func (m ContactMutation) Tx() (*Tx, error) {
  9364. if _, ok := m.driver.(*txDriver); !ok {
  9365. return nil, errors.New("ent: mutation is not running in a transaction")
  9366. }
  9367. tx := &Tx{config: m.config}
  9368. tx.init()
  9369. return tx, nil
  9370. }
  9371. // SetID sets the value of the id field. Note that this
  9372. // operation is only accepted on creation of Contact entities.
  9373. func (m *ContactMutation) SetID(id uint64) {
  9374. m.id = &id
  9375. }
  9376. // ID returns the ID value in the mutation. Note that the ID is only available
  9377. // if it was provided to the builder or after it was returned from the database.
  9378. func (m *ContactMutation) ID() (id uint64, exists bool) {
  9379. if m.id == nil {
  9380. return
  9381. }
  9382. return *m.id, true
  9383. }
  9384. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9385. // That means, if the mutation is applied within a transaction with an isolation level such
  9386. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9387. // or updated by the mutation.
  9388. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  9389. switch {
  9390. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9391. id, exists := m.ID()
  9392. if exists {
  9393. return []uint64{id}, nil
  9394. }
  9395. fallthrough
  9396. case m.op.Is(OpUpdate | OpDelete):
  9397. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  9398. default:
  9399. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9400. }
  9401. }
  9402. // SetCreatedAt sets the "created_at" field.
  9403. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  9404. m.created_at = &t
  9405. }
  9406. // CreatedAt returns the value of the "created_at" field in the mutation.
  9407. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  9408. v := m.created_at
  9409. if v == nil {
  9410. return
  9411. }
  9412. return *v, true
  9413. }
  9414. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  9415. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9417. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9418. if !m.op.Is(OpUpdateOne) {
  9419. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9420. }
  9421. if m.id == nil || m.oldValue == nil {
  9422. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9423. }
  9424. oldValue, err := m.oldValue(ctx)
  9425. if err != nil {
  9426. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9427. }
  9428. return oldValue.CreatedAt, nil
  9429. }
  9430. // ResetCreatedAt resets all changes to the "created_at" field.
  9431. func (m *ContactMutation) ResetCreatedAt() {
  9432. m.created_at = nil
  9433. }
  9434. // SetUpdatedAt sets the "updated_at" field.
  9435. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  9436. m.updated_at = &t
  9437. }
  9438. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9439. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  9440. v := m.updated_at
  9441. if v == nil {
  9442. return
  9443. }
  9444. return *v, true
  9445. }
  9446. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  9447. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9449. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9450. if !m.op.Is(OpUpdateOne) {
  9451. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9452. }
  9453. if m.id == nil || m.oldValue == nil {
  9454. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9455. }
  9456. oldValue, err := m.oldValue(ctx)
  9457. if err != nil {
  9458. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9459. }
  9460. return oldValue.UpdatedAt, nil
  9461. }
  9462. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9463. func (m *ContactMutation) ResetUpdatedAt() {
  9464. m.updated_at = nil
  9465. }
  9466. // SetStatus sets the "status" field.
  9467. func (m *ContactMutation) SetStatus(u uint8) {
  9468. m.status = &u
  9469. m.addstatus = nil
  9470. }
  9471. // Status returns the value of the "status" field in the mutation.
  9472. func (m *ContactMutation) Status() (r uint8, exists bool) {
  9473. v := m.status
  9474. if v == nil {
  9475. return
  9476. }
  9477. return *v, true
  9478. }
  9479. // OldStatus returns the old "status" field's value of the Contact entity.
  9480. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9482. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9483. if !m.op.Is(OpUpdateOne) {
  9484. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9485. }
  9486. if m.id == nil || m.oldValue == nil {
  9487. return v, errors.New("OldStatus requires an ID field in the mutation")
  9488. }
  9489. oldValue, err := m.oldValue(ctx)
  9490. if err != nil {
  9491. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9492. }
  9493. return oldValue.Status, nil
  9494. }
  9495. // AddStatus adds u to the "status" field.
  9496. func (m *ContactMutation) AddStatus(u int8) {
  9497. if m.addstatus != nil {
  9498. *m.addstatus += u
  9499. } else {
  9500. m.addstatus = &u
  9501. }
  9502. }
  9503. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9504. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  9505. v := m.addstatus
  9506. if v == nil {
  9507. return
  9508. }
  9509. return *v, true
  9510. }
  9511. // ClearStatus clears the value of the "status" field.
  9512. func (m *ContactMutation) ClearStatus() {
  9513. m.status = nil
  9514. m.addstatus = nil
  9515. m.clearedFields[contact.FieldStatus] = struct{}{}
  9516. }
  9517. // StatusCleared returns if the "status" field was cleared in this mutation.
  9518. func (m *ContactMutation) StatusCleared() bool {
  9519. _, ok := m.clearedFields[contact.FieldStatus]
  9520. return ok
  9521. }
  9522. // ResetStatus resets all changes to the "status" field.
  9523. func (m *ContactMutation) ResetStatus() {
  9524. m.status = nil
  9525. m.addstatus = nil
  9526. delete(m.clearedFields, contact.FieldStatus)
  9527. }
  9528. // SetDeletedAt sets the "deleted_at" field.
  9529. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  9530. m.deleted_at = &t
  9531. }
  9532. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9533. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  9534. v := m.deleted_at
  9535. if v == nil {
  9536. return
  9537. }
  9538. return *v, true
  9539. }
  9540. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  9541. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9543. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9544. if !m.op.Is(OpUpdateOne) {
  9545. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9546. }
  9547. if m.id == nil || m.oldValue == nil {
  9548. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9549. }
  9550. oldValue, err := m.oldValue(ctx)
  9551. if err != nil {
  9552. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9553. }
  9554. return oldValue.DeletedAt, nil
  9555. }
  9556. // ClearDeletedAt clears the value of the "deleted_at" field.
  9557. func (m *ContactMutation) ClearDeletedAt() {
  9558. m.deleted_at = nil
  9559. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  9560. }
  9561. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9562. func (m *ContactMutation) DeletedAtCleared() bool {
  9563. _, ok := m.clearedFields[contact.FieldDeletedAt]
  9564. return ok
  9565. }
  9566. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9567. func (m *ContactMutation) ResetDeletedAt() {
  9568. m.deleted_at = nil
  9569. delete(m.clearedFields, contact.FieldDeletedAt)
  9570. }
  9571. // SetWxWxid sets the "wx_wxid" field.
  9572. func (m *ContactMutation) SetWxWxid(s string) {
  9573. m.wx_wxid = &s
  9574. }
  9575. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  9576. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  9577. v := m.wx_wxid
  9578. if v == nil {
  9579. return
  9580. }
  9581. return *v, true
  9582. }
  9583. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  9584. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9586. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  9587. if !m.op.Is(OpUpdateOne) {
  9588. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  9589. }
  9590. if m.id == nil || m.oldValue == nil {
  9591. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  9592. }
  9593. oldValue, err := m.oldValue(ctx)
  9594. if err != nil {
  9595. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9596. }
  9597. return oldValue.WxWxid, nil
  9598. }
  9599. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9600. func (m *ContactMutation) ResetWxWxid() {
  9601. m.wx_wxid = nil
  9602. }
  9603. // SetType sets the "type" field.
  9604. func (m *ContactMutation) SetType(i int) {
  9605. m._type = &i
  9606. m.add_type = nil
  9607. }
  9608. // GetType returns the value of the "type" field in the mutation.
  9609. func (m *ContactMutation) GetType() (r int, exists bool) {
  9610. v := m._type
  9611. if v == nil {
  9612. return
  9613. }
  9614. return *v, true
  9615. }
  9616. // OldType returns the old "type" field's value of the Contact entity.
  9617. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9619. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  9620. if !m.op.Is(OpUpdateOne) {
  9621. return v, errors.New("OldType is only allowed on UpdateOne operations")
  9622. }
  9623. if m.id == nil || m.oldValue == nil {
  9624. return v, errors.New("OldType requires an ID field in the mutation")
  9625. }
  9626. oldValue, err := m.oldValue(ctx)
  9627. if err != nil {
  9628. return v, fmt.Errorf("querying old value for OldType: %w", err)
  9629. }
  9630. return oldValue.Type, nil
  9631. }
  9632. // AddType adds i to the "type" field.
  9633. func (m *ContactMutation) AddType(i int) {
  9634. if m.add_type != nil {
  9635. *m.add_type += i
  9636. } else {
  9637. m.add_type = &i
  9638. }
  9639. }
  9640. // AddedType returns the value that was added to the "type" field in this mutation.
  9641. func (m *ContactMutation) AddedType() (r int, exists bool) {
  9642. v := m.add_type
  9643. if v == nil {
  9644. return
  9645. }
  9646. return *v, true
  9647. }
  9648. // ClearType clears the value of the "type" field.
  9649. func (m *ContactMutation) ClearType() {
  9650. m._type = nil
  9651. m.add_type = nil
  9652. m.clearedFields[contact.FieldType] = struct{}{}
  9653. }
  9654. // TypeCleared returns if the "type" field was cleared in this mutation.
  9655. func (m *ContactMutation) TypeCleared() bool {
  9656. _, ok := m.clearedFields[contact.FieldType]
  9657. return ok
  9658. }
  9659. // ResetType resets all changes to the "type" field.
  9660. func (m *ContactMutation) ResetType() {
  9661. m._type = nil
  9662. m.add_type = nil
  9663. delete(m.clearedFields, contact.FieldType)
  9664. }
  9665. // SetWxid sets the "wxid" field.
  9666. func (m *ContactMutation) SetWxid(s string) {
  9667. m.wxid = &s
  9668. }
  9669. // Wxid returns the value of the "wxid" field in the mutation.
  9670. func (m *ContactMutation) Wxid() (r string, exists bool) {
  9671. v := m.wxid
  9672. if v == nil {
  9673. return
  9674. }
  9675. return *v, true
  9676. }
  9677. // OldWxid returns the old "wxid" field's value of the Contact entity.
  9678. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9680. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  9681. if !m.op.Is(OpUpdateOne) {
  9682. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9683. }
  9684. if m.id == nil || m.oldValue == nil {
  9685. return v, errors.New("OldWxid requires an ID field in the mutation")
  9686. }
  9687. oldValue, err := m.oldValue(ctx)
  9688. if err != nil {
  9689. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9690. }
  9691. return oldValue.Wxid, nil
  9692. }
  9693. // ResetWxid resets all changes to the "wxid" field.
  9694. func (m *ContactMutation) ResetWxid() {
  9695. m.wxid = nil
  9696. }
  9697. // SetAccount sets the "account" field.
  9698. func (m *ContactMutation) SetAccount(s string) {
  9699. m.account = &s
  9700. }
  9701. // Account returns the value of the "account" field in the mutation.
  9702. func (m *ContactMutation) Account() (r string, exists bool) {
  9703. v := m.account
  9704. if v == nil {
  9705. return
  9706. }
  9707. return *v, true
  9708. }
  9709. // OldAccount returns the old "account" field's value of the Contact entity.
  9710. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9712. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  9713. if !m.op.Is(OpUpdateOne) {
  9714. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  9715. }
  9716. if m.id == nil || m.oldValue == nil {
  9717. return v, errors.New("OldAccount requires an ID field in the mutation")
  9718. }
  9719. oldValue, err := m.oldValue(ctx)
  9720. if err != nil {
  9721. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  9722. }
  9723. return oldValue.Account, nil
  9724. }
  9725. // ResetAccount resets all changes to the "account" field.
  9726. func (m *ContactMutation) ResetAccount() {
  9727. m.account = nil
  9728. }
  9729. // SetNickname sets the "nickname" field.
  9730. func (m *ContactMutation) SetNickname(s string) {
  9731. m.nickname = &s
  9732. }
  9733. // Nickname returns the value of the "nickname" field in the mutation.
  9734. func (m *ContactMutation) Nickname() (r string, exists bool) {
  9735. v := m.nickname
  9736. if v == nil {
  9737. return
  9738. }
  9739. return *v, true
  9740. }
  9741. // OldNickname returns the old "nickname" field's value of the Contact entity.
  9742. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9744. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  9745. if !m.op.Is(OpUpdateOne) {
  9746. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  9747. }
  9748. if m.id == nil || m.oldValue == nil {
  9749. return v, errors.New("OldNickname requires an ID field in the mutation")
  9750. }
  9751. oldValue, err := m.oldValue(ctx)
  9752. if err != nil {
  9753. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  9754. }
  9755. return oldValue.Nickname, nil
  9756. }
  9757. // ResetNickname resets all changes to the "nickname" field.
  9758. func (m *ContactMutation) ResetNickname() {
  9759. m.nickname = nil
  9760. }
  9761. // SetMarkname sets the "markname" field.
  9762. func (m *ContactMutation) SetMarkname(s string) {
  9763. m.markname = &s
  9764. }
  9765. // Markname returns the value of the "markname" field in the mutation.
  9766. func (m *ContactMutation) Markname() (r string, exists bool) {
  9767. v := m.markname
  9768. if v == nil {
  9769. return
  9770. }
  9771. return *v, true
  9772. }
  9773. // OldMarkname returns the old "markname" field's value of the Contact entity.
  9774. // If the Contact 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 *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  9777. if !m.op.Is(OpUpdateOne) {
  9778. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  9779. }
  9780. if m.id == nil || m.oldValue == nil {
  9781. return v, errors.New("OldMarkname 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 OldMarkname: %w", err)
  9786. }
  9787. return oldValue.Markname, nil
  9788. }
  9789. // ResetMarkname resets all changes to the "markname" field.
  9790. func (m *ContactMutation) ResetMarkname() {
  9791. m.markname = nil
  9792. }
  9793. // SetHeadimg sets the "headimg" field.
  9794. func (m *ContactMutation) SetHeadimg(s string) {
  9795. m.headimg = &s
  9796. }
  9797. // Headimg returns the value of the "headimg" field in the mutation.
  9798. func (m *ContactMutation) Headimg() (r string, exists bool) {
  9799. v := m.headimg
  9800. if v == nil {
  9801. return
  9802. }
  9803. return *v, true
  9804. }
  9805. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  9806. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9808. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  9809. if !m.op.Is(OpUpdateOne) {
  9810. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  9811. }
  9812. if m.id == nil || m.oldValue == nil {
  9813. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  9814. }
  9815. oldValue, err := m.oldValue(ctx)
  9816. if err != nil {
  9817. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  9818. }
  9819. return oldValue.Headimg, nil
  9820. }
  9821. // ResetHeadimg resets all changes to the "headimg" field.
  9822. func (m *ContactMutation) ResetHeadimg() {
  9823. m.headimg = nil
  9824. }
  9825. // SetSex sets the "sex" field.
  9826. func (m *ContactMutation) SetSex(i int) {
  9827. m.sex = &i
  9828. m.addsex = nil
  9829. }
  9830. // Sex returns the value of the "sex" field in the mutation.
  9831. func (m *ContactMutation) Sex() (r int, exists bool) {
  9832. v := m.sex
  9833. if v == nil {
  9834. return
  9835. }
  9836. return *v, true
  9837. }
  9838. // OldSex returns the old "sex" field's value of the Contact entity.
  9839. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9841. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  9842. if !m.op.Is(OpUpdateOne) {
  9843. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  9844. }
  9845. if m.id == nil || m.oldValue == nil {
  9846. return v, errors.New("OldSex requires an ID field in the mutation")
  9847. }
  9848. oldValue, err := m.oldValue(ctx)
  9849. if err != nil {
  9850. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  9851. }
  9852. return oldValue.Sex, nil
  9853. }
  9854. // AddSex adds i to the "sex" field.
  9855. func (m *ContactMutation) AddSex(i int) {
  9856. if m.addsex != nil {
  9857. *m.addsex += i
  9858. } else {
  9859. m.addsex = &i
  9860. }
  9861. }
  9862. // AddedSex returns the value that was added to the "sex" field in this mutation.
  9863. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  9864. v := m.addsex
  9865. if v == nil {
  9866. return
  9867. }
  9868. return *v, true
  9869. }
  9870. // ResetSex resets all changes to the "sex" field.
  9871. func (m *ContactMutation) ResetSex() {
  9872. m.sex = nil
  9873. m.addsex = nil
  9874. }
  9875. // SetStarrole sets the "starrole" field.
  9876. func (m *ContactMutation) SetStarrole(s string) {
  9877. m.starrole = &s
  9878. }
  9879. // Starrole returns the value of the "starrole" field in the mutation.
  9880. func (m *ContactMutation) Starrole() (r string, exists bool) {
  9881. v := m.starrole
  9882. if v == nil {
  9883. return
  9884. }
  9885. return *v, true
  9886. }
  9887. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  9888. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9890. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  9891. if !m.op.Is(OpUpdateOne) {
  9892. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  9893. }
  9894. if m.id == nil || m.oldValue == nil {
  9895. return v, errors.New("OldStarrole requires an ID field in the mutation")
  9896. }
  9897. oldValue, err := m.oldValue(ctx)
  9898. if err != nil {
  9899. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  9900. }
  9901. return oldValue.Starrole, nil
  9902. }
  9903. // ResetStarrole resets all changes to the "starrole" field.
  9904. func (m *ContactMutation) ResetStarrole() {
  9905. m.starrole = nil
  9906. }
  9907. // SetDontseeit sets the "dontseeit" field.
  9908. func (m *ContactMutation) SetDontseeit(i int) {
  9909. m.dontseeit = &i
  9910. m.adddontseeit = nil
  9911. }
  9912. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  9913. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  9914. v := m.dontseeit
  9915. if v == nil {
  9916. return
  9917. }
  9918. return *v, true
  9919. }
  9920. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  9921. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9923. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  9924. if !m.op.Is(OpUpdateOne) {
  9925. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  9926. }
  9927. if m.id == nil || m.oldValue == nil {
  9928. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  9929. }
  9930. oldValue, err := m.oldValue(ctx)
  9931. if err != nil {
  9932. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  9933. }
  9934. return oldValue.Dontseeit, nil
  9935. }
  9936. // AddDontseeit adds i to the "dontseeit" field.
  9937. func (m *ContactMutation) AddDontseeit(i int) {
  9938. if m.adddontseeit != nil {
  9939. *m.adddontseeit += i
  9940. } else {
  9941. m.adddontseeit = &i
  9942. }
  9943. }
  9944. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  9945. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  9946. v := m.adddontseeit
  9947. if v == nil {
  9948. return
  9949. }
  9950. return *v, true
  9951. }
  9952. // ResetDontseeit resets all changes to the "dontseeit" field.
  9953. func (m *ContactMutation) ResetDontseeit() {
  9954. m.dontseeit = nil
  9955. m.adddontseeit = nil
  9956. }
  9957. // SetDontseeme sets the "dontseeme" field.
  9958. func (m *ContactMutation) SetDontseeme(i int) {
  9959. m.dontseeme = &i
  9960. m.adddontseeme = nil
  9961. }
  9962. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  9963. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  9964. v := m.dontseeme
  9965. if v == nil {
  9966. return
  9967. }
  9968. return *v, true
  9969. }
  9970. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  9971. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9973. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  9974. if !m.op.Is(OpUpdateOne) {
  9975. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  9976. }
  9977. if m.id == nil || m.oldValue == nil {
  9978. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  9979. }
  9980. oldValue, err := m.oldValue(ctx)
  9981. if err != nil {
  9982. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  9983. }
  9984. return oldValue.Dontseeme, nil
  9985. }
  9986. // AddDontseeme adds i to the "dontseeme" field.
  9987. func (m *ContactMutation) AddDontseeme(i int) {
  9988. if m.adddontseeme != nil {
  9989. *m.adddontseeme += i
  9990. } else {
  9991. m.adddontseeme = &i
  9992. }
  9993. }
  9994. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  9995. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  9996. v := m.adddontseeme
  9997. if v == nil {
  9998. return
  9999. }
  10000. return *v, true
  10001. }
  10002. // ResetDontseeme resets all changes to the "dontseeme" field.
  10003. func (m *ContactMutation) ResetDontseeme() {
  10004. m.dontseeme = nil
  10005. m.adddontseeme = nil
  10006. }
  10007. // SetLag sets the "lag" field.
  10008. func (m *ContactMutation) SetLag(s string) {
  10009. m.lag = &s
  10010. }
  10011. // Lag returns the value of the "lag" field in the mutation.
  10012. func (m *ContactMutation) Lag() (r string, exists bool) {
  10013. v := m.lag
  10014. if v == nil {
  10015. return
  10016. }
  10017. return *v, true
  10018. }
  10019. // OldLag returns the old "lag" field's value of the Contact entity.
  10020. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10022. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  10023. if !m.op.Is(OpUpdateOne) {
  10024. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  10025. }
  10026. if m.id == nil || m.oldValue == nil {
  10027. return v, errors.New("OldLag requires an ID field in the mutation")
  10028. }
  10029. oldValue, err := m.oldValue(ctx)
  10030. if err != nil {
  10031. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  10032. }
  10033. return oldValue.Lag, nil
  10034. }
  10035. // ResetLag resets all changes to the "lag" field.
  10036. func (m *ContactMutation) ResetLag() {
  10037. m.lag = nil
  10038. }
  10039. // SetGid sets the "gid" field.
  10040. func (m *ContactMutation) SetGid(s string) {
  10041. m.gid = &s
  10042. }
  10043. // Gid returns the value of the "gid" field in the mutation.
  10044. func (m *ContactMutation) Gid() (r string, exists bool) {
  10045. v := m.gid
  10046. if v == nil {
  10047. return
  10048. }
  10049. return *v, true
  10050. }
  10051. // OldGid returns the old "gid" field's value of the Contact entity.
  10052. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10054. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  10055. if !m.op.Is(OpUpdateOne) {
  10056. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  10057. }
  10058. if m.id == nil || m.oldValue == nil {
  10059. return v, errors.New("OldGid requires an ID field in the mutation")
  10060. }
  10061. oldValue, err := m.oldValue(ctx)
  10062. if err != nil {
  10063. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  10064. }
  10065. return oldValue.Gid, nil
  10066. }
  10067. // ResetGid resets all changes to the "gid" field.
  10068. func (m *ContactMutation) ResetGid() {
  10069. m.gid = nil
  10070. }
  10071. // SetGname sets the "gname" field.
  10072. func (m *ContactMutation) SetGname(s string) {
  10073. m.gname = &s
  10074. }
  10075. // Gname returns the value of the "gname" field in the mutation.
  10076. func (m *ContactMutation) Gname() (r string, exists bool) {
  10077. v := m.gname
  10078. if v == nil {
  10079. return
  10080. }
  10081. return *v, true
  10082. }
  10083. // OldGname returns the old "gname" field's value of the Contact entity.
  10084. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10086. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  10087. if !m.op.Is(OpUpdateOne) {
  10088. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  10089. }
  10090. if m.id == nil || m.oldValue == nil {
  10091. return v, errors.New("OldGname requires an ID field in the mutation")
  10092. }
  10093. oldValue, err := m.oldValue(ctx)
  10094. if err != nil {
  10095. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  10096. }
  10097. return oldValue.Gname, nil
  10098. }
  10099. // ResetGname resets all changes to the "gname" field.
  10100. func (m *ContactMutation) ResetGname() {
  10101. m.gname = nil
  10102. }
  10103. // SetV3 sets the "v3" field.
  10104. func (m *ContactMutation) SetV3(s string) {
  10105. m.v3 = &s
  10106. }
  10107. // V3 returns the value of the "v3" field in the mutation.
  10108. func (m *ContactMutation) V3() (r string, exists bool) {
  10109. v := m.v3
  10110. if v == nil {
  10111. return
  10112. }
  10113. return *v, true
  10114. }
  10115. // OldV3 returns the old "v3" field's value of the Contact entity.
  10116. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10118. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  10119. if !m.op.Is(OpUpdateOne) {
  10120. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  10121. }
  10122. if m.id == nil || m.oldValue == nil {
  10123. return v, errors.New("OldV3 requires an ID field in the mutation")
  10124. }
  10125. oldValue, err := m.oldValue(ctx)
  10126. if err != nil {
  10127. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  10128. }
  10129. return oldValue.V3, nil
  10130. }
  10131. // ResetV3 resets all changes to the "v3" field.
  10132. func (m *ContactMutation) ResetV3() {
  10133. m.v3 = nil
  10134. }
  10135. // SetOrganizationID sets the "organization_id" field.
  10136. func (m *ContactMutation) SetOrganizationID(u uint64) {
  10137. m.organization_id = &u
  10138. m.addorganization_id = nil
  10139. }
  10140. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10141. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  10142. v := m.organization_id
  10143. if v == nil {
  10144. return
  10145. }
  10146. return *v, true
  10147. }
  10148. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  10149. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10151. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10152. if !m.op.Is(OpUpdateOne) {
  10153. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10154. }
  10155. if m.id == nil || m.oldValue == nil {
  10156. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10157. }
  10158. oldValue, err := m.oldValue(ctx)
  10159. if err != nil {
  10160. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10161. }
  10162. return oldValue.OrganizationID, nil
  10163. }
  10164. // AddOrganizationID adds u to the "organization_id" field.
  10165. func (m *ContactMutation) AddOrganizationID(u int64) {
  10166. if m.addorganization_id != nil {
  10167. *m.addorganization_id += u
  10168. } else {
  10169. m.addorganization_id = &u
  10170. }
  10171. }
  10172. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10173. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  10174. v := m.addorganization_id
  10175. if v == nil {
  10176. return
  10177. }
  10178. return *v, true
  10179. }
  10180. // ClearOrganizationID clears the value of the "organization_id" field.
  10181. func (m *ContactMutation) ClearOrganizationID() {
  10182. m.organization_id = nil
  10183. m.addorganization_id = nil
  10184. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  10185. }
  10186. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10187. func (m *ContactMutation) OrganizationIDCleared() bool {
  10188. _, ok := m.clearedFields[contact.FieldOrganizationID]
  10189. return ok
  10190. }
  10191. // ResetOrganizationID resets all changes to the "organization_id" field.
  10192. func (m *ContactMutation) ResetOrganizationID() {
  10193. m.organization_id = nil
  10194. m.addorganization_id = nil
  10195. delete(m.clearedFields, contact.FieldOrganizationID)
  10196. }
  10197. // SetCtype sets the "ctype" field.
  10198. func (m *ContactMutation) SetCtype(u uint64) {
  10199. m.ctype = &u
  10200. m.addctype = nil
  10201. }
  10202. // Ctype returns the value of the "ctype" field in the mutation.
  10203. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  10204. v := m.ctype
  10205. if v == nil {
  10206. return
  10207. }
  10208. return *v, true
  10209. }
  10210. // OldCtype returns the old "ctype" field's value of the Contact entity.
  10211. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10213. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  10214. if !m.op.Is(OpUpdateOne) {
  10215. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  10216. }
  10217. if m.id == nil || m.oldValue == nil {
  10218. return v, errors.New("OldCtype requires an ID field in the mutation")
  10219. }
  10220. oldValue, err := m.oldValue(ctx)
  10221. if err != nil {
  10222. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  10223. }
  10224. return oldValue.Ctype, nil
  10225. }
  10226. // AddCtype adds u to the "ctype" field.
  10227. func (m *ContactMutation) AddCtype(u int64) {
  10228. if m.addctype != nil {
  10229. *m.addctype += u
  10230. } else {
  10231. m.addctype = &u
  10232. }
  10233. }
  10234. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  10235. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  10236. v := m.addctype
  10237. if v == nil {
  10238. return
  10239. }
  10240. return *v, true
  10241. }
  10242. // ResetCtype resets all changes to the "ctype" field.
  10243. func (m *ContactMutation) ResetCtype() {
  10244. m.ctype = nil
  10245. m.addctype = nil
  10246. }
  10247. // SetCage sets the "cage" field.
  10248. func (m *ContactMutation) SetCage(i int) {
  10249. m.cage = &i
  10250. m.addcage = nil
  10251. }
  10252. // Cage returns the value of the "cage" field in the mutation.
  10253. func (m *ContactMutation) Cage() (r int, exists bool) {
  10254. v := m.cage
  10255. if v == nil {
  10256. return
  10257. }
  10258. return *v, true
  10259. }
  10260. // OldCage returns the old "cage" field's value of the Contact entity.
  10261. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10263. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  10264. if !m.op.Is(OpUpdateOne) {
  10265. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  10266. }
  10267. if m.id == nil || m.oldValue == nil {
  10268. return v, errors.New("OldCage requires an ID field in the mutation")
  10269. }
  10270. oldValue, err := m.oldValue(ctx)
  10271. if err != nil {
  10272. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  10273. }
  10274. return oldValue.Cage, nil
  10275. }
  10276. // AddCage adds i to the "cage" field.
  10277. func (m *ContactMutation) AddCage(i int) {
  10278. if m.addcage != nil {
  10279. *m.addcage += i
  10280. } else {
  10281. m.addcage = &i
  10282. }
  10283. }
  10284. // AddedCage returns the value that was added to the "cage" field in this mutation.
  10285. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  10286. v := m.addcage
  10287. if v == nil {
  10288. return
  10289. }
  10290. return *v, true
  10291. }
  10292. // ResetCage resets all changes to the "cage" field.
  10293. func (m *ContactMutation) ResetCage() {
  10294. m.cage = nil
  10295. m.addcage = nil
  10296. }
  10297. // SetCname sets the "cname" field.
  10298. func (m *ContactMutation) SetCname(s string) {
  10299. m.cname = &s
  10300. }
  10301. // Cname returns the value of the "cname" field in the mutation.
  10302. func (m *ContactMutation) Cname() (r string, exists bool) {
  10303. v := m.cname
  10304. if v == nil {
  10305. return
  10306. }
  10307. return *v, true
  10308. }
  10309. // OldCname returns the old "cname" field's value of the Contact entity.
  10310. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10312. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  10313. if !m.op.Is(OpUpdateOne) {
  10314. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  10315. }
  10316. if m.id == nil || m.oldValue == nil {
  10317. return v, errors.New("OldCname requires an ID field in the mutation")
  10318. }
  10319. oldValue, err := m.oldValue(ctx)
  10320. if err != nil {
  10321. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  10322. }
  10323. return oldValue.Cname, nil
  10324. }
  10325. // ResetCname resets all changes to the "cname" field.
  10326. func (m *ContactMutation) ResetCname() {
  10327. m.cname = nil
  10328. }
  10329. // SetCarea sets the "carea" field.
  10330. func (m *ContactMutation) SetCarea(s string) {
  10331. m.carea = &s
  10332. }
  10333. // Carea returns the value of the "carea" field in the mutation.
  10334. func (m *ContactMutation) Carea() (r string, exists bool) {
  10335. v := m.carea
  10336. if v == nil {
  10337. return
  10338. }
  10339. return *v, true
  10340. }
  10341. // OldCarea returns the old "carea" field's value of the Contact entity.
  10342. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10344. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  10345. if !m.op.Is(OpUpdateOne) {
  10346. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  10347. }
  10348. if m.id == nil || m.oldValue == nil {
  10349. return v, errors.New("OldCarea requires an ID field in the mutation")
  10350. }
  10351. oldValue, err := m.oldValue(ctx)
  10352. if err != nil {
  10353. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  10354. }
  10355. return oldValue.Carea, nil
  10356. }
  10357. // ResetCarea resets all changes to the "carea" field.
  10358. func (m *ContactMutation) ResetCarea() {
  10359. m.carea = nil
  10360. }
  10361. // SetCbirthday sets the "cbirthday" field.
  10362. func (m *ContactMutation) SetCbirthday(s string) {
  10363. m.cbirthday = &s
  10364. }
  10365. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  10366. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  10367. v := m.cbirthday
  10368. if v == nil {
  10369. return
  10370. }
  10371. return *v, true
  10372. }
  10373. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  10374. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10376. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  10377. if !m.op.Is(OpUpdateOne) {
  10378. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  10379. }
  10380. if m.id == nil || m.oldValue == nil {
  10381. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  10382. }
  10383. oldValue, err := m.oldValue(ctx)
  10384. if err != nil {
  10385. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  10386. }
  10387. return oldValue.Cbirthday, nil
  10388. }
  10389. // ResetCbirthday resets all changes to the "cbirthday" field.
  10390. func (m *ContactMutation) ResetCbirthday() {
  10391. m.cbirthday = nil
  10392. }
  10393. // SetCbirtharea sets the "cbirtharea" field.
  10394. func (m *ContactMutation) SetCbirtharea(s string) {
  10395. m.cbirtharea = &s
  10396. }
  10397. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  10398. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  10399. v := m.cbirtharea
  10400. if v == nil {
  10401. return
  10402. }
  10403. return *v, true
  10404. }
  10405. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  10406. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10408. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  10409. if !m.op.Is(OpUpdateOne) {
  10410. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  10411. }
  10412. if m.id == nil || m.oldValue == nil {
  10413. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  10414. }
  10415. oldValue, err := m.oldValue(ctx)
  10416. if err != nil {
  10417. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  10418. }
  10419. return oldValue.Cbirtharea, nil
  10420. }
  10421. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  10422. func (m *ContactMutation) ResetCbirtharea() {
  10423. m.cbirtharea = nil
  10424. }
  10425. // SetCidcardNo sets the "cidcard_no" field.
  10426. func (m *ContactMutation) SetCidcardNo(s string) {
  10427. m.cidcard_no = &s
  10428. }
  10429. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  10430. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  10431. v := m.cidcard_no
  10432. if v == nil {
  10433. return
  10434. }
  10435. return *v, true
  10436. }
  10437. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  10438. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10440. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  10441. if !m.op.Is(OpUpdateOne) {
  10442. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  10443. }
  10444. if m.id == nil || m.oldValue == nil {
  10445. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  10446. }
  10447. oldValue, err := m.oldValue(ctx)
  10448. if err != nil {
  10449. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  10450. }
  10451. return oldValue.CidcardNo, nil
  10452. }
  10453. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  10454. func (m *ContactMutation) ResetCidcardNo() {
  10455. m.cidcard_no = nil
  10456. }
  10457. // SetCtitle sets the "ctitle" field.
  10458. func (m *ContactMutation) SetCtitle(s string) {
  10459. m.ctitle = &s
  10460. }
  10461. // Ctitle returns the value of the "ctitle" field in the mutation.
  10462. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  10463. v := m.ctitle
  10464. if v == nil {
  10465. return
  10466. }
  10467. return *v, true
  10468. }
  10469. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  10470. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10472. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  10473. if !m.op.Is(OpUpdateOne) {
  10474. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  10475. }
  10476. if m.id == nil || m.oldValue == nil {
  10477. return v, errors.New("OldCtitle requires an ID field in the mutation")
  10478. }
  10479. oldValue, err := m.oldValue(ctx)
  10480. if err != nil {
  10481. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  10482. }
  10483. return oldValue.Ctitle, nil
  10484. }
  10485. // ResetCtitle resets all changes to the "ctitle" field.
  10486. func (m *ContactMutation) ResetCtitle() {
  10487. m.ctitle = nil
  10488. }
  10489. // SetCc sets the "cc" field.
  10490. func (m *ContactMutation) SetCc(s string) {
  10491. m.cc = &s
  10492. }
  10493. // Cc returns the value of the "cc" field in the mutation.
  10494. func (m *ContactMutation) Cc() (r string, exists bool) {
  10495. v := m.cc
  10496. if v == nil {
  10497. return
  10498. }
  10499. return *v, true
  10500. }
  10501. // OldCc returns the old "cc" field's value of the Contact entity.
  10502. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10504. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  10505. if !m.op.Is(OpUpdateOne) {
  10506. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  10507. }
  10508. if m.id == nil || m.oldValue == nil {
  10509. return v, errors.New("OldCc requires an ID field in the mutation")
  10510. }
  10511. oldValue, err := m.oldValue(ctx)
  10512. if err != nil {
  10513. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  10514. }
  10515. return oldValue.Cc, nil
  10516. }
  10517. // ResetCc resets all changes to the "cc" field.
  10518. func (m *ContactMutation) ResetCc() {
  10519. m.cc = nil
  10520. }
  10521. // SetPhone sets the "phone" field.
  10522. func (m *ContactMutation) SetPhone(s string) {
  10523. m.phone = &s
  10524. }
  10525. // Phone returns the value of the "phone" field in the mutation.
  10526. func (m *ContactMutation) Phone() (r string, exists bool) {
  10527. v := m.phone
  10528. if v == nil {
  10529. return
  10530. }
  10531. return *v, true
  10532. }
  10533. // OldPhone returns the old "phone" field's value of the Contact entity.
  10534. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10536. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  10537. if !m.op.Is(OpUpdateOne) {
  10538. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  10539. }
  10540. if m.id == nil || m.oldValue == nil {
  10541. return v, errors.New("OldPhone requires an ID field in the mutation")
  10542. }
  10543. oldValue, err := m.oldValue(ctx)
  10544. if err != nil {
  10545. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  10546. }
  10547. return oldValue.Phone, nil
  10548. }
  10549. // ResetPhone resets all changes to the "phone" field.
  10550. func (m *ContactMutation) ResetPhone() {
  10551. m.phone = nil
  10552. }
  10553. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  10554. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  10555. if m.contact_relationships == nil {
  10556. m.contact_relationships = make(map[uint64]struct{})
  10557. }
  10558. for i := range ids {
  10559. m.contact_relationships[ids[i]] = struct{}{}
  10560. }
  10561. }
  10562. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  10563. func (m *ContactMutation) ClearContactRelationships() {
  10564. m.clearedcontact_relationships = true
  10565. }
  10566. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  10567. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  10568. return m.clearedcontact_relationships
  10569. }
  10570. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  10571. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  10572. if m.removedcontact_relationships == nil {
  10573. m.removedcontact_relationships = make(map[uint64]struct{})
  10574. }
  10575. for i := range ids {
  10576. delete(m.contact_relationships, ids[i])
  10577. m.removedcontact_relationships[ids[i]] = struct{}{}
  10578. }
  10579. }
  10580. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  10581. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  10582. for id := range m.removedcontact_relationships {
  10583. ids = append(ids, id)
  10584. }
  10585. return
  10586. }
  10587. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  10588. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  10589. for id := range m.contact_relationships {
  10590. ids = append(ids, id)
  10591. }
  10592. return
  10593. }
  10594. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  10595. func (m *ContactMutation) ResetContactRelationships() {
  10596. m.contact_relationships = nil
  10597. m.clearedcontact_relationships = false
  10598. m.removedcontact_relationships = nil
  10599. }
  10600. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  10601. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  10602. if m.contact_messages == nil {
  10603. m.contact_messages = make(map[uint64]struct{})
  10604. }
  10605. for i := range ids {
  10606. m.contact_messages[ids[i]] = struct{}{}
  10607. }
  10608. }
  10609. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  10610. func (m *ContactMutation) ClearContactMessages() {
  10611. m.clearedcontact_messages = true
  10612. }
  10613. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  10614. func (m *ContactMutation) ContactMessagesCleared() bool {
  10615. return m.clearedcontact_messages
  10616. }
  10617. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  10618. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  10619. if m.removedcontact_messages == nil {
  10620. m.removedcontact_messages = make(map[uint64]struct{})
  10621. }
  10622. for i := range ids {
  10623. delete(m.contact_messages, ids[i])
  10624. m.removedcontact_messages[ids[i]] = struct{}{}
  10625. }
  10626. }
  10627. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  10628. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  10629. for id := range m.removedcontact_messages {
  10630. ids = append(ids, id)
  10631. }
  10632. return
  10633. }
  10634. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  10635. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  10636. for id := range m.contact_messages {
  10637. ids = append(ids, id)
  10638. }
  10639. return
  10640. }
  10641. // ResetContactMessages resets all changes to the "contact_messages" edge.
  10642. func (m *ContactMutation) ResetContactMessages() {
  10643. m.contact_messages = nil
  10644. m.clearedcontact_messages = false
  10645. m.removedcontact_messages = nil
  10646. }
  10647. // Where appends a list predicates to the ContactMutation builder.
  10648. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  10649. m.predicates = append(m.predicates, ps...)
  10650. }
  10651. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  10652. // users can use type-assertion to append predicates that do not depend on any generated package.
  10653. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  10654. p := make([]predicate.Contact, len(ps))
  10655. for i := range ps {
  10656. p[i] = ps[i]
  10657. }
  10658. m.Where(p...)
  10659. }
  10660. // Op returns the operation name.
  10661. func (m *ContactMutation) Op() Op {
  10662. return m.op
  10663. }
  10664. // SetOp allows setting the mutation operation.
  10665. func (m *ContactMutation) SetOp(op Op) {
  10666. m.op = op
  10667. }
  10668. // Type returns the node type of this mutation (Contact).
  10669. func (m *ContactMutation) Type() string {
  10670. return m.typ
  10671. }
  10672. // Fields returns all fields that were changed during this mutation. Note that in
  10673. // order to get all numeric fields that were incremented/decremented, call
  10674. // AddedFields().
  10675. func (m *ContactMutation) Fields() []string {
  10676. fields := make([]string, 0, 30)
  10677. if m.created_at != nil {
  10678. fields = append(fields, contact.FieldCreatedAt)
  10679. }
  10680. if m.updated_at != nil {
  10681. fields = append(fields, contact.FieldUpdatedAt)
  10682. }
  10683. if m.status != nil {
  10684. fields = append(fields, contact.FieldStatus)
  10685. }
  10686. if m.deleted_at != nil {
  10687. fields = append(fields, contact.FieldDeletedAt)
  10688. }
  10689. if m.wx_wxid != nil {
  10690. fields = append(fields, contact.FieldWxWxid)
  10691. }
  10692. if m._type != nil {
  10693. fields = append(fields, contact.FieldType)
  10694. }
  10695. if m.wxid != nil {
  10696. fields = append(fields, contact.FieldWxid)
  10697. }
  10698. if m.account != nil {
  10699. fields = append(fields, contact.FieldAccount)
  10700. }
  10701. if m.nickname != nil {
  10702. fields = append(fields, contact.FieldNickname)
  10703. }
  10704. if m.markname != nil {
  10705. fields = append(fields, contact.FieldMarkname)
  10706. }
  10707. if m.headimg != nil {
  10708. fields = append(fields, contact.FieldHeadimg)
  10709. }
  10710. if m.sex != nil {
  10711. fields = append(fields, contact.FieldSex)
  10712. }
  10713. if m.starrole != nil {
  10714. fields = append(fields, contact.FieldStarrole)
  10715. }
  10716. if m.dontseeit != nil {
  10717. fields = append(fields, contact.FieldDontseeit)
  10718. }
  10719. if m.dontseeme != nil {
  10720. fields = append(fields, contact.FieldDontseeme)
  10721. }
  10722. if m.lag != nil {
  10723. fields = append(fields, contact.FieldLag)
  10724. }
  10725. if m.gid != nil {
  10726. fields = append(fields, contact.FieldGid)
  10727. }
  10728. if m.gname != nil {
  10729. fields = append(fields, contact.FieldGname)
  10730. }
  10731. if m.v3 != nil {
  10732. fields = append(fields, contact.FieldV3)
  10733. }
  10734. if m.organization_id != nil {
  10735. fields = append(fields, contact.FieldOrganizationID)
  10736. }
  10737. if m.ctype != nil {
  10738. fields = append(fields, contact.FieldCtype)
  10739. }
  10740. if m.cage != nil {
  10741. fields = append(fields, contact.FieldCage)
  10742. }
  10743. if m.cname != nil {
  10744. fields = append(fields, contact.FieldCname)
  10745. }
  10746. if m.carea != nil {
  10747. fields = append(fields, contact.FieldCarea)
  10748. }
  10749. if m.cbirthday != nil {
  10750. fields = append(fields, contact.FieldCbirthday)
  10751. }
  10752. if m.cbirtharea != nil {
  10753. fields = append(fields, contact.FieldCbirtharea)
  10754. }
  10755. if m.cidcard_no != nil {
  10756. fields = append(fields, contact.FieldCidcardNo)
  10757. }
  10758. if m.ctitle != nil {
  10759. fields = append(fields, contact.FieldCtitle)
  10760. }
  10761. if m.cc != nil {
  10762. fields = append(fields, contact.FieldCc)
  10763. }
  10764. if m.phone != nil {
  10765. fields = append(fields, contact.FieldPhone)
  10766. }
  10767. return fields
  10768. }
  10769. // Field returns the value of a field with the given name. The second boolean
  10770. // return value indicates that this field was not set, or was not defined in the
  10771. // schema.
  10772. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  10773. switch name {
  10774. case contact.FieldCreatedAt:
  10775. return m.CreatedAt()
  10776. case contact.FieldUpdatedAt:
  10777. return m.UpdatedAt()
  10778. case contact.FieldStatus:
  10779. return m.Status()
  10780. case contact.FieldDeletedAt:
  10781. return m.DeletedAt()
  10782. case contact.FieldWxWxid:
  10783. return m.WxWxid()
  10784. case contact.FieldType:
  10785. return m.GetType()
  10786. case contact.FieldWxid:
  10787. return m.Wxid()
  10788. case contact.FieldAccount:
  10789. return m.Account()
  10790. case contact.FieldNickname:
  10791. return m.Nickname()
  10792. case contact.FieldMarkname:
  10793. return m.Markname()
  10794. case contact.FieldHeadimg:
  10795. return m.Headimg()
  10796. case contact.FieldSex:
  10797. return m.Sex()
  10798. case contact.FieldStarrole:
  10799. return m.Starrole()
  10800. case contact.FieldDontseeit:
  10801. return m.Dontseeit()
  10802. case contact.FieldDontseeme:
  10803. return m.Dontseeme()
  10804. case contact.FieldLag:
  10805. return m.Lag()
  10806. case contact.FieldGid:
  10807. return m.Gid()
  10808. case contact.FieldGname:
  10809. return m.Gname()
  10810. case contact.FieldV3:
  10811. return m.V3()
  10812. case contact.FieldOrganizationID:
  10813. return m.OrganizationID()
  10814. case contact.FieldCtype:
  10815. return m.Ctype()
  10816. case contact.FieldCage:
  10817. return m.Cage()
  10818. case contact.FieldCname:
  10819. return m.Cname()
  10820. case contact.FieldCarea:
  10821. return m.Carea()
  10822. case contact.FieldCbirthday:
  10823. return m.Cbirthday()
  10824. case contact.FieldCbirtharea:
  10825. return m.Cbirtharea()
  10826. case contact.FieldCidcardNo:
  10827. return m.CidcardNo()
  10828. case contact.FieldCtitle:
  10829. return m.Ctitle()
  10830. case contact.FieldCc:
  10831. return m.Cc()
  10832. case contact.FieldPhone:
  10833. return m.Phone()
  10834. }
  10835. return nil, false
  10836. }
  10837. // OldField returns the old value of the field from the database. An error is
  10838. // returned if the mutation operation is not UpdateOne, or the query to the
  10839. // database failed.
  10840. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10841. switch name {
  10842. case contact.FieldCreatedAt:
  10843. return m.OldCreatedAt(ctx)
  10844. case contact.FieldUpdatedAt:
  10845. return m.OldUpdatedAt(ctx)
  10846. case contact.FieldStatus:
  10847. return m.OldStatus(ctx)
  10848. case contact.FieldDeletedAt:
  10849. return m.OldDeletedAt(ctx)
  10850. case contact.FieldWxWxid:
  10851. return m.OldWxWxid(ctx)
  10852. case contact.FieldType:
  10853. return m.OldType(ctx)
  10854. case contact.FieldWxid:
  10855. return m.OldWxid(ctx)
  10856. case contact.FieldAccount:
  10857. return m.OldAccount(ctx)
  10858. case contact.FieldNickname:
  10859. return m.OldNickname(ctx)
  10860. case contact.FieldMarkname:
  10861. return m.OldMarkname(ctx)
  10862. case contact.FieldHeadimg:
  10863. return m.OldHeadimg(ctx)
  10864. case contact.FieldSex:
  10865. return m.OldSex(ctx)
  10866. case contact.FieldStarrole:
  10867. return m.OldStarrole(ctx)
  10868. case contact.FieldDontseeit:
  10869. return m.OldDontseeit(ctx)
  10870. case contact.FieldDontseeme:
  10871. return m.OldDontseeme(ctx)
  10872. case contact.FieldLag:
  10873. return m.OldLag(ctx)
  10874. case contact.FieldGid:
  10875. return m.OldGid(ctx)
  10876. case contact.FieldGname:
  10877. return m.OldGname(ctx)
  10878. case contact.FieldV3:
  10879. return m.OldV3(ctx)
  10880. case contact.FieldOrganizationID:
  10881. return m.OldOrganizationID(ctx)
  10882. case contact.FieldCtype:
  10883. return m.OldCtype(ctx)
  10884. case contact.FieldCage:
  10885. return m.OldCage(ctx)
  10886. case contact.FieldCname:
  10887. return m.OldCname(ctx)
  10888. case contact.FieldCarea:
  10889. return m.OldCarea(ctx)
  10890. case contact.FieldCbirthday:
  10891. return m.OldCbirthday(ctx)
  10892. case contact.FieldCbirtharea:
  10893. return m.OldCbirtharea(ctx)
  10894. case contact.FieldCidcardNo:
  10895. return m.OldCidcardNo(ctx)
  10896. case contact.FieldCtitle:
  10897. return m.OldCtitle(ctx)
  10898. case contact.FieldCc:
  10899. return m.OldCc(ctx)
  10900. case contact.FieldPhone:
  10901. return m.OldPhone(ctx)
  10902. }
  10903. return nil, fmt.Errorf("unknown Contact field %s", name)
  10904. }
  10905. // SetField sets the value of a field with the given name. It returns an error if
  10906. // the field is not defined in the schema, or if the type mismatched the field
  10907. // type.
  10908. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  10909. switch name {
  10910. case contact.FieldCreatedAt:
  10911. v, ok := value.(time.Time)
  10912. if !ok {
  10913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10914. }
  10915. m.SetCreatedAt(v)
  10916. return nil
  10917. case contact.FieldUpdatedAt:
  10918. v, ok := value.(time.Time)
  10919. if !ok {
  10920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10921. }
  10922. m.SetUpdatedAt(v)
  10923. return nil
  10924. case contact.FieldStatus:
  10925. v, ok := value.(uint8)
  10926. if !ok {
  10927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10928. }
  10929. m.SetStatus(v)
  10930. return nil
  10931. case contact.FieldDeletedAt:
  10932. v, ok := value.(time.Time)
  10933. if !ok {
  10934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10935. }
  10936. m.SetDeletedAt(v)
  10937. return nil
  10938. case contact.FieldWxWxid:
  10939. v, ok := value.(string)
  10940. if !ok {
  10941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10942. }
  10943. m.SetWxWxid(v)
  10944. return nil
  10945. case contact.FieldType:
  10946. v, ok := value.(int)
  10947. if !ok {
  10948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10949. }
  10950. m.SetType(v)
  10951. return nil
  10952. case contact.FieldWxid:
  10953. v, ok := value.(string)
  10954. if !ok {
  10955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10956. }
  10957. m.SetWxid(v)
  10958. return nil
  10959. case contact.FieldAccount:
  10960. v, ok := value.(string)
  10961. if !ok {
  10962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10963. }
  10964. m.SetAccount(v)
  10965. return nil
  10966. case contact.FieldNickname:
  10967. v, ok := value.(string)
  10968. if !ok {
  10969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10970. }
  10971. m.SetNickname(v)
  10972. return nil
  10973. case contact.FieldMarkname:
  10974. v, ok := value.(string)
  10975. if !ok {
  10976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10977. }
  10978. m.SetMarkname(v)
  10979. return nil
  10980. case contact.FieldHeadimg:
  10981. v, ok := value.(string)
  10982. if !ok {
  10983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10984. }
  10985. m.SetHeadimg(v)
  10986. return nil
  10987. case contact.FieldSex:
  10988. v, ok := value.(int)
  10989. if !ok {
  10990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10991. }
  10992. m.SetSex(v)
  10993. return nil
  10994. case contact.FieldStarrole:
  10995. v, ok := value.(string)
  10996. if !ok {
  10997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10998. }
  10999. m.SetStarrole(v)
  11000. return nil
  11001. case contact.FieldDontseeit:
  11002. v, ok := value.(int)
  11003. if !ok {
  11004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11005. }
  11006. m.SetDontseeit(v)
  11007. return nil
  11008. case contact.FieldDontseeme:
  11009. v, ok := value.(int)
  11010. if !ok {
  11011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11012. }
  11013. m.SetDontseeme(v)
  11014. return nil
  11015. case contact.FieldLag:
  11016. v, ok := value.(string)
  11017. if !ok {
  11018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11019. }
  11020. m.SetLag(v)
  11021. return nil
  11022. case contact.FieldGid:
  11023. v, ok := value.(string)
  11024. if !ok {
  11025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11026. }
  11027. m.SetGid(v)
  11028. return nil
  11029. case contact.FieldGname:
  11030. v, ok := value.(string)
  11031. if !ok {
  11032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11033. }
  11034. m.SetGname(v)
  11035. return nil
  11036. case contact.FieldV3:
  11037. v, ok := value.(string)
  11038. if !ok {
  11039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11040. }
  11041. m.SetV3(v)
  11042. return nil
  11043. case contact.FieldOrganizationID:
  11044. v, ok := value.(uint64)
  11045. if !ok {
  11046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11047. }
  11048. m.SetOrganizationID(v)
  11049. return nil
  11050. case contact.FieldCtype:
  11051. v, ok := value.(uint64)
  11052. if !ok {
  11053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11054. }
  11055. m.SetCtype(v)
  11056. return nil
  11057. case contact.FieldCage:
  11058. v, ok := value.(int)
  11059. if !ok {
  11060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11061. }
  11062. m.SetCage(v)
  11063. return nil
  11064. case contact.FieldCname:
  11065. v, ok := value.(string)
  11066. if !ok {
  11067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11068. }
  11069. m.SetCname(v)
  11070. return nil
  11071. case contact.FieldCarea:
  11072. v, ok := value.(string)
  11073. if !ok {
  11074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11075. }
  11076. m.SetCarea(v)
  11077. return nil
  11078. case contact.FieldCbirthday:
  11079. v, ok := value.(string)
  11080. if !ok {
  11081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11082. }
  11083. m.SetCbirthday(v)
  11084. return nil
  11085. case contact.FieldCbirtharea:
  11086. v, ok := value.(string)
  11087. if !ok {
  11088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11089. }
  11090. m.SetCbirtharea(v)
  11091. return nil
  11092. case contact.FieldCidcardNo:
  11093. v, ok := value.(string)
  11094. if !ok {
  11095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11096. }
  11097. m.SetCidcardNo(v)
  11098. return nil
  11099. case contact.FieldCtitle:
  11100. v, ok := value.(string)
  11101. if !ok {
  11102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11103. }
  11104. m.SetCtitle(v)
  11105. return nil
  11106. case contact.FieldCc:
  11107. v, ok := value.(string)
  11108. if !ok {
  11109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11110. }
  11111. m.SetCc(v)
  11112. return nil
  11113. case contact.FieldPhone:
  11114. v, ok := value.(string)
  11115. if !ok {
  11116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11117. }
  11118. m.SetPhone(v)
  11119. return nil
  11120. }
  11121. return fmt.Errorf("unknown Contact field %s", name)
  11122. }
  11123. // AddedFields returns all numeric fields that were incremented/decremented during
  11124. // this mutation.
  11125. func (m *ContactMutation) AddedFields() []string {
  11126. var fields []string
  11127. if m.addstatus != nil {
  11128. fields = append(fields, contact.FieldStatus)
  11129. }
  11130. if m.add_type != nil {
  11131. fields = append(fields, contact.FieldType)
  11132. }
  11133. if m.addsex != nil {
  11134. fields = append(fields, contact.FieldSex)
  11135. }
  11136. if m.adddontseeit != nil {
  11137. fields = append(fields, contact.FieldDontseeit)
  11138. }
  11139. if m.adddontseeme != nil {
  11140. fields = append(fields, contact.FieldDontseeme)
  11141. }
  11142. if m.addorganization_id != nil {
  11143. fields = append(fields, contact.FieldOrganizationID)
  11144. }
  11145. if m.addctype != nil {
  11146. fields = append(fields, contact.FieldCtype)
  11147. }
  11148. if m.addcage != nil {
  11149. fields = append(fields, contact.FieldCage)
  11150. }
  11151. return fields
  11152. }
  11153. // AddedField returns the numeric value that was incremented/decremented on a field
  11154. // with the given name. The second boolean return value indicates that this field
  11155. // was not set, or was not defined in the schema.
  11156. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  11157. switch name {
  11158. case contact.FieldStatus:
  11159. return m.AddedStatus()
  11160. case contact.FieldType:
  11161. return m.AddedType()
  11162. case contact.FieldSex:
  11163. return m.AddedSex()
  11164. case contact.FieldDontseeit:
  11165. return m.AddedDontseeit()
  11166. case contact.FieldDontseeme:
  11167. return m.AddedDontseeme()
  11168. case contact.FieldOrganizationID:
  11169. return m.AddedOrganizationID()
  11170. case contact.FieldCtype:
  11171. return m.AddedCtype()
  11172. case contact.FieldCage:
  11173. return m.AddedCage()
  11174. }
  11175. return nil, false
  11176. }
  11177. // AddField adds the value to the field with the given name. It returns an error if
  11178. // the field is not defined in the schema, or if the type mismatched the field
  11179. // type.
  11180. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  11181. switch name {
  11182. case contact.FieldStatus:
  11183. v, ok := value.(int8)
  11184. if !ok {
  11185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11186. }
  11187. m.AddStatus(v)
  11188. return nil
  11189. case contact.FieldType:
  11190. v, ok := value.(int)
  11191. if !ok {
  11192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11193. }
  11194. m.AddType(v)
  11195. return nil
  11196. case contact.FieldSex:
  11197. v, ok := value.(int)
  11198. if !ok {
  11199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11200. }
  11201. m.AddSex(v)
  11202. return nil
  11203. case contact.FieldDontseeit:
  11204. v, ok := value.(int)
  11205. if !ok {
  11206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11207. }
  11208. m.AddDontseeit(v)
  11209. return nil
  11210. case contact.FieldDontseeme:
  11211. v, ok := value.(int)
  11212. if !ok {
  11213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11214. }
  11215. m.AddDontseeme(v)
  11216. return nil
  11217. case contact.FieldOrganizationID:
  11218. v, ok := value.(int64)
  11219. if !ok {
  11220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11221. }
  11222. m.AddOrganizationID(v)
  11223. return nil
  11224. case contact.FieldCtype:
  11225. v, ok := value.(int64)
  11226. if !ok {
  11227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11228. }
  11229. m.AddCtype(v)
  11230. return nil
  11231. case contact.FieldCage:
  11232. v, ok := value.(int)
  11233. if !ok {
  11234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11235. }
  11236. m.AddCage(v)
  11237. return nil
  11238. }
  11239. return fmt.Errorf("unknown Contact numeric field %s", name)
  11240. }
  11241. // ClearedFields returns all nullable fields that were cleared during this
  11242. // mutation.
  11243. func (m *ContactMutation) ClearedFields() []string {
  11244. var fields []string
  11245. if m.FieldCleared(contact.FieldStatus) {
  11246. fields = append(fields, contact.FieldStatus)
  11247. }
  11248. if m.FieldCleared(contact.FieldDeletedAt) {
  11249. fields = append(fields, contact.FieldDeletedAt)
  11250. }
  11251. if m.FieldCleared(contact.FieldType) {
  11252. fields = append(fields, contact.FieldType)
  11253. }
  11254. if m.FieldCleared(contact.FieldOrganizationID) {
  11255. fields = append(fields, contact.FieldOrganizationID)
  11256. }
  11257. return fields
  11258. }
  11259. // FieldCleared returns a boolean indicating if a field with the given name was
  11260. // cleared in this mutation.
  11261. func (m *ContactMutation) FieldCleared(name string) bool {
  11262. _, ok := m.clearedFields[name]
  11263. return ok
  11264. }
  11265. // ClearField clears the value of the field with the given name. It returns an
  11266. // error if the field is not defined in the schema.
  11267. func (m *ContactMutation) ClearField(name string) error {
  11268. switch name {
  11269. case contact.FieldStatus:
  11270. m.ClearStatus()
  11271. return nil
  11272. case contact.FieldDeletedAt:
  11273. m.ClearDeletedAt()
  11274. return nil
  11275. case contact.FieldType:
  11276. m.ClearType()
  11277. return nil
  11278. case contact.FieldOrganizationID:
  11279. m.ClearOrganizationID()
  11280. return nil
  11281. }
  11282. return fmt.Errorf("unknown Contact nullable field %s", name)
  11283. }
  11284. // ResetField resets all changes in the mutation for the field with the given name.
  11285. // It returns an error if the field is not defined in the schema.
  11286. func (m *ContactMutation) ResetField(name string) error {
  11287. switch name {
  11288. case contact.FieldCreatedAt:
  11289. m.ResetCreatedAt()
  11290. return nil
  11291. case contact.FieldUpdatedAt:
  11292. m.ResetUpdatedAt()
  11293. return nil
  11294. case contact.FieldStatus:
  11295. m.ResetStatus()
  11296. return nil
  11297. case contact.FieldDeletedAt:
  11298. m.ResetDeletedAt()
  11299. return nil
  11300. case contact.FieldWxWxid:
  11301. m.ResetWxWxid()
  11302. return nil
  11303. case contact.FieldType:
  11304. m.ResetType()
  11305. return nil
  11306. case contact.FieldWxid:
  11307. m.ResetWxid()
  11308. return nil
  11309. case contact.FieldAccount:
  11310. m.ResetAccount()
  11311. return nil
  11312. case contact.FieldNickname:
  11313. m.ResetNickname()
  11314. return nil
  11315. case contact.FieldMarkname:
  11316. m.ResetMarkname()
  11317. return nil
  11318. case contact.FieldHeadimg:
  11319. m.ResetHeadimg()
  11320. return nil
  11321. case contact.FieldSex:
  11322. m.ResetSex()
  11323. return nil
  11324. case contact.FieldStarrole:
  11325. m.ResetStarrole()
  11326. return nil
  11327. case contact.FieldDontseeit:
  11328. m.ResetDontseeit()
  11329. return nil
  11330. case contact.FieldDontseeme:
  11331. m.ResetDontseeme()
  11332. return nil
  11333. case contact.FieldLag:
  11334. m.ResetLag()
  11335. return nil
  11336. case contact.FieldGid:
  11337. m.ResetGid()
  11338. return nil
  11339. case contact.FieldGname:
  11340. m.ResetGname()
  11341. return nil
  11342. case contact.FieldV3:
  11343. m.ResetV3()
  11344. return nil
  11345. case contact.FieldOrganizationID:
  11346. m.ResetOrganizationID()
  11347. return nil
  11348. case contact.FieldCtype:
  11349. m.ResetCtype()
  11350. return nil
  11351. case contact.FieldCage:
  11352. m.ResetCage()
  11353. return nil
  11354. case contact.FieldCname:
  11355. m.ResetCname()
  11356. return nil
  11357. case contact.FieldCarea:
  11358. m.ResetCarea()
  11359. return nil
  11360. case contact.FieldCbirthday:
  11361. m.ResetCbirthday()
  11362. return nil
  11363. case contact.FieldCbirtharea:
  11364. m.ResetCbirtharea()
  11365. return nil
  11366. case contact.FieldCidcardNo:
  11367. m.ResetCidcardNo()
  11368. return nil
  11369. case contact.FieldCtitle:
  11370. m.ResetCtitle()
  11371. return nil
  11372. case contact.FieldCc:
  11373. m.ResetCc()
  11374. return nil
  11375. case contact.FieldPhone:
  11376. m.ResetPhone()
  11377. return nil
  11378. }
  11379. return fmt.Errorf("unknown Contact field %s", name)
  11380. }
  11381. // AddedEdges returns all edge names that were set/added in this mutation.
  11382. func (m *ContactMutation) AddedEdges() []string {
  11383. edges := make([]string, 0, 2)
  11384. if m.contact_relationships != nil {
  11385. edges = append(edges, contact.EdgeContactRelationships)
  11386. }
  11387. if m.contact_messages != nil {
  11388. edges = append(edges, contact.EdgeContactMessages)
  11389. }
  11390. return edges
  11391. }
  11392. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11393. // name in this mutation.
  11394. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  11395. switch name {
  11396. case contact.EdgeContactRelationships:
  11397. ids := make([]ent.Value, 0, len(m.contact_relationships))
  11398. for id := range m.contact_relationships {
  11399. ids = append(ids, id)
  11400. }
  11401. return ids
  11402. case contact.EdgeContactMessages:
  11403. ids := make([]ent.Value, 0, len(m.contact_messages))
  11404. for id := range m.contact_messages {
  11405. ids = append(ids, id)
  11406. }
  11407. return ids
  11408. }
  11409. return nil
  11410. }
  11411. // RemovedEdges returns all edge names that were removed in this mutation.
  11412. func (m *ContactMutation) RemovedEdges() []string {
  11413. edges := make([]string, 0, 2)
  11414. if m.removedcontact_relationships != nil {
  11415. edges = append(edges, contact.EdgeContactRelationships)
  11416. }
  11417. if m.removedcontact_messages != nil {
  11418. edges = append(edges, contact.EdgeContactMessages)
  11419. }
  11420. return edges
  11421. }
  11422. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11423. // the given name in this mutation.
  11424. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  11425. switch name {
  11426. case contact.EdgeContactRelationships:
  11427. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  11428. for id := range m.removedcontact_relationships {
  11429. ids = append(ids, id)
  11430. }
  11431. return ids
  11432. case contact.EdgeContactMessages:
  11433. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  11434. for id := range m.removedcontact_messages {
  11435. ids = append(ids, id)
  11436. }
  11437. return ids
  11438. }
  11439. return nil
  11440. }
  11441. // ClearedEdges returns all edge names that were cleared in this mutation.
  11442. func (m *ContactMutation) ClearedEdges() []string {
  11443. edges := make([]string, 0, 2)
  11444. if m.clearedcontact_relationships {
  11445. edges = append(edges, contact.EdgeContactRelationships)
  11446. }
  11447. if m.clearedcontact_messages {
  11448. edges = append(edges, contact.EdgeContactMessages)
  11449. }
  11450. return edges
  11451. }
  11452. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11453. // was cleared in this mutation.
  11454. func (m *ContactMutation) EdgeCleared(name string) bool {
  11455. switch name {
  11456. case contact.EdgeContactRelationships:
  11457. return m.clearedcontact_relationships
  11458. case contact.EdgeContactMessages:
  11459. return m.clearedcontact_messages
  11460. }
  11461. return false
  11462. }
  11463. // ClearEdge clears the value of the edge with the given name. It returns an error
  11464. // if that edge is not defined in the schema.
  11465. func (m *ContactMutation) ClearEdge(name string) error {
  11466. switch name {
  11467. }
  11468. return fmt.Errorf("unknown Contact unique edge %s", name)
  11469. }
  11470. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11471. // It returns an error if the edge is not defined in the schema.
  11472. func (m *ContactMutation) ResetEdge(name string) error {
  11473. switch name {
  11474. case contact.EdgeContactRelationships:
  11475. m.ResetContactRelationships()
  11476. return nil
  11477. case contact.EdgeContactMessages:
  11478. m.ResetContactMessages()
  11479. return nil
  11480. }
  11481. return fmt.Errorf("unknown Contact edge %s", name)
  11482. }
  11483. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  11484. type CreditBalanceMutation struct {
  11485. config
  11486. op Op
  11487. typ string
  11488. id *uint64
  11489. created_at *time.Time
  11490. updated_at *time.Time
  11491. deleted_at *time.Time
  11492. user_id *string
  11493. balance *float32
  11494. addbalance *float32
  11495. status *int
  11496. addstatus *int
  11497. organization_id *uint64
  11498. addorganization_id *int64
  11499. clearedFields map[string]struct{}
  11500. done bool
  11501. oldValue func(context.Context) (*CreditBalance, error)
  11502. predicates []predicate.CreditBalance
  11503. }
  11504. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  11505. // creditbalanceOption allows management of the mutation configuration using functional options.
  11506. type creditbalanceOption func(*CreditBalanceMutation)
  11507. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  11508. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  11509. m := &CreditBalanceMutation{
  11510. config: c,
  11511. op: op,
  11512. typ: TypeCreditBalance,
  11513. clearedFields: make(map[string]struct{}),
  11514. }
  11515. for _, opt := range opts {
  11516. opt(m)
  11517. }
  11518. return m
  11519. }
  11520. // withCreditBalanceID sets the ID field of the mutation.
  11521. func withCreditBalanceID(id uint64) creditbalanceOption {
  11522. return func(m *CreditBalanceMutation) {
  11523. var (
  11524. err error
  11525. once sync.Once
  11526. value *CreditBalance
  11527. )
  11528. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  11529. once.Do(func() {
  11530. if m.done {
  11531. err = errors.New("querying old values post mutation is not allowed")
  11532. } else {
  11533. value, err = m.Client().CreditBalance.Get(ctx, id)
  11534. }
  11535. })
  11536. return value, err
  11537. }
  11538. m.id = &id
  11539. }
  11540. }
  11541. // withCreditBalance sets the old CreditBalance of the mutation.
  11542. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  11543. return func(m *CreditBalanceMutation) {
  11544. m.oldValue = func(context.Context) (*CreditBalance, error) {
  11545. return node, nil
  11546. }
  11547. m.id = &node.ID
  11548. }
  11549. }
  11550. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11551. // executed in a transaction (ent.Tx), a transactional client is returned.
  11552. func (m CreditBalanceMutation) Client() *Client {
  11553. client := &Client{config: m.config}
  11554. client.init()
  11555. return client
  11556. }
  11557. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11558. // it returns an error otherwise.
  11559. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  11560. if _, ok := m.driver.(*txDriver); !ok {
  11561. return nil, errors.New("ent: mutation is not running in a transaction")
  11562. }
  11563. tx := &Tx{config: m.config}
  11564. tx.init()
  11565. return tx, nil
  11566. }
  11567. // SetID sets the value of the id field. Note that this
  11568. // operation is only accepted on creation of CreditBalance entities.
  11569. func (m *CreditBalanceMutation) SetID(id uint64) {
  11570. m.id = &id
  11571. }
  11572. // ID returns the ID value in the mutation. Note that the ID is only available
  11573. // if it was provided to the builder or after it was returned from the database.
  11574. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  11575. if m.id == nil {
  11576. return
  11577. }
  11578. return *m.id, true
  11579. }
  11580. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11581. // That means, if the mutation is applied within a transaction with an isolation level such
  11582. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11583. // or updated by the mutation.
  11584. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  11585. switch {
  11586. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11587. id, exists := m.ID()
  11588. if exists {
  11589. return []uint64{id}, nil
  11590. }
  11591. fallthrough
  11592. case m.op.Is(OpUpdate | OpDelete):
  11593. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  11594. default:
  11595. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11596. }
  11597. }
  11598. // SetCreatedAt sets the "created_at" field.
  11599. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  11600. m.created_at = &t
  11601. }
  11602. // CreatedAt returns the value of the "created_at" field in the mutation.
  11603. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  11604. v := m.created_at
  11605. if v == nil {
  11606. return
  11607. }
  11608. return *v, true
  11609. }
  11610. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  11611. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11613. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11614. if !m.op.Is(OpUpdateOne) {
  11615. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11616. }
  11617. if m.id == nil || m.oldValue == nil {
  11618. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11619. }
  11620. oldValue, err := m.oldValue(ctx)
  11621. if err != nil {
  11622. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11623. }
  11624. return oldValue.CreatedAt, nil
  11625. }
  11626. // ResetCreatedAt resets all changes to the "created_at" field.
  11627. func (m *CreditBalanceMutation) ResetCreatedAt() {
  11628. m.created_at = nil
  11629. }
  11630. // SetUpdatedAt sets the "updated_at" field.
  11631. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  11632. m.updated_at = &t
  11633. }
  11634. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11635. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  11636. v := m.updated_at
  11637. if v == nil {
  11638. return
  11639. }
  11640. return *v, true
  11641. }
  11642. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  11643. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11645. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11646. if !m.op.Is(OpUpdateOne) {
  11647. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11648. }
  11649. if m.id == nil || m.oldValue == nil {
  11650. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11651. }
  11652. oldValue, err := m.oldValue(ctx)
  11653. if err != nil {
  11654. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11655. }
  11656. return oldValue.UpdatedAt, nil
  11657. }
  11658. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11659. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  11660. m.updated_at = nil
  11661. }
  11662. // SetDeletedAt sets the "deleted_at" field.
  11663. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  11664. m.deleted_at = &t
  11665. }
  11666. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11667. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  11668. v := m.deleted_at
  11669. if v == nil {
  11670. return
  11671. }
  11672. return *v, true
  11673. }
  11674. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  11675. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11677. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11678. if !m.op.Is(OpUpdateOne) {
  11679. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11680. }
  11681. if m.id == nil || m.oldValue == nil {
  11682. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11683. }
  11684. oldValue, err := m.oldValue(ctx)
  11685. if err != nil {
  11686. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11687. }
  11688. return oldValue.DeletedAt, nil
  11689. }
  11690. // ClearDeletedAt clears the value of the "deleted_at" field.
  11691. func (m *CreditBalanceMutation) ClearDeletedAt() {
  11692. m.deleted_at = nil
  11693. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  11694. }
  11695. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11696. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  11697. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  11698. return ok
  11699. }
  11700. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11701. func (m *CreditBalanceMutation) ResetDeletedAt() {
  11702. m.deleted_at = nil
  11703. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  11704. }
  11705. // SetUserID sets the "user_id" field.
  11706. func (m *CreditBalanceMutation) SetUserID(s string) {
  11707. m.user_id = &s
  11708. }
  11709. // UserID returns the value of the "user_id" field in the mutation.
  11710. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  11711. v := m.user_id
  11712. if v == nil {
  11713. return
  11714. }
  11715. return *v, true
  11716. }
  11717. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  11718. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11720. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  11721. if !m.op.Is(OpUpdateOne) {
  11722. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11723. }
  11724. if m.id == nil || m.oldValue == nil {
  11725. return v, errors.New("OldUserID requires an ID field in the mutation")
  11726. }
  11727. oldValue, err := m.oldValue(ctx)
  11728. if err != nil {
  11729. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11730. }
  11731. return oldValue.UserID, nil
  11732. }
  11733. // ClearUserID clears the value of the "user_id" field.
  11734. func (m *CreditBalanceMutation) ClearUserID() {
  11735. m.user_id = nil
  11736. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  11737. }
  11738. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11739. func (m *CreditBalanceMutation) UserIDCleared() bool {
  11740. _, ok := m.clearedFields[creditbalance.FieldUserID]
  11741. return ok
  11742. }
  11743. // ResetUserID resets all changes to the "user_id" field.
  11744. func (m *CreditBalanceMutation) ResetUserID() {
  11745. m.user_id = nil
  11746. delete(m.clearedFields, creditbalance.FieldUserID)
  11747. }
  11748. // SetBalance sets the "balance" field.
  11749. func (m *CreditBalanceMutation) SetBalance(f float32) {
  11750. m.balance = &f
  11751. m.addbalance = nil
  11752. }
  11753. // Balance returns the value of the "balance" field in the mutation.
  11754. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  11755. v := m.balance
  11756. if v == nil {
  11757. return
  11758. }
  11759. return *v, true
  11760. }
  11761. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  11762. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11764. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  11765. if !m.op.Is(OpUpdateOne) {
  11766. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  11767. }
  11768. if m.id == nil || m.oldValue == nil {
  11769. return v, errors.New("OldBalance requires an ID field in the mutation")
  11770. }
  11771. oldValue, err := m.oldValue(ctx)
  11772. if err != nil {
  11773. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  11774. }
  11775. return oldValue.Balance, nil
  11776. }
  11777. // AddBalance adds f to the "balance" field.
  11778. func (m *CreditBalanceMutation) AddBalance(f float32) {
  11779. if m.addbalance != nil {
  11780. *m.addbalance += f
  11781. } else {
  11782. m.addbalance = &f
  11783. }
  11784. }
  11785. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  11786. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  11787. v := m.addbalance
  11788. if v == nil {
  11789. return
  11790. }
  11791. return *v, true
  11792. }
  11793. // ResetBalance resets all changes to the "balance" field.
  11794. func (m *CreditBalanceMutation) ResetBalance() {
  11795. m.balance = nil
  11796. m.addbalance = nil
  11797. }
  11798. // SetStatus sets the "status" field.
  11799. func (m *CreditBalanceMutation) SetStatus(i int) {
  11800. m.status = &i
  11801. m.addstatus = nil
  11802. }
  11803. // Status returns the value of the "status" field in the mutation.
  11804. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  11805. v := m.status
  11806. if v == nil {
  11807. return
  11808. }
  11809. return *v, true
  11810. }
  11811. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  11812. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11814. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  11815. if !m.op.Is(OpUpdateOne) {
  11816. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11817. }
  11818. if m.id == nil || m.oldValue == nil {
  11819. return v, errors.New("OldStatus requires an ID field in the mutation")
  11820. }
  11821. oldValue, err := m.oldValue(ctx)
  11822. if err != nil {
  11823. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11824. }
  11825. return oldValue.Status, nil
  11826. }
  11827. // AddStatus adds i to the "status" field.
  11828. func (m *CreditBalanceMutation) AddStatus(i int) {
  11829. if m.addstatus != nil {
  11830. *m.addstatus += i
  11831. } else {
  11832. m.addstatus = &i
  11833. }
  11834. }
  11835. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11836. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  11837. v := m.addstatus
  11838. if v == nil {
  11839. return
  11840. }
  11841. return *v, true
  11842. }
  11843. // ClearStatus clears the value of the "status" field.
  11844. func (m *CreditBalanceMutation) ClearStatus() {
  11845. m.status = nil
  11846. m.addstatus = nil
  11847. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  11848. }
  11849. // StatusCleared returns if the "status" field was cleared in this mutation.
  11850. func (m *CreditBalanceMutation) StatusCleared() bool {
  11851. _, ok := m.clearedFields[creditbalance.FieldStatus]
  11852. return ok
  11853. }
  11854. // ResetStatus resets all changes to the "status" field.
  11855. func (m *CreditBalanceMutation) ResetStatus() {
  11856. m.status = nil
  11857. m.addstatus = nil
  11858. delete(m.clearedFields, creditbalance.FieldStatus)
  11859. }
  11860. // SetOrganizationID sets the "organization_id" field.
  11861. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  11862. m.organization_id = &u
  11863. m.addorganization_id = nil
  11864. }
  11865. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11866. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  11867. v := m.organization_id
  11868. if v == nil {
  11869. return
  11870. }
  11871. return *v, true
  11872. }
  11873. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  11874. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11876. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11877. if !m.op.Is(OpUpdateOne) {
  11878. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11879. }
  11880. if m.id == nil || m.oldValue == nil {
  11881. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11882. }
  11883. oldValue, err := m.oldValue(ctx)
  11884. if err != nil {
  11885. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11886. }
  11887. return oldValue.OrganizationID, nil
  11888. }
  11889. // AddOrganizationID adds u to the "organization_id" field.
  11890. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  11891. if m.addorganization_id != nil {
  11892. *m.addorganization_id += u
  11893. } else {
  11894. m.addorganization_id = &u
  11895. }
  11896. }
  11897. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11898. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  11899. v := m.addorganization_id
  11900. if v == nil {
  11901. return
  11902. }
  11903. return *v, true
  11904. }
  11905. // ClearOrganizationID clears the value of the "organization_id" field.
  11906. func (m *CreditBalanceMutation) ClearOrganizationID() {
  11907. m.organization_id = nil
  11908. m.addorganization_id = nil
  11909. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  11910. }
  11911. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11912. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  11913. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  11914. return ok
  11915. }
  11916. // ResetOrganizationID resets all changes to the "organization_id" field.
  11917. func (m *CreditBalanceMutation) ResetOrganizationID() {
  11918. m.organization_id = nil
  11919. m.addorganization_id = nil
  11920. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  11921. }
  11922. // Where appends a list predicates to the CreditBalanceMutation builder.
  11923. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  11924. m.predicates = append(m.predicates, ps...)
  11925. }
  11926. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  11927. // users can use type-assertion to append predicates that do not depend on any generated package.
  11928. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  11929. p := make([]predicate.CreditBalance, len(ps))
  11930. for i := range ps {
  11931. p[i] = ps[i]
  11932. }
  11933. m.Where(p...)
  11934. }
  11935. // Op returns the operation name.
  11936. func (m *CreditBalanceMutation) Op() Op {
  11937. return m.op
  11938. }
  11939. // SetOp allows setting the mutation operation.
  11940. func (m *CreditBalanceMutation) SetOp(op Op) {
  11941. m.op = op
  11942. }
  11943. // Type returns the node type of this mutation (CreditBalance).
  11944. func (m *CreditBalanceMutation) Type() string {
  11945. return m.typ
  11946. }
  11947. // Fields returns all fields that were changed during this mutation. Note that in
  11948. // order to get all numeric fields that were incremented/decremented, call
  11949. // AddedFields().
  11950. func (m *CreditBalanceMutation) Fields() []string {
  11951. fields := make([]string, 0, 7)
  11952. if m.created_at != nil {
  11953. fields = append(fields, creditbalance.FieldCreatedAt)
  11954. }
  11955. if m.updated_at != nil {
  11956. fields = append(fields, creditbalance.FieldUpdatedAt)
  11957. }
  11958. if m.deleted_at != nil {
  11959. fields = append(fields, creditbalance.FieldDeletedAt)
  11960. }
  11961. if m.user_id != nil {
  11962. fields = append(fields, creditbalance.FieldUserID)
  11963. }
  11964. if m.balance != nil {
  11965. fields = append(fields, creditbalance.FieldBalance)
  11966. }
  11967. if m.status != nil {
  11968. fields = append(fields, creditbalance.FieldStatus)
  11969. }
  11970. if m.organization_id != nil {
  11971. fields = append(fields, creditbalance.FieldOrganizationID)
  11972. }
  11973. return fields
  11974. }
  11975. // Field returns the value of a field with the given name. The second boolean
  11976. // return value indicates that this field was not set, or was not defined in the
  11977. // schema.
  11978. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  11979. switch name {
  11980. case creditbalance.FieldCreatedAt:
  11981. return m.CreatedAt()
  11982. case creditbalance.FieldUpdatedAt:
  11983. return m.UpdatedAt()
  11984. case creditbalance.FieldDeletedAt:
  11985. return m.DeletedAt()
  11986. case creditbalance.FieldUserID:
  11987. return m.UserID()
  11988. case creditbalance.FieldBalance:
  11989. return m.Balance()
  11990. case creditbalance.FieldStatus:
  11991. return m.Status()
  11992. case creditbalance.FieldOrganizationID:
  11993. return m.OrganizationID()
  11994. }
  11995. return nil, false
  11996. }
  11997. // OldField returns the old value of the field from the database. An error is
  11998. // returned if the mutation operation is not UpdateOne, or the query to the
  11999. // database failed.
  12000. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12001. switch name {
  12002. case creditbalance.FieldCreatedAt:
  12003. return m.OldCreatedAt(ctx)
  12004. case creditbalance.FieldUpdatedAt:
  12005. return m.OldUpdatedAt(ctx)
  12006. case creditbalance.FieldDeletedAt:
  12007. return m.OldDeletedAt(ctx)
  12008. case creditbalance.FieldUserID:
  12009. return m.OldUserID(ctx)
  12010. case creditbalance.FieldBalance:
  12011. return m.OldBalance(ctx)
  12012. case creditbalance.FieldStatus:
  12013. return m.OldStatus(ctx)
  12014. case creditbalance.FieldOrganizationID:
  12015. return m.OldOrganizationID(ctx)
  12016. }
  12017. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  12018. }
  12019. // SetField sets the value of a field with the given name. It returns an error if
  12020. // the field is not defined in the schema, or if the type mismatched the field
  12021. // type.
  12022. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  12023. switch name {
  12024. case creditbalance.FieldCreatedAt:
  12025. v, ok := value.(time.Time)
  12026. if !ok {
  12027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12028. }
  12029. m.SetCreatedAt(v)
  12030. return nil
  12031. case creditbalance.FieldUpdatedAt:
  12032. v, ok := value.(time.Time)
  12033. if !ok {
  12034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12035. }
  12036. m.SetUpdatedAt(v)
  12037. return nil
  12038. case creditbalance.FieldDeletedAt:
  12039. v, ok := value.(time.Time)
  12040. if !ok {
  12041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12042. }
  12043. m.SetDeletedAt(v)
  12044. return nil
  12045. case creditbalance.FieldUserID:
  12046. v, ok := value.(string)
  12047. if !ok {
  12048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12049. }
  12050. m.SetUserID(v)
  12051. return nil
  12052. case creditbalance.FieldBalance:
  12053. v, ok := value.(float32)
  12054. if !ok {
  12055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12056. }
  12057. m.SetBalance(v)
  12058. return nil
  12059. case creditbalance.FieldStatus:
  12060. v, ok := value.(int)
  12061. if !ok {
  12062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12063. }
  12064. m.SetStatus(v)
  12065. return nil
  12066. case creditbalance.FieldOrganizationID:
  12067. v, ok := value.(uint64)
  12068. if !ok {
  12069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12070. }
  12071. m.SetOrganizationID(v)
  12072. return nil
  12073. }
  12074. return fmt.Errorf("unknown CreditBalance field %s", name)
  12075. }
  12076. // AddedFields returns all numeric fields that were incremented/decremented during
  12077. // this mutation.
  12078. func (m *CreditBalanceMutation) AddedFields() []string {
  12079. var fields []string
  12080. if m.addbalance != nil {
  12081. fields = append(fields, creditbalance.FieldBalance)
  12082. }
  12083. if m.addstatus != nil {
  12084. fields = append(fields, creditbalance.FieldStatus)
  12085. }
  12086. if m.addorganization_id != nil {
  12087. fields = append(fields, creditbalance.FieldOrganizationID)
  12088. }
  12089. return fields
  12090. }
  12091. // AddedField returns the numeric value that was incremented/decremented on a field
  12092. // with the given name. The second boolean return value indicates that this field
  12093. // was not set, or was not defined in the schema.
  12094. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  12095. switch name {
  12096. case creditbalance.FieldBalance:
  12097. return m.AddedBalance()
  12098. case creditbalance.FieldStatus:
  12099. return m.AddedStatus()
  12100. case creditbalance.FieldOrganizationID:
  12101. return m.AddedOrganizationID()
  12102. }
  12103. return nil, false
  12104. }
  12105. // AddField adds the value to the field with the given name. It returns an error if
  12106. // the field is not defined in the schema, or if the type mismatched the field
  12107. // type.
  12108. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  12109. switch name {
  12110. case creditbalance.FieldBalance:
  12111. v, ok := value.(float32)
  12112. if !ok {
  12113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12114. }
  12115. m.AddBalance(v)
  12116. return nil
  12117. case creditbalance.FieldStatus:
  12118. v, ok := value.(int)
  12119. if !ok {
  12120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12121. }
  12122. m.AddStatus(v)
  12123. return nil
  12124. case creditbalance.FieldOrganizationID:
  12125. v, ok := value.(int64)
  12126. if !ok {
  12127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12128. }
  12129. m.AddOrganizationID(v)
  12130. return nil
  12131. }
  12132. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  12133. }
  12134. // ClearedFields returns all nullable fields that were cleared during this
  12135. // mutation.
  12136. func (m *CreditBalanceMutation) ClearedFields() []string {
  12137. var fields []string
  12138. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  12139. fields = append(fields, creditbalance.FieldDeletedAt)
  12140. }
  12141. if m.FieldCleared(creditbalance.FieldUserID) {
  12142. fields = append(fields, creditbalance.FieldUserID)
  12143. }
  12144. if m.FieldCleared(creditbalance.FieldStatus) {
  12145. fields = append(fields, creditbalance.FieldStatus)
  12146. }
  12147. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  12148. fields = append(fields, creditbalance.FieldOrganizationID)
  12149. }
  12150. return fields
  12151. }
  12152. // FieldCleared returns a boolean indicating if a field with the given name was
  12153. // cleared in this mutation.
  12154. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  12155. _, ok := m.clearedFields[name]
  12156. return ok
  12157. }
  12158. // ClearField clears the value of the field with the given name. It returns an
  12159. // error if the field is not defined in the schema.
  12160. func (m *CreditBalanceMutation) ClearField(name string) error {
  12161. switch name {
  12162. case creditbalance.FieldDeletedAt:
  12163. m.ClearDeletedAt()
  12164. return nil
  12165. case creditbalance.FieldUserID:
  12166. m.ClearUserID()
  12167. return nil
  12168. case creditbalance.FieldStatus:
  12169. m.ClearStatus()
  12170. return nil
  12171. case creditbalance.FieldOrganizationID:
  12172. m.ClearOrganizationID()
  12173. return nil
  12174. }
  12175. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  12176. }
  12177. // ResetField resets all changes in the mutation for the field with the given name.
  12178. // It returns an error if the field is not defined in the schema.
  12179. func (m *CreditBalanceMutation) ResetField(name string) error {
  12180. switch name {
  12181. case creditbalance.FieldCreatedAt:
  12182. m.ResetCreatedAt()
  12183. return nil
  12184. case creditbalance.FieldUpdatedAt:
  12185. m.ResetUpdatedAt()
  12186. return nil
  12187. case creditbalance.FieldDeletedAt:
  12188. m.ResetDeletedAt()
  12189. return nil
  12190. case creditbalance.FieldUserID:
  12191. m.ResetUserID()
  12192. return nil
  12193. case creditbalance.FieldBalance:
  12194. m.ResetBalance()
  12195. return nil
  12196. case creditbalance.FieldStatus:
  12197. m.ResetStatus()
  12198. return nil
  12199. case creditbalance.FieldOrganizationID:
  12200. m.ResetOrganizationID()
  12201. return nil
  12202. }
  12203. return fmt.Errorf("unknown CreditBalance field %s", name)
  12204. }
  12205. // AddedEdges returns all edge names that were set/added in this mutation.
  12206. func (m *CreditBalanceMutation) AddedEdges() []string {
  12207. edges := make([]string, 0, 0)
  12208. return edges
  12209. }
  12210. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12211. // name in this mutation.
  12212. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  12213. return nil
  12214. }
  12215. // RemovedEdges returns all edge names that were removed in this mutation.
  12216. func (m *CreditBalanceMutation) RemovedEdges() []string {
  12217. edges := make([]string, 0, 0)
  12218. return edges
  12219. }
  12220. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12221. // the given name in this mutation.
  12222. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  12223. return nil
  12224. }
  12225. // ClearedEdges returns all edge names that were cleared in this mutation.
  12226. func (m *CreditBalanceMutation) ClearedEdges() []string {
  12227. edges := make([]string, 0, 0)
  12228. return edges
  12229. }
  12230. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12231. // was cleared in this mutation.
  12232. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  12233. return false
  12234. }
  12235. // ClearEdge clears the value of the edge with the given name. It returns an error
  12236. // if that edge is not defined in the schema.
  12237. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  12238. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  12239. }
  12240. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12241. // It returns an error if the edge is not defined in the schema.
  12242. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  12243. return fmt.Errorf("unknown CreditBalance edge %s", name)
  12244. }
  12245. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  12246. type CreditUsageMutation struct {
  12247. config
  12248. op Op
  12249. typ string
  12250. id *uint64
  12251. created_at *time.Time
  12252. updated_at *time.Time
  12253. deleted_at *time.Time
  12254. user_id *string
  12255. number *float32
  12256. addnumber *float32
  12257. pay_number *float32
  12258. addpay_number *float32
  12259. before_number *float32
  12260. addbefore_number *float32
  12261. after_number *float32
  12262. addafter_number *float32
  12263. pay_method *string
  12264. status *int
  12265. addstatus *int
  12266. ntype *int
  12267. addntype *int
  12268. table *string
  12269. organization_id *uint64
  12270. addorganization_id *int64
  12271. nid *uint64
  12272. addnid *int64
  12273. reason *string
  12274. operator *string
  12275. clearedFields map[string]struct{}
  12276. done bool
  12277. oldValue func(context.Context) (*CreditUsage, error)
  12278. predicates []predicate.CreditUsage
  12279. }
  12280. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  12281. // creditusageOption allows management of the mutation configuration using functional options.
  12282. type creditusageOption func(*CreditUsageMutation)
  12283. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  12284. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  12285. m := &CreditUsageMutation{
  12286. config: c,
  12287. op: op,
  12288. typ: TypeCreditUsage,
  12289. clearedFields: make(map[string]struct{}),
  12290. }
  12291. for _, opt := range opts {
  12292. opt(m)
  12293. }
  12294. return m
  12295. }
  12296. // withCreditUsageID sets the ID field of the mutation.
  12297. func withCreditUsageID(id uint64) creditusageOption {
  12298. return func(m *CreditUsageMutation) {
  12299. var (
  12300. err error
  12301. once sync.Once
  12302. value *CreditUsage
  12303. )
  12304. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  12305. once.Do(func() {
  12306. if m.done {
  12307. err = errors.New("querying old values post mutation is not allowed")
  12308. } else {
  12309. value, err = m.Client().CreditUsage.Get(ctx, id)
  12310. }
  12311. })
  12312. return value, err
  12313. }
  12314. m.id = &id
  12315. }
  12316. }
  12317. // withCreditUsage sets the old CreditUsage of the mutation.
  12318. func withCreditUsage(node *CreditUsage) creditusageOption {
  12319. return func(m *CreditUsageMutation) {
  12320. m.oldValue = func(context.Context) (*CreditUsage, error) {
  12321. return node, nil
  12322. }
  12323. m.id = &node.ID
  12324. }
  12325. }
  12326. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12327. // executed in a transaction (ent.Tx), a transactional client is returned.
  12328. func (m CreditUsageMutation) Client() *Client {
  12329. client := &Client{config: m.config}
  12330. client.init()
  12331. return client
  12332. }
  12333. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12334. // it returns an error otherwise.
  12335. func (m CreditUsageMutation) Tx() (*Tx, error) {
  12336. if _, ok := m.driver.(*txDriver); !ok {
  12337. return nil, errors.New("ent: mutation is not running in a transaction")
  12338. }
  12339. tx := &Tx{config: m.config}
  12340. tx.init()
  12341. return tx, nil
  12342. }
  12343. // SetID sets the value of the id field. Note that this
  12344. // operation is only accepted on creation of CreditUsage entities.
  12345. func (m *CreditUsageMutation) SetID(id uint64) {
  12346. m.id = &id
  12347. }
  12348. // ID returns the ID value in the mutation. Note that the ID is only available
  12349. // if it was provided to the builder or after it was returned from the database.
  12350. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  12351. if m.id == nil {
  12352. return
  12353. }
  12354. return *m.id, true
  12355. }
  12356. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12357. // That means, if the mutation is applied within a transaction with an isolation level such
  12358. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12359. // or updated by the mutation.
  12360. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  12361. switch {
  12362. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12363. id, exists := m.ID()
  12364. if exists {
  12365. return []uint64{id}, nil
  12366. }
  12367. fallthrough
  12368. case m.op.Is(OpUpdate | OpDelete):
  12369. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  12370. default:
  12371. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12372. }
  12373. }
  12374. // SetCreatedAt sets the "created_at" field.
  12375. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  12376. m.created_at = &t
  12377. }
  12378. // CreatedAt returns the value of the "created_at" field in the mutation.
  12379. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  12380. v := m.created_at
  12381. if v == nil {
  12382. return
  12383. }
  12384. return *v, true
  12385. }
  12386. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  12387. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12389. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12390. if !m.op.Is(OpUpdateOne) {
  12391. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12392. }
  12393. if m.id == nil || m.oldValue == nil {
  12394. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12395. }
  12396. oldValue, err := m.oldValue(ctx)
  12397. if err != nil {
  12398. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12399. }
  12400. return oldValue.CreatedAt, nil
  12401. }
  12402. // ResetCreatedAt resets all changes to the "created_at" field.
  12403. func (m *CreditUsageMutation) ResetCreatedAt() {
  12404. m.created_at = nil
  12405. }
  12406. // SetUpdatedAt sets the "updated_at" field.
  12407. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  12408. m.updated_at = &t
  12409. }
  12410. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12411. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  12412. v := m.updated_at
  12413. if v == nil {
  12414. return
  12415. }
  12416. return *v, true
  12417. }
  12418. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  12419. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12421. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12422. if !m.op.Is(OpUpdateOne) {
  12423. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12424. }
  12425. if m.id == nil || m.oldValue == nil {
  12426. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12427. }
  12428. oldValue, err := m.oldValue(ctx)
  12429. if err != nil {
  12430. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12431. }
  12432. return oldValue.UpdatedAt, nil
  12433. }
  12434. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12435. func (m *CreditUsageMutation) ResetUpdatedAt() {
  12436. m.updated_at = nil
  12437. }
  12438. // SetDeletedAt sets the "deleted_at" field.
  12439. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  12440. m.deleted_at = &t
  12441. }
  12442. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12443. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  12444. v := m.deleted_at
  12445. if v == nil {
  12446. return
  12447. }
  12448. return *v, true
  12449. }
  12450. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  12451. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12453. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12454. if !m.op.Is(OpUpdateOne) {
  12455. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12456. }
  12457. if m.id == nil || m.oldValue == nil {
  12458. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12459. }
  12460. oldValue, err := m.oldValue(ctx)
  12461. if err != nil {
  12462. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12463. }
  12464. return oldValue.DeletedAt, nil
  12465. }
  12466. // ClearDeletedAt clears the value of the "deleted_at" field.
  12467. func (m *CreditUsageMutation) ClearDeletedAt() {
  12468. m.deleted_at = nil
  12469. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  12470. }
  12471. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12472. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  12473. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  12474. return ok
  12475. }
  12476. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12477. func (m *CreditUsageMutation) ResetDeletedAt() {
  12478. m.deleted_at = nil
  12479. delete(m.clearedFields, creditusage.FieldDeletedAt)
  12480. }
  12481. // SetUserID sets the "user_id" field.
  12482. func (m *CreditUsageMutation) SetUserID(s string) {
  12483. m.user_id = &s
  12484. }
  12485. // UserID returns the value of the "user_id" field in the mutation.
  12486. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  12487. v := m.user_id
  12488. if v == nil {
  12489. return
  12490. }
  12491. return *v, true
  12492. }
  12493. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  12494. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12496. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  12497. if !m.op.Is(OpUpdateOne) {
  12498. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  12499. }
  12500. if m.id == nil || m.oldValue == nil {
  12501. return v, errors.New("OldUserID requires an ID field in the mutation")
  12502. }
  12503. oldValue, err := m.oldValue(ctx)
  12504. if err != nil {
  12505. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  12506. }
  12507. return oldValue.UserID, nil
  12508. }
  12509. // ClearUserID clears the value of the "user_id" field.
  12510. func (m *CreditUsageMutation) ClearUserID() {
  12511. m.user_id = nil
  12512. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  12513. }
  12514. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  12515. func (m *CreditUsageMutation) UserIDCleared() bool {
  12516. _, ok := m.clearedFields[creditusage.FieldUserID]
  12517. return ok
  12518. }
  12519. // ResetUserID resets all changes to the "user_id" field.
  12520. func (m *CreditUsageMutation) ResetUserID() {
  12521. m.user_id = nil
  12522. delete(m.clearedFields, creditusage.FieldUserID)
  12523. }
  12524. // SetNumber sets the "number" field.
  12525. func (m *CreditUsageMutation) SetNumber(f float32) {
  12526. m.number = &f
  12527. m.addnumber = nil
  12528. }
  12529. // Number returns the value of the "number" field in the mutation.
  12530. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  12531. v := m.number
  12532. if v == nil {
  12533. return
  12534. }
  12535. return *v, true
  12536. }
  12537. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  12538. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12540. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  12541. if !m.op.Is(OpUpdateOne) {
  12542. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  12543. }
  12544. if m.id == nil || m.oldValue == nil {
  12545. return v, errors.New("OldNumber requires an ID field in the mutation")
  12546. }
  12547. oldValue, err := m.oldValue(ctx)
  12548. if err != nil {
  12549. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  12550. }
  12551. return oldValue.Number, nil
  12552. }
  12553. // AddNumber adds f to the "number" field.
  12554. func (m *CreditUsageMutation) AddNumber(f float32) {
  12555. if m.addnumber != nil {
  12556. *m.addnumber += f
  12557. } else {
  12558. m.addnumber = &f
  12559. }
  12560. }
  12561. // AddedNumber returns the value that was added to the "number" field in this mutation.
  12562. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  12563. v := m.addnumber
  12564. if v == nil {
  12565. return
  12566. }
  12567. return *v, true
  12568. }
  12569. // ResetNumber resets all changes to the "number" field.
  12570. func (m *CreditUsageMutation) ResetNumber() {
  12571. m.number = nil
  12572. m.addnumber = nil
  12573. }
  12574. // SetPayNumber sets the "pay_number" field.
  12575. func (m *CreditUsageMutation) SetPayNumber(f float32) {
  12576. m.pay_number = &f
  12577. m.addpay_number = nil
  12578. }
  12579. // PayNumber returns the value of the "pay_number" field in the mutation.
  12580. func (m *CreditUsageMutation) PayNumber() (r float32, exists bool) {
  12581. v := m.pay_number
  12582. if v == nil {
  12583. return
  12584. }
  12585. return *v, true
  12586. }
  12587. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  12588. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12590. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float32, err error) {
  12591. if !m.op.Is(OpUpdateOne) {
  12592. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  12593. }
  12594. if m.id == nil || m.oldValue == nil {
  12595. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  12596. }
  12597. oldValue, err := m.oldValue(ctx)
  12598. if err != nil {
  12599. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  12600. }
  12601. return oldValue.PayNumber, nil
  12602. }
  12603. // AddPayNumber adds f to the "pay_number" field.
  12604. func (m *CreditUsageMutation) AddPayNumber(f float32) {
  12605. if m.addpay_number != nil {
  12606. *m.addpay_number += f
  12607. } else {
  12608. m.addpay_number = &f
  12609. }
  12610. }
  12611. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  12612. func (m *CreditUsageMutation) AddedPayNumber() (r float32, exists bool) {
  12613. v := m.addpay_number
  12614. if v == nil {
  12615. return
  12616. }
  12617. return *v, true
  12618. }
  12619. // ResetPayNumber resets all changes to the "pay_number" field.
  12620. func (m *CreditUsageMutation) ResetPayNumber() {
  12621. m.pay_number = nil
  12622. m.addpay_number = nil
  12623. }
  12624. // SetBeforeNumber sets the "before_number" field.
  12625. func (m *CreditUsageMutation) SetBeforeNumber(f float32) {
  12626. m.before_number = &f
  12627. m.addbefore_number = nil
  12628. }
  12629. // BeforeNumber returns the value of the "before_number" field in the mutation.
  12630. func (m *CreditUsageMutation) BeforeNumber() (r float32, exists bool) {
  12631. v := m.before_number
  12632. if v == nil {
  12633. return
  12634. }
  12635. return *v, true
  12636. }
  12637. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  12638. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12640. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float32, err error) {
  12641. if !m.op.Is(OpUpdateOne) {
  12642. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  12643. }
  12644. if m.id == nil || m.oldValue == nil {
  12645. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  12646. }
  12647. oldValue, err := m.oldValue(ctx)
  12648. if err != nil {
  12649. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  12650. }
  12651. return oldValue.BeforeNumber, nil
  12652. }
  12653. // AddBeforeNumber adds f to the "before_number" field.
  12654. func (m *CreditUsageMutation) AddBeforeNumber(f float32) {
  12655. if m.addbefore_number != nil {
  12656. *m.addbefore_number += f
  12657. } else {
  12658. m.addbefore_number = &f
  12659. }
  12660. }
  12661. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  12662. func (m *CreditUsageMutation) AddedBeforeNumber() (r float32, exists bool) {
  12663. v := m.addbefore_number
  12664. if v == nil {
  12665. return
  12666. }
  12667. return *v, true
  12668. }
  12669. // ResetBeforeNumber resets all changes to the "before_number" field.
  12670. func (m *CreditUsageMutation) ResetBeforeNumber() {
  12671. m.before_number = nil
  12672. m.addbefore_number = nil
  12673. }
  12674. // SetAfterNumber sets the "after_number" field.
  12675. func (m *CreditUsageMutation) SetAfterNumber(f float32) {
  12676. m.after_number = &f
  12677. m.addafter_number = nil
  12678. }
  12679. // AfterNumber returns the value of the "after_number" field in the mutation.
  12680. func (m *CreditUsageMutation) AfterNumber() (r float32, exists bool) {
  12681. v := m.after_number
  12682. if v == nil {
  12683. return
  12684. }
  12685. return *v, true
  12686. }
  12687. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  12688. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12690. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float32, err error) {
  12691. if !m.op.Is(OpUpdateOne) {
  12692. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  12693. }
  12694. if m.id == nil || m.oldValue == nil {
  12695. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  12696. }
  12697. oldValue, err := m.oldValue(ctx)
  12698. if err != nil {
  12699. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  12700. }
  12701. return oldValue.AfterNumber, nil
  12702. }
  12703. // AddAfterNumber adds f to the "after_number" field.
  12704. func (m *CreditUsageMutation) AddAfterNumber(f float32) {
  12705. if m.addafter_number != nil {
  12706. *m.addafter_number += f
  12707. } else {
  12708. m.addafter_number = &f
  12709. }
  12710. }
  12711. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  12712. func (m *CreditUsageMutation) AddedAfterNumber() (r float32, exists bool) {
  12713. v := m.addafter_number
  12714. if v == nil {
  12715. return
  12716. }
  12717. return *v, true
  12718. }
  12719. // ResetAfterNumber resets all changes to the "after_number" field.
  12720. func (m *CreditUsageMutation) ResetAfterNumber() {
  12721. m.after_number = nil
  12722. m.addafter_number = nil
  12723. }
  12724. // SetPayMethod sets the "pay_method" field.
  12725. func (m *CreditUsageMutation) SetPayMethod(s string) {
  12726. m.pay_method = &s
  12727. }
  12728. // PayMethod returns the value of the "pay_method" field in the mutation.
  12729. func (m *CreditUsageMutation) PayMethod() (r string, exists bool) {
  12730. v := m.pay_method
  12731. if v == nil {
  12732. return
  12733. }
  12734. return *v, true
  12735. }
  12736. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  12737. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12739. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v string, err error) {
  12740. if !m.op.Is(OpUpdateOne) {
  12741. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  12742. }
  12743. if m.id == nil || m.oldValue == nil {
  12744. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  12745. }
  12746. oldValue, err := m.oldValue(ctx)
  12747. if err != nil {
  12748. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  12749. }
  12750. return oldValue.PayMethod, nil
  12751. }
  12752. // ResetPayMethod resets all changes to the "pay_method" field.
  12753. func (m *CreditUsageMutation) ResetPayMethod() {
  12754. m.pay_method = nil
  12755. }
  12756. // SetStatus sets the "status" field.
  12757. func (m *CreditUsageMutation) SetStatus(i int) {
  12758. m.status = &i
  12759. m.addstatus = nil
  12760. }
  12761. // Status returns the value of the "status" field in the mutation.
  12762. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  12763. v := m.status
  12764. if v == nil {
  12765. return
  12766. }
  12767. return *v, true
  12768. }
  12769. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  12770. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12772. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  12773. if !m.op.Is(OpUpdateOne) {
  12774. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12775. }
  12776. if m.id == nil || m.oldValue == nil {
  12777. return v, errors.New("OldStatus requires an ID field in the mutation")
  12778. }
  12779. oldValue, err := m.oldValue(ctx)
  12780. if err != nil {
  12781. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12782. }
  12783. return oldValue.Status, nil
  12784. }
  12785. // AddStatus adds i to the "status" field.
  12786. func (m *CreditUsageMutation) AddStatus(i int) {
  12787. if m.addstatus != nil {
  12788. *m.addstatus += i
  12789. } else {
  12790. m.addstatus = &i
  12791. }
  12792. }
  12793. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12794. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  12795. v := m.addstatus
  12796. if v == nil {
  12797. return
  12798. }
  12799. return *v, true
  12800. }
  12801. // ClearStatus clears the value of the "status" field.
  12802. func (m *CreditUsageMutation) ClearStatus() {
  12803. m.status = nil
  12804. m.addstatus = nil
  12805. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  12806. }
  12807. // StatusCleared returns if the "status" field was cleared in this mutation.
  12808. func (m *CreditUsageMutation) StatusCleared() bool {
  12809. _, ok := m.clearedFields[creditusage.FieldStatus]
  12810. return ok
  12811. }
  12812. // ResetStatus resets all changes to the "status" field.
  12813. func (m *CreditUsageMutation) ResetStatus() {
  12814. m.status = nil
  12815. m.addstatus = nil
  12816. delete(m.clearedFields, creditusage.FieldStatus)
  12817. }
  12818. // SetNtype sets the "ntype" field.
  12819. func (m *CreditUsageMutation) SetNtype(i int) {
  12820. m.ntype = &i
  12821. m.addntype = nil
  12822. }
  12823. // Ntype returns the value of the "ntype" field in the mutation.
  12824. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  12825. v := m.ntype
  12826. if v == nil {
  12827. return
  12828. }
  12829. return *v, true
  12830. }
  12831. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  12832. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12834. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  12835. if !m.op.Is(OpUpdateOne) {
  12836. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  12837. }
  12838. if m.id == nil || m.oldValue == nil {
  12839. return v, errors.New("OldNtype requires an ID field in the mutation")
  12840. }
  12841. oldValue, err := m.oldValue(ctx)
  12842. if err != nil {
  12843. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  12844. }
  12845. return oldValue.Ntype, nil
  12846. }
  12847. // AddNtype adds i to the "ntype" field.
  12848. func (m *CreditUsageMutation) AddNtype(i int) {
  12849. if m.addntype != nil {
  12850. *m.addntype += i
  12851. } else {
  12852. m.addntype = &i
  12853. }
  12854. }
  12855. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  12856. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  12857. v := m.addntype
  12858. if v == nil {
  12859. return
  12860. }
  12861. return *v, true
  12862. }
  12863. // ResetNtype resets all changes to the "ntype" field.
  12864. func (m *CreditUsageMutation) ResetNtype() {
  12865. m.ntype = nil
  12866. m.addntype = nil
  12867. }
  12868. // SetTable sets the "table" field.
  12869. func (m *CreditUsageMutation) SetTable(s string) {
  12870. m.table = &s
  12871. }
  12872. // Table returns the value of the "table" field in the mutation.
  12873. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  12874. v := m.table
  12875. if v == nil {
  12876. return
  12877. }
  12878. return *v, true
  12879. }
  12880. // OldTable returns the old "table" field's value of the CreditUsage entity.
  12881. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12883. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  12884. if !m.op.Is(OpUpdateOne) {
  12885. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  12886. }
  12887. if m.id == nil || m.oldValue == nil {
  12888. return v, errors.New("OldTable requires an ID field in the mutation")
  12889. }
  12890. oldValue, err := m.oldValue(ctx)
  12891. if err != nil {
  12892. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  12893. }
  12894. return oldValue.Table, nil
  12895. }
  12896. // ResetTable resets all changes to the "table" field.
  12897. func (m *CreditUsageMutation) ResetTable() {
  12898. m.table = nil
  12899. }
  12900. // SetOrganizationID sets the "organization_id" field.
  12901. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  12902. m.organization_id = &u
  12903. m.addorganization_id = nil
  12904. }
  12905. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12906. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  12907. v := m.organization_id
  12908. if v == nil {
  12909. return
  12910. }
  12911. return *v, true
  12912. }
  12913. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  12914. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12916. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12917. if !m.op.Is(OpUpdateOne) {
  12918. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12919. }
  12920. if m.id == nil || m.oldValue == nil {
  12921. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12922. }
  12923. oldValue, err := m.oldValue(ctx)
  12924. if err != nil {
  12925. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12926. }
  12927. return oldValue.OrganizationID, nil
  12928. }
  12929. // AddOrganizationID adds u to the "organization_id" field.
  12930. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  12931. if m.addorganization_id != nil {
  12932. *m.addorganization_id += u
  12933. } else {
  12934. m.addorganization_id = &u
  12935. }
  12936. }
  12937. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12938. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  12939. v := m.addorganization_id
  12940. if v == nil {
  12941. return
  12942. }
  12943. return *v, true
  12944. }
  12945. // ClearOrganizationID clears the value of the "organization_id" field.
  12946. func (m *CreditUsageMutation) ClearOrganizationID() {
  12947. m.organization_id = nil
  12948. m.addorganization_id = nil
  12949. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  12950. }
  12951. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12952. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  12953. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  12954. return ok
  12955. }
  12956. // ResetOrganizationID resets all changes to the "organization_id" field.
  12957. func (m *CreditUsageMutation) ResetOrganizationID() {
  12958. m.organization_id = nil
  12959. m.addorganization_id = nil
  12960. delete(m.clearedFields, creditusage.FieldOrganizationID)
  12961. }
  12962. // SetNid sets the "nid" field.
  12963. func (m *CreditUsageMutation) SetNid(u uint64) {
  12964. m.nid = &u
  12965. m.addnid = nil
  12966. }
  12967. // Nid returns the value of the "nid" field in the mutation.
  12968. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  12969. v := m.nid
  12970. if v == nil {
  12971. return
  12972. }
  12973. return *v, true
  12974. }
  12975. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  12976. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12978. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  12979. if !m.op.Is(OpUpdateOne) {
  12980. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  12981. }
  12982. if m.id == nil || m.oldValue == nil {
  12983. return v, errors.New("OldNid requires an ID field in the mutation")
  12984. }
  12985. oldValue, err := m.oldValue(ctx)
  12986. if err != nil {
  12987. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  12988. }
  12989. return oldValue.Nid, nil
  12990. }
  12991. // AddNid adds u to the "nid" field.
  12992. func (m *CreditUsageMutation) AddNid(u int64) {
  12993. if m.addnid != nil {
  12994. *m.addnid += u
  12995. } else {
  12996. m.addnid = &u
  12997. }
  12998. }
  12999. // AddedNid returns the value that was added to the "nid" field in this mutation.
  13000. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  13001. v := m.addnid
  13002. if v == nil {
  13003. return
  13004. }
  13005. return *v, true
  13006. }
  13007. // ResetNid resets all changes to the "nid" field.
  13008. func (m *CreditUsageMutation) ResetNid() {
  13009. m.nid = nil
  13010. m.addnid = nil
  13011. }
  13012. // SetReason sets the "reason" field.
  13013. func (m *CreditUsageMutation) SetReason(s string) {
  13014. m.reason = &s
  13015. }
  13016. // Reason returns the value of the "reason" field in the mutation.
  13017. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  13018. v := m.reason
  13019. if v == nil {
  13020. return
  13021. }
  13022. return *v, true
  13023. }
  13024. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  13025. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13027. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  13028. if !m.op.Is(OpUpdateOne) {
  13029. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  13030. }
  13031. if m.id == nil || m.oldValue == nil {
  13032. return v, errors.New("OldReason requires an ID field in the mutation")
  13033. }
  13034. oldValue, err := m.oldValue(ctx)
  13035. if err != nil {
  13036. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  13037. }
  13038. return oldValue.Reason, nil
  13039. }
  13040. // ResetReason resets all changes to the "reason" field.
  13041. func (m *CreditUsageMutation) ResetReason() {
  13042. m.reason = nil
  13043. }
  13044. // SetOperator sets the "operator" field.
  13045. func (m *CreditUsageMutation) SetOperator(s string) {
  13046. m.operator = &s
  13047. }
  13048. // Operator returns the value of the "operator" field in the mutation.
  13049. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  13050. v := m.operator
  13051. if v == nil {
  13052. return
  13053. }
  13054. return *v, true
  13055. }
  13056. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  13057. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13059. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  13060. if !m.op.Is(OpUpdateOne) {
  13061. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  13062. }
  13063. if m.id == nil || m.oldValue == nil {
  13064. return v, errors.New("OldOperator requires an ID field in the mutation")
  13065. }
  13066. oldValue, err := m.oldValue(ctx)
  13067. if err != nil {
  13068. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  13069. }
  13070. return oldValue.Operator, nil
  13071. }
  13072. // ResetOperator resets all changes to the "operator" field.
  13073. func (m *CreditUsageMutation) ResetOperator() {
  13074. m.operator = nil
  13075. }
  13076. // Where appends a list predicates to the CreditUsageMutation builder.
  13077. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  13078. m.predicates = append(m.predicates, ps...)
  13079. }
  13080. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  13081. // users can use type-assertion to append predicates that do not depend on any generated package.
  13082. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  13083. p := make([]predicate.CreditUsage, len(ps))
  13084. for i := range ps {
  13085. p[i] = ps[i]
  13086. }
  13087. m.Where(p...)
  13088. }
  13089. // Op returns the operation name.
  13090. func (m *CreditUsageMutation) Op() Op {
  13091. return m.op
  13092. }
  13093. // SetOp allows setting the mutation operation.
  13094. func (m *CreditUsageMutation) SetOp(op Op) {
  13095. m.op = op
  13096. }
  13097. // Type returns the node type of this mutation (CreditUsage).
  13098. func (m *CreditUsageMutation) Type() string {
  13099. return m.typ
  13100. }
  13101. // Fields returns all fields that were changed during this mutation. Note that in
  13102. // order to get all numeric fields that were incremented/decremented, call
  13103. // AddedFields().
  13104. func (m *CreditUsageMutation) Fields() []string {
  13105. fields := make([]string, 0, 16)
  13106. if m.created_at != nil {
  13107. fields = append(fields, creditusage.FieldCreatedAt)
  13108. }
  13109. if m.updated_at != nil {
  13110. fields = append(fields, creditusage.FieldUpdatedAt)
  13111. }
  13112. if m.deleted_at != nil {
  13113. fields = append(fields, creditusage.FieldDeletedAt)
  13114. }
  13115. if m.user_id != nil {
  13116. fields = append(fields, creditusage.FieldUserID)
  13117. }
  13118. if m.number != nil {
  13119. fields = append(fields, creditusage.FieldNumber)
  13120. }
  13121. if m.pay_number != nil {
  13122. fields = append(fields, creditusage.FieldPayNumber)
  13123. }
  13124. if m.before_number != nil {
  13125. fields = append(fields, creditusage.FieldBeforeNumber)
  13126. }
  13127. if m.after_number != nil {
  13128. fields = append(fields, creditusage.FieldAfterNumber)
  13129. }
  13130. if m.pay_method != nil {
  13131. fields = append(fields, creditusage.FieldPayMethod)
  13132. }
  13133. if m.status != nil {
  13134. fields = append(fields, creditusage.FieldStatus)
  13135. }
  13136. if m.ntype != nil {
  13137. fields = append(fields, creditusage.FieldNtype)
  13138. }
  13139. if m.table != nil {
  13140. fields = append(fields, creditusage.FieldTable)
  13141. }
  13142. if m.organization_id != nil {
  13143. fields = append(fields, creditusage.FieldOrganizationID)
  13144. }
  13145. if m.nid != nil {
  13146. fields = append(fields, creditusage.FieldNid)
  13147. }
  13148. if m.reason != nil {
  13149. fields = append(fields, creditusage.FieldReason)
  13150. }
  13151. if m.operator != nil {
  13152. fields = append(fields, creditusage.FieldOperator)
  13153. }
  13154. return fields
  13155. }
  13156. // Field returns the value of a field with the given name. The second boolean
  13157. // return value indicates that this field was not set, or was not defined in the
  13158. // schema.
  13159. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  13160. switch name {
  13161. case creditusage.FieldCreatedAt:
  13162. return m.CreatedAt()
  13163. case creditusage.FieldUpdatedAt:
  13164. return m.UpdatedAt()
  13165. case creditusage.FieldDeletedAt:
  13166. return m.DeletedAt()
  13167. case creditusage.FieldUserID:
  13168. return m.UserID()
  13169. case creditusage.FieldNumber:
  13170. return m.Number()
  13171. case creditusage.FieldPayNumber:
  13172. return m.PayNumber()
  13173. case creditusage.FieldBeforeNumber:
  13174. return m.BeforeNumber()
  13175. case creditusage.FieldAfterNumber:
  13176. return m.AfterNumber()
  13177. case creditusage.FieldPayMethod:
  13178. return m.PayMethod()
  13179. case creditusage.FieldStatus:
  13180. return m.Status()
  13181. case creditusage.FieldNtype:
  13182. return m.Ntype()
  13183. case creditusage.FieldTable:
  13184. return m.Table()
  13185. case creditusage.FieldOrganizationID:
  13186. return m.OrganizationID()
  13187. case creditusage.FieldNid:
  13188. return m.Nid()
  13189. case creditusage.FieldReason:
  13190. return m.Reason()
  13191. case creditusage.FieldOperator:
  13192. return m.Operator()
  13193. }
  13194. return nil, false
  13195. }
  13196. // OldField returns the old value of the field from the database. An error is
  13197. // returned if the mutation operation is not UpdateOne, or the query to the
  13198. // database failed.
  13199. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13200. switch name {
  13201. case creditusage.FieldCreatedAt:
  13202. return m.OldCreatedAt(ctx)
  13203. case creditusage.FieldUpdatedAt:
  13204. return m.OldUpdatedAt(ctx)
  13205. case creditusage.FieldDeletedAt:
  13206. return m.OldDeletedAt(ctx)
  13207. case creditusage.FieldUserID:
  13208. return m.OldUserID(ctx)
  13209. case creditusage.FieldNumber:
  13210. return m.OldNumber(ctx)
  13211. case creditusage.FieldPayNumber:
  13212. return m.OldPayNumber(ctx)
  13213. case creditusage.FieldBeforeNumber:
  13214. return m.OldBeforeNumber(ctx)
  13215. case creditusage.FieldAfterNumber:
  13216. return m.OldAfterNumber(ctx)
  13217. case creditusage.FieldPayMethod:
  13218. return m.OldPayMethod(ctx)
  13219. case creditusage.FieldStatus:
  13220. return m.OldStatus(ctx)
  13221. case creditusage.FieldNtype:
  13222. return m.OldNtype(ctx)
  13223. case creditusage.FieldTable:
  13224. return m.OldTable(ctx)
  13225. case creditusage.FieldOrganizationID:
  13226. return m.OldOrganizationID(ctx)
  13227. case creditusage.FieldNid:
  13228. return m.OldNid(ctx)
  13229. case creditusage.FieldReason:
  13230. return m.OldReason(ctx)
  13231. case creditusage.FieldOperator:
  13232. return m.OldOperator(ctx)
  13233. }
  13234. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  13235. }
  13236. // SetField sets the value of a field with the given name. It returns an error if
  13237. // the field is not defined in the schema, or if the type mismatched the field
  13238. // type.
  13239. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  13240. switch name {
  13241. case creditusage.FieldCreatedAt:
  13242. v, ok := value.(time.Time)
  13243. if !ok {
  13244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13245. }
  13246. m.SetCreatedAt(v)
  13247. return nil
  13248. case creditusage.FieldUpdatedAt:
  13249. v, ok := value.(time.Time)
  13250. if !ok {
  13251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13252. }
  13253. m.SetUpdatedAt(v)
  13254. return nil
  13255. case creditusage.FieldDeletedAt:
  13256. v, ok := value.(time.Time)
  13257. if !ok {
  13258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13259. }
  13260. m.SetDeletedAt(v)
  13261. return nil
  13262. case creditusage.FieldUserID:
  13263. v, ok := value.(string)
  13264. if !ok {
  13265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13266. }
  13267. m.SetUserID(v)
  13268. return nil
  13269. case creditusage.FieldNumber:
  13270. v, ok := value.(float32)
  13271. if !ok {
  13272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13273. }
  13274. m.SetNumber(v)
  13275. return nil
  13276. case creditusage.FieldPayNumber:
  13277. v, ok := value.(float32)
  13278. if !ok {
  13279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13280. }
  13281. m.SetPayNumber(v)
  13282. return nil
  13283. case creditusage.FieldBeforeNumber:
  13284. v, ok := value.(float32)
  13285. if !ok {
  13286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13287. }
  13288. m.SetBeforeNumber(v)
  13289. return nil
  13290. case creditusage.FieldAfterNumber:
  13291. v, ok := value.(float32)
  13292. if !ok {
  13293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13294. }
  13295. m.SetAfterNumber(v)
  13296. return nil
  13297. case creditusage.FieldPayMethod:
  13298. v, ok := value.(string)
  13299. if !ok {
  13300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13301. }
  13302. m.SetPayMethod(v)
  13303. return nil
  13304. case creditusage.FieldStatus:
  13305. v, ok := value.(int)
  13306. if !ok {
  13307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13308. }
  13309. m.SetStatus(v)
  13310. return nil
  13311. case creditusage.FieldNtype:
  13312. v, ok := value.(int)
  13313. if !ok {
  13314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13315. }
  13316. m.SetNtype(v)
  13317. return nil
  13318. case creditusage.FieldTable:
  13319. v, ok := value.(string)
  13320. if !ok {
  13321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13322. }
  13323. m.SetTable(v)
  13324. return nil
  13325. case creditusage.FieldOrganizationID:
  13326. v, ok := value.(uint64)
  13327. if !ok {
  13328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13329. }
  13330. m.SetOrganizationID(v)
  13331. return nil
  13332. case creditusage.FieldNid:
  13333. v, ok := value.(uint64)
  13334. if !ok {
  13335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13336. }
  13337. m.SetNid(v)
  13338. return nil
  13339. case creditusage.FieldReason:
  13340. v, ok := value.(string)
  13341. if !ok {
  13342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13343. }
  13344. m.SetReason(v)
  13345. return nil
  13346. case creditusage.FieldOperator:
  13347. v, ok := value.(string)
  13348. if !ok {
  13349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13350. }
  13351. m.SetOperator(v)
  13352. return nil
  13353. }
  13354. return fmt.Errorf("unknown CreditUsage field %s", name)
  13355. }
  13356. // AddedFields returns all numeric fields that were incremented/decremented during
  13357. // this mutation.
  13358. func (m *CreditUsageMutation) AddedFields() []string {
  13359. var fields []string
  13360. if m.addnumber != nil {
  13361. fields = append(fields, creditusage.FieldNumber)
  13362. }
  13363. if m.addpay_number != nil {
  13364. fields = append(fields, creditusage.FieldPayNumber)
  13365. }
  13366. if m.addbefore_number != nil {
  13367. fields = append(fields, creditusage.FieldBeforeNumber)
  13368. }
  13369. if m.addafter_number != nil {
  13370. fields = append(fields, creditusage.FieldAfterNumber)
  13371. }
  13372. if m.addstatus != nil {
  13373. fields = append(fields, creditusage.FieldStatus)
  13374. }
  13375. if m.addntype != nil {
  13376. fields = append(fields, creditusage.FieldNtype)
  13377. }
  13378. if m.addorganization_id != nil {
  13379. fields = append(fields, creditusage.FieldOrganizationID)
  13380. }
  13381. if m.addnid != nil {
  13382. fields = append(fields, creditusage.FieldNid)
  13383. }
  13384. return fields
  13385. }
  13386. // AddedField returns the numeric value that was incremented/decremented on a field
  13387. // with the given name. The second boolean return value indicates that this field
  13388. // was not set, or was not defined in the schema.
  13389. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  13390. switch name {
  13391. case creditusage.FieldNumber:
  13392. return m.AddedNumber()
  13393. case creditusage.FieldPayNumber:
  13394. return m.AddedPayNumber()
  13395. case creditusage.FieldBeforeNumber:
  13396. return m.AddedBeforeNumber()
  13397. case creditusage.FieldAfterNumber:
  13398. return m.AddedAfterNumber()
  13399. case creditusage.FieldStatus:
  13400. return m.AddedStatus()
  13401. case creditusage.FieldNtype:
  13402. return m.AddedNtype()
  13403. case creditusage.FieldOrganizationID:
  13404. return m.AddedOrganizationID()
  13405. case creditusage.FieldNid:
  13406. return m.AddedNid()
  13407. }
  13408. return nil, false
  13409. }
  13410. // AddField adds the value to the field with the given name. It returns an error if
  13411. // the field is not defined in the schema, or if the type mismatched the field
  13412. // type.
  13413. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  13414. switch name {
  13415. case creditusage.FieldNumber:
  13416. v, ok := value.(float32)
  13417. if !ok {
  13418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13419. }
  13420. m.AddNumber(v)
  13421. return nil
  13422. case creditusage.FieldPayNumber:
  13423. v, ok := value.(float32)
  13424. if !ok {
  13425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13426. }
  13427. m.AddPayNumber(v)
  13428. return nil
  13429. case creditusage.FieldBeforeNumber:
  13430. v, ok := value.(float32)
  13431. if !ok {
  13432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13433. }
  13434. m.AddBeforeNumber(v)
  13435. return nil
  13436. case creditusage.FieldAfterNumber:
  13437. v, ok := value.(float32)
  13438. if !ok {
  13439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13440. }
  13441. m.AddAfterNumber(v)
  13442. return nil
  13443. case creditusage.FieldStatus:
  13444. v, ok := value.(int)
  13445. if !ok {
  13446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13447. }
  13448. m.AddStatus(v)
  13449. return nil
  13450. case creditusage.FieldNtype:
  13451. v, ok := value.(int)
  13452. if !ok {
  13453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13454. }
  13455. m.AddNtype(v)
  13456. return nil
  13457. case creditusage.FieldOrganizationID:
  13458. v, ok := value.(int64)
  13459. if !ok {
  13460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13461. }
  13462. m.AddOrganizationID(v)
  13463. return nil
  13464. case creditusage.FieldNid:
  13465. v, ok := value.(int64)
  13466. if !ok {
  13467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13468. }
  13469. m.AddNid(v)
  13470. return nil
  13471. }
  13472. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  13473. }
  13474. // ClearedFields returns all nullable fields that were cleared during this
  13475. // mutation.
  13476. func (m *CreditUsageMutation) ClearedFields() []string {
  13477. var fields []string
  13478. if m.FieldCleared(creditusage.FieldDeletedAt) {
  13479. fields = append(fields, creditusage.FieldDeletedAt)
  13480. }
  13481. if m.FieldCleared(creditusage.FieldUserID) {
  13482. fields = append(fields, creditusage.FieldUserID)
  13483. }
  13484. if m.FieldCleared(creditusage.FieldStatus) {
  13485. fields = append(fields, creditusage.FieldStatus)
  13486. }
  13487. if m.FieldCleared(creditusage.FieldOrganizationID) {
  13488. fields = append(fields, creditusage.FieldOrganizationID)
  13489. }
  13490. return fields
  13491. }
  13492. // FieldCleared returns a boolean indicating if a field with the given name was
  13493. // cleared in this mutation.
  13494. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  13495. _, ok := m.clearedFields[name]
  13496. return ok
  13497. }
  13498. // ClearField clears the value of the field with the given name. It returns an
  13499. // error if the field is not defined in the schema.
  13500. func (m *CreditUsageMutation) ClearField(name string) error {
  13501. switch name {
  13502. case creditusage.FieldDeletedAt:
  13503. m.ClearDeletedAt()
  13504. return nil
  13505. case creditusage.FieldUserID:
  13506. m.ClearUserID()
  13507. return nil
  13508. case creditusage.FieldStatus:
  13509. m.ClearStatus()
  13510. return nil
  13511. case creditusage.FieldOrganizationID:
  13512. m.ClearOrganizationID()
  13513. return nil
  13514. }
  13515. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  13516. }
  13517. // ResetField resets all changes in the mutation for the field with the given name.
  13518. // It returns an error if the field is not defined in the schema.
  13519. func (m *CreditUsageMutation) ResetField(name string) error {
  13520. switch name {
  13521. case creditusage.FieldCreatedAt:
  13522. m.ResetCreatedAt()
  13523. return nil
  13524. case creditusage.FieldUpdatedAt:
  13525. m.ResetUpdatedAt()
  13526. return nil
  13527. case creditusage.FieldDeletedAt:
  13528. m.ResetDeletedAt()
  13529. return nil
  13530. case creditusage.FieldUserID:
  13531. m.ResetUserID()
  13532. return nil
  13533. case creditusage.FieldNumber:
  13534. m.ResetNumber()
  13535. return nil
  13536. case creditusage.FieldPayNumber:
  13537. m.ResetPayNumber()
  13538. return nil
  13539. case creditusage.FieldBeforeNumber:
  13540. m.ResetBeforeNumber()
  13541. return nil
  13542. case creditusage.FieldAfterNumber:
  13543. m.ResetAfterNumber()
  13544. return nil
  13545. case creditusage.FieldPayMethod:
  13546. m.ResetPayMethod()
  13547. return nil
  13548. case creditusage.FieldStatus:
  13549. m.ResetStatus()
  13550. return nil
  13551. case creditusage.FieldNtype:
  13552. m.ResetNtype()
  13553. return nil
  13554. case creditusage.FieldTable:
  13555. m.ResetTable()
  13556. return nil
  13557. case creditusage.FieldOrganizationID:
  13558. m.ResetOrganizationID()
  13559. return nil
  13560. case creditusage.FieldNid:
  13561. m.ResetNid()
  13562. return nil
  13563. case creditusage.FieldReason:
  13564. m.ResetReason()
  13565. return nil
  13566. case creditusage.FieldOperator:
  13567. m.ResetOperator()
  13568. return nil
  13569. }
  13570. return fmt.Errorf("unknown CreditUsage field %s", name)
  13571. }
  13572. // AddedEdges returns all edge names that were set/added in this mutation.
  13573. func (m *CreditUsageMutation) AddedEdges() []string {
  13574. edges := make([]string, 0, 0)
  13575. return edges
  13576. }
  13577. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13578. // name in this mutation.
  13579. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  13580. return nil
  13581. }
  13582. // RemovedEdges returns all edge names that were removed in this mutation.
  13583. func (m *CreditUsageMutation) RemovedEdges() []string {
  13584. edges := make([]string, 0, 0)
  13585. return edges
  13586. }
  13587. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13588. // the given name in this mutation.
  13589. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  13590. return nil
  13591. }
  13592. // ClearedEdges returns all edge names that were cleared in this mutation.
  13593. func (m *CreditUsageMutation) ClearedEdges() []string {
  13594. edges := make([]string, 0, 0)
  13595. return edges
  13596. }
  13597. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13598. // was cleared in this mutation.
  13599. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  13600. return false
  13601. }
  13602. // ClearEdge clears the value of the edge with the given name. It returns an error
  13603. // if that edge is not defined in the schema.
  13604. func (m *CreditUsageMutation) ClearEdge(name string) error {
  13605. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  13606. }
  13607. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13608. // It returns an error if the edge is not defined in the schema.
  13609. func (m *CreditUsageMutation) ResetEdge(name string) error {
  13610. return fmt.Errorf("unknown CreditUsage edge %s", name)
  13611. }
  13612. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  13613. type EmployeeMutation struct {
  13614. config
  13615. op Op
  13616. typ string
  13617. id *uint64
  13618. created_at *time.Time
  13619. updated_at *time.Time
  13620. deleted_at *time.Time
  13621. title *string
  13622. avatar *string
  13623. tags *string
  13624. hire_count *int
  13625. addhire_count *int
  13626. service_count *int
  13627. addservice_count *int
  13628. achievement_count *int
  13629. addachievement_count *int
  13630. intro *string
  13631. estimate *string
  13632. skill *string
  13633. ability_type *string
  13634. scene *string
  13635. switch_in *string
  13636. video_url *string
  13637. organization_id *uint64
  13638. addorganization_id *int64
  13639. category_id *uint64
  13640. addcategory_id *int64
  13641. api_base *string
  13642. api_key *string
  13643. ai_info *string
  13644. is_vip *int
  13645. addis_vip *int
  13646. chat_url *string
  13647. clearedFields map[string]struct{}
  13648. em_work_experiences map[uint64]struct{}
  13649. removedem_work_experiences map[uint64]struct{}
  13650. clearedem_work_experiences bool
  13651. em_tutorial map[uint64]struct{}
  13652. removedem_tutorial map[uint64]struct{}
  13653. clearedem_tutorial bool
  13654. done bool
  13655. oldValue func(context.Context) (*Employee, error)
  13656. predicates []predicate.Employee
  13657. }
  13658. var _ ent.Mutation = (*EmployeeMutation)(nil)
  13659. // employeeOption allows management of the mutation configuration using functional options.
  13660. type employeeOption func(*EmployeeMutation)
  13661. // newEmployeeMutation creates new mutation for the Employee entity.
  13662. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  13663. m := &EmployeeMutation{
  13664. config: c,
  13665. op: op,
  13666. typ: TypeEmployee,
  13667. clearedFields: make(map[string]struct{}),
  13668. }
  13669. for _, opt := range opts {
  13670. opt(m)
  13671. }
  13672. return m
  13673. }
  13674. // withEmployeeID sets the ID field of the mutation.
  13675. func withEmployeeID(id uint64) employeeOption {
  13676. return func(m *EmployeeMutation) {
  13677. var (
  13678. err error
  13679. once sync.Once
  13680. value *Employee
  13681. )
  13682. m.oldValue = func(ctx context.Context) (*Employee, error) {
  13683. once.Do(func() {
  13684. if m.done {
  13685. err = errors.New("querying old values post mutation is not allowed")
  13686. } else {
  13687. value, err = m.Client().Employee.Get(ctx, id)
  13688. }
  13689. })
  13690. return value, err
  13691. }
  13692. m.id = &id
  13693. }
  13694. }
  13695. // withEmployee sets the old Employee of the mutation.
  13696. func withEmployee(node *Employee) employeeOption {
  13697. return func(m *EmployeeMutation) {
  13698. m.oldValue = func(context.Context) (*Employee, error) {
  13699. return node, nil
  13700. }
  13701. m.id = &node.ID
  13702. }
  13703. }
  13704. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13705. // executed in a transaction (ent.Tx), a transactional client is returned.
  13706. func (m EmployeeMutation) Client() *Client {
  13707. client := &Client{config: m.config}
  13708. client.init()
  13709. return client
  13710. }
  13711. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13712. // it returns an error otherwise.
  13713. func (m EmployeeMutation) Tx() (*Tx, error) {
  13714. if _, ok := m.driver.(*txDriver); !ok {
  13715. return nil, errors.New("ent: mutation is not running in a transaction")
  13716. }
  13717. tx := &Tx{config: m.config}
  13718. tx.init()
  13719. return tx, nil
  13720. }
  13721. // SetID sets the value of the id field. Note that this
  13722. // operation is only accepted on creation of Employee entities.
  13723. func (m *EmployeeMutation) SetID(id uint64) {
  13724. m.id = &id
  13725. }
  13726. // ID returns the ID value in the mutation. Note that the ID is only available
  13727. // if it was provided to the builder or after it was returned from the database.
  13728. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  13729. if m.id == nil {
  13730. return
  13731. }
  13732. return *m.id, true
  13733. }
  13734. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13735. // That means, if the mutation is applied within a transaction with an isolation level such
  13736. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13737. // or updated by the mutation.
  13738. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  13739. switch {
  13740. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13741. id, exists := m.ID()
  13742. if exists {
  13743. return []uint64{id}, nil
  13744. }
  13745. fallthrough
  13746. case m.op.Is(OpUpdate | OpDelete):
  13747. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  13748. default:
  13749. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13750. }
  13751. }
  13752. // SetCreatedAt sets the "created_at" field.
  13753. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  13754. m.created_at = &t
  13755. }
  13756. // CreatedAt returns the value of the "created_at" field in the mutation.
  13757. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  13758. v := m.created_at
  13759. if v == nil {
  13760. return
  13761. }
  13762. return *v, true
  13763. }
  13764. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  13765. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13767. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13768. if !m.op.Is(OpUpdateOne) {
  13769. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13770. }
  13771. if m.id == nil || m.oldValue == nil {
  13772. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13773. }
  13774. oldValue, err := m.oldValue(ctx)
  13775. if err != nil {
  13776. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13777. }
  13778. return oldValue.CreatedAt, nil
  13779. }
  13780. // ResetCreatedAt resets all changes to the "created_at" field.
  13781. func (m *EmployeeMutation) ResetCreatedAt() {
  13782. m.created_at = nil
  13783. }
  13784. // SetUpdatedAt sets the "updated_at" field.
  13785. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  13786. m.updated_at = &t
  13787. }
  13788. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13789. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  13790. v := m.updated_at
  13791. if v == nil {
  13792. return
  13793. }
  13794. return *v, true
  13795. }
  13796. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  13797. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13799. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13800. if !m.op.Is(OpUpdateOne) {
  13801. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13802. }
  13803. if m.id == nil || m.oldValue == nil {
  13804. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13805. }
  13806. oldValue, err := m.oldValue(ctx)
  13807. if err != nil {
  13808. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13809. }
  13810. return oldValue.UpdatedAt, nil
  13811. }
  13812. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13813. func (m *EmployeeMutation) ResetUpdatedAt() {
  13814. m.updated_at = nil
  13815. }
  13816. // SetDeletedAt sets the "deleted_at" field.
  13817. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  13818. m.deleted_at = &t
  13819. }
  13820. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13821. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  13822. v := m.deleted_at
  13823. if v == nil {
  13824. return
  13825. }
  13826. return *v, true
  13827. }
  13828. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  13829. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13831. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13832. if !m.op.Is(OpUpdateOne) {
  13833. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13834. }
  13835. if m.id == nil || m.oldValue == nil {
  13836. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13837. }
  13838. oldValue, err := m.oldValue(ctx)
  13839. if err != nil {
  13840. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13841. }
  13842. return oldValue.DeletedAt, nil
  13843. }
  13844. // ClearDeletedAt clears the value of the "deleted_at" field.
  13845. func (m *EmployeeMutation) ClearDeletedAt() {
  13846. m.deleted_at = nil
  13847. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  13848. }
  13849. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13850. func (m *EmployeeMutation) DeletedAtCleared() bool {
  13851. _, ok := m.clearedFields[employee.FieldDeletedAt]
  13852. return ok
  13853. }
  13854. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13855. func (m *EmployeeMutation) ResetDeletedAt() {
  13856. m.deleted_at = nil
  13857. delete(m.clearedFields, employee.FieldDeletedAt)
  13858. }
  13859. // SetTitle sets the "title" field.
  13860. func (m *EmployeeMutation) SetTitle(s string) {
  13861. m.title = &s
  13862. }
  13863. // Title returns the value of the "title" field in the mutation.
  13864. func (m *EmployeeMutation) Title() (r string, exists bool) {
  13865. v := m.title
  13866. if v == nil {
  13867. return
  13868. }
  13869. return *v, true
  13870. }
  13871. // OldTitle returns the old "title" field's value of the Employee entity.
  13872. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13874. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  13875. if !m.op.Is(OpUpdateOne) {
  13876. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13877. }
  13878. if m.id == nil || m.oldValue == nil {
  13879. return v, errors.New("OldTitle requires an ID field in the mutation")
  13880. }
  13881. oldValue, err := m.oldValue(ctx)
  13882. if err != nil {
  13883. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13884. }
  13885. return oldValue.Title, nil
  13886. }
  13887. // ResetTitle resets all changes to the "title" field.
  13888. func (m *EmployeeMutation) ResetTitle() {
  13889. m.title = nil
  13890. }
  13891. // SetAvatar sets the "avatar" field.
  13892. func (m *EmployeeMutation) SetAvatar(s string) {
  13893. m.avatar = &s
  13894. }
  13895. // Avatar returns the value of the "avatar" field in the mutation.
  13896. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  13897. v := m.avatar
  13898. if v == nil {
  13899. return
  13900. }
  13901. return *v, true
  13902. }
  13903. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  13904. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13906. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  13907. if !m.op.Is(OpUpdateOne) {
  13908. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  13909. }
  13910. if m.id == nil || m.oldValue == nil {
  13911. return v, errors.New("OldAvatar requires an ID field in the mutation")
  13912. }
  13913. oldValue, err := m.oldValue(ctx)
  13914. if err != nil {
  13915. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  13916. }
  13917. return oldValue.Avatar, nil
  13918. }
  13919. // ResetAvatar resets all changes to the "avatar" field.
  13920. func (m *EmployeeMutation) ResetAvatar() {
  13921. m.avatar = nil
  13922. }
  13923. // SetTags sets the "tags" field.
  13924. func (m *EmployeeMutation) SetTags(s string) {
  13925. m.tags = &s
  13926. }
  13927. // Tags returns the value of the "tags" field in the mutation.
  13928. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  13929. v := m.tags
  13930. if v == nil {
  13931. return
  13932. }
  13933. return *v, true
  13934. }
  13935. // OldTags returns the old "tags" field's value of the Employee entity.
  13936. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13938. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  13939. if !m.op.Is(OpUpdateOne) {
  13940. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  13941. }
  13942. if m.id == nil || m.oldValue == nil {
  13943. return v, errors.New("OldTags requires an ID field in the mutation")
  13944. }
  13945. oldValue, err := m.oldValue(ctx)
  13946. if err != nil {
  13947. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  13948. }
  13949. return oldValue.Tags, nil
  13950. }
  13951. // ResetTags resets all changes to the "tags" field.
  13952. func (m *EmployeeMutation) ResetTags() {
  13953. m.tags = nil
  13954. }
  13955. // SetHireCount sets the "hire_count" field.
  13956. func (m *EmployeeMutation) SetHireCount(i int) {
  13957. m.hire_count = &i
  13958. m.addhire_count = nil
  13959. }
  13960. // HireCount returns the value of the "hire_count" field in the mutation.
  13961. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  13962. v := m.hire_count
  13963. if v == nil {
  13964. return
  13965. }
  13966. return *v, true
  13967. }
  13968. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  13969. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13971. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  13972. if !m.op.Is(OpUpdateOne) {
  13973. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  13974. }
  13975. if m.id == nil || m.oldValue == nil {
  13976. return v, errors.New("OldHireCount requires an ID field in the mutation")
  13977. }
  13978. oldValue, err := m.oldValue(ctx)
  13979. if err != nil {
  13980. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  13981. }
  13982. return oldValue.HireCount, nil
  13983. }
  13984. // AddHireCount adds i to the "hire_count" field.
  13985. func (m *EmployeeMutation) AddHireCount(i int) {
  13986. if m.addhire_count != nil {
  13987. *m.addhire_count += i
  13988. } else {
  13989. m.addhire_count = &i
  13990. }
  13991. }
  13992. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  13993. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  13994. v := m.addhire_count
  13995. if v == nil {
  13996. return
  13997. }
  13998. return *v, true
  13999. }
  14000. // ResetHireCount resets all changes to the "hire_count" field.
  14001. func (m *EmployeeMutation) ResetHireCount() {
  14002. m.hire_count = nil
  14003. m.addhire_count = nil
  14004. }
  14005. // SetServiceCount sets the "service_count" field.
  14006. func (m *EmployeeMutation) SetServiceCount(i int) {
  14007. m.service_count = &i
  14008. m.addservice_count = nil
  14009. }
  14010. // ServiceCount returns the value of the "service_count" field in the mutation.
  14011. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  14012. v := m.service_count
  14013. if v == nil {
  14014. return
  14015. }
  14016. return *v, true
  14017. }
  14018. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  14019. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14021. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  14022. if !m.op.Is(OpUpdateOne) {
  14023. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  14024. }
  14025. if m.id == nil || m.oldValue == nil {
  14026. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  14027. }
  14028. oldValue, err := m.oldValue(ctx)
  14029. if err != nil {
  14030. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  14031. }
  14032. return oldValue.ServiceCount, nil
  14033. }
  14034. // AddServiceCount adds i to the "service_count" field.
  14035. func (m *EmployeeMutation) AddServiceCount(i int) {
  14036. if m.addservice_count != nil {
  14037. *m.addservice_count += i
  14038. } else {
  14039. m.addservice_count = &i
  14040. }
  14041. }
  14042. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  14043. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  14044. v := m.addservice_count
  14045. if v == nil {
  14046. return
  14047. }
  14048. return *v, true
  14049. }
  14050. // ResetServiceCount resets all changes to the "service_count" field.
  14051. func (m *EmployeeMutation) ResetServiceCount() {
  14052. m.service_count = nil
  14053. m.addservice_count = nil
  14054. }
  14055. // SetAchievementCount sets the "achievement_count" field.
  14056. func (m *EmployeeMutation) SetAchievementCount(i int) {
  14057. m.achievement_count = &i
  14058. m.addachievement_count = nil
  14059. }
  14060. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  14061. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  14062. v := m.achievement_count
  14063. if v == nil {
  14064. return
  14065. }
  14066. return *v, true
  14067. }
  14068. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  14069. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14071. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  14072. if !m.op.Is(OpUpdateOne) {
  14073. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  14074. }
  14075. if m.id == nil || m.oldValue == nil {
  14076. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  14077. }
  14078. oldValue, err := m.oldValue(ctx)
  14079. if err != nil {
  14080. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  14081. }
  14082. return oldValue.AchievementCount, nil
  14083. }
  14084. // AddAchievementCount adds i to the "achievement_count" field.
  14085. func (m *EmployeeMutation) AddAchievementCount(i int) {
  14086. if m.addachievement_count != nil {
  14087. *m.addachievement_count += i
  14088. } else {
  14089. m.addachievement_count = &i
  14090. }
  14091. }
  14092. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  14093. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  14094. v := m.addachievement_count
  14095. if v == nil {
  14096. return
  14097. }
  14098. return *v, true
  14099. }
  14100. // ResetAchievementCount resets all changes to the "achievement_count" field.
  14101. func (m *EmployeeMutation) ResetAchievementCount() {
  14102. m.achievement_count = nil
  14103. m.addachievement_count = nil
  14104. }
  14105. // SetIntro sets the "intro" field.
  14106. func (m *EmployeeMutation) SetIntro(s string) {
  14107. m.intro = &s
  14108. }
  14109. // Intro returns the value of the "intro" field in the mutation.
  14110. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  14111. v := m.intro
  14112. if v == nil {
  14113. return
  14114. }
  14115. return *v, true
  14116. }
  14117. // OldIntro returns the old "intro" field's value of the Employee entity.
  14118. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14120. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  14121. if !m.op.Is(OpUpdateOne) {
  14122. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  14123. }
  14124. if m.id == nil || m.oldValue == nil {
  14125. return v, errors.New("OldIntro requires an ID field in the mutation")
  14126. }
  14127. oldValue, err := m.oldValue(ctx)
  14128. if err != nil {
  14129. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  14130. }
  14131. return oldValue.Intro, nil
  14132. }
  14133. // ResetIntro resets all changes to the "intro" field.
  14134. func (m *EmployeeMutation) ResetIntro() {
  14135. m.intro = nil
  14136. }
  14137. // SetEstimate sets the "estimate" field.
  14138. func (m *EmployeeMutation) SetEstimate(s string) {
  14139. m.estimate = &s
  14140. }
  14141. // Estimate returns the value of the "estimate" field in the mutation.
  14142. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  14143. v := m.estimate
  14144. if v == nil {
  14145. return
  14146. }
  14147. return *v, true
  14148. }
  14149. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  14150. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14152. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  14153. if !m.op.Is(OpUpdateOne) {
  14154. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  14155. }
  14156. if m.id == nil || m.oldValue == nil {
  14157. return v, errors.New("OldEstimate requires an ID field in the mutation")
  14158. }
  14159. oldValue, err := m.oldValue(ctx)
  14160. if err != nil {
  14161. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  14162. }
  14163. return oldValue.Estimate, nil
  14164. }
  14165. // ResetEstimate resets all changes to the "estimate" field.
  14166. func (m *EmployeeMutation) ResetEstimate() {
  14167. m.estimate = nil
  14168. }
  14169. // SetSkill sets the "skill" field.
  14170. func (m *EmployeeMutation) SetSkill(s string) {
  14171. m.skill = &s
  14172. }
  14173. // Skill returns the value of the "skill" field in the mutation.
  14174. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  14175. v := m.skill
  14176. if v == nil {
  14177. return
  14178. }
  14179. return *v, true
  14180. }
  14181. // OldSkill returns the old "skill" field's value of the Employee entity.
  14182. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14184. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  14185. if !m.op.Is(OpUpdateOne) {
  14186. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  14187. }
  14188. if m.id == nil || m.oldValue == nil {
  14189. return v, errors.New("OldSkill requires an ID field in the mutation")
  14190. }
  14191. oldValue, err := m.oldValue(ctx)
  14192. if err != nil {
  14193. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  14194. }
  14195. return oldValue.Skill, nil
  14196. }
  14197. // ResetSkill resets all changes to the "skill" field.
  14198. func (m *EmployeeMutation) ResetSkill() {
  14199. m.skill = nil
  14200. }
  14201. // SetAbilityType sets the "ability_type" field.
  14202. func (m *EmployeeMutation) SetAbilityType(s string) {
  14203. m.ability_type = &s
  14204. }
  14205. // AbilityType returns the value of the "ability_type" field in the mutation.
  14206. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  14207. v := m.ability_type
  14208. if v == nil {
  14209. return
  14210. }
  14211. return *v, true
  14212. }
  14213. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  14214. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14216. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  14217. if !m.op.Is(OpUpdateOne) {
  14218. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  14219. }
  14220. if m.id == nil || m.oldValue == nil {
  14221. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  14222. }
  14223. oldValue, err := m.oldValue(ctx)
  14224. if err != nil {
  14225. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  14226. }
  14227. return oldValue.AbilityType, nil
  14228. }
  14229. // ResetAbilityType resets all changes to the "ability_type" field.
  14230. func (m *EmployeeMutation) ResetAbilityType() {
  14231. m.ability_type = nil
  14232. }
  14233. // SetScene sets the "scene" field.
  14234. func (m *EmployeeMutation) SetScene(s string) {
  14235. m.scene = &s
  14236. }
  14237. // Scene returns the value of the "scene" field in the mutation.
  14238. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  14239. v := m.scene
  14240. if v == nil {
  14241. return
  14242. }
  14243. return *v, true
  14244. }
  14245. // OldScene returns the old "scene" field's value of the Employee entity.
  14246. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14248. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  14249. if !m.op.Is(OpUpdateOne) {
  14250. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  14251. }
  14252. if m.id == nil || m.oldValue == nil {
  14253. return v, errors.New("OldScene requires an ID field in the mutation")
  14254. }
  14255. oldValue, err := m.oldValue(ctx)
  14256. if err != nil {
  14257. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  14258. }
  14259. return oldValue.Scene, nil
  14260. }
  14261. // ResetScene resets all changes to the "scene" field.
  14262. func (m *EmployeeMutation) ResetScene() {
  14263. m.scene = nil
  14264. }
  14265. // SetSwitchIn sets the "switch_in" field.
  14266. func (m *EmployeeMutation) SetSwitchIn(s string) {
  14267. m.switch_in = &s
  14268. }
  14269. // SwitchIn returns the value of the "switch_in" field in the mutation.
  14270. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  14271. v := m.switch_in
  14272. if v == nil {
  14273. return
  14274. }
  14275. return *v, true
  14276. }
  14277. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  14278. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14280. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  14281. if !m.op.Is(OpUpdateOne) {
  14282. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  14283. }
  14284. if m.id == nil || m.oldValue == nil {
  14285. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  14286. }
  14287. oldValue, err := m.oldValue(ctx)
  14288. if err != nil {
  14289. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  14290. }
  14291. return oldValue.SwitchIn, nil
  14292. }
  14293. // ResetSwitchIn resets all changes to the "switch_in" field.
  14294. func (m *EmployeeMutation) ResetSwitchIn() {
  14295. m.switch_in = nil
  14296. }
  14297. // SetVideoURL sets the "video_url" field.
  14298. func (m *EmployeeMutation) SetVideoURL(s string) {
  14299. m.video_url = &s
  14300. }
  14301. // VideoURL returns the value of the "video_url" field in the mutation.
  14302. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  14303. v := m.video_url
  14304. if v == nil {
  14305. return
  14306. }
  14307. return *v, true
  14308. }
  14309. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  14310. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14312. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  14313. if !m.op.Is(OpUpdateOne) {
  14314. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  14315. }
  14316. if m.id == nil || m.oldValue == nil {
  14317. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  14318. }
  14319. oldValue, err := m.oldValue(ctx)
  14320. if err != nil {
  14321. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  14322. }
  14323. return oldValue.VideoURL, nil
  14324. }
  14325. // ResetVideoURL resets all changes to the "video_url" field.
  14326. func (m *EmployeeMutation) ResetVideoURL() {
  14327. m.video_url = nil
  14328. }
  14329. // SetOrganizationID sets the "organization_id" field.
  14330. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  14331. m.organization_id = &u
  14332. m.addorganization_id = nil
  14333. }
  14334. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14335. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  14336. v := m.organization_id
  14337. if v == nil {
  14338. return
  14339. }
  14340. return *v, true
  14341. }
  14342. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  14343. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14345. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14346. if !m.op.Is(OpUpdateOne) {
  14347. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14348. }
  14349. if m.id == nil || m.oldValue == nil {
  14350. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14351. }
  14352. oldValue, err := m.oldValue(ctx)
  14353. if err != nil {
  14354. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14355. }
  14356. return oldValue.OrganizationID, nil
  14357. }
  14358. // AddOrganizationID adds u to the "organization_id" field.
  14359. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  14360. if m.addorganization_id != nil {
  14361. *m.addorganization_id += u
  14362. } else {
  14363. m.addorganization_id = &u
  14364. }
  14365. }
  14366. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14367. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  14368. v := m.addorganization_id
  14369. if v == nil {
  14370. return
  14371. }
  14372. return *v, true
  14373. }
  14374. // ResetOrganizationID resets all changes to the "organization_id" field.
  14375. func (m *EmployeeMutation) ResetOrganizationID() {
  14376. m.organization_id = nil
  14377. m.addorganization_id = nil
  14378. }
  14379. // SetCategoryID sets the "category_id" field.
  14380. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  14381. m.category_id = &u
  14382. m.addcategory_id = nil
  14383. }
  14384. // CategoryID returns the value of the "category_id" field in the mutation.
  14385. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  14386. v := m.category_id
  14387. if v == nil {
  14388. return
  14389. }
  14390. return *v, true
  14391. }
  14392. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  14393. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14395. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  14396. if !m.op.Is(OpUpdateOne) {
  14397. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  14398. }
  14399. if m.id == nil || m.oldValue == nil {
  14400. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  14401. }
  14402. oldValue, err := m.oldValue(ctx)
  14403. if err != nil {
  14404. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  14405. }
  14406. return oldValue.CategoryID, nil
  14407. }
  14408. // AddCategoryID adds u to the "category_id" field.
  14409. func (m *EmployeeMutation) AddCategoryID(u int64) {
  14410. if m.addcategory_id != nil {
  14411. *m.addcategory_id += u
  14412. } else {
  14413. m.addcategory_id = &u
  14414. }
  14415. }
  14416. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  14417. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  14418. v := m.addcategory_id
  14419. if v == nil {
  14420. return
  14421. }
  14422. return *v, true
  14423. }
  14424. // ResetCategoryID resets all changes to the "category_id" field.
  14425. func (m *EmployeeMutation) ResetCategoryID() {
  14426. m.category_id = nil
  14427. m.addcategory_id = nil
  14428. }
  14429. // SetAPIBase sets the "api_base" field.
  14430. func (m *EmployeeMutation) SetAPIBase(s string) {
  14431. m.api_base = &s
  14432. }
  14433. // APIBase returns the value of the "api_base" field in the mutation.
  14434. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  14435. v := m.api_base
  14436. if v == nil {
  14437. return
  14438. }
  14439. return *v, true
  14440. }
  14441. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  14442. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14444. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  14445. if !m.op.Is(OpUpdateOne) {
  14446. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  14447. }
  14448. if m.id == nil || m.oldValue == nil {
  14449. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  14450. }
  14451. oldValue, err := m.oldValue(ctx)
  14452. if err != nil {
  14453. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  14454. }
  14455. return oldValue.APIBase, nil
  14456. }
  14457. // ResetAPIBase resets all changes to the "api_base" field.
  14458. func (m *EmployeeMutation) ResetAPIBase() {
  14459. m.api_base = nil
  14460. }
  14461. // SetAPIKey sets the "api_key" field.
  14462. func (m *EmployeeMutation) SetAPIKey(s string) {
  14463. m.api_key = &s
  14464. }
  14465. // APIKey returns the value of the "api_key" field in the mutation.
  14466. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  14467. v := m.api_key
  14468. if v == nil {
  14469. return
  14470. }
  14471. return *v, true
  14472. }
  14473. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  14474. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14476. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  14477. if !m.op.Is(OpUpdateOne) {
  14478. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  14479. }
  14480. if m.id == nil || m.oldValue == nil {
  14481. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  14482. }
  14483. oldValue, err := m.oldValue(ctx)
  14484. if err != nil {
  14485. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  14486. }
  14487. return oldValue.APIKey, nil
  14488. }
  14489. // ResetAPIKey resets all changes to the "api_key" field.
  14490. func (m *EmployeeMutation) ResetAPIKey() {
  14491. m.api_key = nil
  14492. }
  14493. // SetAiInfo sets the "ai_info" field.
  14494. func (m *EmployeeMutation) SetAiInfo(s string) {
  14495. m.ai_info = &s
  14496. }
  14497. // AiInfo returns the value of the "ai_info" field in the mutation.
  14498. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  14499. v := m.ai_info
  14500. if v == nil {
  14501. return
  14502. }
  14503. return *v, true
  14504. }
  14505. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  14506. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14508. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  14509. if !m.op.Is(OpUpdateOne) {
  14510. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  14511. }
  14512. if m.id == nil || m.oldValue == nil {
  14513. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  14514. }
  14515. oldValue, err := m.oldValue(ctx)
  14516. if err != nil {
  14517. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  14518. }
  14519. return oldValue.AiInfo, nil
  14520. }
  14521. // ClearAiInfo clears the value of the "ai_info" field.
  14522. func (m *EmployeeMutation) ClearAiInfo() {
  14523. m.ai_info = nil
  14524. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  14525. }
  14526. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  14527. func (m *EmployeeMutation) AiInfoCleared() bool {
  14528. _, ok := m.clearedFields[employee.FieldAiInfo]
  14529. return ok
  14530. }
  14531. // ResetAiInfo resets all changes to the "ai_info" field.
  14532. func (m *EmployeeMutation) ResetAiInfo() {
  14533. m.ai_info = nil
  14534. delete(m.clearedFields, employee.FieldAiInfo)
  14535. }
  14536. // SetIsVip sets the "is_vip" field.
  14537. func (m *EmployeeMutation) SetIsVip(i int) {
  14538. m.is_vip = &i
  14539. m.addis_vip = nil
  14540. }
  14541. // IsVip returns the value of the "is_vip" field in the mutation.
  14542. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  14543. v := m.is_vip
  14544. if v == nil {
  14545. return
  14546. }
  14547. return *v, true
  14548. }
  14549. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  14550. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14552. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  14553. if !m.op.Is(OpUpdateOne) {
  14554. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  14555. }
  14556. if m.id == nil || m.oldValue == nil {
  14557. return v, errors.New("OldIsVip requires an ID field in the mutation")
  14558. }
  14559. oldValue, err := m.oldValue(ctx)
  14560. if err != nil {
  14561. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  14562. }
  14563. return oldValue.IsVip, nil
  14564. }
  14565. // AddIsVip adds i to the "is_vip" field.
  14566. func (m *EmployeeMutation) AddIsVip(i int) {
  14567. if m.addis_vip != nil {
  14568. *m.addis_vip += i
  14569. } else {
  14570. m.addis_vip = &i
  14571. }
  14572. }
  14573. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  14574. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  14575. v := m.addis_vip
  14576. if v == nil {
  14577. return
  14578. }
  14579. return *v, true
  14580. }
  14581. // ResetIsVip resets all changes to the "is_vip" field.
  14582. func (m *EmployeeMutation) ResetIsVip() {
  14583. m.is_vip = nil
  14584. m.addis_vip = nil
  14585. }
  14586. // SetChatURL sets the "chat_url" field.
  14587. func (m *EmployeeMutation) SetChatURL(s string) {
  14588. m.chat_url = &s
  14589. }
  14590. // ChatURL returns the value of the "chat_url" field in the mutation.
  14591. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  14592. v := m.chat_url
  14593. if v == nil {
  14594. return
  14595. }
  14596. return *v, true
  14597. }
  14598. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  14599. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14601. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  14602. if !m.op.Is(OpUpdateOne) {
  14603. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  14604. }
  14605. if m.id == nil || m.oldValue == nil {
  14606. return v, errors.New("OldChatURL requires an ID field in the mutation")
  14607. }
  14608. oldValue, err := m.oldValue(ctx)
  14609. if err != nil {
  14610. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  14611. }
  14612. return oldValue.ChatURL, nil
  14613. }
  14614. // ResetChatURL resets all changes to the "chat_url" field.
  14615. func (m *EmployeeMutation) ResetChatURL() {
  14616. m.chat_url = nil
  14617. }
  14618. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  14619. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  14620. if m.em_work_experiences == nil {
  14621. m.em_work_experiences = make(map[uint64]struct{})
  14622. }
  14623. for i := range ids {
  14624. m.em_work_experiences[ids[i]] = struct{}{}
  14625. }
  14626. }
  14627. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  14628. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  14629. m.clearedem_work_experiences = true
  14630. }
  14631. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  14632. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  14633. return m.clearedem_work_experiences
  14634. }
  14635. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  14636. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  14637. if m.removedem_work_experiences == nil {
  14638. m.removedem_work_experiences = make(map[uint64]struct{})
  14639. }
  14640. for i := range ids {
  14641. delete(m.em_work_experiences, ids[i])
  14642. m.removedem_work_experiences[ids[i]] = struct{}{}
  14643. }
  14644. }
  14645. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  14646. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  14647. for id := range m.removedem_work_experiences {
  14648. ids = append(ids, id)
  14649. }
  14650. return
  14651. }
  14652. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  14653. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  14654. for id := range m.em_work_experiences {
  14655. ids = append(ids, id)
  14656. }
  14657. return
  14658. }
  14659. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  14660. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  14661. m.em_work_experiences = nil
  14662. m.clearedem_work_experiences = false
  14663. m.removedem_work_experiences = nil
  14664. }
  14665. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  14666. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  14667. if m.em_tutorial == nil {
  14668. m.em_tutorial = make(map[uint64]struct{})
  14669. }
  14670. for i := range ids {
  14671. m.em_tutorial[ids[i]] = struct{}{}
  14672. }
  14673. }
  14674. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  14675. func (m *EmployeeMutation) ClearEmTutorial() {
  14676. m.clearedem_tutorial = true
  14677. }
  14678. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  14679. func (m *EmployeeMutation) EmTutorialCleared() bool {
  14680. return m.clearedem_tutorial
  14681. }
  14682. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  14683. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  14684. if m.removedem_tutorial == nil {
  14685. m.removedem_tutorial = make(map[uint64]struct{})
  14686. }
  14687. for i := range ids {
  14688. delete(m.em_tutorial, ids[i])
  14689. m.removedem_tutorial[ids[i]] = struct{}{}
  14690. }
  14691. }
  14692. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  14693. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  14694. for id := range m.removedem_tutorial {
  14695. ids = append(ids, id)
  14696. }
  14697. return
  14698. }
  14699. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  14700. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  14701. for id := range m.em_tutorial {
  14702. ids = append(ids, id)
  14703. }
  14704. return
  14705. }
  14706. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  14707. func (m *EmployeeMutation) ResetEmTutorial() {
  14708. m.em_tutorial = nil
  14709. m.clearedem_tutorial = false
  14710. m.removedem_tutorial = nil
  14711. }
  14712. // Where appends a list predicates to the EmployeeMutation builder.
  14713. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  14714. m.predicates = append(m.predicates, ps...)
  14715. }
  14716. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  14717. // users can use type-assertion to append predicates that do not depend on any generated package.
  14718. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  14719. p := make([]predicate.Employee, len(ps))
  14720. for i := range ps {
  14721. p[i] = ps[i]
  14722. }
  14723. m.Where(p...)
  14724. }
  14725. // Op returns the operation name.
  14726. func (m *EmployeeMutation) Op() Op {
  14727. return m.op
  14728. }
  14729. // SetOp allows setting the mutation operation.
  14730. func (m *EmployeeMutation) SetOp(op Op) {
  14731. m.op = op
  14732. }
  14733. // Type returns the node type of this mutation (Employee).
  14734. func (m *EmployeeMutation) Type() string {
  14735. return m.typ
  14736. }
  14737. // Fields returns all fields that were changed during this mutation. Note that in
  14738. // order to get all numeric fields that were incremented/decremented, call
  14739. // AddedFields().
  14740. func (m *EmployeeMutation) Fields() []string {
  14741. fields := make([]string, 0, 23)
  14742. if m.created_at != nil {
  14743. fields = append(fields, employee.FieldCreatedAt)
  14744. }
  14745. if m.updated_at != nil {
  14746. fields = append(fields, employee.FieldUpdatedAt)
  14747. }
  14748. if m.deleted_at != nil {
  14749. fields = append(fields, employee.FieldDeletedAt)
  14750. }
  14751. if m.title != nil {
  14752. fields = append(fields, employee.FieldTitle)
  14753. }
  14754. if m.avatar != nil {
  14755. fields = append(fields, employee.FieldAvatar)
  14756. }
  14757. if m.tags != nil {
  14758. fields = append(fields, employee.FieldTags)
  14759. }
  14760. if m.hire_count != nil {
  14761. fields = append(fields, employee.FieldHireCount)
  14762. }
  14763. if m.service_count != nil {
  14764. fields = append(fields, employee.FieldServiceCount)
  14765. }
  14766. if m.achievement_count != nil {
  14767. fields = append(fields, employee.FieldAchievementCount)
  14768. }
  14769. if m.intro != nil {
  14770. fields = append(fields, employee.FieldIntro)
  14771. }
  14772. if m.estimate != nil {
  14773. fields = append(fields, employee.FieldEstimate)
  14774. }
  14775. if m.skill != nil {
  14776. fields = append(fields, employee.FieldSkill)
  14777. }
  14778. if m.ability_type != nil {
  14779. fields = append(fields, employee.FieldAbilityType)
  14780. }
  14781. if m.scene != nil {
  14782. fields = append(fields, employee.FieldScene)
  14783. }
  14784. if m.switch_in != nil {
  14785. fields = append(fields, employee.FieldSwitchIn)
  14786. }
  14787. if m.video_url != nil {
  14788. fields = append(fields, employee.FieldVideoURL)
  14789. }
  14790. if m.organization_id != nil {
  14791. fields = append(fields, employee.FieldOrganizationID)
  14792. }
  14793. if m.category_id != nil {
  14794. fields = append(fields, employee.FieldCategoryID)
  14795. }
  14796. if m.api_base != nil {
  14797. fields = append(fields, employee.FieldAPIBase)
  14798. }
  14799. if m.api_key != nil {
  14800. fields = append(fields, employee.FieldAPIKey)
  14801. }
  14802. if m.ai_info != nil {
  14803. fields = append(fields, employee.FieldAiInfo)
  14804. }
  14805. if m.is_vip != nil {
  14806. fields = append(fields, employee.FieldIsVip)
  14807. }
  14808. if m.chat_url != nil {
  14809. fields = append(fields, employee.FieldChatURL)
  14810. }
  14811. return fields
  14812. }
  14813. // Field returns the value of a field with the given name. The second boolean
  14814. // return value indicates that this field was not set, or was not defined in the
  14815. // schema.
  14816. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  14817. switch name {
  14818. case employee.FieldCreatedAt:
  14819. return m.CreatedAt()
  14820. case employee.FieldUpdatedAt:
  14821. return m.UpdatedAt()
  14822. case employee.FieldDeletedAt:
  14823. return m.DeletedAt()
  14824. case employee.FieldTitle:
  14825. return m.Title()
  14826. case employee.FieldAvatar:
  14827. return m.Avatar()
  14828. case employee.FieldTags:
  14829. return m.Tags()
  14830. case employee.FieldHireCount:
  14831. return m.HireCount()
  14832. case employee.FieldServiceCount:
  14833. return m.ServiceCount()
  14834. case employee.FieldAchievementCount:
  14835. return m.AchievementCount()
  14836. case employee.FieldIntro:
  14837. return m.Intro()
  14838. case employee.FieldEstimate:
  14839. return m.Estimate()
  14840. case employee.FieldSkill:
  14841. return m.Skill()
  14842. case employee.FieldAbilityType:
  14843. return m.AbilityType()
  14844. case employee.FieldScene:
  14845. return m.Scene()
  14846. case employee.FieldSwitchIn:
  14847. return m.SwitchIn()
  14848. case employee.FieldVideoURL:
  14849. return m.VideoURL()
  14850. case employee.FieldOrganizationID:
  14851. return m.OrganizationID()
  14852. case employee.FieldCategoryID:
  14853. return m.CategoryID()
  14854. case employee.FieldAPIBase:
  14855. return m.APIBase()
  14856. case employee.FieldAPIKey:
  14857. return m.APIKey()
  14858. case employee.FieldAiInfo:
  14859. return m.AiInfo()
  14860. case employee.FieldIsVip:
  14861. return m.IsVip()
  14862. case employee.FieldChatURL:
  14863. return m.ChatURL()
  14864. }
  14865. return nil, false
  14866. }
  14867. // OldField returns the old value of the field from the database. An error is
  14868. // returned if the mutation operation is not UpdateOne, or the query to the
  14869. // database failed.
  14870. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14871. switch name {
  14872. case employee.FieldCreatedAt:
  14873. return m.OldCreatedAt(ctx)
  14874. case employee.FieldUpdatedAt:
  14875. return m.OldUpdatedAt(ctx)
  14876. case employee.FieldDeletedAt:
  14877. return m.OldDeletedAt(ctx)
  14878. case employee.FieldTitle:
  14879. return m.OldTitle(ctx)
  14880. case employee.FieldAvatar:
  14881. return m.OldAvatar(ctx)
  14882. case employee.FieldTags:
  14883. return m.OldTags(ctx)
  14884. case employee.FieldHireCount:
  14885. return m.OldHireCount(ctx)
  14886. case employee.FieldServiceCount:
  14887. return m.OldServiceCount(ctx)
  14888. case employee.FieldAchievementCount:
  14889. return m.OldAchievementCount(ctx)
  14890. case employee.FieldIntro:
  14891. return m.OldIntro(ctx)
  14892. case employee.FieldEstimate:
  14893. return m.OldEstimate(ctx)
  14894. case employee.FieldSkill:
  14895. return m.OldSkill(ctx)
  14896. case employee.FieldAbilityType:
  14897. return m.OldAbilityType(ctx)
  14898. case employee.FieldScene:
  14899. return m.OldScene(ctx)
  14900. case employee.FieldSwitchIn:
  14901. return m.OldSwitchIn(ctx)
  14902. case employee.FieldVideoURL:
  14903. return m.OldVideoURL(ctx)
  14904. case employee.FieldOrganizationID:
  14905. return m.OldOrganizationID(ctx)
  14906. case employee.FieldCategoryID:
  14907. return m.OldCategoryID(ctx)
  14908. case employee.FieldAPIBase:
  14909. return m.OldAPIBase(ctx)
  14910. case employee.FieldAPIKey:
  14911. return m.OldAPIKey(ctx)
  14912. case employee.FieldAiInfo:
  14913. return m.OldAiInfo(ctx)
  14914. case employee.FieldIsVip:
  14915. return m.OldIsVip(ctx)
  14916. case employee.FieldChatURL:
  14917. return m.OldChatURL(ctx)
  14918. }
  14919. return nil, fmt.Errorf("unknown Employee field %s", name)
  14920. }
  14921. // SetField sets the value of a field with the given name. It returns an error if
  14922. // the field is not defined in the schema, or if the type mismatched the field
  14923. // type.
  14924. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  14925. switch name {
  14926. case employee.FieldCreatedAt:
  14927. v, ok := value.(time.Time)
  14928. if !ok {
  14929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14930. }
  14931. m.SetCreatedAt(v)
  14932. return nil
  14933. case employee.FieldUpdatedAt:
  14934. v, ok := value.(time.Time)
  14935. if !ok {
  14936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14937. }
  14938. m.SetUpdatedAt(v)
  14939. return nil
  14940. case employee.FieldDeletedAt:
  14941. v, ok := value.(time.Time)
  14942. if !ok {
  14943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14944. }
  14945. m.SetDeletedAt(v)
  14946. return nil
  14947. case employee.FieldTitle:
  14948. v, ok := value.(string)
  14949. if !ok {
  14950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14951. }
  14952. m.SetTitle(v)
  14953. return nil
  14954. case employee.FieldAvatar:
  14955. v, ok := value.(string)
  14956. if !ok {
  14957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14958. }
  14959. m.SetAvatar(v)
  14960. return nil
  14961. case employee.FieldTags:
  14962. v, ok := value.(string)
  14963. if !ok {
  14964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14965. }
  14966. m.SetTags(v)
  14967. return nil
  14968. case employee.FieldHireCount:
  14969. v, ok := value.(int)
  14970. if !ok {
  14971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14972. }
  14973. m.SetHireCount(v)
  14974. return nil
  14975. case employee.FieldServiceCount:
  14976. v, ok := value.(int)
  14977. if !ok {
  14978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14979. }
  14980. m.SetServiceCount(v)
  14981. return nil
  14982. case employee.FieldAchievementCount:
  14983. v, ok := value.(int)
  14984. if !ok {
  14985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14986. }
  14987. m.SetAchievementCount(v)
  14988. return nil
  14989. case employee.FieldIntro:
  14990. v, ok := value.(string)
  14991. if !ok {
  14992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14993. }
  14994. m.SetIntro(v)
  14995. return nil
  14996. case employee.FieldEstimate:
  14997. v, ok := value.(string)
  14998. if !ok {
  14999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15000. }
  15001. m.SetEstimate(v)
  15002. return nil
  15003. case employee.FieldSkill:
  15004. v, ok := value.(string)
  15005. if !ok {
  15006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15007. }
  15008. m.SetSkill(v)
  15009. return nil
  15010. case employee.FieldAbilityType:
  15011. v, ok := value.(string)
  15012. if !ok {
  15013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15014. }
  15015. m.SetAbilityType(v)
  15016. return nil
  15017. case employee.FieldScene:
  15018. v, ok := value.(string)
  15019. if !ok {
  15020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15021. }
  15022. m.SetScene(v)
  15023. return nil
  15024. case employee.FieldSwitchIn:
  15025. v, ok := value.(string)
  15026. if !ok {
  15027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15028. }
  15029. m.SetSwitchIn(v)
  15030. return nil
  15031. case employee.FieldVideoURL:
  15032. v, ok := value.(string)
  15033. if !ok {
  15034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15035. }
  15036. m.SetVideoURL(v)
  15037. return nil
  15038. case employee.FieldOrganizationID:
  15039. v, ok := value.(uint64)
  15040. if !ok {
  15041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15042. }
  15043. m.SetOrganizationID(v)
  15044. return nil
  15045. case employee.FieldCategoryID:
  15046. v, ok := value.(uint64)
  15047. if !ok {
  15048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15049. }
  15050. m.SetCategoryID(v)
  15051. return nil
  15052. case employee.FieldAPIBase:
  15053. v, ok := value.(string)
  15054. if !ok {
  15055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15056. }
  15057. m.SetAPIBase(v)
  15058. return nil
  15059. case employee.FieldAPIKey:
  15060. v, ok := value.(string)
  15061. if !ok {
  15062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15063. }
  15064. m.SetAPIKey(v)
  15065. return nil
  15066. case employee.FieldAiInfo:
  15067. v, ok := value.(string)
  15068. if !ok {
  15069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15070. }
  15071. m.SetAiInfo(v)
  15072. return nil
  15073. case employee.FieldIsVip:
  15074. v, ok := value.(int)
  15075. if !ok {
  15076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15077. }
  15078. m.SetIsVip(v)
  15079. return nil
  15080. case employee.FieldChatURL:
  15081. v, ok := value.(string)
  15082. if !ok {
  15083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15084. }
  15085. m.SetChatURL(v)
  15086. return nil
  15087. }
  15088. return fmt.Errorf("unknown Employee field %s", name)
  15089. }
  15090. // AddedFields returns all numeric fields that were incremented/decremented during
  15091. // this mutation.
  15092. func (m *EmployeeMutation) AddedFields() []string {
  15093. var fields []string
  15094. if m.addhire_count != nil {
  15095. fields = append(fields, employee.FieldHireCount)
  15096. }
  15097. if m.addservice_count != nil {
  15098. fields = append(fields, employee.FieldServiceCount)
  15099. }
  15100. if m.addachievement_count != nil {
  15101. fields = append(fields, employee.FieldAchievementCount)
  15102. }
  15103. if m.addorganization_id != nil {
  15104. fields = append(fields, employee.FieldOrganizationID)
  15105. }
  15106. if m.addcategory_id != nil {
  15107. fields = append(fields, employee.FieldCategoryID)
  15108. }
  15109. if m.addis_vip != nil {
  15110. fields = append(fields, employee.FieldIsVip)
  15111. }
  15112. return fields
  15113. }
  15114. // AddedField returns the numeric value that was incremented/decremented on a field
  15115. // with the given name. The second boolean return value indicates that this field
  15116. // was not set, or was not defined in the schema.
  15117. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  15118. switch name {
  15119. case employee.FieldHireCount:
  15120. return m.AddedHireCount()
  15121. case employee.FieldServiceCount:
  15122. return m.AddedServiceCount()
  15123. case employee.FieldAchievementCount:
  15124. return m.AddedAchievementCount()
  15125. case employee.FieldOrganizationID:
  15126. return m.AddedOrganizationID()
  15127. case employee.FieldCategoryID:
  15128. return m.AddedCategoryID()
  15129. case employee.FieldIsVip:
  15130. return m.AddedIsVip()
  15131. }
  15132. return nil, false
  15133. }
  15134. // AddField adds the value to the field with the given name. It returns an error if
  15135. // the field is not defined in the schema, or if the type mismatched the field
  15136. // type.
  15137. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  15138. switch name {
  15139. case employee.FieldHireCount:
  15140. v, ok := value.(int)
  15141. if !ok {
  15142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15143. }
  15144. m.AddHireCount(v)
  15145. return nil
  15146. case employee.FieldServiceCount:
  15147. v, ok := value.(int)
  15148. if !ok {
  15149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15150. }
  15151. m.AddServiceCount(v)
  15152. return nil
  15153. case employee.FieldAchievementCount:
  15154. v, ok := value.(int)
  15155. if !ok {
  15156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15157. }
  15158. m.AddAchievementCount(v)
  15159. return nil
  15160. case employee.FieldOrganizationID:
  15161. v, ok := value.(int64)
  15162. if !ok {
  15163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15164. }
  15165. m.AddOrganizationID(v)
  15166. return nil
  15167. case employee.FieldCategoryID:
  15168. v, ok := value.(int64)
  15169. if !ok {
  15170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15171. }
  15172. m.AddCategoryID(v)
  15173. return nil
  15174. case employee.FieldIsVip:
  15175. v, ok := value.(int)
  15176. if !ok {
  15177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15178. }
  15179. m.AddIsVip(v)
  15180. return nil
  15181. }
  15182. return fmt.Errorf("unknown Employee numeric field %s", name)
  15183. }
  15184. // ClearedFields returns all nullable fields that were cleared during this
  15185. // mutation.
  15186. func (m *EmployeeMutation) ClearedFields() []string {
  15187. var fields []string
  15188. if m.FieldCleared(employee.FieldDeletedAt) {
  15189. fields = append(fields, employee.FieldDeletedAt)
  15190. }
  15191. if m.FieldCleared(employee.FieldAiInfo) {
  15192. fields = append(fields, employee.FieldAiInfo)
  15193. }
  15194. return fields
  15195. }
  15196. // FieldCleared returns a boolean indicating if a field with the given name was
  15197. // cleared in this mutation.
  15198. func (m *EmployeeMutation) FieldCleared(name string) bool {
  15199. _, ok := m.clearedFields[name]
  15200. return ok
  15201. }
  15202. // ClearField clears the value of the field with the given name. It returns an
  15203. // error if the field is not defined in the schema.
  15204. func (m *EmployeeMutation) ClearField(name string) error {
  15205. switch name {
  15206. case employee.FieldDeletedAt:
  15207. m.ClearDeletedAt()
  15208. return nil
  15209. case employee.FieldAiInfo:
  15210. m.ClearAiInfo()
  15211. return nil
  15212. }
  15213. return fmt.Errorf("unknown Employee nullable field %s", name)
  15214. }
  15215. // ResetField resets all changes in the mutation for the field with the given name.
  15216. // It returns an error if the field is not defined in the schema.
  15217. func (m *EmployeeMutation) ResetField(name string) error {
  15218. switch name {
  15219. case employee.FieldCreatedAt:
  15220. m.ResetCreatedAt()
  15221. return nil
  15222. case employee.FieldUpdatedAt:
  15223. m.ResetUpdatedAt()
  15224. return nil
  15225. case employee.FieldDeletedAt:
  15226. m.ResetDeletedAt()
  15227. return nil
  15228. case employee.FieldTitle:
  15229. m.ResetTitle()
  15230. return nil
  15231. case employee.FieldAvatar:
  15232. m.ResetAvatar()
  15233. return nil
  15234. case employee.FieldTags:
  15235. m.ResetTags()
  15236. return nil
  15237. case employee.FieldHireCount:
  15238. m.ResetHireCount()
  15239. return nil
  15240. case employee.FieldServiceCount:
  15241. m.ResetServiceCount()
  15242. return nil
  15243. case employee.FieldAchievementCount:
  15244. m.ResetAchievementCount()
  15245. return nil
  15246. case employee.FieldIntro:
  15247. m.ResetIntro()
  15248. return nil
  15249. case employee.FieldEstimate:
  15250. m.ResetEstimate()
  15251. return nil
  15252. case employee.FieldSkill:
  15253. m.ResetSkill()
  15254. return nil
  15255. case employee.FieldAbilityType:
  15256. m.ResetAbilityType()
  15257. return nil
  15258. case employee.FieldScene:
  15259. m.ResetScene()
  15260. return nil
  15261. case employee.FieldSwitchIn:
  15262. m.ResetSwitchIn()
  15263. return nil
  15264. case employee.FieldVideoURL:
  15265. m.ResetVideoURL()
  15266. return nil
  15267. case employee.FieldOrganizationID:
  15268. m.ResetOrganizationID()
  15269. return nil
  15270. case employee.FieldCategoryID:
  15271. m.ResetCategoryID()
  15272. return nil
  15273. case employee.FieldAPIBase:
  15274. m.ResetAPIBase()
  15275. return nil
  15276. case employee.FieldAPIKey:
  15277. m.ResetAPIKey()
  15278. return nil
  15279. case employee.FieldAiInfo:
  15280. m.ResetAiInfo()
  15281. return nil
  15282. case employee.FieldIsVip:
  15283. m.ResetIsVip()
  15284. return nil
  15285. case employee.FieldChatURL:
  15286. m.ResetChatURL()
  15287. return nil
  15288. }
  15289. return fmt.Errorf("unknown Employee field %s", name)
  15290. }
  15291. // AddedEdges returns all edge names that were set/added in this mutation.
  15292. func (m *EmployeeMutation) AddedEdges() []string {
  15293. edges := make([]string, 0, 2)
  15294. if m.em_work_experiences != nil {
  15295. edges = append(edges, employee.EdgeEmWorkExperiences)
  15296. }
  15297. if m.em_tutorial != nil {
  15298. edges = append(edges, employee.EdgeEmTutorial)
  15299. }
  15300. return edges
  15301. }
  15302. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15303. // name in this mutation.
  15304. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  15305. switch name {
  15306. case employee.EdgeEmWorkExperiences:
  15307. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  15308. for id := range m.em_work_experiences {
  15309. ids = append(ids, id)
  15310. }
  15311. return ids
  15312. case employee.EdgeEmTutorial:
  15313. ids := make([]ent.Value, 0, len(m.em_tutorial))
  15314. for id := range m.em_tutorial {
  15315. ids = append(ids, id)
  15316. }
  15317. return ids
  15318. }
  15319. return nil
  15320. }
  15321. // RemovedEdges returns all edge names that were removed in this mutation.
  15322. func (m *EmployeeMutation) RemovedEdges() []string {
  15323. edges := make([]string, 0, 2)
  15324. if m.removedem_work_experiences != nil {
  15325. edges = append(edges, employee.EdgeEmWorkExperiences)
  15326. }
  15327. if m.removedem_tutorial != nil {
  15328. edges = append(edges, employee.EdgeEmTutorial)
  15329. }
  15330. return edges
  15331. }
  15332. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15333. // the given name in this mutation.
  15334. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  15335. switch name {
  15336. case employee.EdgeEmWorkExperiences:
  15337. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  15338. for id := range m.removedem_work_experiences {
  15339. ids = append(ids, id)
  15340. }
  15341. return ids
  15342. case employee.EdgeEmTutorial:
  15343. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  15344. for id := range m.removedem_tutorial {
  15345. ids = append(ids, id)
  15346. }
  15347. return ids
  15348. }
  15349. return nil
  15350. }
  15351. // ClearedEdges returns all edge names that were cleared in this mutation.
  15352. func (m *EmployeeMutation) ClearedEdges() []string {
  15353. edges := make([]string, 0, 2)
  15354. if m.clearedem_work_experiences {
  15355. edges = append(edges, employee.EdgeEmWorkExperiences)
  15356. }
  15357. if m.clearedem_tutorial {
  15358. edges = append(edges, employee.EdgeEmTutorial)
  15359. }
  15360. return edges
  15361. }
  15362. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15363. // was cleared in this mutation.
  15364. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  15365. switch name {
  15366. case employee.EdgeEmWorkExperiences:
  15367. return m.clearedem_work_experiences
  15368. case employee.EdgeEmTutorial:
  15369. return m.clearedem_tutorial
  15370. }
  15371. return false
  15372. }
  15373. // ClearEdge clears the value of the edge with the given name. It returns an error
  15374. // if that edge is not defined in the schema.
  15375. func (m *EmployeeMutation) ClearEdge(name string) error {
  15376. switch name {
  15377. }
  15378. return fmt.Errorf("unknown Employee unique edge %s", name)
  15379. }
  15380. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15381. // It returns an error if the edge is not defined in the schema.
  15382. func (m *EmployeeMutation) ResetEdge(name string) error {
  15383. switch name {
  15384. case employee.EdgeEmWorkExperiences:
  15385. m.ResetEmWorkExperiences()
  15386. return nil
  15387. case employee.EdgeEmTutorial:
  15388. m.ResetEmTutorial()
  15389. return nil
  15390. }
  15391. return fmt.Errorf("unknown Employee edge %s", name)
  15392. }
  15393. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  15394. type EmployeeConfigMutation struct {
  15395. config
  15396. op Op
  15397. typ string
  15398. id *uint64
  15399. created_at *time.Time
  15400. updated_at *time.Time
  15401. deleted_at *time.Time
  15402. stype *string
  15403. title *string
  15404. photo *string
  15405. organization_id *uint64
  15406. addorganization_id *int64
  15407. clearedFields map[string]struct{}
  15408. done bool
  15409. oldValue func(context.Context) (*EmployeeConfig, error)
  15410. predicates []predicate.EmployeeConfig
  15411. }
  15412. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  15413. // employeeconfigOption allows management of the mutation configuration using functional options.
  15414. type employeeconfigOption func(*EmployeeConfigMutation)
  15415. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  15416. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  15417. m := &EmployeeConfigMutation{
  15418. config: c,
  15419. op: op,
  15420. typ: TypeEmployeeConfig,
  15421. clearedFields: make(map[string]struct{}),
  15422. }
  15423. for _, opt := range opts {
  15424. opt(m)
  15425. }
  15426. return m
  15427. }
  15428. // withEmployeeConfigID sets the ID field of the mutation.
  15429. func withEmployeeConfigID(id uint64) employeeconfigOption {
  15430. return func(m *EmployeeConfigMutation) {
  15431. var (
  15432. err error
  15433. once sync.Once
  15434. value *EmployeeConfig
  15435. )
  15436. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  15437. once.Do(func() {
  15438. if m.done {
  15439. err = errors.New("querying old values post mutation is not allowed")
  15440. } else {
  15441. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  15442. }
  15443. })
  15444. return value, err
  15445. }
  15446. m.id = &id
  15447. }
  15448. }
  15449. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  15450. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  15451. return func(m *EmployeeConfigMutation) {
  15452. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  15453. return node, nil
  15454. }
  15455. m.id = &node.ID
  15456. }
  15457. }
  15458. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15459. // executed in a transaction (ent.Tx), a transactional client is returned.
  15460. func (m EmployeeConfigMutation) Client() *Client {
  15461. client := &Client{config: m.config}
  15462. client.init()
  15463. return client
  15464. }
  15465. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15466. // it returns an error otherwise.
  15467. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  15468. if _, ok := m.driver.(*txDriver); !ok {
  15469. return nil, errors.New("ent: mutation is not running in a transaction")
  15470. }
  15471. tx := &Tx{config: m.config}
  15472. tx.init()
  15473. return tx, nil
  15474. }
  15475. // SetID sets the value of the id field. Note that this
  15476. // operation is only accepted on creation of EmployeeConfig entities.
  15477. func (m *EmployeeConfigMutation) SetID(id uint64) {
  15478. m.id = &id
  15479. }
  15480. // ID returns the ID value in the mutation. Note that the ID is only available
  15481. // if it was provided to the builder or after it was returned from the database.
  15482. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  15483. if m.id == nil {
  15484. return
  15485. }
  15486. return *m.id, true
  15487. }
  15488. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15489. // That means, if the mutation is applied within a transaction with an isolation level such
  15490. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15491. // or updated by the mutation.
  15492. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  15493. switch {
  15494. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15495. id, exists := m.ID()
  15496. if exists {
  15497. return []uint64{id}, nil
  15498. }
  15499. fallthrough
  15500. case m.op.Is(OpUpdate | OpDelete):
  15501. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  15502. default:
  15503. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15504. }
  15505. }
  15506. // SetCreatedAt sets the "created_at" field.
  15507. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  15508. m.created_at = &t
  15509. }
  15510. // CreatedAt returns the value of the "created_at" field in the mutation.
  15511. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  15512. v := m.created_at
  15513. if v == nil {
  15514. return
  15515. }
  15516. return *v, true
  15517. }
  15518. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  15519. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15521. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15522. if !m.op.Is(OpUpdateOne) {
  15523. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15524. }
  15525. if m.id == nil || m.oldValue == nil {
  15526. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15527. }
  15528. oldValue, err := m.oldValue(ctx)
  15529. if err != nil {
  15530. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15531. }
  15532. return oldValue.CreatedAt, nil
  15533. }
  15534. // ResetCreatedAt resets all changes to the "created_at" field.
  15535. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  15536. m.created_at = nil
  15537. }
  15538. // SetUpdatedAt sets the "updated_at" field.
  15539. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  15540. m.updated_at = &t
  15541. }
  15542. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15543. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  15544. v := m.updated_at
  15545. if v == nil {
  15546. return
  15547. }
  15548. return *v, true
  15549. }
  15550. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  15551. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15553. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15554. if !m.op.Is(OpUpdateOne) {
  15555. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15556. }
  15557. if m.id == nil || m.oldValue == nil {
  15558. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15559. }
  15560. oldValue, err := m.oldValue(ctx)
  15561. if err != nil {
  15562. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15563. }
  15564. return oldValue.UpdatedAt, nil
  15565. }
  15566. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15567. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  15568. m.updated_at = nil
  15569. }
  15570. // SetDeletedAt sets the "deleted_at" field.
  15571. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  15572. m.deleted_at = &t
  15573. }
  15574. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15575. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  15576. v := m.deleted_at
  15577. if v == nil {
  15578. return
  15579. }
  15580. return *v, true
  15581. }
  15582. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  15583. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15585. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15586. if !m.op.Is(OpUpdateOne) {
  15587. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15588. }
  15589. if m.id == nil || m.oldValue == nil {
  15590. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15591. }
  15592. oldValue, err := m.oldValue(ctx)
  15593. if err != nil {
  15594. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15595. }
  15596. return oldValue.DeletedAt, nil
  15597. }
  15598. // ClearDeletedAt clears the value of the "deleted_at" field.
  15599. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  15600. m.deleted_at = nil
  15601. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  15602. }
  15603. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15604. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  15605. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  15606. return ok
  15607. }
  15608. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15609. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  15610. m.deleted_at = nil
  15611. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  15612. }
  15613. // SetStype sets the "stype" field.
  15614. func (m *EmployeeConfigMutation) SetStype(s string) {
  15615. m.stype = &s
  15616. }
  15617. // Stype returns the value of the "stype" field in the mutation.
  15618. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  15619. v := m.stype
  15620. if v == nil {
  15621. return
  15622. }
  15623. return *v, true
  15624. }
  15625. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  15626. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15628. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  15629. if !m.op.Is(OpUpdateOne) {
  15630. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  15631. }
  15632. if m.id == nil || m.oldValue == nil {
  15633. return v, errors.New("OldStype requires an ID field in the mutation")
  15634. }
  15635. oldValue, err := m.oldValue(ctx)
  15636. if err != nil {
  15637. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  15638. }
  15639. return oldValue.Stype, nil
  15640. }
  15641. // ResetStype resets all changes to the "stype" field.
  15642. func (m *EmployeeConfigMutation) ResetStype() {
  15643. m.stype = nil
  15644. }
  15645. // SetTitle sets the "title" field.
  15646. func (m *EmployeeConfigMutation) SetTitle(s string) {
  15647. m.title = &s
  15648. }
  15649. // Title returns the value of the "title" field in the mutation.
  15650. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  15651. v := m.title
  15652. if v == nil {
  15653. return
  15654. }
  15655. return *v, true
  15656. }
  15657. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  15658. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15660. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  15661. if !m.op.Is(OpUpdateOne) {
  15662. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15663. }
  15664. if m.id == nil || m.oldValue == nil {
  15665. return v, errors.New("OldTitle requires an ID field in the mutation")
  15666. }
  15667. oldValue, err := m.oldValue(ctx)
  15668. if err != nil {
  15669. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15670. }
  15671. return oldValue.Title, nil
  15672. }
  15673. // ResetTitle resets all changes to the "title" field.
  15674. func (m *EmployeeConfigMutation) ResetTitle() {
  15675. m.title = nil
  15676. }
  15677. // SetPhoto sets the "photo" field.
  15678. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  15679. m.photo = &s
  15680. }
  15681. // Photo returns the value of the "photo" field in the mutation.
  15682. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  15683. v := m.photo
  15684. if v == nil {
  15685. return
  15686. }
  15687. return *v, true
  15688. }
  15689. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  15690. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15692. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  15693. if !m.op.Is(OpUpdateOne) {
  15694. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  15695. }
  15696. if m.id == nil || m.oldValue == nil {
  15697. return v, errors.New("OldPhoto requires an ID field in the mutation")
  15698. }
  15699. oldValue, err := m.oldValue(ctx)
  15700. if err != nil {
  15701. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  15702. }
  15703. return oldValue.Photo, nil
  15704. }
  15705. // ResetPhoto resets all changes to the "photo" field.
  15706. func (m *EmployeeConfigMutation) ResetPhoto() {
  15707. m.photo = nil
  15708. }
  15709. // SetOrganizationID sets the "organization_id" field.
  15710. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  15711. m.organization_id = &u
  15712. m.addorganization_id = nil
  15713. }
  15714. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15715. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  15716. v := m.organization_id
  15717. if v == nil {
  15718. return
  15719. }
  15720. return *v, true
  15721. }
  15722. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  15723. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15725. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15726. if !m.op.Is(OpUpdateOne) {
  15727. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15728. }
  15729. if m.id == nil || m.oldValue == nil {
  15730. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15731. }
  15732. oldValue, err := m.oldValue(ctx)
  15733. if err != nil {
  15734. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15735. }
  15736. return oldValue.OrganizationID, nil
  15737. }
  15738. // AddOrganizationID adds u to the "organization_id" field.
  15739. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  15740. if m.addorganization_id != nil {
  15741. *m.addorganization_id += u
  15742. } else {
  15743. m.addorganization_id = &u
  15744. }
  15745. }
  15746. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15747. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  15748. v := m.addorganization_id
  15749. if v == nil {
  15750. return
  15751. }
  15752. return *v, true
  15753. }
  15754. // ClearOrganizationID clears the value of the "organization_id" field.
  15755. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  15756. m.organization_id = nil
  15757. m.addorganization_id = nil
  15758. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  15759. }
  15760. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15761. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  15762. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  15763. return ok
  15764. }
  15765. // ResetOrganizationID resets all changes to the "organization_id" field.
  15766. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  15767. m.organization_id = nil
  15768. m.addorganization_id = nil
  15769. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  15770. }
  15771. // Where appends a list predicates to the EmployeeConfigMutation builder.
  15772. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  15773. m.predicates = append(m.predicates, ps...)
  15774. }
  15775. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  15776. // users can use type-assertion to append predicates that do not depend on any generated package.
  15777. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  15778. p := make([]predicate.EmployeeConfig, len(ps))
  15779. for i := range ps {
  15780. p[i] = ps[i]
  15781. }
  15782. m.Where(p...)
  15783. }
  15784. // Op returns the operation name.
  15785. func (m *EmployeeConfigMutation) Op() Op {
  15786. return m.op
  15787. }
  15788. // SetOp allows setting the mutation operation.
  15789. func (m *EmployeeConfigMutation) SetOp(op Op) {
  15790. m.op = op
  15791. }
  15792. // Type returns the node type of this mutation (EmployeeConfig).
  15793. func (m *EmployeeConfigMutation) Type() string {
  15794. return m.typ
  15795. }
  15796. // Fields returns all fields that were changed during this mutation. Note that in
  15797. // order to get all numeric fields that were incremented/decremented, call
  15798. // AddedFields().
  15799. func (m *EmployeeConfigMutation) Fields() []string {
  15800. fields := make([]string, 0, 7)
  15801. if m.created_at != nil {
  15802. fields = append(fields, employeeconfig.FieldCreatedAt)
  15803. }
  15804. if m.updated_at != nil {
  15805. fields = append(fields, employeeconfig.FieldUpdatedAt)
  15806. }
  15807. if m.deleted_at != nil {
  15808. fields = append(fields, employeeconfig.FieldDeletedAt)
  15809. }
  15810. if m.stype != nil {
  15811. fields = append(fields, employeeconfig.FieldStype)
  15812. }
  15813. if m.title != nil {
  15814. fields = append(fields, employeeconfig.FieldTitle)
  15815. }
  15816. if m.photo != nil {
  15817. fields = append(fields, employeeconfig.FieldPhoto)
  15818. }
  15819. if m.organization_id != nil {
  15820. fields = append(fields, employeeconfig.FieldOrganizationID)
  15821. }
  15822. return fields
  15823. }
  15824. // Field returns the value of a field with the given name. The second boolean
  15825. // return value indicates that this field was not set, or was not defined in the
  15826. // schema.
  15827. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  15828. switch name {
  15829. case employeeconfig.FieldCreatedAt:
  15830. return m.CreatedAt()
  15831. case employeeconfig.FieldUpdatedAt:
  15832. return m.UpdatedAt()
  15833. case employeeconfig.FieldDeletedAt:
  15834. return m.DeletedAt()
  15835. case employeeconfig.FieldStype:
  15836. return m.Stype()
  15837. case employeeconfig.FieldTitle:
  15838. return m.Title()
  15839. case employeeconfig.FieldPhoto:
  15840. return m.Photo()
  15841. case employeeconfig.FieldOrganizationID:
  15842. return m.OrganizationID()
  15843. }
  15844. return nil, false
  15845. }
  15846. // OldField returns the old value of the field from the database. An error is
  15847. // returned if the mutation operation is not UpdateOne, or the query to the
  15848. // database failed.
  15849. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15850. switch name {
  15851. case employeeconfig.FieldCreatedAt:
  15852. return m.OldCreatedAt(ctx)
  15853. case employeeconfig.FieldUpdatedAt:
  15854. return m.OldUpdatedAt(ctx)
  15855. case employeeconfig.FieldDeletedAt:
  15856. return m.OldDeletedAt(ctx)
  15857. case employeeconfig.FieldStype:
  15858. return m.OldStype(ctx)
  15859. case employeeconfig.FieldTitle:
  15860. return m.OldTitle(ctx)
  15861. case employeeconfig.FieldPhoto:
  15862. return m.OldPhoto(ctx)
  15863. case employeeconfig.FieldOrganizationID:
  15864. return m.OldOrganizationID(ctx)
  15865. }
  15866. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  15867. }
  15868. // SetField sets the value of a field with the given name. It returns an error if
  15869. // the field is not defined in the schema, or if the type mismatched the field
  15870. // type.
  15871. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  15872. switch name {
  15873. case employeeconfig.FieldCreatedAt:
  15874. v, ok := value.(time.Time)
  15875. if !ok {
  15876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15877. }
  15878. m.SetCreatedAt(v)
  15879. return nil
  15880. case employeeconfig.FieldUpdatedAt:
  15881. v, ok := value.(time.Time)
  15882. if !ok {
  15883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15884. }
  15885. m.SetUpdatedAt(v)
  15886. return nil
  15887. case employeeconfig.FieldDeletedAt:
  15888. v, ok := value.(time.Time)
  15889. if !ok {
  15890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15891. }
  15892. m.SetDeletedAt(v)
  15893. return nil
  15894. case employeeconfig.FieldStype:
  15895. v, ok := value.(string)
  15896. if !ok {
  15897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15898. }
  15899. m.SetStype(v)
  15900. return nil
  15901. case employeeconfig.FieldTitle:
  15902. v, ok := value.(string)
  15903. if !ok {
  15904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15905. }
  15906. m.SetTitle(v)
  15907. return nil
  15908. case employeeconfig.FieldPhoto:
  15909. v, ok := value.(string)
  15910. if !ok {
  15911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15912. }
  15913. m.SetPhoto(v)
  15914. return nil
  15915. case employeeconfig.FieldOrganizationID:
  15916. v, ok := value.(uint64)
  15917. if !ok {
  15918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15919. }
  15920. m.SetOrganizationID(v)
  15921. return nil
  15922. }
  15923. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15924. }
  15925. // AddedFields returns all numeric fields that were incremented/decremented during
  15926. // this mutation.
  15927. func (m *EmployeeConfigMutation) AddedFields() []string {
  15928. var fields []string
  15929. if m.addorganization_id != nil {
  15930. fields = append(fields, employeeconfig.FieldOrganizationID)
  15931. }
  15932. return fields
  15933. }
  15934. // AddedField returns the numeric value that was incremented/decremented on a field
  15935. // with the given name. The second boolean return value indicates that this field
  15936. // was not set, or was not defined in the schema.
  15937. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  15938. switch name {
  15939. case employeeconfig.FieldOrganizationID:
  15940. return m.AddedOrganizationID()
  15941. }
  15942. return nil, false
  15943. }
  15944. // AddField adds the value to the field with the given name. It returns an error if
  15945. // the field is not defined in the schema, or if the type mismatched the field
  15946. // type.
  15947. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  15948. switch name {
  15949. case employeeconfig.FieldOrganizationID:
  15950. v, ok := value.(int64)
  15951. if !ok {
  15952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15953. }
  15954. m.AddOrganizationID(v)
  15955. return nil
  15956. }
  15957. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  15958. }
  15959. // ClearedFields returns all nullable fields that were cleared during this
  15960. // mutation.
  15961. func (m *EmployeeConfigMutation) ClearedFields() []string {
  15962. var fields []string
  15963. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  15964. fields = append(fields, employeeconfig.FieldDeletedAt)
  15965. }
  15966. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  15967. fields = append(fields, employeeconfig.FieldOrganizationID)
  15968. }
  15969. return fields
  15970. }
  15971. // FieldCleared returns a boolean indicating if a field with the given name was
  15972. // cleared in this mutation.
  15973. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  15974. _, ok := m.clearedFields[name]
  15975. return ok
  15976. }
  15977. // ClearField clears the value of the field with the given name. It returns an
  15978. // error if the field is not defined in the schema.
  15979. func (m *EmployeeConfigMutation) ClearField(name string) error {
  15980. switch name {
  15981. case employeeconfig.FieldDeletedAt:
  15982. m.ClearDeletedAt()
  15983. return nil
  15984. case employeeconfig.FieldOrganizationID:
  15985. m.ClearOrganizationID()
  15986. return nil
  15987. }
  15988. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  15989. }
  15990. // ResetField resets all changes in the mutation for the field with the given name.
  15991. // It returns an error if the field is not defined in the schema.
  15992. func (m *EmployeeConfigMutation) ResetField(name string) error {
  15993. switch name {
  15994. case employeeconfig.FieldCreatedAt:
  15995. m.ResetCreatedAt()
  15996. return nil
  15997. case employeeconfig.FieldUpdatedAt:
  15998. m.ResetUpdatedAt()
  15999. return nil
  16000. case employeeconfig.FieldDeletedAt:
  16001. m.ResetDeletedAt()
  16002. return nil
  16003. case employeeconfig.FieldStype:
  16004. m.ResetStype()
  16005. return nil
  16006. case employeeconfig.FieldTitle:
  16007. m.ResetTitle()
  16008. return nil
  16009. case employeeconfig.FieldPhoto:
  16010. m.ResetPhoto()
  16011. return nil
  16012. case employeeconfig.FieldOrganizationID:
  16013. m.ResetOrganizationID()
  16014. return nil
  16015. }
  16016. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  16017. }
  16018. // AddedEdges returns all edge names that were set/added in this mutation.
  16019. func (m *EmployeeConfigMutation) AddedEdges() []string {
  16020. edges := make([]string, 0, 0)
  16021. return edges
  16022. }
  16023. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16024. // name in this mutation.
  16025. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  16026. return nil
  16027. }
  16028. // RemovedEdges returns all edge names that were removed in this mutation.
  16029. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  16030. edges := make([]string, 0, 0)
  16031. return edges
  16032. }
  16033. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16034. // the given name in this mutation.
  16035. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  16036. return nil
  16037. }
  16038. // ClearedEdges returns all edge names that were cleared in this mutation.
  16039. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  16040. edges := make([]string, 0, 0)
  16041. return edges
  16042. }
  16043. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16044. // was cleared in this mutation.
  16045. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  16046. return false
  16047. }
  16048. // ClearEdge clears the value of the edge with the given name. It returns an error
  16049. // if that edge is not defined in the schema.
  16050. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  16051. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  16052. }
  16053. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16054. // It returns an error if the edge is not defined in the schema.
  16055. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  16056. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  16057. }
  16058. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  16059. type LabelMutation struct {
  16060. config
  16061. op Op
  16062. typ string
  16063. id *uint64
  16064. created_at *time.Time
  16065. updated_at *time.Time
  16066. status *uint8
  16067. addstatus *int8
  16068. _type *int
  16069. add_type *int
  16070. name *string
  16071. from *int
  16072. addfrom *int
  16073. mode *int
  16074. addmode *int
  16075. conditions *string
  16076. organization_id *uint64
  16077. addorganization_id *int64
  16078. clearedFields map[string]struct{}
  16079. label_relationships map[uint64]struct{}
  16080. removedlabel_relationships map[uint64]struct{}
  16081. clearedlabel_relationships bool
  16082. done bool
  16083. oldValue func(context.Context) (*Label, error)
  16084. predicates []predicate.Label
  16085. }
  16086. var _ ent.Mutation = (*LabelMutation)(nil)
  16087. // labelOption allows management of the mutation configuration using functional options.
  16088. type labelOption func(*LabelMutation)
  16089. // newLabelMutation creates new mutation for the Label entity.
  16090. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  16091. m := &LabelMutation{
  16092. config: c,
  16093. op: op,
  16094. typ: TypeLabel,
  16095. clearedFields: make(map[string]struct{}),
  16096. }
  16097. for _, opt := range opts {
  16098. opt(m)
  16099. }
  16100. return m
  16101. }
  16102. // withLabelID sets the ID field of the mutation.
  16103. func withLabelID(id uint64) labelOption {
  16104. return func(m *LabelMutation) {
  16105. var (
  16106. err error
  16107. once sync.Once
  16108. value *Label
  16109. )
  16110. m.oldValue = func(ctx context.Context) (*Label, error) {
  16111. once.Do(func() {
  16112. if m.done {
  16113. err = errors.New("querying old values post mutation is not allowed")
  16114. } else {
  16115. value, err = m.Client().Label.Get(ctx, id)
  16116. }
  16117. })
  16118. return value, err
  16119. }
  16120. m.id = &id
  16121. }
  16122. }
  16123. // withLabel sets the old Label of the mutation.
  16124. func withLabel(node *Label) labelOption {
  16125. return func(m *LabelMutation) {
  16126. m.oldValue = func(context.Context) (*Label, error) {
  16127. return node, nil
  16128. }
  16129. m.id = &node.ID
  16130. }
  16131. }
  16132. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16133. // executed in a transaction (ent.Tx), a transactional client is returned.
  16134. func (m LabelMutation) Client() *Client {
  16135. client := &Client{config: m.config}
  16136. client.init()
  16137. return client
  16138. }
  16139. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16140. // it returns an error otherwise.
  16141. func (m LabelMutation) Tx() (*Tx, error) {
  16142. if _, ok := m.driver.(*txDriver); !ok {
  16143. return nil, errors.New("ent: mutation is not running in a transaction")
  16144. }
  16145. tx := &Tx{config: m.config}
  16146. tx.init()
  16147. return tx, nil
  16148. }
  16149. // SetID sets the value of the id field. Note that this
  16150. // operation is only accepted on creation of Label entities.
  16151. func (m *LabelMutation) SetID(id uint64) {
  16152. m.id = &id
  16153. }
  16154. // ID returns the ID value in the mutation. Note that the ID is only available
  16155. // if it was provided to the builder or after it was returned from the database.
  16156. func (m *LabelMutation) ID() (id uint64, exists bool) {
  16157. if m.id == nil {
  16158. return
  16159. }
  16160. return *m.id, true
  16161. }
  16162. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16163. // That means, if the mutation is applied within a transaction with an isolation level such
  16164. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16165. // or updated by the mutation.
  16166. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  16167. switch {
  16168. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16169. id, exists := m.ID()
  16170. if exists {
  16171. return []uint64{id}, nil
  16172. }
  16173. fallthrough
  16174. case m.op.Is(OpUpdate | OpDelete):
  16175. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  16176. default:
  16177. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16178. }
  16179. }
  16180. // SetCreatedAt sets the "created_at" field.
  16181. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  16182. m.created_at = &t
  16183. }
  16184. // CreatedAt returns the value of the "created_at" field in the mutation.
  16185. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  16186. v := m.created_at
  16187. if v == nil {
  16188. return
  16189. }
  16190. return *v, true
  16191. }
  16192. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  16193. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16195. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16196. if !m.op.Is(OpUpdateOne) {
  16197. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16198. }
  16199. if m.id == nil || m.oldValue == nil {
  16200. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16201. }
  16202. oldValue, err := m.oldValue(ctx)
  16203. if err != nil {
  16204. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16205. }
  16206. return oldValue.CreatedAt, nil
  16207. }
  16208. // ResetCreatedAt resets all changes to the "created_at" field.
  16209. func (m *LabelMutation) ResetCreatedAt() {
  16210. m.created_at = nil
  16211. }
  16212. // SetUpdatedAt sets the "updated_at" field.
  16213. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  16214. m.updated_at = &t
  16215. }
  16216. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16217. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  16218. v := m.updated_at
  16219. if v == nil {
  16220. return
  16221. }
  16222. return *v, true
  16223. }
  16224. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  16225. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16227. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16228. if !m.op.Is(OpUpdateOne) {
  16229. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16230. }
  16231. if m.id == nil || m.oldValue == nil {
  16232. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16233. }
  16234. oldValue, err := m.oldValue(ctx)
  16235. if err != nil {
  16236. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16237. }
  16238. return oldValue.UpdatedAt, nil
  16239. }
  16240. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16241. func (m *LabelMutation) ResetUpdatedAt() {
  16242. m.updated_at = nil
  16243. }
  16244. // SetStatus sets the "status" field.
  16245. func (m *LabelMutation) SetStatus(u uint8) {
  16246. m.status = &u
  16247. m.addstatus = nil
  16248. }
  16249. // Status returns the value of the "status" field in the mutation.
  16250. func (m *LabelMutation) Status() (r uint8, exists bool) {
  16251. v := m.status
  16252. if v == nil {
  16253. return
  16254. }
  16255. return *v, true
  16256. }
  16257. // OldStatus returns the old "status" field's value of the Label entity.
  16258. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16260. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16261. if !m.op.Is(OpUpdateOne) {
  16262. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16263. }
  16264. if m.id == nil || m.oldValue == nil {
  16265. return v, errors.New("OldStatus requires an ID field in the mutation")
  16266. }
  16267. oldValue, err := m.oldValue(ctx)
  16268. if err != nil {
  16269. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16270. }
  16271. return oldValue.Status, nil
  16272. }
  16273. // AddStatus adds u to the "status" field.
  16274. func (m *LabelMutation) AddStatus(u int8) {
  16275. if m.addstatus != nil {
  16276. *m.addstatus += u
  16277. } else {
  16278. m.addstatus = &u
  16279. }
  16280. }
  16281. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16282. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  16283. v := m.addstatus
  16284. if v == nil {
  16285. return
  16286. }
  16287. return *v, true
  16288. }
  16289. // ClearStatus clears the value of the "status" field.
  16290. func (m *LabelMutation) ClearStatus() {
  16291. m.status = nil
  16292. m.addstatus = nil
  16293. m.clearedFields[label.FieldStatus] = struct{}{}
  16294. }
  16295. // StatusCleared returns if the "status" field was cleared in this mutation.
  16296. func (m *LabelMutation) StatusCleared() bool {
  16297. _, ok := m.clearedFields[label.FieldStatus]
  16298. return ok
  16299. }
  16300. // ResetStatus resets all changes to the "status" field.
  16301. func (m *LabelMutation) ResetStatus() {
  16302. m.status = nil
  16303. m.addstatus = nil
  16304. delete(m.clearedFields, label.FieldStatus)
  16305. }
  16306. // SetType sets the "type" field.
  16307. func (m *LabelMutation) SetType(i int) {
  16308. m._type = &i
  16309. m.add_type = nil
  16310. }
  16311. // GetType returns the value of the "type" field in the mutation.
  16312. func (m *LabelMutation) GetType() (r int, exists bool) {
  16313. v := m._type
  16314. if v == nil {
  16315. return
  16316. }
  16317. return *v, true
  16318. }
  16319. // OldType returns the old "type" field's value of the Label entity.
  16320. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16322. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  16323. if !m.op.Is(OpUpdateOne) {
  16324. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16325. }
  16326. if m.id == nil || m.oldValue == nil {
  16327. return v, errors.New("OldType requires an ID field in the mutation")
  16328. }
  16329. oldValue, err := m.oldValue(ctx)
  16330. if err != nil {
  16331. return v, fmt.Errorf("querying old value for OldType: %w", err)
  16332. }
  16333. return oldValue.Type, nil
  16334. }
  16335. // AddType adds i to the "type" field.
  16336. func (m *LabelMutation) AddType(i int) {
  16337. if m.add_type != nil {
  16338. *m.add_type += i
  16339. } else {
  16340. m.add_type = &i
  16341. }
  16342. }
  16343. // AddedType returns the value that was added to the "type" field in this mutation.
  16344. func (m *LabelMutation) AddedType() (r int, exists bool) {
  16345. v := m.add_type
  16346. if v == nil {
  16347. return
  16348. }
  16349. return *v, true
  16350. }
  16351. // ResetType resets all changes to the "type" field.
  16352. func (m *LabelMutation) ResetType() {
  16353. m._type = nil
  16354. m.add_type = nil
  16355. }
  16356. // SetName sets the "name" field.
  16357. func (m *LabelMutation) SetName(s string) {
  16358. m.name = &s
  16359. }
  16360. // Name returns the value of the "name" field in the mutation.
  16361. func (m *LabelMutation) Name() (r string, exists bool) {
  16362. v := m.name
  16363. if v == nil {
  16364. return
  16365. }
  16366. return *v, true
  16367. }
  16368. // OldName returns the old "name" field's value of the Label entity.
  16369. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16371. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  16372. if !m.op.Is(OpUpdateOne) {
  16373. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16374. }
  16375. if m.id == nil || m.oldValue == nil {
  16376. return v, errors.New("OldName requires an ID field in the mutation")
  16377. }
  16378. oldValue, err := m.oldValue(ctx)
  16379. if err != nil {
  16380. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16381. }
  16382. return oldValue.Name, nil
  16383. }
  16384. // ResetName resets all changes to the "name" field.
  16385. func (m *LabelMutation) ResetName() {
  16386. m.name = nil
  16387. }
  16388. // SetFrom sets the "from" field.
  16389. func (m *LabelMutation) SetFrom(i int) {
  16390. m.from = &i
  16391. m.addfrom = nil
  16392. }
  16393. // From returns the value of the "from" field in the mutation.
  16394. func (m *LabelMutation) From() (r int, exists bool) {
  16395. v := m.from
  16396. if v == nil {
  16397. return
  16398. }
  16399. return *v, true
  16400. }
  16401. // OldFrom returns the old "from" field's value of the Label entity.
  16402. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16404. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  16405. if !m.op.Is(OpUpdateOne) {
  16406. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  16407. }
  16408. if m.id == nil || m.oldValue == nil {
  16409. return v, errors.New("OldFrom requires an ID field in the mutation")
  16410. }
  16411. oldValue, err := m.oldValue(ctx)
  16412. if err != nil {
  16413. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  16414. }
  16415. return oldValue.From, nil
  16416. }
  16417. // AddFrom adds i to the "from" field.
  16418. func (m *LabelMutation) AddFrom(i int) {
  16419. if m.addfrom != nil {
  16420. *m.addfrom += i
  16421. } else {
  16422. m.addfrom = &i
  16423. }
  16424. }
  16425. // AddedFrom returns the value that was added to the "from" field in this mutation.
  16426. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  16427. v := m.addfrom
  16428. if v == nil {
  16429. return
  16430. }
  16431. return *v, true
  16432. }
  16433. // ResetFrom resets all changes to the "from" field.
  16434. func (m *LabelMutation) ResetFrom() {
  16435. m.from = nil
  16436. m.addfrom = nil
  16437. }
  16438. // SetMode sets the "mode" field.
  16439. func (m *LabelMutation) SetMode(i int) {
  16440. m.mode = &i
  16441. m.addmode = nil
  16442. }
  16443. // Mode returns the value of the "mode" field in the mutation.
  16444. func (m *LabelMutation) Mode() (r int, exists bool) {
  16445. v := m.mode
  16446. if v == nil {
  16447. return
  16448. }
  16449. return *v, true
  16450. }
  16451. // OldMode returns the old "mode" field's value of the Label entity.
  16452. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16454. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  16455. if !m.op.Is(OpUpdateOne) {
  16456. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  16457. }
  16458. if m.id == nil || m.oldValue == nil {
  16459. return v, errors.New("OldMode requires an ID field in the mutation")
  16460. }
  16461. oldValue, err := m.oldValue(ctx)
  16462. if err != nil {
  16463. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  16464. }
  16465. return oldValue.Mode, nil
  16466. }
  16467. // AddMode adds i to the "mode" field.
  16468. func (m *LabelMutation) AddMode(i int) {
  16469. if m.addmode != nil {
  16470. *m.addmode += i
  16471. } else {
  16472. m.addmode = &i
  16473. }
  16474. }
  16475. // AddedMode returns the value that was added to the "mode" field in this mutation.
  16476. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  16477. v := m.addmode
  16478. if v == nil {
  16479. return
  16480. }
  16481. return *v, true
  16482. }
  16483. // ResetMode resets all changes to the "mode" field.
  16484. func (m *LabelMutation) ResetMode() {
  16485. m.mode = nil
  16486. m.addmode = nil
  16487. }
  16488. // SetConditions sets the "conditions" field.
  16489. func (m *LabelMutation) SetConditions(s string) {
  16490. m.conditions = &s
  16491. }
  16492. // Conditions returns the value of the "conditions" field in the mutation.
  16493. func (m *LabelMutation) Conditions() (r string, exists bool) {
  16494. v := m.conditions
  16495. if v == nil {
  16496. return
  16497. }
  16498. return *v, true
  16499. }
  16500. // OldConditions returns the old "conditions" field's value of the Label entity.
  16501. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16503. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  16504. if !m.op.Is(OpUpdateOne) {
  16505. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16506. }
  16507. if m.id == nil || m.oldValue == nil {
  16508. return v, errors.New("OldConditions requires an ID field in the mutation")
  16509. }
  16510. oldValue, err := m.oldValue(ctx)
  16511. if err != nil {
  16512. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16513. }
  16514. return oldValue.Conditions, nil
  16515. }
  16516. // ClearConditions clears the value of the "conditions" field.
  16517. func (m *LabelMutation) ClearConditions() {
  16518. m.conditions = nil
  16519. m.clearedFields[label.FieldConditions] = struct{}{}
  16520. }
  16521. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  16522. func (m *LabelMutation) ConditionsCleared() bool {
  16523. _, ok := m.clearedFields[label.FieldConditions]
  16524. return ok
  16525. }
  16526. // ResetConditions resets all changes to the "conditions" field.
  16527. func (m *LabelMutation) ResetConditions() {
  16528. m.conditions = nil
  16529. delete(m.clearedFields, label.FieldConditions)
  16530. }
  16531. // SetOrganizationID sets the "organization_id" field.
  16532. func (m *LabelMutation) SetOrganizationID(u uint64) {
  16533. m.organization_id = &u
  16534. m.addorganization_id = nil
  16535. }
  16536. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16537. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  16538. v := m.organization_id
  16539. if v == nil {
  16540. return
  16541. }
  16542. return *v, true
  16543. }
  16544. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  16545. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16547. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16548. if !m.op.Is(OpUpdateOne) {
  16549. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16550. }
  16551. if m.id == nil || m.oldValue == nil {
  16552. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16553. }
  16554. oldValue, err := m.oldValue(ctx)
  16555. if err != nil {
  16556. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16557. }
  16558. return oldValue.OrganizationID, nil
  16559. }
  16560. // AddOrganizationID adds u to the "organization_id" field.
  16561. func (m *LabelMutation) AddOrganizationID(u int64) {
  16562. if m.addorganization_id != nil {
  16563. *m.addorganization_id += u
  16564. } else {
  16565. m.addorganization_id = &u
  16566. }
  16567. }
  16568. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16569. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  16570. v := m.addorganization_id
  16571. if v == nil {
  16572. return
  16573. }
  16574. return *v, true
  16575. }
  16576. // ClearOrganizationID clears the value of the "organization_id" field.
  16577. func (m *LabelMutation) ClearOrganizationID() {
  16578. m.organization_id = nil
  16579. m.addorganization_id = nil
  16580. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  16581. }
  16582. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16583. func (m *LabelMutation) OrganizationIDCleared() bool {
  16584. _, ok := m.clearedFields[label.FieldOrganizationID]
  16585. return ok
  16586. }
  16587. // ResetOrganizationID resets all changes to the "organization_id" field.
  16588. func (m *LabelMutation) ResetOrganizationID() {
  16589. m.organization_id = nil
  16590. m.addorganization_id = nil
  16591. delete(m.clearedFields, label.FieldOrganizationID)
  16592. }
  16593. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  16594. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  16595. if m.label_relationships == nil {
  16596. m.label_relationships = make(map[uint64]struct{})
  16597. }
  16598. for i := range ids {
  16599. m.label_relationships[ids[i]] = struct{}{}
  16600. }
  16601. }
  16602. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  16603. func (m *LabelMutation) ClearLabelRelationships() {
  16604. m.clearedlabel_relationships = true
  16605. }
  16606. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  16607. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  16608. return m.clearedlabel_relationships
  16609. }
  16610. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  16611. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  16612. if m.removedlabel_relationships == nil {
  16613. m.removedlabel_relationships = make(map[uint64]struct{})
  16614. }
  16615. for i := range ids {
  16616. delete(m.label_relationships, ids[i])
  16617. m.removedlabel_relationships[ids[i]] = struct{}{}
  16618. }
  16619. }
  16620. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  16621. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  16622. for id := range m.removedlabel_relationships {
  16623. ids = append(ids, id)
  16624. }
  16625. return
  16626. }
  16627. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  16628. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  16629. for id := range m.label_relationships {
  16630. ids = append(ids, id)
  16631. }
  16632. return
  16633. }
  16634. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  16635. func (m *LabelMutation) ResetLabelRelationships() {
  16636. m.label_relationships = nil
  16637. m.clearedlabel_relationships = false
  16638. m.removedlabel_relationships = nil
  16639. }
  16640. // Where appends a list predicates to the LabelMutation builder.
  16641. func (m *LabelMutation) Where(ps ...predicate.Label) {
  16642. m.predicates = append(m.predicates, ps...)
  16643. }
  16644. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  16645. // users can use type-assertion to append predicates that do not depend on any generated package.
  16646. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  16647. p := make([]predicate.Label, len(ps))
  16648. for i := range ps {
  16649. p[i] = ps[i]
  16650. }
  16651. m.Where(p...)
  16652. }
  16653. // Op returns the operation name.
  16654. func (m *LabelMutation) Op() Op {
  16655. return m.op
  16656. }
  16657. // SetOp allows setting the mutation operation.
  16658. func (m *LabelMutation) SetOp(op Op) {
  16659. m.op = op
  16660. }
  16661. // Type returns the node type of this mutation (Label).
  16662. func (m *LabelMutation) Type() string {
  16663. return m.typ
  16664. }
  16665. // Fields returns all fields that were changed during this mutation. Note that in
  16666. // order to get all numeric fields that were incremented/decremented, call
  16667. // AddedFields().
  16668. func (m *LabelMutation) Fields() []string {
  16669. fields := make([]string, 0, 9)
  16670. if m.created_at != nil {
  16671. fields = append(fields, label.FieldCreatedAt)
  16672. }
  16673. if m.updated_at != nil {
  16674. fields = append(fields, label.FieldUpdatedAt)
  16675. }
  16676. if m.status != nil {
  16677. fields = append(fields, label.FieldStatus)
  16678. }
  16679. if m._type != nil {
  16680. fields = append(fields, label.FieldType)
  16681. }
  16682. if m.name != nil {
  16683. fields = append(fields, label.FieldName)
  16684. }
  16685. if m.from != nil {
  16686. fields = append(fields, label.FieldFrom)
  16687. }
  16688. if m.mode != nil {
  16689. fields = append(fields, label.FieldMode)
  16690. }
  16691. if m.conditions != nil {
  16692. fields = append(fields, label.FieldConditions)
  16693. }
  16694. if m.organization_id != nil {
  16695. fields = append(fields, label.FieldOrganizationID)
  16696. }
  16697. return fields
  16698. }
  16699. // Field returns the value of a field with the given name. The second boolean
  16700. // return value indicates that this field was not set, or was not defined in the
  16701. // schema.
  16702. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  16703. switch name {
  16704. case label.FieldCreatedAt:
  16705. return m.CreatedAt()
  16706. case label.FieldUpdatedAt:
  16707. return m.UpdatedAt()
  16708. case label.FieldStatus:
  16709. return m.Status()
  16710. case label.FieldType:
  16711. return m.GetType()
  16712. case label.FieldName:
  16713. return m.Name()
  16714. case label.FieldFrom:
  16715. return m.From()
  16716. case label.FieldMode:
  16717. return m.Mode()
  16718. case label.FieldConditions:
  16719. return m.Conditions()
  16720. case label.FieldOrganizationID:
  16721. return m.OrganizationID()
  16722. }
  16723. return nil, false
  16724. }
  16725. // OldField returns the old value of the field from the database. An error is
  16726. // returned if the mutation operation is not UpdateOne, or the query to the
  16727. // database failed.
  16728. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16729. switch name {
  16730. case label.FieldCreatedAt:
  16731. return m.OldCreatedAt(ctx)
  16732. case label.FieldUpdatedAt:
  16733. return m.OldUpdatedAt(ctx)
  16734. case label.FieldStatus:
  16735. return m.OldStatus(ctx)
  16736. case label.FieldType:
  16737. return m.OldType(ctx)
  16738. case label.FieldName:
  16739. return m.OldName(ctx)
  16740. case label.FieldFrom:
  16741. return m.OldFrom(ctx)
  16742. case label.FieldMode:
  16743. return m.OldMode(ctx)
  16744. case label.FieldConditions:
  16745. return m.OldConditions(ctx)
  16746. case label.FieldOrganizationID:
  16747. return m.OldOrganizationID(ctx)
  16748. }
  16749. return nil, fmt.Errorf("unknown Label field %s", name)
  16750. }
  16751. // SetField sets the value of a field with the given name. It returns an error if
  16752. // the field is not defined in the schema, or if the type mismatched the field
  16753. // type.
  16754. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  16755. switch name {
  16756. case label.FieldCreatedAt:
  16757. v, ok := value.(time.Time)
  16758. if !ok {
  16759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16760. }
  16761. m.SetCreatedAt(v)
  16762. return nil
  16763. case label.FieldUpdatedAt:
  16764. v, ok := value.(time.Time)
  16765. if !ok {
  16766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16767. }
  16768. m.SetUpdatedAt(v)
  16769. return nil
  16770. case label.FieldStatus:
  16771. v, ok := value.(uint8)
  16772. if !ok {
  16773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16774. }
  16775. m.SetStatus(v)
  16776. return nil
  16777. case label.FieldType:
  16778. v, ok := value.(int)
  16779. if !ok {
  16780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16781. }
  16782. m.SetType(v)
  16783. return nil
  16784. case label.FieldName:
  16785. v, ok := value.(string)
  16786. if !ok {
  16787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16788. }
  16789. m.SetName(v)
  16790. return nil
  16791. case label.FieldFrom:
  16792. v, ok := value.(int)
  16793. if !ok {
  16794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16795. }
  16796. m.SetFrom(v)
  16797. return nil
  16798. case label.FieldMode:
  16799. v, ok := value.(int)
  16800. if !ok {
  16801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16802. }
  16803. m.SetMode(v)
  16804. return nil
  16805. case label.FieldConditions:
  16806. v, ok := value.(string)
  16807. if !ok {
  16808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16809. }
  16810. m.SetConditions(v)
  16811. return nil
  16812. case label.FieldOrganizationID:
  16813. v, ok := value.(uint64)
  16814. if !ok {
  16815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16816. }
  16817. m.SetOrganizationID(v)
  16818. return nil
  16819. }
  16820. return fmt.Errorf("unknown Label field %s", name)
  16821. }
  16822. // AddedFields returns all numeric fields that were incremented/decremented during
  16823. // this mutation.
  16824. func (m *LabelMutation) AddedFields() []string {
  16825. var fields []string
  16826. if m.addstatus != nil {
  16827. fields = append(fields, label.FieldStatus)
  16828. }
  16829. if m.add_type != nil {
  16830. fields = append(fields, label.FieldType)
  16831. }
  16832. if m.addfrom != nil {
  16833. fields = append(fields, label.FieldFrom)
  16834. }
  16835. if m.addmode != nil {
  16836. fields = append(fields, label.FieldMode)
  16837. }
  16838. if m.addorganization_id != nil {
  16839. fields = append(fields, label.FieldOrganizationID)
  16840. }
  16841. return fields
  16842. }
  16843. // AddedField returns the numeric value that was incremented/decremented on a field
  16844. // with the given name. The second boolean return value indicates that this field
  16845. // was not set, or was not defined in the schema.
  16846. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  16847. switch name {
  16848. case label.FieldStatus:
  16849. return m.AddedStatus()
  16850. case label.FieldType:
  16851. return m.AddedType()
  16852. case label.FieldFrom:
  16853. return m.AddedFrom()
  16854. case label.FieldMode:
  16855. return m.AddedMode()
  16856. case label.FieldOrganizationID:
  16857. return m.AddedOrganizationID()
  16858. }
  16859. return nil, false
  16860. }
  16861. // AddField adds the value to the field with the given name. It returns an error if
  16862. // the field is not defined in the schema, or if the type mismatched the field
  16863. // type.
  16864. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  16865. switch name {
  16866. case label.FieldStatus:
  16867. v, ok := value.(int8)
  16868. if !ok {
  16869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16870. }
  16871. m.AddStatus(v)
  16872. return nil
  16873. case label.FieldType:
  16874. v, ok := value.(int)
  16875. if !ok {
  16876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16877. }
  16878. m.AddType(v)
  16879. return nil
  16880. case label.FieldFrom:
  16881. v, ok := value.(int)
  16882. if !ok {
  16883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16884. }
  16885. m.AddFrom(v)
  16886. return nil
  16887. case label.FieldMode:
  16888. v, ok := value.(int)
  16889. if !ok {
  16890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16891. }
  16892. m.AddMode(v)
  16893. return nil
  16894. case label.FieldOrganizationID:
  16895. v, ok := value.(int64)
  16896. if !ok {
  16897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16898. }
  16899. m.AddOrganizationID(v)
  16900. return nil
  16901. }
  16902. return fmt.Errorf("unknown Label numeric field %s", name)
  16903. }
  16904. // ClearedFields returns all nullable fields that were cleared during this
  16905. // mutation.
  16906. func (m *LabelMutation) ClearedFields() []string {
  16907. var fields []string
  16908. if m.FieldCleared(label.FieldStatus) {
  16909. fields = append(fields, label.FieldStatus)
  16910. }
  16911. if m.FieldCleared(label.FieldConditions) {
  16912. fields = append(fields, label.FieldConditions)
  16913. }
  16914. if m.FieldCleared(label.FieldOrganizationID) {
  16915. fields = append(fields, label.FieldOrganizationID)
  16916. }
  16917. return fields
  16918. }
  16919. // FieldCleared returns a boolean indicating if a field with the given name was
  16920. // cleared in this mutation.
  16921. func (m *LabelMutation) FieldCleared(name string) bool {
  16922. _, ok := m.clearedFields[name]
  16923. return ok
  16924. }
  16925. // ClearField clears the value of the field with the given name. It returns an
  16926. // error if the field is not defined in the schema.
  16927. func (m *LabelMutation) ClearField(name string) error {
  16928. switch name {
  16929. case label.FieldStatus:
  16930. m.ClearStatus()
  16931. return nil
  16932. case label.FieldConditions:
  16933. m.ClearConditions()
  16934. return nil
  16935. case label.FieldOrganizationID:
  16936. m.ClearOrganizationID()
  16937. return nil
  16938. }
  16939. return fmt.Errorf("unknown Label nullable field %s", name)
  16940. }
  16941. // ResetField resets all changes in the mutation for the field with the given name.
  16942. // It returns an error if the field is not defined in the schema.
  16943. func (m *LabelMutation) ResetField(name string) error {
  16944. switch name {
  16945. case label.FieldCreatedAt:
  16946. m.ResetCreatedAt()
  16947. return nil
  16948. case label.FieldUpdatedAt:
  16949. m.ResetUpdatedAt()
  16950. return nil
  16951. case label.FieldStatus:
  16952. m.ResetStatus()
  16953. return nil
  16954. case label.FieldType:
  16955. m.ResetType()
  16956. return nil
  16957. case label.FieldName:
  16958. m.ResetName()
  16959. return nil
  16960. case label.FieldFrom:
  16961. m.ResetFrom()
  16962. return nil
  16963. case label.FieldMode:
  16964. m.ResetMode()
  16965. return nil
  16966. case label.FieldConditions:
  16967. m.ResetConditions()
  16968. return nil
  16969. case label.FieldOrganizationID:
  16970. m.ResetOrganizationID()
  16971. return nil
  16972. }
  16973. return fmt.Errorf("unknown Label field %s", name)
  16974. }
  16975. // AddedEdges returns all edge names that were set/added in this mutation.
  16976. func (m *LabelMutation) AddedEdges() []string {
  16977. edges := make([]string, 0, 1)
  16978. if m.label_relationships != nil {
  16979. edges = append(edges, label.EdgeLabelRelationships)
  16980. }
  16981. return edges
  16982. }
  16983. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16984. // name in this mutation.
  16985. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  16986. switch name {
  16987. case label.EdgeLabelRelationships:
  16988. ids := make([]ent.Value, 0, len(m.label_relationships))
  16989. for id := range m.label_relationships {
  16990. ids = append(ids, id)
  16991. }
  16992. return ids
  16993. }
  16994. return nil
  16995. }
  16996. // RemovedEdges returns all edge names that were removed in this mutation.
  16997. func (m *LabelMutation) RemovedEdges() []string {
  16998. edges := make([]string, 0, 1)
  16999. if m.removedlabel_relationships != nil {
  17000. edges = append(edges, label.EdgeLabelRelationships)
  17001. }
  17002. return edges
  17003. }
  17004. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17005. // the given name in this mutation.
  17006. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  17007. switch name {
  17008. case label.EdgeLabelRelationships:
  17009. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  17010. for id := range m.removedlabel_relationships {
  17011. ids = append(ids, id)
  17012. }
  17013. return ids
  17014. }
  17015. return nil
  17016. }
  17017. // ClearedEdges returns all edge names that were cleared in this mutation.
  17018. func (m *LabelMutation) ClearedEdges() []string {
  17019. edges := make([]string, 0, 1)
  17020. if m.clearedlabel_relationships {
  17021. edges = append(edges, label.EdgeLabelRelationships)
  17022. }
  17023. return edges
  17024. }
  17025. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17026. // was cleared in this mutation.
  17027. func (m *LabelMutation) EdgeCleared(name string) bool {
  17028. switch name {
  17029. case label.EdgeLabelRelationships:
  17030. return m.clearedlabel_relationships
  17031. }
  17032. return false
  17033. }
  17034. // ClearEdge clears the value of the edge with the given name. It returns an error
  17035. // if that edge is not defined in the schema.
  17036. func (m *LabelMutation) ClearEdge(name string) error {
  17037. switch name {
  17038. }
  17039. return fmt.Errorf("unknown Label unique edge %s", name)
  17040. }
  17041. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17042. // It returns an error if the edge is not defined in the schema.
  17043. func (m *LabelMutation) ResetEdge(name string) error {
  17044. switch name {
  17045. case label.EdgeLabelRelationships:
  17046. m.ResetLabelRelationships()
  17047. return nil
  17048. }
  17049. return fmt.Errorf("unknown Label edge %s", name)
  17050. }
  17051. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  17052. type LabelRelationshipMutation struct {
  17053. config
  17054. op Op
  17055. typ string
  17056. id *uint64
  17057. created_at *time.Time
  17058. updated_at *time.Time
  17059. status *uint8
  17060. addstatus *int8
  17061. organization_id *uint64
  17062. addorganization_id *int64
  17063. clearedFields map[string]struct{}
  17064. contacts *uint64
  17065. clearedcontacts bool
  17066. labels *uint64
  17067. clearedlabels bool
  17068. done bool
  17069. oldValue func(context.Context) (*LabelRelationship, error)
  17070. predicates []predicate.LabelRelationship
  17071. }
  17072. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  17073. // labelrelationshipOption allows management of the mutation configuration using functional options.
  17074. type labelrelationshipOption func(*LabelRelationshipMutation)
  17075. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  17076. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  17077. m := &LabelRelationshipMutation{
  17078. config: c,
  17079. op: op,
  17080. typ: TypeLabelRelationship,
  17081. clearedFields: make(map[string]struct{}),
  17082. }
  17083. for _, opt := range opts {
  17084. opt(m)
  17085. }
  17086. return m
  17087. }
  17088. // withLabelRelationshipID sets the ID field of the mutation.
  17089. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  17090. return func(m *LabelRelationshipMutation) {
  17091. var (
  17092. err error
  17093. once sync.Once
  17094. value *LabelRelationship
  17095. )
  17096. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  17097. once.Do(func() {
  17098. if m.done {
  17099. err = errors.New("querying old values post mutation is not allowed")
  17100. } else {
  17101. value, err = m.Client().LabelRelationship.Get(ctx, id)
  17102. }
  17103. })
  17104. return value, err
  17105. }
  17106. m.id = &id
  17107. }
  17108. }
  17109. // withLabelRelationship sets the old LabelRelationship of the mutation.
  17110. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  17111. return func(m *LabelRelationshipMutation) {
  17112. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  17113. return node, nil
  17114. }
  17115. m.id = &node.ID
  17116. }
  17117. }
  17118. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17119. // executed in a transaction (ent.Tx), a transactional client is returned.
  17120. func (m LabelRelationshipMutation) Client() *Client {
  17121. client := &Client{config: m.config}
  17122. client.init()
  17123. return client
  17124. }
  17125. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17126. // it returns an error otherwise.
  17127. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  17128. if _, ok := m.driver.(*txDriver); !ok {
  17129. return nil, errors.New("ent: mutation is not running in a transaction")
  17130. }
  17131. tx := &Tx{config: m.config}
  17132. tx.init()
  17133. return tx, nil
  17134. }
  17135. // SetID sets the value of the id field. Note that this
  17136. // operation is only accepted on creation of LabelRelationship entities.
  17137. func (m *LabelRelationshipMutation) SetID(id uint64) {
  17138. m.id = &id
  17139. }
  17140. // ID returns the ID value in the mutation. Note that the ID is only available
  17141. // if it was provided to the builder or after it was returned from the database.
  17142. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  17143. if m.id == nil {
  17144. return
  17145. }
  17146. return *m.id, true
  17147. }
  17148. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17149. // That means, if the mutation is applied within a transaction with an isolation level such
  17150. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17151. // or updated by the mutation.
  17152. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  17153. switch {
  17154. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17155. id, exists := m.ID()
  17156. if exists {
  17157. return []uint64{id}, nil
  17158. }
  17159. fallthrough
  17160. case m.op.Is(OpUpdate | OpDelete):
  17161. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  17162. default:
  17163. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17164. }
  17165. }
  17166. // SetCreatedAt sets the "created_at" field.
  17167. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  17168. m.created_at = &t
  17169. }
  17170. // CreatedAt returns the value of the "created_at" field in the mutation.
  17171. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  17172. v := m.created_at
  17173. if v == nil {
  17174. return
  17175. }
  17176. return *v, true
  17177. }
  17178. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  17179. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17181. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17182. if !m.op.Is(OpUpdateOne) {
  17183. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17184. }
  17185. if m.id == nil || m.oldValue == nil {
  17186. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17187. }
  17188. oldValue, err := m.oldValue(ctx)
  17189. if err != nil {
  17190. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17191. }
  17192. return oldValue.CreatedAt, nil
  17193. }
  17194. // ResetCreatedAt resets all changes to the "created_at" field.
  17195. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  17196. m.created_at = nil
  17197. }
  17198. // SetUpdatedAt sets the "updated_at" field.
  17199. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  17200. m.updated_at = &t
  17201. }
  17202. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17203. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  17204. v := m.updated_at
  17205. if v == nil {
  17206. return
  17207. }
  17208. return *v, true
  17209. }
  17210. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  17211. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17213. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17214. if !m.op.Is(OpUpdateOne) {
  17215. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17216. }
  17217. if m.id == nil || m.oldValue == nil {
  17218. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17219. }
  17220. oldValue, err := m.oldValue(ctx)
  17221. if err != nil {
  17222. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17223. }
  17224. return oldValue.UpdatedAt, nil
  17225. }
  17226. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17227. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  17228. m.updated_at = nil
  17229. }
  17230. // SetStatus sets the "status" field.
  17231. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  17232. m.status = &u
  17233. m.addstatus = nil
  17234. }
  17235. // Status returns the value of the "status" field in the mutation.
  17236. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  17237. v := m.status
  17238. if v == nil {
  17239. return
  17240. }
  17241. return *v, true
  17242. }
  17243. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  17244. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17246. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17247. if !m.op.Is(OpUpdateOne) {
  17248. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17249. }
  17250. if m.id == nil || m.oldValue == nil {
  17251. return v, errors.New("OldStatus requires an ID field in the mutation")
  17252. }
  17253. oldValue, err := m.oldValue(ctx)
  17254. if err != nil {
  17255. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17256. }
  17257. return oldValue.Status, nil
  17258. }
  17259. // AddStatus adds u to the "status" field.
  17260. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  17261. if m.addstatus != nil {
  17262. *m.addstatus += u
  17263. } else {
  17264. m.addstatus = &u
  17265. }
  17266. }
  17267. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17268. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  17269. v := m.addstatus
  17270. if v == nil {
  17271. return
  17272. }
  17273. return *v, true
  17274. }
  17275. // ClearStatus clears the value of the "status" field.
  17276. func (m *LabelRelationshipMutation) ClearStatus() {
  17277. m.status = nil
  17278. m.addstatus = nil
  17279. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  17280. }
  17281. // StatusCleared returns if the "status" field was cleared in this mutation.
  17282. func (m *LabelRelationshipMutation) StatusCleared() bool {
  17283. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  17284. return ok
  17285. }
  17286. // ResetStatus resets all changes to the "status" field.
  17287. func (m *LabelRelationshipMutation) ResetStatus() {
  17288. m.status = nil
  17289. m.addstatus = nil
  17290. delete(m.clearedFields, labelrelationship.FieldStatus)
  17291. }
  17292. // SetLabelID sets the "label_id" field.
  17293. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  17294. m.labels = &u
  17295. }
  17296. // LabelID returns the value of the "label_id" field in the mutation.
  17297. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  17298. v := m.labels
  17299. if v == nil {
  17300. return
  17301. }
  17302. return *v, true
  17303. }
  17304. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  17305. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17307. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  17308. if !m.op.Is(OpUpdateOne) {
  17309. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  17310. }
  17311. if m.id == nil || m.oldValue == nil {
  17312. return v, errors.New("OldLabelID requires an ID field in the mutation")
  17313. }
  17314. oldValue, err := m.oldValue(ctx)
  17315. if err != nil {
  17316. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  17317. }
  17318. return oldValue.LabelID, nil
  17319. }
  17320. // ResetLabelID resets all changes to the "label_id" field.
  17321. func (m *LabelRelationshipMutation) ResetLabelID() {
  17322. m.labels = nil
  17323. }
  17324. // SetContactID sets the "contact_id" field.
  17325. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  17326. m.contacts = &u
  17327. }
  17328. // ContactID returns the value of the "contact_id" field in the mutation.
  17329. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  17330. v := m.contacts
  17331. if v == nil {
  17332. return
  17333. }
  17334. return *v, true
  17335. }
  17336. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  17337. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17339. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  17340. if !m.op.Is(OpUpdateOne) {
  17341. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  17342. }
  17343. if m.id == nil || m.oldValue == nil {
  17344. return v, errors.New("OldContactID requires an ID field in the mutation")
  17345. }
  17346. oldValue, err := m.oldValue(ctx)
  17347. if err != nil {
  17348. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  17349. }
  17350. return oldValue.ContactID, nil
  17351. }
  17352. // ResetContactID resets all changes to the "contact_id" field.
  17353. func (m *LabelRelationshipMutation) ResetContactID() {
  17354. m.contacts = nil
  17355. }
  17356. // SetOrganizationID sets the "organization_id" field.
  17357. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  17358. m.organization_id = &u
  17359. m.addorganization_id = nil
  17360. }
  17361. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17362. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  17363. v := m.organization_id
  17364. if v == nil {
  17365. return
  17366. }
  17367. return *v, true
  17368. }
  17369. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  17370. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17372. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17373. if !m.op.Is(OpUpdateOne) {
  17374. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17375. }
  17376. if m.id == nil || m.oldValue == nil {
  17377. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17378. }
  17379. oldValue, err := m.oldValue(ctx)
  17380. if err != nil {
  17381. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17382. }
  17383. return oldValue.OrganizationID, nil
  17384. }
  17385. // AddOrganizationID adds u to the "organization_id" field.
  17386. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  17387. if m.addorganization_id != nil {
  17388. *m.addorganization_id += u
  17389. } else {
  17390. m.addorganization_id = &u
  17391. }
  17392. }
  17393. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17394. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  17395. v := m.addorganization_id
  17396. if v == nil {
  17397. return
  17398. }
  17399. return *v, true
  17400. }
  17401. // ClearOrganizationID clears the value of the "organization_id" field.
  17402. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  17403. m.organization_id = nil
  17404. m.addorganization_id = nil
  17405. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  17406. }
  17407. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17408. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  17409. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  17410. return ok
  17411. }
  17412. // ResetOrganizationID resets all changes to the "organization_id" field.
  17413. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  17414. m.organization_id = nil
  17415. m.addorganization_id = nil
  17416. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  17417. }
  17418. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  17419. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  17420. m.contacts = &id
  17421. }
  17422. // ClearContacts clears the "contacts" edge to the Contact entity.
  17423. func (m *LabelRelationshipMutation) ClearContacts() {
  17424. m.clearedcontacts = true
  17425. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  17426. }
  17427. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  17428. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  17429. return m.clearedcontacts
  17430. }
  17431. // ContactsID returns the "contacts" edge ID in the mutation.
  17432. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  17433. if m.contacts != nil {
  17434. return *m.contacts, true
  17435. }
  17436. return
  17437. }
  17438. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  17439. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17440. // ContactsID instead. It exists only for internal usage by the builders.
  17441. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  17442. if id := m.contacts; id != nil {
  17443. ids = append(ids, *id)
  17444. }
  17445. return
  17446. }
  17447. // ResetContacts resets all changes to the "contacts" edge.
  17448. func (m *LabelRelationshipMutation) ResetContacts() {
  17449. m.contacts = nil
  17450. m.clearedcontacts = false
  17451. }
  17452. // SetLabelsID sets the "labels" edge to the Label entity by id.
  17453. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  17454. m.labels = &id
  17455. }
  17456. // ClearLabels clears the "labels" edge to the Label entity.
  17457. func (m *LabelRelationshipMutation) ClearLabels() {
  17458. m.clearedlabels = true
  17459. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  17460. }
  17461. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  17462. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  17463. return m.clearedlabels
  17464. }
  17465. // LabelsID returns the "labels" edge ID in the mutation.
  17466. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  17467. if m.labels != nil {
  17468. return *m.labels, true
  17469. }
  17470. return
  17471. }
  17472. // LabelsIDs returns the "labels" edge IDs in the mutation.
  17473. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17474. // LabelsID instead. It exists only for internal usage by the builders.
  17475. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  17476. if id := m.labels; id != nil {
  17477. ids = append(ids, *id)
  17478. }
  17479. return
  17480. }
  17481. // ResetLabels resets all changes to the "labels" edge.
  17482. func (m *LabelRelationshipMutation) ResetLabels() {
  17483. m.labels = nil
  17484. m.clearedlabels = false
  17485. }
  17486. // Where appends a list predicates to the LabelRelationshipMutation builder.
  17487. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  17488. m.predicates = append(m.predicates, ps...)
  17489. }
  17490. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  17491. // users can use type-assertion to append predicates that do not depend on any generated package.
  17492. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  17493. p := make([]predicate.LabelRelationship, len(ps))
  17494. for i := range ps {
  17495. p[i] = ps[i]
  17496. }
  17497. m.Where(p...)
  17498. }
  17499. // Op returns the operation name.
  17500. func (m *LabelRelationshipMutation) Op() Op {
  17501. return m.op
  17502. }
  17503. // SetOp allows setting the mutation operation.
  17504. func (m *LabelRelationshipMutation) SetOp(op Op) {
  17505. m.op = op
  17506. }
  17507. // Type returns the node type of this mutation (LabelRelationship).
  17508. func (m *LabelRelationshipMutation) Type() string {
  17509. return m.typ
  17510. }
  17511. // Fields returns all fields that were changed during this mutation. Note that in
  17512. // order to get all numeric fields that were incremented/decremented, call
  17513. // AddedFields().
  17514. func (m *LabelRelationshipMutation) Fields() []string {
  17515. fields := make([]string, 0, 6)
  17516. if m.created_at != nil {
  17517. fields = append(fields, labelrelationship.FieldCreatedAt)
  17518. }
  17519. if m.updated_at != nil {
  17520. fields = append(fields, labelrelationship.FieldUpdatedAt)
  17521. }
  17522. if m.status != nil {
  17523. fields = append(fields, labelrelationship.FieldStatus)
  17524. }
  17525. if m.labels != nil {
  17526. fields = append(fields, labelrelationship.FieldLabelID)
  17527. }
  17528. if m.contacts != nil {
  17529. fields = append(fields, labelrelationship.FieldContactID)
  17530. }
  17531. if m.organization_id != nil {
  17532. fields = append(fields, labelrelationship.FieldOrganizationID)
  17533. }
  17534. return fields
  17535. }
  17536. // Field returns the value of a field with the given name. The second boolean
  17537. // return value indicates that this field was not set, or was not defined in the
  17538. // schema.
  17539. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  17540. switch name {
  17541. case labelrelationship.FieldCreatedAt:
  17542. return m.CreatedAt()
  17543. case labelrelationship.FieldUpdatedAt:
  17544. return m.UpdatedAt()
  17545. case labelrelationship.FieldStatus:
  17546. return m.Status()
  17547. case labelrelationship.FieldLabelID:
  17548. return m.LabelID()
  17549. case labelrelationship.FieldContactID:
  17550. return m.ContactID()
  17551. case labelrelationship.FieldOrganizationID:
  17552. return m.OrganizationID()
  17553. }
  17554. return nil, false
  17555. }
  17556. // OldField returns the old value of the field from the database. An error is
  17557. // returned if the mutation operation is not UpdateOne, or the query to the
  17558. // database failed.
  17559. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17560. switch name {
  17561. case labelrelationship.FieldCreatedAt:
  17562. return m.OldCreatedAt(ctx)
  17563. case labelrelationship.FieldUpdatedAt:
  17564. return m.OldUpdatedAt(ctx)
  17565. case labelrelationship.FieldStatus:
  17566. return m.OldStatus(ctx)
  17567. case labelrelationship.FieldLabelID:
  17568. return m.OldLabelID(ctx)
  17569. case labelrelationship.FieldContactID:
  17570. return m.OldContactID(ctx)
  17571. case labelrelationship.FieldOrganizationID:
  17572. return m.OldOrganizationID(ctx)
  17573. }
  17574. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  17575. }
  17576. // SetField sets the value of a field with the given name. It returns an error if
  17577. // the field is not defined in the schema, or if the type mismatched the field
  17578. // type.
  17579. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  17580. switch name {
  17581. case labelrelationship.FieldCreatedAt:
  17582. v, ok := value.(time.Time)
  17583. if !ok {
  17584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17585. }
  17586. m.SetCreatedAt(v)
  17587. return nil
  17588. case labelrelationship.FieldUpdatedAt:
  17589. v, ok := value.(time.Time)
  17590. if !ok {
  17591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17592. }
  17593. m.SetUpdatedAt(v)
  17594. return nil
  17595. case labelrelationship.FieldStatus:
  17596. v, ok := value.(uint8)
  17597. if !ok {
  17598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17599. }
  17600. m.SetStatus(v)
  17601. return nil
  17602. case labelrelationship.FieldLabelID:
  17603. v, ok := value.(uint64)
  17604. if !ok {
  17605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17606. }
  17607. m.SetLabelID(v)
  17608. return nil
  17609. case labelrelationship.FieldContactID:
  17610. v, ok := value.(uint64)
  17611. if !ok {
  17612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17613. }
  17614. m.SetContactID(v)
  17615. return nil
  17616. case labelrelationship.FieldOrganizationID:
  17617. v, ok := value.(uint64)
  17618. if !ok {
  17619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17620. }
  17621. m.SetOrganizationID(v)
  17622. return nil
  17623. }
  17624. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17625. }
  17626. // AddedFields returns all numeric fields that were incremented/decremented during
  17627. // this mutation.
  17628. func (m *LabelRelationshipMutation) AddedFields() []string {
  17629. var fields []string
  17630. if m.addstatus != nil {
  17631. fields = append(fields, labelrelationship.FieldStatus)
  17632. }
  17633. if m.addorganization_id != nil {
  17634. fields = append(fields, labelrelationship.FieldOrganizationID)
  17635. }
  17636. return fields
  17637. }
  17638. // AddedField returns the numeric value that was incremented/decremented on a field
  17639. // with the given name. The second boolean return value indicates that this field
  17640. // was not set, or was not defined in the schema.
  17641. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  17642. switch name {
  17643. case labelrelationship.FieldStatus:
  17644. return m.AddedStatus()
  17645. case labelrelationship.FieldOrganizationID:
  17646. return m.AddedOrganizationID()
  17647. }
  17648. return nil, false
  17649. }
  17650. // AddField adds the value to the field with the given name. It returns an error if
  17651. // the field is not defined in the schema, or if the type mismatched the field
  17652. // type.
  17653. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  17654. switch name {
  17655. case labelrelationship.FieldStatus:
  17656. v, ok := value.(int8)
  17657. if !ok {
  17658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17659. }
  17660. m.AddStatus(v)
  17661. return nil
  17662. case labelrelationship.FieldOrganizationID:
  17663. v, ok := value.(int64)
  17664. if !ok {
  17665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17666. }
  17667. m.AddOrganizationID(v)
  17668. return nil
  17669. }
  17670. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  17671. }
  17672. // ClearedFields returns all nullable fields that were cleared during this
  17673. // mutation.
  17674. func (m *LabelRelationshipMutation) ClearedFields() []string {
  17675. var fields []string
  17676. if m.FieldCleared(labelrelationship.FieldStatus) {
  17677. fields = append(fields, labelrelationship.FieldStatus)
  17678. }
  17679. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  17680. fields = append(fields, labelrelationship.FieldOrganizationID)
  17681. }
  17682. return fields
  17683. }
  17684. // FieldCleared returns a boolean indicating if a field with the given name was
  17685. // cleared in this mutation.
  17686. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  17687. _, ok := m.clearedFields[name]
  17688. return ok
  17689. }
  17690. // ClearField clears the value of the field with the given name. It returns an
  17691. // error if the field is not defined in the schema.
  17692. func (m *LabelRelationshipMutation) ClearField(name string) error {
  17693. switch name {
  17694. case labelrelationship.FieldStatus:
  17695. m.ClearStatus()
  17696. return nil
  17697. case labelrelationship.FieldOrganizationID:
  17698. m.ClearOrganizationID()
  17699. return nil
  17700. }
  17701. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  17702. }
  17703. // ResetField resets all changes in the mutation for the field with the given name.
  17704. // It returns an error if the field is not defined in the schema.
  17705. func (m *LabelRelationshipMutation) ResetField(name string) error {
  17706. switch name {
  17707. case labelrelationship.FieldCreatedAt:
  17708. m.ResetCreatedAt()
  17709. return nil
  17710. case labelrelationship.FieldUpdatedAt:
  17711. m.ResetUpdatedAt()
  17712. return nil
  17713. case labelrelationship.FieldStatus:
  17714. m.ResetStatus()
  17715. return nil
  17716. case labelrelationship.FieldLabelID:
  17717. m.ResetLabelID()
  17718. return nil
  17719. case labelrelationship.FieldContactID:
  17720. m.ResetContactID()
  17721. return nil
  17722. case labelrelationship.FieldOrganizationID:
  17723. m.ResetOrganizationID()
  17724. return nil
  17725. }
  17726. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17727. }
  17728. // AddedEdges returns all edge names that were set/added in this mutation.
  17729. func (m *LabelRelationshipMutation) AddedEdges() []string {
  17730. edges := make([]string, 0, 2)
  17731. if m.contacts != nil {
  17732. edges = append(edges, labelrelationship.EdgeContacts)
  17733. }
  17734. if m.labels != nil {
  17735. edges = append(edges, labelrelationship.EdgeLabels)
  17736. }
  17737. return edges
  17738. }
  17739. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17740. // name in this mutation.
  17741. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  17742. switch name {
  17743. case labelrelationship.EdgeContacts:
  17744. if id := m.contacts; id != nil {
  17745. return []ent.Value{*id}
  17746. }
  17747. case labelrelationship.EdgeLabels:
  17748. if id := m.labels; id != nil {
  17749. return []ent.Value{*id}
  17750. }
  17751. }
  17752. return nil
  17753. }
  17754. // RemovedEdges returns all edge names that were removed in this mutation.
  17755. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  17756. edges := make([]string, 0, 2)
  17757. return edges
  17758. }
  17759. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17760. // the given name in this mutation.
  17761. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  17762. return nil
  17763. }
  17764. // ClearedEdges returns all edge names that were cleared in this mutation.
  17765. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  17766. edges := make([]string, 0, 2)
  17767. if m.clearedcontacts {
  17768. edges = append(edges, labelrelationship.EdgeContacts)
  17769. }
  17770. if m.clearedlabels {
  17771. edges = append(edges, labelrelationship.EdgeLabels)
  17772. }
  17773. return edges
  17774. }
  17775. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17776. // was cleared in this mutation.
  17777. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  17778. switch name {
  17779. case labelrelationship.EdgeContacts:
  17780. return m.clearedcontacts
  17781. case labelrelationship.EdgeLabels:
  17782. return m.clearedlabels
  17783. }
  17784. return false
  17785. }
  17786. // ClearEdge clears the value of the edge with the given name. It returns an error
  17787. // if that edge is not defined in the schema.
  17788. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  17789. switch name {
  17790. case labelrelationship.EdgeContacts:
  17791. m.ClearContacts()
  17792. return nil
  17793. case labelrelationship.EdgeLabels:
  17794. m.ClearLabels()
  17795. return nil
  17796. }
  17797. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  17798. }
  17799. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17800. // It returns an error if the edge is not defined in the schema.
  17801. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  17802. switch name {
  17803. case labelrelationship.EdgeContacts:
  17804. m.ResetContacts()
  17805. return nil
  17806. case labelrelationship.EdgeLabels:
  17807. m.ResetLabels()
  17808. return nil
  17809. }
  17810. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  17811. }
  17812. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  17813. type LabelTaggingMutation struct {
  17814. config
  17815. op Op
  17816. typ string
  17817. id *uint64
  17818. created_at *time.Time
  17819. updated_at *time.Time
  17820. status *uint8
  17821. addstatus *int8
  17822. deleted_at *time.Time
  17823. organization_id *uint64
  17824. addorganization_id *int64
  17825. _type *int
  17826. add_type *int
  17827. conditions *string
  17828. action_label_add *[]uint64
  17829. appendaction_label_add []uint64
  17830. action_label_del *[]uint64
  17831. appendaction_label_del []uint64
  17832. clearedFields map[string]struct{}
  17833. done bool
  17834. oldValue func(context.Context) (*LabelTagging, error)
  17835. predicates []predicate.LabelTagging
  17836. }
  17837. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  17838. // labeltaggingOption allows management of the mutation configuration using functional options.
  17839. type labeltaggingOption func(*LabelTaggingMutation)
  17840. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  17841. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  17842. m := &LabelTaggingMutation{
  17843. config: c,
  17844. op: op,
  17845. typ: TypeLabelTagging,
  17846. clearedFields: make(map[string]struct{}),
  17847. }
  17848. for _, opt := range opts {
  17849. opt(m)
  17850. }
  17851. return m
  17852. }
  17853. // withLabelTaggingID sets the ID field of the mutation.
  17854. func withLabelTaggingID(id uint64) labeltaggingOption {
  17855. return func(m *LabelTaggingMutation) {
  17856. var (
  17857. err error
  17858. once sync.Once
  17859. value *LabelTagging
  17860. )
  17861. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  17862. once.Do(func() {
  17863. if m.done {
  17864. err = errors.New("querying old values post mutation is not allowed")
  17865. } else {
  17866. value, err = m.Client().LabelTagging.Get(ctx, id)
  17867. }
  17868. })
  17869. return value, err
  17870. }
  17871. m.id = &id
  17872. }
  17873. }
  17874. // withLabelTagging sets the old LabelTagging of the mutation.
  17875. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  17876. return func(m *LabelTaggingMutation) {
  17877. m.oldValue = func(context.Context) (*LabelTagging, error) {
  17878. return node, nil
  17879. }
  17880. m.id = &node.ID
  17881. }
  17882. }
  17883. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17884. // executed in a transaction (ent.Tx), a transactional client is returned.
  17885. func (m LabelTaggingMutation) Client() *Client {
  17886. client := &Client{config: m.config}
  17887. client.init()
  17888. return client
  17889. }
  17890. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17891. // it returns an error otherwise.
  17892. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  17893. if _, ok := m.driver.(*txDriver); !ok {
  17894. return nil, errors.New("ent: mutation is not running in a transaction")
  17895. }
  17896. tx := &Tx{config: m.config}
  17897. tx.init()
  17898. return tx, nil
  17899. }
  17900. // SetID sets the value of the id field. Note that this
  17901. // operation is only accepted on creation of LabelTagging entities.
  17902. func (m *LabelTaggingMutation) SetID(id uint64) {
  17903. m.id = &id
  17904. }
  17905. // ID returns the ID value in the mutation. Note that the ID is only available
  17906. // if it was provided to the builder or after it was returned from the database.
  17907. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  17908. if m.id == nil {
  17909. return
  17910. }
  17911. return *m.id, true
  17912. }
  17913. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17914. // That means, if the mutation is applied within a transaction with an isolation level such
  17915. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17916. // or updated by the mutation.
  17917. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  17918. switch {
  17919. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17920. id, exists := m.ID()
  17921. if exists {
  17922. return []uint64{id}, nil
  17923. }
  17924. fallthrough
  17925. case m.op.Is(OpUpdate | OpDelete):
  17926. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  17927. default:
  17928. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17929. }
  17930. }
  17931. // SetCreatedAt sets the "created_at" field.
  17932. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  17933. m.created_at = &t
  17934. }
  17935. // CreatedAt returns the value of the "created_at" field in the mutation.
  17936. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  17937. v := m.created_at
  17938. if v == nil {
  17939. return
  17940. }
  17941. return *v, true
  17942. }
  17943. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  17944. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17946. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17947. if !m.op.Is(OpUpdateOne) {
  17948. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17949. }
  17950. if m.id == nil || m.oldValue == nil {
  17951. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17952. }
  17953. oldValue, err := m.oldValue(ctx)
  17954. if err != nil {
  17955. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17956. }
  17957. return oldValue.CreatedAt, nil
  17958. }
  17959. // ResetCreatedAt resets all changes to the "created_at" field.
  17960. func (m *LabelTaggingMutation) ResetCreatedAt() {
  17961. m.created_at = nil
  17962. }
  17963. // SetUpdatedAt sets the "updated_at" field.
  17964. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  17965. m.updated_at = &t
  17966. }
  17967. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17968. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  17969. v := m.updated_at
  17970. if v == nil {
  17971. return
  17972. }
  17973. return *v, true
  17974. }
  17975. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  17976. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17978. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17979. if !m.op.Is(OpUpdateOne) {
  17980. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17981. }
  17982. if m.id == nil || m.oldValue == nil {
  17983. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17984. }
  17985. oldValue, err := m.oldValue(ctx)
  17986. if err != nil {
  17987. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17988. }
  17989. return oldValue.UpdatedAt, nil
  17990. }
  17991. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17992. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  17993. m.updated_at = nil
  17994. }
  17995. // SetStatus sets the "status" field.
  17996. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  17997. m.status = &u
  17998. m.addstatus = nil
  17999. }
  18000. // Status returns the value of the "status" field in the mutation.
  18001. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  18002. v := m.status
  18003. if v == nil {
  18004. return
  18005. }
  18006. return *v, true
  18007. }
  18008. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  18009. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18011. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18012. if !m.op.Is(OpUpdateOne) {
  18013. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18014. }
  18015. if m.id == nil || m.oldValue == nil {
  18016. return v, errors.New("OldStatus requires an ID field in the mutation")
  18017. }
  18018. oldValue, err := m.oldValue(ctx)
  18019. if err != nil {
  18020. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18021. }
  18022. return oldValue.Status, nil
  18023. }
  18024. // AddStatus adds u to the "status" field.
  18025. func (m *LabelTaggingMutation) AddStatus(u int8) {
  18026. if m.addstatus != nil {
  18027. *m.addstatus += u
  18028. } else {
  18029. m.addstatus = &u
  18030. }
  18031. }
  18032. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18033. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  18034. v := m.addstatus
  18035. if v == nil {
  18036. return
  18037. }
  18038. return *v, true
  18039. }
  18040. // ClearStatus clears the value of the "status" field.
  18041. func (m *LabelTaggingMutation) ClearStatus() {
  18042. m.status = nil
  18043. m.addstatus = nil
  18044. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  18045. }
  18046. // StatusCleared returns if the "status" field was cleared in this mutation.
  18047. func (m *LabelTaggingMutation) StatusCleared() bool {
  18048. _, ok := m.clearedFields[labeltagging.FieldStatus]
  18049. return ok
  18050. }
  18051. // ResetStatus resets all changes to the "status" field.
  18052. func (m *LabelTaggingMutation) ResetStatus() {
  18053. m.status = nil
  18054. m.addstatus = nil
  18055. delete(m.clearedFields, labeltagging.FieldStatus)
  18056. }
  18057. // SetDeletedAt sets the "deleted_at" field.
  18058. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  18059. m.deleted_at = &t
  18060. }
  18061. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18062. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  18063. v := m.deleted_at
  18064. if v == nil {
  18065. return
  18066. }
  18067. return *v, true
  18068. }
  18069. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  18070. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18072. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18073. if !m.op.Is(OpUpdateOne) {
  18074. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18075. }
  18076. if m.id == nil || m.oldValue == nil {
  18077. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18078. }
  18079. oldValue, err := m.oldValue(ctx)
  18080. if err != nil {
  18081. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18082. }
  18083. return oldValue.DeletedAt, nil
  18084. }
  18085. // ClearDeletedAt clears the value of the "deleted_at" field.
  18086. func (m *LabelTaggingMutation) ClearDeletedAt() {
  18087. m.deleted_at = nil
  18088. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  18089. }
  18090. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18091. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  18092. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  18093. return ok
  18094. }
  18095. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18096. func (m *LabelTaggingMutation) ResetDeletedAt() {
  18097. m.deleted_at = nil
  18098. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  18099. }
  18100. // SetOrganizationID sets the "organization_id" field.
  18101. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  18102. m.organization_id = &u
  18103. m.addorganization_id = nil
  18104. }
  18105. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18106. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  18107. v := m.organization_id
  18108. if v == nil {
  18109. return
  18110. }
  18111. return *v, true
  18112. }
  18113. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  18114. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18116. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18117. if !m.op.Is(OpUpdateOne) {
  18118. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18119. }
  18120. if m.id == nil || m.oldValue == nil {
  18121. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18122. }
  18123. oldValue, err := m.oldValue(ctx)
  18124. if err != nil {
  18125. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18126. }
  18127. return oldValue.OrganizationID, nil
  18128. }
  18129. // AddOrganizationID adds u to the "organization_id" field.
  18130. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  18131. if m.addorganization_id != nil {
  18132. *m.addorganization_id += u
  18133. } else {
  18134. m.addorganization_id = &u
  18135. }
  18136. }
  18137. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18138. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  18139. v := m.addorganization_id
  18140. if v == nil {
  18141. return
  18142. }
  18143. return *v, true
  18144. }
  18145. // ResetOrganizationID resets all changes to the "organization_id" field.
  18146. func (m *LabelTaggingMutation) ResetOrganizationID() {
  18147. m.organization_id = nil
  18148. m.addorganization_id = nil
  18149. }
  18150. // SetType sets the "type" field.
  18151. func (m *LabelTaggingMutation) SetType(i int) {
  18152. m._type = &i
  18153. m.add_type = nil
  18154. }
  18155. // GetType returns the value of the "type" field in the mutation.
  18156. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  18157. v := m._type
  18158. if v == nil {
  18159. return
  18160. }
  18161. return *v, true
  18162. }
  18163. // OldType returns the old "type" field's value of the LabelTagging entity.
  18164. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18166. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  18167. if !m.op.Is(OpUpdateOne) {
  18168. return v, errors.New("OldType is only allowed on UpdateOne operations")
  18169. }
  18170. if m.id == nil || m.oldValue == nil {
  18171. return v, errors.New("OldType requires an ID field in the mutation")
  18172. }
  18173. oldValue, err := m.oldValue(ctx)
  18174. if err != nil {
  18175. return v, fmt.Errorf("querying old value for OldType: %w", err)
  18176. }
  18177. return oldValue.Type, nil
  18178. }
  18179. // AddType adds i to the "type" field.
  18180. func (m *LabelTaggingMutation) AddType(i int) {
  18181. if m.add_type != nil {
  18182. *m.add_type += i
  18183. } else {
  18184. m.add_type = &i
  18185. }
  18186. }
  18187. // AddedType returns the value that was added to the "type" field in this mutation.
  18188. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  18189. v := m.add_type
  18190. if v == nil {
  18191. return
  18192. }
  18193. return *v, true
  18194. }
  18195. // ResetType resets all changes to the "type" field.
  18196. func (m *LabelTaggingMutation) ResetType() {
  18197. m._type = nil
  18198. m.add_type = nil
  18199. }
  18200. // SetConditions sets the "conditions" field.
  18201. func (m *LabelTaggingMutation) SetConditions(s string) {
  18202. m.conditions = &s
  18203. }
  18204. // Conditions returns the value of the "conditions" field in the mutation.
  18205. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  18206. v := m.conditions
  18207. if v == nil {
  18208. return
  18209. }
  18210. return *v, true
  18211. }
  18212. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  18213. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18215. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  18216. if !m.op.Is(OpUpdateOne) {
  18217. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  18218. }
  18219. if m.id == nil || m.oldValue == nil {
  18220. return v, errors.New("OldConditions requires an ID field in the mutation")
  18221. }
  18222. oldValue, err := m.oldValue(ctx)
  18223. if err != nil {
  18224. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  18225. }
  18226. return oldValue.Conditions, nil
  18227. }
  18228. // ResetConditions resets all changes to the "conditions" field.
  18229. func (m *LabelTaggingMutation) ResetConditions() {
  18230. m.conditions = nil
  18231. }
  18232. // SetActionLabelAdd sets the "action_label_add" field.
  18233. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  18234. m.action_label_add = &u
  18235. m.appendaction_label_add = nil
  18236. }
  18237. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18238. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18239. v := m.action_label_add
  18240. if v == nil {
  18241. return
  18242. }
  18243. return *v, true
  18244. }
  18245. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  18246. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18248. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18249. if !m.op.Is(OpUpdateOne) {
  18250. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18251. }
  18252. if m.id == nil || m.oldValue == nil {
  18253. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18254. }
  18255. oldValue, err := m.oldValue(ctx)
  18256. if err != nil {
  18257. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18258. }
  18259. return oldValue.ActionLabelAdd, nil
  18260. }
  18261. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18262. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  18263. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18264. }
  18265. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18266. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18267. if len(m.appendaction_label_add) == 0 {
  18268. return nil, false
  18269. }
  18270. return m.appendaction_label_add, true
  18271. }
  18272. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18273. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  18274. m.action_label_add = nil
  18275. m.appendaction_label_add = nil
  18276. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  18277. }
  18278. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18279. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  18280. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  18281. return ok
  18282. }
  18283. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18284. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  18285. m.action_label_add = nil
  18286. m.appendaction_label_add = nil
  18287. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  18288. }
  18289. // SetActionLabelDel sets the "action_label_del" field.
  18290. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  18291. m.action_label_del = &u
  18292. m.appendaction_label_del = nil
  18293. }
  18294. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18295. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  18296. v := m.action_label_del
  18297. if v == nil {
  18298. return
  18299. }
  18300. return *v, true
  18301. }
  18302. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  18303. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18305. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18306. if !m.op.Is(OpUpdateOne) {
  18307. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18308. }
  18309. if m.id == nil || m.oldValue == nil {
  18310. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18311. }
  18312. oldValue, err := m.oldValue(ctx)
  18313. if err != nil {
  18314. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18315. }
  18316. return oldValue.ActionLabelDel, nil
  18317. }
  18318. // AppendActionLabelDel adds u to the "action_label_del" field.
  18319. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  18320. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18321. }
  18322. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18323. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18324. if len(m.appendaction_label_del) == 0 {
  18325. return nil, false
  18326. }
  18327. return m.appendaction_label_del, true
  18328. }
  18329. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18330. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  18331. m.action_label_del = nil
  18332. m.appendaction_label_del = nil
  18333. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  18334. }
  18335. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18336. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  18337. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  18338. return ok
  18339. }
  18340. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18341. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  18342. m.action_label_del = nil
  18343. m.appendaction_label_del = nil
  18344. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  18345. }
  18346. // Where appends a list predicates to the LabelTaggingMutation builder.
  18347. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  18348. m.predicates = append(m.predicates, ps...)
  18349. }
  18350. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  18351. // users can use type-assertion to append predicates that do not depend on any generated package.
  18352. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  18353. p := make([]predicate.LabelTagging, len(ps))
  18354. for i := range ps {
  18355. p[i] = ps[i]
  18356. }
  18357. m.Where(p...)
  18358. }
  18359. // Op returns the operation name.
  18360. func (m *LabelTaggingMutation) Op() Op {
  18361. return m.op
  18362. }
  18363. // SetOp allows setting the mutation operation.
  18364. func (m *LabelTaggingMutation) SetOp(op Op) {
  18365. m.op = op
  18366. }
  18367. // Type returns the node type of this mutation (LabelTagging).
  18368. func (m *LabelTaggingMutation) Type() string {
  18369. return m.typ
  18370. }
  18371. // Fields returns all fields that were changed during this mutation. Note that in
  18372. // order to get all numeric fields that were incremented/decremented, call
  18373. // AddedFields().
  18374. func (m *LabelTaggingMutation) Fields() []string {
  18375. fields := make([]string, 0, 9)
  18376. if m.created_at != nil {
  18377. fields = append(fields, labeltagging.FieldCreatedAt)
  18378. }
  18379. if m.updated_at != nil {
  18380. fields = append(fields, labeltagging.FieldUpdatedAt)
  18381. }
  18382. if m.status != nil {
  18383. fields = append(fields, labeltagging.FieldStatus)
  18384. }
  18385. if m.deleted_at != nil {
  18386. fields = append(fields, labeltagging.FieldDeletedAt)
  18387. }
  18388. if m.organization_id != nil {
  18389. fields = append(fields, labeltagging.FieldOrganizationID)
  18390. }
  18391. if m._type != nil {
  18392. fields = append(fields, labeltagging.FieldType)
  18393. }
  18394. if m.conditions != nil {
  18395. fields = append(fields, labeltagging.FieldConditions)
  18396. }
  18397. if m.action_label_add != nil {
  18398. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18399. }
  18400. if m.action_label_del != nil {
  18401. fields = append(fields, labeltagging.FieldActionLabelDel)
  18402. }
  18403. return fields
  18404. }
  18405. // Field returns the value of a field with the given name. The second boolean
  18406. // return value indicates that this field was not set, or was not defined in the
  18407. // schema.
  18408. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  18409. switch name {
  18410. case labeltagging.FieldCreatedAt:
  18411. return m.CreatedAt()
  18412. case labeltagging.FieldUpdatedAt:
  18413. return m.UpdatedAt()
  18414. case labeltagging.FieldStatus:
  18415. return m.Status()
  18416. case labeltagging.FieldDeletedAt:
  18417. return m.DeletedAt()
  18418. case labeltagging.FieldOrganizationID:
  18419. return m.OrganizationID()
  18420. case labeltagging.FieldType:
  18421. return m.GetType()
  18422. case labeltagging.FieldConditions:
  18423. return m.Conditions()
  18424. case labeltagging.FieldActionLabelAdd:
  18425. return m.ActionLabelAdd()
  18426. case labeltagging.FieldActionLabelDel:
  18427. return m.ActionLabelDel()
  18428. }
  18429. return nil, false
  18430. }
  18431. // OldField returns the old value of the field from the database. An error is
  18432. // returned if the mutation operation is not UpdateOne, or the query to the
  18433. // database failed.
  18434. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18435. switch name {
  18436. case labeltagging.FieldCreatedAt:
  18437. return m.OldCreatedAt(ctx)
  18438. case labeltagging.FieldUpdatedAt:
  18439. return m.OldUpdatedAt(ctx)
  18440. case labeltagging.FieldStatus:
  18441. return m.OldStatus(ctx)
  18442. case labeltagging.FieldDeletedAt:
  18443. return m.OldDeletedAt(ctx)
  18444. case labeltagging.FieldOrganizationID:
  18445. return m.OldOrganizationID(ctx)
  18446. case labeltagging.FieldType:
  18447. return m.OldType(ctx)
  18448. case labeltagging.FieldConditions:
  18449. return m.OldConditions(ctx)
  18450. case labeltagging.FieldActionLabelAdd:
  18451. return m.OldActionLabelAdd(ctx)
  18452. case labeltagging.FieldActionLabelDel:
  18453. return m.OldActionLabelDel(ctx)
  18454. }
  18455. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  18456. }
  18457. // SetField sets the value of a field with the given name. It returns an error if
  18458. // the field is not defined in the schema, or if the type mismatched the field
  18459. // type.
  18460. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  18461. switch name {
  18462. case labeltagging.FieldCreatedAt:
  18463. v, ok := value.(time.Time)
  18464. if !ok {
  18465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18466. }
  18467. m.SetCreatedAt(v)
  18468. return nil
  18469. case labeltagging.FieldUpdatedAt:
  18470. v, ok := value.(time.Time)
  18471. if !ok {
  18472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18473. }
  18474. m.SetUpdatedAt(v)
  18475. return nil
  18476. case labeltagging.FieldStatus:
  18477. v, ok := value.(uint8)
  18478. if !ok {
  18479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18480. }
  18481. m.SetStatus(v)
  18482. return nil
  18483. case labeltagging.FieldDeletedAt:
  18484. v, ok := value.(time.Time)
  18485. if !ok {
  18486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18487. }
  18488. m.SetDeletedAt(v)
  18489. return nil
  18490. case labeltagging.FieldOrganizationID:
  18491. v, ok := value.(uint64)
  18492. if !ok {
  18493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18494. }
  18495. m.SetOrganizationID(v)
  18496. return nil
  18497. case labeltagging.FieldType:
  18498. v, ok := value.(int)
  18499. if !ok {
  18500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18501. }
  18502. m.SetType(v)
  18503. return nil
  18504. case labeltagging.FieldConditions:
  18505. v, ok := value.(string)
  18506. if !ok {
  18507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18508. }
  18509. m.SetConditions(v)
  18510. return nil
  18511. case labeltagging.FieldActionLabelAdd:
  18512. v, ok := value.([]uint64)
  18513. if !ok {
  18514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18515. }
  18516. m.SetActionLabelAdd(v)
  18517. return nil
  18518. case labeltagging.FieldActionLabelDel:
  18519. v, ok := value.([]uint64)
  18520. if !ok {
  18521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18522. }
  18523. m.SetActionLabelDel(v)
  18524. return nil
  18525. }
  18526. return fmt.Errorf("unknown LabelTagging field %s", name)
  18527. }
  18528. // AddedFields returns all numeric fields that were incremented/decremented during
  18529. // this mutation.
  18530. func (m *LabelTaggingMutation) AddedFields() []string {
  18531. var fields []string
  18532. if m.addstatus != nil {
  18533. fields = append(fields, labeltagging.FieldStatus)
  18534. }
  18535. if m.addorganization_id != nil {
  18536. fields = append(fields, labeltagging.FieldOrganizationID)
  18537. }
  18538. if m.add_type != nil {
  18539. fields = append(fields, labeltagging.FieldType)
  18540. }
  18541. return fields
  18542. }
  18543. // AddedField returns the numeric value that was incremented/decremented on a field
  18544. // with the given name. The second boolean return value indicates that this field
  18545. // was not set, or was not defined in the schema.
  18546. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  18547. switch name {
  18548. case labeltagging.FieldStatus:
  18549. return m.AddedStatus()
  18550. case labeltagging.FieldOrganizationID:
  18551. return m.AddedOrganizationID()
  18552. case labeltagging.FieldType:
  18553. return m.AddedType()
  18554. }
  18555. return nil, false
  18556. }
  18557. // AddField adds the value to the field with the given name. It returns an error if
  18558. // the field is not defined in the schema, or if the type mismatched the field
  18559. // type.
  18560. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  18561. switch name {
  18562. case labeltagging.FieldStatus:
  18563. v, ok := value.(int8)
  18564. if !ok {
  18565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18566. }
  18567. m.AddStatus(v)
  18568. return nil
  18569. case labeltagging.FieldOrganizationID:
  18570. v, ok := value.(int64)
  18571. if !ok {
  18572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18573. }
  18574. m.AddOrganizationID(v)
  18575. return nil
  18576. case labeltagging.FieldType:
  18577. v, ok := value.(int)
  18578. if !ok {
  18579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18580. }
  18581. m.AddType(v)
  18582. return nil
  18583. }
  18584. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  18585. }
  18586. // ClearedFields returns all nullable fields that were cleared during this
  18587. // mutation.
  18588. func (m *LabelTaggingMutation) ClearedFields() []string {
  18589. var fields []string
  18590. if m.FieldCleared(labeltagging.FieldStatus) {
  18591. fields = append(fields, labeltagging.FieldStatus)
  18592. }
  18593. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  18594. fields = append(fields, labeltagging.FieldDeletedAt)
  18595. }
  18596. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  18597. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18598. }
  18599. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  18600. fields = append(fields, labeltagging.FieldActionLabelDel)
  18601. }
  18602. return fields
  18603. }
  18604. // FieldCleared returns a boolean indicating if a field with the given name was
  18605. // cleared in this mutation.
  18606. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  18607. _, ok := m.clearedFields[name]
  18608. return ok
  18609. }
  18610. // ClearField clears the value of the field with the given name. It returns an
  18611. // error if the field is not defined in the schema.
  18612. func (m *LabelTaggingMutation) ClearField(name string) error {
  18613. switch name {
  18614. case labeltagging.FieldStatus:
  18615. m.ClearStatus()
  18616. return nil
  18617. case labeltagging.FieldDeletedAt:
  18618. m.ClearDeletedAt()
  18619. return nil
  18620. case labeltagging.FieldActionLabelAdd:
  18621. m.ClearActionLabelAdd()
  18622. return nil
  18623. case labeltagging.FieldActionLabelDel:
  18624. m.ClearActionLabelDel()
  18625. return nil
  18626. }
  18627. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  18628. }
  18629. // ResetField resets all changes in the mutation for the field with the given name.
  18630. // It returns an error if the field is not defined in the schema.
  18631. func (m *LabelTaggingMutation) ResetField(name string) error {
  18632. switch name {
  18633. case labeltagging.FieldCreatedAt:
  18634. m.ResetCreatedAt()
  18635. return nil
  18636. case labeltagging.FieldUpdatedAt:
  18637. m.ResetUpdatedAt()
  18638. return nil
  18639. case labeltagging.FieldStatus:
  18640. m.ResetStatus()
  18641. return nil
  18642. case labeltagging.FieldDeletedAt:
  18643. m.ResetDeletedAt()
  18644. return nil
  18645. case labeltagging.FieldOrganizationID:
  18646. m.ResetOrganizationID()
  18647. return nil
  18648. case labeltagging.FieldType:
  18649. m.ResetType()
  18650. return nil
  18651. case labeltagging.FieldConditions:
  18652. m.ResetConditions()
  18653. return nil
  18654. case labeltagging.FieldActionLabelAdd:
  18655. m.ResetActionLabelAdd()
  18656. return nil
  18657. case labeltagging.FieldActionLabelDel:
  18658. m.ResetActionLabelDel()
  18659. return nil
  18660. }
  18661. return fmt.Errorf("unknown LabelTagging field %s", name)
  18662. }
  18663. // AddedEdges returns all edge names that were set/added in this mutation.
  18664. func (m *LabelTaggingMutation) AddedEdges() []string {
  18665. edges := make([]string, 0, 0)
  18666. return edges
  18667. }
  18668. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18669. // name in this mutation.
  18670. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  18671. return nil
  18672. }
  18673. // RemovedEdges returns all edge names that were removed in this mutation.
  18674. func (m *LabelTaggingMutation) RemovedEdges() []string {
  18675. edges := make([]string, 0, 0)
  18676. return edges
  18677. }
  18678. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18679. // the given name in this mutation.
  18680. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  18681. return nil
  18682. }
  18683. // ClearedEdges returns all edge names that were cleared in this mutation.
  18684. func (m *LabelTaggingMutation) ClearedEdges() []string {
  18685. edges := make([]string, 0, 0)
  18686. return edges
  18687. }
  18688. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18689. // was cleared in this mutation.
  18690. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  18691. return false
  18692. }
  18693. // ClearEdge clears the value of the edge with the given name. It returns an error
  18694. // if that edge is not defined in the schema.
  18695. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  18696. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  18697. }
  18698. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18699. // It returns an error if the edge is not defined in the schema.
  18700. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  18701. return fmt.Errorf("unknown LabelTagging edge %s", name)
  18702. }
  18703. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  18704. type MessageMutation struct {
  18705. config
  18706. op Op
  18707. typ string
  18708. id *int
  18709. wx_wxid *string
  18710. wxid *string
  18711. content *string
  18712. clearedFields map[string]struct{}
  18713. done bool
  18714. oldValue func(context.Context) (*Message, error)
  18715. predicates []predicate.Message
  18716. }
  18717. var _ ent.Mutation = (*MessageMutation)(nil)
  18718. // messageOption allows management of the mutation configuration using functional options.
  18719. type messageOption func(*MessageMutation)
  18720. // newMessageMutation creates new mutation for the Message entity.
  18721. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  18722. m := &MessageMutation{
  18723. config: c,
  18724. op: op,
  18725. typ: TypeMessage,
  18726. clearedFields: make(map[string]struct{}),
  18727. }
  18728. for _, opt := range opts {
  18729. opt(m)
  18730. }
  18731. return m
  18732. }
  18733. // withMessageID sets the ID field of the mutation.
  18734. func withMessageID(id int) messageOption {
  18735. return func(m *MessageMutation) {
  18736. var (
  18737. err error
  18738. once sync.Once
  18739. value *Message
  18740. )
  18741. m.oldValue = func(ctx context.Context) (*Message, error) {
  18742. once.Do(func() {
  18743. if m.done {
  18744. err = errors.New("querying old values post mutation is not allowed")
  18745. } else {
  18746. value, err = m.Client().Message.Get(ctx, id)
  18747. }
  18748. })
  18749. return value, err
  18750. }
  18751. m.id = &id
  18752. }
  18753. }
  18754. // withMessage sets the old Message of the mutation.
  18755. func withMessage(node *Message) messageOption {
  18756. return func(m *MessageMutation) {
  18757. m.oldValue = func(context.Context) (*Message, error) {
  18758. return node, nil
  18759. }
  18760. m.id = &node.ID
  18761. }
  18762. }
  18763. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18764. // executed in a transaction (ent.Tx), a transactional client is returned.
  18765. func (m MessageMutation) Client() *Client {
  18766. client := &Client{config: m.config}
  18767. client.init()
  18768. return client
  18769. }
  18770. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18771. // it returns an error otherwise.
  18772. func (m MessageMutation) Tx() (*Tx, error) {
  18773. if _, ok := m.driver.(*txDriver); !ok {
  18774. return nil, errors.New("ent: mutation is not running in a transaction")
  18775. }
  18776. tx := &Tx{config: m.config}
  18777. tx.init()
  18778. return tx, nil
  18779. }
  18780. // ID returns the ID value in the mutation. Note that the ID is only available
  18781. // if it was provided to the builder or after it was returned from the database.
  18782. func (m *MessageMutation) ID() (id int, exists bool) {
  18783. if m.id == nil {
  18784. return
  18785. }
  18786. return *m.id, true
  18787. }
  18788. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18789. // That means, if the mutation is applied within a transaction with an isolation level such
  18790. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18791. // or updated by the mutation.
  18792. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  18793. switch {
  18794. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18795. id, exists := m.ID()
  18796. if exists {
  18797. return []int{id}, nil
  18798. }
  18799. fallthrough
  18800. case m.op.Is(OpUpdate | OpDelete):
  18801. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  18802. default:
  18803. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18804. }
  18805. }
  18806. // SetWxWxid sets the "wx_wxid" field.
  18807. func (m *MessageMutation) SetWxWxid(s string) {
  18808. m.wx_wxid = &s
  18809. }
  18810. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  18811. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  18812. v := m.wx_wxid
  18813. if v == nil {
  18814. return
  18815. }
  18816. return *v, true
  18817. }
  18818. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  18819. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18821. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  18822. if !m.op.Is(OpUpdateOne) {
  18823. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  18824. }
  18825. if m.id == nil || m.oldValue == nil {
  18826. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  18827. }
  18828. oldValue, err := m.oldValue(ctx)
  18829. if err != nil {
  18830. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  18831. }
  18832. return oldValue.WxWxid, nil
  18833. }
  18834. // ClearWxWxid clears the value of the "wx_wxid" field.
  18835. func (m *MessageMutation) ClearWxWxid() {
  18836. m.wx_wxid = nil
  18837. m.clearedFields[message.FieldWxWxid] = struct{}{}
  18838. }
  18839. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  18840. func (m *MessageMutation) WxWxidCleared() bool {
  18841. _, ok := m.clearedFields[message.FieldWxWxid]
  18842. return ok
  18843. }
  18844. // ResetWxWxid resets all changes to the "wx_wxid" field.
  18845. func (m *MessageMutation) ResetWxWxid() {
  18846. m.wx_wxid = nil
  18847. delete(m.clearedFields, message.FieldWxWxid)
  18848. }
  18849. // SetWxid sets the "wxid" field.
  18850. func (m *MessageMutation) SetWxid(s string) {
  18851. m.wxid = &s
  18852. }
  18853. // Wxid returns the value of the "wxid" field in the mutation.
  18854. func (m *MessageMutation) Wxid() (r string, exists bool) {
  18855. v := m.wxid
  18856. if v == nil {
  18857. return
  18858. }
  18859. return *v, true
  18860. }
  18861. // OldWxid returns the old "wxid" field's value of the Message entity.
  18862. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18864. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  18865. if !m.op.Is(OpUpdateOne) {
  18866. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  18867. }
  18868. if m.id == nil || m.oldValue == nil {
  18869. return v, errors.New("OldWxid requires an ID field in the mutation")
  18870. }
  18871. oldValue, err := m.oldValue(ctx)
  18872. if err != nil {
  18873. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  18874. }
  18875. return oldValue.Wxid, nil
  18876. }
  18877. // ResetWxid resets all changes to the "wxid" field.
  18878. func (m *MessageMutation) ResetWxid() {
  18879. m.wxid = nil
  18880. }
  18881. // SetContent sets the "content" field.
  18882. func (m *MessageMutation) SetContent(s string) {
  18883. m.content = &s
  18884. }
  18885. // Content returns the value of the "content" field in the mutation.
  18886. func (m *MessageMutation) Content() (r string, exists bool) {
  18887. v := m.content
  18888. if v == nil {
  18889. return
  18890. }
  18891. return *v, true
  18892. }
  18893. // OldContent returns the old "content" field's value of the Message entity.
  18894. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18896. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  18897. if !m.op.Is(OpUpdateOne) {
  18898. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18899. }
  18900. if m.id == nil || m.oldValue == nil {
  18901. return v, errors.New("OldContent requires an ID field in the mutation")
  18902. }
  18903. oldValue, err := m.oldValue(ctx)
  18904. if err != nil {
  18905. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18906. }
  18907. return oldValue.Content, nil
  18908. }
  18909. // ResetContent resets all changes to the "content" field.
  18910. func (m *MessageMutation) ResetContent() {
  18911. m.content = nil
  18912. }
  18913. // Where appends a list predicates to the MessageMutation builder.
  18914. func (m *MessageMutation) Where(ps ...predicate.Message) {
  18915. m.predicates = append(m.predicates, ps...)
  18916. }
  18917. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  18918. // users can use type-assertion to append predicates that do not depend on any generated package.
  18919. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  18920. p := make([]predicate.Message, len(ps))
  18921. for i := range ps {
  18922. p[i] = ps[i]
  18923. }
  18924. m.Where(p...)
  18925. }
  18926. // Op returns the operation name.
  18927. func (m *MessageMutation) Op() Op {
  18928. return m.op
  18929. }
  18930. // SetOp allows setting the mutation operation.
  18931. func (m *MessageMutation) SetOp(op Op) {
  18932. m.op = op
  18933. }
  18934. // Type returns the node type of this mutation (Message).
  18935. func (m *MessageMutation) Type() string {
  18936. return m.typ
  18937. }
  18938. // Fields returns all fields that were changed during this mutation. Note that in
  18939. // order to get all numeric fields that were incremented/decremented, call
  18940. // AddedFields().
  18941. func (m *MessageMutation) Fields() []string {
  18942. fields := make([]string, 0, 3)
  18943. if m.wx_wxid != nil {
  18944. fields = append(fields, message.FieldWxWxid)
  18945. }
  18946. if m.wxid != nil {
  18947. fields = append(fields, message.FieldWxid)
  18948. }
  18949. if m.content != nil {
  18950. fields = append(fields, message.FieldContent)
  18951. }
  18952. return fields
  18953. }
  18954. // Field returns the value of a field with the given name. The second boolean
  18955. // return value indicates that this field was not set, or was not defined in the
  18956. // schema.
  18957. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  18958. switch name {
  18959. case message.FieldWxWxid:
  18960. return m.WxWxid()
  18961. case message.FieldWxid:
  18962. return m.Wxid()
  18963. case message.FieldContent:
  18964. return m.Content()
  18965. }
  18966. return nil, false
  18967. }
  18968. // OldField returns the old value of the field from the database. An error is
  18969. // returned if the mutation operation is not UpdateOne, or the query to the
  18970. // database failed.
  18971. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18972. switch name {
  18973. case message.FieldWxWxid:
  18974. return m.OldWxWxid(ctx)
  18975. case message.FieldWxid:
  18976. return m.OldWxid(ctx)
  18977. case message.FieldContent:
  18978. return m.OldContent(ctx)
  18979. }
  18980. return nil, fmt.Errorf("unknown Message field %s", name)
  18981. }
  18982. // SetField sets the value of a field with the given name. It returns an error if
  18983. // the field is not defined in the schema, or if the type mismatched the field
  18984. // type.
  18985. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  18986. switch name {
  18987. case message.FieldWxWxid:
  18988. v, ok := value.(string)
  18989. if !ok {
  18990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18991. }
  18992. m.SetWxWxid(v)
  18993. return nil
  18994. case message.FieldWxid:
  18995. v, ok := value.(string)
  18996. if !ok {
  18997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18998. }
  18999. m.SetWxid(v)
  19000. return nil
  19001. case message.FieldContent:
  19002. v, ok := value.(string)
  19003. if !ok {
  19004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19005. }
  19006. m.SetContent(v)
  19007. return nil
  19008. }
  19009. return fmt.Errorf("unknown Message field %s", name)
  19010. }
  19011. // AddedFields returns all numeric fields that were incremented/decremented during
  19012. // this mutation.
  19013. func (m *MessageMutation) AddedFields() []string {
  19014. return nil
  19015. }
  19016. // AddedField returns the numeric value that was incremented/decremented on a field
  19017. // with the given name. The second boolean return value indicates that this field
  19018. // was not set, or was not defined in the schema.
  19019. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  19020. return nil, false
  19021. }
  19022. // AddField adds the value to the field with the given name. It returns an error if
  19023. // the field is not defined in the schema, or if the type mismatched the field
  19024. // type.
  19025. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  19026. switch name {
  19027. }
  19028. return fmt.Errorf("unknown Message numeric field %s", name)
  19029. }
  19030. // ClearedFields returns all nullable fields that were cleared during this
  19031. // mutation.
  19032. func (m *MessageMutation) ClearedFields() []string {
  19033. var fields []string
  19034. if m.FieldCleared(message.FieldWxWxid) {
  19035. fields = append(fields, message.FieldWxWxid)
  19036. }
  19037. return fields
  19038. }
  19039. // FieldCleared returns a boolean indicating if a field with the given name was
  19040. // cleared in this mutation.
  19041. func (m *MessageMutation) FieldCleared(name string) bool {
  19042. _, ok := m.clearedFields[name]
  19043. return ok
  19044. }
  19045. // ClearField clears the value of the field with the given name. It returns an
  19046. // error if the field is not defined in the schema.
  19047. func (m *MessageMutation) ClearField(name string) error {
  19048. switch name {
  19049. case message.FieldWxWxid:
  19050. m.ClearWxWxid()
  19051. return nil
  19052. }
  19053. return fmt.Errorf("unknown Message nullable field %s", name)
  19054. }
  19055. // ResetField resets all changes in the mutation for the field with the given name.
  19056. // It returns an error if the field is not defined in the schema.
  19057. func (m *MessageMutation) ResetField(name string) error {
  19058. switch name {
  19059. case message.FieldWxWxid:
  19060. m.ResetWxWxid()
  19061. return nil
  19062. case message.FieldWxid:
  19063. m.ResetWxid()
  19064. return nil
  19065. case message.FieldContent:
  19066. m.ResetContent()
  19067. return nil
  19068. }
  19069. return fmt.Errorf("unknown Message field %s", name)
  19070. }
  19071. // AddedEdges returns all edge names that were set/added in this mutation.
  19072. func (m *MessageMutation) AddedEdges() []string {
  19073. edges := make([]string, 0, 0)
  19074. return edges
  19075. }
  19076. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19077. // name in this mutation.
  19078. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  19079. return nil
  19080. }
  19081. // RemovedEdges returns all edge names that were removed in this mutation.
  19082. func (m *MessageMutation) RemovedEdges() []string {
  19083. edges := make([]string, 0, 0)
  19084. return edges
  19085. }
  19086. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19087. // the given name in this mutation.
  19088. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  19089. return nil
  19090. }
  19091. // ClearedEdges returns all edge names that were cleared in this mutation.
  19092. func (m *MessageMutation) ClearedEdges() []string {
  19093. edges := make([]string, 0, 0)
  19094. return edges
  19095. }
  19096. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19097. // was cleared in this mutation.
  19098. func (m *MessageMutation) EdgeCleared(name string) bool {
  19099. return false
  19100. }
  19101. // ClearEdge clears the value of the edge with the given name. It returns an error
  19102. // if that edge is not defined in the schema.
  19103. func (m *MessageMutation) ClearEdge(name string) error {
  19104. return fmt.Errorf("unknown Message unique edge %s", name)
  19105. }
  19106. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19107. // It returns an error if the edge is not defined in the schema.
  19108. func (m *MessageMutation) ResetEdge(name string) error {
  19109. return fmt.Errorf("unknown Message edge %s", name)
  19110. }
  19111. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  19112. type MessageRecordsMutation struct {
  19113. config
  19114. op Op
  19115. typ string
  19116. id *uint64
  19117. created_at *time.Time
  19118. updated_at *time.Time
  19119. status *uint8
  19120. addstatus *int8
  19121. bot_wxid *string
  19122. contact_type *int
  19123. addcontact_type *int
  19124. contact_wxid *string
  19125. content_type *int
  19126. addcontent_type *int
  19127. content *string
  19128. meta *custom_types.Meta
  19129. error_detail *string
  19130. send_time *time.Time
  19131. source_type *int
  19132. addsource_type *int
  19133. organization_id *uint64
  19134. addorganization_id *int64
  19135. clearedFields map[string]struct{}
  19136. sop_stage *uint64
  19137. clearedsop_stage bool
  19138. sop_node *uint64
  19139. clearedsop_node bool
  19140. message_contact *uint64
  19141. clearedmessage_contact bool
  19142. done bool
  19143. oldValue func(context.Context) (*MessageRecords, error)
  19144. predicates []predicate.MessageRecords
  19145. }
  19146. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  19147. // messagerecordsOption allows management of the mutation configuration using functional options.
  19148. type messagerecordsOption func(*MessageRecordsMutation)
  19149. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  19150. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  19151. m := &MessageRecordsMutation{
  19152. config: c,
  19153. op: op,
  19154. typ: TypeMessageRecords,
  19155. clearedFields: make(map[string]struct{}),
  19156. }
  19157. for _, opt := range opts {
  19158. opt(m)
  19159. }
  19160. return m
  19161. }
  19162. // withMessageRecordsID sets the ID field of the mutation.
  19163. func withMessageRecordsID(id uint64) messagerecordsOption {
  19164. return func(m *MessageRecordsMutation) {
  19165. var (
  19166. err error
  19167. once sync.Once
  19168. value *MessageRecords
  19169. )
  19170. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  19171. once.Do(func() {
  19172. if m.done {
  19173. err = errors.New("querying old values post mutation is not allowed")
  19174. } else {
  19175. value, err = m.Client().MessageRecords.Get(ctx, id)
  19176. }
  19177. })
  19178. return value, err
  19179. }
  19180. m.id = &id
  19181. }
  19182. }
  19183. // withMessageRecords sets the old MessageRecords of the mutation.
  19184. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  19185. return func(m *MessageRecordsMutation) {
  19186. m.oldValue = func(context.Context) (*MessageRecords, error) {
  19187. return node, nil
  19188. }
  19189. m.id = &node.ID
  19190. }
  19191. }
  19192. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19193. // executed in a transaction (ent.Tx), a transactional client is returned.
  19194. func (m MessageRecordsMutation) Client() *Client {
  19195. client := &Client{config: m.config}
  19196. client.init()
  19197. return client
  19198. }
  19199. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19200. // it returns an error otherwise.
  19201. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  19202. if _, ok := m.driver.(*txDriver); !ok {
  19203. return nil, errors.New("ent: mutation is not running in a transaction")
  19204. }
  19205. tx := &Tx{config: m.config}
  19206. tx.init()
  19207. return tx, nil
  19208. }
  19209. // SetID sets the value of the id field. Note that this
  19210. // operation is only accepted on creation of MessageRecords entities.
  19211. func (m *MessageRecordsMutation) SetID(id uint64) {
  19212. m.id = &id
  19213. }
  19214. // ID returns the ID value in the mutation. Note that the ID is only available
  19215. // if it was provided to the builder or after it was returned from the database.
  19216. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  19217. if m.id == nil {
  19218. return
  19219. }
  19220. return *m.id, true
  19221. }
  19222. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19223. // That means, if the mutation is applied within a transaction with an isolation level such
  19224. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19225. // or updated by the mutation.
  19226. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  19227. switch {
  19228. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19229. id, exists := m.ID()
  19230. if exists {
  19231. return []uint64{id}, nil
  19232. }
  19233. fallthrough
  19234. case m.op.Is(OpUpdate | OpDelete):
  19235. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  19236. default:
  19237. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19238. }
  19239. }
  19240. // SetCreatedAt sets the "created_at" field.
  19241. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  19242. m.created_at = &t
  19243. }
  19244. // CreatedAt returns the value of the "created_at" field in the mutation.
  19245. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  19246. v := m.created_at
  19247. if v == nil {
  19248. return
  19249. }
  19250. return *v, true
  19251. }
  19252. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  19253. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19255. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19256. if !m.op.Is(OpUpdateOne) {
  19257. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19258. }
  19259. if m.id == nil || m.oldValue == nil {
  19260. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19261. }
  19262. oldValue, err := m.oldValue(ctx)
  19263. if err != nil {
  19264. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19265. }
  19266. return oldValue.CreatedAt, nil
  19267. }
  19268. // ResetCreatedAt resets all changes to the "created_at" field.
  19269. func (m *MessageRecordsMutation) ResetCreatedAt() {
  19270. m.created_at = nil
  19271. }
  19272. // SetUpdatedAt sets the "updated_at" field.
  19273. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  19274. m.updated_at = &t
  19275. }
  19276. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19277. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  19278. v := m.updated_at
  19279. if v == nil {
  19280. return
  19281. }
  19282. return *v, true
  19283. }
  19284. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  19285. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19287. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19288. if !m.op.Is(OpUpdateOne) {
  19289. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19290. }
  19291. if m.id == nil || m.oldValue == nil {
  19292. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19293. }
  19294. oldValue, err := m.oldValue(ctx)
  19295. if err != nil {
  19296. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19297. }
  19298. return oldValue.UpdatedAt, nil
  19299. }
  19300. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19301. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  19302. m.updated_at = nil
  19303. }
  19304. // SetStatus sets the "status" field.
  19305. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  19306. m.status = &u
  19307. m.addstatus = nil
  19308. }
  19309. // Status returns the value of the "status" field in the mutation.
  19310. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  19311. v := m.status
  19312. if v == nil {
  19313. return
  19314. }
  19315. return *v, true
  19316. }
  19317. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  19318. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19320. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19321. if !m.op.Is(OpUpdateOne) {
  19322. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19323. }
  19324. if m.id == nil || m.oldValue == nil {
  19325. return v, errors.New("OldStatus requires an ID field in the mutation")
  19326. }
  19327. oldValue, err := m.oldValue(ctx)
  19328. if err != nil {
  19329. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19330. }
  19331. return oldValue.Status, nil
  19332. }
  19333. // AddStatus adds u to the "status" field.
  19334. func (m *MessageRecordsMutation) AddStatus(u int8) {
  19335. if m.addstatus != nil {
  19336. *m.addstatus += u
  19337. } else {
  19338. m.addstatus = &u
  19339. }
  19340. }
  19341. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19342. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  19343. v := m.addstatus
  19344. if v == nil {
  19345. return
  19346. }
  19347. return *v, true
  19348. }
  19349. // ClearStatus clears the value of the "status" field.
  19350. func (m *MessageRecordsMutation) ClearStatus() {
  19351. m.status = nil
  19352. m.addstatus = nil
  19353. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  19354. }
  19355. // StatusCleared returns if the "status" field was cleared in this mutation.
  19356. func (m *MessageRecordsMutation) StatusCleared() bool {
  19357. _, ok := m.clearedFields[messagerecords.FieldStatus]
  19358. return ok
  19359. }
  19360. // ResetStatus resets all changes to the "status" field.
  19361. func (m *MessageRecordsMutation) ResetStatus() {
  19362. m.status = nil
  19363. m.addstatus = nil
  19364. delete(m.clearedFields, messagerecords.FieldStatus)
  19365. }
  19366. // SetBotWxid sets the "bot_wxid" field.
  19367. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  19368. m.bot_wxid = &s
  19369. }
  19370. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  19371. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  19372. v := m.bot_wxid
  19373. if v == nil {
  19374. return
  19375. }
  19376. return *v, true
  19377. }
  19378. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  19379. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19381. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  19382. if !m.op.Is(OpUpdateOne) {
  19383. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  19384. }
  19385. if m.id == nil || m.oldValue == nil {
  19386. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  19387. }
  19388. oldValue, err := m.oldValue(ctx)
  19389. if err != nil {
  19390. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  19391. }
  19392. return oldValue.BotWxid, nil
  19393. }
  19394. // ResetBotWxid resets all changes to the "bot_wxid" field.
  19395. func (m *MessageRecordsMutation) ResetBotWxid() {
  19396. m.bot_wxid = nil
  19397. }
  19398. // SetContactID sets the "contact_id" field.
  19399. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  19400. m.message_contact = &u
  19401. }
  19402. // ContactID returns the value of the "contact_id" field in the mutation.
  19403. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  19404. v := m.message_contact
  19405. if v == nil {
  19406. return
  19407. }
  19408. return *v, true
  19409. }
  19410. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  19411. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19413. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  19414. if !m.op.Is(OpUpdateOne) {
  19415. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  19416. }
  19417. if m.id == nil || m.oldValue == nil {
  19418. return v, errors.New("OldContactID requires an ID field in the mutation")
  19419. }
  19420. oldValue, err := m.oldValue(ctx)
  19421. if err != nil {
  19422. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  19423. }
  19424. return oldValue.ContactID, nil
  19425. }
  19426. // ClearContactID clears the value of the "contact_id" field.
  19427. func (m *MessageRecordsMutation) ClearContactID() {
  19428. m.message_contact = nil
  19429. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19430. }
  19431. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  19432. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  19433. _, ok := m.clearedFields[messagerecords.FieldContactID]
  19434. return ok
  19435. }
  19436. // ResetContactID resets all changes to the "contact_id" field.
  19437. func (m *MessageRecordsMutation) ResetContactID() {
  19438. m.message_contact = nil
  19439. delete(m.clearedFields, messagerecords.FieldContactID)
  19440. }
  19441. // SetContactType sets the "contact_type" field.
  19442. func (m *MessageRecordsMutation) SetContactType(i int) {
  19443. m.contact_type = &i
  19444. m.addcontact_type = nil
  19445. }
  19446. // ContactType returns the value of the "contact_type" field in the mutation.
  19447. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  19448. v := m.contact_type
  19449. if v == nil {
  19450. return
  19451. }
  19452. return *v, true
  19453. }
  19454. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  19455. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19457. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  19458. if !m.op.Is(OpUpdateOne) {
  19459. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  19460. }
  19461. if m.id == nil || m.oldValue == nil {
  19462. return v, errors.New("OldContactType requires an ID field in the mutation")
  19463. }
  19464. oldValue, err := m.oldValue(ctx)
  19465. if err != nil {
  19466. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  19467. }
  19468. return oldValue.ContactType, nil
  19469. }
  19470. // AddContactType adds i to the "contact_type" field.
  19471. func (m *MessageRecordsMutation) AddContactType(i int) {
  19472. if m.addcontact_type != nil {
  19473. *m.addcontact_type += i
  19474. } else {
  19475. m.addcontact_type = &i
  19476. }
  19477. }
  19478. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  19479. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  19480. v := m.addcontact_type
  19481. if v == nil {
  19482. return
  19483. }
  19484. return *v, true
  19485. }
  19486. // ResetContactType resets all changes to the "contact_type" field.
  19487. func (m *MessageRecordsMutation) ResetContactType() {
  19488. m.contact_type = nil
  19489. m.addcontact_type = nil
  19490. }
  19491. // SetContactWxid sets the "contact_wxid" field.
  19492. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  19493. m.contact_wxid = &s
  19494. }
  19495. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  19496. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  19497. v := m.contact_wxid
  19498. if v == nil {
  19499. return
  19500. }
  19501. return *v, true
  19502. }
  19503. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  19504. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19506. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  19507. if !m.op.Is(OpUpdateOne) {
  19508. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  19509. }
  19510. if m.id == nil || m.oldValue == nil {
  19511. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  19512. }
  19513. oldValue, err := m.oldValue(ctx)
  19514. if err != nil {
  19515. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  19516. }
  19517. return oldValue.ContactWxid, nil
  19518. }
  19519. // ResetContactWxid resets all changes to the "contact_wxid" field.
  19520. func (m *MessageRecordsMutation) ResetContactWxid() {
  19521. m.contact_wxid = nil
  19522. }
  19523. // SetContentType sets the "content_type" field.
  19524. func (m *MessageRecordsMutation) SetContentType(i int) {
  19525. m.content_type = &i
  19526. m.addcontent_type = nil
  19527. }
  19528. // ContentType returns the value of the "content_type" field in the mutation.
  19529. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  19530. v := m.content_type
  19531. if v == nil {
  19532. return
  19533. }
  19534. return *v, true
  19535. }
  19536. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  19537. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19539. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  19540. if !m.op.Is(OpUpdateOne) {
  19541. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  19542. }
  19543. if m.id == nil || m.oldValue == nil {
  19544. return v, errors.New("OldContentType requires an ID field in the mutation")
  19545. }
  19546. oldValue, err := m.oldValue(ctx)
  19547. if err != nil {
  19548. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  19549. }
  19550. return oldValue.ContentType, nil
  19551. }
  19552. // AddContentType adds i to the "content_type" field.
  19553. func (m *MessageRecordsMutation) AddContentType(i int) {
  19554. if m.addcontent_type != nil {
  19555. *m.addcontent_type += i
  19556. } else {
  19557. m.addcontent_type = &i
  19558. }
  19559. }
  19560. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  19561. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  19562. v := m.addcontent_type
  19563. if v == nil {
  19564. return
  19565. }
  19566. return *v, true
  19567. }
  19568. // ResetContentType resets all changes to the "content_type" field.
  19569. func (m *MessageRecordsMutation) ResetContentType() {
  19570. m.content_type = nil
  19571. m.addcontent_type = nil
  19572. }
  19573. // SetContent sets the "content" field.
  19574. func (m *MessageRecordsMutation) SetContent(s string) {
  19575. m.content = &s
  19576. }
  19577. // Content returns the value of the "content" field in the mutation.
  19578. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  19579. v := m.content
  19580. if v == nil {
  19581. return
  19582. }
  19583. return *v, true
  19584. }
  19585. // OldContent returns the old "content" field's value of the MessageRecords entity.
  19586. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19588. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  19589. if !m.op.Is(OpUpdateOne) {
  19590. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  19591. }
  19592. if m.id == nil || m.oldValue == nil {
  19593. return v, errors.New("OldContent requires an ID field in the mutation")
  19594. }
  19595. oldValue, err := m.oldValue(ctx)
  19596. if err != nil {
  19597. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  19598. }
  19599. return oldValue.Content, nil
  19600. }
  19601. // ResetContent resets all changes to the "content" field.
  19602. func (m *MessageRecordsMutation) ResetContent() {
  19603. m.content = nil
  19604. }
  19605. // SetMeta sets the "meta" field.
  19606. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  19607. m.meta = &ct
  19608. }
  19609. // Meta returns the value of the "meta" field in the mutation.
  19610. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  19611. v := m.meta
  19612. if v == nil {
  19613. return
  19614. }
  19615. return *v, true
  19616. }
  19617. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  19618. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19620. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  19621. if !m.op.Is(OpUpdateOne) {
  19622. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  19623. }
  19624. if m.id == nil || m.oldValue == nil {
  19625. return v, errors.New("OldMeta requires an ID field in the mutation")
  19626. }
  19627. oldValue, err := m.oldValue(ctx)
  19628. if err != nil {
  19629. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  19630. }
  19631. return oldValue.Meta, nil
  19632. }
  19633. // ClearMeta clears the value of the "meta" field.
  19634. func (m *MessageRecordsMutation) ClearMeta() {
  19635. m.meta = nil
  19636. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  19637. }
  19638. // MetaCleared returns if the "meta" field was cleared in this mutation.
  19639. func (m *MessageRecordsMutation) MetaCleared() bool {
  19640. _, ok := m.clearedFields[messagerecords.FieldMeta]
  19641. return ok
  19642. }
  19643. // ResetMeta resets all changes to the "meta" field.
  19644. func (m *MessageRecordsMutation) ResetMeta() {
  19645. m.meta = nil
  19646. delete(m.clearedFields, messagerecords.FieldMeta)
  19647. }
  19648. // SetErrorDetail sets the "error_detail" field.
  19649. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  19650. m.error_detail = &s
  19651. }
  19652. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  19653. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  19654. v := m.error_detail
  19655. if v == nil {
  19656. return
  19657. }
  19658. return *v, true
  19659. }
  19660. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  19661. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19663. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  19664. if !m.op.Is(OpUpdateOne) {
  19665. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  19666. }
  19667. if m.id == nil || m.oldValue == nil {
  19668. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  19669. }
  19670. oldValue, err := m.oldValue(ctx)
  19671. if err != nil {
  19672. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  19673. }
  19674. return oldValue.ErrorDetail, nil
  19675. }
  19676. // ResetErrorDetail resets all changes to the "error_detail" field.
  19677. func (m *MessageRecordsMutation) ResetErrorDetail() {
  19678. m.error_detail = nil
  19679. }
  19680. // SetSendTime sets the "send_time" field.
  19681. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  19682. m.send_time = &t
  19683. }
  19684. // SendTime returns the value of the "send_time" field in the mutation.
  19685. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  19686. v := m.send_time
  19687. if v == nil {
  19688. return
  19689. }
  19690. return *v, true
  19691. }
  19692. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  19693. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19695. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  19696. if !m.op.Is(OpUpdateOne) {
  19697. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  19698. }
  19699. if m.id == nil || m.oldValue == nil {
  19700. return v, errors.New("OldSendTime requires an ID field in the mutation")
  19701. }
  19702. oldValue, err := m.oldValue(ctx)
  19703. if err != nil {
  19704. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  19705. }
  19706. return oldValue.SendTime, nil
  19707. }
  19708. // ClearSendTime clears the value of the "send_time" field.
  19709. func (m *MessageRecordsMutation) ClearSendTime() {
  19710. m.send_time = nil
  19711. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  19712. }
  19713. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  19714. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  19715. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  19716. return ok
  19717. }
  19718. // ResetSendTime resets all changes to the "send_time" field.
  19719. func (m *MessageRecordsMutation) ResetSendTime() {
  19720. m.send_time = nil
  19721. delete(m.clearedFields, messagerecords.FieldSendTime)
  19722. }
  19723. // SetSourceType sets the "source_type" field.
  19724. func (m *MessageRecordsMutation) SetSourceType(i int) {
  19725. m.source_type = &i
  19726. m.addsource_type = nil
  19727. }
  19728. // SourceType returns the value of the "source_type" field in the mutation.
  19729. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  19730. v := m.source_type
  19731. if v == nil {
  19732. return
  19733. }
  19734. return *v, true
  19735. }
  19736. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  19737. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19739. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  19740. if !m.op.Is(OpUpdateOne) {
  19741. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  19742. }
  19743. if m.id == nil || m.oldValue == nil {
  19744. return v, errors.New("OldSourceType requires an ID field in the mutation")
  19745. }
  19746. oldValue, err := m.oldValue(ctx)
  19747. if err != nil {
  19748. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  19749. }
  19750. return oldValue.SourceType, nil
  19751. }
  19752. // AddSourceType adds i to the "source_type" field.
  19753. func (m *MessageRecordsMutation) AddSourceType(i int) {
  19754. if m.addsource_type != nil {
  19755. *m.addsource_type += i
  19756. } else {
  19757. m.addsource_type = &i
  19758. }
  19759. }
  19760. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  19761. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  19762. v := m.addsource_type
  19763. if v == nil {
  19764. return
  19765. }
  19766. return *v, true
  19767. }
  19768. // ResetSourceType resets all changes to the "source_type" field.
  19769. func (m *MessageRecordsMutation) ResetSourceType() {
  19770. m.source_type = nil
  19771. m.addsource_type = nil
  19772. }
  19773. // SetSourceID sets the "source_id" field.
  19774. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  19775. m.sop_stage = &u
  19776. }
  19777. // SourceID returns the value of the "source_id" field in the mutation.
  19778. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  19779. v := m.sop_stage
  19780. if v == nil {
  19781. return
  19782. }
  19783. return *v, true
  19784. }
  19785. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  19786. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19788. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  19789. if !m.op.Is(OpUpdateOne) {
  19790. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  19791. }
  19792. if m.id == nil || m.oldValue == nil {
  19793. return v, errors.New("OldSourceID requires an ID field in the mutation")
  19794. }
  19795. oldValue, err := m.oldValue(ctx)
  19796. if err != nil {
  19797. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  19798. }
  19799. return oldValue.SourceID, nil
  19800. }
  19801. // ClearSourceID clears the value of the "source_id" field.
  19802. func (m *MessageRecordsMutation) ClearSourceID() {
  19803. m.sop_stage = nil
  19804. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19805. }
  19806. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  19807. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  19808. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  19809. return ok
  19810. }
  19811. // ResetSourceID resets all changes to the "source_id" field.
  19812. func (m *MessageRecordsMutation) ResetSourceID() {
  19813. m.sop_stage = nil
  19814. delete(m.clearedFields, messagerecords.FieldSourceID)
  19815. }
  19816. // SetSubSourceID sets the "sub_source_id" field.
  19817. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  19818. m.sop_node = &u
  19819. }
  19820. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  19821. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  19822. v := m.sop_node
  19823. if v == nil {
  19824. return
  19825. }
  19826. return *v, true
  19827. }
  19828. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  19829. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19831. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  19832. if !m.op.Is(OpUpdateOne) {
  19833. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  19834. }
  19835. if m.id == nil || m.oldValue == nil {
  19836. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  19837. }
  19838. oldValue, err := m.oldValue(ctx)
  19839. if err != nil {
  19840. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  19841. }
  19842. return oldValue.SubSourceID, nil
  19843. }
  19844. // ClearSubSourceID clears the value of the "sub_source_id" field.
  19845. func (m *MessageRecordsMutation) ClearSubSourceID() {
  19846. m.sop_node = nil
  19847. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19848. }
  19849. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  19850. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  19851. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  19852. return ok
  19853. }
  19854. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  19855. func (m *MessageRecordsMutation) ResetSubSourceID() {
  19856. m.sop_node = nil
  19857. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  19858. }
  19859. // SetOrganizationID sets the "organization_id" field.
  19860. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  19861. m.organization_id = &u
  19862. m.addorganization_id = nil
  19863. }
  19864. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19865. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  19866. v := m.organization_id
  19867. if v == nil {
  19868. return
  19869. }
  19870. return *v, true
  19871. }
  19872. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  19873. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19875. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19876. if !m.op.Is(OpUpdateOne) {
  19877. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19878. }
  19879. if m.id == nil || m.oldValue == nil {
  19880. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19881. }
  19882. oldValue, err := m.oldValue(ctx)
  19883. if err != nil {
  19884. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19885. }
  19886. return oldValue.OrganizationID, nil
  19887. }
  19888. // AddOrganizationID adds u to the "organization_id" field.
  19889. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  19890. if m.addorganization_id != nil {
  19891. *m.addorganization_id += u
  19892. } else {
  19893. m.addorganization_id = &u
  19894. }
  19895. }
  19896. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19897. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  19898. v := m.addorganization_id
  19899. if v == nil {
  19900. return
  19901. }
  19902. return *v, true
  19903. }
  19904. // ClearOrganizationID clears the value of the "organization_id" field.
  19905. func (m *MessageRecordsMutation) ClearOrganizationID() {
  19906. m.organization_id = nil
  19907. m.addorganization_id = nil
  19908. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  19909. }
  19910. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19911. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  19912. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  19913. return ok
  19914. }
  19915. // ResetOrganizationID resets all changes to the "organization_id" field.
  19916. func (m *MessageRecordsMutation) ResetOrganizationID() {
  19917. m.organization_id = nil
  19918. m.addorganization_id = nil
  19919. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  19920. }
  19921. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  19922. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  19923. m.sop_stage = &id
  19924. }
  19925. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  19926. func (m *MessageRecordsMutation) ClearSopStage() {
  19927. m.clearedsop_stage = true
  19928. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19929. }
  19930. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  19931. func (m *MessageRecordsMutation) SopStageCleared() bool {
  19932. return m.SourceIDCleared() || m.clearedsop_stage
  19933. }
  19934. // SopStageID returns the "sop_stage" edge ID in the mutation.
  19935. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  19936. if m.sop_stage != nil {
  19937. return *m.sop_stage, true
  19938. }
  19939. return
  19940. }
  19941. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  19942. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19943. // SopStageID instead. It exists only for internal usage by the builders.
  19944. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  19945. if id := m.sop_stage; id != nil {
  19946. ids = append(ids, *id)
  19947. }
  19948. return
  19949. }
  19950. // ResetSopStage resets all changes to the "sop_stage" edge.
  19951. func (m *MessageRecordsMutation) ResetSopStage() {
  19952. m.sop_stage = nil
  19953. m.clearedsop_stage = false
  19954. }
  19955. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  19956. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  19957. m.sop_node = &id
  19958. }
  19959. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  19960. func (m *MessageRecordsMutation) ClearSopNode() {
  19961. m.clearedsop_node = true
  19962. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19963. }
  19964. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  19965. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  19966. return m.SubSourceIDCleared() || m.clearedsop_node
  19967. }
  19968. // SopNodeID returns the "sop_node" edge ID in the mutation.
  19969. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  19970. if m.sop_node != nil {
  19971. return *m.sop_node, true
  19972. }
  19973. return
  19974. }
  19975. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  19976. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19977. // SopNodeID instead. It exists only for internal usage by the builders.
  19978. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  19979. if id := m.sop_node; id != nil {
  19980. ids = append(ids, *id)
  19981. }
  19982. return
  19983. }
  19984. // ResetSopNode resets all changes to the "sop_node" edge.
  19985. func (m *MessageRecordsMutation) ResetSopNode() {
  19986. m.sop_node = nil
  19987. m.clearedsop_node = false
  19988. }
  19989. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  19990. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  19991. m.message_contact = &id
  19992. }
  19993. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  19994. func (m *MessageRecordsMutation) ClearMessageContact() {
  19995. m.clearedmessage_contact = true
  19996. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19997. }
  19998. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  19999. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  20000. return m.ContactIDCleared() || m.clearedmessage_contact
  20001. }
  20002. // MessageContactID returns the "message_contact" edge ID in the mutation.
  20003. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  20004. if m.message_contact != nil {
  20005. return *m.message_contact, true
  20006. }
  20007. return
  20008. }
  20009. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  20010. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20011. // MessageContactID instead. It exists only for internal usage by the builders.
  20012. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  20013. if id := m.message_contact; id != nil {
  20014. ids = append(ids, *id)
  20015. }
  20016. return
  20017. }
  20018. // ResetMessageContact resets all changes to the "message_contact" edge.
  20019. func (m *MessageRecordsMutation) ResetMessageContact() {
  20020. m.message_contact = nil
  20021. m.clearedmessage_contact = false
  20022. }
  20023. // Where appends a list predicates to the MessageRecordsMutation builder.
  20024. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  20025. m.predicates = append(m.predicates, ps...)
  20026. }
  20027. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  20028. // users can use type-assertion to append predicates that do not depend on any generated package.
  20029. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  20030. p := make([]predicate.MessageRecords, len(ps))
  20031. for i := range ps {
  20032. p[i] = ps[i]
  20033. }
  20034. m.Where(p...)
  20035. }
  20036. // Op returns the operation name.
  20037. func (m *MessageRecordsMutation) Op() Op {
  20038. return m.op
  20039. }
  20040. // SetOp allows setting the mutation operation.
  20041. func (m *MessageRecordsMutation) SetOp(op Op) {
  20042. m.op = op
  20043. }
  20044. // Type returns the node type of this mutation (MessageRecords).
  20045. func (m *MessageRecordsMutation) Type() string {
  20046. return m.typ
  20047. }
  20048. // Fields returns all fields that were changed during this mutation. Note that in
  20049. // order to get all numeric fields that were incremented/decremented, call
  20050. // AddedFields().
  20051. func (m *MessageRecordsMutation) Fields() []string {
  20052. fields := make([]string, 0, 16)
  20053. if m.created_at != nil {
  20054. fields = append(fields, messagerecords.FieldCreatedAt)
  20055. }
  20056. if m.updated_at != nil {
  20057. fields = append(fields, messagerecords.FieldUpdatedAt)
  20058. }
  20059. if m.status != nil {
  20060. fields = append(fields, messagerecords.FieldStatus)
  20061. }
  20062. if m.bot_wxid != nil {
  20063. fields = append(fields, messagerecords.FieldBotWxid)
  20064. }
  20065. if m.message_contact != nil {
  20066. fields = append(fields, messagerecords.FieldContactID)
  20067. }
  20068. if m.contact_type != nil {
  20069. fields = append(fields, messagerecords.FieldContactType)
  20070. }
  20071. if m.contact_wxid != nil {
  20072. fields = append(fields, messagerecords.FieldContactWxid)
  20073. }
  20074. if m.content_type != nil {
  20075. fields = append(fields, messagerecords.FieldContentType)
  20076. }
  20077. if m.content != nil {
  20078. fields = append(fields, messagerecords.FieldContent)
  20079. }
  20080. if m.meta != nil {
  20081. fields = append(fields, messagerecords.FieldMeta)
  20082. }
  20083. if m.error_detail != nil {
  20084. fields = append(fields, messagerecords.FieldErrorDetail)
  20085. }
  20086. if m.send_time != nil {
  20087. fields = append(fields, messagerecords.FieldSendTime)
  20088. }
  20089. if m.source_type != nil {
  20090. fields = append(fields, messagerecords.FieldSourceType)
  20091. }
  20092. if m.sop_stage != nil {
  20093. fields = append(fields, messagerecords.FieldSourceID)
  20094. }
  20095. if m.sop_node != nil {
  20096. fields = append(fields, messagerecords.FieldSubSourceID)
  20097. }
  20098. if m.organization_id != nil {
  20099. fields = append(fields, messagerecords.FieldOrganizationID)
  20100. }
  20101. return fields
  20102. }
  20103. // Field returns the value of a field with the given name. The second boolean
  20104. // return value indicates that this field was not set, or was not defined in the
  20105. // schema.
  20106. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  20107. switch name {
  20108. case messagerecords.FieldCreatedAt:
  20109. return m.CreatedAt()
  20110. case messagerecords.FieldUpdatedAt:
  20111. return m.UpdatedAt()
  20112. case messagerecords.FieldStatus:
  20113. return m.Status()
  20114. case messagerecords.FieldBotWxid:
  20115. return m.BotWxid()
  20116. case messagerecords.FieldContactID:
  20117. return m.ContactID()
  20118. case messagerecords.FieldContactType:
  20119. return m.ContactType()
  20120. case messagerecords.FieldContactWxid:
  20121. return m.ContactWxid()
  20122. case messagerecords.FieldContentType:
  20123. return m.ContentType()
  20124. case messagerecords.FieldContent:
  20125. return m.Content()
  20126. case messagerecords.FieldMeta:
  20127. return m.Meta()
  20128. case messagerecords.FieldErrorDetail:
  20129. return m.ErrorDetail()
  20130. case messagerecords.FieldSendTime:
  20131. return m.SendTime()
  20132. case messagerecords.FieldSourceType:
  20133. return m.SourceType()
  20134. case messagerecords.FieldSourceID:
  20135. return m.SourceID()
  20136. case messagerecords.FieldSubSourceID:
  20137. return m.SubSourceID()
  20138. case messagerecords.FieldOrganizationID:
  20139. return m.OrganizationID()
  20140. }
  20141. return nil, false
  20142. }
  20143. // OldField returns the old value of the field from the database. An error is
  20144. // returned if the mutation operation is not UpdateOne, or the query to the
  20145. // database failed.
  20146. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20147. switch name {
  20148. case messagerecords.FieldCreatedAt:
  20149. return m.OldCreatedAt(ctx)
  20150. case messagerecords.FieldUpdatedAt:
  20151. return m.OldUpdatedAt(ctx)
  20152. case messagerecords.FieldStatus:
  20153. return m.OldStatus(ctx)
  20154. case messagerecords.FieldBotWxid:
  20155. return m.OldBotWxid(ctx)
  20156. case messagerecords.FieldContactID:
  20157. return m.OldContactID(ctx)
  20158. case messagerecords.FieldContactType:
  20159. return m.OldContactType(ctx)
  20160. case messagerecords.FieldContactWxid:
  20161. return m.OldContactWxid(ctx)
  20162. case messagerecords.FieldContentType:
  20163. return m.OldContentType(ctx)
  20164. case messagerecords.FieldContent:
  20165. return m.OldContent(ctx)
  20166. case messagerecords.FieldMeta:
  20167. return m.OldMeta(ctx)
  20168. case messagerecords.FieldErrorDetail:
  20169. return m.OldErrorDetail(ctx)
  20170. case messagerecords.FieldSendTime:
  20171. return m.OldSendTime(ctx)
  20172. case messagerecords.FieldSourceType:
  20173. return m.OldSourceType(ctx)
  20174. case messagerecords.FieldSourceID:
  20175. return m.OldSourceID(ctx)
  20176. case messagerecords.FieldSubSourceID:
  20177. return m.OldSubSourceID(ctx)
  20178. case messagerecords.FieldOrganizationID:
  20179. return m.OldOrganizationID(ctx)
  20180. }
  20181. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  20182. }
  20183. // SetField sets the value of a field with the given name. It returns an error if
  20184. // the field is not defined in the schema, or if the type mismatched the field
  20185. // type.
  20186. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  20187. switch name {
  20188. case messagerecords.FieldCreatedAt:
  20189. v, ok := value.(time.Time)
  20190. if !ok {
  20191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20192. }
  20193. m.SetCreatedAt(v)
  20194. return nil
  20195. case messagerecords.FieldUpdatedAt:
  20196. v, ok := value.(time.Time)
  20197. if !ok {
  20198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20199. }
  20200. m.SetUpdatedAt(v)
  20201. return nil
  20202. case messagerecords.FieldStatus:
  20203. v, ok := value.(uint8)
  20204. if !ok {
  20205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20206. }
  20207. m.SetStatus(v)
  20208. return nil
  20209. case messagerecords.FieldBotWxid:
  20210. v, ok := value.(string)
  20211. if !ok {
  20212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20213. }
  20214. m.SetBotWxid(v)
  20215. return nil
  20216. case messagerecords.FieldContactID:
  20217. v, ok := value.(uint64)
  20218. if !ok {
  20219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20220. }
  20221. m.SetContactID(v)
  20222. return nil
  20223. case messagerecords.FieldContactType:
  20224. v, ok := value.(int)
  20225. if !ok {
  20226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20227. }
  20228. m.SetContactType(v)
  20229. return nil
  20230. case messagerecords.FieldContactWxid:
  20231. v, ok := value.(string)
  20232. if !ok {
  20233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20234. }
  20235. m.SetContactWxid(v)
  20236. return nil
  20237. case messagerecords.FieldContentType:
  20238. v, ok := value.(int)
  20239. if !ok {
  20240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20241. }
  20242. m.SetContentType(v)
  20243. return nil
  20244. case messagerecords.FieldContent:
  20245. v, ok := value.(string)
  20246. if !ok {
  20247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20248. }
  20249. m.SetContent(v)
  20250. return nil
  20251. case messagerecords.FieldMeta:
  20252. v, ok := value.(custom_types.Meta)
  20253. if !ok {
  20254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20255. }
  20256. m.SetMeta(v)
  20257. return nil
  20258. case messagerecords.FieldErrorDetail:
  20259. v, ok := value.(string)
  20260. if !ok {
  20261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20262. }
  20263. m.SetErrorDetail(v)
  20264. return nil
  20265. case messagerecords.FieldSendTime:
  20266. v, ok := value.(time.Time)
  20267. if !ok {
  20268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20269. }
  20270. m.SetSendTime(v)
  20271. return nil
  20272. case messagerecords.FieldSourceType:
  20273. v, ok := value.(int)
  20274. if !ok {
  20275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20276. }
  20277. m.SetSourceType(v)
  20278. return nil
  20279. case messagerecords.FieldSourceID:
  20280. v, ok := value.(uint64)
  20281. if !ok {
  20282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20283. }
  20284. m.SetSourceID(v)
  20285. return nil
  20286. case messagerecords.FieldSubSourceID:
  20287. v, ok := value.(uint64)
  20288. if !ok {
  20289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20290. }
  20291. m.SetSubSourceID(v)
  20292. return nil
  20293. case messagerecords.FieldOrganizationID:
  20294. v, ok := value.(uint64)
  20295. if !ok {
  20296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20297. }
  20298. m.SetOrganizationID(v)
  20299. return nil
  20300. }
  20301. return fmt.Errorf("unknown MessageRecords field %s", name)
  20302. }
  20303. // AddedFields returns all numeric fields that were incremented/decremented during
  20304. // this mutation.
  20305. func (m *MessageRecordsMutation) AddedFields() []string {
  20306. var fields []string
  20307. if m.addstatus != nil {
  20308. fields = append(fields, messagerecords.FieldStatus)
  20309. }
  20310. if m.addcontact_type != nil {
  20311. fields = append(fields, messagerecords.FieldContactType)
  20312. }
  20313. if m.addcontent_type != nil {
  20314. fields = append(fields, messagerecords.FieldContentType)
  20315. }
  20316. if m.addsource_type != nil {
  20317. fields = append(fields, messagerecords.FieldSourceType)
  20318. }
  20319. if m.addorganization_id != nil {
  20320. fields = append(fields, messagerecords.FieldOrganizationID)
  20321. }
  20322. return fields
  20323. }
  20324. // AddedField returns the numeric value that was incremented/decremented on a field
  20325. // with the given name. The second boolean return value indicates that this field
  20326. // was not set, or was not defined in the schema.
  20327. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  20328. switch name {
  20329. case messagerecords.FieldStatus:
  20330. return m.AddedStatus()
  20331. case messagerecords.FieldContactType:
  20332. return m.AddedContactType()
  20333. case messagerecords.FieldContentType:
  20334. return m.AddedContentType()
  20335. case messagerecords.FieldSourceType:
  20336. return m.AddedSourceType()
  20337. case messagerecords.FieldOrganizationID:
  20338. return m.AddedOrganizationID()
  20339. }
  20340. return nil, false
  20341. }
  20342. // AddField adds the value to the field with the given name. It returns an error if
  20343. // the field is not defined in the schema, or if the type mismatched the field
  20344. // type.
  20345. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  20346. switch name {
  20347. case messagerecords.FieldStatus:
  20348. v, ok := value.(int8)
  20349. if !ok {
  20350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20351. }
  20352. m.AddStatus(v)
  20353. return nil
  20354. case messagerecords.FieldContactType:
  20355. v, ok := value.(int)
  20356. if !ok {
  20357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20358. }
  20359. m.AddContactType(v)
  20360. return nil
  20361. case messagerecords.FieldContentType:
  20362. v, ok := value.(int)
  20363. if !ok {
  20364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20365. }
  20366. m.AddContentType(v)
  20367. return nil
  20368. case messagerecords.FieldSourceType:
  20369. v, ok := value.(int)
  20370. if !ok {
  20371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20372. }
  20373. m.AddSourceType(v)
  20374. return nil
  20375. case messagerecords.FieldOrganizationID:
  20376. v, ok := value.(int64)
  20377. if !ok {
  20378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20379. }
  20380. m.AddOrganizationID(v)
  20381. return nil
  20382. }
  20383. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  20384. }
  20385. // ClearedFields returns all nullable fields that were cleared during this
  20386. // mutation.
  20387. func (m *MessageRecordsMutation) ClearedFields() []string {
  20388. var fields []string
  20389. if m.FieldCleared(messagerecords.FieldStatus) {
  20390. fields = append(fields, messagerecords.FieldStatus)
  20391. }
  20392. if m.FieldCleared(messagerecords.FieldContactID) {
  20393. fields = append(fields, messagerecords.FieldContactID)
  20394. }
  20395. if m.FieldCleared(messagerecords.FieldMeta) {
  20396. fields = append(fields, messagerecords.FieldMeta)
  20397. }
  20398. if m.FieldCleared(messagerecords.FieldSendTime) {
  20399. fields = append(fields, messagerecords.FieldSendTime)
  20400. }
  20401. if m.FieldCleared(messagerecords.FieldSourceID) {
  20402. fields = append(fields, messagerecords.FieldSourceID)
  20403. }
  20404. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  20405. fields = append(fields, messagerecords.FieldSubSourceID)
  20406. }
  20407. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  20408. fields = append(fields, messagerecords.FieldOrganizationID)
  20409. }
  20410. return fields
  20411. }
  20412. // FieldCleared returns a boolean indicating if a field with the given name was
  20413. // cleared in this mutation.
  20414. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  20415. _, ok := m.clearedFields[name]
  20416. return ok
  20417. }
  20418. // ClearField clears the value of the field with the given name. It returns an
  20419. // error if the field is not defined in the schema.
  20420. func (m *MessageRecordsMutation) ClearField(name string) error {
  20421. switch name {
  20422. case messagerecords.FieldStatus:
  20423. m.ClearStatus()
  20424. return nil
  20425. case messagerecords.FieldContactID:
  20426. m.ClearContactID()
  20427. return nil
  20428. case messagerecords.FieldMeta:
  20429. m.ClearMeta()
  20430. return nil
  20431. case messagerecords.FieldSendTime:
  20432. m.ClearSendTime()
  20433. return nil
  20434. case messagerecords.FieldSourceID:
  20435. m.ClearSourceID()
  20436. return nil
  20437. case messagerecords.FieldSubSourceID:
  20438. m.ClearSubSourceID()
  20439. return nil
  20440. case messagerecords.FieldOrganizationID:
  20441. m.ClearOrganizationID()
  20442. return nil
  20443. }
  20444. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  20445. }
  20446. // ResetField resets all changes in the mutation for the field with the given name.
  20447. // It returns an error if the field is not defined in the schema.
  20448. func (m *MessageRecordsMutation) ResetField(name string) error {
  20449. switch name {
  20450. case messagerecords.FieldCreatedAt:
  20451. m.ResetCreatedAt()
  20452. return nil
  20453. case messagerecords.FieldUpdatedAt:
  20454. m.ResetUpdatedAt()
  20455. return nil
  20456. case messagerecords.FieldStatus:
  20457. m.ResetStatus()
  20458. return nil
  20459. case messagerecords.FieldBotWxid:
  20460. m.ResetBotWxid()
  20461. return nil
  20462. case messagerecords.FieldContactID:
  20463. m.ResetContactID()
  20464. return nil
  20465. case messagerecords.FieldContactType:
  20466. m.ResetContactType()
  20467. return nil
  20468. case messagerecords.FieldContactWxid:
  20469. m.ResetContactWxid()
  20470. return nil
  20471. case messagerecords.FieldContentType:
  20472. m.ResetContentType()
  20473. return nil
  20474. case messagerecords.FieldContent:
  20475. m.ResetContent()
  20476. return nil
  20477. case messagerecords.FieldMeta:
  20478. m.ResetMeta()
  20479. return nil
  20480. case messagerecords.FieldErrorDetail:
  20481. m.ResetErrorDetail()
  20482. return nil
  20483. case messagerecords.FieldSendTime:
  20484. m.ResetSendTime()
  20485. return nil
  20486. case messagerecords.FieldSourceType:
  20487. m.ResetSourceType()
  20488. return nil
  20489. case messagerecords.FieldSourceID:
  20490. m.ResetSourceID()
  20491. return nil
  20492. case messagerecords.FieldSubSourceID:
  20493. m.ResetSubSourceID()
  20494. return nil
  20495. case messagerecords.FieldOrganizationID:
  20496. m.ResetOrganizationID()
  20497. return nil
  20498. }
  20499. return fmt.Errorf("unknown MessageRecords field %s", name)
  20500. }
  20501. // AddedEdges returns all edge names that were set/added in this mutation.
  20502. func (m *MessageRecordsMutation) AddedEdges() []string {
  20503. edges := make([]string, 0, 3)
  20504. if m.sop_stage != nil {
  20505. edges = append(edges, messagerecords.EdgeSopStage)
  20506. }
  20507. if m.sop_node != nil {
  20508. edges = append(edges, messagerecords.EdgeSopNode)
  20509. }
  20510. if m.message_contact != nil {
  20511. edges = append(edges, messagerecords.EdgeMessageContact)
  20512. }
  20513. return edges
  20514. }
  20515. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20516. // name in this mutation.
  20517. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  20518. switch name {
  20519. case messagerecords.EdgeSopStage:
  20520. if id := m.sop_stage; id != nil {
  20521. return []ent.Value{*id}
  20522. }
  20523. case messagerecords.EdgeSopNode:
  20524. if id := m.sop_node; id != nil {
  20525. return []ent.Value{*id}
  20526. }
  20527. case messagerecords.EdgeMessageContact:
  20528. if id := m.message_contact; id != nil {
  20529. return []ent.Value{*id}
  20530. }
  20531. }
  20532. return nil
  20533. }
  20534. // RemovedEdges returns all edge names that were removed in this mutation.
  20535. func (m *MessageRecordsMutation) RemovedEdges() []string {
  20536. edges := make([]string, 0, 3)
  20537. return edges
  20538. }
  20539. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20540. // the given name in this mutation.
  20541. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  20542. return nil
  20543. }
  20544. // ClearedEdges returns all edge names that were cleared in this mutation.
  20545. func (m *MessageRecordsMutation) ClearedEdges() []string {
  20546. edges := make([]string, 0, 3)
  20547. if m.clearedsop_stage {
  20548. edges = append(edges, messagerecords.EdgeSopStage)
  20549. }
  20550. if m.clearedsop_node {
  20551. edges = append(edges, messagerecords.EdgeSopNode)
  20552. }
  20553. if m.clearedmessage_contact {
  20554. edges = append(edges, messagerecords.EdgeMessageContact)
  20555. }
  20556. return edges
  20557. }
  20558. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20559. // was cleared in this mutation.
  20560. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  20561. switch name {
  20562. case messagerecords.EdgeSopStage:
  20563. return m.clearedsop_stage
  20564. case messagerecords.EdgeSopNode:
  20565. return m.clearedsop_node
  20566. case messagerecords.EdgeMessageContact:
  20567. return m.clearedmessage_contact
  20568. }
  20569. return false
  20570. }
  20571. // ClearEdge clears the value of the edge with the given name. It returns an error
  20572. // if that edge is not defined in the schema.
  20573. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  20574. switch name {
  20575. case messagerecords.EdgeSopStage:
  20576. m.ClearSopStage()
  20577. return nil
  20578. case messagerecords.EdgeSopNode:
  20579. m.ClearSopNode()
  20580. return nil
  20581. case messagerecords.EdgeMessageContact:
  20582. m.ClearMessageContact()
  20583. return nil
  20584. }
  20585. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  20586. }
  20587. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20588. // It returns an error if the edge is not defined in the schema.
  20589. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  20590. switch name {
  20591. case messagerecords.EdgeSopStage:
  20592. m.ResetSopStage()
  20593. return nil
  20594. case messagerecords.EdgeSopNode:
  20595. m.ResetSopNode()
  20596. return nil
  20597. case messagerecords.EdgeMessageContact:
  20598. m.ResetMessageContact()
  20599. return nil
  20600. }
  20601. return fmt.Errorf("unknown MessageRecords edge %s", name)
  20602. }
  20603. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  20604. type MsgMutation struct {
  20605. config
  20606. op Op
  20607. typ string
  20608. id *uint64
  20609. created_at *time.Time
  20610. updated_at *time.Time
  20611. deleted_at *time.Time
  20612. status *uint8
  20613. addstatus *int8
  20614. fromwxid *string
  20615. toid *string
  20616. msgtype *int32
  20617. addmsgtype *int32
  20618. msg *string
  20619. batch_no *string
  20620. cc *string
  20621. phone *string
  20622. clearedFields map[string]struct{}
  20623. done bool
  20624. oldValue func(context.Context) (*Msg, error)
  20625. predicates []predicate.Msg
  20626. }
  20627. var _ ent.Mutation = (*MsgMutation)(nil)
  20628. // msgOption allows management of the mutation configuration using functional options.
  20629. type msgOption func(*MsgMutation)
  20630. // newMsgMutation creates new mutation for the Msg entity.
  20631. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  20632. m := &MsgMutation{
  20633. config: c,
  20634. op: op,
  20635. typ: TypeMsg,
  20636. clearedFields: make(map[string]struct{}),
  20637. }
  20638. for _, opt := range opts {
  20639. opt(m)
  20640. }
  20641. return m
  20642. }
  20643. // withMsgID sets the ID field of the mutation.
  20644. func withMsgID(id uint64) msgOption {
  20645. return func(m *MsgMutation) {
  20646. var (
  20647. err error
  20648. once sync.Once
  20649. value *Msg
  20650. )
  20651. m.oldValue = func(ctx context.Context) (*Msg, error) {
  20652. once.Do(func() {
  20653. if m.done {
  20654. err = errors.New("querying old values post mutation is not allowed")
  20655. } else {
  20656. value, err = m.Client().Msg.Get(ctx, id)
  20657. }
  20658. })
  20659. return value, err
  20660. }
  20661. m.id = &id
  20662. }
  20663. }
  20664. // withMsg sets the old Msg of the mutation.
  20665. func withMsg(node *Msg) msgOption {
  20666. return func(m *MsgMutation) {
  20667. m.oldValue = func(context.Context) (*Msg, error) {
  20668. return node, nil
  20669. }
  20670. m.id = &node.ID
  20671. }
  20672. }
  20673. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20674. // executed in a transaction (ent.Tx), a transactional client is returned.
  20675. func (m MsgMutation) Client() *Client {
  20676. client := &Client{config: m.config}
  20677. client.init()
  20678. return client
  20679. }
  20680. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20681. // it returns an error otherwise.
  20682. func (m MsgMutation) Tx() (*Tx, error) {
  20683. if _, ok := m.driver.(*txDriver); !ok {
  20684. return nil, errors.New("ent: mutation is not running in a transaction")
  20685. }
  20686. tx := &Tx{config: m.config}
  20687. tx.init()
  20688. return tx, nil
  20689. }
  20690. // SetID sets the value of the id field. Note that this
  20691. // operation is only accepted on creation of Msg entities.
  20692. func (m *MsgMutation) SetID(id uint64) {
  20693. m.id = &id
  20694. }
  20695. // ID returns the ID value in the mutation. Note that the ID is only available
  20696. // if it was provided to the builder or after it was returned from the database.
  20697. func (m *MsgMutation) ID() (id uint64, exists bool) {
  20698. if m.id == nil {
  20699. return
  20700. }
  20701. return *m.id, true
  20702. }
  20703. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20704. // That means, if the mutation is applied within a transaction with an isolation level such
  20705. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20706. // or updated by the mutation.
  20707. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  20708. switch {
  20709. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20710. id, exists := m.ID()
  20711. if exists {
  20712. return []uint64{id}, nil
  20713. }
  20714. fallthrough
  20715. case m.op.Is(OpUpdate | OpDelete):
  20716. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  20717. default:
  20718. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20719. }
  20720. }
  20721. // SetCreatedAt sets the "created_at" field.
  20722. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  20723. m.created_at = &t
  20724. }
  20725. // CreatedAt returns the value of the "created_at" field in the mutation.
  20726. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  20727. v := m.created_at
  20728. if v == nil {
  20729. return
  20730. }
  20731. return *v, true
  20732. }
  20733. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  20734. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20736. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20737. if !m.op.Is(OpUpdateOne) {
  20738. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20739. }
  20740. if m.id == nil || m.oldValue == nil {
  20741. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20742. }
  20743. oldValue, err := m.oldValue(ctx)
  20744. if err != nil {
  20745. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20746. }
  20747. return oldValue.CreatedAt, nil
  20748. }
  20749. // ResetCreatedAt resets all changes to the "created_at" field.
  20750. func (m *MsgMutation) ResetCreatedAt() {
  20751. m.created_at = nil
  20752. }
  20753. // SetUpdatedAt sets the "updated_at" field.
  20754. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  20755. m.updated_at = &t
  20756. }
  20757. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20758. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  20759. v := m.updated_at
  20760. if v == nil {
  20761. return
  20762. }
  20763. return *v, true
  20764. }
  20765. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  20766. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20768. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20769. if !m.op.Is(OpUpdateOne) {
  20770. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20771. }
  20772. if m.id == nil || m.oldValue == nil {
  20773. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20774. }
  20775. oldValue, err := m.oldValue(ctx)
  20776. if err != nil {
  20777. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20778. }
  20779. return oldValue.UpdatedAt, nil
  20780. }
  20781. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20782. func (m *MsgMutation) ResetUpdatedAt() {
  20783. m.updated_at = nil
  20784. }
  20785. // SetDeletedAt sets the "deleted_at" field.
  20786. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  20787. m.deleted_at = &t
  20788. }
  20789. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20790. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  20791. v := m.deleted_at
  20792. if v == nil {
  20793. return
  20794. }
  20795. return *v, true
  20796. }
  20797. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  20798. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20800. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20801. if !m.op.Is(OpUpdateOne) {
  20802. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20803. }
  20804. if m.id == nil || m.oldValue == nil {
  20805. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20806. }
  20807. oldValue, err := m.oldValue(ctx)
  20808. if err != nil {
  20809. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20810. }
  20811. return oldValue.DeletedAt, nil
  20812. }
  20813. // ClearDeletedAt clears the value of the "deleted_at" field.
  20814. func (m *MsgMutation) ClearDeletedAt() {
  20815. m.deleted_at = nil
  20816. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  20817. }
  20818. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20819. func (m *MsgMutation) DeletedAtCleared() bool {
  20820. _, ok := m.clearedFields[msg.FieldDeletedAt]
  20821. return ok
  20822. }
  20823. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20824. func (m *MsgMutation) ResetDeletedAt() {
  20825. m.deleted_at = nil
  20826. delete(m.clearedFields, msg.FieldDeletedAt)
  20827. }
  20828. // SetStatus sets the "status" field.
  20829. func (m *MsgMutation) SetStatus(u uint8) {
  20830. m.status = &u
  20831. m.addstatus = nil
  20832. }
  20833. // Status returns the value of the "status" field in the mutation.
  20834. func (m *MsgMutation) Status() (r uint8, exists bool) {
  20835. v := m.status
  20836. if v == nil {
  20837. return
  20838. }
  20839. return *v, true
  20840. }
  20841. // OldStatus returns the old "status" field's value of the Msg entity.
  20842. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20844. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20845. if !m.op.Is(OpUpdateOne) {
  20846. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20847. }
  20848. if m.id == nil || m.oldValue == nil {
  20849. return v, errors.New("OldStatus requires an ID field in the mutation")
  20850. }
  20851. oldValue, err := m.oldValue(ctx)
  20852. if err != nil {
  20853. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20854. }
  20855. return oldValue.Status, nil
  20856. }
  20857. // AddStatus adds u to the "status" field.
  20858. func (m *MsgMutation) AddStatus(u int8) {
  20859. if m.addstatus != nil {
  20860. *m.addstatus += u
  20861. } else {
  20862. m.addstatus = &u
  20863. }
  20864. }
  20865. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20866. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  20867. v := m.addstatus
  20868. if v == nil {
  20869. return
  20870. }
  20871. return *v, true
  20872. }
  20873. // ClearStatus clears the value of the "status" field.
  20874. func (m *MsgMutation) ClearStatus() {
  20875. m.status = nil
  20876. m.addstatus = nil
  20877. m.clearedFields[msg.FieldStatus] = struct{}{}
  20878. }
  20879. // StatusCleared returns if the "status" field was cleared in this mutation.
  20880. func (m *MsgMutation) StatusCleared() bool {
  20881. _, ok := m.clearedFields[msg.FieldStatus]
  20882. return ok
  20883. }
  20884. // ResetStatus resets all changes to the "status" field.
  20885. func (m *MsgMutation) ResetStatus() {
  20886. m.status = nil
  20887. m.addstatus = nil
  20888. delete(m.clearedFields, msg.FieldStatus)
  20889. }
  20890. // SetFromwxid sets the "fromwxid" field.
  20891. func (m *MsgMutation) SetFromwxid(s string) {
  20892. m.fromwxid = &s
  20893. }
  20894. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  20895. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  20896. v := m.fromwxid
  20897. if v == nil {
  20898. return
  20899. }
  20900. return *v, true
  20901. }
  20902. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  20903. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20905. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  20906. if !m.op.Is(OpUpdateOne) {
  20907. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  20908. }
  20909. if m.id == nil || m.oldValue == nil {
  20910. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  20911. }
  20912. oldValue, err := m.oldValue(ctx)
  20913. if err != nil {
  20914. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  20915. }
  20916. return oldValue.Fromwxid, nil
  20917. }
  20918. // ClearFromwxid clears the value of the "fromwxid" field.
  20919. func (m *MsgMutation) ClearFromwxid() {
  20920. m.fromwxid = nil
  20921. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  20922. }
  20923. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  20924. func (m *MsgMutation) FromwxidCleared() bool {
  20925. _, ok := m.clearedFields[msg.FieldFromwxid]
  20926. return ok
  20927. }
  20928. // ResetFromwxid resets all changes to the "fromwxid" field.
  20929. func (m *MsgMutation) ResetFromwxid() {
  20930. m.fromwxid = nil
  20931. delete(m.clearedFields, msg.FieldFromwxid)
  20932. }
  20933. // SetToid sets the "toid" field.
  20934. func (m *MsgMutation) SetToid(s string) {
  20935. m.toid = &s
  20936. }
  20937. // Toid returns the value of the "toid" field in the mutation.
  20938. func (m *MsgMutation) Toid() (r string, exists bool) {
  20939. v := m.toid
  20940. if v == nil {
  20941. return
  20942. }
  20943. return *v, true
  20944. }
  20945. // OldToid returns the old "toid" field's value of the Msg entity.
  20946. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20948. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  20949. if !m.op.Is(OpUpdateOne) {
  20950. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  20951. }
  20952. if m.id == nil || m.oldValue == nil {
  20953. return v, errors.New("OldToid requires an ID field in the mutation")
  20954. }
  20955. oldValue, err := m.oldValue(ctx)
  20956. if err != nil {
  20957. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  20958. }
  20959. return oldValue.Toid, nil
  20960. }
  20961. // ClearToid clears the value of the "toid" field.
  20962. func (m *MsgMutation) ClearToid() {
  20963. m.toid = nil
  20964. m.clearedFields[msg.FieldToid] = struct{}{}
  20965. }
  20966. // ToidCleared returns if the "toid" field was cleared in this mutation.
  20967. func (m *MsgMutation) ToidCleared() bool {
  20968. _, ok := m.clearedFields[msg.FieldToid]
  20969. return ok
  20970. }
  20971. // ResetToid resets all changes to the "toid" field.
  20972. func (m *MsgMutation) ResetToid() {
  20973. m.toid = nil
  20974. delete(m.clearedFields, msg.FieldToid)
  20975. }
  20976. // SetMsgtype sets the "msgtype" field.
  20977. func (m *MsgMutation) SetMsgtype(i int32) {
  20978. m.msgtype = &i
  20979. m.addmsgtype = nil
  20980. }
  20981. // Msgtype returns the value of the "msgtype" field in the mutation.
  20982. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  20983. v := m.msgtype
  20984. if v == nil {
  20985. return
  20986. }
  20987. return *v, true
  20988. }
  20989. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  20990. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20992. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  20993. if !m.op.Is(OpUpdateOne) {
  20994. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  20995. }
  20996. if m.id == nil || m.oldValue == nil {
  20997. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  20998. }
  20999. oldValue, err := m.oldValue(ctx)
  21000. if err != nil {
  21001. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  21002. }
  21003. return oldValue.Msgtype, nil
  21004. }
  21005. // AddMsgtype adds i to the "msgtype" field.
  21006. func (m *MsgMutation) AddMsgtype(i int32) {
  21007. if m.addmsgtype != nil {
  21008. *m.addmsgtype += i
  21009. } else {
  21010. m.addmsgtype = &i
  21011. }
  21012. }
  21013. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  21014. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  21015. v := m.addmsgtype
  21016. if v == nil {
  21017. return
  21018. }
  21019. return *v, true
  21020. }
  21021. // ClearMsgtype clears the value of the "msgtype" field.
  21022. func (m *MsgMutation) ClearMsgtype() {
  21023. m.msgtype = nil
  21024. m.addmsgtype = nil
  21025. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  21026. }
  21027. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  21028. func (m *MsgMutation) MsgtypeCleared() bool {
  21029. _, ok := m.clearedFields[msg.FieldMsgtype]
  21030. return ok
  21031. }
  21032. // ResetMsgtype resets all changes to the "msgtype" field.
  21033. func (m *MsgMutation) ResetMsgtype() {
  21034. m.msgtype = nil
  21035. m.addmsgtype = nil
  21036. delete(m.clearedFields, msg.FieldMsgtype)
  21037. }
  21038. // SetMsg sets the "msg" field.
  21039. func (m *MsgMutation) SetMsg(s string) {
  21040. m.msg = &s
  21041. }
  21042. // Msg returns the value of the "msg" field in the mutation.
  21043. func (m *MsgMutation) Msg() (r string, exists bool) {
  21044. v := m.msg
  21045. if v == nil {
  21046. return
  21047. }
  21048. return *v, true
  21049. }
  21050. // OldMsg returns the old "msg" field's value of the Msg entity.
  21051. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21053. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  21054. if !m.op.Is(OpUpdateOne) {
  21055. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  21056. }
  21057. if m.id == nil || m.oldValue == nil {
  21058. return v, errors.New("OldMsg requires an ID field in the mutation")
  21059. }
  21060. oldValue, err := m.oldValue(ctx)
  21061. if err != nil {
  21062. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  21063. }
  21064. return oldValue.Msg, nil
  21065. }
  21066. // ClearMsg clears the value of the "msg" field.
  21067. func (m *MsgMutation) ClearMsg() {
  21068. m.msg = nil
  21069. m.clearedFields[msg.FieldMsg] = struct{}{}
  21070. }
  21071. // MsgCleared returns if the "msg" field was cleared in this mutation.
  21072. func (m *MsgMutation) MsgCleared() bool {
  21073. _, ok := m.clearedFields[msg.FieldMsg]
  21074. return ok
  21075. }
  21076. // ResetMsg resets all changes to the "msg" field.
  21077. func (m *MsgMutation) ResetMsg() {
  21078. m.msg = nil
  21079. delete(m.clearedFields, msg.FieldMsg)
  21080. }
  21081. // SetBatchNo sets the "batch_no" field.
  21082. func (m *MsgMutation) SetBatchNo(s string) {
  21083. m.batch_no = &s
  21084. }
  21085. // BatchNo returns the value of the "batch_no" field in the mutation.
  21086. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  21087. v := m.batch_no
  21088. if v == nil {
  21089. return
  21090. }
  21091. return *v, true
  21092. }
  21093. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  21094. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21096. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  21097. if !m.op.Is(OpUpdateOne) {
  21098. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  21099. }
  21100. if m.id == nil || m.oldValue == nil {
  21101. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  21102. }
  21103. oldValue, err := m.oldValue(ctx)
  21104. if err != nil {
  21105. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  21106. }
  21107. return oldValue.BatchNo, nil
  21108. }
  21109. // ClearBatchNo clears the value of the "batch_no" field.
  21110. func (m *MsgMutation) ClearBatchNo() {
  21111. m.batch_no = nil
  21112. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  21113. }
  21114. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  21115. func (m *MsgMutation) BatchNoCleared() bool {
  21116. _, ok := m.clearedFields[msg.FieldBatchNo]
  21117. return ok
  21118. }
  21119. // ResetBatchNo resets all changes to the "batch_no" field.
  21120. func (m *MsgMutation) ResetBatchNo() {
  21121. m.batch_no = nil
  21122. delete(m.clearedFields, msg.FieldBatchNo)
  21123. }
  21124. // SetCc sets the "cc" field.
  21125. func (m *MsgMutation) SetCc(s string) {
  21126. m.cc = &s
  21127. }
  21128. // Cc returns the value of the "cc" field in the mutation.
  21129. func (m *MsgMutation) Cc() (r string, exists bool) {
  21130. v := m.cc
  21131. if v == nil {
  21132. return
  21133. }
  21134. return *v, true
  21135. }
  21136. // OldCc returns the old "cc" field's value of the Msg entity.
  21137. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21139. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  21140. if !m.op.Is(OpUpdateOne) {
  21141. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  21142. }
  21143. if m.id == nil || m.oldValue == nil {
  21144. return v, errors.New("OldCc requires an ID field in the mutation")
  21145. }
  21146. oldValue, err := m.oldValue(ctx)
  21147. if err != nil {
  21148. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  21149. }
  21150. return oldValue.Cc, nil
  21151. }
  21152. // ResetCc resets all changes to the "cc" field.
  21153. func (m *MsgMutation) ResetCc() {
  21154. m.cc = nil
  21155. }
  21156. // SetPhone sets the "phone" field.
  21157. func (m *MsgMutation) SetPhone(s string) {
  21158. m.phone = &s
  21159. }
  21160. // Phone returns the value of the "phone" field in the mutation.
  21161. func (m *MsgMutation) Phone() (r string, exists bool) {
  21162. v := m.phone
  21163. if v == nil {
  21164. return
  21165. }
  21166. return *v, true
  21167. }
  21168. // OldPhone returns the old "phone" field's value of the Msg entity.
  21169. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21171. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  21172. if !m.op.Is(OpUpdateOne) {
  21173. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  21174. }
  21175. if m.id == nil || m.oldValue == nil {
  21176. return v, errors.New("OldPhone requires an ID field in the mutation")
  21177. }
  21178. oldValue, err := m.oldValue(ctx)
  21179. if err != nil {
  21180. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  21181. }
  21182. return oldValue.Phone, nil
  21183. }
  21184. // ResetPhone resets all changes to the "phone" field.
  21185. func (m *MsgMutation) ResetPhone() {
  21186. m.phone = nil
  21187. }
  21188. // Where appends a list predicates to the MsgMutation builder.
  21189. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  21190. m.predicates = append(m.predicates, ps...)
  21191. }
  21192. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  21193. // users can use type-assertion to append predicates that do not depend on any generated package.
  21194. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  21195. p := make([]predicate.Msg, len(ps))
  21196. for i := range ps {
  21197. p[i] = ps[i]
  21198. }
  21199. m.Where(p...)
  21200. }
  21201. // Op returns the operation name.
  21202. func (m *MsgMutation) Op() Op {
  21203. return m.op
  21204. }
  21205. // SetOp allows setting the mutation operation.
  21206. func (m *MsgMutation) SetOp(op Op) {
  21207. m.op = op
  21208. }
  21209. // Type returns the node type of this mutation (Msg).
  21210. func (m *MsgMutation) Type() string {
  21211. return m.typ
  21212. }
  21213. // Fields returns all fields that were changed during this mutation. Note that in
  21214. // order to get all numeric fields that were incremented/decremented, call
  21215. // AddedFields().
  21216. func (m *MsgMutation) Fields() []string {
  21217. fields := make([]string, 0, 11)
  21218. if m.created_at != nil {
  21219. fields = append(fields, msg.FieldCreatedAt)
  21220. }
  21221. if m.updated_at != nil {
  21222. fields = append(fields, msg.FieldUpdatedAt)
  21223. }
  21224. if m.deleted_at != nil {
  21225. fields = append(fields, msg.FieldDeletedAt)
  21226. }
  21227. if m.status != nil {
  21228. fields = append(fields, msg.FieldStatus)
  21229. }
  21230. if m.fromwxid != nil {
  21231. fields = append(fields, msg.FieldFromwxid)
  21232. }
  21233. if m.toid != nil {
  21234. fields = append(fields, msg.FieldToid)
  21235. }
  21236. if m.msgtype != nil {
  21237. fields = append(fields, msg.FieldMsgtype)
  21238. }
  21239. if m.msg != nil {
  21240. fields = append(fields, msg.FieldMsg)
  21241. }
  21242. if m.batch_no != nil {
  21243. fields = append(fields, msg.FieldBatchNo)
  21244. }
  21245. if m.cc != nil {
  21246. fields = append(fields, msg.FieldCc)
  21247. }
  21248. if m.phone != nil {
  21249. fields = append(fields, msg.FieldPhone)
  21250. }
  21251. return fields
  21252. }
  21253. // Field returns the value of a field with the given name. The second boolean
  21254. // return value indicates that this field was not set, or was not defined in the
  21255. // schema.
  21256. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  21257. switch name {
  21258. case msg.FieldCreatedAt:
  21259. return m.CreatedAt()
  21260. case msg.FieldUpdatedAt:
  21261. return m.UpdatedAt()
  21262. case msg.FieldDeletedAt:
  21263. return m.DeletedAt()
  21264. case msg.FieldStatus:
  21265. return m.Status()
  21266. case msg.FieldFromwxid:
  21267. return m.Fromwxid()
  21268. case msg.FieldToid:
  21269. return m.Toid()
  21270. case msg.FieldMsgtype:
  21271. return m.Msgtype()
  21272. case msg.FieldMsg:
  21273. return m.Msg()
  21274. case msg.FieldBatchNo:
  21275. return m.BatchNo()
  21276. case msg.FieldCc:
  21277. return m.Cc()
  21278. case msg.FieldPhone:
  21279. return m.Phone()
  21280. }
  21281. return nil, false
  21282. }
  21283. // OldField returns the old value of the field from the database. An error is
  21284. // returned if the mutation operation is not UpdateOne, or the query to the
  21285. // database failed.
  21286. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21287. switch name {
  21288. case msg.FieldCreatedAt:
  21289. return m.OldCreatedAt(ctx)
  21290. case msg.FieldUpdatedAt:
  21291. return m.OldUpdatedAt(ctx)
  21292. case msg.FieldDeletedAt:
  21293. return m.OldDeletedAt(ctx)
  21294. case msg.FieldStatus:
  21295. return m.OldStatus(ctx)
  21296. case msg.FieldFromwxid:
  21297. return m.OldFromwxid(ctx)
  21298. case msg.FieldToid:
  21299. return m.OldToid(ctx)
  21300. case msg.FieldMsgtype:
  21301. return m.OldMsgtype(ctx)
  21302. case msg.FieldMsg:
  21303. return m.OldMsg(ctx)
  21304. case msg.FieldBatchNo:
  21305. return m.OldBatchNo(ctx)
  21306. case msg.FieldCc:
  21307. return m.OldCc(ctx)
  21308. case msg.FieldPhone:
  21309. return m.OldPhone(ctx)
  21310. }
  21311. return nil, fmt.Errorf("unknown Msg field %s", name)
  21312. }
  21313. // SetField sets the value of a field with the given name. It returns an error if
  21314. // the field is not defined in the schema, or if the type mismatched the field
  21315. // type.
  21316. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  21317. switch name {
  21318. case msg.FieldCreatedAt:
  21319. v, ok := value.(time.Time)
  21320. if !ok {
  21321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21322. }
  21323. m.SetCreatedAt(v)
  21324. return nil
  21325. case msg.FieldUpdatedAt:
  21326. v, ok := value.(time.Time)
  21327. if !ok {
  21328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21329. }
  21330. m.SetUpdatedAt(v)
  21331. return nil
  21332. case msg.FieldDeletedAt:
  21333. v, ok := value.(time.Time)
  21334. if !ok {
  21335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21336. }
  21337. m.SetDeletedAt(v)
  21338. return nil
  21339. case msg.FieldStatus:
  21340. v, ok := value.(uint8)
  21341. if !ok {
  21342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21343. }
  21344. m.SetStatus(v)
  21345. return nil
  21346. case msg.FieldFromwxid:
  21347. v, ok := value.(string)
  21348. if !ok {
  21349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21350. }
  21351. m.SetFromwxid(v)
  21352. return nil
  21353. case msg.FieldToid:
  21354. v, ok := value.(string)
  21355. if !ok {
  21356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21357. }
  21358. m.SetToid(v)
  21359. return nil
  21360. case msg.FieldMsgtype:
  21361. v, ok := value.(int32)
  21362. if !ok {
  21363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21364. }
  21365. m.SetMsgtype(v)
  21366. return nil
  21367. case msg.FieldMsg:
  21368. v, ok := value.(string)
  21369. if !ok {
  21370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21371. }
  21372. m.SetMsg(v)
  21373. return nil
  21374. case msg.FieldBatchNo:
  21375. v, ok := value.(string)
  21376. if !ok {
  21377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21378. }
  21379. m.SetBatchNo(v)
  21380. return nil
  21381. case msg.FieldCc:
  21382. v, ok := value.(string)
  21383. if !ok {
  21384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21385. }
  21386. m.SetCc(v)
  21387. return nil
  21388. case msg.FieldPhone:
  21389. v, ok := value.(string)
  21390. if !ok {
  21391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21392. }
  21393. m.SetPhone(v)
  21394. return nil
  21395. }
  21396. return fmt.Errorf("unknown Msg field %s", name)
  21397. }
  21398. // AddedFields returns all numeric fields that were incremented/decremented during
  21399. // this mutation.
  21400. func (m *MsgMutation) AddedFields() []string {
  21401. var fields []string
  21402. if m.addstatus != nil {
  21403. fields = append(fields, msg.FieldStatus)
  21404. }
  21405. if m.addmsgtype != nil {
  21406. fields = append(fields, msg.FieldMsgtype)
  21407. }
  21408. return fields
  21409. }
  21410. // AddedField returns the numeric value that was incremented/decremented on a field
  21411. // with the given name. The second boolean return value indicates that this field
  21412. // was not set, or was not defined in the schema.
  21413. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  21414. switch name {
  21415. case msg.FieldStatus:
  21416. return m.AddedStatus()
  21417. case msg.FieldMsgtype:
  21418. return m.AddedMsgtype()
  21419. }
  21420. return nil, false
  21421. }
  21422. // AddField adds the value to the field with the given name. It returns an error if
  21423. // the field is not defined in the schema, or if the type mismatched the field
  21424. // type.
  21425. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  21426. switch name {
  21427. case msg.FieldStatus:
  21428. v, ok := value.(int8)
  21429. if !ok {
  21430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21431. }
  21432. m.AddStatus(v)
  21433. return nil
  21434. case msg.FieldMsgtype:
  21435. v, ok := value.(int32)
  21436. if !ok {
  21437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21438. }
  21439. m.AddMsgtype(v)
  21440. return nil
  21441. }
  21442. return fmt.Errorf("unknown Msg numeric field %s", name)
  21443. }
  21444. // ClearedFields returns all nullable fields that were cleared during this
  21445. // mutation.
  21446. func (m *MsgMutation) ClearedFields() []string {
  21447. var fields []string
  21448. if m.FieldCleared(msg.FieldDeletedAt) {
  21449. fields = append(fields, msg.FieldDeletedAt)
  21450. }
  21451. if m.FieldCleared(msg.FieldStatus) {
  21452. fields = append(fields, msg.FieldStatus)
  21453. }
  21454. if m.FieldCleared(msg.FieldFromwxid) {
  21455. fields = append(fields, msg.FieldFromwxid)
  21456. }
  21457. if m.FieldCleared(msg.FieldToid) {
  21458. fields = append(fields, msg.FieldToid)
  21459. }
  21460. if m.FieldCleared(msg.FieldMsgtype) {
  21461. fields = append(fields, msg.FieldMsgtype)
  21462. }
  21463. if m.FieldCleared(msg.FieldMsg) {
  21464. fields = append(fields, msg.FieldMsg)
  21465. }
  21466. if m.FieldCleared(msg.FieldBatchNo) {
  21467. fields = append(fields, msg.FieldBatchNo)
  21468. }
  21469. return fields
  21470. }
  21471. // FieldCleared returns a boolean indicating if a field with the given name was
  21472. // cleared in this mutation.
  21473. func (m *MsgMutation) FieldCleared(name string) bool {
  21474. _, ok := m.clearedFields[name]
  21475. return ok
  21476. }
  21477. // ClearField clears the value of the field with the given name. It returns an
  21478. // error if the field is not defined in the schema.
  21479. func (m *MsgMutation) ClearField(name string) error {
  21480. switch name {
  21481. case msg.FieldDeletedAt:
  21482. m.ClearDeletedAt()
  21483. return nil
  21484. case msg.FieldStatus:
  21485. m.ClearStatus()
  21486. return nil
  21487. case msg.FieldFromwxid:
  21488. m.ClearFromwxid()
  21489. return nil
  21490. case msg.FieldToid:
  21491. m.ClearToid()
  21492. return nil
  21493. case msg.FieldMsgtype:
  21494. m.ClearMsgtype()
  21495. return nil
  21496. case msg.FieldMsg:
  21497. m.ClearMsg()
  21498. return nil
  21499. case msg.FieldBatchNo:
  21500. m.ClearBatchNo()
  21501. return nil
  21502. }
  21503. return fmt.Errorf("unknown Msg nullable field %s", name)
  21504. }
  21505. // ResetField resets all changes in the mutation for the field with the given name.
  21506. // It returns an error if the field is not defined in the schema.
  21507. func (m *MsgMutation) ResetField(name string) error {
  21508. switch name {
  21509. case msg.FieldCreatedAt:
  21510. m.ResetCreatedAt()
  21511. return nil
  21512. case msg.FieldUpdatedAt:
  21513. m.ResetUpdatedAt()
  21514. return nil
  21515. case msg.FieldDeletedAt:
  21516. m.ResetDeletedAt()
  21517. return nil
  21518. case msg.FieldStatus:
  21519. m.ResetStatus()
  21520. return nil
  21521. case msg.FieldFromwxid:
  21522. m.ResetFromwxid()
  21523. return nil
  21524. case msg.FieldToid:
  21525. m.ResetToid()
  21526. return nil
  21527. case msg.FieldMsgtype:
  21528. m.ResetMsgtype()
  21529. return nil
  21530. case msg.FieldMsg:
  21531. m.ResetMsg()
  21532. return nil
  21533. case msg.FieldBatchNo:
  21534. m.ResetBatchNo()
  21535. return nil
  21536. case msg.FieldCc:
  21537. m.ResetCc()
  21538. return nil
  21539. case msg.FieldPhone:
  21540. m.ResetPhone()
  21541. return nil
  21542. }
  21543. return fmt.Errorf("unknown Msg field %s", name)
  21544. }
  21545. // AddedEdges returns all edge names that were set/added in this mutation.
  21546. func (m *MsgMutation) AddedEdges() []string {
  21547. edges := make([]string, 0, 0)
  21548. return edges
  21549. }
  21550. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21551. // name in this mutation.
  21552. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  21553. return nil
  21554. }
  21555. // RemovedEdges returns all edge names that were removed in this mutation.
  21556. func (m *MsgMutation) RemovedEdges() []string {
  21557. edges := make([]string, 0, 0)
  21558. return edges
  21559. }
  21560. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21561. // the given name in this mutation.
  21562. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  21563. return nil
  21564. }
  21565. // ClearedEdges returns all edge names that were cleared in this mutation.
  21566. func (m *MsgMutation) ClearedEdges() []string {
  21567. edges := make([]string, 0, 0)
  21568. return edges
  21569. }
  21570. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21571. // was cleared in this mutation.
  21572. func (m *MsgMutation) EdgeCleared(name string) bool {
  21573. return false
  21574. }
  21575. // ClearEdge clears the value of the edge with the given name. It returns an error
  21576. // if that edge is not defined in the schema.
  21577. func (m *MsgMutation) ClearEdge(name string) error {
  21578. return fmt.Errorf("unknown Msg unique edge %s", name)
  21579. }
  21580. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21581. // It returns an error if the edge is not defined in the schema.
  21582. func (m *MsgMutation) ResetEdge(name string) error {
  21583. return fmt.Errorf("unknown Msg edge %s", name)
  21584. }
  21585. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  21586. type PayRechargeMutation struct {
  21587. config
  21588. op Op
  21589. typ string
  21590. id *uint64
  21591. created_at *time.Time
  21592. updated_at *time.Time
  21593. deleted_at *time.Time
  21594. user_id *string
  21595. number *float32
  21596. addnumber *float32
  21597. status *int
  21598. addstatus *int
  21599. money *float32
  21600. addmoney *float32
  21601. out_trade_no *string
  21602. organization_id *uint64
  21603. addorganization_id *int64
  21604. clearedFields map[string]struct{}
  21605. done bool
  21606. oldValue func(context.Context) (*PayRecharge, error)
  21607. predicates []predicate.PayRecharge
  21608. }
  21609. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  21610. // payrechargeOption allows management of the mutation configuration using functional options.
  21611. type payrechargeOption func(*PayRechargeMutation)
  21612. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  21613. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  21614. m := &PayRechargeMutation{
  21615. config: c,
  21616. op: op,
  21617. typ: TypePayRecharge,
  21618. clearedFields: make(map[string]struct{}),
  21619. }
  21620. for _, opt := range opts {
  21621. opt(m)
  21622. }
  21623. return m
  21624. }
  21625. // withPayRechargeID sets the ID field of the mutation.
  21626. func withPayRechargeID(id uint64) payrechargeOption {
  21627. return func(m *PayRechargeMutation) {
  21628. var (
  21629. err error
  21630. once sync.Once
  21631. value *PayRecharge
  21632. )
  21633. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  21634. once.Do(func() {
  21635. if m.done {
  21636. err = errors.New("querying old values post mutation is not allowed")
  21637. } else {
  21638. value, err = m.Client().PayRecharge.Get(ctx, id)
  21639. }
  21640. })
  21641. return value, err
  21642. }
  21643. m.id = &id
  21644. }
  21645. }
  21646. // withPayRecharge sets the old PayRecharge of the mutation.
  21647. func withPayRecharge(node *PayRecharge) payrechargeOption {
  21648. return func(m *PayRechargeMutation) {
  21649. m.oldValue = func(context.Context) (*PayRecharge, error) {
  21650. return node, nil
  21651. }
  21652. m.id = &node.ID
  21653. }
  21654. }
  21655. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21656. // executed in a transaction (ent.Tx), a transactional client is returned.
  21657. func (m PayRechargeMutation) Client() *Client {
  21658. client := &Client{config: m.config}
  21659. client.init()
  21660. return client
  21661. }
  21662. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21663. // it returns an error otherwise.
  21664. func (m PayRechargeMutation) Tx() (*Tx, error) {
  21665. if _, ok := m.driver.(*txDriver); !ok {
  21666. return nil, errors.New("ent: mutation is not running in a transaction")
  21667. }
  21668. tx := &Tx{config: m.config}
  21669. tx.init()
  21670. return tx, nil
  21671. }
  21672. // SetID sets the value of the id field. Note that this
  21673. // operation is only accepted on creation of PayRecharge entities.
  21674. func (m *PayRechargeMutation) SetID(id uint64) {
  21675. m.id = &id
  21676. }
  21677. // ID returns the ID value in the mutation. Note that the ID is only available
  21678. // if it was provided to the builder or after it was returned from the database.
  21679. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  21680. if m.id == nil {
  21681. return
  21682. }
  21683. return *m.id, true
  21684. }
  21685. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21686. // That means, if the mutation is applied within a transaction with an isolation level such
  21687. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21688. // or updated by the mutation.
  21689. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  21690. switch {
  21691. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21692. id, exists := m.ID()
  21693. if exists {
  21694. return []uint64{id}, nil
  21695. }
  21696. fallthrough
  21697. case m.op.Is(OpUpdate | OpDelete):
  21698. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  21699. default:
  21700. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21701. }
  21702. }
  21703. // SetCreatedAt sets the "created_at" field.
  21704. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  21705. m.created_at = &t
  21706. }
  21707. // CreatedAt returns the value of the "created_at" field in the mutation.
  21708. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  21709. v := m.created_at
  21710. if v == nil {
  21711. return
  21712. }
  21713. return *v, true
  21714. }
  21715. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  21716. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21718. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21719. if !m.op.Is(OpUpdateOne) {
  21720. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21721. }
  21722. if m.id == nil || m.oldValue == nil {
  21723. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21724. }
  21725. oldValue, err := m.oldValue(ctx)
  21726. if err != nil {
  21727. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21728. }
  21729. return oldValue.CreatedAt, nil
  21730. }
  21731. // ResetCreatedAt resets all changes to the "created_at" field.
  21732. func (m *PayRechargeMutation) ResetCreatedAt() {
  21733. m.created_at = nil
  21734. }
  21735. // SetUpdatedAt sets the "updated_at" field.
  21736. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  21737. m.updated_at = &t
  21738. }
  21739. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21740. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  21741. v := m.updated_at
  21742. if v == nil {
  21743. return
  21744. }
  21745. return *v, true
  21746. }
  21747. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  21748. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21750. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21751. if !m.op.Is(OpUpdateOne) {
  21752. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21753. }
  21754. if m.id == nil || m.oldValue == nil {
  21755. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21756. }
  21757. oldValue, err := m.oldValue(ctx)
  21758. if err != nil {
  21759. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21760. }
  21761. return oldValue.UpdatedAt, nil
  21762. }
  21763. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21764. func (m *PayRechargeMutation) ResetUpdatedAt() {
  21765. m.updated_at = nil
  21766. }
  21767. // SetDeletedAt sets the "deleted_at" field.
  21768. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  21769. m.deleted_at = &t
  21770. }
  21771. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21772. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  21773. v := m.deleted_at
  21774. if v == nil {
  21775. return
  21776. }
  21777. return *v, true
  21778. }
  21779. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  21780. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21782. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21783. if !m.op.Is(OpUpdateOne) {
  21784. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21785. }
  21786. if m.id == nil || m.oldValue == nil {
  21787. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21788. }
  21789. oldValue, err := m.oldValue(ctx)
  21790. if err != nil {
  21791. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21792. }
  21793. return oldValue.DeletedAt, nil
  21794. }
  21795. // ClearDeletedAt clears the value of the "deleted_at" field.
  21796. func (m *PayRechargeMutation) ClearDeletedAt() {
  21797. m.deleted_at = nil
  21798. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  21799. }
  21800. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21801. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  21802. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  21803. return ok
  21804. }
  21805. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21806. func (m *PayRechargeMutation) ResetDeletedAt() {
  21807. m.deleted_at = nil
  21808. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  21809. }
  21810. // SetUserID sets the "user_id" field.
  21811. func (m *PayRechargeMutation) SetUserID(s string) {
  21812. m.user_id = &s
  21813. }
  21814. // UserID returns the value of the "user_id" field in the mutation.
  21815. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  21816. v := m.user_id
  21817. if v == nil {
  21818. return
  21819. }
  21820. return *v, true
  21821. }
  21822. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  21823. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21825. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  21826. if !m.op.Is(OpUpdateOne) {
  21827. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  21828. }
  21829. if m.id == nil || m.oldValue == nil {
  21830. return v, errors.New("OldUserID requires an ID field in the mutation")
  21831. }
  21832. oldValue, err := m.oldValue(ctx)
  21833. if err != nil {
  21834. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  21835. }
  21836. return oldValue.UserID, nil
  21837. }
  21838. // ResetUserID resets all changes to the "user_id" field.
  21839. func (m *PayRechargeMutation) ResetUserID() {
  21840. m.user_id = nil
  21841. }
  21842. // SetNumber sets the "number" field.
  21843. func (m *PayRechargeMutation) SetNumber(f float32) {
  21844. m.number = &f
  21845. m.addnumber = nil
  21846. }
  21847. // Number returns the value of the "number" field in the mutation.
  21848. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  21849. v := m.number
  21850. if v == nil {
  21851. return
  21852. }
  21853. return *v, true
  21854. }
  21855. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  21856. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21858. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  21859. if !m.op.Is(OpUpdateOne) {
  21860. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  21861. }
  21862. if m.id == nil || m.oldValue == nil {
  21863. return v, errors.New("OldNumber requires an ID field in the mutation")
  21864. }
  21865. oldValue, err := m.oldValue(ctx)
  21866. if err != nil {
  21867. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  21868. }
  21869. return oldValue.Number, nil
  21870. }
  21871. // AddNumber adds f to the "number" field.
  21872. func (m *PayRechargeMutation) AddNumber(f float32) {
  21873. if m.addnumber != nil {
  21874. *m.addnumber += f
  21875. } else {
  21876. m.addnumber = &f
  21877. }
  21878. }
  21879. // AddedNumber returns the value that was added to the "number" field in this mutation.
  21880. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  21881. v := m.addnumber
  21882. if v == nil {
  21883. return
  21884. }
  21885. return *v, true
  21886. }
  21887. // ResetNumber resets all changes to the "number" field.
  21888. func (m *PayRechargeMutation) ResetNumber() {
  21889. m.number = nil
  21890. m.addnumber = nil
  21891. }
  21892. // SetStatus sets the "status" field.
  21893. func (m *PayRechargeMutation) SetStatus(i int) {
  21894. m.status = &i
  21895. m.addstatus = nil
  21896. }
  21897. // Status returns the value of the "status" field in the mutation.
  21898. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  21899. v := m.status
  21900. if v == nil {
  21901. return
  21902. }
  21903. return *v, true
  21904. }
  21905. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  21906. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21908. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  21909. if !m.op.Is(OpUpdateOne) {
  21910. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21911. }
  21912. if m.id == nil || m.oldValue == nil {
  21913. return v, errors.New("OldStatus requires an ID field in the mutation")
  21914. }
  21915. oldValue, err := m.oldValue(ctx)
  21916. if err != nil {
  21917. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21918. }
  21919. return oldValue.Status, nil
  21920. }
  21921. // AddStatus adds i to the "status" field.
  21922. func (m *PayRechargeMutation) AddStatus(i int) {
  21923. if m.addstatus != nil {
  21924. *m.addstatus += i
  21925. } else {
  21926. m.addstatus = &i
  21927. }
  21928. }
  21929. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21930. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  21931. v := m.addstatus
  21932. if v == nil {
  21933. return
  21934. }
  21935. return *v, true
  21936. }
  21937. // ClearStatus clears the value of the "status" field.
  21938. func (m *PayRechargeMutation) ClearStatus() {
  21939. m.status = nil
  21940. m.addstatus = nil
  21941. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  21942. }
  21943. // StatusCleared returns if the "status" field was cleared in this mutation.
  21944. func (m *PayRechargeMutation) StatusCleared() bool {
  21945. _, ok := m.clearedFields[payrecharge.FieldStatus]
  21946. return ok
  21947. }
  21948. // ResetStatus resets all changes to the "status" field.
  21949. func (m *PayRechargeMutation) ResetStatus() {
  21950. m.status = nil
  21951. m.addstatus = nil
  21952. delete(m.clearedFields, payrecharge.FieldStatus)
  21953. }
  21954. // SetMoney sets the "money" field.
  21955. func (m *PayRechargeMutation) SetMoney(f float32) {
  21956. m.money = &f
  21957. m.addmoney = nil
  21958. }
  21959. // Money returns the value of the "money" field in the mutation.
  21960. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  21961. v := m.money
  21962. if v == nil {
  21963. return
  21964. }
  21965. return *v, true
  21966. }
  21967. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  21968. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21970. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  21971. if !m.op.Is(OpUpdateOne) {
  21972. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  21973. }
  21974. if m.id == nil || m.oldValue == nil {
  21975. return v, errors.New("OldMoney requires an ID field in the mutation")
  21976. }
  21977. oldValue, err := m.oldValue(ctx)
  21978. if err != nil {
  21979. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  21980. }
  21981. return oldValue.Money, nil
  21982. }
  21983. // AddMoney adds f to the "money" field.
  21984. func (m *PayRechargeMutation) AddMoney(f float32) {
  21985. if m.addmoney != nil {
  21986. *m.addmoney += f
  21987. } else {
  21988. m.addmoney = &f
  21989. }
  21990. }
  21991. // AddedMoney returns the value that was added to the "money" field in this mutation.
  21992. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  21993. v := m.addmoney
  21994. if v == nil {
  21995. return
  21996. }
  21997. return *v, true
  21998. }
  21999. // ClearMoney clears the value of the "money" field.
  22000. func (m *PayRechargeMutation) ClearMoney() {
  22001. m.money = nil
  22002. m.addmoney = nil
  22003. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  22004. }
  22005. // MoneyCleared returns if the "money" field was cleared in this mutation.
  22006. func (m *PayRechargeMutation) MoneyCleared() bool {
  22007. _, ok := m.clearedFields[payrecharge.FieldMoney]
  22008. return ok
  22009. }
  22010. // ResetMoney resets all changes to the "money" field.
  22011. func (m *PayRechargeMutation) ResetMoney() {
  22012. m.money = nil
  22013. m.addmoney = nil
  22014. delete(m.clearedFields, payrecharge.FieldMoney)
  22015. }
  22016. // SetOutTradeNo sets the "out_trade_no" field.
  22017. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  22018. m.out_trade_no = &s
  22019. }
  22020. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  22021. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  22022. v := m.out_trade_no
  22023. if v == nil {
  22024. return
  22025. }
  22026. return *v, true
  22027. }
  22028. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  22029. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22031. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  22032. if !m.op.Is(OpUpdateOne) {
  22033. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  22034. }
  22035. if m.id == nil || m.oldValue == nil {
  22036. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  22037. }
  22038. oldValue, err := m.oldValue(ctx)
  22039. if err != nil {
  22040. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  22041. }
  22042. return oldValue.OutTradeNo, nil
  22043. }
  22044. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  22045. func (m *PayRechargeMutation) ClearOutTradeNo() {
  22046. m.out_trade_no = nil
  22047. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  22048. }
  22049. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  22050. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  22051. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  22052. return ok
  22053. }
  22054. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  22055. func (m *PayRechargeMutation) ResetOutTradeNo() {
  22056. m.out_trade_no = nil
  22057. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  22058. }
  22059. // SetOrganizationID sets the "organization_id" field.
  22060. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  22061. m.organization_id = &u
  22062. m.addorganization_id = nil
  22063. }
  22064. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22065. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  22066. v := m.organization_id
  22067. if v == nil {
  22068. return
  22069. }
  22070. return *v, true
  22071. }
  22072. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  22073. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22075. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22076. if !m.op.Is(OpUpdateOne) {
  22077. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22078. }
  22079. if m.id == nil || m.oldValue == nil {
  22080. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22081. }
  22082. oldValue, err := m.oldValue(ctx)
  22083. if err != nil {
  22084. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22085. }
  22086. return oldValue.OrganizationID, nil
  22087. }
  22088. // AddOrganizationID adds u to the "organization_id" field.
  22089. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  22090. if m.addorganization_id != nil {
  22091. *m.addorganization_id += u
  22092. } else {
  22093. m.addorganization_id = &u
  22094. }
  22095. }
  22096. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22097. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  22098. v := m.addorganization_id
  22099. if v == nil {
  22100. return
  22101. }
  22102. return *v, true
  22103. }
  22104. // ResetOrganizationID resets all changes to the "organization_id" field.
  22105. func (m *PayRechargeMutation) ResetOrganizationID() {
  22106. m.organization_id = nil
  22107. m.addorganization_id = nil
  22108. }
  22109. // Where appends a list predicates to the PayRechargeMutation builder.
  22110. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  22111. m.predicates = append(m.predicates, ps...)
  22112. }
  22113. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  22114. // users can use type-assertion to append predicates that do not depend on any generated package.
  22115. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  22116. p := make([]predicate.PayRecharge, len(ps))
  22117. for i := range ps {
  22118. p[i] = ps[i]
  22119. }
  22120. m.Where(p...)
  22121. }
  22122. // Op returns the operation name.
  22123. func (m *PayRechargeMutation) Op() Op {
  22124. return m.op
  22125. }
  22126. // SetOp allows setting the mutation operation.
  22127. func (m *PayRechargeMutation) SetOp(op Op) {
  22128. m.op = op
  22129. }
  22130. // Type returns the node type of this mutation (PayRecharge).
  22131. func (m *PayRechargeMutation) Type() string {
  22132. return m.typ
  22133. }
  22134. // Fields returns all fields that were changed during this mutation. Note that in
  22135. // order to get all numeric fields that were incremented/decremented, call
  22136. // AddedFields().
  22137. func (m *PayRechargeMutation) Fields() []string {
  22138. fields := make([]string, 0, 9)
  22139. if m.created_at != nil {
  22140. fields = append(fields, payrecharge.FieldCreatedAt)
  22141. }
  22142. if m.updated_at != nil {
  22143. fields = append(fields, payrecharge.FieldUpdatedAt)
  22144. }
  22145. if m.deleted_at != nil {
  22146. fields = append(fields, payrecharge.FieldDeletedAt)
  22147. }
  22148. if m.user_id != nil {
  22149. fields = append(fields, payrecharge.FieldUserID)
  22150. }
  22151. if m.number != nil {
  22152. fields = append(fields, payrecharge.FieldNumber)
  22153. }
  22154. if m.status != nil {
  22155. fields = append(fields, payrecharge.FieldStatus)
  22156. }
  22157. if m.money != nil {
  22158. fields = append(fields, payrecharge.FieldMoney)
  22159. }
  22160. if m.out_trade_no != nil {
  22161. fields = append(fields, payrecharge.FieldOutTradeNo)
  22162. }
  22163. if m.organization_id != nil {
  22164. fields = append(fields, payrecharge.FieldOrganizationID)
  22165. }
  22166. return fields
  22167. }
  22168. // Field returns the value of a field with the given name. The second boolean
  22169. // return value indicates that this field was not set, or was not defined in the
  22170. // schema.
  22171. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  22172. switch name {
  22173. case payrecharge.FieldCreatedAt:
  22174. return m.CreatedAt()
  22175. case payrecharge.FieldUpdatedAt:
  22176. return m.UpdatedAt()
  22177. case payrecharge.FieldDeletedAt:
  22178. return m.DeletedAt()
  22179. case payrecharge.FieldUserID:
  22180. return m.UserID()
  22181. case payrecharge.FieldNumber:
  22182. return m.Number()
  22183. case payrecharge.FieldStatus:
  22184. return m.Status()
  22185. case payrecharge.FieldMoney:
  22186. return m.Money()
  22187. case payrecharge.FieldOutTradeNo:
  22188. return m.OutTradeNo()
  22189. case payrecharge.FieldOrganizationID:
  22190. return m.OrganizationID()
  22191. }
  22192. return nil, false
  22193. }
  22194. // OldField returns the old value of the field from the database. An error is
  22195. // returned if the mutation operation is not UpdateOne, or the query to the
  22196. // database failed.
  22197. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22198. switch name {
  22199. case payrecharge.FieldCreatedAt:
  22200. return m.OldCreatedAt(ctx)
  22201. case payrecharge.FieldUpdatedAt:
  22202. return m.OldUpdatedAt(ctx)
  22203. case payrecharge.FieldDeletedAt:
  22204. return m.OldDeletedAt(ctx)
  22205. case payrecharge.FieldUserID:
  22206. return m.OldUserID(ctx)
  22207. case payrecharge.FieldNumber:
  22208. return m.OldNumber(ctx)
  22209. case payrecharge.FieldStatus:
  22210. return m.OldStatus(ctx)
  22211. case payrecharge.FieldMoney:
  22212. return m.OldMoney(ctx)
  22213. case payrecharge.FieldOutTradeNo:
  22214. return m.OldOutTradeNo(ctx)
  22215. case payrecharge.FieldOrganizationID:
  22216. return m.OldOrganizationID(ctx)
  22217. }
  22218. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  22219. }
  22220. // SetField sets the value of a field with the given name. It returns an error if
  22221. // the field is not defined in the schema, or if the type mismatched the field
  22222. // type.
  22223. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  22224. switch name {
  22225. case payrecharge.FieldCreatedAt:
  22226. v, ok := value.(time.Time)
  22227. if !ok {
  22228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22229. }
  22230. m.SetCreatedAt(v)
  22231. return nil
  22232. case payrecharge.FieldUpdatedAt:
  22233. v, ok := value.(time.Time)
  22234. if !ok {
  22235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22236. }
  22237. m.SetUpdatedAt(v)
  22238. return nil
  22239. case payrecharge.FieldDeletedAt:
  22240. v, ok := value.(time.Time)
  22241. if !ok {
  22242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22243. }
  22244. m.SetDeletedAt(v)
  22245. return nil
  22246. case payrecharge.FieldUserID:
  22247. v, ok := value.(string)
  22248. if !ok {
  22249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22250. }
  22251. m.SetUserID(v)
  22252. return nil
  22253. case payrecharge.FieldNumber:
  22254. v, ok := value.(float32)
  22255. if !ok {
  22256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22257. }
  22258. m.SetNumber(v)
  22259. return nil
  22260. case payrecharge.FieldStatus:
  22261. v, ok := value.(int)
  22262. if !ok {
  22263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22264. }
  22265. m.SetStatus(v)
  22266. return nil
  22267. case payrecharge.FieldMoney:
  22268. v, ok := value.(float32)
  22269. if !ok {
  22270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22271. }
  22272. m.SetMoney(v)
  22273. return nil
  22274. case payrecharge.FieldOutTradeNo:
  22275. v, ok := value.(string)
  22276. if !ok {
  22277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22278. }
  22279. m.SetOutTradeNo(v)
  22280. return nil
  22281. case payrecharge.FieldOrganizationID:
  22282. v, ok := value.(uint64)
  22283. if !ok {
  22284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22285. }
  22286. m.SetOrganizationID(v)
  22287. return nil
  22288. }
  22289. return fmt.Errorf("unknown PayRecharge field %s", name)
  22290. }
  22291. // AddedFields returns all numeric fields that were incremented/decremented during
  22292. // this mutation.
  22293. func (m *PayRechargeMutation) AddedFields() []string {
  22294. var fields []string
  22295. if m.addnumber != nil {
  22296. fields = append(fields, payrecharge.FieldNumber)
  22297. }
  22298. if m.addstatus != nil {
  22299. fields = append(fields, payrecharge.FieldStatus)
  22300. }
  22301. if m.addmoney != nil {
  22302. fields = append(fields, payrecharge.FieldMoney)
  22303. }
  22304. if m.addorganization_id != nil {
  22305. fields = append(fields, payrecharge.FieldOrganizationID)
  22306. }
  22307. return fields
  22308. }
  22309. // AddedField returns the numeric value that was incremented/decremented on a field
  22310. // with the given name. The second boolean return value indicates that this field
  22311. // was not set, or was not defined in the schema.
  22312. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  22313. switch name {
  22314. case payrecharge.FieldNumber:
  22315. return m.AddedNumber()
  22316. case payrecharge.FieldStatus:
  22317. return m.AddedStatus()
  22318. case payrecharge.FieldMoney:
  22319. return m.AddedMoney()
  22320. case payrecharge.FieldOrganizationID:
  22321. return m.AddedOrganizationID()
  22322. }
  22323. return nil, false
  22324. }
  22325. // AddField adds the value to the field with the given name. It returns an error if
  22326. // the field is not defined in the schema, or if the type mismatched the field
  22327. // type.
  22328. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  22329. switch name {
  22330. case payrecharge.FieldNumber:
  22331. v, ok := value.(float32)
  22332. if !ok {
  22333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22334. }
  22335. m.AddNumber(v)
  22336. return nil
  22337. case payrecharge.FieldStatus:
  22338. v, ok := value.(int)
  22339. if !ok {
  22340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22341. }
  22342. m.AddStatus(v)
  22343. return nil
  22344. case payrecharge.FieldMoney:
  22345. v, ok := value.(float32)
  22346. if !ok {
  22347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22348. }
  22349. m.AddMoney(v)
  22350. return nil
  22351. case payrecharge.FieldOrganizationID:
  22352. v, ok := value.(int64)
  22353. if !ok {
  22354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22355. }
  22356. m.AddOrganizationID(v)
  22357. return nil
  22358. }
  22359. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  22360. }
  22361. // ClearedFields returns all nullable fields that were cleared during this
  22362. // mutation.
  22363. func (m *PayRechargeMutation) ClearedFields() []string {
  22364. var fields []string
  22365. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  22366. fields = append(fields, payrecharge.FieldDeletedAt)
  22367. }
  22368. if m.FieldCleared(payrecharge.FieldStatus) {
  22369. fields = append(fields, payrecharge.FieldStatus)
  22370. }
  22371. if m.FieldCleared(payrecharge.FieldMoney) {
  22372. fields = append(fields, payrecharge.FieldMoney)
  22373. }
  22374. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  22375. fields = append(fields, payrecharge.FieldOutTradeNo)
  22376. }
  22377. return fields
  22378. }
  22379. // FieldCleared returns a boolean indicating if a field with the given name was
  22380. // cleared in this mutation.
  22381. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  22382. _, ok := m.clearedFields[name]
  22383. return ok
  22384. }
  22385. // ClearField clears the value of the field with the given name. It returns an
  22386. // error if the field is not defined in the schema.
  22387. func (m *PayRechargeMutation) ClearField(name string) error {
  22388. switch name {
  22389. case payrecharge.FieldDeletedAt:
  22390. m.ClearDeletedAt()
  22391. return nil
  22392. case payrecharge.FieldStatus:
  22393. m.ClearStatus()
  22394. return nil
  22395. case payrecharge.FieldMoney:
  22396. m.ClearMoney()
  22397. return nil
  22398. case payrecharge.FieldOutTradeNo:
  22399. m.ClearOutTradeNo()
  22400. return nil
  22401. }
  22402. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  22403. }
  22404. // ResetField resets all changes in the mutation for the field with the given name.
  22405. // It returns an error if the field is not defined in the schema.
  22406. func (m *PayRechargeMutation) ResetField(name string) error {
  22407. switch name {
  22408. case payrecharge.FieldCreatedAt:
  22409. m.ResetCreatedAt()
  22410. return nil
  22411. case payrecharge.FieldUpdatedAt:
  22412. m.ResetUpdatedAt()
  22413. return nil
  22414. case payrecharge.FieldDeletedAt:
  22415. m.ResetDeletedAt()
  22416. return nil
  22417. case payrecharge.FieldUserID:
  22418. m.ResetUserID()
  22419. return nil
  22420. case payrecharge.FieldNumber:
  22421. m.ResetNumber()
  22422. return nil
  22423. case payrecharge.FieldStatus:
  22424. m.ResetStatus()
  22425. return nil
  22426. case payrecharge.FieldMoney:
  22427. m.ResetMoney()
  22428. return nil
  22429. case payrecharge.FieldOutTradeNo:
  22430. m.ResetOutTradeNo()
  22431. return nil
  22432. case payrecharge.FieldOrganizationID:
  22433. m.ResetOrganizationID()
  22434. return nil
  22435. }
  22436. return fmt.Errorf("unknown PayRecharge field %s", name)
  22437. }
  22438. // AddedEdges returns all edge names that were set/added in this mutation.
  22439. func (m *PayRechargeMutation) AddedEdges() []string {
  22440. edges := make([]string, 0, 0)
  22441. return edges
  22442. }
  22443. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22444. // name in this mutation.
  22445. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  22446. return nil
  22447. }
  22448. // RemovedEdges returns all edge names that were removed in this mutation.
  22449. func (m *PayRechargeMutation) RemovedEdges() []string {
  22450. edges := make([]string, 0, 0)
  22451. return edges
  22452. }
  22453. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22454. // the given name in this mutation.
  22455. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  22456. return nil
  22457. }
  22458. // ClearedEdges returns all edge names that were cleared in this mutation.
  22459. func (m *PayRechargeMutation) ClearedEdges() []string {
  22460. edges := make([]string, 0, 0)
  22461. return edges
  22462. }
  22463. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22464. // was cleared in this mutation.
  22465. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  22466. return false
  22467. }
  22468. // ClearEdge clears the value of the edge with the given name. It returns an error
  22469. // if that edge is not defined in the schema.
  22470. func (m *PayRechargeMutation) ClearEdge(name string) error {
  22471. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  22472. }
  22473. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22474. // It returns an error if the edge is not defined in the schema.
  22475. func (m *PayRechargeMutation) ResetEdge(name string) error {
  22476. return fmt.Errorf("unknown PayRecharge edge %s", name)
  22477. }
  22478. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  22479. type ServerMutation struct {
  22480. config
  22481. op Op
  22482. typ string
  22483. id *uint64
  22484. created_at *time.Time
  22485. updated_at *time.Time
  22486. status *uint8
  22487. addstatus *int8
  22488. deleted_at *time.Time
  22489. name *string
  22490. public_ip *string
  22491. private_ip *string
  22492. admin_port *string
  22493. clearedFields map[string]struct{}
  22494. wxs map[uint64]struct{}
  22495. removedwxs map[uint64]struct{}
  22496. clearedwxs bool
  22497. done bool
  22498. oldValue func(context.Context) (*Server, error)
  22499. predicates []predicate.Server
  22500. }
  22501. var _ ent.Mutation = (*ServerMutation)(nil)
  22502. // serverOption allows management of the mutation configuration using functional options.
  22503. type serverOption func(*ServerMutation)
  22504. // newServerMutation creates new mutation for the Server entity.
  22505. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  22506. m := &ServerMutation{
  22507. config: c,
  22508. op: op,
  22509. typ: TypeServer,
  22510. clearedFields: make(map[string]struct{}),
  22511. }
  22512. for _, opt := range opts {
  22513. opt(m)
  22514. }
  22515. return m
  22516. }
  22517. // withServerID sets the ID field of the mutation.
  22518. func withServerID(id uint64) serverOption {
  22519. return func(m *ServerMutation) {
  22520. var (
  22521. err error
  22522. once sync.Once
  22523. value *Server
  22524. )
  22525. m.oldValue = func(ctx context.Context) (*Server, error) {
  22526. once.Do(func() {
  22527. if m.done {
  22528. err = errors.New("querying old values post mutation is not allowed")
  22529. } else {
  22530. value, err = m.Client().Server.Get(ctx, id)
  22531. }
  22532. })
  22533. return value, err
  22534. }
  22535. m.id = &id
  22536. }
  22537. }
  22538. // withServer sets the old Server of the mutation.
  22539. func withServer(node *Server) serverOption {
  22540. return func(m *ServerMutation) {
  22541. m.oldValue = func(context.Context) (*Server, error) {
  22542. return node, nil
  22543. }
  22544. m.id = &node.ID
  22545. }
  22546. }
  22547. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22548. // executed in a transaction (ent.Tx), a transactional client is returned.
  22549. func (m ServerMutation) Client() *Client {
  22550. client := &Client{config: m.config}
  22551. client.init()
  22552. return client
  22553. }
  22554. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22555. // it returns an error otherwise.
  22556. func (m ServerMutation) Tx() (*Tx, error) {
  22557. if _, ok := m.driver.(*txDriver); !ok {
  22558. return nil, errors.New("ent: mutation is not running in a transaction")
  22559. }
  22560. tx := &Tx{config: m.config}
  22561. tx.init()
  22562. return tx, nil
  22563. }
  22564. // SetID sets the value of the id field. Note that this
  22565. // operation is only accepted on creation of Server entities.
  22566. func (m *ServerMutation) SetID(id uint64) {
  22567. m.id = &id
  22568. }
  22569. // ID returns the ID value in the mutation. Note that the ID is only available
  22570. // if it was provided to the builder or after it was returned from the database.
  22571. func (m *ServerMutation) ID() (id uint64, exists bool) {
  22572. if m.id == nil {
  22573. return
  22574. }
  22575. return *m.id, true
  22576. }
  22577. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22578. // That means, if the mutation is applied within a transaction with an isolation level such
  22579. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22580. // or updated by the mutation.
  22581. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  22582. switch {
  22583. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22584. id, exists := m.ID()
  22585. if exists {
  22586. return []uint64{id}, nil
  22587. }
  22588. fallthrough
  22589. case m.op.Is(OpUpdate | OpDelete):
  22590. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  22591. default:
  22592. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22593. }
  22594. }
  22595. // SetCreatedAt sets the "created_at" field.
  22596. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  22597. m.created_at = &t
  22598. }
  22599. // CreatedAt returns the value of the "created_at" field in the mutation.
  22600. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  22601. v := m.created_at
  22602. if v == nil {
  22603. return
  22604. }
  22605. return *v, true
  22606. }
  22607. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  22608. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22610. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22611. if !m.op.Is(OpUpdateOne) {
  22612. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22613. }
  22614. if m.id == nil || m.oldValue == nil {
  22615. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22616. }
  22617. oldValue, err := m.oldValue(ctx)
  22618. if err != nil {
  22619. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22620. }
  22621. return oldValue.CreatedAt, nil
  22622. }
  22623. // ResetCreatedAt resets all changes to the "created_at" field.
  22624. func (m *ServerMutation) ResetCreatedAt() {
  22625. m.created_at = nil
  22626. }
  22627. // SetUpdatedAt sets the "updated_at" field.
  22628. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  22629. m.updated_at = &t
  22630. }
  22631. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22632. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  22633. v := m.updated_at
  22634. if v == nil {
  22635. return
  22636. }
  22637. return *v, true
  22638. }
  22639. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  22640. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22642. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22643. if !m.op.Is(OpUpdateOne) {
  22644. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22645. }
  22646. if m.id == nil || m.oldValue == nil {
  22647. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22648. }
  22649. oldValue, err := m.oldValue(ctx)
  22650. if err != nil {
  22651. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22652. }
  22653. return oldValue.UpdatedAt, nil
  22654. }
  22655. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22656. func (m *ServerMutation) ResetUpdatedAt() {
  22657. m.updated_at = nil
  22658. }
  22659. // SetStatus sets the "status" field.
  22660. func (m *ServerMutation) SetStatus(u uint8) {
  22661. m.status = &u
  22662. m.addstatus = nil
  22663. }
  22664. // Status returns the value of the "status" field in the mutation.
  22665. func (m *ServerMutation) Status() (r uint8, exists bool) {
  22666. v := m.status
  22667. if v == nil {
  22668. return
  22669. }
  22670. return *v, true
  22671. }
  22672. // OldStatus returns the old "status" field's value of the Server entity.
  22673. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22675. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22676. if !m.op.Is(OpUpdateOne) {
  22677. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22678. }
  22679. if m.id == nil || m.oldValue == nil {
  22680. return v, errors.New("OldStatus requires an ID field in the mutation")
  22681. }
  22682. oldValue, err := m.oldValue(ctx)
  22683. if err != nil {
  22684. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22685. }
  22686. return oldValue.Status, nil
  22687. }
  22688. // AddStatus adds u to the "status" field.
  22689. func (m *ServerMutation) AddStatus(u int8) {
  22690. if m.addstatus != nil {
  22691. *m.addstatus += u
  22692. } else {
  22693. m.addstatus = &u
  22694. }
  22695. }
  22696. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22697. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  22698. v := m.addstatus
  22699. if v == nil {
  22700. return
  22701. }
  22702. return *v, true
  22703. }
  22704. // ClearStatus clears the value of the "status" field.
  22705. func (m *ServerMutation) ClearStatus() {
  22706. m.status = nil
  22707. m.addstatus = nil
  22708. m.clearedFields[server.FieldStatus] = struct{}{}
  22709. }
  22710. // StatusCleared returns if the "status" field was cleared in this mutation.
  22711. func (m *ServerMutation) StatusCleared() bool {
  22712. _, ok := m.clearedFields[server.FieldStatus]
  22713. return ok
  22714. }
  22715. // ResetStatus resets all changes to the "status" field.
  22716. func (m *ServerMutation) ResetStatus() {
  22717. m.status = nil
  22718. m.addstatus = nil
  22719. delete(m.clearedFields, server.FieldStatus)
  22720. }
  22721. // SetDeletedAt sets the "deleted_at" field.
  22722. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  22723. m.deleted_at = &t
  22724. }
  22725. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22726. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  22727. v := m.deleted_at
  22728. if v == nil {
  22729. return
  22730. }
  22731. return *v, true
  22732. }
  22733. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  22734. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22736. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22737. if !m.op.Is(OpUpdateOne) {
  22738. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22739. }
  22740. if m.id == nil || m.oldValue == nil {
  22741. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22742. }
  22743. oldValue, err := m.oldValue(ctx)
  22744. if err != nil {
  22745. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22746. }
  22747. return oldValue.DeletedAt, nil
  22748. }
  22749. // ClearDeletedAt clears the value of the "deleted_at" field.
  22750. func (m *ServerMutation) ClearDeletedAt() {
  22751. m.deleted_at = nil
  22752. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  22753. }
  22754. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22755. func (m *ServerMutation) DeletedAtCleared() bool {
  22756. _, ok := m.clearedFields[server.FieldDeletedAt]
  22757. return ok
  22758. }
  22759. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22760. func (m *ServerMutation) ResetDeletedAt() {
  22761. m.deleted_at = nil
  22762. delete(m.clearedFields, server.FieldDeletedAt)
  22763. }
  22764. // SetName sets the "name" field.
  22765. func (m *ServerMutation) SetName(s string) {
  22766. m.name = &s
  22767. }
  22768. // Name returns the value of the "name" field in the mutation.
  22769. func (m *ServerMutation) Name() (r string, exists bool) {
  22770. v := m.name
  22771. if v == nil {
  22772. return
  22773. }
  22774. return *v, true
  22775. }
  22776. // OldName returns the old "name" field's value of the Server entity.
  22777. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22779. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  22780. if !m.op.Is(OpUpdateOne) {
  22781. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22782. }
  22783. if m.id == nil || m.oldValue == nil {
  22784. return v, errors.New("OldName requires an ID field in the mutation")
  22785. }
  22786. oldValue, err := m.oldValue(ctx)
  22787. if err != nil {
  22788. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22789. }
  22790. return oldValue.Name, nil
  22791. }
  22792. // ResetName resets all changes to the "name" field.
  22793. func (m *ServerMutation) ResetName() {
  22794. m.name = nil
  22795. }
  22796. // SetPublicIP sets the "public_ip" field.
  22797. func (m *ServerMutation) SetPublicIP(s string) {
  22798. m.public_ip = &s
  22799. }
  22800. // PublicIP returns the value of the "public_ip" field in the mutation.
  22801. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  22802. v := m.public_ip
  22803. if v == nil {
  22804. return
  22805. }
  22806. return *v, true
  22807. }
  22808. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  22809. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22811. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  22812. if !m.op.Is(OpUpdateOne) {
  22813. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  22814. }
  22815. if m.id == nil || m.oldValue == nil {
  22816. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  22817. }
  22818. oldValue, err := m.oldValue(ctx)
  22819. if err != nil {
  22820. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  22821. }
  22822. return oldValue.PublicIP, nil
  22823. }
  22824. // ResetPublicIP resets all changes to the "public_ip" field.
  22825. func (m *ServerMutation) ResetPublicIP() {
  22826. m.public_ip = nil
  22827. }
  22828. // SetPrivateIP sets the "private_ip" field.
  22829. func (m *ServerMutation) SetPrivateIP(s string) {
  22830. m.private_ip = &s
  22831. }
  22832. // PrivateIP returns the value of the "private_ip" field in the mutation.
  22833. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  22834. v := m.private_ip
  22835. if v == nil {
  22836. return
  22837. }
  22838. return *v, true
  22839. }
  22840. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  22841. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22843. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  22844. if !m.op.Is(OpUpdateOne) {
  22845. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  22846. }
  22847. if m.id == nil || m.oldValue == nil {
  22848. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  22849. }
  22850. oldValue, err := m.oldValue(ctx)
  22851. if err != nil {
  22852. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  22853. }
  22854. return oldValue.PrivateIP, nil
  22855. }
  22856. // ResetPrivateIP resets all changes to the "private_ip" field.
  22857. func (m *ServerMutation) ResetPrivateIP() {
  22858. m.private_ip = nil
  22859. }
  22860. // SetAdminPort sets the "admin_port" field.
  22861. func (m *ServerMutation) SetAdminPort(s string) {
  22862. m.admin_port = &s
  22863. }
  22864. // AdminPort returns the value of the "admin_port" field in the mutation.
  22865. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  22866. v := m.admin_port
  22867. if v == nil {
  22868. return
  22869. }
  22870. return *v, true
  22871. }
  22872. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  22873. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22875. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  22876. if !m.op.Is(OpUpdateOne) {
  22877. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  22878. }
  22879. if m.id == nil || m.oldValue == nil {
  22880. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  22881. }
  22882. oldValue, err := m.oldValue(ctx)
  22883. if err != nil {
  22884. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  22885. }
  22886. return oldValue.AdminPort, nil
  22887. }
  22888. // ResetAdminPort resets all changes to the "admin_port" field.
  22889. func (m *ServerMutation) ResetAdminPort() {
  22890. m.admin_port = nil
  22891. }
  22892. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  22893. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  22894. if m.wxs == nil {
  22895. m.wxs = make(map[uint64]struct{})
  22896. }
  22897. for i := range ids {
  22898. m.wxs[ids[i]] = struct{}{}
  22899. }
  22900. }
  22901. // ClearWxs clears the "wxs" edge to the Wx entity.
  22902. func (m *ServerMutation) ClearWxs() {
  22903. m.clearedwxs = true
  22904. }
  22905. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  22906. func (m *ServerMutation) WxsCleared() bool {
  22907. return m.clearedwxs
  22908. }
  22909. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  22910. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  22911. if m.removedwxs == nil {
  22912. m.removedwxs = make(map[uint64]struct{})
  22913. }
  22914. for i := range ids {
  22915. delete(m.wxs, ids[i])
  22916. m.removedwxs[ids[i]] = struct{}{}
  22917. }
  22918. }
  22919. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  22920. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  22921. for id := range m.removedwxs {
  22922. ids = append(ids, id)
  22923. }
  22924. return
  22925. }
  22926. // WxsIDs returns the "wxs" edge IDs in the mutation.
  22927. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  22928. for id := range m.wxs {
  22929. ids = append(ids, id)
  22930. }
  22931. return
  22932. }
  22933. // ResetWxs resets all changes to the "wxs" edge.
  22934. func (m *ServerMutation) ResetWxs() {
  22935. m.wxs = nil
  22936. m.clearedwxs = false
  22937. m.removedwxs = nil
  22938. }
  22939. // Where appends a list predicates to the ServerMutation builder.
  22940. func (m *ServerMutation) Where(ps ...predicate.Server) {
  22941. m.predicates = append(m.predicates, ps...)
  22942. }
  22943. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  22944. // users can use type-assertion to append predicates that do not depend on any generated package.
  22945. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  22946. p := make([]predicate.Server, len(ps))
  22947. for i := range ps {
  22948. p[i] = ps[i]
  22949. }
  22950. m.Where(p...)
  22951. }
  22952. // Op returns the operation name.
  22953. func (m *ServerMutation) Op() Op {
  22954. return m.op
  22955. }
  22956. // SetOp allows setting the mutation operation.
  22957. func (m *ServerMutation) SetOp(op Op) {
  22958. m.op = op
  22959. }
  22960. // Type returns the node type of this mutation (Server).
  22961. func (m *ServerMutation) Type() string {
  22962. return m.typ
  22963. }
  22964. // Fields returns all fields that were changed during this mutation. Note that in
  22965. // order to get all numeric fields that were incremented/decremented, call
  22966. // AddedFields().
  22967. func (m *ServerMutation) Fields() []string {
  22968. fields := make([]string, 0, 8)
  22969. if m.created_at != nil {
  22970. fields = append(fields, server.FieldCreatedAt)
  22971. }
  22972. if m.updated_at != nil {
  22973. fields = append(fields, server.FieldUpdatedAt)
  22974. }
  22975. if m.status != nil {
  22976. fields = append(fields, server.FieldStatus)
  22977. }
  22978. if m.deleted_at != nil {
  22979. fields = append(fields, server.FieldDeletedAt)
  22980. }
  22981. if m.name != nil {
  22982. fields = append(fields, server.FieldName)
  22983. }
  22984. if m.public_ip != nil {
  22985. fields = append(fields, server.FieldPublicIP)
  22986. }
  22987. if m.private_ip != nil {
  22988. fields = append(fields, server.FieldPrivateIP)
  22989. }
  22990. if m.admin_port != nil {
  22991. fields = append(fields, server.FieldAdminPort)
  22992. }
  22993. return fields
  22994. }
  22995. // Field returns the value of a field with the given name. The second boolean
  22996. // return value indicates that this field was not set, or was not defined in the
  22997. // schema.
  22998. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  22999. switch name {
  23000. case server.FieldCreatedAt:
  23001. return m.CreatedAt()
  23002. case server.FieldUpdatedAt:
  23003. return m.UpdatedAt()
  23004. case server.FieldStatus:
  23005. return m.Status()
  23006. case server.FieldDeletedAt:
  23007. return m.DeletedAt()
  23008. case server.FieldName:
  23009. return m.Name()
  23010. case server.FieldPublicIP:
  23011. return m.PublicIP()
  23012. case server.FieldPrivateIP:
  23013. return m.PrivateIP()
  23014. case server.FieldAdminPort:
  23015. return m.AdminPort()
  23016. }
  23017. return nil, false
  23018. }
  23019. // OldField returns the old value of the field from the database. An error is
  23020. // returned if the mutation operation is not UpdateOne, or the query to the
  23021. // database failed.
  23022. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23023. switch name {
  23024. case server.FieldCreatedAt:
  23025. return m.OldCreatedAt(ctx)
  23026. case server.FieldUpdatedAt:
  23027. return m.OldUpdatedAt(ctx)
  23028. case server.FieldStatus:
  23029. return m.OldStatus(ctx)
  23030. case server.FieldDeletedAt:
  23031. return m.OldDeletedAt(ctx)
  23032. case server.FieldName:
  23033. return m.OldName(ctx)
  23034. case server.FieldPublicIP:
  23035. return m.OldPublicIP(ctx)
  23036. case server.FieldPrivateIP:
  23037. return m.OldPrivateIP(ctx)
  23038. case server.FieldAdminPort:
  23039. return m.OldAdminPort(ctx)
  23040. }
  23041. return nil, fmt.Errorf("unknown Server field %s", name)
  23042. }
  23043. // SetField sets the value of a field with the given name. It returns an error if
  23044. // the field is not defined in the schema, or if the type mismatched the field
  23045. // type.
  23046. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  23047. switch name {
  23048. case server.FieldCreatedAt:
  23049. v, ok := value.(time.Time)
  23050. if !ok {
  23051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23052. }
  23053. m.SetCreatedAt(v)
  23054. return nil
  23055. case server.FieldUpdatedAt:
  23056. v, ok := value.(time.Time)
  23057. if !ok {
  23058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23059. }
  23060. m.SetUpdatedAt(v)
  23061. return nil
  23062. case server.FieldStatus:
  23063. v, ok := value.(uint8)
  23064. if !ok {
  23065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23066. }
  23067. m.SetStatus(v)
  23068. return nil
  23069. case server.FieldDeletedAt:
  23070. v, ok := value.(time.Time)
  23071. if !ok {
  23072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23073. }
  23074. m.SetDeletedAt(v)
  23075. return nil
  23076. case server.FieldName:
  23077. v, ok := value.(string)
  23078. if !ok {
  23079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23080. }
  23081. m.SetName(v)
  23082. return nil
  23083. case server.FieldPublicIP:
  23084. v, ok := value.(string)
  23085. if !ok {
  23086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23087. }
  23088. m.SetPublicIP(v)
  23089. return nil
  23090. case server.FieldPrivateIP:
  23091. v, ok := value.(string)
  23092. if !ok {
  23093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23094. }
  23095. m.SetPrivateIP(v)
  23096. return nil
  23097. case server.FieldAdminPort:
  23098. v, ok := value.(string)
  23099. if !ok {
  23100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23101. }
  23102. m.SetAdminPort(v)
  23103. return nil
  23104. }
  23105. return fmt.Errorf("unknown Server field %s", name)
  23106. }
  23107. // AddedFields returns all numeric fields that were incremented/decremented during
  23108. // this mutation.
  23109. func (m *ServerMutation) AddedFields() []string {
  23110. var fields []string
  23111. if m.addstatus != nil {
  23112. fields = append(fields, server.FieldStatus)
  23113. }
  23114. return fields
  23115. }
  23116. // AddedField returns the numeric value that was incremented/decremented on a field
  23117. // with the given name. The second boolean return value indicates that this field
  23118. // was not set, or was not defined in the schema.
  23119. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  23120. switch name {
  23121. case server.FieldStatus:
  23122. return m.AddedStatus()
  23123. }
  23124. return nil, false
  23125. }
  23126. // AddField adds the value to the field with the given name. It returns an error if
  23127. // the field is not defined in the schema, or if the type mismatched the field
  23128. // type.
  23129. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  23130. switch name {
  23131. case server.FieldStatus:
  23132. v, ok := value.(int8)
  23133. if !ok {
  23134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23135. }
  23136. m.AddStatus(v)
  23137. return nil
  23138. }
  23139. return fmt.Errorf("unknown Server numeric field %s", name)
  23140. }
  23141. // ClearedFields returns all nullable fields that were cleared during this
  23142. // mutation.
  23143. func (m *ServerMutation) ClearedFields() []string {
  23144. var fields []string
  23145. if m.FieldCleared(server.FieldStatus) {
  23146. fields = append(fields, server.FieldStatus)
  23147. }
  23148. if m.FieldCleared(server.FieldDeletedAt) {
  23149. fields = append(fields, server.FieldDeletedAt)
  23150. }
  23151. return fields
  23152. }
  23153. // FieldCleared returns a boolean indicating if a field with the given name was
  23154. // cleared in this mutation.
  23155. func (m *ServerMutation) FieldCleared(name string) bool {
  23156. _, ok := m.clearedFields[name]
  23157. return ok
  23158. }
  23159. // ClearField clears the value of the field with the given name. It returns an
  23160. // error if the field is not defined in the schema.
  23161. func (m *ServerMutation) ClearField(name string) error {
  23162. switch name {
  23163. case server.FieldStatus:
  23164. m.ClearStatus()
  23165. return nil
  23166. case server.FieldDeletedAt:
  23167. m.ClearDeletedAt()
  23168. return nil
  23169. }
  23170. return fmt.Errorf("unknown Server nullable field %s", name)
  23171. }
  23172. // ResetField resets all changes in the mutation for the field with the given name.
  23173. // It returns an error if the field is not defined in the schema.
  23174. func (m *ServerMutation) ResetField(name string) error {
  23175. switch name {
  23176. case server.FieldCreatedAt:
  23177. m.ResetCreatedAt()
  23178. return nil
  23179. case server.FieldUpdatedAt:
  23180. m.ResetUpdatedAt()
  23181. return nil
  23182. case server.FieldStatus:
  23183. m.ResetStatus()
  23184. return nil
  23185. case server.FieldDeletedAt:
  23186. m.ResetDeletedAt()
  23187. return nil
  23188. case server.FieldName:
  23189. m.ResetName()
  23190. return nil
  23191. case server.FieldPublicIP:
  23192. m.ResetPublicIP()
  23193. return nil
  23194. case server.FieldPrivateIP:
  23195. m.ResetPrivateIP()
  23196. return nil
  23197. case server.FieldAdminPort:
  23198. m.ResetAdminPort()
  23199. return nil
  23200. }
  23201. return fmt.Errorf("unknown Server field %s", name)
  23202. }
  23203. // AddedEdges returns all edge names that were set/added in this mutation.
  23204. func (m *ServerMutation) AddedEdges() []string {
  23205. edges := make([]string, 0, 1)
  23206. if m.wxs != nil {
  23207. edges = append(edges, server.EdgeWxs)
  23208. }
  23209. return edges
  23210. }
  23211. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23212. // name in this mutation.
  23213. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  23214. switch name {
  23215. case server.EdgeWxs:
  23216. ids := make([]ent.Value, 0, len(m.wxs))
  23217. for id := range m.wxs {
  23218. ids = append(ids, id)
  23219. }
  23220. return ids
  23221. }
  23222. return nil
  23223. }
  23224. // RemovedEdges returns all edge names that were removed in this mutation.
  23225. func (m *ServerMutation) RemovedEdges() []string {
  23226. edges := make([]string, 0, 1)
  23227. if m.removedwxs != nil {
  23228. edges = append(edges, server.EdgeWxs)
  23229. }
  23230. return edges
  23231. }
  23232. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23233. // the given name in this mutation.
  23234. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  23235. switch name {
  23236. case server.EdgeWxs:
  23237. ids := make([]ent.Value, 0, len(m.removedwxs))
  23238. for id := range m.removedwxs {
  23239. ids = append(ids, id)
  23240. }
  23241. return ids
  23242. }
  23243. return nil
  23244. }
  23245. // ClearedEdges returns all edge names that were cleared in this mutation.
  23246. func (m *ServerMutation) ClearedEdges() []string {
  23247. edges := make([]string, 0, 1)
  23248. if m.clearedwxs {
  23249. edges = append(edges, server.EdgeWxs)
  23250. }
  23251. return edges
  23252. }
  23253. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23254. // was cleared in this mutation.
  23255. func (m *ServerMutation) EdgeCleared(name string) bool {
  23256. switch name {
  23257. case server.EdgeWxs:
  23258. return m.clearedwxs
  23259. }
  23260. return false
  23261. }
  23262. // ClearEdge clears the value of the edge with the given name. It returns an error
  23263. // if that edge is not defined in the schema.
  23264. func (m *ServerMutation) ClearEdge(name string) error {
  23265. switch name {
  23266. }
  23267. return fmt.Errorf("unknown Server unique edge %s", name)
  23268. }
  23269. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23270. // It returns an error if the edge is not defined in the schema.
  23271. func (m *ServerMutation) ResetEdge(name string) error {
  23272. switch name {
  23273. case server.EdgeWxs:
  23274. m.ResetWxs()
  23275. return nil
  23276. }
  23277. return fmt.Errorf("unknown Server edge %s", name)
  23278. }
  23279. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  23280. type SopNodeMutation struct {
  23281. config
  23282. op Op
  23283. typ string
  23284. id *uint64
  23285. created_at *time.Time
  23286. updated_at *time.Time
  23287. status *uint8
  23288. addstatus *int8
  23289. deleted_at *time.Time
  23290. parent_id *uint64
  23291. addparent_id *int64
  23292. name *string
  23293. condition_type *int
  23294. addcondition_type *int
  23295. condition_list *[]string
  23296. appendcondition_list []string
  23297. no_reply_condition *uint64
  23298. addno_reply_condition *int64
  23299. no_reply_unit *string
  23300. action_message *[]custom_types.Action
  23301. appendaction_message []custom_types.Action
  23302. action_label_add *[]uint64
  23303. appendaction_label_add []uint64
  23304. action_label_del *[]uint64
  23305. appendaction_label_del []uint64
  23306. action_forward **custom_types.ActionForward
  23307. clearedFields map[string]struct{}
  23308. sop_stage *uint64
  23309. clearedsop_stage bool
  23310. node_messages map[uint64]struct{}
  23311. removednode_messages map[uint64]struct{}
  23312. clearednode_messages bool
  23313. done bool
  23314. oldValue func(context.Context) (*SopNode, error)
  23315. predicates []predicate.SopNode
  23316. }
  23317. var _ ent.Mutation = (*SopNodeMutation)(nil)
  23318. // sopnodeOption allows management of the mutation configuration using functional options.
  23319. type sopnodeOption func(*SopNodeMutation)
  23320. // newSopNodeMutation creates new mutation for the SopNode entity.
  23321. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  23322. m := &SopNodeMutation{
  23323. config: c,
  23324. op: op,
  23325. typ: TypeSopNode,
  23326. clearedFields: make(map[string]struct{}),
  23327. }
  23328. for _, opt := range opts {
  23329. opt(m)
  23330. }
  23331. return m
  23332. }
  23333. // withSopNodeID sets the ID field of the mutation.
  23334. func withSopNodeID(id uint64) sopnodeOption {
  23335. return func(m *SopNodeMutation) {
  23336. var (
  23337. err error
  23338. once sync.Once
  23339. value *SopNode
  23340. )
  23341. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  23342. once.Do(func() {
  23343. if m.done {
  23344. err = errors.New("querying old values post mutation is not allowed")
  23345. } else {
  23346. value, err = m.Client().SopNode.Get(ctx, id)
  23347. }
  23348. })
  23349. return value, err
  23350. }
  23351. m.id = &id
  23352. }
  23353. }
  23354. // withSopNode sets the old SopNode of the mutation.
  23355. func withSopNode(node *SopNode) sopnodeOption {
  23356. return func(m *SopNodeMutation) {
  23357. m.oldValue = func(context.Context) (*SopNode, error) {
  23358. return node, nil
  23359. }
  23360. m.id = &node.ID
  23361. }
  23362. }
  23363. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23364. // executed in a transaction (ent.Tx), a transactional client is returned.
  23365. func (m SopNodeMutation) Client() *Client {
  23366. client := &Client{config: m.config}
  23367. client.init()
  23368. return client
  23369. }
  23370. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23371. // it returns an error otherwise.
  23372. func (m SopNodeMutation) Tx() (*Tx, error) {
  23373. if _, ok := m.driver.(*txDriver); !ok {
  23374. return nil, errors.New("ent: mutation is not running in a transaction")
  23375. }
  23376. tx := &Tx{config: m.config}
  23377. tx.init()
  23378. return tx, nil
  23379. }
  23380. // SetID sets the value of the id field. Note that this
  23381. // operation is only accepted on creation of SopNode entities.
  23382. func (m *SopNodeMutation) SetID(id uint64) {
  23383. m.id = &id
  23384. }
  23385. // ID returns the ID value in the mutation. Note that the ID is only available
  23386. // if it was provided to the builder or after it was returned from the database.
  23387. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  23388. if m.id == nil {
  23389. return
  23390. }
  23391. return *m.id, true
  23392. }
  23393. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23394. // That means, if the mutation is applied within a transaction with an isolation level such
  23395. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23396. // or updated by the mutation.
  23397. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  23398. switch {
  23399. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23400. id, exists := m.ID()
  23401. if exists {
  23402. return []uint64{id}, nil
  23403. }
  23404. fallthrough
  23405. case m.op.Is(OpUpdate | OpDelete):
  23406. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  23407. default:
  23408. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23409. }
  23410. }
  23411. // SetCreatedAt sets the "created_at" field.
  23412. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  23413. m.created_at = &t
  23414. }
  23415. // CreatedAt returns the value of the "created_at" field in the mutation.
  23416. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  23417. v := m.created_at
  23418. if v == nil {
  23419. return
  23420. }
  23421. return *v, true
  23422. }
  23423. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  23424. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23426. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23427. if !m.op.Is(OpUpdateOne) {
  23428. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23429. }
  23430. if m.id == nil || m.oldValue == nil {
  23431. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23432. }
  23433. oldValue, err := m.oldValue(ctx)
  23434. if err != nil {
  23435. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23436. }
  23437. return oldValue.CreatedAt, nil
  23438. }
  23439. // ResetCreatedAt resets all changes to the "created_at" field.
  23440. func (m *SopNodeMutation) ResetCreatedAt() {
  23441. m.created_at = nil
  23442. }
  23443. // SetUpdatedAt sets the "updated_at" field.
  23444. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  23445. m.updated_at = &t
  23446. }
  23447. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23448. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  23449. v := m.updated_at
  23450. if v == nil {
  23451. return
  23452. }
  23453. return *v, true
  23454. }
  23455. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  23456. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23458. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23459. if !m.op.Is(OpUpdateOne) {
  23460. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23461. }
  23462. if m.id == nil || m.oldValue == nil {
  23463. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23464. }
  23465. oldValue, err := m.oldValue(ctx)
  23466. if err != nil {
  23467. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23468. }
  23469. return oldValue.UpdatedAt, nil
  23470. }
  23471. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23472. func (m *SopNodeMutation) ResetUpdatedAt() {
  23473. m.updated_at = nil
  23474. }
  23475. // SetStatus sets the "status" field.
  23476. func (m *SopNodeMutation) SetStatus(u uint8) {
  23477. m.status = &u
  23478. m.addstatus = nil
  23479. }
  23480. // Status returns the value of the "status" field in the mutation.
  23481. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  23482. v := m.status
  23483. if v == nil {
  23484. return
  23485. }
  23486. return *v, true
  23487. }
  23488. // OldStatus returns the old "status" field's value of the SopNode entity.
  23489. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23491. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23492. if !m.op.Is(OpUpdateOne) {
  23493. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23494. }
  23495. if m.id == nil || m.oldValue == nil {
  23496. return v, errors.New("OldStatus requires an ID field in the mutation")
  23497. }
  23498. oldValue, err := m.oldValue(ctx)
  23499. if err != nil {
  23500. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23501. }
  23502. return oldValue.Status, nil
  23503. }
  23504. // AddStatus adds u to the "status" field.
  23505. func (m *SopNodeMutation) AddStatus(u int8) {
  23506. if m.addstatus != nil {
  23507. *m.addstatus += u
  23508. } else {
  23509. m.addstatus = &u
  23510. }
  23511. }
  23512. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23513. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  23514. v := m.addstatus
  23515. if v == nil {
  23516. return
  23517. }
  23518. return *v, true
  23519. }
  23520. // ClearStatus clears the value of the "status" field.
  23521. func (m *SopNodeMutation) ClearStatus() {
  23522. m.status = nil
  23523. m.addstatus = nil
  23524. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  23525. }
  23526. // StatusCleared returns if the "status" field was cleared in this mutation.
  23527. func (m *SopNodeMutation) StatusCleared() bool {
  23528. _, ok := m.clearedFields[sopnode.FieldStatus]
  23529. return ok
  23530. }
  23531. // ResetStatus resets all changes to the "status" field.
  23532. func (m *SopNodeMutation) ResetStatus() {
  23533. m.status = nil
  23534. m.addstatus = nil
  23535. delete(m.clearedFields, sopnode.FieldStatus)
  23536. }
  23537. // SetDeletedAt sets the "deleted_at" field.
  23538. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  23539. m.deleted_at = &t
  23540. }
  23541. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23542. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  23543. v := m.deleted_at
  23544. if v == nil {
  23545. return
  23546. }
  23547. return *v, true
  23548. }
  23549. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  23550. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23552. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23553. if !m.op.Is(OpUpdateOne) {
  23554. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23555. }
  23556. if m.id == nil || m.oldValue == nil {
  23557. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23558. }
  23559. oldValue, err := m.oldValue(ctx)
  23560. if err != nil {
  23561. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23562. }
  23563. return oldValue.DeletedAt, nil
  23564. }
  23565. // ClearDeletedAt clears the value of the "deleted_at" field.
  23566. func (m *SopNodeMutation) ClearDeletedAt() {
  23567. m.deleted_at = nil
  23568. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  23569. }
  23570. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23571. func (m *SopNodeMutation) DeletedAtCleared() bool {
  23572. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  23573. return ok
  23574. }
  23575. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23576. func (m *SopNodeMutation) ResetDeletedAt() {
  23577. m.deleted_at = nil
  23578. delete(m.clearedFields, sopnode.FieldDeletedAt)
  23579. }
  23580. // SetStageID sets the "stage_id" field.
  23581. func (m *SopNodeMutation) SetStageID(u uint64) {
  23582. m.sop_stage = &u
  23583. }
  23584. // StageID returns the value of the "stage_id" field in the mutation.
  23585. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  23586. v := m.sop_stage
  23587. if v == nil {
  23588. return
  23589. }
  23590. return *v, true
  23591. }
  23592. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  23593. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23595. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  23596. if !m.op.Is(OpUpdateOne) {
  23597. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  23598. }
  23599. if m.id == nil || m.oldValue == nil {
  23600. return v, errors.New("OldStageID requires an ID field in the mutation")
  23601. }
  23602. oldValue, err := m.oldValue(ctx)
  23603. if err != nil {
  23604. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  23605. }
  23606. return oldValue.StageID, nil
  23607. }
  23608. // ResetStageID resets all changes to the "stage_id" field.
  23609. func (m *SopNodeMutation) ResetStageID() {
  23610. m.sop_stage = nil
  23611. }
  23612. // SetParentID sets the "parent_id" field.
  23613. func (m *SopNodeMutation) SetParentID(u uint64) {
  23614. m.parent_id = &u
  23615. m.addparent_id = nil
  23616. }
  23617. // ParentID returns the value of the "parent_id" field in the mutation.
  23618. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  23619. v := m.parent_id
  23620. if v == nil {
  23621. return
  23622. }
  23623. return *v, true
  23624. }
  23625. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  23626. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23628. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  23629. if !m.op.Is(OpUpdateOne) {
  23630. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  23631. }
  23632. if m.id == nil || m.oldValue == nil {
  23633. return v, errors.New("OldParentID requires an ID field in the mutation")
  23634. }
  23635. oldValue, err := m.oldValue(ctx)
  23636. if err != nil {
  23637. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  23638. }
  23639. return oldValue.ParentID, nil
  23640. }
  23641. // AddParentID adds u to the "parent_id" field.
  23642. func (m *SopNodeMutation) AddParentID(u int64) {
  23643. if m.addparent_id != nil {
  23644. *m.addparent_id += u
  23645. } else {
  23646. m.addparent_id = &u
  23647. }
  23648. }
  23649. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  23650. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  23651. v := m.addparent_id
  23652. if v == nil {
  23653. return
  23654. }
  23655. return *v, true
  23656. }
  23657. // ResetParentID resets all changes to the "parent_id" field.
  23658. func (m *SopNodeMutation) ResetParentID() {
  23659. m.parent_id = nil
  23660. m.addparent_id = nil
  23661. }
  23662. // SetName sets the "name" field.
  23663. func (m *SopNodeMutation) SetName(s string) {
  23664. m.name = &s
  23665. }
  23666. // Name returns the value of the "name" field in the mutation.
  23667. func (m *SopNodeMutation) Name() (r string, exists bool) {
  23668. v := m.name
  23669. if v == nil {
  23670. return
  23671. }
  23672. return *v, true
  23673. }
  23674. // OldName returns the old "name" field's value of the SopNode entity.
  23675. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23677. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  23678. if !m.op.Is(OpUpdateOne) {
  23679. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23680. }
  23681. if m.id == nil || m.oldValue == nil {
  23682. return v, errors.New("OldName requires an ID field in the mutation")
  23683. }
  23684. oldValue, err := m.oldValue(ctx)
  23685. if err != nil {
  23686. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23687. }
  23688. return oldValue.Name, nil
  23689. }
  23690. // ResetName resets all changes to the "name" field.
  23691. func (m *SopNodeMutation) ResetName() {
  23692. m.name = nil
  23693. }
  23694. // SetConditionType sets the "condition_type" field.
  23695. func (m *SopNodeMutation) SetConditionType(i int) {
  23696. m.condition_type = &i
  23697. m.addcondition_type = nil
  23698. }
  23699. // ConditionType returns the value of the "condition_type" field in the mutation.
  23700. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  23701. v := m.condition_type
  23702. if v == nil {
  23703. return
  23704. }
  23705. return *v, true
  23706. }
  23707. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  23708. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23710. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23711. if !m.op.Is(OpUpdateOne) {
  23712. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23713. }
  23714. if m.id == nil || m.oldValue == nil {
  23715. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23716. }
  23717. oldValue, err := m.oldValue(ctx)
  23718. if err != nil {
  23719. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23720. }
  23721. return oldValue.ConditionType, nil
  23722. }
  23723. // AddConditionType adds i to the "condition_type" field.
  23724. func (m *SopNodeMutation) AddConditionType(i int) {
  23725. if m.addcondition_type != nil {
  23726. *m.addcondition_type += i
  23727. } else {
  23728. m.addcondition_type = &i
  23729. }
  23730. }
  23731. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23732. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  23733. v := m.addcondition_type
  23734. if v == nil {
  23735. return
  23736. }
  23737. return *v, true
  23738. }
  23739. // ResetConditionType resets all changes to the "condition_type" field.
  23740. func (m *SopNodeMutation) ResetConditionType() {
  23741. m.condition_type = nil
  23742. m.addcondition_type = nil
  23743. }
  23744. // SetConditionList sets the "condition_list" field.
  23745. func (m *SopNodeMutation) SetConditionList(s []string) {
  23746. m.condition_list = &s
  23747. m.appendcondition_list = nil
  23748. }
  23749. // ConditionList returns the value of the "condition_list" field in the mutation.
  23750. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  23751. v := m.condition_list
  23752. if v == nil {
  23753. return
  23754. }
  23755. return *v, true
  23756. }
  23757. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  23758. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23760. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  23761. if !m.op.Is(OpUpdateOne) {
  23762. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23763. }
  23764. if m.id == nil || m.oldValue == nil {
  23765. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23766. }
  23767. oldValue, err := m.oldValue(ctx)
  23768. if err != nil {
  23769. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23770. }
  23771. return oldValue.ConditionList, nil
  23772. }
  23773. // AppendConditionList adds s to the "condition_list" field.
  23774. func (m *SopNodeMutation) AppendConditionList(s []string) {
  23775. m.appendcondition_list = append(m.appendcondition_list, s...)
  23776. }
  23777. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23778. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  23779. if len(m.appendcondition_list) == 0 {
  23780. return nil, false
  23781. }
  23782. return m.appendcondition_list, true
  23783. }
  23784. // ClearConditionList clears the value of the "condition_list" field.
  23785. func (m *SopNodeMutation) ClearConditionList() {
  23786. m.condition_list = nil
  23787. m.appendcondition_list = nil
  23788. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  23789. }
  23790. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  23791. func (m *SopNodeMutation) ConditionListCleared() bool {
  23792. _, ok := m.clearedFields[sopnode.FieldConditionList]
  23793. return ok
  23794. }
  23795. // ResetConditionList resets all changes to the "condition_list" field.
  23796. func (m *SopNodeMutation) ResetConditionList() {
  23797. m.condition_list = nil
  23798. m.appendcondition_list = nil
  23799. delete(m.clearedFields, sopnode.FieldConditionList)
  23800. }
  23801. // SetNoReplyCondition sets the "no_reply_condition" field.
  23802. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  23803. m.no_reply_condition = &u
  23804. m.addno_reply_condition = nil
  23805. }
  23806. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  23807. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  23808. v := m.no_reply_condition
  23809. if v == nil {
  23810. return
  23811. }
  23812. return *v, true
  23813. }
  23814. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  23815. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23817. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  23818. if !m.op.Is(OpUpdateOne) {
  23819. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  23820. }
  23821. if m.id == nil || m.oldValue == nil {
  23822. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  23823. }
  23824. oldValue, err := m.oldValue(ctx)
  23825. if err != nil {
  23826. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  23827. }
  23828. return oldValue.NoReplyCondition, nil
  23829. }
  23830. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  23831. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  23832. if m.addno_reply_condition != nil {
  23833. *m.addno_reply_condition += u
  23834. } else {
  23835. m.addno_reply_condition = &u
  23836. }
  23837. }
  23838. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  23839. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  23840. v := m.addno_reply_condition
  23841. if v == nil {
  23842. return
  23843. }
  23844. return *v, true
  23845. }
  23846. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  23847. func (m *SopNodeMutation) ResetNoReplyCondition() {
  23848. m.no_reply_condition = nil
  23849. m.addno_reply_condition = nil
  23850. }
  23851. // SetNoReplyUnit sets the "no_reply_unit" field.
  23852. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  23853. m.no_reply_unit = &s
  23854. }
  23855. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  23856. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  23857. v := m.no_reply_unit
  23858. if v == nil {
  23859. return
  23860. }
  23861. return *v, true
  23862. }
  23863. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  23864. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23866. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  23867. if !m.op.Is(OpUpdateOne) {
  23868. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  23869. }
  23870. if m.id == nil || m.oldValue == nil {
  23871. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  23872. }
  23873. oldValue, err := m.oldValue(ctx)
  23874. if err != nil {
  23875. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  23876. }
  23877. return oldValue.NoReplyUnit, nil
  23878. }
  23879. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  23880. func (m *SopNodeMutation) ResetNoReplyUnit() {
  23881. m.no_reply_unit = nil
  23882. }
  23883. // SetActionMessage sets the "action_message" field.
  23884. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  23885. m.action_message = &ct
  23886. m.appendaction_message = nil
  23887. }
  23888. // ActionMessage returns the value of the "action_message" field in the mutation.
  23889. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23890. v := m.action_message
  23891. if v == nil {
  23892. return
  23893. }
  23894. return *v, true
  23895. }
  23896. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  23897. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23899. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23900. if !m.op.Is(OpUpdateOne) {
  23901. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23902. }
  23903. if m.id == nil || m.oldValue == nil {
  23904. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23905. }
  23906. oldValue, err := m.oldValue(ctx)
  23907. if err != nil {
  23908. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23909. }
  23910. return oldValue.ActionMessage, nil
  23911. }
  23912. // AppendActionMessage adds ct to the "action_message" field.
  23913. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  23914. m.appendaction_message = append(m.appendaction_message, ct...)
  23915. }
  23916. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23917. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23918. if len(m.appendaction_message) == 0 {
  23919. return nil, false
  23920. }
  23921. return m.appendaction_message, true
  23922. }
  23923. // ClearActionMessage clears the value of the "action_message" field.
  23924. func (m *SopNodeMutation) ClearActionMessage() {
  23925. m.action_message = nil
  23926. m.appendaction_message = nil
  23927. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  23928. }
  23929. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  23930. func (m *SopNodeMutation) ActionMessageCleared() bool {
  23931. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  23932. return ok
  23933. }
  23934. // ResetActionMessage resets all changes to the "action_message" field.
  23935. func (m *SopNodeMutation) ResetActionMessage() {
  23936. m.action_message = nil
  23937. m.appendaction_message = nil
  23938. delete(m.clearedFields, sopnode.FieldActionMessage)
  23939. }
  23940. // SetActionLabelAdd sets the "action_label_add" field.
  23941. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  23942. m.action_label_add = &u
  23943. m.appendaction_label_add = nil
  23944. }
  23945. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23946. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23947. v := m.action_label_add
  23948. if v == nil {
  23949. return
  23950. }
  23951. return *v, true
  23952. }
  23953. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  23954. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23956. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23957. if !m.op.Is(OpUpdateOne) {
  23958. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23959. }
  23960. if m.id == nil || m.oldValue == nil {
  23961. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23962. }
  23963. oldValue, err := m.oldValue(ctx)
  23964. if err != nil {
  23965. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23966. }
  23967. return oldValue.ActionLabelAdd, nil
  23968. }
  23969. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23970. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  23971. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23972. }
  23973. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23974. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23975. if len(m.appendaction_label_add) == 0 {
  23976. return nil, false
  23977. }
  23978. return m.appendaction_label_add, true
  23979. }
  23980. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23981. func (m *SopNodeMutation) ClearActionLabelAdd() {
  23982. m.action_label_add = nil
  23983. m.appendaction_label_add = nil
  23984. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  23985. }
  23986. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23987. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  23988. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  23989. return ok
  23990. }
  23991. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23992. func (m *SopNodeMutation) ResetActionLabelAdd() {
  23993. m.action_label_add = nil
  23994. m.appendaction_label_add = nil
  23995. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  23996. }
  23997. // SetActionLabelDel sets the "action_label_del" field.
  23998. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  23999. m.action_label_del = &u
  24000. m.appendaction_label_del = nil
  24001. }
  24002. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  24003. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  24004. v := m.action_label_del
  24005. if v == nil {
  24006. return
  24007. }
  24008. return *v, true
  24009. }
  24010. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  24011. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24013. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  24014. if !m.op.Is(OpUpdateOne) {
  24015. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  24016. }
  24017. if m.id == nil || m.oldValue == nil {
  24018. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  24019. }
  24020. oldValue, err := m.oldValue(ctx)
  24021. if err != nil {
  24022. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  24023. }
  24024. return oldValue.ActionLabelDel, nil
  24025. }
  24026. // AppendActionLabelDel adds u to the "action_label_del" field.
  24027. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  24028. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  24029. }
  24030. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  24031. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  24032. if len(m.appendaction_label_del) == 0 {
  24033. return nil, false
  24034. }
  24035. return m.appendaction_label_del, true
  24036. }
  24037. // ClearActionLabelDel clears the value of the "action_label_del" field.
  24038. func (m *SopNodeMutation) ClearActionLabelDel() {
  24039. m.action_label_del = nil
  24040. m.appendaction_label_del = nil
  24041. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  24042. }
  24043. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  24044. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  24045. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  24046. return ok
  24047. }
  24048. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  24049. func (m *SopNodeMutation) ResetActionLabelDel() {
  24050. m.action_label_del = nil
  24051. m.appendaction_label_del = nil
  24052. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  24053. }
  24054. // SetActionForward sets the "action_forward" field.
  24055. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  24056. m.action_forward = &ctf
  24057. }
  24058. // ActionForward returns the value of the "action_forward" field in the mutation.
  24059. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  24060. v := m.action_forward
  24061. if v == nil {
  24062. return
  24063. }
  24064. return *v, true
  24065. }
  24066. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  24067. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24069. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  24070. if !m.op.Is(OpUpdateOne) {
  24071. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  24072. }
  24073. if m.id == nil || m.oldValue == nil {
  24074. return v, errors.New("OldActionForward requires an ID field in the mutation")
  24075. }
  24076. oldValue, err := m.oldValue(ctx)
  24077. if err != nil {
  24078. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  24079. }
  24080. return oldValue.ActionForward, nil
  24081. }
  24082. // ClearActionForward clears the value of the "action_forward" field.
  24083. func (m *SopNodeMutation) ClearActionForward() {
  24084. m.action_forward = nil
  24085. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  24086. }
  24087. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  24088. func (m *SopNodeMutation) ActionForwardCleared() bool {
  24089. _, ok := m.clearedFields[sopnode.FieldActionForward]
  24090. return ok
  24091. }
  24092. // ResetActionForward resets all changes to the "action_forward" field.
  24093. func (m *SopNodeMutation) ResetActionForward() {
  24094. m.action_forward = nil
  24095. delete(m.clearedFields, sopnode.FieldActionForward)
  24096. }
  24097. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  24098. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  24099. m.sop_stage = &id
  24100. }
  24101. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  24102. func (m *SopNodeMutation) ClearSopStage() {
  24103. m.clearedsop_stage = true
  24104. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  24105. }
  24106. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  24107. func (m *SopNodeMutation) SopStageCleared() bool {
  24108. return m.clearedsop_stage
  24109. }
  24110. // SopStageID returns the "sop_stage" edge ID in the mutation.
  24111. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  24112. if m.sop_stage != nil {
  24113. return *m.sop_stage, true
  24114. }
  24115. return
  24116. }
  24117. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  24118. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24119. // SopStageID instead. It exists only for internal usage by the builders.
  24120. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  24121. if id := m.sop_stage; id != nil {
  24122. ids = append(ids, *id)
  24123. }
  24124. return
  24125. }
  24126. // ResetSopStage resets all changes to the "sop_stage" edge.
  24127. func (m *SopNodeMutation) ResetSopStage() {
  24128. m.sop_stage = nil
  24129. m.clearedsop_stage = false
  24130. }
  24131. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  24132. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  24133. if m.node_messages == nil {
  24134. m.node_messages = make(map[uint64]struct{})
  24135. }
  24136. for i := range ids {
  24137. m.node_messages[ids[i]] = struct{}{}
  24138. }
  24139. }
  24140. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  24141. func (m *SopNodeMutation) ClearNodeMessages() {
  24142. m.clearednode_messages = true
  24143. }
  24144. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  24145. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  24146. return m.clearednode_messages
  24147. }
  24148. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  24149. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  24150. if m.removednode_messages == nil {
  24151. m.removednode_messages = make(map[uint64]struct{})
  24152. }
  24153. for i := range ids {
  24154. delete(m.node_messages, ids[i])
  24155. m.removednode_messages[ids[i]] = struct{}{}
  24156. }
  24157. }
  24158. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  24159. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  24160. for id := range m.removednode_messages {
  24161. ids = append(ids, id)
  24162. }
  24163. return
  24164. }
  24165. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  24166. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  24167. for id := range m.node_messages {
  24168. ids = append(ids, id)
  24169. }
  24170. return
  24171. }
  24172. // ResetNodeMessages resets all changes to the "node_messages" edge.
  24173. func (m *SopNodeMutation) ResetNodeMessages() {
  24174. m.node_messages = nil
  24175. m.clearednode_messages = false
  24176. m.removednode_messages = nil
  24177. }
  24178. // Where appends a list predicates to the SopNodeMutation builder.
  24179. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  24180. m.predicates = append(m.predicates, ps...)
  24181. }
  24182. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  24183. // users can use type-assertion to append predicates that do not depend on any generated package.
  24184. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  24185. p := make([]predicate.SopNode, len(ps))
  24186. for i := range ps {
  24187. p[i] = ps[i]
  24188. }
  24189. m.Where(p...)
  24190. }
  24191. // Op returns the operation name.
  24192. func (m *SopNodeMutation) Op() Op {
  24193. return m.op
  24194. }
  24195. // SetOp allows setting the mutation operation.
  24196. func (m *SopNodeMutation) SetOp(op Op) {
  24197. m.op = op
  24198. }
  24199. // Type returns the node type of this mutation (SopNode).
  24200. func (m *SopNodeMutation) Type() string {
  24201. return m.typ
  24202. }
  24203. // Fields returns all fields that were changed during this mutation. Note that in
  24204. // order to get all numeric fields that were incremented/decremented, call
  24205. // AddedFields().
  24206. func (m *SopNodeMutation) Fields() []string {
  24207. fields := make([]string, 0, 15)
  24208. if m.created_at != nil {
  24209. fields = append(fields, sopnode.FieldCreatedAt)
  24210. }
  24211. if m.updated_at != nil {
  24212. fields = append(fields, sopnode.FieldUpdatedAt)
  24213. }
  24214. if m.status != nil {
  24215. fields = append(fields, sopnode.FieldStatus)
  24216. }
  24217. if m.deleted_at != nil {
  24218. fields = append(fields, sopnode.FieldDeletedAt)
  24219. }
  24220. if m.sop_stage != nil {
  24221. fields = append(fields, sopnode.FieldStageID)
  24222. }
  24223. if m.parent_id != nil {
  24224. fields = append(fields, sopnode.FieldParentID)
  24225. }
  24226. if m.name != nil {
  24227. fields = append(fields, sopnode.FieldName)
  24228. }
  24229. if m.condition_type != nil {
  24230. fields = append(fields, sopnode.FieldConditionType)
  24231. }
  24232. if m.condition_list != nil {
  24233. fields = append(fields, sopnode.FieldConditionList)
  24234. }
  24235. if m.no_reply_condition != nil {
  24236. fields = append(fields, sopnode.FieldNoReplyCondition)
  24237. }
  24238. if m.no_reply_unit != nil {
  24239. fields = append(fields, sopnode.FieldNoReplyUnit)
  24240. }
  24241. if m.action_message != nil {
  24242. fields = append(fields, sopnode.FieldActionMessage)
  24243. }
  24244. if m.action_label_add != nil {
  24245. fields = append(fields, sopnode.FieldActionLabelAdd)
  24246. }
  24247. if m.action_label_del != nil {
  24248. fields = append(fields, sopnode.FieldActionLabelDel)
  24249. }
  24250. if m.action_forward != nil {
  24251. fields = append(fields, sopnode.FieldActionForward)
  24252. }
  24253. return fields
  24254. }
  24255. // Field returns the value of a field with the given name. The second boolean
  24256. // return value indicates that this field was not set, or was not defined in the
  24257. // schema.
  24258. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  24259. switch name {
  24260. case sopnode.FieldCreatedAt:
  24261. return m.CreatedAt()
  24262. case sopnode.FieldUpdatedAt:
  24263. return m.UpdatedAt()
  24264. case sopnode.FieldStatus:
  24265. return m.Status()
  24266. case sopnode.FieldDeletedAt:
  24267. return m.DeletedAt()
  24268. case sopnode.FieldStageID:
  24269. return m.StageID()
  24270. case sopnode.FieldParentID:
  24271. return m.ParentID()
  24272. case sopnode.FieldName:
  24273. return m.Name()
  24274. case sopnode.FieldConditionType:
  24275. return m.ConditionType()
  24276. case sopnode.FieldConditionList:
  24277. return m.ConditionList()
  24278. case sopnode.FieldNoReplyCondition:
  24279. return m.NoReplyCondition()
  24280. case sopnode.FieldNoReplyUnit:
  24281. return m.NoReplyUnit()
  24282. case sopnode.FieldActionMessage:
  24283. return m.ActionMessage()
  24284. case sopnode.FieldActionLabelAdd:
  24285. return m.ActionLabelAdd()
  24286. case sopnode.FieldActionLabelDel:
  24287. return m.ActionLabelDel()
  24288. case sopnode.FieldActionForward:
  24289. return m.ActionForward()
  24290. }
  24291. return nil, false
  24292. }
  24293. // OldField returns the old value of the field from the database. An error is
  24294. // returned if the mutation operation is not UpdateOne, or the query to the
  24295. // database failed.
  24296. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24297. switch name {
  24298. case sopnode.FieldCreatedAt:
  24299. return m.OldCreatedAt(ctx)
  24300. case sopnode.FieldUpdatedAt:
  24301. return m.OldUpdatedAt(ctx)
  24302. case sopnode.FieldStatus:
  24303. return m.OldStatus(ctx)
  24304. case sopnode.FieldDeletedAt:
  24305. return m.OldDeletedAt(ctx)
  24306. case sopnode.FieldStageID:
  24307. return m.OldStageID(ctx)
  24308. case sopnode.FieldParentID:
  24309. return m.OldParentID(ctx)
  24310. case sopnode.FieldName:
  24311. return m.OldName(ctx)
  24312. case sopnode.FieldConditionType:
  24313. return m.OldConditionType(ctx)
  24314. case sopnode.FieldConditionList:
  24315. return m.OldConditionList(ctx)
  24316. case sopnode.FieldNoReplyCondition:
  24317. return m.OldNoReplyCondition(ctx)
  24318. case sopnode.FieldNoReplyUnit:
  24319. return m.OldNoReplyUnit(ctx)
  24320. case sopnode.FieldActionMessage:
  24321. return m.OldActionMessage(ctx)
  24322. case sopnode.FieldActionLabelAdd:
  24323. return m.OldActionLabelAdd(ctx)
  24324. case sopnode.FieldActionLabelDel:
  24325. return m.OldActionLabelDel(ctx)
  24326. case sopnode.FieldActionForward:
  24327. return m.OldActionForward(ctx)
  24328. }
  24329. return nil, fmt.Errorf("unknown SopNode field %s", name)
  24330. }
  24331. // SetField sets the value of a field with the given name. It returns an error if
  24332. // the field is not defined in the schema, or if the type mismatched the field
  24333. // type.
  24334. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  24335. switch name {
  24336. case sopnode.FieldCreatedAt:
  24337. v, ok := value.(time.Time)
  24338. if !ok {
  24339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24340. }
  24341. m.SetCreatedAt(v)
  24342. return nil
  24343. case sopnode.FieldUpdatedAt:
  24344. v, ok := value.(time.Time)
  24345. if !ok {
  24346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24347. }
  24348. m.SetUpdatedAt(v)
  24349. return nil
  24350. case sopnode.FieldStatus:
  24351. v, ok := value.(uint8)
  24352. if !ok {
  24353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24354. }
  24355. m.SetStatus(v)
  24356. return nil
  24357. case sopnode.FieldDeletedAt:
  24358. v, ok := value.(time.Time)
  24359. if !ok {
  24360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24361. }
  24362. m.SetDeletedAt(v)
  24363. return nil
  24364. case sopnode.FieldStageID:
  24365. v, ok := value.(uint64)
  24366. if !ok {
  24367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24368. }
  24369. m.SetStageID(v)
  24370. return nil
  24371. case sopnode.FieldParentID:
  24372. v, ok := value.(uint64)
  24373. if !ok {
  24374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24375. }
  24376. m.SetParentID(v)
  24377. return nil
  24378. case sopnode.FieldName:
  24379. v, ok := value.(string)
  24380. if !ok {
  24381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24382. }
  24383. m.SetName(v)
  24384. return nil
  24385. case sopnode.FieldConditionType:
  24386. v, ok := value.(int)
  24387. if !ok {
  24388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24389. }
  24390. m.SetConditionType(v)
  24391. return nil
  24392. case sopnode.FieldConditionList:
  24393. v, ok := value.([]string)
  24394. if !ok {
  24395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24396. }
  24397. m.SetConditionList(v)
  24398. return nil
  24399. case sopnode.FieldNoReplyCondition:
  24400. v, ok := value.(uint64)
  24401. if !ok {
  24402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24403. }
  24404. m.SetNoReplyCondition(v)
  24405. return nil
  24406. case sopnode.FieldNoReplyUnit:
  24407. v, ok := value.(string)
  24408. if !ok {
  24409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24410. }
  24411. m.SetNoReplyUnit(v)
  24412. return nil
  24413. case sopnode.FieldActionMessage:
  24414. v, ok := value.([]custom_types.Action)
  24415. if !ok {
  24416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24417. }
  24418. m.SetActionMessage(v)
  24419. return nil
  24420. case sopnode.FieldActionLabelAdd:
  24421. v, ok := value.([]uint64)
  24422. if !ok {
  24423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24424. }
  24425. m.SetActionLabelAdd(v)
  24426. return nil
  24427. case sopnode.FieldActionLabelDel:
  24428. v, ok := value.([]uint64)
  24429. if !ok {
  24430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24431. }
  24432. m.SetActionLabelDel(v)
  24433. return nil
  24434. case sopnode.FieldActionForward:
  24435. v, ok := value.(*custom_types.ActionForward)
  24436. if !ok {
  24437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24438. }
  24439. m.SetActionForward(v)
  24440. return nil
  24441. }
  24442. return fmt.Errorf("unknown SopNode field %s", name)
  24443. }
  24444. // AddedFields returns all numeric fields that were incremented/decremented during
  24445. // this mutation.
  24446. func (m *SopNodeMutation) AddedFields() []string {
  24447. var fields []string
  24448. if m.addstatus != nil {
  24449. fields = append(fields, sopnode.FieldStatus)
  24450. }
  24451. if m.addparent_id != nil {
  24452. fields = append(fields, sopnode.FieldParentID)
  24453. }
  24454. if m.addcondition_type != nil {
  24455. fields = append(fields, sopnode.FieldConditionType)
  24456. }
  24457. if m.addno_reply_condition != nil {
  24458. fields = append(fields, sopnode.FieldNoReplyCondition)
  24459. }
  24460. return fields
  24461. }
  24462. // AddedField returns the numeric value that was incremented/decremented on a field
  24463. // with the given name. The second boolean return value indicates that this field
  24464. // was not set, or was not defined in the schema.
  24465. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  24466. switch name {
  24467. case sopnode.FieldStatus:
  24468. return m.AddedStatus()
  24469. case sopnode.FieldParentID:
  24470. return m.AddedParentID()
  24471. case sopnode.FieldConditionType:
  24472. return m.AddedConditionType()
  24473. case sopnode.FieldNoReplyCondition:
  24474. return m.AddedNoReplyCondition()
  24475. }
  24476. return nil, false
  24477. }
  24478. // AddField adds the value to the field with the given name. It returns an error if
  24479. // the field is not defined in the schema, or if the type mismatched the field
  24480. // type.
  24481. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  24482. switch name {
  24483. case sopnode.FieldStatus:
  24484. v, ok := value.(int8)
  24485. if !ok {
  24486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24487. }
  24488. m.AddStatus(v)
  24489. return nil
  24490. case sopnode.FieldParentID:
  24491. v, ok := value.(int64)
  24492. if !ok {
  24493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24494. }
  24495. m.AddParentID(v)
  24496. return nil
  24497. case sopnode.FieldConditionType:
  24498. v, ok := value.(int)
  24499. if !ok {
  24500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24501. }
  24502. m.AddConditionType(v)
  24503. return nil
  24504. case sopnode.FieldNoReplyCondition:
  24505. v, ok := value.(int64)
  24506. if !ok {
  24507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24508. }
  24509. m.AddNoReplyCondition(v)
  24510. return nil
  24511. }
  24512. return fmt.Errorf("unknown SopNode numeric field %s", name)
  24513. }
  24514. // ClearedFields returns all nullable fields that were cleared during this
  24515. // mutation.
  24516. func (m *SopNodeMutation) ClearedFields() []string {
  24517. var fields []string
  24518. if m.FieldCleared(sopnode.FieldStatus) {
  24519. fields = append(fields, sopnode.FieldStatus)
  24520. }
  24521. if m.FieldCleared(sopnode.FieldDeletedAt) {
  24522. fields = append(fields, sopnode.FieldDeletedAt)
  24523. }
  24524. if m.FieldCleared(sopnode.FieldConditionList) {
  24525. fields = append(fields, sopnode.FieldConditionList)
  24526. }
  24527. if m.FieldCleared(sopnode.FieldActionMessage) {
  24528. fields = append(fields, sopnode.FieldActionMessage)
  24529. }
  24530. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  24531. fields = append(fields, sopnode.FieldActionLabelAdd)
  24532. }
  24533. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  24534. fields = append(fields, sopnode.FieldActionLabelDel)
  24535. }
  24536. if m.FieldCleared(sopnode.FieldActionForward) {
  24537. fields = append(fields, sopnode.FieldActionForward)
  24538. }
  24539. return fields
  24540. }
  24541. // FieldCleared returns a boolean indicating if a field with the given name was
  24542. // cleared in this mutation.
  24543. func (m *SopNodeMutation) FieldCleared(name string) bool {
  24544. _, ok := m.clearedFields[name]
  24545. return ok
  24546. }
  24547. // ClearField clears the value of the field with the given name. It returns an
  24548. // error if the field is not defined in the schema.
  24549. func (m *SopNodeMutation) ClearField(name string) error {
  24550. switch name {
  24551. case sopnode.FieldStatus:
  24552. m.ClearStatus()
  24553. return nil
  24554. case sopnode.FieldDeletedAt:
  24555. m.ClearDeletedAt()
  24556. return nil
  24557. case sopnode.FieldConditionList:
  24558. m.ClearConditionList()
  24559. return nil
  24560. case sopnode.FieldActionMessage:
  24561. m.ClearActionMessage()
  24562. return nil
  24563. case sopnode.FieldActionLabelAdd:
  24564. m.ClearActionLabelAdd()
  24565. return nil
  24566. case sopnode.FieldActionLabelDel:
  24567. m.ClearActionLabelDel()
  24568. return nil
  24569. case sopnode.FieldActionForward:
  24570. m.ClearActionForward()
  24571. return nil
  24572. }
  24573. return fmt.Errorf("unknown SopNode nullable field %s", name)
  24574. }
  24575. // ResetField resets all changes in the mutation for the field with the given name.
  24576. // It returns an error if the field is not defined in the schema.
  24577. func (m *SopNodeMutation) ResetField(name string) error {
  24578. switch name {
  24579. case sopnode.FieldCreatedAt:
  24580. m.ResetCreatedAt()
  24581. return nil
  24582. case sopnode.FieldUpdatedAt:
  24583. m.ResetUpdatedAt()
  24584. return nil
  24585. case sopnode.FieldStatus:
  24586. m.ResetStatus()
  24587. return nil
  24588. case sopnode.FieldDeletedAt:
  24589. m.ResetDeletedAt()
  24590. return nil
  24591. case sopnode.FieldStageID:
  24592. m.ResetStageID()
  24593. return nil
  24594. case sopnode.FieldParentID:
  24595. m.ResetParentID()
  24596. return nil
  24597. case sopnode.FieldName:
  24598. m.ResetName()
  24599. return nil
  24600. case sopnode.FieldConditionType:
  24601. m.ResetConditionType()
  24602. return nil
  24603. case sopnode.FieldConditionList:
  24604. m.ResetConditionList()
  24605. return nil
  24606. case sopnode.FieldNoReplyCondition:
  24607. m.ResetNoReplyCondition()
  24608. return nil
  24609. case sopnode.FieldNoReplyUnit:
  24610. m.ResetNoReplyUnit()
  24611. return nil
  24612. case sopnode.FieldActionMessage:
  24613. m.ResetActionMessage()
  24614. return nil
  24615. case sopnode.FieldActionLabelAdd:
  24616. m.ResetActionLabelAdd()
  24617. return nil
  24618. case sopnode.FieldActionLabelDel:
  24619. m.ResetActionLabelDel()
  24620. return nil
  24621. case sopnode.FieldActionForward:
  24622. m.ResetActionForward()
  24623. return nil
  24624. }
  24625. return fmt.Errorf("unknown SopNode field %s", name)
  24626. }
  24627. // AddedEdges returns all edge names that were set/added in this mutation.
  24628. func (m *SopNodeMutation) AddedEdges() []string {
  24629. edges := make([]string, 0, 2)
  24630. if m.sop_stage != nil {
  24631. edges = append(edges, sopnode.EdgeSopStage)
  24632. }
  24633. if m.node_messages != nil {
  24634. edges = append(edges, sopnode.EdgeNodeMessages)
  24635. }
  24636. return edges
  24637. }
  24638. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24639. // name in this mutation.
  24640. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  24641. switch name {
  24642. case sopnode.EdgeSopStage:
  24643. if id := m.sop_stage; id != nil {
  24644. return []ent.Value{*id}
  24645. }
  24646. case sopnode.EdgeNodeMessages:
  24647. ids := make([]ent.Value, 0, len(m.node_messages))
  24648. for id := range m.node_messages {
  24649. ids = append(ids, id)
  24650. }
  24651. return ids
  24652. }
  24653. return nil
  24654. }
  24655. // RemovedEdges returns all edge names that were removed in this mutation.
  24656. func (m *SopNodeMutation) RemovedEdges() []string {
  24657. edges := make([]string, 0, 2)
  24658. if m.removednode_messages != nil {
  24659. edges = append(edges, sopnode.EdgeNodeMessages)
  24660. }
  24661. return edges
  24662. }
  24663. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24664. // the given name in this mutation.
  24665. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  24666. switch name {
  24667. case sopnode.EdgeNodeMessages:
  24668. ids := make([]ent.Value, 0, len(m.removednode_messages))
  24669. for id := range m.removednode_messages {
  24670. ids = append(ids, id)
  24671. }
  24672. return ids
  24673. }
  24674. return nil
  24675. }
  24676. // ClearedEdges returns all edge names that were cleared in this mutation.
  24677. func (m *SopNodeMutation) ClearedEdges() []string {
  24678. edges := make([]string, 0, 2)
  24679. if m.clearedsop_stage {
  24680. edges = append(edges, sopnode.EdgeSopStage)
  24681. }
  24682. if m.clearednode_messages {
  24683. edges = append(edges, sopnode.EdgeNodeMessages)
  24684. }
  24685. return edges
  24686. }
  24687. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24688. // was cleared in this mutation.
  24689. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  24690. switch name {
  24691. case sopnode.EdgeSopStage:
  24692. return m.clearedsop_stage
  24693. case sopnode.EdgeNodeMessages:
  24694. return m.clearednode_messages
  24695. }
  24696. return false
  24697. }
  24698. // ClearEdge clears the value of the edge with the given name. It returns an error
  24699. // if that edge is not defined in the schema.
  24700. func (m *SopNodeMutation) ClearEdge(name string) error {
  24701. switch name {
  24702. case sopnode.EdgeSopStage:
  24703. m.ClearSopStage()
  24704. return nil
  24705. }
  24706. return fmt.Errorf("unknown SopNode unique edge %s", name)
  24707. }
  24708. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24709. // It returns an error if the edge is not defined in the schema.
  24710. func (m *SopNodeMutation) ResetEdge(name string) error {
  24711. switch name {
  24712. case sopnode.EdgeSopStage:
  24713. m.ResetSopStage()
  24714. return nil
  24715. case sopnode.EdgeNodeMessages:
  24716. m.ResetNodeMessages()
  24717. return nil
  24718. }
  24719. return fmt.Errorf("unknown SopNode edge %s", name)
  24720. }
  24721. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  24722. type SopStageMutation struct {
  24723. config
  24724. op Op
  24725. typ string
  24726. id *uint64
  24727. created_at *time.Time
  24728. updated_at *time.Time
  24729. status *uint8
  24730. addstatus *int8
  24731. deleted_at *time.Time
  24732. name *string
  24733. condition_type *int
  24734. addcondition_type *int
  24735. condition_operator *int
  24736. addcondition_operator *int
  24737. condition_list *[]custom_types.Condition
  24738. appendcondition_list []custom_types.Condition
  24739. action_message *[]custom_types.Action
  24740. appendaction_message []custom_types.Action
  24741. action_label_add *[]uint64
  24742. appendaction_label_add []uint64
  24743. action_label_del *[]uint64
  24744. appendaction_label_del []uint64
  24745. action_forward **custom_types.ActionForward
  24746. index_sort *int
  24747. addindex_sort *int
  24748. clearedFields map[string]struct{}
  24749. sop_task *uint64
  24750. clearedsop_task bool
  24751. stage_nodes map[uint64]struct{}
  24752. removedstage_nodes map[uint64]struct{}
  24753. clearedstage_nodes bool
  24754. stage_messages map[uint64]struct{}
  24755. removedstage_messages map[uint64]struct{}
  24756. clearedstage_messages bool
  24757. done bool
  24758. oldValue func(context.Context) (*SopStage, error)
  24759. predicates []predicate.SopStage
  24760. }
  24761. var _ ent.Mutation = (*SopStageMutation)(nil)
  24762. // sopstageOption allows management of the mutation configuration using functional options.
  24763. type sopstageOption func(*SopStageMutation)
  24764. // newSopStageMutation creates new mutation for the SopStage entity.
  24765. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  24766. m := &SopStageMutation{
  24767. config: c,
  24768. op: op,
  24769. typ: TypeSopStage,
  24770. clearedFields: make(map[string]struct{}),
  24771. }
  24772. for _, opt := range opts {
  24773. opt(m)
  24774. }
  24775. return m
  24776. }
  24777. // withSopStageID sets the ID field of the mutation.
  24778. func withSopStageID(id uint64) sopstageOption {
  24779. return func(m *SopStageMutation) {
  24780. var (
  24781. err error
  24782. once sync.Once
  24783. value *SopStage
  24784. )
  24785. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  24786. once.Do(func() {
  24787. if m.done {
  24788. err = errors.New("querying old values post mutation is not allowed")
  24789. } else {
  24790. value, err = m.Client().SopStage.Get(ctx, id)
  24791. }
  24792. })
  24793. return value, err
  24794. }
  24795. m.id = &id
  24796. }
  24797. }
  24798. // withSopStage sets the old SopStage of the mutation.
  24799. func withSopStage(node *SopStage) sopstageOption {
  24800. return func(m *SopStageMutation) {
  24801. m.oldValue = func(context.Context) (*SopStage, error) {
  24802. return node, nil
  24803. }
  24804. m.id = &node.ID
  24805. }
  24806. }
  24807. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24808. // executed in a transaction (ent.Tx), a transactional client is returned.
  24809. func (m SopStageMutation) Client() *Client {
  24810. client := &Client{config: m.config}
  24811. client.init()
  24812. return client
  24813. }
  24814. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24815. // it returns an error otherwise.
  24816. func (m SopStageMutation) Tx() (*Tx, error) {
  24817. if _, ok := m.driver.(*txDriver); !ok {
  24818. return nil, errors.New("ent: mutation is not running in a transaction")
  24819. }
  24820. tx := &Tx{config: m.config}
  24821. tx.init()
  24822. return tx, nil
  24823. }
  24824. // SetID sets the value of the id field. Note that this
  24825. // operation is only accepted on creation of SopStage entities.
  24826. func (m *SopStageMutation) SetID(id uint64) {
  24827. m.id = &id
  24828. }
  24829. // ID returns the ID value in the mutation. Note that the ID is only available
  24830. // if it was provided to the builder or after it was returned from the database.
  24831. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  24832. if m.id == nil {
  24833. return
  24834. }
  24835. return *m.id, true
  24836. }
  24837. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24838. // That means, if the mutation is applied within a transaction with an isolation level such
  24839. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24840. // or updated by the mutation.
  24841. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  24842. switch {
  24843. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24844. id, exists := m.ID()
  24845. if exists {
  24846. return []uint64{id}, nil
  24847. }
  24848. fallthrough
  24849. case m.op.Is(OpUpdate | OpDelete):
  24850. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  24851. default:
  24852. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24853. }
  24854. }
  24855. // SetCreatedAt sets the "created_at" field.
  24856. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  24857. m.created_at = &t
  24858. }
  24859. // CreatedAt returns the value of the "created_at" field in the mutation.
  24860. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  24861. v := m.created_at
  24862. if v == nil {
  24863. return
  24864. }
  24865. return *v, true
  24866. }
  24867. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  24868. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24870. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24871. if !m.op.Is(OpUpdateOne) {
  24872. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24873. }
  24874. if m.id == nil || m.oldValue == nil {
  24875. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24876. }
  24877. oldValue, err := m.oldValue(ctx)
  24878. if err != nil {
  24879. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24880. }
  24881. return oldValue.CreatedAt, nil
  24882. }
  24883. // ResetCreatedAt resets all changes to the "created_at" field.
  24884. func (m *SopStageMutation) ResetCreatedAt() {
  24885. m.created_at = nil
  24886. }
  24887. // SetUpdatedAt sets the "updated_at" field.
  24888. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  24889. m.updated_at = &t
  24890. }
  24891. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24892. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  24893. v := m.updated_at
  24894. if v == nil {
  24895. return
  24896. }
  24897. return *v, true
  24898. }
  24899. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  24900. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24902. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24903. if !m.op.Is(OpUpdateOne) {
  24904. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24905. }
  24906. if m.id == nil || m.oldValue == nil {
  24907. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24908. }
  24909. oldValue, err := m.oldValue(ctx)
  24910. if err != nil {
  24911. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24912. }
  24913. return oldValue.UpdatedAt, nil
  24914. }
  24915. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24916. func (m *SopStageMutation) ResetUpdatedAt() {
  24917. m.updated_at = nil
  24918. }
  24919. // SetStatus sets the "status" field.
  24920. func (m *SopStageMutation) SetStatus(u uint8) {
  24921. m.status = &u
  24922. m.addstatus = nil
  24923. }
  24924. // Status returns the value of the "status" field in the mutation.
  24925. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  24926. v := m.status
  24927. if v == nil {
  24928. return
  24929. }
  24930. return *v, true
  24931. }
  24932. // OldStatus returns the old "status" field's value of the SopStage entity.
  24933. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24935. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24936. if !m.op.Is(OpUpdateOne) {
  24937. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24938. }
  24939. if m.id == nil || m.oldValue == nil {
  24940. return v, errors.New("OldStatus requires an ID field in the mutation")
  24941. }
  24942. oldValue, err := m.oldValue(ctx)
  24943. if err != nil {
  24944. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24945. }
  24946. return oldValue.Status, nil
  24947. }
  24948. // AddStatus adds u to the "status" field.
  24949. func (m *SopStageMutation) AddStatus(u int8) {
  24950. if m.addstatus != nil {
  24951. *m.addstatus += u
  24952. } else {
  24953. m.addstatus = &u
  24954. }
  24955. }
  24956. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24957. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  24958. v := m.addstatus
  24959. if v == nil {
  24960. return
  24961. }
  24962. return *v, true
  24963. }
  24964. // ClearStatus clears the value of the "status" field.
  24965. func (m *SopStageMutation) ClearStatus() {
  24966. m.status = nil
  24967. m.addstatus = nil
  24968. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  24969. }
  24970. // StatusCleared returns if the "status" field was cleared in this mutation.
  24971. func (m *SopStageMutation) StatusCleared() bool {
  24972. _, ok := m.clearedFields[sopstage.FieldStatus]
  24973. return ok
  24974. }
  24975. // ResetStatus resets all changes to the "status" field.
  24976. func (m *SopStageMutation) ResetStatus() {
  24977. m.status = nil
  24978. m.addstatus = nil
  24979. delete(m.clearedFields, sopstage.FieldStatus)
  24980. }
  24981. // SetDeletedAt sets the "deleted_at" field.
  24982. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  24983. m.deleted_at = &t
  24984. }
  24985. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24986. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  24987. v := m.deleted_at
  24988. if v == nil {
  24989. return
  24990. }
  24991. return *v, true
  24992. }
  24993. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  24994. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24996. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24997. if !m.op.Is(OpUpdateOne) {
  24998. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24999. }
  25000. if m.id == nil || m.oldValue == nil {
  25001. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25002. }
  25003. oldValue, err := m.oldValue(ctx)
  25004. if err != nil {
  25005. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25006. }
  25007. return oldValue.DeletedAt, nil
  25008. }
  25009. // ClearDeletedAt clears the value of the "deleted_at" field.
  25010. func (m *SopStageMutation) ClearDeletedAt() {
  25011. m.deleted_at = nil
  25012. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  25013. }
  25014. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25015. func (m *SopStageMutation) DeletedAtCleared() bool {
  25016. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  25017. return ok
  25018. }
  25019. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25020. func (m *SopStageMutation) ResetDeletedAt() {
  25021. m.deleted_at = nil
  25022. delete(m.clearedFields, sopstage.FieldDeletedAt)
  25023. }
  25024. // SetTaskID sets the "task_id" field.
  25025. func (m *SopStageMutation) SetTaskID(u uint64) {
  25026. m.sop_task = &u
  25027. }
  25028. // TaskID returns the value of the "task_id" field in the mutation.
  25029. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  25030. v := m.sop_task
  25031. if v == nil {
  25032. return
  25033. }
  25034. return *v, true
  25035. }
  25036. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  25037. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25039. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  25040. if !m.op.Is(OpUpdateOne) {
  25041. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  25042. }
  25043. if m.id == nil || m.oldValue == nil {
  25044. return v, errors.New("OldTaskID requires an ID field in the mutation")
  25045. }
  25046. oldValue, err := m.oldValue(ctx)
  25047. if err != nil {
  25048. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  25049. }
  25050. return oldValue.TaskID, nil
  25051. }
  25052. // ResetTaskID resets all changes to the "task_id" field.
  25053. func (m *SopStageMutation) ResetTaskID() {
  25054. m.sop_task = nil
  25055. }
  25056. // SetName sets the "name" field.
  25057. func (m *SopStageMutation) SetName(s string) {
  25058. m.name = &s
  25059. }
  25060. // Name returns the value of the "name" field in the mutation.
  25061. func (m *SopStageMutation) Name() (r string, exists bool) {
  25062. v := m.name
  25063. if v == nil {
  25064. return
  25065. }
  25066. return *v, true
  25067. }
  25068. // OldName returns the old "name" field's value of the SopStage entity.
  25069. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25071. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  25072. if !m.op.Is(OpUpdateOne) {
  25073. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25074. }
  25075. if m.id == nil || m.oldValue == nil {
  25076. return v, errors.New("OldName requires an ID field in the mutation")
  25077. }
  25078. oldValue, err := m.oldValue(ctx)
  25079. if err != nil {
  25080. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25081. }
  25082. return oldValue.Name, nil
  25083. }
  25084. // ResetName resets all changes to the "name" field.
  25085. func (m *SopStageMutation) ResetName() {
  25086. m.name = nil
  25087. }
  25088. // SetConditionType sets the "condition_type" field.
  25089. func (m *SopStageMutation) SetConditionType(i int) {
  25090. m.condition_type = &i
  25091. m.addcondition_type = nil
  25092. }
  25093. // ConditionType returns the value of the "condition_type" field in the mutation.
  25094. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  25095. v := m.condition_type
  25096. if v == nil {
  25097. return
  25098. }
  25099. return *v, true
  25100. }
  25101. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  25102. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25104. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  25105. if !m.op.Is(OpUpdateOne) {
  25106. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  25107. }
  25108. if m.id == nil || m.oldValue == nil {
  25109. return v, errors.New("OldConditionType requires an ID field in the mutation")
  25110. }
  25111. oldValue, err := m.oldValue(ctx)
  25112. if err != nil {
  25113. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  25114. }
  25115. return oldValue.ConditionType, nil
  25116. }
  25117. // AddConditionType adds i to the "condition_type" field.
  25118. func (m *SopStageMutation) AddConditionType(i int) {
  25119. if m.addcondition_type != nil {
  25120. *m.addcondition_type += i
  25121. } else {
  25122. m.addcondition_type = &i
  25123. }
  25124. }
  25125. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  25126. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  25127. v := m.addcondition_type
  25128. if v == nil {
  25129. return
  25130. }
  25131. return *v, true
  25132. }
  25133. // ResetConditionType resets all changes to the "condition_type" field.
  25134. func (m *SopStageMutation) ResetConditionType() {
  25135. m.condition_type = nil
  25136. m.addcondition_type = nil
  25137. }
  25138. // SetConditionOperator sets the "condition_operator" field.
  25139. func (m *SopStageMutation) SetConditionOperator(i int) {
  25140. m.condition_operator = &i
  25141. m.addcondition_operator = nil
  25142. }
  25143. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  25144. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  25145. v := m.condition_operator
  25146. if v == nil {
  25147. return
  25148. }
  25149. return *v, true
  25150. }
  25151. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  25152. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25154. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  25155. if !m.op.Is(OpUpdateOne) {
  25156. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  25157. }
  25158. if m.id == nil || m.oldValue == nil {
  25159. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  25160. }
  25161. oldValue, err := m.oldValue(ctx)
  25162. if err != nil {
  25163. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  25164. }
  25165. return oldValue.ConditionOperator, nil
  25166. }
  25167. // AddConditionOperator adds i to the "condition_operator" field.
  25168. func (m *SopStageMutation) AddConditionOperator(i int) {
  25169. if m.addcondition_operator != nil {
  25170. *m.addcondition_operator += i
  25171. } else {
  25172. m.addcondition_operator = &i
  25173. }
  25174. }
  25175. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  25176. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  25177. v := m.addcondition_operator
  25178. if v == nil {
  25179. return
  25180. }
  25181. return *v, true
  25182. }
  25183. // ResetConditionOperator resets all changes to the "condition_operator" field.
  25184. func (m *SopStageMutation) ResetConditionOperator() {
  25185. m.condition_operator = nil
  25186. m.addcondition_operator = nil
  25187. }
  25188. // SetConditionList sets the "condition_list" field.
  25189. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  25190. m.condition_list = &ct
  25191. m.appendcondition_list = nil
  25192. }
  25193. // ConditionList returns the value of the "condition_list" field in the mutation.
  25194. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  25195. v := m.condition_list
  25196. if v == nil {
  25197. return
  25198. }
  25199. return *v, true
  25200. }
  25201. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  25202. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25204. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  25205. if !m.op.Is(OpUpdateOne) {
  25206. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  25207. }
  25208. if m.id == nil || m.oldValue == nil {
  25209. return v, errors.New("OldConditionList requires an ID field in the mutation")
  25210. }
  25211. oldValue, err := m.oldValue(ctx)
  25212. if err != nil {
  25213. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  25214. }
  25215. return oldValue.ConditionList, nil
  25216. }
  25217. // AppendConditionList adds ct to the "condition_list" field.
  25218. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  25219. m.appendcondition_list = append(m.appendcondition_list, ct...)
  25220. }
  25221. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  25222. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  25223. if len(m.appendcondition_list) == 0 {
  25224. return nil, false
  25225. }
  25226. return m.appendcondition_list, true
  25227. }
  25228. // ResetConditionList resets all changes to the "condition_list" field.
  25229. func (m *SopStageMutation) ResetConditionList() {
  25230. m.condition_list = nil
  25231. m.appendcondition_list = nil
  25232. }
  25233. // SetActionMessage sets the "action_message" field.
  25234. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  25235. m.action_message = &ct
  25236. m.appendaction_message = nil
  25237. }
  25238. // ActionMessage returns the value of the "action_message" field in the mutation.
  25239. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  25240. v := m.action_message
  25241. if v == nil {
  25242. return
  25243. }
  25244. return *v, true
  25245. }
  25246. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  25247. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25249. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  25250. if !m.op.Is(OpUpdateOne) {
  25251. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  25252. }
  25253. if m.id == nil || m.oldValue == nil {
  25254. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  25255. }
  25256. oldValue, err := m.oldValue(ctx)
  25257. if err != nil {
  25258. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  25259. }
  25260. return oldValue.ActionMessage, nil
  25261. }
  25262. // AppendActionMessage adds ct to the "action_message" field.
  25263. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  25264. m.appendaction_message = append(m.appendaction_message, ct...)
  25265. }
  25266. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  25267. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  25268. if len(m.appendaction_message) == 0 {
  25269. return nil, false
  25270. }
  25271. return m.appendaction_message, true
  25272. }
  25273. // ClearActionMessage clears the value of the "action_message" field.
  25274. func (m *SopStageMutation) ClearActionMessage() {
  25275. m.action_message = nil
  25276. m.appendaction_message = nil
  25277. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  25278. }
  25279. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  25280. func (m *SopStageMutation) ActionMessageCleared() bool {
  25281. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  25282. return ok
  25283. }
  25284. // ResetActionMessage resets all changes to the "action_message" field.
  25285. func (m *SopStageMutation) ResetActionMessage() {
  25286. m.action_message = nil
  25287. m.appendaction_message = nil
  25288. delete(m.clearedFields, sopstage.FieldActionMessage)
  25289. }
  25290. // SetActionLabelAdd sets the "action_label_add" field.
  25291. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  25292. m.action_label_add = &u
  25293. m.appendaction_label_add = nil
  25294. }
  25295. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  25296. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  25297. v := m.action_label_add
  25298. if v == nil {
  25299. return
  25300. }
  25301. return *v, true
  25302. }
  25303. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  25304. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25306. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  25307. if !m.op.Is(OpUpdateOne) {
  25308. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  25309. }
  25310. if m.id == nil || m.oldValue == nil {
  25311. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  25312. }
  25313. oldValue, err := m.oldValue(ctx)
  25314. if err != nil {
  25315. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  25316. }
  25317. return oldValue.ActionLabelAdd, nil
  25318. }
  25319. // AppendActionLabelAdd adds u to the "action_label_add" field.
  25320. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  25321. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  25322. }
  25323. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  25324. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  25325. if len(m.appendaction_label_add) == 0 {
  25326. return nil, false
  25327. }
  25328. return m.appendaction_label_add, true
  25329. }
  25330. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  25331. func (m *SopStageMutation) ClearActionLabelAdd() {
  25332. m.action_label_add = nil
  25333. m.appendaction_label_add = nil
  25334. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  25335. }
  25336. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  25337. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  25338. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  25339. return ok
  25340. }
  25341. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  25342. func (m *SopStageMutation) ResetActionLabelAdd() {
  25343. m.action_label_add = nil
  25344. m.appendaction_label_add = nil
  25345. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  25346. }
  25347. // SetActionLabelDel sets the "action_label_del" field.
  25348. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  25349. m.action_label_del = &u
  25350. m.appendaction_label_del = nil
  25351. }
  25352. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  25353. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  25354. v := m.action_label_del
  25355. if v == nil {
  25356. return
  25357. }
  25358. return *v, true
  25359. }
  25360. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  25361. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25363. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  25364. if !m.op.Is(OpUpdateOne) {
  25365. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  25366. }
  25367. if m.id == nil || m.oldValue == nil {
  25368. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  25369. }
  25370. oldValue, err := m.oldValue(ctx)
  25371. if err != nil {
  25372. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  25373. }
  25374. return oldValue.ActionLabelDel, nil
  25375. }
  25376. // AppendActionLabelDel adds u to the "action_label_del" field.
  25377. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  25378. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25379. }
  25380. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25381. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25382. if len(m.appendaction_label_del) == 0 {
  25383. return nil, false
  25384. }
  25385. return m.appendaction_label_del, true
  25386. }
  25387. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25388. func (m *SopStageMutation) ClearActionLabelDel() {
  25389. m.action_label_del = nil
  25390. m.appendaction_label_del = nil
  25391. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  25392. }
  25393. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25394. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  25395. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  25396. return ok
  25397. }
  25398. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25399. func (m *SopStageMutation) ResetActionLabelDel() {
  25400. m.action_label_del = nil
  25401. m.appendaction_label_del = nil
  25402. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  25403. }
  25404. // SetActionForward sets the "action_forward" field.
  25405. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25406. m.action_forward = &ctf
  25407. }
  25408. // ActionForward returns the value of the "action_forward" field in the mutation.
  25409. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25410. v := m.action_forward
  25411. if v == nil {
  25412. return
  25413. }
  25414. return *v, true
  25415. }
  25416. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  25417. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25419. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25420. if !m.op.Is(OpUpdateOne) {
  25421. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25422. }
  25423. if m.id == nil || m.oldValue == nil {
  25424. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25425. }
  25426. oldValue, err := m.oldValue(ctx)
  25427. if err != nil {
  25428. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25429. }
  25430. return oldValue.ActionForward, nil
  25431. }
  25432. // ClearActionForward clears the value of the "action_forward" field.
  25433. func (m *SopStageMutation) ClearActionForward() {
  25434. m.action_forward = nil
  25435. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  25436. }
  25437. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25438. func (m *SopStageMutation) ActionForwardCleared() bool {
  25439. _, ok := m.clearedFields[sopstage.FieldActionForward]
  25440. return ok
  25441. }
  25442. // ResetActionForward resets all changes to the "action_forward" field.
  25443. func (m *SopStageMutation) ResetActionForward() {
  25444. m.action_forward = nil
  25445. delete(m.clearedFields, sopstage.FieldActionForward)
  25446. }
  25447. // SetIndexSort sets the "index_sort" field.
  25448. func (m *SopStageMutation) SetIndexSort(i int) {
  25449. m.index_sort = &i
  25450. m.addindex_sort = nil
  25451. }
  25452. // IndexSort returns the value of the "index_sort" field in the mutation.
  25453. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  25454. v := m.index_sort
  25455. if v == nil {
  25456. return
  25457. }
  25458. return *v, true
  25459. }
  25460. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  25461. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25463. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  25464. if !m.op.Is(OpUpdateOne) {
  25465. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  25466. }
  25467. if m.id == nil || m.oldValue == nil {
  25468. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  25469. }
  25470. oldValue, err := m.oldValue(ctx)
  25471. if err != nil {
  25472. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  25473. }
  25474. return oldValue.IndexSort, nil
  25475. }
  25476. // AddIndexSort adds i to the "index_sort" field.
  25477. func (m *SopStageMutation) AddIndexSort(i int) {
  25478. if m.addindex_sort != nil {
  25479. *m.addindex_sort += i
  25480. } else {
  25481. m.addindex_sort = &i
  25482. }
  25483. }
  25484. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  25485. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  25486. v := m.addindex_sort
  25487. if v == nil {
  25488. return
  25489. }
  25490. return *v, true
  25491. }
  25492. // ClearIndexSort clears the value of the "index_sort" field.
  25493. func (m *SopStageMutation) ClearIndexSort() {
  25494. m.index_sort = nil
  25495. m.addindex_sort = nil
  25496. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  25497. }
  25498. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  25499. func (m *SopStageMutation) IndexSortCleared() bool {
  25500. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  25501. return ok
  25502. }
  25503. // ResetIndexSort resets all changes to the "index_sort" field.
  25504. func (m *SopStageMutation) ResetIndexSort() {
  25505. m.index_sort = nil
  25506. m.addindex_sort = nil
  25507. delete(m.clearedFields, sopstage.FieldIndexSort)
  25508. }
  25509. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  25510. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  25511. m.sop_task = &id
  25512. }
  25513. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  25514. func (m *SopStageMutation) ClearSopTask() {
  25515. m.clearedsop_task = true
  25516. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  25517. }
  25518. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  25519. func (m *SopStageMutation) SopTaskCleared() bool {
  25520. return m.clearedsop_task
  25521. }
  25522. // SopTaskID returns the "sop_task" edge ID in the mutation.
  25523. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  25524. if m.sop_task != nil {
  25525. return *m.sop_task, true
  25526. }
  25527. return
  25528. }
  25529. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  25530. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25531. // SopTaskID instead. It exists only for internal usage by the builders.
  25532. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  25533. if id := m.sop_task; id != nil {
  25534. ids = append(ids, *id)
  25535. }
  25536. return
  25537. }
  25538. // ResetSopTask resets all changes to the "sop_task" edge.
  25539. func (m *SopStageMutation) ResetSopTask() {
  25540. m.sop_task = nil
  25541. m.clearedsop_task = false
  25542. }
  25543. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  25544. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  25545. if m.stage_nodes == nil {
  25546. m.stage_nodes = make(map[uint64]struct{})
  25547. }
  25548. for i := range ids {
  25549. m.stage_nodes[ids[i]] = struct{}{}
  25550. }
  25551. }
  25552. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  25553. func (m *SopStageMutation) ClearStageNodes() {
  25554. m.clearedstage_nodes = true
  25555. }
  25556. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  25557. func (m *SopStageMutation) StageNodesCleared() bool {
  25558. return m.clearedstage_nodes
  25559. }
  25560. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  25561. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  25562. if m.removedstage_nodes == nil {
  25563. m.removedstage_nodes = make(map[uint64]struct{})
  25564. }
  25565. for i := range ids {
  25566. delete(m.stage_nodes, ids[i])
  25567. m.removedstage_nodes[ids[i]] = struct{}{}
  25568. }
  25569. }
  25570. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  25571. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  25572. for id := range m.removedstage_nodes {
  25573. ids = append(ids, id)
  25574. }
  25575. return
  25576. }
  25577. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  25578. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  25579. for id := range m.stage_nodes {
  25580. ids = append(ids, id)
  25581. }
  25582. return
  25583. }
  25584. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  25585. func (m *SopStageMutation) ResetStageNodes() {
  25586. m.stage_nodes = nil
  25587. m.clearedstage_nodes = false
  25588. m.removedstage_nodes = nil
  25589. }
  25590. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  25591. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  25592. if m.stage_messages == nil {
  25593. m.stage_messages = make(map[uint64]struct{})
  25594. }
  25595. for i := range ids {
  25596. m.stage_messages[ids[i]] = struct{}{}
  25597. }
  25598. }
  25599. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  25600. func (m *SopStageMutation) ClearStageMessages() {
  25601. m.clearedstage_messages = true
  25602. }
  25603. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  25604. func (m *SopStageMutation) StageMessagesCleared() bool {
  25605. return m.clearedstage_messages
  25606. }
  25607. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  25608. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  25609. if m.removedstage_messages == nil {
  25610. m.removedstage_messages = make(map[uint64]struct{})
  25611. }
  25612. for i := range ids {
  25613. delete(m.stage_messages, ids[i])
  25614. m.removedstage_messages[ids[i]] = struct{}{}
  25615. }
  25616. }
  25617. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  25618. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  25619. for id := range m.removedstage_messages {
  25620. ids = append(ids, id)
  25621. }
  25622. return
  25623. }
  25624. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  25625. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  25626. for id := range m.stage_messages {
  25627. ids = append(ids, id)
  25628. }
  25629. return
  25630. }
  25631. // ResetStageMessages resets all changes to the "stage_messages" edge.
  25632. func (m *SopStageMutation) ResetStageMessages() {
  25633. m.stage_messages = nil
  25634. m.clearedstage_messages = false
  25635. m.removedstage_messages = nil
  25636. }
  25637. // Where appends a list predicates to the SopStageMutation builder.
  25638. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  25639. m.predicates = append(m.predicates, ps...)
  25640. }
  25641. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  25642. // users can use type-assertion to append predicates that do not depend on any generated package.
  25643. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  25644. p := make([]predicate.SopStage, len(ps))
  25645. for i := range ps {
  25646. p[i] = ps[i]
  25647. }
  25648. m.Where(p...)
  25649. }
  25650. // Op returns the operation name.
  25651. func (m *SopStageMutation) Op() Op {
  25652. return m.op
  25653. }
  25654. // SetOp allows setting the mutation operation.
  25655. func (m *SopStageMutation) SetOp(op Op) {
  25656. m.op = op
  25657. }
  25658. // Type returns the node type of this mutation (SopStage).
  25659. func (m *SopStageMutation) Type() string {
  25660. return m.typ
  25661. }
  25662. // Fields returns all fields that were changed during this mutation. Note that in
  25663. // order to get all numeric fields that were incremented/decremented, call
  25664. // AddedFields().
  25665. func (m *SopStageMutation) Fields() []string {
  25666. fields := make([]string, 0, 14)
  25667. if m.created_at != nil {
  25668. fields = append(fields, sopstage.FieldCreatedAt)
  25669. }
  25670. if m.updated_at != nil {
  25671. fields = append(fields, sopstage.FieldUpdatedAt)
  25672. }
  25673. if m.status != nil {
  25674. fields = append(fields, sopstage.FieldStatus)
  25675. }
  25676. if m.deleted_at != nil {
  25677. fields = append(fields, sopstage.FieldDeletedAt)
  25678. }
  25679. if m.sop_task != nil {
  25680. fields = append(fields, sopstage.FieldTaskID)
  25681. }
  25682. if m.name != nil {
  25683. fields = append(fields, sopstage.FieldName)
  25684. }
  25685. if m.condition_type != nil {
  25686. fields = append(fields, sopstage.FieldConditionType)
  25687. }
  25688. if m.condition_operator != nil {
  25689. fields = append(fields, sopstage.FieldConditionOperator)
  25690. }
  25691. if m.condition_list != nil {
  25692. fields = append(fields, sopstage.FieldConditionList)
  25693. }
  25694. if m.action_message != nil {
  25695. fields = append(fields, sopstage.FieldActionMessage)
  25696. }
  25697. if m.action_label_add != nil {
  25698. fields = append(fields, sopstage.FieldActionLabelAdd)
  25699. }
  25700. if m.action_label_del != nil {
  25701. fields = append(fields, sopstage.FieldActionLabelDel)
  25702. }
  25703. if m.action_forward != nil {
  25704. fields = append(fields, sopstage.FieldActionForward)
  25705. }
  25706. if m.index_sort != nil {
  25707. fields = append(fields, sopstage.FieldIndexSort)
  25708. }
  25709. return fields
  25710. }
  25711. // Field returns the value of a field with the given name. The second boolean
  25712. // return value indicates that this field was not set, or was not defined in the
  25713. // schema.
  25714. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  25715. switch name {
  25716. case sopstage.FieldCreatedAt:
  25717. return m.CreatedAt()
  25718. case sopstage.FieldUpdatedAt:
  25719. return m.UpdatedAt()
  25720. case sopstage.FieldStatus:
  25721. return m.Status()
  25722. case sopstage.FieldDeletedAt:
  25723. return m.DeletedAt()
  25724. case sopstage.FieldTaskID:
  25725. return m.TaskID()
  25726. case sopstage.FieldName:
  25727. return m.Name()
  25728. case sopstage.FieldConditionType:
  25729. return m.ConditionType()
  25730. case sopstage.FieldConditionOperator:
  25731. return m.ConditionOperator()
  25732. case sopstage.FieldConditionList:
  25733. return m.ConditionList()
  25734. case sopstage.FieldActionMessage:
  25735. return m.ActionMessage()
  25736. case sopstage.FieldActionLabelAdd:
  25737. return m.ActionLabelAdd()
  25738. case sopstage.FieldActionLabelDel:
  25739. return m.ActionLabelDel()
  25740. case sopstage.FieldActionForward:
  25741. return m.ActionForward()
  25742. case sopstage.FieldIndexSort:
  25743. return m.IndexSort()
  25744. }
  25745. return nil, false
  25746. }
  25747. // OldField returns the old value of the field from the database. An error is
  25748. // returned if the mutation operation is not UpdateOne, or the query to the
  25749. // database failed.
  25750. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25751. switch name {
  25752. case sopstage.FieldCreatedAt:
  25753. return m.OldCreatedAt(ctx)
  25754. case sopstage.FieldUpdatedAt:
  25755. return m.OldUpdatedAt(ctx)
  25756. case sopstage.FieldStatus:
  25757. return m.OldStatus(ctx)
  25758. case sopstage.FieldDeletedAt:
  25759. return m.OldDeletedAt(ctx)
  25760. case sopstage.FieldTaskID:
  25761. return m.OldTaskID(ctx)
  25762. case sopstage.FieldName:
  25763. return m.OldName(ctx)
  25764. case sopstage.FieldConditionType:
  25765. return m.OldConditionType(ctx)
  25766. case sopstage.FieldConditionOperator:
  25767. return m.OldConditionOperator(ctx)
  25768. case sopstage.FieldConditionList:
  25769. return m.OldConditionList(ctx)
  25770. case sopstage.FieldActionMessage:
  25771. return m.OldActionMessage(ctx)
  25772. case sopstage.FieldActionLabelAdd:
  25773. return m.OldActionLabelAdd(ctx)
  25774. case sopstage.FieldActionLabelDel:
  25775. return m.OldActionLabelDel(ctx)
  25776. case sopstage.FieldActionForward:
  25777. return m.OldActionForward(ctx)
  25778. case sopstage.FieldIndexSort:
  25779. return m.OldIndexSort(ctx)
  25780. }
  25781. return nil, fmt.Errorf("unknown SopStage field %s", name)
  25782. }
  25783. // SetField sets the value of a field with the given name. It returns an error if
  25784. // the field is not defined in the schema, or if the type mismatched the field
  25785. // type.
  25786. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  25787. switch name {
  25788. case sopstage.FieldCreatedAt:
  25789. v, ok := value.(time.Time)
  25790. if !ok {
  25791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25792. }
  25793. m.SetCreatedAt(v)
  25794. return nil
  25795. case sopstage.FieldUpdatedAt:
  25796. v, ok := value.(time.Time)
  25797. if !ok {
  25798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25799. }
  25800. m.SetUpdatedAt(v)
  25801. return nil
  25802. case sopstage.FieldStatus:
  25803. v, ok := value.(uint8)
  25804. if !ok {
  25805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25806. }
  25807. m.SetStatus(v)
  25808. return nil
  25809. case sopstage.FieldDeletedAt:
  25810. v, ok := value.(time.Time)
  25811. if !ok {
  25812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25813. }
  25814. m.SetDeletedAt(v)
  25815. return nil
  25816. case sopstage.FieldTaskID:
  25817. v, ok := value.(uint64)
  25818. if !ok {
  25819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25820. }
  25821. m.SetTaskID(v)
  25822. return nil
  25823. case sopstage.FieldName:
  25824. v, ok := value.(string)
  25825. if !ok {
  25826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25827. }
  25828. m.SetName(v)
  25829. return nil
  25830. case sopstage.FieldConditionType:
  25831. v, ok := value.(int)
  25832. if !ok {
  25833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25834. }
  25835. m.SetConditionType(v)
  25836. return nil
  25837. case sopstage.FieldConditionOperator:
  25838. v, ok := value.(int)
  25839. if !ok {
  25840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25841. }
  25842. m.SetConditionOperator(v)
  25843. return nil
  25844. case sopstage.FieldConditionList:
  25845. v, ok := value.([]custom_types.Condition)
  25846. if !ok {
  25847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25848. }
  25849. m.SetConditionList(v)
  25850. return nil
  25851. case sopstage.FieldActionMessage:
  25852. v, ok := value.([]custom_types.Action)
  25853. if !ok {
  25854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25855. }
  25856. m.SetActionMessage(v)
  25857. return nil
  25858. case sopstage.FieldActionLabelAdd:
  25859. v, ok := value.([]uint64)
  25860. if !ok {
  25861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25862. }
  25863. m.SetActionLabelAdd(v)
  25864. return nil
  25865. case sopstage.FieldActionLabelDel:
  25866. v, ok := value.([]uint64)
  25867. if !ok {
  25868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25869. }
  25870. m.SetActionLabelDel(v)
  25871. return nil
  25872. case sopstage.FieldActionForward:
  25873. v, ok := value.(*custom_types.ActionForward)
  25874. if !ok {
  25875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25876. }
  25877. m.SetActionForward(v)
  25878. return nil
  25879. case sopstage.FieldIndexSort:
  25880. v, ok := value.(int)
  25881. if !ok {
  25882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25883. }
  25884. m.SetIndexSort(v)
  25885. return nil
  25886. }
  25887. return fmt.Errorf("unknown SopStage field %s", name)
  25888. }
  25889. // AddedFields returns all numeric fields that were incremented/decremented during
  25890. // this mutation.
  25891. func (m *SopStageMutation) AddedFields() []string {
  25892. var fields []string
  25893. if m.addstatus != nil {
  25894. fields = append(fields, sopstage.FieldStatus)
  25895. }
  25896. if m.addcondition_type != nil {
  25897. fields = append(fields, sopstage.FieldConditionType)
  25898. }
  25899. if m.addcondition_operator != nil {
  25900. fields = append(fields, sopstage.FieldConditionOperator)
  25901. }
  25902. if m.addindex_sort != nil {
  25903. fields = append(fields, sopstage.FieldIndexSort)
  25904. }
  25905. return fields
  25906. }
  25907. // AddedField returns the numeric value that was incremented/decremented on a field
  25908. // with the given name. The second boolean return value indicates that this field
  25909. // was not set, or was not defined in the schema.
  25910. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  25911. switch name {
  25912. case sopstage.FieldStatus:
  25913. return m.AddedStatus()
  25914. case sopstage.FieldConditionType:
  25915. return m.AddedConditionType()
  25916. case sopstage.FieldConditionOperator:
  25917. return m.AddedConditionOperator()
  25918. case sopstage.FieldIndexSort:
  25919. return m.AddedIndexSort()
  25920. }
  25921. return nil, false
  25922. }
  25923. // AddField adds the value to the field with the given name. It returns an error if
  25924. // the field is not defined in the schema, or if the type mismatched the field
  25925. // type.
  25926. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  25927. switch name {
  25928. case sopstage.FieldStatus:
  25929. v, ok := value.(int8)
  25930. if !ok {
  25931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25932. }
  25933. m.AddStatus(v)
  25934. return nil
  25935. case sopstage.FieldConditionType:
  25936. v, ok := value.(int)
  25937. if !ok {
  25938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25939. }
  25940. m.AddConditionType(v)
  25941. return nil
  25942. case sopstage.FieldConditionOperator:
  25943. v, ok := value.(int)
  25944. if !ok {
  25945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25946. }
  25947. m.AddConditionOperator(v)
  25948. return nil
  25949. case sopstage.FieldIndexSort:
  25950. v, ok := value.(int)
  25951. if !ok {
  25952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25953. }
  25954. m.AddIndexSort(v)
  25955. return nil
  25956. }
  25957. return fmt.Errorf("unknown SopStage numeric field %s", name)
  25958. }
  25959. // ClearedFields returns all nullable fields that were cleared during this
  25960. // mutation.
  25961. func (m *SopStageMutation) ClearedFields() []string {
  25962. var fields []string
  25963. if m.FieldCleared(sopstage.FieldStatus) {
  25964. fields = append(fields, sopstage.FieldStatus)
  25965. }
  25966. if m.FieldCleared(sopstage.FieldDeletedAt) {
  25967. fields = append(fields, sopstage.FieldDeletedAt)
  25968. }
  25969. if m.FieldCleared(sopstage.FieldActionMessage) {
  25970. fields = append(fields, sopstage.FieldActionMessage)
  25971. }
  25972. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  25973. fields = append(fields, sopstage.FieldActionLabelAdd)
  25974. }
  25975. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  25976. fields = append(fields, sopstage.FieldActionLabelDel)
  25977. }
  25978. if m.FieldCleared(sopstage.FieldActionForward) {
  25979. fields = append(fields, sopstage.FieldActionForward)
  25980. }
  25981. if m.FieldCleared(sopstage.FieldIndexSort) {
  25982. fields = append(fields, sopstage.FieldIndexSort)
  25983. }
  25984. return fields
  25985. }
  25986. // FieldCleared returns a boolean indicating if a field with the given name was
  25987. // cleared in this mutation.
  25988. func (m *SopStageMutation) FieldCleared(name string) bool {
  25989. _, ok := m.clearedFields[name]
  25990. return ok
  25991. }
  25992. // ClearField clears the value of the field with the given name. It returns an
  25993. // error if the field is not defined in the schema.
  25994. func (m *SopStageMutation) ClearField(name string) error {
  25995. switch name {
  25996. case sopstage.FieldStatus:
  25997. m.ClearStatus()
  25998. return nil
  25999. case sopstage.FieldDeletedAt:
  26000. m.ClearDeletedAt()
  26001. return nil
  26002. case sopstage.FieldActionMessage:
  26003. m.ClearActionMessage()
  26004. return nil
  26005. case sopstage.FieldActionLabelAdd:
  26006. m.ClearActionLabelAdd()
  26007. return nil
  26008. case sopstage.FieldActionLabelDel:
  26009. m.ClearActionLabelDel()
  26010. return nil
  26011. case sopstage.FieldActionForward:
  26012. m.ClearActionForward()
  26013. return nil
  26014. case sopstage.FieldIndexSort:
  26015. m.ClearIndexSort()
  26016. return nil
  26017. }
  26018. return fmt.Errorf("unknown SopStage nullable field %s", name)
  26019. }
  26020. // ResetField resets all changes in the mutation for the field with the given name.
  26021. // It returns an error if the field is not defined in the schema.
  26022. func (m *SopStageMutation) ResetField(name string) error {
  26023. switch name {
  26024. case sopstage.FieldCreatedAt:
  26025. m.ResetCreatedAt()
  26026. return nil
  26027. case sopstage.FieldUpdatedAt:
  26028. m.ResetUpdatedAt()
  26029. return nil
  26030. case sopstage.FieldStatus:
  26031. m.ResetStatus()
  26032. return nil
  26033. case sopstage.FieldDeletedAt:
  26034. m.ResetDeletedAt()
  26035. return nil
  26036. case sopstage.FieldTaskID:
  26037. m.ResetTaskID()
  26038. return nil
  26039. case sopstage.FieldName:
  26040. m.ResetName()
  26041. return nil
  26042. case sopstage.FieldConditionType:
  26043. m.ResetConditionType()
  26044. return nil
  26045. case sopstage.FieldConditionOperator:
  26046. m.ResetConditionOperator()
  26047. return nil
  26048. case sopstage.FieldConditionList:
  26049. m.ResetConditionList()
  26050. return nil
  26051. case sopstage.FieldActionMessage:
  26052. m.ResetActionMessage()
  26053. return nil
  26054. case sopstage.FieldActionLabelAdd:
  26055. m.ResetActionLabelAdd()
  26056. return nil
  26057. case sopstage.FieldActionLabelDel:
  26058. m.ResetActionLabelDel()
  26059. return nil
  26060. case sopstage.FieldActionForward:
  26061. m.ResetActionForward()
  26062. return nil
  26063. case sopstage.FieldIndexSort:
  26064. m.ResetIndexSort()
  26065. return nil
  26066. }
  26067. return fmt.Errorf("unknown SopStage field %s", name)
  26068. }
  26069. // AddedEdges returns all edge names that were set/added in this mutation.
  26070. func (m *SopStageMutation) AddedEdges() []string {
  26071. edges := make([]string, 0, 3)
  26072. if m.sop_task != nil {
  26073. edges = append(edges, sopstage.EdgeSopTask)
  26074. }
  26075. if m.stage_nodes != nil {
  26076. edges = append(edges, sopstage.EdgeStageNodes)
  26077. }
  26078. if m.stage_messages != nil {
  26079. edges = append(edges, sopstage.EdgeStageMessages)
  26080. }
  26081. return edges
  26082. }
  26083. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26084. // name in this mutation.
  26085. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  26086. switch name {
  26087. case sopstage.EdgeSopTask:
  26088. if id := m.sop_task; id != nil {
  26089. return []ent.Value{*id}
  26090. }
  26091. case sopstage.EdgeStageNodes:
  26092. ids := make([]ent.Value, 0, len(m.stage_nodes))
  26093. for id := range m.stage_nodes {
  26094. ids = append(ids, id)
  26095. }
  26096. return ids
  26097. case sopstage.EdgeStageMessages:
  26098. ids := make([]ent.Value, 0, len(m.stage_messages))
  26099. for id := range m.stage_messages {
  26100. ids = append(ids, id)
  26101. }
  26102. return ids
  26103. }
  26104. return nil
  26105. }
  26106. // RemovedEdges returns all edge names that were removed in this mutation.
  26107. func (m *SopStageMutation) RemovedEdges() []string {
  26108. edges := make([]string, 0, 3)
  26109. if m.removedstage_nodes != nil {
  26110. edges = append(edges, sopstage.EdgeStageNodes)
  26111. }
  26112. if m.removedstage_messages != nil {
  26113. edges = append(edges, sopstage.EdgeStageMessages)
  26114. }
  26115. return edges
  26116. }
  26117. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26118. // the given name in this mutation.
  26119. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  26120. switch name {
  26121. case sopstage.EdgeStageNodes:
  26122. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  26123. for id := range m.removedstage_nodes {
  26124. ids = append(ids, id)
  26125. }
  26126. return ids
  26127. case sopstage.EdgeStageMessages:
  26128. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  26129. for id := range m.removedstage_messages {
  26130. ids = append(ids, id)
  26131. }
  26132. return ids
  26133. }
  26134. return nil
  26135. }
  26136. // ClearedEdges returns all edge names that were cleared in this mutation.
  26137. func (m *SopStageMutation) ClearedEdges() []string {
  26138. edges := make([]string, 0, 3)
  26139. if m.clearedsop_task {
  26140. edges = append(edges, sopstage.EdgeSopTask)
  26141. }
  26142. if m.clearedstage_nodes {
  26143. edges = append(edges, sopstage.EdgeStageNodes)
  26144. }
  26145. if m.clearedstage_messages {
  26146. edges = append(edges, sopstage.EdgeStageMessages)
  26147. }
  26148. return edges
  26149. }
  26150. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26151. // was cleared in this mutation.
  26152. func (m *SopStageMutation) EdgeCleared(name string) bool {
  26153. switch name {
  26154. case sopstage.EdgeSopTask:
  26155. return m.clearedsop_task
  26156. case sopstage.EdgeStageNodes:
  26157. return m.clearedstage_nodes
  26158. case sopstage.EdgeStageMessages:
  26159. return m.clearedstage_messages
  26160. }
  26161. return false
  26162. }
  26163. // ClearEdge clears the value of the edge with the given name. It returns an error
  26164. // if that edge is not defined in the schema.
  26165. func (m *SopStageMutation) ClearEdge(name string) error {
  26166. switch name {
  26167. case sopstage.EdgeSopTask:
  26168. m.ClearSopTask()
  26169. return nil
  26170. }
  26171. return fmt.Errorf("unknown SopStage unique edge %s", name)
  26172. }
  26173. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26174. // It returns an error if the edge is not defined in the schema.
  26175. func (m *SopStageMutation) ResetEdge(name string) error {
  26176. switch name {
  26177. case sopstage.EdgeSopTask:
  26178. m.ResetSopTask()
  26179. return nil
  26180. case sopstage.EdgeStageNodes:
  26181. m.ResetStageNodes()
  26182. return nil
  26183. case sopstage.EdgeStageMessages:
  26184. m.ResetStageMessages()
  26185. return nil
  26186. }
  26187. return fmt.Errorf("unknown SopStage edge %s", name)
  26188. }
  26189. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  26190. type SopTaskMutation struct {
  26191. config
  26192. op Op
  26193. typ string
  26194. id *uint64
  26195. created_at *time.Time
  26196. updated_at *time.Time
  26197. status *uint8
  26198. addstatus *int8
  26199. deleted_at *time.Time
  26200. name *string
  26201. bot_wxid_list *[]string
  26202. appendbot_wxid_list []string
  26203. _type *int
  26204. add_type *int
  26205. plan_start_time *time.Time
  26206. plan_end_time *time.Time
  26207. creator_id *string
  26208. organization_id *uint64
  26209. addorganization_id *int64
  26210. token *[]string
  26211. appendtoken []string
  26212. clearedFields map[string]struct{}
  26213. task_stages map[uint64]struct{}
  26214. removedtask_stages map[uint64]struct{}
  26215. clearedtask_stages bool
  26216. done bool
  26217. oldValue func(context.Context) (*SopTask, error)
  26218. predicates []predicate.SopTask
  26219. }
  26220. var _ ent.Mutation = (*SopTaskMutation)(nil)
  26221. // soptaskOption allows management of the mutation configuration using functional options.
  26222. type soptaskOption func(*SopTaskMutation)
  26223. // newSopTaskMutation creates new mutation for the SopTask entity.
  26224. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  26225. m := &SopTaskMutation{
  26226. config: c,
  26227. op: op,
  26228. typ: TypeSopTask,
  26229. clearedFields: make(map[string]struct{}),
  26230. }
  26231. for _, opt := range opts {
  26232. opt(m)
  26233. }
  26234. return m
  26235. }
  26236. // withSopTaskID sets the ID field of the mutation.
  26237. func withSopTaskID(id uint64) soptaskOption {
  26238. return func(m *SopTaskMutation) {
  26239. var (
  26240. err error
  26241. once sync.Once
  26242. value *SopTask
  26243. )
  26244. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  26245. once.Do(func() {
  26246. if m.done {
  26247. err = errors.New("querying old values post mutation is not allowed")
  26248. } else {
  26249. value, err = m.Client().SopTask.Get(ctx, id)
  26250. }
  26251. })
  26252. return value, err
  26253. }
  26254. m.id = &id
  26255. }
  26256. }
  26257. // withSopTask sets the old SopTask of the mutation.
  26258. func withSopTask(node *SopTask) soptaskOption {
  26259. return func(m *SopTaskMutation) {
  26260. m.oldValue = func(context.Context) (*SopTask, error) {
  26261. return node, nil
  26262. }
  26263. m.id = &node.ID
  26264. }
  26265. }
  26266. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26267. // executed in a transaction (ent.Tx), a transactional client is returned.
  26268. func (m SopTaskMutation) Client() *Client {
  26269. client := &Client{config: m.config}
  26270. client.init()
  26271. return client
  26272. }
  26273. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26274. // it returns an error otherwise.
  26275. func (m SopTaskMutation) Tx() (*Tx, error) {
  26276. if _, ok := m.driver.(*txDriver); !ok {
  26277. return nil, errors.New("ent: mutation is not running in a transaction")
  26278. }
  26279. tx := &Tx{config: m.config}
  26280. tx.init()
  26281. return tx, nil
  26282. }
  26283. // SetID sets the value of the id field. Note that this
  26284. // operation is only accepted on creation of SopTask entities.
  26285. func (m *SopTaskMutation) SetID(id uint64) {
  26286. m.id = &id
  26287. }
  26288. // ID returns the ID value in the mutation. Note that the ID is only available
  26289. // if it was provided to the builder or after it was returned from the database.
  26290. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  26291. if m.id == nil {
  26292. return
  26293. }
  26294. return *m.id, true
  26295. }
  26296. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26297. // That means, if the mutation is applied within a transaction with an isolation level such
  26298. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26299. // or updated by the mutation.
  26300. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  26301. switch {
  26302. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26303. id, exists := m.ID()
  26304. if exists {
  26305. return []uint64{id}, nil
  26306. }
  26307. fallthrough
  26308. case m.op.Is(OpUpdate | OpDelete):
  26309. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  26310. default:
  26311. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26312. }
  26313. }
  26314. // SetCreatedAt sets the "created_at" field.
  26315. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  26316. m.created_at = &t
  26317. }
  26318. // CreatedAt returns the value of the "created_at" field in the mutation.
  26319. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  26320. v := m.created_at
  26321. if v == nil {
  26322. return
  26323. }
  26324. return *v, true
  26325. }
  26326. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  26327. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26329. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26330. if !m.op.Is(OpUpdateOne) {
  26331. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26332. }
  26333. if m.id == nil || m.oldValue == nil {
  26334. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26335. }
  26336. oldValue, err := m.oldValue(ctx)
  26337. if err != nil {
  26338. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26339. }
  26340. return oldValue.CreatedAt, nil
  26341. }
  26342. // ResetCreatedAt resets all changes to the "created_at" field.
  26343. func (m *SopTaskMutation) ResetCreatedAt() {
  26344. m.created_at = nil
  26345. }
  26346. // SetUpdatedAt sets the "updated_at" field.
  26347. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  26348. m.updated_at = &t
  26349. }
  26350. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26351. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  26352. v := m.updated_at
  26353. if v == nil {
  26354. return
  26355. }
  26356. return *v, true
  26357. }
  26358. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  26359. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26361. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26362. if !m.op.Is(OpUpdateOne) {
  26363. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26364. }
  26365. if m.id == nil || m.oldValue == nil {
  26366. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26367. }
  26368. oldValue, err := m.oldValue(ctx)
  26369. if err != nil {
  26370. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26371. }
  26372. return oldValue.UpdatedAt, nil
  26373. }
  26374. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26375. func (m *SopTaskMutation) ResetUpdatedAt() {
  26376. m.updated_at = nil
  26377. }
  26378. // SetStatus sets the "status" field.
  26379. func (m *SopTaskMutation) SetStatus(u uint8) {
  26380. m.status = &u
  26381. m.addstatus = nil
  26382. }
  26383. // Status returns the value of the "status" field in the mutation.
  26384. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  26385. v := m.status
  26386. if v == nil {
  26387. return
  26388. }
  26389. return *v, true
  26390. }
  26391. // OldStatus returns the old "status" field's value of the SopTask entity.
  26392. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26394. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26395. if !m.op.Is(OpUpdateOne) {
  26396. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26397. }
  26398. if m.id == nil || m.oldValue == nil {
  26399. return v, errors.New("OldStatus requires an ID field in the mutation")
  26400. }
  26401. oldValue, err := m.oldValue(ctx)
  26402. if err != nil {
  26403. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26404. }
  26405. return oldValue.Status, nil
  26406. }
  26407. // AddStatus adds u to the "status" field.
  26408. func (m *SopTaskMutation) AddStatus(u int8) {
  26409. if m.addstatus != nil {
  26410. *m.addstatus += u
  26411. } else {
  26412. m.addstatus = &u
  26413. }
  26414. }
  26415. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26416. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  26417. v := m.addstatus
  26418. if v == nil {
  26419. return
  26420. }
  26421. return *v, true
  26422. }
  26423. // ClearStatus clears the value of the "status" field.
  26424. func (m *SopTaskMutation) ClearStatus() {
  26425. m.status = nil
  26426. m.addstatus = nil
  26427. m.clearedFields[soptask.FieldStatus] = struct{}{}
  26428. }
  26429. // StatusCleared returns if the "status" field was cleared in this mutation.
  26430. func (m *SopTaskMutation) StatusCleared() bool {
  26431. _, ok := m.clearedFields[soptask.FieldStatus]
  26432. return ok
  26433. }
  26434. // ResetStatus resets all changes to the "status" field.
  26435. func (m *SopTaskMutation) ResetStatus() {
  26436. m.status = nil
  26437. m.addstatus = nil
  26438. delete(m.clearedFields, soptask.FieldStatus)
  26439. }
  26440. // SetDeletedAt sets the "deleted_at" field.
  26441. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  26442. m.deleted_at = &t
  26443. }
  26444. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26445. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  26446. v := m.deleted_at
  26447. if v == nil {
  26448. return
  26449. }
  26450. return *v, true
  26451. }
  26452. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  26453. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26455. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26456. if !m.op.Is(OpUpdateOne) {
  26457. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26458. }
  26459. if m.id == nil || m.oldValue == nil {
  26460. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26461. }
  26462. oldValue, err := m.oldValue(ctx)
  26463. if err != nil {
  26464. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26465. }
  26466. return oldValue.DeletedAt, nil
  26467. }
  26468. // ClearDeletedAt clears the value of the "deleted_at" field.
  26469. func (m *SopTaskMutation) ClearDeletedAt() {
  26470. m.deleted_at = nil
  26471. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  26472. }
  26473. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26474. func (m *SopTaskMutation) DeletedAtCleared() bool {
  26475. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  26476. return ok
  26477. }
  26478. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26479. func (m *SopTaskMutation) ResetDeletedAt() {
  26480. m.deleted_at = nil
  26481. delete(m.clearedFields, soptask.FieldDeletedAt)
  26482. }
  26483. // SetName sets the "name" field.
  26484. func (m *SopTaskMutation) SetName(s string) {
  26485. m.name = &s
  26486. }
  26487. // Name returns the value of the "name" field in the mutation.
  26488. func (m *SopTaskMutation) Name() (r string, exists bool) {
  26489. v := m.name
  26490. if v == nil {
  26491. return
  26492. }
  26493. return *v, true
  26494. }
  26495. // OldName returns the old "name" field's value of the SopTask entity.
  26496. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26498. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  26499. if !m.op.Is(OpUpdateOne) {
  26500. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26501. }
  26502. if m.id == nil || m.oldValue == nil {
  26503. return v, errors.New("OldName requires an ID field in the mutation")
  26504. }
  26505. oldValue, err := m.oldValue(ctx)
  26506. if err != nil {
  26507. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26508. }
  26509. return oldValue.Name, nil
  26510. }
  26511. // ResetName resets all changes to the "name" field.
  26512. func (m *SopTaskMutation) ResetName() {
  26513. m.name = nil
  26514. }
  26515. // SetBotWxidList sets the "bot_wxid_list" field.
  26516. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  26517. m.bot_wxid_list = &s
  26518. m.appendbot_wxid_list = nil
  26519. }
  26520. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  26521. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  26522. v := m.bot_wxid_list
  26523. if v == nil {
  26524. return
  26525. }
  26526. return *v, true
  26527. }
  26528. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  26529. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26531. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  26532. if !m.op.Is(OpUpdateOne) {
  26533. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  26534. }
  26535. if m.id == nil || m.oldValue == nil {
  26536. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  26537. }
  26538. oldValue, err := m.oldValue(ctx)
  26539. if err != nil {
  26540. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  26541. }
  26542. return oldValue.BotWxidList, nil
  26543. }
  26544. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  26545. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  26546. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  26547. }
  26548. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  26549. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  26550. if len(m.appendbot_wxid_list) == 0 {
  26551. return nil, false
  26552. }
  26553. return m.appendbot_wxid_list, true
  26554. }
  26555. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  26556. func (m *SopTaskMutation) ClearBotWxidList() {
  26557. m.bot_wxid_list = nil
  26558. m.appendbot_wxid_list = nil
  26559. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  26560. }
  26561. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  26562. func (m *SopTaskMutation) BotWxidListCleared() bool {
  26563. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  26564. return ok
  26565. }
  26566. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  26567. func (m *SopTaskMutation) ResetBotWxidList() {
  26568. m.bot_wxid_list = nil
  26569. m.appendbot_wxid_list = nil
  26570. delete(m.clearedFields, soptask.FieldBotWxidList)
  26571. }
  26572. // SetType sets the "type" field.
  26573. func (m *SopTaskMutation) SetType(i int) {
  26574. m._type = &i
  26575. m.add_type = nil
  26576. }
  26577. // GetType returns the value of the "type" field in the mutation.
  26578. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  26579. v := m._type
  26580. if v == nil {
  26581. return
  26582. }
  26583. return *v, true
  26584. }
  26585. // OldType returns the old "type" field's value of the SopTask entity.
  26586. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26588. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  26589. if !m.op.Is(OpUpdateOne) {
  26590. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26591. }
  26592. if m.id == nil || m.oldValue == nil {
  26593. return v, errors.New("OldType requires an ID field in the mutation")
  26594. }
  26595. oldValue, err := m.oldValue(ctx)
  26596. if err != nil {
  26597. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26598. }
  26599. return oldValue.Type, nil
  26600. }
  26601. // AddType adds i to the "type" field.
  26602. func (m *SopTaskMutation) AddType(i int) {
  26603. if m.add_type != nil {
  26604. *m.add_type += i
  26605. } else {
  26606. m.add_type = &i
  26607. }
  26608. }
  26609. // AddedType returns the value that was added to the "type" field in this mutation.
  26610. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  26611. v := m.add_type
  26612. if v == nil {
  26613. return
  26614. }
  26615. return *v, true
  26616. }
  26617. // ResetType resets all changes to the "type" field.
  26618. func (m *SopTaskMutation) ResetType() {
  26619. m._type = nil
  26620. m.add_type = nil
  26621. }
  26622. // SetPlanStartTime sets the "plan_start_time" field.
  26623. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  26624. m.plan_start_time = &t
  26625. }
  26626. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  26627. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  26628. v := m.plan_start_time
  26629. if v == nil {
  26630. return
  26631. }
  26632. return *v, true
  26633. }
  26634. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  26635. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26637. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  26638. if !m.op.Is(OpUpdateOne) {
  26639. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  26640. }
  26641. if m.id == nil || m.oldValue == nil {
  26642. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  26643. }
  26644. oldValue, err := m.oldValue(ctx)
  26645. if err != nil {
  26646. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  26647. }
  26648. return oldValue.PlanStartTime, nil
  26649. }
  26650. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  26651. func (m *SopTaskMutation) ClearPlanStartTime() {
  26652. m.plan_start_time = nil
  26653. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  26654. }
  26655. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  26656. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  26657. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  26658. return ok
  26659. }
  26660. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  26661. func (m *SopTaskMutation) ResetPlanStartTime() {
  26662. m.plan_start_time = nil
  26663. delete(m.clearedFields, soptask.FieldPlanStartTime)
  26664. }
  26665. // SetPlanEndTime sets the "plan_end_time" field.
  26666. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  26667. m.plan_end_time = &t
  26668. }
  26669. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  26670. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  26671. v := m.plan_end_time
  26672. if v == nil {
  26673. return
  26674. }
  26675. return *v, true
  26676. }
  26677. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  26678. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26680. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  26681. if !m.op.Is(OpUpdateOne) {
  26682. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  26683. }
  26684. if m.id == nil || m.oldValue == nil {
  26685. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  26686. }
  26687. oldValue, err := m.oldValue(ctx)
  26688. if err != nil {
  26689. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  26690. }
  26691. return oldValue.PlanEndTime, nil
  26692. }
  26693. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  26694. func (m *SopTaskMutation) ClearPlanEndTime() {
  26695. m.plan_end_time = nil
  26696. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  26697. }
  26698. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  26699. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  26700. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  26701. return ok
  26702. }
  26703. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  26704. func (m *SopTaskMutation) ResetPlanEndTime() {
  26705. m.plan_end_time = nil
  26706. delete(m.clearedFields, soptask.FieldPlanEndTime)
  26707. }
  26708. // SetCreatorID sets the "creator_id" field.
  26709. func (m *SopTaskMutation) SetCreatorID(s string) {
  26710. m.creator_id = &s
  26711. }
  26712. // CreatorID returns the value of the "creator_id" field in the mutation.
  26713. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  26714. v := m.creator_id
  26715. if v == nil {
  26716. return
  26717. }
  26718. return *v, true
  26719. }
  26720. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  26721. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26723. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  26724. if !m.op.Is(OpUpdateOne) {
  26725. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  26726. }
  26727. if m.id == nil || m.oldValue == nil {
  26728. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  26729. }
  26730. oldValue, err := m.oldValue(ctx)
  26731. if err != nil {
  26732. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  26733. }
  26734. return oldValue.CreatorID, nil
  26735. }
  26736. // ClearCreatorID clears the value of the "creator_id" field.
  26737. func (m *SopTaskMutation) ClearCreatorID() {
  26738. m.creator_id = nil
  26739. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  26740. }
  26741. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  26742. func (m *SopTaskMutation) CreatorIDCleared() bool {
  26743. _, ok := m.clearedFields[soptask.FieldCreatorID]
  26744. return ok
  26745. }
  26746. // ResetCreatorID resets all changes to the "creator_id" field.
  26747. func (m *SopTaskMutation) ResetCreatorID() {
  26748. m.creator_id = nil
  26749. delete(m.clearedFields, soptask.FieldCreatorID)
  26750. }
  26751. // SetOrganizationID sets the "organization_id" field.
  26752. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  26753. m.organization_id = &u
  26754. m.addorganization_id = nil
  26755. }
  26756. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26757. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  26758. v := m.organization_id
  26759. if v == nil {
  26760. return
  26761. }
  26762. return *v, true
  26763. }
  26764. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  26765. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26767. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26768. if !m.op.Is(OpUpdateOne) {
  26769. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26770. }
  26771. if m.id == nil || m.oldValue == nil {
  26772. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26773. }
  26774. oldValue, err := m.oldValue(ctx)
  26775. if err != nil {
  26776. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26777. }
  26778. return oldValue.OrganizationID, nil
  26779. }
  26780. // AddOrganizationID adds u to the "organization_id" field.
  26781. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  26782. if m.addorganization_id != nil {
  26783. *m.addorganization_id += u
  26784. } else {
  26785. m.addorganization_id = &u
  26786. }
  26787. }
  26788. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26789. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  26790. v := m.addorganization_id
  26791. if v == nil {
  26792. return
  26793. }
  26794. return *v, true
  26795. }
  26796. // ClearOrganizationID clears the value of the "organization_id" field.
  26797. func (m *SopTaskMutation) ClearOrganizationID() {
  26798. m.organization_id = nil
  26799. m.addorganization_id = nil
  26800. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  26801. }
  26802. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  26803. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  26804. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  26805. return ok
  26806. }
  26807. // ResetOrganizationID resets all changes to the "organization_id" field.
  26808. func (m *SopTaskMutation) ResetOrganizationID() {
  26809. m.organization_id = nil
  26810. m.addorganization_id = nil
  26811. delete(m.clearedFields, soptask.FieldOrganizationID)
  26812. }
  26813. // SetToken sets the "token" field.
  26814. func (m *SopTaskMutation) SetToken(s []string) {
  26815. m.token = &s
  26816. m.appendtoken = nil
  26817. }
  26818. // Token returns the value of the "token" field in the mutation.
  26819. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  26820. v := m.token
  26821. if v == nil {
  26822. return
  26823. }
  26824. return *v, true
  26825. }
  26826. // OldToken returns the old "token" field's value of the SopTask entity.
  26827. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26829. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  26830. if !m.op.Is(OpUpdateOne) {
  26831. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26832. }
  26833. if m.id == nil || m.oldValue == nil {
  26834. return v, errors.New("OldToken requires an ID field in the mutation")
  26835. }
  26836. oldValue, err := m.oldValue(ctx)
  26837. if err != nil {
  26838. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26839. }
  26840. return oldValue.Token, nil
  26841. }
  26842. // AppendToken adds s to the "token" field.
  26843. func (m *SopTaskMutation) AppendToken(s []string) {
  26844. m.appendtoken = append(m.appendtoken, s...)
  26845. }
  26846. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  26847. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  26848. if len(m.appendtoken) == 0 {
  26849. return nil, false
  26850. }
  26851. return m.appendtoken, true
  26852. }
  26853. // ClearToken clears the value of the "token" field.
  26854. func (m *SopTaskMutation) ClearToken() {
  26855. m.token = nil
  26856. m.appendtoken = nil
  26857. m.clearedFields[soptask.FieldToken] = struct{}{}
  26858. }
  26859. // TokenCleared returns if the "token" field was cleared in this mutation.
  26860. func (m *SopTaskMutation) TokenCleared() bool {
  26861. _, ok := m.clearedFields[soptask.FieldToken]
  26862. return ok
  26863. }
  26864. // ResetToken resets all changes to the "token" field.
  26865. func (m *SopTaskMutation) ResetToken() {
  26866. m.token = nil
  26867. m.appendtoken = nil
  26868. delete(m.clearedFields, soptask.FieldToken)
  26869. }
  26870. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  26871. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  26872. if m.task_stages == nil {
  26873. m.task_stages = make(map[uint64]struct{})
  26874. }
  26875. for i := range ids {
  26876. m.task_stages[ids[i]] = struct{}{}
  26877. }
  26878. }
  26879. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  26880. func (m *SopTaskMutation) ClearTaskStages() {
  26881. m.clearedtask_stages = true
  26882. }
  26883. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  26884. func (m *SopTaskMutation) TaskStagesCleared() bool {
  26885. return m.clearedtask_stages
  26886. }
  26887. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  26888. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  26889. if m.removedtask_stages == nil {
  26890. m.removedtask_stages = make(map[uint64]struct{})
  26891. }
  26892. for i := range ids {
  26893. delete(m.task_stages, ids[i])
  26894. m.removedtask_stages[ids[i]] = struct{}{}
  26895. }
  26896. }
  26897. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  26898. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  26899. for id := range m.removedtask_stages {
  26900. ids = append(ids, id)
  26901. }
  26902. return
  26903. }
  26904. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  26905. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  26906. for id := range m.task_stages {
  26907. ids = append(ids, id)
  26908. }
  26909. return
  26910. }
  26911. // ResetTaskStages resets all changes to the "task_stages" edge.
  26912. func (m *SopTaskMutation) ResetTaskStages() {
  26913. m.task_stages = nil
  26914. m.clearedtask_stages = false
  26915. m.removedtask_stages = nil
  26916. }
  26917. // Where appends a list predicates to the SopTaskMutation builder.
  26918. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  26919. m.predicates = append(m.predicates, ps...)
  26920. }
  26921. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  26922. // users can use type-assertion to append predicates that do not depend on any generated package.
  26923. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  26924. p := make([]predicate.SopTask, len(ps))
  26925. for i := range ps {
  26926. p[i] = ps[i]
  26927. }
  26928. m.Where(p...)
  26929. }
  26930. // Op returns the operation name.
  26931. func (m *SopTaskMutation) Op() Op {
  26932. return m.op
  26933. }
  26934. // SetOp allows setting the mutation operation.
  26935. func (m *SopTaskMutation) SetOp(op Op) {
  26936. m.op = op
  26937. }
  26938. // Type returns the node type of this mutation (SopTask).
  26939. func (m *SopTaskMutation) Type() string {
  26940. return m.typ
  26941. }
  26942. // Fields returns all fields that were changed during this mutation. Note that in
  26943. // order to get all numeric fields that were incremented/decremented, call
  26944. // AddedFields().
  26945. func (m *SopTaskMutation) Fields() []string {
  26946. fields := make([]string, 0, 12)
  26947. if m.created_at != nil {
  26948. fields = append(fields, soptask.FieldCreatedAt)
  26949. }
  26950. if m.updated_at != nil {
  26951. fields = append(fields, soptask.FieldUpdatedAt)
  26952. }
  26953. if m.status != nil {
  26954. fields = append(fields, soptask.FieldStatus)
  26955. }
  26956. if m.deleted_at != nil {
  26957. fields = append(fields, soptask.FieldDeletedAt)
  26958. }
  26959. if m.name != nil {
  26960. fields = append(fields, soptask.FieldName)
  26961. }
  26962. if m.bot_wxid_list != nil {
  26963. fields = append(fields, soptask.FieldBotWxidList)
  26964. }
  26965. if m._type != nil {
  26966. fields = append(fields, soptask.FieldType)
  26967. }
  26968. if m.plan_start_time != nil {
  26969. fields = append(fields, soptask.FieldPlanStartTime)
  26970. }
  26971. if m.plan_end_time != nil {
  26972. fields = append(fields, soptask.FieldPlanEndTime)
  26973. }
  26974. if m.creator_id != nil {
  26975. fields = append(fields, soptask.FieldCreatorID)
  26976. }
  26977. if m.organization_id != nil {
  26978. fields = append(fields, soptask.FieldOrganizationID)
  26979. }
  26980. if m.token != nil {
  26981. fields = append(fields, soptask.FieldToken)
  26982. }
  26983. return fields
  26984. }
  26985. // Field returns the value of a field with the given name. The second boolean
  26986. // return value indicates that this field was not set, or was not defined in the
  26987. // schema.
  26988. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  26989. switch name {
  26990. case soptask.FieldCreatedAt:
  26991. return m.CreatedAt()
  26992. case soptask.FieldUpdatedAt:
  26993. return m.UpdatedAt()
  26994. case soptask.FieldStatus:
  26995. return m.Status()
  26996. case soptask.FieldDeletedAt:
  26997. return m.DeletedAt()
  26998. case soptask.FieldName:
  26999. return m.Name()
  27000. case soptask.FieldBotWxidList:
  27001. return m.BotWxidList()
  27002. case soptask.FieldType:
  27003. return m.GetType()
  27004. case soptask.FieldPlanStartTime:
  27005. return m.PlanStartTime()
  27006. case soptask.FieldPlanEndTime:
  27007. return m.PlanEndTime()
  27008. case soptask.FieldCreatorID:
  27009. return m.CreatorID()
  27010. case soptask.FieldOrganizationID:
  27011. return m.OrganizationID()
  27012. case soptask.FieldToken:
  27013. return m.Token()
  27014. }
  27015. return nil, false
  27016. }
  27017. // OldField returns the old value of the field from the database. An error is
  27018. // returned if the mutation operation is not UpdateOne, or the query to the
  27019. // database failed.
  27020. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27021. switch name {
  27022. case soptask.FieldCreatedAt:
  27023. return m.OldCreatedAt(ctx)
  27024. case soptask.FieldUpdatedAt:
  27025. return m.OldUpdatedAt(ctx)
  27026. case soptask.FieldStatus:
  27027. return m.OldStatus(ctx)
  27028. case soptask.FieldDeletedAt:
  27029. return m.OldDeletedAt(ctx)
  27030. case soptask.FieldName:
  27031. return m.OldName(ctx)
  27032. case soptask.FieldBotWxidList:
  27033. return m.OldBotWxidList(ctx)
  27034. case soptask.FieldType:
  27035. return m.OldType(ctx)
  27036. case soptask.FieldPlanStartTime:
  27037. return m.OldPlanStartTime(ctx)
  27038. case soptask.FieldPlanEndTime:
  27039. return m.OldPlanEndTime(ctx)
  27040. case soptask.FieldCreatorID:
  27041. return m.OldCreatorID(ctx)
  27042. case soptask.FieldOrganizationID:
  27043. return m.OldOrganizationID(ctx)
  27044. case soptask.FieldToken:
  27045. return m.OldToken(ctx)
  27046. }
  27047. return nil, fmt.Errorf("unknown SopTask field %s", name)
  27048. }
  27049. // SetField sets the value of a field with the given name. It returns an error if
  27050. // the field is not defined in the schema, or if the type mismatched the field
  27051. // type.
  27052. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  27053. switch name {
  27054. case soptask.FieldCreatedAt:
  27055. v, ok := value.(time.Time)
  27056. if !ok {
  27057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27058. }
  27059. m.SetCreatedAt(v)
  27060. return nil
  27061. case soptask.FieldUpdatedAt:
  27062. v, ok := value.(time.Time)
  27063. if !ok {
  27064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27065. }
  27066. m.SetUpdatedAt(v)
  27067. return nil
  27068. case soptask.FieldStatus:
  27069. v, ok := value.(uint8)
  27070. if !ok {
  27071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27072. }
  27073. m.SetStatus(v)
  27074. return nil
  27075. case soptask.FieldDeletedAt:
  27076. v, ok := value.(time.Time)
  27077. if !ok {
  27078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27079. }
  27080. m.SetDeletedAt(v)
  27081. return nil
  27082. case soptask.FieldName:
  27083. v, ok := value.(string)
  27084. if !ok {
  27085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27086. }
  27087. m.SetName(v)
  27088. return nil
  27089. case soptask.FieldBotWxidList:
  27090. v, ok := value.([]string)
  27091. if !ok {
  27092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27093. }
  27094. m.SetBotWxidList(v)
  27095. return nil
  27096. case soptask.FieldType:
  27097. v, ok := value.(int)
  27098. if !ok {
  27099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27100. }
  27101. m.SetType(v)
  27102. return nil
  27103. case soptask.FieldPlanStartTime:
  27104. v, ok := value.(time.Time)
  27105. if !ok {
  27106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27107. }
  27108. m.SetPlanStartTime(v)
  27109. return nil
  27110. case soptask.FieldPlanEndTime:
  27111. v, ok := value.(time.Time)
  27112. if !ok {
  27113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27114. }
  27115. m.SetPlanEndTime(v)
  27116. return nil
  27117. case soptask.FieldCreatorID:
  27118. v, ok := value.(string)
  27119. if !ok {
  27120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27121. }
  27122. m.SetCreatorID(v)
  27123. return nil
  27124. case soptask.FieldOrganizationID:
  27125. v, ok := value.(uint64)
  27126. if !ok {
  27127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27128. }
  27129. m.SetOrganizationID(v)
  27130. return nil
  27131. case soptask.FieldToken:
  27132. v, ok := value.([]string)
  27133. if !ok {
  27134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27135. }
  27136. m.SetToken(v)
  27137. return nil
  27138. }
  27139. return fmt.Errorf("unknown SopTask field %s", name)
  27140. }
  27141. // AddedFields returns all numeric fields that were incremented/decremented during
  27142. // this mutation.
  27143. func (m *SopTaskMutation) AddedFields() []string {
  27144. var fields []string
  27145. if m.addstatus != nil {
  27146. fields = append(fields, soptask.FieldStatus)
  27147. }
  27148. if m.add_type != nil {
  27149. fields = append(fields, soptask.FieldType)
  27150. }
  27151. if m.addorganization_id != nil {
  27152. fields = append(fields, soptask.FieldOrganizationID)
  27153. }
  27154. return fields
  27155. }
  27156. // AddedField returns the numeric value that was incremented/decremented on a field
  27157. // with the given name. The second boolean return value indicates that this field
  27158. // was not set, or was not defined in the schema.
  27159. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  27160. switch name {
  27161. case soptask.FieldStatus:
  27162. return m.AddedStatus()
  27163. case soptask.FieldType:
  27164. return m.AddedType()
  27165. case soptask.FieldOrganizationID:
  27166. return m.AddedOrganizationID()
  27167. }
  27168. return nil, false
  27169. }
  27170. // AddField adds the value to the field with the given name. It returns an error if
  27171. // the field is not defined in the schema, or if the type mismatched the field
  27172. // type.
  27173. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  27174. switch name {
  27175. case soptask.FieldStatus:
  27176. v, ok := value.(int8)
  27177. if !ok {
  27178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27179. }
  27180. m.AddStatus(v)
  27181. return nil
  27182. case soptask.FieldType:
  27183. v, ok := value.(int)
  27184. if !ok {
  27185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27186. }
  27187. m.AddType(v)
  27188. return nil
  27189. case soptask.FieldOrganizationID:
  27190. v, ok := value.(int64)
  27191. if !ok {
  27192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27193. }
  27194. m.AddOrganizationID(v)
  27195. return nil
  27196. }
  27197. return fmt.Errorf("unknown SopTask numeric field %s", name)
  27198. }
  27199. // ClearedFields returns all nullable fields that were cleared during this
  27200. // mutation.
  27201. func (m *SopTaskMutation) ClearedFields() []string {
  27202. var fields []string
  27203. if m.FieldCleared(soptask.FieldStatus) {
  27204. fields = append(fields, soptask.FieldStatus)
  27205. }
  27206. if m.FieldCleared(soptask.FieldDeletedAt) {
  27207. fields = append(fields, soptask.FieldDeletedAt)
  27208. }
  27209. if m.FieldCleared(soptask.FieldBotWxidList) {
  27210. fields = append(fields, soptask.FieldBotWxidList)
  27211. }
  27212. if m.FieldCleared(soptask.FieldPlanStartTime) {
  27213. fields = append(fields, soptask.FieldPlanStartTime)
  27214. }
  27215. if m.FieldCleared(soptask.FieldPlanEndTime) {
  27216. fields = append(fields, soptask.FieldPlanEndTime)
  27217. }
  27218. if m.FieldCleared(soptask.FieldCreatorID) {
  27219. fields = append(fields, soptask.FieldCreatorID)
  27220. }
  27221. if m.FieldCleared(soptask.FieldOrganizationID) {
  27222. fields = append(fields, soptask.FieldOrganizationID)
  27223. }
  27224. if m.FieldCleared(soptask.FieldToken) {
  27225. fields = append(fields, soptask.FieldToken)
  27226. }
  27227. return fields
  27228. }
  27229. // FieldCleared returns a boolean indicating if a field with the given name was
  27230. // cleared in this mutation.
  27231. func (m *SopTaskMutation) FieldCleared(name string) bool {
  27232. _, ok := m.clearedFields[name]
  27233. return ok
  27234. }
  27235. // ClearField clears the value of the field with the given name. It returns an
  27236. // error if the field is not defined in the schema.
  27237. func (m *SopTaskMutation) ClearField(name string) error {
  27238. switch name {
  27239. case soptask.FieldStatus:
  27240. m.ClearStatus()
  27241. return nil
  27242. case soptask.FieldDeletedAt:
  27243. m.ClearDeletedAt()
  27244. return nil
  27245. case soptask.FieldBotWxidList:
  27246. m.ClearBotWxidList()
  27247. return nil
  27248. case soptask.FieldPlanStartTime:
  27249. m.ClearPlanStartTime()
  27250. return nil
  27251. case soptask.FieldPlanEndTime:
  27252. m.ClearPlanEndTime()
  27253. return nil
  27254. case soptask.FieldCreatorID:
  27255. m.ClearCreatorID()
  27256. return nil
  27257. case soptask.FieldOrganizationID:
  27258. m.ClearOrganizationID()
  27259. return nil
  27260. case soptask.FieldToken:
  27261. m.ClearToken()
  27262. return nil
  27263. }
  27264. return fmt.Errorf("unknown SopTask nullable field %s", name)
  27265. }
  27266. // ResetField resets all changes in the mutation for the field with the given name.
  27267. // It returns an error if the field is not defined in the schema.
  27268. func (m *SopTaskMutation) ResetField(name string) error {
  27269. switch name {
  27270. case soptask.FieldCreatedAt:
  27271. m.ResetCreatedAt()
  27272. return nil
  27273. case soptask.FieldUpdatedAt:
  27274. m.ResetUpdatedAt()
  27275. return nil
  27276. case soptask.FieldStatus:
  27277. m.ResetStatus()
  27278. return nil
  27279. case soptask.FieldDeletedAt:
  27280. m.ResetDeletedAt()
  27281. return nil
  27282. case soptask.FieldName:
  27283. m.ResetName()
  27284. return nil
  27285. case soptask.FieldBotWxidList:
  27286. m.ResetBotWxidList()
  27287. return nil
  27288. case soptask.FieldType:
  27289. m.ResetType()
  27290. return nil
  27291. case soptask.FieldPlanStartTime:
  27292. m.ResetPlanStartTime()
  27293. return nil
  27294. case soptask.FieldPlanEndTime:
  27295. m.ResetPlanEndTime()
  27296. return nil
  27297. case soptask.FieldCreatorID:
  27298. m.ResetCreatorID()
  27299. return nil
  27300. case soptask.FieldOrganizationID:
  27301. m.ResetOrganizationID()
  27302. return nil
  27303. case soptask.FieldToken:
  27304. m.ResetToken()
  27305. return nil
  27306. }
  27307. return fmt.Errorf("unknown SopTask field %s", name)
  27308. }
  27309. // AddedEdges returns all edge names that were set/added in this mutation.
  27310. func (m *SopTaskMutation) AddedEdges() []string {
  27311. edges := make([]string, 0, 1)
  27312. if m.task_stages != nil {
  27313. edges = append(edges, soptask.EdgeTaskStages)
  27314. }
  27315. return edges
  27316. }
  27317. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27318. // name in this mutation.
  27319. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  27320. switch name {
  27321. case soptask.EdgeTaskStages:
  27322. ids := make([]ent.Value, 0, len(m.task_stages))
  27323. for id := range m.task_stages {
  27324. ids = append(ids, id)
  27325. }
  27326. return ids
  27327. }
  27328. return nil
  27329. }
  27330. // RemovedEdges returns all edge names that were removed in this mutation.
  27331. func (m *SopTaskMutation) RemovedEdges() []string {
  27332. edges := make([]string, 0, 1)
  27333. if m.removedtask_stages != nil {
  27334. edges = append(edges, soptask.EdgeTaskStages)
  27335. }
  27336. return edges
  27337. }
  27338. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27339. // the given name in this mutation.
  27340. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  27341. switch name {
  27342. case soptask.EdgeTaskStages:
  27343. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  27344. for id := range m.removedtask_stages {
  27345. ids = append(ids, id)
  27346. }
  27347. return ids
  27348. }
  27349. return nil
  27350. }
  27351. // ClearedEdges returns all edge names that were cleared in this mutation.
  27352. func (m *SopTaskMutation) ClearedEdges() []string {
  27353. edges := make([]string, 0, 1)
  27354. if m.clearedtask_stages {
  27355. edges = append(edges, soptask.EdgeTaskStages)
  27356. }
  27357. return edges
  27358. }
  27359. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27360. // was cleared in this mutation.
  27361. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  27362. switch name {
  27363. case soptask.EdgeTaskStages:
  27364. return m.clearedtask_stages
  27365. }
  27366. return false
  27367. }
  27368. // ClearEdge clears the value of the edge with the given name. It returns an error
  27369. // if that edge is not defined in the schema.
  27370. func (m *SopTaskMutation) ClearEdge(name string) error {
  27371. switch name {
  27372. }
  27373. return fmt.Errorf("unknown SopTask unique edge %s", name)
  27374. }
  27375. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27376. // It returns an error if the edge is not defined in the schema.
  27377. func (m *SopTaskMutation) ResetEdge(name string) error {
  27378. switch name {
  27379. case soptask.EdgeTaskStages:
  27380. m.ResetTaskStages()
  27381. return nil
  27382. }
  27383. return fmt.Errorf("unknown SopTask edge %s", name)
  27384. }
  27385. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  27386. type TokenMutation struct {
  27387. config
  27388. op Op
  27389. typ string
  27390. id *uint64
  27391. created_at *time.Time
  27392. updated_at *time.Time
  27393. deleted_at *time.Time
  27394. expire_at *time.Time
  27395. token *string
  27396. mac *string
  27397. organization_id *uint64
  27398. addorganization_id *int64
  27399. custom_agent_base *string
  27400. custom_agent_key *string
  27401. openai_base *string
  27402. openai_key *string
  27403. clearedFields map[string]struct{}
  27404. agent *uint64
  27405. clearedagent bool
  27406. done bool
  27407. oldValue func(context.Context) (*Token, error)
  27408. predicates []predicate.Token
  27409. }
  27410. var _ ent.Mutation = (*TokenMutation)(nil)
  27411. // tokenOption allows management of the mutation configuration using functional options.
  27412. type tokenOption func(*TokenMutation)
  27413. // newTokenMutation creates new mutation for the Token entity.
  27414. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  27415. m := &TokenMutation{
  27416. config: c,
  27417. op: op,
  27418. typ: TypeToken,
  27419. clearedFields: make(map[string]struct{}),
  27420. }
  27421. for _, opt := range opts {
  27422. opt(m)
  27423. }
  27424. return m
  27425. }
  27426. // withTokenID sets the ID field of the mutation.
  27427. func withTokenID(id uint64) tokenOption {
  27428. return func(m *TokenMutation) {
  27429. var (
  27430. err error
  27431. once sync.Once
  27432. value *Token
  27433. )
  27434. m.oldValue = func(ctx context.Context) (*Token, error) {
  27435. once.Do(func() {
  27436. if m.done {
  27437. err = errors.New("querying old values post mutation is not allowed")
  27438. } else {
  27439. value, err = m.Client().Token.Get(ctx, id)
  27440. }
  27441. })
  27442. return value, err
  27443. }
  27444. m.id = &id
  27445. }
  27446. }
  27447. // withToken sets the old Token of the mutation.
  27448. func withToken(node *Token) tokenOption {
  27449. return func(m *TokenMutation) {
  27450. m.oldValue = func(context.Context) (*Token, error) {
  27451. return node, nil
  27452. }
  27453. m.id = &node.ID
  27454. }
  27455. }
  27456. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27457. // executed in a transaction (ent.Tx), a transactional client is returned.
  27458. func (m TokenMutation) Client() *Client {
  27459. client := &Client{config: m.config}
  27460. client.init()
  27461. return client
  27462. }
  27463. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27464. // it returns an error otherwise.
  27465. func (m TokenMutation) Tx() (*Tx, error) {
  27466. if _, ok := m.driver.(*txDriver); !ok {
  27467. return nil, errors.New("ent: mutation is not running in a transaction")
  27468. }
  27469. tx := &Tx{config: m.config}
  27470. tx.init()
  27471. return tx, nil
  27472. }
  27473. // SetID sets the value of the id field. Note that this
  27474. // operation is only accepted on creation of Token entities.
  27475. func (m *TokenMutation) SetID(id uint64) {
  27476. m.id = &id
  27477. }
  27478. // ID returns the ID value in the mutation. Note that the ID is only available
  27479. // if it was provided to the builder or after it was returned from the database.
  27480. func (m *TokenMutation) ID() (id uint64, exists bool) {
  27481. if m.id == nil {
  27482. return
  27483. }
  27484. return *m.id, true
  27485. }
  27486. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27487. // That means, if the mutation is applied within a transaction with an isolation level such
  27488. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27489. // or updated by the mutation.
  27490. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  27491. switch {
  27492. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27493. id, exists := m.ID()
  27494. if exists {
  27495. return []uint64{id}, nil
  27496. }
  27497. fallthrough
  27498. case m.op.Is(OpUpdate | OpDelete):
  27499. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  27500. default:
  27501. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27502. }
  27503. }
  27504. // SetCreatedAt sets the "created_at" field.
  27505. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  27506. m.created_at = &t
  27507. }
  27508. // CreatedAt returns the value of the "created_at" field in the mutation.
  27509. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  27510. v := m.created_at
  27511. if v == nil {
  27512. return
  27513. }
  27514. return *v, true
  27515. }
  27516. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  27517. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27519. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27520. if !m.op.Is(OpUpdateOne) {
  27521. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27522. }
  27523. if m.id == nil || m.oldValue == nil {
  27524. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27525. }
  27526. oldValue, err := m.oldValue(ctx)
  27527. if err != nil {
  27528. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27529. }
  27530. return oldValue.CreatedAt, nil
  27531. }
  27532. // ResetCreatedAt resets all changes to the "created_at" field.
  27533. func (m *TokenMutation) ResetCreatedAt() {
  27534. m.created_at = nil
  27535. }
  27536. // SetUpdatedAt sets the "updated_at" field.
  27537. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  27538. m.updated_at = &t
  27539. }
  27540. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27541. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  27542. v := m.updated_at
  27543. if v == nil {
  27544. return
  27545. }
  27546. return *v, true
  27547. }
  27548. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  27549. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27551. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27552. if !m.op.Is(OpUpdateOne) {
  27553. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27554. }
  27555. if m.id == nil || m.oldValue == nil {
  27556. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27557. }
  27558. oldValue, err := m.oldValue(ctx)
  27559. if err != nil {
  27560. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27561. }
  27562. return oldValue.UpdatedAt, nil
  27563. }
  27564. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27565. func (m *TokenMutation) ResetUpdatedAt() {
  27566. m.updated_at = nil
  27567. }
  27568. // SetDeletedAt sets the "deleted_at" field.
  27569. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  27570. m.deleted_at = &t
  27571. }
  27572. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27573. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  27574. v := m.deleted_at
  27575. if v == nil {
  27576. return
  27577. }
  27578. return *v, true
  27579. }
  27580. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  27581. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27583. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27584. if !m.op.Is(OpUpdateOne) {
  27585. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27586. }
  27587. if m.id == nil || m.oldValue == nil {
  27588. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27589. }
  27590. oldValue, err := m.oldValue(ctx)
  27591. if err != nil {
  27592. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27593. }
  27594. return oldValue.DeletedAt, nil
  27595. }
  27596. // ClearDeletedAt clears the value of the "deleted_at" field.
  27597. func (m *TokenMutation) ClearDeletedAt() {
  27598. m.deleted_at = nil
  27599. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  27600. }
  27601. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27602. func (m *TokenMutation) DeletedAtCleared() bool {
  27603. _, ok := m.clearedFields[token.FieldDeletedAt]
  27604. return ok
  27605. }
  27606. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27607. func (m *TokenMutation) ResetDeletedAt() {
  27608. m.deleted_at = nil
  27609. delete(m.clearedFields, token.FieldDeletedAt)
  27610. }
  27611. // SetExpireAt sets the "expire_at" field.
  27612. func (m *TokenMutation) SetExpireAt(t time.Time) {
  27613. m.expire_at = &t
  27614. }
  27615. // ExpireAt returns the value of the "expire_at" field in the mutation.
  27616. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  27617. v := m.expire_at
  27618. if v == nil {
  27619. return
  27620. }
  27621. return *v, true
  27622. }
  27623. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  27624. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27626. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  27627. if !m.op.Is(OpUpdateOne) {
  27628. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  27629. }
  27630. if m.id == nil || m.oldValue == nil {
  27631. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  27632. }
  27633. oldValue, err := m.oldValue(ctx)
  27634. if err != nil {
  27635. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  27636. }
  27637. return oldValue.ExpireAt, nil
  27638. }
  27639. // ClearExpireAt clears the value of the "expire_at" field.
  27640. func (m *TokenMutation) ClearExpireAt() {
  27641. m.expire_at = nil
  27642. m.clearedFields[token.FieldExpireAt] = struct{}{}
  27643. }
  27644. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  27645. func (m *TokenMutation) ExpireAtCleared() bool {
  27646. _, ok := m.clearedFields[token.FieldExpireAt]
  27647. return ok
  27648. }
  27649. // ResetExpireAt resets all changes to the "expire_at" field.
  27650. func (m *TokenMutation) ResetExpireAt() {
  27651. m.expire_at = nil
  27652. delete(m.clearedFields, token.FieldExpireAt)
  27653. }
  27654. // SetToken sets the "token" field.
  27655. func (m *TokenMutation) SetToken(s string) {
  27656. m.token = &s
  27657. }
  27658. // Token returns the value of the "token" field in the mutation.
  27659. func (m *TokenMutation) Token() (r string, exists bool) {
  27660. v := m.token
  27661. if v == nil {
  27662. return
  27663. }
  27664. return *v, true
  27665. }
  27666. // OldToken returns the old "token" field's value of the Token entity.
  27667. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27669. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  27670. if !m.op.Is(OpUpdateOne) {
  27671. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  27672. }
  27673. if m.id == nil || m.oldValue == nil {
  27674. return v, errors.New("OldToken requires an ID field in the mutation")
  27675. }
  27676. oldValue, err := m.oldValue(ctx)
  27677. if err != nil {
  27678. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  27679. }
  27680. return oldValue.Token, nil
  27681. }
  27682. // ClearToken clears the value of the "token" field.
  27683. func (m *TokenMutation) ClearToken() {
  27684. m.token = nil
  27685. m.clearedFields[token.FieldToken] = struct{}{}
  27686. }
  27687. // TokenCleared returns if the "token" field was cleared in this mutation.
  27688. func (m *TokenMutation) TokenCleared() bool {
  27689. _, ok := m.clearedFields[token.FieldToken]
  27690. return ok
  27691. }
  27692. // ResetToken resets all changes to the "token" field.
  27693. func (m *TokenMutation) ResetToken() {
  27694. m.token = nil
  27695. delete(m.clearedFields, token.FieldToken)
  27696. }
  27697. // SetMAC sets the "mac" field.
  27698. func (m *TokenMutation) SetMAC(s string) {
  27699. m.mac = &s
  27700. }
  27701. // MAC returns the value of the "mac" field in the mutation.
  27702. func (m *TokenMutation) MAC() (r string, exists bool) {
  27703. v := m.mac
  27704. if v == nil {
  27705. return
  27706. }
  27707. return *v, true
  27708. }
  27709. // OldMAC returns the old "mac" field's value of the Token entity.
  27710. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27712. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  27713. if !m.op.Is(OpUpdateOne) {
  27714. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  27715. }
  27716. if m.id == nil || m.oldValue == nil {
  27717. return v, errors.New("OldMAC requires an ID field in the mutation")
  27718. }
  27719. oldValue, err := m.oldValue(ctx)
  27720. if err != nil {
  27721. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  27722. }
  27723. return oldValue.MAC, nil
  27724. }
  27725. // ClearMAC clears the value of the "mac" field.
  27726. func (m *TokenMutation) ClearMAC() {
  27727. m.mac = nil
  27728. m.clearedFields[token.FieldMAC] = struct{}{}
  27729. }
  27730. // MACCleared returns if the "mac" field was cleared in this mutation.
  27731. func (m *TokenMutation) MACCleared() bool {
  27732. _, ok := m.clearedFields[token.FieldMAC]
  27733. return ok
  27734. }
  27735. // ResetMAC resets all changes to the "mac" field.
  27736. func (m *TokenMutation) ResetMAC() {
  27737. m.mac = nil
  27738. delete(m.clearedFields, token.FieldMAC)
  27739. }
  27740. // SetOrganizationID sets the "organization_id" field.
  27741. func (m *TokenMutation) SetOrganizationID(u uint64) {
  27742. m.organization_id = &u
  27743. m.addorganization_id = nil
  27744. }
  27745. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27746. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  27747. v := m.organization_id
  27748. if v == nil {
  27749. return
  27750. }
  27751. return *v, true
  27752. }
  27753. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  27754. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27756. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27757. if !m.op.Is(OpUpdateOne) {
  27758. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27759. }
  27760. if m.id == nil || m.oldValue == nil {
  27761. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27762. }
  27763. oldValue, err := m.oldValue(ctx)
  27764. if err != nil {
  27765. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27766. }
  27767. return oldValue.OrganizationID, nil
  27768. }
  27769. // AddOrganizationID adds u to the "organization_id" field.
  27770. func (m *TokenMutation) AddOrganizationID(u int64) {
  27771. if m.addorganization_id != nil {
  27772. *m.addorganization_id += u
  27773. } else {
  27774. m.addorganization_id = &u
  27775. }
  27776. }
  27777. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27778. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  27779. v := m.addorganization_id
  27780. if v == nil {
  27781. return
  27782. }
  27783. return *v, true
  27784. }
  27785. // ResetOrganizationID resets all changes to the "organization_id" field.
  27786. func (m *TokenMutation) ResetOrganizationID() {
  27787. m.organization_id = nil
  27788. m.addorganization_id = nil
  27789. }
  27790. // SetAgentID sets the "agent_id" field.
  27791. func (m *TokenMutation) SetAgentID(u uint64) {
  27792. m.agent = &u
  27793. }
  27794. // AgentID returns the value of the "agent_id" field in the mutation.
  27795. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  27796. v := m.agent
  27797. if v == nil {
  27798. return
  27799. }
  27800. return *v, true
  27801. }
  27802. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  27803. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27805. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  27806. if !m.op.Is(OpUpdateOne) {
  27807. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  27808. }
  27809. if m.id == nil || m.oldValue == nil {
  27810. return v, errors.New("OldAgentID requires an ID field in the mutation")
  27811. }
  27812. oldValue, err := m.oldValue(ctx)
  27813. if err != nil {
  27814. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  27815. }
  27816. return oldValue.AgentID, nil
  27817. }
  27818. // ResetAgentID resets all changes to the "agent_id" field.
  27819. func (m *TokenMutation) ResetAgentID() {
  27820. m.agent = nil
  27821. }
  27822. // SetCustomAgentBase sets the "custom_agent_base" field.
  27823. func (m *TokenMutation) SetCustomAgentBase(s string) {
  27824. m.custom_agent_base = &s
  27825. }
  27826. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  27827. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  27828. v := m.custom_agent_base
  27829. if v == nil {
  27830. return
  27831. }
  27832. return *v, true
  27833. }
  27834. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  27835. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27837. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  27838. if !m.op.Is(OpUpdateOne) {
  27839. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  27840. }
  27841. if m.id == nil || m.oldValue == nil {
  27842. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  27843. }
  27844. oldValue, err := m.oldValue(ctx)
  27845. if err != nil {
  27846. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  27847. }
  27848. return oldValue.CustomAgentBase, nil
  27849. }
  27850. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  27851. func (m *TokenMutation) ClearCustomAgentBase() {
  27852. m.custom_agent_base = nil
  27853. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  27854. }
  27855. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  27856. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  27857. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  27858. return ok
  27859. }
  27860. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  27861. func (m *TokenMutation) ResetCustomAgentBase() {
  27862. m.custom_agent_base = nil
  27863. delete(m.clearedFields, token.FieldCustomAgentBase)
  27864. }
  27865. // SetCustomAgentKey sets the "custom_agent_key" field.
  27866. func (m *TokenMutation) SetCustomAgentKey(s string) {
  27867. m.custom_agent_key = &s
  27868. }
  27869. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  27870. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  27871. v := m.custom_agent_key
  27872. if v == nil {
  27873. return
  27874. }
  27875. return *v, true
  27876. }
  27877. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  27878. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27880. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  27881. if !m.op.Is(OpUpdateOne) {
  27882. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  27883. }
  27884. if m.id == nil || m.oldValue == nil {
  27885. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  27886. }
  27887. oldValue, err := m.oldValue(ctx)
  27888. if err != nil {
  27889. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  27890. }
  27891. return oldValue.CustomAgentKey, nil
  27892. }
  27893. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  27894. func (m *TokenMutation) ClearCustomAgentKey() {
  27895. m.custom_agent_key = nil
  27896. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  27897. }
  27898. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  27899. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  27900. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  27901. return ok
  27902. }
  27903. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  27904. func (m *TokenMutation) ResetCustomAgentKey() {
  27905. m.custom_agent_key = nil
  27906. delete(m.clearedFields, token.FieldCustomAgentKey)
  27907. }
  27908. // SetOpenaiBase sets the "openai_base" field.
  27909. func (m *TokenMutation) SetOpenaiBase(s string) {
  27910. m.openai_base = &s
  27911. }
  27912. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  27913. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  27914. v := m.openai_base
  27915. if v == nil {
  27916. return
  27917. }
  27918. return *v, true
  27919. }
  27920. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  27921. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27923. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  27924. if !m.op.Is(OpUpdateOne) {
  27925. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  27926. }
  27927. if m.id == nil || m.oldValue == nil {
  27928. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  27929. }
  27930. oldValue, err := m.oldValue(ctx)
  27931. if err != nil {
  27932. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  27933. }
  27934. return oldValue.OpenaiBase, nil
  27935. }
  27936. // ClearOpenaiBase clears the value of the "openai_base" field.
  27937. func (m *TokenMutation) ClearOpenaiBase() {
  27938. m.openai_base = nil
  27939. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  27940. }
  27941. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  27942. func (m *TokenMutation) OpenaiBaseCleared() bool {
  27943. _, ok := m.clearedFields[token.FieldOpenaiBase]
  27944. return ok
  27945. }
  27946. // ResetOpenaiBase resets all changes to the "openai_base" field.
  27947. func (m *TokenMutation) ResetOpenaiBase() {
  27948. m.openai_base = nil
  27949. delete(m.clearedFields, token.FieldOpenaiBase)
  27950. }
  27951. // SetOpenaiKey sets the "openai_key" field.
  27952. func (m *TokenMutation) SetOpenaiKey(s string) {
  27953. m.openai_key = &s
  27954. }
  27955. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  27956. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  27957. v := m.openai_key
  27958. if v == nil {
  27959. return
  27960. }
  27961. return *v, true
  27962. }
  27963. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  27964. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27966. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  27967. if !m.op.Is(OpUpdateOne) {
  27968. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  27969. }
  27970. if m.id == nil || m.oldValue == nil {
  27971. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  27972. }
  27973. oldValue, err := m.oldValue(ctx)
  27974. if err != nil {
  27975. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  27976. }
  27977. return oldValue.OpenaiKey, nil
  27978. }
  27979. // ClearOpenaiKey clears the value of the "openai_key" field.
  27980. func (m *TokenMutation) ClearOpenaiKey() {
  27981. m.openai_key = nil
  27982. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  27983. }
  27984. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  27985. func (m *TokenMutation) OpenaiKeyCleared() bool {
  27986. _, ok := m.clearedFields[token.FieldOpenaiKey]
  27987. return ok
  27988. }
  27989. // ResetOpenaiKey resets all changes to the "openai_key" field.
  27990. func (m *TokenMutation) ResetOpenaiKey() {
  27991. m.openai_key = nil
  27992. delete(m.clearedFields, token.FieldOpenaiKey)
  27993. }
  27994. // ClearAgent clears the "agent" edge to the Agent entity.
  27995. func (m *TokenMutation) ClearAgent() {
  27996. m.clearedagent = true
  27997. m.clearedFields[token.FieldAgentID] = struct{}{}
  27998. }
  27999. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  28000. func (m *TokenMutation) AgentCleared() bool {
  28001. return m.clearedagent
  28002. }
  28003. // AgentIDs returns the "agent" edge IDs in the mutation.
  28004. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28005. // AgentID instead. It exists only for internal usage by the builders.
  28006. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  28007. if id := m.agent; id != nil {
  28008. ids = append(ids, *id)
  28009. }
  28010. return
  28011. }
  28012. // ResetAgent resets all changes to the "agent" edge.
  28013. func (m *TokenMutation) ResetAgent() {
  28014. m.agent = nil
  28015. m.clearedagent = false
  28016. }
  28017. // Where appends a list predicates to the TokenMutation builder.
  28018. func (m *TokenMutation) Where(ps ...predicate.Token) {
  28019. m.predicates = append(m.predicates, ps...)
  28020. }
  28021. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  28022. // users can use type-assertion to append predicates that do not depend on any generated package.
  28023. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  28024. p := make([]predicate.Token, len(ps))
  28025. for i := range ps {
  28026. p[i] = ps[i]
  28027. }
  28028. m.Where(p...)
  28029. }
  28030. // Op returns the operation name.
  28031. func (m *TokenMutation) Op() Op {
  28032. return m.op
  28033. }
  28034. // SetOp allows setting the mutation operation.
  28035. func (m *TokenMutation) SetOp(op Op) {
  28036. m.op = op
  28037. }
  28038. // Type returns the node type of this mutation (Token).
  28039. func (m *TokenMutation) Type() string {
  28040. return m.typ
  28041. }
  28042. // Fields returns all fields that were changed during this mutation. Note that in
  28043. // order to get all numeric fields that were incremented/decremented, call
  28044. // AddedFields().
  28045. func (m *TokenMutation) Fields() []string {
  28046. fields := make([]string, 0, 12)
  28047. if m.created_at != nil {
  28048. fields = append(fields, token.FieldCreatedAt)
  28049. }
  28050. if m.updated_at != nil {
  28051. fields = append(fields, token.FieldUpdatedAt)
  28052. }
  28053. if m.deleted_at != nil {
  28054. fields = append(fields, token.FieldDeletedAt)
  28055. }
  28056. if m.expire_at != nil {
  28057. fields = append(fields, token.FieldExpireAt)
  28058. }
  28059. if m.token != nil {
  28060. fields = append(fields, token.FieldToken)
  28061. }
  28062. if m.mac != nil {
  28063. fields = append(fields, token.FieldMAC)
  28064. }
  28065. if m.organization_id != nil {
  28066. fields = append(fields, token.FieldOrganizationID)
  28067. }
  28068. if m.agent != nil {
  28069. fields = append(fields, token.FieldAgentID)
  28070. }
  28071. if m.custom_agent_base != nil {
  28072. fields = append(fields, token.FieldCustomAgentBase)
  28073. }
  28074. if m.custom_agent_key != nil {
  28075. fields = append(fields, token.FieldCustomAgentKey)
  28076. }
  28077. if m.openai_base != nil {
  28078. fields = append(fields, token.FieldOpenaiBase)
  28079. }
  28080. if m.openai_key != nil {
  28081. fields = append(fields, token.FieldOpenaiKey)
  28082. }
  28083. return fields
  28084. }
  28085. // Field returns the value of a field with the given name. The second boolean
  28086. // return value indicates that this field was not set, or was not defined in the
  28087. // schema.
  28088. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  28089. switch name {
  28090. case token.FieldCreatedAt:
  28091. return m.CreatedAt()
  28092. case token.FieldUpdatedAt:
  28093. return m.UpdatedAt()
  28094. case token.FieldDeletedAt:
  28095. return m.DeletedAt()
  28096. case token.FieldExpireAt:
  28097. return m.ExpireAt()
  28098. case token.FieldToken:
  28099. return m.Token()
  28100. case token.FieldMAC:
  28101. return m.MAC()
  28102. case token.FieldOrganizationID:
  28103. return m.OrganizationID()
  28104. case token.FieldAgentID:
  28105. return m.AgentID()
  28106. case token.FieldCustomAgentBase:
  28107. return m.CustomAgentBase()
  28108. case token.FieldCustomAgentKey:
  28109. return m.CustomAgentKey()
  28110. case token.FieldOpenaiBase:
  28111. return m.OpenaiBase()
  28112. case token.FieldOpenaiKey:
  28113. return m.OpenaiKey()
  28114. }
  28115. return nil, false
  28116. }
  28117. // OldField returns the old value of the field from the database. An error is
  28118. // returned if the mutation operation is not UpdateOne, or the query to the
  28119. // database failed.
  28120. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28121. switch name {
  28122. case token.FieldCreatedAt:
  28123. return m.OldCreatedAt(ctx)
  28124. case token.FieldUpdatedAt:
  28125. return m.OldUpdatedAt(ctx)
  28126. case token.FieldDeletedAt:
  28127. return m.OldDeletedAt(ctx)
  28128. case token.FieldExpireAt:
  28129. return m.OldExpireAt(ctx)
  28130. case token.FieldToken:
  28131. return m.OldToken(ctx)
  28132. case token.FieldMAC:
  28133. return m.OldMAC(ctx)
  28134. case token.FieldOrganizationID:
  28135. return m.OldOrganizationID(ctx)
  28136. case token.FieldAgentID:
  28137. return m.OldAgentID(ctx)
  28138. case token.FieldCustomAgentBase:
  28139. return m.OldCustomAgentBase(ctx)
  28140. case token.FieldCustomAgentKey:
  28141. return m.OldCustomAgentKey(ctx)
  28142. case token.FieldOpenaiBase:
  28143. return m.OldOpenaiBase(ctx)
  28144. case token.FieldOpenaiKey:
  28145. return m.OldOpenaiKey(ctx)
  28146. }
  28147. return nil, fmt.Errorf("unknown Token field %s", name)
  28148. }
  28149. // SetField sets the value of a field with the given name. It returns an error if
  28150. // the field is not defined in the schema, or if the type mismatched the field
  28151. // type.
  28152. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  28153. switch name {
  28154. case token.FieldCreatedAt:
  28155. v, ok := value.(time.Time)
  28156. if !ok {
  28157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28158. }
  28159. m.SetCreatedAt(v)
  28160. return nil
  28161. case token.FieldUpdatedAt:
  28162. v, ok := value.(time.Time)
  28163. if !ok {
  28164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28165. }
  28166. m.SetUpdatedAt(v)
  28167. return nil
  28168. case token.FieldDeletedAt:
  28169. v, ok := value.(time.Time)
  28170. if !ok {
  28171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28172. }
  28173. m.SetDeletedAt(v)
  28174. return nil
  28175. case token.FieldExpireAt:
  28176. v, ok := value.(time.Time)
  28177. if !ok {
  28178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28179. }
  28180. m.SetExpireAt(v)
  28181. return nil
  28182. case token.FieldToken:
  28183. v, ok := value.(string)
  28184. if !ok {
  28185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28186. }
  28187. m.SetToken(v)
  28188. return nil
  28189. case token.FieldMAC:
  28190. v, ok := value.(string)
  28191. if !ok {
  28192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28193. }
  28194. m.SetMAC(v)
  28195. return nil
  28196. case token.FieldOrganizationID:
  28197. v, ok := value.(uint64)
  28198. if !ok {
  28199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28200. }
  28201. m.SetOrganizationID(v)
  28202. return nil
  28203. case token.FieldAgentID:
  28204. v, ok := value.(uint64)
  28205. if !ok {
  28206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28207. }
  28208. m.SetAgentID(v)
  28209. return nil
  28210. case token.FieldCustomAgentBase:
  28211. v, ok := value.(string)
  28212. if !ok {
  28213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28214. }
  28215. m.SetCustomAgentBase(v)
  28216. return nil
  28217. case token.FieldCustomAgentKey:
  28218. v, ok := value.(string)
  28219. if !ok {
  28220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28221. }
  28222. m.SetCustomAgentKey(v)
  28223. return nil
  28224. case token.FieldOpenaiBase:
  28225. v, ok := value.(string)
  28226. if !ok {
  28227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28228. }
  28229. m.SetOpenaiBase(v)
  28230. return nil
  28231. case token.FieldOpenaiKey:
  28232. v, ok := value.(string)
  28233. if !ok {
  28234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28235. }
  28236. m.SetOpenaiKey(v)
  28237. return nil
  28238. }
  28239. return fmt.Errorf("unknown Token field %s", name)
  28240. }
  28241. // AddedFields returns all numeric fields that were incremented/decremented during
  28242. // this mutation.
  28243. func (m *TokenMutation) AddedFields() []string {
  28244. var fields []string
  28245. if m.addorganization_id != nil {
  28246. fields = append(fields, token.FieldOrganizationID)
  28247. }
  28248. return fields
  28249. }
  28250. // AddedField returns the numeric value that was incremented/decremented on a field
  28251. // with the given name. The second boolean return value indicates that this field
  28252. // was not set, or was not defined in the schema.
  28253. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  28254. switch name {
  28255. case token.FieldOrganizationID:
  28256. return m.AddedOrganizationID()
  28257. }
  28258. return nil, false
  28259. }
  28260. // AddField adds the value to the field with the given name. It returns an error if
  28261. // the field is not defined in the schema, or if the type mismatched the field
  28262. // type.
  28263. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  28264. switch name {
  28265. case token.FieldOrganizationID:
  28266. v, ok := value.(int64)
  28267. if !ok {
  28268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28269. }
  28270. m.AddOrganizationID(v)
  28271. return nil
  28272. }
  28273. return fmt.Errorf("unknown Token numeric field %s", name)
  28274. }
  28275. // ClearedFields returns all nullable fields that were cleared during this
  28276. // mutation.
  28277. func (m *TokenMutation) ClearedFields() []string {
  28278. var fields []string
  28279. if m.FieldCleared(token.FieldDeletedAt) {
  28280. fields = append(fields, token.FieldDeletedAt)
  28281. }
  28282. if m.FieldCleared(token.FieldExpireAt) {
  28283. fields = append(fields, token.FieldExpireAt)
  28284. }
  28285. if m.FieldCleared(token.FieldToken) {
  28286. fields = append(fields, token.FieldToken)
  28287. }
  28288. if m.FieldCleared(token.FieldMAC) {
  28289. fields = append(fields, token.FieldMAC)
  28290. }
  28291. if m.FieldCleared(token.FieldCustomAgentBase) {
  28292. fields = append(fields, token.FieldCustomAgentBase)
  28293. }
  28294. if m.FieldCleared(token.FieldCustomAgentKey) {
  28295. fields = append(fields, token.FieldCustomAgentKey)
  28296. }
  28297. if m.FieldCleared(token.FieldOpenaiBase) {
  28298. fields = append(fields, token.FieldOpenaiBase)
  28299. }
  28300. if m.FieldCleared(token.FieldOpenaiKey) {
  28301. fields = append(fields, token.FieldOpenaiKey)
  28302. }
  28303. return fields
  28304. }
  28305. // FieldCleared returns a boolean indicating if a field with the given name was
  28306. // cleared in this mutation.
  28307. func (m *TokenMutation) FieldCleared(name string) bool {
  28308. _, ok := m.clearedFields[name]
  28309. return ok
  28310. }
  28311. // ClearField clears the value of the field with the given name. It returns an
  28312. // error if the field is not defined in the schema.
  28313. func (m *TokenMutation) ClearField(name string) error {
  28314. switch name {
  28315. case token.FieldDeletedAt:
  28316. m.ClearDeletedAt()
  28317. return nil
  28318. case token.FieldExpireAt:
  28319. m.ClearExpireAt()
  28320. return nil
  28321. case token.FieldToken:
  28322. m.ClearToken()
  28323. return nil
  28324. case token.FieldMAC:
  28325. m.ClearMAC()
  28326. return nil
  28327. case token.FieldCustomAgentBase:
  28328. m.ClearCustomAgentBase()
  28329. return nil
  28330. case token.FieldCustomAgentKey:
  28331. m.ClearCustomAgentKey()
  28332. return nil
  28333. case token.FieldOpenaiBase:
  28334. m.ClearOpenaiBase()
  28335. return nil
  28336. case token.FieldOpenaiKey:
  28337. m.ClearOpenaiKey()
  28338. return nil
  28339. }
  28340. return fmt.Errorf("unknown Token nullable field %s", name)
  28341. }
  28342. // ResetField resets all changes in the mutation for the field with the given name.
  28343. // It returns an error if the field is not defined in the schema.
  28344. func (m *TokenMutation) ResetField(name string) error {
  28345. switch name {
  28346. case token.FieldCreatedAt:
  28347. m.ResetCreatedAt()
  28348. return nil
  28349. case token.FieldUpdatedAt:
  28350. m.ResetUpdatedAt()
  28351. return nil
  28352. case token.FieldDeletedAt:
  28353. m.ResetDeletedAt()
  28354. return nil
  28355. case token.FieldExpireAt:
  28356. m.ResetExpireAt()
  28357. return nil
  28358. case token.FieldToken:
  28359. m.ResetToken()
  28360. return nil
  28361. case token.FieldMAC:
  28362. m.ResetMAC()
  28363. return nil
  28364. case token.FieldOrganizationID:
  28365. m.ResetOrganizationID()
  28366. return nil
  28367. case token.FieldAgentID:
  28368. m.ResetAgentID()
  28369. return nil
  28370. case token.FieldCustomAgentBase:
  28371. m.ResetCustomAgentBase()
  28372. return nil
  28373. case token.FieldCustomAgentKey:
  28374. m.ResetCustomAgentKey()
  28375. return nil
  28376. case token.FieldOpenaiBase:
  28377. m.ResetOpenaiBase()
  28378. return nil
  28379. case token.FieldOpenaiKey:
  28380. m.ResetOpenaiKey()
  28381. return nil
  28382. }
  28383. return fmt.Errorf("unknown Token field %s", name)
  28384. }
  28385. // AddedEdges returns all edge names that were set/added in this mutation.
  28386. func (m *TokenMutation) AddedEdges() []string {
  28387. edges := make([]string, 0, 1)
  28388. if m.agent != nil {
  28389. edges = append(edges, token.EdgeAgent)
  28390. }
  28391. return edges
  28392. }
  28393. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28394. // name in this mutation.
  28395. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  28396. switch name {
  28397. case token.EdgeAgent:
  28398. if id := m.agent; id != nil {
  28399. return []ent.Value{*id}
  28400. }
  28401. }
  28402. return nil
  28403. }
  28404. // RemovedEdges returns all edge names that were removed in this mutation.
  28405. func (m *TokenMutation) RemovedEdges() []string {
  28406. edges := make([]string, 0, 1)
  28407. return edges
  28408. }
  28409. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28410. // the given name in this mutation.
  28411. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  28412. return nil
  28413. }
  28414. // ClearedEdges returns all edge names that were cleared in this mutation.
  28415. func (m *TokenMutation) ClearedEdges() []string {
  28416. edges := make([]string, 0, 1)
  28417. if m.clearedagent {
  28418. edges = append(edges, token.EdgeAgent)
  28419. }
  28420. return edges
  28421. }
  28422. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28423. // was cleared in this mutation.
  28424. func (m *TokenMutation) EdgeCleared(name string) bool {
  28425. switch name {
  28426. case token.EdgeAgent:
  28427. return m.clearedagent
  28428. }
  28429. return false
  28430. }
  28431. // ClearEdge clears the value of the edge with the given name. It returns an error
  28432. // if that edge is not defined in the schema.
  28433. func (m *TokenMutation) ClearEdge(name string) error {
  28434. switch name {
  28435. case token.EdgeAgent:
  28436. m.ClearAgent()
  28437. return nil
  28438. }
  28439. return fmt.Errorf("unknown Token unique edge %s", name)
  28440. }
  28441. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28442. // It returns an error if the edge is not defined in the schema.
  28443. func (m *TokenMutation) ResetEdge(name string) error {
  28444. switch name {
  28445. case token.EdgeAgent:
  28446. m.ResetAgent()
  28447. return nil
  28448. }
  28449. return fmt.Errorf("unknown Token edge %s", name)
  28450. }
  28451. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  28452. type TutorialMutation struct {
  28453. config
  28454. op Op
  28455. typ string
  28456. id *uint64
  28457. created_at *time.Time
  28458. updated_at *time.Time
  28459. deleted_at *time.Time
  28460. index *int
  28461. addindex *int
  28462. title *string
  28463. content *string
  28464. organization_id *uint64
  28465. addorganization_id *int64
  28466. clearedFields map[string]struct{}
  28467. employee *uint64
  28468. clearedemployee bool
  28469. done bool
  28470. oldValue func(context.Context) (*Tutorial, error)
  28471. predicates []predicate.Tutorial
  28472. }
  28473. var _ ent.Mutation = (*TutorialMutation)(nil)
  28474. // tutorialOption allows management of the mutation configuration using functional options.
  28475. type tutorialOption func(*TutorialMutation)
  28476. // newTutorialMutation creates new mutation for the Tutorial entity.
  28477. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  28478. m := &TutorialMutation{
  28479. config: c,
  28480. op: op,
  28481. typ: TypeTutorial,
  28482. clearedFields: make(map[string]struct{}),
  28483. }
  28484. for _, opt := range opts {
  28485. opt(m)
  28486. }
  28487. return m
  28488. }
  28489. // withTutorialID sets the ID field of the mutation.
  28490. func withTutorialID(id uint64) tutorialOption {
  28491. return func(m *TutorialMutation) {
  28492. var (
  28493. err error
  28494. once sync.Once
  28495. value *Tutorial
  28496. )
  28497. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  28498. once.Do(func() {
  28499. if m.done {
  28500. err = errors.New("querying old values post mutation is not allowed")
  28501. } else {
  28502. value, err = m.Client().Tutorial.Get(ctx, id)
  28503. }
  28504. })
  28505. return value, err
  28506. }
  28507. m.id = &id
  28508. }
  28509. }
  28510. // withTutorial sets the old Tutorial of the mutation.
  28511. func withTutorial(node *Tutorial) tutorialOption {
  28512. return func(m *TutorialMutation) {
  28513. m.oldValue = func(context.Context) (*Tutorial, error) {
  28514. return node, nil
  28515. }
  28516. m.id = &node.ID
  28517. }
  28518. }
  28519. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28520. // executed in a transaction (ent.Tx), a transactional client is returned.
  28521. func (m TutorialMutation) Client() *Client {
  28522. client := &Client{config: m.config}
  28523. client.init()
  28524. return client
  28525. }
  28526. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28527. // it returns an error otherwise.
  28528. func (m TutorialMutation) Tx() (*Tx, error) {
  28529. if _, ok := m.driver.(*txDriver); !ok {
  28530. return nil, errors.New("ent: mutation is not running in a transaction")
  28531. }
  28532. tx := &Tx{config: m.config}
  28533. tx.init()
  28534. return tx, nil
  28535. }
  28536. // SetID sets the value of the id field. Note that this
  28537. // operation is only accepted on creation of Tutorial entities.
  28538. func (m *TutorialMutation) SetID(id uint64) {
  28539. m.id = &id
  28540. }
  28541. // ID returns the ID value in the mutation. Note that the ID is only available
  28542. // if it was provided to the builder or after it was returned from the database.
  28543. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  28544. if m.id == nil {
  28545. return
  28546. }
  28547. return *m.id, true
  28548. }
  28549. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28550. // That means, if the mutation is applied within a transaction with an isolation level such
  28551. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28552. // or updated by the mutation.
  28553. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  28554. switch {
  28555. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28556. id, exists := m.ID()
  28557. if exists {
  28558. return []uint64{id}, nil
  28559. }
  28560. fallthrough
  28561. case m.op.Is(OpUpdate | OpDelete):
  28562. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  28563. default:
  28564. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28565. }
  28566. }
  28567. // SetCreatedAt sets the "created_at" field.
  28568. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  28569. m.created_at = &t
  28570. }
  28571. // CreatedAt returns the value of the "created_at" field in the mutation.
  28572. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  28573. v := m.created_at
  28574. if v == nil {
  28575. return
  28576. }
  28577. return *v, true
  28578. }
  28579. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  28580. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28582. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28583. if !m.op.Is(OpUpdateOne) {
  28584. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28585. }
  28586. if m.id == nil || m.oldValue == nil {
  28587. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28588. }
  28589. oldValue, err := m.oldValue(ctx)
  28590. if err != nil {
  28591. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28592. }
  28593. return oldValue.CreatedAt, nil
  28594. }
  28595. // ResetCreatedAt resets all changes to the "created_at" field.
  28596. func (m *TutorialMutation) ResetCreatedAt() {
  28597. m.created_at = nil
  28598. }
  28599. // SetUpdatedAt sets the "updated_at" field.
  28600. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  28601. m.updated_at = &t
  28602. }
  28603. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28604. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  28605. v := m.updated_at
  28606. if v == nil {
  28607. return
  28608. }
  28609. return *v, true
  28610. }
  28611. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  28612. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28614. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28615. if !m.op.Is(OpUpdateOne) {
  28616. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28617. }
  28618. if m.id == nil || m.oldValue == nil {
  28619. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28620. }
  28621. oldValue, err := m.oldValue(ctx)
  28622. if err != nil {
  28623. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28624. }
  28625. return oldValue.UpdatedAt, nil
  28626. }
  28627. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28628. func (m *TutorialMutation) ResetUpdatedAt() {
  28629. m.updated_at = nil
  28630. }
  28631. // SetDeletedAt sets the "deleted_at" field.
  28632. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  28633. m.deleted_at = &t
  28634. }
  28635. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28636. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  28637. v := m.deleted_at
  28638. if v == nil {
  28639. return
  28640. }
  28641. return *v, true
  28642. }
  28643. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  28644. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28646. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28647. if !m.op.Is(OpUpdateOne) {
  28648. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28649. }
  28650. if m.id == nil || m.oldValue == nil {
  28651. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28652. }
  28653. oldValue, err := m.oldValue(ctx)
  28654. if err != nil {
  28655. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28656. }
  28657. return oldValue.DeletedAt, nil
  28658. }
  28659. // ClearDeletedAt clears the value of the "deleted_at" field.
  28660. func (m *TutorialMutation) ClearDeletedAt() {
  28661. m.deleted_at = nil
  28662. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  28663. }
  28664. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28665. func (m *TutorialMutation) DeletedAtCleared() bool {
  28666. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  28667. return ok
  28668. }
  28669. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28670. func (m *TutorialMutation) ResetDeletedAt() {
  28671. m.deleted_at = nil
  28672. delete(m.clearedFields, tutorial.FieldDeletedAt)
  28673. }
  28674. // SetEmployeeID sets the "employee_id" field.
  28675. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  28676. m.employee = &u
  28677. }
  28678. // EmployeeID returns the value of the "employee_id" field in the mutation.
  28679. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  28680. v := m.employee
  28681. if v == nil {
  28682. return
  28683. }
  28684. return *v, true
  28685. }
  28686. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  28687. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28689. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  28690. if !m.op.Is(OpUpdateOne) {
  28691. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  28692. }
  28693. if m.id == nil || m.oldValue == nil {
  28694. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  28695. }
  28696. oldValue, err := m.oldValue(ctx)
  28697. if err != nil {
  28698. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  28699. }
  28700. return oldValue.EmployeeID, nil
  28701. }
  28702. // ResetEmployeeID resets all changes to the "employee_id" field.
  28703. func (m *TutorialMutation) ResetEmployeeID() {
  28704. m.employee = nil
  28705. }
  28706. // SetIndex sets the "index" field.
  28707. func (m *TutorialMutation) SetIndex(i int) {
  28708. m.index = &i
  28709. m.addindex = nil
  28710. }
  28711. // Index returns the value of the "index" field in the mutation.
  28712. func (m *TutorialMutation) Index() (r int, exists bool) {
  28713. v := m.index
  28714. if v == nil {
  28715. return
  28716. }
  28717. return *v, true
  28718. }
  28719. // OldIndex returns the old "index" field's value of the Tutorial entity.
  28720. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28722. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  28723. if !m.op.Is(OpUpdateOne) {
  28724. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  28725. }
  28726. if m.id == nil || m.oldValue == nil {
  28727. return v, errors.New("OldIndex requires an ID field in the mutation")
  28728. }
  28729. oldValue, err := m.oldValue(ctx)
  28730. if err != nil {
  28731. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  28732. }
  28733. return oldValue.Index, nil
  28734. }
  28735. // AddIndex adds i to the "index" field.
  28736. func (m *TutorialMutation) AddIndex(i int) {
  28737. if m.addindex != nil {
  28738. *m.addindex += i
  28739. } else {
  28740. m.addindex = &i
  28741. }
  28742. }
  28743. // AddedIndex returns the value that was added to the "index" field in this mutation.
  28744. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  28745. v := m.addindex
  28746. if v == nil {
  28747. return
  28748. }
  28749. return *v, true
  28750. }
  28751. // ResetIndex resets all changes to the "index" field.
  28752. func (m *TutorialMutation) ResetIndex() {
  28753. m.index = nil
  28754. m.addindex = nil
  28755. }
  28756. // SetTitle sets the "title" field.
  28757. func (m *TutorialMutation) SetTitle(s string) {
  28758. m.title = &s
  28759. }
  28760. // Title returns the value of the "title" field in the mutation.
  28761. func (m *TutorialMutation) Title() (r string, exists bool) {
  28762. v := m.title
  28763. if v == nil {
  28764. return
  28765. }
  28766. return *v, true
  28767. }
  28768. // OldTitle returns the old "title" field's value of the Tutorial entity.
  28769. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28771. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  28772. if !m.op.Is(OpUpdateOne) {
  28773. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  28774. }
  28775. if m.id == nil || m.oldValue == nil {
  28776. return v, errors.New("OldTitle requires an ID field in the mutation")
  28777. }
  28778. oldValue, err := m.oldValue(ctx)
  28779. if err != nil {
  28780. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  28781. }
  28782. return oldValue.Title, nil
  28783. }
  28784. // ResetTitle resets all changes to the "title" field.
  28785. func (m *TutorialMutation) ResetTitle() {
  28786. m.title = nil
  28787. }
  28788. // SetContent sets the "content" field.
  28789. func (m *TutorialMutation) SetContent(s string) {
  28790. m.content = &s
  28791. }
  28792. // Content returns the value of the "content" field in the mutation.
  28793. func (m *TutorialMutation) Content() (r string, exists bool) {
  28794. v := m.content
  28795. if v == nil {
  28796. return
  28797. }
  28798. return *v, true
  28799. }
  28800. // OldContent returns the old "content" field's value of the Tutorial entity.
  28801. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28803. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  28804. if !m.op.Is(OpUpdateOne) {
  28805. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  28806. }
  28807. if m.id == nil || m.oldValue == nil {
  28808. return v, errors.New("OldContent requires an ID field in the mutation")
  28809. }
  28810. oldValue, err := m.oldValue(ctx)
  28811. if err != nil {
  28812. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  28813. }
  28814. return oldValue.Content, nil
  28815. }
  28816. // ResetContent resets all changes to the "content" field.
  28817. func (m *TutorialMutation) ResetContent() {
  28818. m.content = nil
  28819. }
  28820. // SetOrganizationID sets the "organization_id" field.
  28821. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  28822. m.organization_id = &u
  28823. m.addorganization_id = nil
  28824. }
  28825. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28826. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  28827. v := m.organization_id
  28828. if v == nil {
  28829. return
  28830. }
  28831. return *v, true
  28832. }
  28833. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  28834. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28836. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28837. if !m.op.Is(OpUpdateOne) {
  28838. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28839. }
  28840. if m.id == nil || m.oldValue == nil {
  28841. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28842. }
  28843. oldValue, err := m.oldValue(ctx)
  28844. if err != nil {
  28845. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28846. }
  28847. return oldValue.OrganizationID, nil
  28848. }
  28849. // AddOrganizationID adds u to the "organization_id" field.
  28850. func (m *TutorialMutation) AddOrganizationID(u int64) {
  28851. if m.addorganization_id != nil {
  28852. *m.addorganization_id += u
  28853. } else {
  28854. m.addorganization_id = &u
  28855. }
  28856. }
  28857. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28858. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  28859. v := m.addorganization_id
  28860. if v == nil {
  28861. return
  28862. }
  28863. return *v, true
  28864. }
  28865. // ResetOrganizationID resets all changes to the "organization_id" field.
  28866. func (m *TutorialMutation) ResetOrganizationID() {
  28867. m.organization_id = nil
  28868. m.addorganization_id = nil
  28869. }
  28870. // ClearEmployee clears the "employee" edge to the Employee entity.
  28871. func (m *TutorialMutation) ClearEmployee() {
  28872. m.clearedemployee = true
  28873. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  28874. }
  28875. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  28876. func (m *TutorialMutation) EmployeeCleared() bool {
  28877. return m.clearedemployee
  28878. }
  28879. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  28880. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28881. // EmployeeID instead. It exists only for internal usage by the builders.
  28882. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  28883. if id := m.employee; id != nil {
  28884. ids = append(ids, *id)
  28885. }
  28886. return
  28887. }
  28888. // ResetEmployee resets all changes to the "employee" edge.
  28889. func (m *TutorialMutation) ResetEmployee() {
  28890. m.employee = nil
  28891. m.clearedemployee = false
  28892. }
  28893. // Where appends a list predicates to the TutorialMutation builder.
  28894. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  28895. m.predicates = append(m.predicates, ps...)
  28896. }
  28897. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  28898. // users can use type-assertion to append predicates that do not depend on any generated package.
  28899. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  28900. p := make([]predicate.Tutorial, len(ps))
  28901. for i := range ps {
  28902. p[i] = ps[i]
  28903. }
  28904. m.Where(p...)
  28905. }
  28906. // Op returns the operation name.
  28907. func (m *TutorialMutation) Op() Op {
  28908. return m.op
  28909. }
  28910. // SetOp allows setting the mutation operation.
  28911. func (m *TutorialMutation) SetOp(op Op) {
  28912. m.op = op
  28913. }
  28914. // Type returns the node type of this mutation (Tutorial).
  28915. func (m *TutorialMutation) Type() string {
  28916. return m.typ
  28917. }
  28918. // Fields returns all fields that were changed during this mutation. Note that in
  28919. // order to get all numeric fields that were incremented/decremented, call
  28920. // AddedFields().
  28921. func (m *TutorialMutation) Fields() []string {
  28922. fields := make([]string, 0, 8)
  28923. if m.created_at != nil {
  28924. fields = append(fields, tutorial.FieldCreatedAt)
  28925. }
  28926. if m.updated_at != nil {
  28927. fields = append(fields, tutorial.FieldUpdatedAt)
  28928. }
  28929. if m.deleted_at != nil {
  28930. fields = append(fields, tutorial.FieldDeletedAt)
  28931. }
  28932. if m.employee != nil {
  28933. fields = append(fields, tutorial.FieldEmployeeID)
  28934. }
  28935. if m.index != nil {
  28936. fields = append(fields, tutorial.FieldIndex)
  28937. }
  28938. if m.title != nil {
  28939. fields = append(fields, tutorial.FieldTitle)
  28940. }
  28941. if m.content != nil {
  28942. fields = append(fields, tutorial.FieldContent)
  28943. }
  28944. if m.organization_id != nil {
  28945. fields = append(fields, tutorial.FieldOrganizationID)
  28946. }
  28947. return fields
  28948. }
  28949. // Field returns the value of a field with the given name. The second boolean
  28950. // return value indicates that this field was not set, or was not defined in the
  28951. // schema.
  28952. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  28953. switch name {
  28954. case tutorial.FieldCreatedAt:
  28955. return m.CreatedAt()
  28956. case tutorial.FieldUpdatedAt:
  28957. return m.UpdatedAt()
  28958. case tutorial.FieldDeletedAt:
  28959. return m.DeletedAt()
  28960. case tutorial.FieldEmployeeID:
  28961. return m.EmployeeID()
  28962. case tutorial.FieldIndex:
  28963. return m.Index()
  28964. case tutorial.FieldTitle:
  28965. return m.Title()
  28966. case tutorial.FieldContent:
  28967. return m.Content()
  28968. case tutorial.FieldOrganizationID:
  28969. return m.OrganizationID()
  28970. }
  28971. return nil, false
  28972. }
  28973. // OldField returns the old value of the field from the database. An error is
  28974. // returned if the mutation operation is not UpdateOne, or the query to the
  28975. // database failed.
  28976. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28977. switch name {
  28978. case tutorial.FieldCreatedAt:
  28979. return m.OldCreatedAt(ctx)
  28980. case tutorial.FieldUpdatedAt:
  28981. return m.OldUpdatedAt(ctx)
  28982. case tutorial.FieldDeletedAt:
  28983. return m.OldDeletedAt(ctx)
  28984. case tutorial.FieldEmployeeID:
  28985. return m.OldEmployeeID(ctx)
  28986. case tutorial.FieldIndex:
  28987. return m.OldIndex(ctx)
  28988. case tutorial.FieldTitle:
  28989. return m.OldTitle(ctx)
  28990. case tutorial.FieldContent:
  28991. return m.OldContent(ctx)
  28992. case tutorial.FieldOrganizationID:
  28993. return m.OldOrganizationID(ctx)
  28994. }
  28995. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  28996. }
  28997. // SetField sets the value of a field with the given name. It returns an error if
  28998. // the field is not defined in the schema, or if the type mismatched the field
  28999. // type.
  29000. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  29001. switch name {
  29002. case tutorial.FieldCreatedAt:
  29003. v, ok := value.(time.Time)
  29004. if !ok {
  29005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29006. }
  29007. m.SetCreatedAt(v)
  29008. return nil
  29009. case tutorial.FieldUpdatedAt:
  29010. v, ok := value.(time.Time)
  29011. if !ok {
  29012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29013. }
  29014. m.SetUpdatedAt(v)
  29015. return nil
  29016. case tutorial.FieldDeletedAt:
  29017. v, ok := value.(time.Time)
  29018. if !ok {
  29019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29020. }
  29021. m.SetDeletedAt(v)
  29022. return nil
  29023. case tutorial.FieldEmployeeID:
  29024. v, ok := value.(uint64)
  29025. if !ok {
  29026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29027. }
  29028. m.SetEmployeeID(v)
  29029. return nil
  29030. case tutorial.FieldIndex:
  29031. v, ok := value.(int)
  29032. if !ok {
  29033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29034. }
  29035. m.SetIndex(v)
  29036. return nil
  29037. case tutorial.FieldTitle:
  29038. v, ok := value.(string)
  29039. if !ok {
  29040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29041. }
  29042. m.SetTitle(v)
  29043. return nil
  29044. case tutorial.FieldContent:
  29045. v, ok := value.(string)
  29046. if !ok {
  29047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29048. }
  29049. m.SetContent(v)
  29050. return nil
  29051. case tutorial.FieldOrganizationID:
  29052. v, ok := value.(uint64)
  29053. if !ok {
  29054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29055. }
  29056. m.SetOrganizationID(v)
  29057. return nil
  29058. }
  29059. return fmt.Errorf("unknown Tutorial field %s", name)
  29060. }
  29061. // AddedFields returns all numeric fields that were incremented/decremented during
  29062. // this mutation.
  29063. func (m *TutorialMutation) AddedFields() []string {
  29064. var fields []string
  29065. if m.addindex != nil {
  29066. fields = append(fields, tutorial.FieldIndex)
  29067. }
  29068. if m.addorganization_id != nil {
  29069. fields = append(fields, tutorial.FieldOrganizationID)
  29070. }
  29071. return fields
  29072. }
  29073. // AddedField returns the numeric value that was incremented/decremented on a field
  29074. // with the given name. The second boolean return value indicates that this field
  29075. // was not set, or was not defined in the schema.
  29076. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  29077. switch name {
  29078. case tutorial.FieldIndex:
  29079. return m.AddedIndex()
  29080. case tutorial.FieldOrganizationID:
  29081. return m.AddedOrganizationID()
  29082. }
  29083. return nil, false
  29084. }
  29085. // AddField adds the value to the field with the given name. It returns an error if
  29086. // the field is not defined in the schema, or if the type mismatched the field
  29087. // type.
  29088. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  29089. switch name {
  29090. case tutorial.FieldIndex:
  29091. v, ok := value.(int)
  29092. if !ok {
  29093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29094. }
  29095. m.AddIndex(v)
  29096. return nil
  29097. case tutorial.FieldOrganizationID:
  29098. v, ok := value.(int64)
  29099. if !ok {
  29100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29101. }
  29102. m.AddOrganizationID(v)
  29103. return nil
  29104. }
  29105. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  29106. }
  29107. // ClearedFields returns all nullable fields that were cleared during this
  29108. // mutation.
  29109. func (m *TutorialMutation) ClearedFields() []string {
  29110. var fields []string
  29111. if m.FieldCleared(tutorial.FieldDeletedAt) {
  29112. fields = append(fields, tutorial.FieldDeletedAt)
  29113. }
  29114. return fields
  29115. }
  29116. // FieldCleared returns a boolean indicating if a field with the given name was
  29117. // cleared in this mutation.
  29118. func (m *TutorialMutation) FieldCleared(name string) bool {
  29119. _, ok := m.clearedFields[name]
  29120. return ok
  29121. }
  29122. // ClearField clears the value of the field with the given name. It returns an
  29123. // error if the field is not defined in the schema.
  29124. func (m *TutorialMutation) ClearField(name string) error {
  29125. switch name {
  29126. case tutorial.FieldDeletedAt:
  29127. m.ClearDeletedAt()
  29128. return nil
  29129. }
  29130. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  29131. }
  29132. // ResetField resets all changes in the mutation for the field with the given name.
  29133. // It returns an error if the field is not defined in the schema.
  29134. func (m *TutorialMutation) ResetField(name string) error {
  29135. switch name {
  29136. case tutorial.FieldCreatedAt:
  29137. m.ResetCreatedAt()
  29138. return nil
  29139. case tutorial.FieldUpdatedAt:
  29140. m.ResetUpdatedAt()
  29141. return nil
  29142. case tutorial.FieldDeletedAt:
  29143. m.ResetDeletedAt()
  29144. return nil
  29145. case tutorial.FieldEmployeeID:
  29146. m.ResetEmployeeID()
  29147. return nil
  29148. case tutorial.FieldIndex:
  29149. m.ResetIndex()
  29150. return nil
  29151. case tutorial.FieldTitle:
  29152. m.ResetTitle()
  29153. return nil
  29154. case tutorial.FieldContent:
  29155. m.ResetContent()
  29156. return nil
  29157. case tutorial.FieldOrganizationID:
  29158. m.ResetOrganizationID()
  29159. return nil
  29160. }
  29161. return fmt.Errorf("unknown Tutorial field %s", name)
  29162. }
  29163. // AddedEdges returns all edge names that were set/added in this mutation.
  29164. func (m *TutorialMutation) AddedEdges() []string {
  29165. edges := make([]string, 0, 1)
  29166. if m.employee != nil {
  29167. edges = append(edges, tutorial.EdgeEmployee)
  29168. }
  29169. return edges
  29170. }
  29171. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29172. // name in this mutation.
  29173. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  29174. switch name {
  29175. case tutorial.EdgeEmployee:
  29176. if id := m.employee; id != nil {
  29177. return []ent.Value{*id}
  29178. }
  29179. }
  29180. return nil
  29181. }
  29182. // RemovedEdges returns all edge names that were removed in this mutation.
  29183. func (m *TutorialMutation) RemovedEdges() []string {
  29184. edges := make([]string, 0, 1)
  29185. return edges
  29186. }
  29187. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29188. // the given name in this mutation.
  29189. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  29190. return nil
  29191. }
  29192. // ClearedEdges returns all edge names that were cleared in this mutation.
  29193. func (m *TutorialMutation) ClearedEdges() []string {
  29194. edges := make([]string, 0, 1)
  29195. if m.clearedemployee {
  29196. edges = append(edges, tutorial.EdgeEmployee)
  29197. }
  29198. return edges
  29199. }
  29200. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29201. // was cleared in this mutation.
  29202. func (m *TutorialMutation) EdgeCleared(name string) bool {
  29203. switch name {
  29204. case tutorial.EdgeEmployee:
  29205. return m.clearedemployee
  29206. }
  29207. return false
  29208. }
  29209. // ClearEdge clears the value of the edge with the given name. It returns an error
  29210. // if that edge is not defined in the schema.
  29211. func (m *TutorialMutation) ClearEdge(name string) error {
  29212. switch name {
  29213. case tutorial.EdgeEmployee:
  29214. m.ClearEmployee()
  29215. return nil
  29216. }
  29217. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  29218. }
  29219. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29220. // It returns an error if the edge is not defined in the schema.
  29221. func (m *TutorialMutation) ResetEdge(name string) error {
  29222. switch name {
  29223. case tutorial.EdgeEmployee:
  29224. m.ResetEmployee()
  29225. return nil
  29226. }
  29227. return fmt.Errorf("unknown Tutorial edge %s", name)
  29228. }
  29229. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  29230. type UsageDetailMutation struct {
  29231. config
  29232. op Op
  29233. typ string
  29234. id *uint64
  29235. created_at *time.Time
  29236. updated_at *time.Time
  29237. status *uint8
  29238. addstatus *int8
  29239. _type *int
  29240. add_type *int
  29241. bot_id *string
  29242. receiver_id *string
  29243. app *int
  29244. addapp *int
  29245. session_id *uint64
  29246. addsession_id *int64
  29247. request *string
  29248. response *string
  29249. original_data *custom_types.OriginalData
  29250. total_tokens *uint64
  29251. addtotal_tokens *int64
  29252. prompt_tokens *uint64
  29253. addprompt_tokens *int64
  29254. completion_tokens *uint64
  29255. addcompletion_tokens *int64
  29256. organization_id *uint64
  29257. addorganization_id *int64
  29258. clearedFields map[string]struct{}
  29259. done bool
  29260. oldValue func(context.Context) (*UsageDetail, error)
  29261. predicates []predicate.UsageDetail
  29262. }
  29263. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  29264. // usagedetailOption allows management of the mutation configuration using functional options.
  29265. type usagedetailOption func(*UsageDetailMutation)
  29266. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  29267. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  29268. m := &UsageDetailMutation{
  29269. config: c,
  29270. op: op,
  29271. typ: TypeUsageDetail,
  29272. clearedFields: make(map[string]struct{}),
  29273. }
  29274. for _, opt := range opts {
  29275. opt(m)
  29276. }
  29277. return m
  29278. }
  29279. // withUsageDetailID sets the ID field of the mutation.
  29280. func withUsageDetailID(id uint64) usagedetailOption {
  29281. return func(m *UsageDetailMutation) {
  29282. var (
  29283. err error
  29284. once sync.Once
  29285. value *UsageDetail
  29286. )
  29287. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  29288. once.Do(func() {
  29289. if m.done {
  29290. err = errors.New("querying old values post mutation is not allowed")
  29291. } else {
  29292. value, err = m.Client().UsageDetail.Get(ctx, id)
  29293. }
  29294. })
  29295. return value, err
  29296. }
  29297. m.id = &id
  29298. }
  29299. }
  29300. // withUsageDetail sets the old UsageDetail of the mutation.
  29301. func withUsageDetail(node *UsageDetail) usagedetailOption {
  29302. return func(m *UsageDetailMutation) {
  29303. m.oldValue = func(context.Context) (*UsageDetail, error) {
  29304. return node, nil
  29305. }
  29306. m.id = &node.ID
  29307. }
  29308. }
  29309. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29310. // executed in a transaction (ent.Tx), a transactional client is returned.
  29311. func (m UsageDetailMutation) Client() *Client {
  29312. client := &Client{config: m.config}
  29313. client.init()
  29314. return client
  29315. }
  29316. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29317. // it returns an error otherwise.
  29318. func (m UsageDetailMutation) Tx() (*Tx, error) {
  29319. if _, ok := m.driver.(*txDriver); !ok {
  29320. return nil, errors.New("ent: mutation is not running in a transaction")
  29321. }
  29322. tx := &Tx{config: m.config}
  29323. tx.init()
  29324. return tx, nil
  29325. }
  29326. // SetID sets the value of the id field. Note that this
  29327. // operation is only accepted on creation of UsageDetail entities.
  29328. func (m *UsageDetailMutation) SetID(id uint64) {
  29329. m.id = &id
  29330. }
  29331. // ID returns the ID value in the mutation. Note that the ID is only available
  29332. // if it was provided to the builder or after it was returned from the database.
  29333. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  29334. if m.id == nil {
  29335. return
  29336. }
  29337. return *m.id, true
  29338. }
  29339. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29340. // That means, if the mutation is applied within a transaction with an isolation level such
  29341. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29342. // or updated by the mutation.
  29343. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  29344. switch {
  29345. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29346. id, exists := m.ID()
  29347. if exists {
  29348. return []uint64{id}, nil
  29349. }
  29350. fallthrough
  29351. case m.op.Is(OpUpdate | OpDelete):
  29352. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  29353. default:
  29354. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29355. }
  29356. }
  29357. // SetCreatedAt sets the "created_at" field.
  29358. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  29359. m.created_at = &t
  29360. }
  29361. // CreatedAt returns the value of the "created_at" field in the mutation.
  29362. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  29363. v := m.created_at
  29364. if v == nil {
  29365. return
  29366. }
  29367. return *v, true
  29368. }
  29369. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  29370. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29372. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29373. if !m.op.Is(OpUpdateOne) {
  29374. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29375. }
  29376. if m.id == nil || m.oldValue == nil {
  29377. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29378. }
  29379. oldValue, err := m.oldValue(ctx)
  29380. if err != nil {
  29381. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29382. }
  29383. return oldValue.CreatedAt, nil
  29384. }
  29385. // ResetCreatedAt resets all changes to the "created_at" field.
  29386. func (m *UsageDetailMutation) ResetCreatedAt() {
  29387. m.created_at = nil
  29388. }
  29389. // SetUpdatedAt sets the "updated_at" field.
  29390. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  29391. m.updated_at = &t
  29392. }
  29393. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29394. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  29395. v := m.updated_at
  29396. if v == nil {
  29397. return
  29398. }
  29399. return *v, true
  29400. }
  29401. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  29402. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29404. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29405. if !m.op.Is(OpUpdateOne) {
  29406. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29407. }
  29408. if m.id == nil || m.oldValue == nil {
  29409. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29410. }
  29411. oldValue, err := m.oldValue(ctx)
  29412. if err != nil {
  29413. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29414. }
  29415. return oldValue.UpdatedAt, nil
  29416. }
  29417. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29418. func (m *UsageDetailMutation) ResetUpdatedAt() {
  29419. m.updated_at = nil
  29420. }
  29421. // SetStatus sets the "status" field.
  29422. func (m *UsageDetailMutation) SetStatus(u uint8) {
  29423. m.status = &u
  29424. m.addstatus = nil
  29425. }
  29426. // Status returns the value of the "status" field in the mutation.
  29427. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  29428. v := m.status
  29429. if v == nil {
  29430. return
  29431. }
  29432. return *v, true
  29433. }
  29434. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  29435. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29437. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29438. if !m.op.Is(OpUpdateOne) {
  29439. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29440. }
  29441. if m.id == nil || m.oldValue == nil {
  29442. return v, errors.New("OldStatus requires an ID field in the mutation")
  29443. }
  29444. oldValue, err := m.oldValue(ctx)
  29445. if err != nil {
  29446. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29447. }
  29448. return oldValue.Status, nil
  29449. }
  29450. // AddStatus adds u to the "status" field.
  29451. func (m *UsageDetailMutation) AddStatus(u int8) {
  29452. if m.addstatus != nil {
  29453. *m.addstatus += u
  29454. } else {
  29455. m.addstatus = &u
  29456. }
  29457. }
  29458. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29459. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  29460. v := m.addstatus
  29461. if v == nil {
  29462. return
  29463. }
  29464. return *v, true
  29465. }
  29466. // ClearStatus clears the value of the "status" field.
  29467. func (m *UsageDetailMutation) ClearStatus() {
  29468. m.status = nil
  29469. m.addstatus = nil
  29470. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  29471. }
  29472. // StatusCleared returns if the "status" field was cleared in this mutation.
  29473. func (m *UsageDetailMutation) StatusCleared() bool {
  29474. _, ok := m.clearedFields[usagedetail.FieldStatus]
  29475. return ok
  29476. }
  29477. // ResetStatus resets all changes to the "status" field.
  29478. func (m *UsageDetailMutation) ResetStatus() {
  29479. m.status = nil
  29480. m.addstatus = nil
  29481. delete(m.clearedFields, usagedetail.FieldStatus)
  29482. }
  29483. // SetType sets the "type" field.
  29484. func (m *UsageDetailMutation) SetType(i int) {
  29485. m._type = &i
  29486. m.add_type = nil
  29487. }
  29488. // GetType returns the value of the "type" field in the mutation.
  29489. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  29490. v := m._type
  29491. if v == nil {
  29492. return
  29493. }
  29494. return *v, true
  29495. }
  29496. // OldType returns the old "type" field's value of the UsageDetail entity.
  29497. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29499. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  29500. if !m.op.Is(OpUpdateOne) {
  29501. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29502. }
  29503. if m.id == nil || m.oldValue == nil {
  29504. return v, errors.New("OldType requires an ID field in the mutation")
  29505. }
  29506. oldValue, err := m.oldValue(ctx)
  29507. if err != nil {
  29508. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29509. }
  29510. return oldValue.Type, nil
  29511. }
  29512. // AddType adds i to the "type" field.
  29513. func (m *UsageDetailMutation) AddType(i int) {
  29514. if m.add_type != nil {
  29515. *m.add_type += i
  29516. } else {
  29517. m.add_type = &i
  29518. }
  29519. }
  29520. // AddedType returns the value that was added to the "type" field in this mutation.
  29521. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  29522. v := m.add_type
  29523. if v == nil {
  29524. return
  29525. }
  29526. return *v, true
  29527. }
  29528. // ClearType clears the value of the "type" field.
  29529. func (m *UsageDetailMutation) ClearType() {
  29530. m._type = nil
  29531. m.add_type = nil
  29532. m.clearedFields[usagedetail.FieldType] = struct{}{}
  29533. }
  29534. // TypeCleared returns if the "type" field was cleared in this mutation.
  29535. func (m *UsageDetailMutation) TypeCleared() bool {
  29536. _, ok := m.clearedFields[usagedetail.FieldType]
  29537. return ok
  29538. }
  29539. // ResetType resets all changes to the "type" field.
  29540. func (m *UsageDetailMutation) ResetType() {
  29541. m._type = nil
  29542. m.add_type = nil
  29543. delete(m.clearedFields, usagedetail.FieldType)
  29544. }
  29545. // SetBotID sets the "bot_id" field.
  29546. func (m *UsageDetailMutation) SetBotID(s string) {
  29547. m.bot_id = &s
  29548. }
  29549. // BotID returns the value of the "bot_id" field in the mutation.
  29550. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  29551. v := m.bot_id
  29552. if v == nil {
  29553. return
  29554. }
  29555. return *v, true
  29556. }
  29557. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  29558. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29560. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  29561. if !m.op.Is(OpUpdateOne) {
  29562. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29563. }
  29564. if m.id == nil || m.oldValue == nil {
  29565. return v, errors.New("OldBotID requires an ID field in the mutation")
  29566. }
  29567. oldValue, err := m.oldValue(ctx)
  29568. if err != nil {
  29569. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29570. }
  29571. return oldValue.BotID, nil
  29572. }
  29573. // ResetBotID resets all changes to the "bot_id" field.
  29574. func (m *UsageDetailMutation) ResetBotID() {
  29575. m.bot_id = nil
  29576. }
  29577. // SetReceiverID sets the "receiver_id" field.
  29578. func (m *UsageDetailMutation) SetReceiverID(s string) {
  29579. m.receiver_id = &s
  29580. }
  29581. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  29582. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  29583. v := m.receiver_id
  29584. if v == nil {
  29585. return
  29586. }
  29587. return *v, true
  29588. }
  29589. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  29590. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29592. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  29593. if !m.op.Is(OpUpdateOne) {
  29594. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  29595. }
  29596. if m.id == nil || m.oldValue == nil {
  29597. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  29598. }
  29599. oldValue, err := m.oldValue(ctx)
  29600. if err != nil {
  29601. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  29602. }
  29603. return oldValue.ReceiverID, nil
  29604. }
  29605. // ResetReceiverID resets all changes to the "receiver_id" field.
  29606. func (m *UsageDetailMutation) ResetReceiverID() {
  29607. m.receiver_id = nil
  29608. }
  29609. // SetApp sets the "app" field.
  29610. func (m *UsageDetailMutation) SetApp(i int) {
  29611. m.app = &i
  29612. m.addapp = nil
  29613. }
  29614. // App returns the value of the "app" field in the mutation.
  29615. func (m *UsageDetailMutation) App() (r int, exists bool) {
  29616. v := m.app
  29617. if v == nil {
  29618. return
  29619. }
  29620. return *v, true
  29621. }
  29622. // OldApp returns the old "app" field's value of the UsageDetail entity.
  29623. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29625. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  29626. if !m.op.Is(OpUpdateOne) {
  29627. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  29628. }
  29629. if m.id == nil || m.oldValue == nil {
  29630. return v, errors.New("OldApp requires an ID field in the mutation")
  29631. }
  29632. oldValue, err := m.oldValue(ctx)
  29633. if err != nil {
  29634. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  29635. }
  29636. return oldValue.App, nil
  29637. }
  29638. // AddApp adds i to the "app" field.
  29639. func (m *UsageDetailMutation) AddApp(i int) {
  29640. if m.addapp != nil {
  29641. *m.addapp += i
  29642. } else {
  29643. m.addapp = &i
  29644. }
  29645. }
  29646. // AddedApp returns the value that was added to the "app" field in this mutation.
  29647. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  29648. v := m.addapp
  29649. if v == nil {
  29650. return
  29651. }
  29652. return *v, true
  29653. }
  29654. // ClearApp clears the value of the "app" field.
  29655. func (m *UsageDetailMutation) ClearApp() {
  29656. m.app = nil
  29657. m.addapp = nil
  29658. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  29659. }
  29660. // AppCleared returns if the "app" field was cleared in this mutation.
  29661. func (m *UsageDetailMutation) AppCleared() bool {
  29662. _, ok := m.clearedFields[usagedetail.FieldApp]
  29663. return ok
  29664. }
  29665. // ResetApp resets all changes to the "app" field.
  29666. func (m *UsageDetailMutation) ResetApp() {
  29667. m.app = nil
  29668. m.addapp = nil
  29669. delete(m.clearedFields, usagedetail.FieldApp)
  29670. }
  29671. // SetSessionID sets the "session_id" field.
  29672. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  29673. m.session_id = &u
  29674. m.addsession_id = nil
  29675. }
  29676. // SessionID returns the value of the "session_id" field in the mutation.
  29677. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  29678. v := m.session_id
  29679. if v == nil {
  29680. return
  29681. }
  29682. return *v, true
  29683. }
  29684. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  29685. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29687. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  29688. if !m.op.Is(OpUpdateOne) {
  29689. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  29690. }
  29691. if m.id == nil || m.oldValue == nil {
  29692. return v, errors.New("OldSessionID requires an ID field in the mutation")
  29693. }
  29694. oldValue, err := m.oldValue(ctx)
  29695. if err != nil {
  29696. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  29697. }
  29698. return oldValue.SessionID, nil
  29699. }
  29700. // AddSessionID adds u to the "session_id" field.
  29701. func (m *UsageDetailMutation) AddSessionID(u int64) {
  29702. if m.addsession_id != nil {
  29703. *m.addsession_id += u
  29704. } else {
  29705. m.addsession_id = &u
  29706. }
  29707. }
  29708. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  29709. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  29710. v := m.addsession_id
  29711. if v == nil {
  29712. return
  29713. }
  29714. return *v, true
  29715. }
  29716. // ClearSessionID clears the value of the "session_id" field.
  29717. func (m *UsageDetailMutation) ClearSessionID() {
  29718. m.session_id = nil
  29719. m.addsession_id = nil
  29720. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  29721. }
  29722. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  29723. func (m *UsageDetailMutation) SessionIDCleared() bool {
  29724. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  29725. return ok
  29726. }
  29727. // ResetSessionID resets all changes to the "session_id" field.
  29728. func (m *UsageDetailMutation) ResetSessionID() {
  29729. m.session_id = nil
  29730. m.addsession_id = nil
  29731. delete(m.clearedFields, usagedetail.FieldSessionID)
  29732. }
  29733. // SetRequest sets the "request" field.
  29734. func (m *UsageDetailMutation) SetRequest(s string) {
  29735. m.request = &s
  29736. }
  29737. // Request returns the value of the "request" field in the mutation.
  29738. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  29739. v := m.request
  29740. if v == nil {
  29741. return
  29742. }
  29743. return *v, true
  29744. }
  29745. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  29746. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29748. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  29749. if !m.op.Is(OpUpdateOne) {
  29750. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  29751. }
  29752. if m.id == nil || m.oldValue == nil {
  29753. return v, errors.New("OldRequest requires an ID field in the mutation")
  29754. }
  29755. oldValue, err := m.oldValue(ctx)
  29756. if err != nil {
  29757. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  29758. }
  29759. return oldValue.Request, nil
  29760. }
  29761. // ResetRequest resets all changes to the "request" field.
  29762. func (m *UsageDetailMutation) ResetRequest() {
  29763. m.request = nil
  29764. }
  29765. // SetResponse sets the "response" field.
  29766. func (m *UsageDetailMutation) SetResponse(s string) {
  29767. m.response = &s
  29768. }
  29769. // Response returns the value of the "response" field in the mutation.
  29770. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  29771. v := m.response
  29772. if v == nil {
  29773. return
  29774. }
  29775. return *v, true
  29776. }
  29777. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  29778. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29780. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  29781. if !m.op.Is(OpUpdateOne) {
  29782. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  29783. }
  29784. if m.id == nil || m.oldValue == nil {
  29785. return v, errors.New("OldResponse requires an ID field in the mutation")
  29786. }
  29787. oldValue, err := m.oldValue(ctx)
  29788. if err != nil {
  29789. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  29790. }
  29791. return oldValue.Response, nil
  29792. }
  29793. // ResetResponse resets all changes to the "response" field.
  29794. func (m *UsageDetailMutation) ResetResponse() {
  29795. m.response = nil
  29796. }
  29797. // SetOriginalData sets the "original_data" field.
  29798. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  29799. m.original_data = &ctd
  29800. }
  29801. // OriginalData returns the value of the "original_data" field in the mutation.
  29802. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  29803. v := m.original_data
  29804. if v == nil {
  29805. return
  29806. }
  29807. return *v, true
  29808. }
  29809. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  29810. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29812. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  29813. if !m.op.Is(OpUpdateOne) {
  29814. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  29815. }
  29816. if m.id == nil || m.oldValue == nil {
  29817. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  29818. }
  29819. oldValue, err := m.oldValue(ctx)
  29820. if err != nil {
  29821. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  29822. }
  29823. return oldValue.OriginalData, nil
  29824. }
  29825. // ResetOriginalData resets all changes to the "original_data" field.
  29826. func (m *UsageDetailMutation) ResetOriginalData() {
  29827. m.original_data = nil
  29828. }
  29829. // SetTotalTokens sets the "total_tokens" field.
  29830. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  29831. m.total_tokens = &u
  29832. m.addtotal_tokens = nil
  29833. }
  29834. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  29835. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  29836. v := m.total_tokens
  29837. if v == nil {
  29838. return
  29839. }
  29840. return *v, true
  29841. }
  29842. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  29843. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29845. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  29846. if !m.op.Is(OpUpdateOne) {
  29847. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  29848. }
  29849. if m.id == nil || m.oldValue == nil {
  29850. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  29851. }
  29852. oldValue, err := m.oldValue(ctx)
  29853. if err != nil {
  29854. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  29855. }
  29856. return oldValue.TotalTokens, nil
  29857. }
  29858. // AddTotalTokens adds u to the "total_tokens" field.
  29859. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  29860. if m.addtotal_tokens != nil {
  29861. *m.addtotal_tokens += u
  29862. } else {
  29863. m.addtotal_tokens = &u
  29864. }
  29865. }
  29866. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  29867. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  29868. v := m.addtotal_tokens
  29869. if v == nil {
  29870. return
  29871. }
  29872. return *v, true
  29873. }
  29874. // ClearTotalTokens clears the value of the "total_tokens" field.
  29875. func (m *UsageDetailMutation) ClearTotalTokens() {
  29876. m.total_tokens = nil
  29877. m.addtotal_tokens = nil
  29878. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  29879. }
  29880. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  29881. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  29882. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  29883. return ok
  29884. }
  29885. // ResetTotalTokens resets all changes to the "total_tokens" field.
  29886. func (m *UsageDetailMutation) ResetTotalTokens() {
  29887. m.total_tokens = nil
  29888. m.addtotal_tokens = nil
  29889. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  29890. }
  29891. // SetPromptTokens sets the "prompt_tokens" field.
  29892. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  29893. m.prompt_tokens = &u
  29894. m.addprompt_tokens = nil
  29895. }
  29896. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  29897. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  29898. v := m.prompt_tokens
  29899. if v == nil {
  29900. return
  29901. }
  29902. return *v, true
  29903. }
  29904. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  29905. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29907. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  29908. if !m.op.Is(OpUpdateOne) {
  29909. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  29910. }
  29911. if m.id == nil || m.oldValue == nil {
  29912. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  29913. }
  29914. oldValue, err := m.oldValue(ctx)
  29915. if err != nil {
  29916. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  29917. }
  29918. return oldValue.PromptTokens, nil
  29919. }
  29920. // AddPromptTokens adds u to the "prompt_tokens" field.
  29921. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  29922. if m.addprompt_tokens != nil {
  29923. *m.addprompt_tokens += u
  29924. } else {
  29925. m.addprompt_tokens = &u
  29926. }
  29927. }
  29928. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  29929. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  29930. v := m.addprompt_tokens
  29931. if v == nil {
  29932. return
  29933. }
  29934. return *v, true
  29935. }
  29936. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  29937. func (m *UsageDetailMutation) ClearPromptTokens() {
  29938. m.prompt_tokens = nil
  29939. m.addprompt_tokens = nil
  29940. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  29941. }
  29942. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  29943. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  29944. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  29945. return ok
  29946. }
  29947. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  29948. func (m *UsageDetailMutation) ResetPromptTokens() {
  29949. m.prompt_tokens = nil
  29950. m.addprompt_tokens = nil
  29951. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  29952. }
  29953. // SetCompletionTokens sets the "completion_tokens" field.
  29954. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  29955. m.completion_tokens = &u
  29956. m.addcompletion_tokens = nil
  29957. }
  29958. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  29959. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  29960. v := m.completion_tokens
  29961. if v == nil {
  29962. return
  29963. }
  29964. return *v, true
  29965. }
  29966. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  29967. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29969. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  29970. if !m.op.Is(OpUpdateOne) {
  29971. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  29972. }
  29973. if m.id == nil || m.oldValue == nil {
  29974. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  29975. }
  29976. oldValue, err := m.oldValue(ctx)
  29977. if err != nil {
  29978. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  29979. }
  29980. return oldValue.CompletionTokens, nil
  29981. }
  29982. // AddCompletionTokens adds u to the "completion_tokens" field.
  29983. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  29984. if m.addcompletion_tokens != nil {
  29985. *m.addcompletion_tokens += u
  29986. } else {
  29987. m.addcompletion_tokens = &u
  29988. }
  29989. }
  29990. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  29991. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  29992. v := m.addcompletion_tokens
  29993. if v == nil {
  29994. return
  29995. }
  29996. return *v, true
  29997. }
  29998. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  29999. func (m *UsageDetailMutation) ClearCompletionTokens() {
  30000. m.completion_tokens = nil
  30001. m.addcompletion_tokens = nil
  30002. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  30003. }
  30004. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  30005. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  30006. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  30007. return ok
  30008. }
  30009. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  30010. func (m *UsageDetailMutation) ResetCompletionTokens() {
  30011. m.completion_tokens = nil
  30012. m.addcompletion_tokens = nil
  30013. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  30014. }
  30015. // SetOrganizationID sets the "organization_id" field.
  30016. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  30017. m.organization_id = &u
  30018. m.addorganization_id = nil
  30019. }
  30020. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30021. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  30022. v := m.organization_id
  30023. if v == nil {
  30024. return
  30025. }
  30026. return *v, true
  30027. }
  30028. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  30029. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30031. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30032. if !m.op.Is(OpUpdateOne) {
  30033. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30034. }
  30035. if m.id == nil || m.oldValue == nil {
  30036. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30037. }
  30038. oldValue, err := m.oldValue(ctx)
  30039. if err != nil {
  30040. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30041. }
  30042. return oldValue.OrganizationID, nil
  30043. }
  30044. // AddOrganizationID adds u to the "organization_id" field.
  30045. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  30046. if m.addorganization_id != nil {
  30047. *m.addorganization_id += u
  30048. } else {
  30049. m.addorganization_id = &u
  30050. }
  30051. }
  30052. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30053. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  30054. v := m.addorganization_id
  30055. if v == nil {
  30056. return
  30057. }
  30058. return *v, true
  30059. }
  30060. // ClearOrganizationID clears the value of the "organization_id" field.
  30061. func (m *UsageDetailMutation) ClearOrganizationID() {
  30062. m.organization_id = nil
  30063. m.addorganization_id = nil
  30064. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  30065. }
  30066. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30067. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  30068. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  30069. return ok
  30070. }
  30071. // ResetOrganizationID resets all changes to the "organization_id" field.
  30072. func (m *UsageDetailMutation) ResetOrganizationID() {
  30073. m.organization_id = nil
  30074. m.addorganization_id = nil
  30075. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  30076. }
  30077. // Where appends a list predicates to the UsageDetailMutation builder.
  30078. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  30079. m.predicates = append(m.predicates, ps...)
  30080. }
  30081. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  30082. // users can use type-assertion to append predicates that do not depend on any generated package.
  30083. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  30084. p := make([]predicate.UsageDetail, len(ps))
  30085. for i := range ps {
  30086. p[i] = ps[i]
  30087. }
  30088. m.Where(p...)
  30089. }
  30090. // Op returns the operation name.
  30091. func (m *UsageDetailMutation) Op() Op {
  30092. return m.op
  30093. }
  30094. // SetOp allows setting the mutation operation.
  30095. func (m *UsageDetailMutation) SetOp(op Op) {
  30096. m.op = op
  30097. }
  30098. // Type returns the node type of this mutation (UsageDetail).
  30099. func (m *UsageDetailMutation) Type() string {
  30100. return m.typ
  30101. }
  30102. // Fields returns all fields that were changed during this mutation. Note that in
  30103. // order to get all numeric fields that were incremented/decremented, call
  30104. // AddedFields().
  30105. func (m *UsageDetailMutation) Fields() []string {
  30106. fields := make([]string, 0, 15)
  30107. if m.created_at != nil {
  30108. fields = append(fields, usagedetail.FieldCreatedAt)
  30109. }
  30110. if m.updated_at != nil {
  30111. fields = append(fields, usagedetail.FieldUpdatedAt)
  30112. }
  30113. if m.status != nil {
  30114. fields = append(fields, usagedetail.FieldStatus)
  30115. }
  30116. if m._type != nil {
  30117. fields = append(fields, usagedetail.FieldType)
  30118. }
  30119. if m.bot_id != nil {
  30120. fields = append(fields, usagedetail.FieldBotID)
  30121. }
  30122. if m.receiver_id != nil {
  30123. fields = append(fields, usagedetail.FieldReceiverID)
  30124. }
  30125. if m.app != nil {
  30126. fields = append(fields, usagedetail.FieldApp)
  30127. }
  30128. if m.session_id != nil {
  30129. fields = append(fields, usagedetail.FieldSessionID)
  30130. }
  30131. if m.request != nil {
  30132. fields = append(fields, usagedetail.FieldRequest)
  30133. }
  30134. if m.response != nil {
  30135. fields = append(fields, usagedetail.FieldResponse)
  30136. }
  30137. if m.original_data != nil {
  30138. fields = append(fields, usagedetail.FieldOriginalData)
  30139. }
  30140. if m.total_tokens != nil {
  30141. fields = append(fields, usagedetail.FieldTotalTokens)
  30142. }
  30143. if m.prompt_tokens != nil {
  30144. fields = append(fields, usagedetail.FieldPromptTokens)
  30145. }
  30146. if m.completion_tokens != nil {
  30147. fields = append(fields, usagedetail.FieldCompletionTokens)
  30148. }
  30149. if m.organization_id != nil {
  30150. fields = append(fields, usagedetail.FieldOrganizationID)
  30151. }
  30152. return fields
  30153. }
  30154. // Field returns the value of a field with the given name. The second boolean
  30155. // return value indicates that this field was not set, or was not defined in the
  30156. // schema.
  30157. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  30158. switch name {
  30159. case usagedetail.FieldCreatedAt:
  30160. return m.CreatedAt()
  30161. case usagedetail.FieldUpdatedAt:
  30162. return m.UpdatedAt()
  30163. case usagedetail.FieldStatus:
  30164. return m.Status()
  30165. case usagedetail.FieldType:
  30166. return m.GetType()
  30167. case usagedetail.FieldBotID:
  30168. return m.BotID()
  30169. case usagedetail.FieldReceiverID:
  30170. return m.ReceiverID()
  30171. case usagedetail.FieldApp:
  30172. return m.App()
  30173. case usagedetail.FieldSessionID:
  30174. return m.SessionID()
  30175. case usagedetail.FieldRequest:
  30176. return m.Request()
  30177. case usagedetail.FieldResponse:
  30178. return m.Response()
  30179. case usagedetail.FieldOriginalData:
  30180. return m.OriginalData()
  30181. case usagedetail.FieldTotalTokens:
  30182. return m.TotalTokens()
  30183. case usagedetail.FieldPromptTokens:
  30184. return m.PromptTokens()
  30185. case usagedetail.FieldCompletionTokens:
  30186. return m.CompletionTokens()
  30187. case usagedetail.FieldOrganizationID:
  30188. return m.OrganizationID()
  30189. }
  30190. return nil, false
  30191. }
  30192. // OldField returns the old value of the field from the database. An error is
  30193. // returned if the mutation operation is not UpdateOne, or the query to the
  30194. // database failed.
  30195. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30196. switch name {
  30197. case usagedetail.FieldCreatedAt:
  30198. return m.OldCreatedAt(ctx)
  30199. case usagedetail.FieldUpdatedAt:
  30200. return m.OldUpdatedAt(ctx)
  30201. case usagedetail.FieldStatus:
  30202. return m.OldStatus(ctx)
  30203. case usagedetail.FieldType:
  30204. return m.OldType(ctx)
  30205. case usagedetail.FieldBotID:
  30206. return m.OldBotID(ctx)
  30207. case usagedetail.FieldReceiverID:
  30208. return m.OldReceiverID(ctx)
  30209. case usagedetail.FieldApp:
  30210. return m.OldApp(ctx)
  30211. case usagedetail.FieldSessionID:
  30212. return m.OldSessionID(ctx)
  30213. case usagedetail.FieldRequest:
  30214. return m.OldRequest(ctx)
  30215. case usagedetail.FieldResponse:
  30216. return m.OldResponse(ctx)
  30217. case usagedetail.FieldOriginalData:
  30218. return m.OldOriginalData(ctx)
  30219. case usagedetail.FieldTotalTokens:
  30220. return m.OldTotalTokens(ctx)
  30221. case usagedetail.FieldPromptTokens:
  30222. return m.OldPromptTokens(ctx)
  30223. case usagedetail.FieldCompletionTokens:
  30224. return m.OldCompletionTokens(ctx)
  30225. case usagedetail.FieldOrganizationID:
  30226. return m.OldOrganizationID(ctx)
  30227. }
  30228. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  30229. }
  30230. // SetField sets the value of a field with the given name. It returns an error if
  30231. // the field is not defined in the schema, or if the type mismatched the field
  30232. // type.
  30233. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  30234. switch name {
  30235. case usagedetail.FieldCreatedAt:
  30236. v, ok := value.(time.Time)
  30237. if !ok {
  30238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30239. }
  30240. m.SetCreatedAt(v)
  30241. return nil
  30242. case usagedetail.FieldUpdatedAt:
  30243. v, ok := value.(time.Time)
  30244. if !ok {
  30245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30246. }
  30247. m.SetUpdatedAt(v)
  30248. return nil
  30249. case usagedetail.FieldStatus:
  30250. v, ok := value.(uint8)
  30251. if !ok {
  30252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30253. }
  30254. m.SetStatus(v)
  30255. return nil
  30256. case usagedetail.FieldType:
  30257. v, ok := value.(int)
  30258. if !ok {
  30259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30260. }
  30261. m.SetType(v)
  30262. return nil
  30263. case usagedetail.FieldBotID:
  30264. v, ok := value.(string)
  30265. if !ok {
  30266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30267. }
  30268. m.SetBotID(v)
  30269. return nil
  30270. case usagedetail.FieldReceiverID:
  30271. v, ok := value.(string)
  30272. if !ok {
  30273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30274. }
  30275. m.SetReceiverID(v)
  30276. return nil
  30277. case usagedetail.FieldApp:
  30278. v, ok := value.(int)
  30279. if !ok {
  30280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30281. }
  30282. m.SetApp(v)
  30283. return nil
  30284. case usagedetail.FieldSessionID:
  30285. v, ok := value.(uint64)
  30286. if !ok {
  30287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30288. }
  30289. m.SetSessionID(v)
  30290. return nil
  30291. case usagedetail.FieldRequest:
  30292. v, ok := value.(string)
  30293. if !ok {
  30294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30295. }
  30296. m.SetRequest(v)
  30297. return nil
  30298. case usagedetail.FieldResponse:
  30299. v, ok := value.(string)
  30300. if !ok {
  30301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30302. }
  30303. m.SetResponse(v)
  30304. return nil
  30305. case usagedetail.FieldOriginalData:
  30306. v, ok := value.(custom_types.OriginalData)
  30307. if !ok {
  30308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30309. }
  30310. m.SetOriginalData(v)
  30311. return nil
  30312. case usagedetail.FieldTotalTokens:
  30313. v, ok := value.(uint64)
  30314. if !ok {
  30315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30316. }
  30317. m.SetTotalTokens(v)
  30318. return nil
  30319. case usagedetail.FieldPromptTokens:
  30320. v, ok := value.(uint64)
  30321. if !ok {
  30322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30323. }
  30324. m.SetPromptTokens(v)
  30325. return nil
  30326. case usagedetail.FieldCompletionTokens:
  30327. v, ok := value.(uint64)
  30328. if !ok {
  30329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30330. }
  30331. m.SetCompletionTokens(v)
  30332. return nil
  30333. case usagedetail.FieldOrganizationID:
  30334. v, ok := value.(uint64)
  30335. if !ok {
  30336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30337. }
  30338. m.SetOrganizationID(v)
  30339. return nil
  30340. }
  30341. return fmt.Errorf("unknown UsageDetail field %s", name)
  30342. }
  30343. // AddedFields returns all numeric fields that were incremented/decremented during
  30344. // this mutation.
  30345. func (m *UsageDetailMutation) AddedFields() []string {
  30346. var fields []string
  30347. if m.addstatus != nil {
  30348. fields = append(fields, usagedetail.FieldStatus)
  30349. }
  30350. if m.add_type != nil {
  30351. fields = append(fields, usagedetail.FieldType)
  30352. }
  30353. if m.addapp != nil {
  30354. fields = append(fields, usagedetail.FieldApp)
  30355. }
  30356. if m.addsession_id != nil {
  30357. fields = append(fields, usagedetail.FieldSessionID)
  30358. }
  30359. if m.addtotal_tokens != nil {
  30360. fields = append(fields, usagedetail.FieldTotalTokens)
  30361. }
  30362. if m.addprompt_tokens != nil {
  30363. fields = append(fields, usagedetail.FieldPromptTokens)
  30364. }
  30365. if m.addcompletion_tokens != nil {
  30366. fields = append(fields, usagedetail.FieldCompletionTokens)
  30367. }
  30368. if m.addorganization_id != nil {
  30369. fields = append(fields, usagedetail.FieldOrganizationID)
  30370. }
  30371. return fields
  30372. }
  30373. // AddedField returns the numeric value that was incremented/decremented on a field
  30374. // with the given name. The second boolean return value indicates that this field
  30375. // was not set, or was not defined in the schema.
  30376. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  30377. switch name {
  30378. case usagedetail.FieldStatus:
  30379. return m.AddedStatus()
  30380. case usagedetail.FieldType:
  30381. return m.AddedType()
  30382. case usagedetail.FieldApp:
  30383. return m.AddedApp()
  30384. case usagedetail.FieldSessionID:
  30385. return m.AddedSessionID()
  30386. case usagedetail.FieldTotalTokens:
  30387. return m.AddedTotalTokens()
  30388. case usagedetail.FieldPromptTokens:
  30389. return m.AddedPromptTokens()
  30390. case usagedetail.FieldCompletionTokens:
  30391. return m.AddedCompletionTokens()
  30392. case usagedetail.FieldOrganizationID:
  30393. return m.AddedOrganizationID()
  30394. }
  30395. return nil, false
  30396. }
  30397. // AddField adds the value to the field with the given name. It returns an error if
  30398. // the field is not defined in the schema, or if the type mismatched the field
  30399. // type.
  30400. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  30401. switch name {
  30402. case usagedetail.FieldStatus:
  30403. v, ok := value.(int8)
  30404. if !ok {
  30405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30406. }
  30407. m.AddStatus(v)
  30408. return nil
  30409. case usagedetail.FieldType:
  30410. v, ok := value.(int)
  30411. if !ok {
  30412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30413. }
  30414. m.AddType(v)
  30415. return nil
  30416. case usagedetail.FieldApp:
  30417. v, ok := value.(int)
  30418. if !ok {
  30419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30420. }
  30421. m.AddApp(v)
  30422. return nil
  30423. case usagedetail.FieldSessionID:
  30424. v, ok := value.(int64)
  30425. if !ok {
  30426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30427. }
  30428. m.AddSessionID(v)
  30429. return nil
  30430. case usagedetail.FieldTotalTokens:
  30431. v, ok := value.(int64)
  30432. if !ok {
  30433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30434. }
  30435. m.AddTotalTokens(v)
  30436. return nil
  30437. case usagedetail.FieldPromptTokens:
  30438. v, ok := value.(int64)
  30439. if !ok {
  30440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30441. }
  30442. m.AddPromptTokens(v)
  30443. return nil
  30444. case usagedetail.FieldCompletionTokens:
  30445. v, ok := value.(int64)
  30446. if !ok {
  30447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30448. }
  30449. m.AddCompletionTokens(v)
  30450. return nil
  30451. case usagedetail.FieldOrganizationID:
  30452. v, ok := value.(int64)
  30453. if !ok {
  30454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30455. }
  30456. m.AddOrganizationID(v)
  30457. return nil
  30458. }
  30459. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  30460. }
  30461. // ClearedFields returns all nullable fields that were cleared during this
  30462. // mutation.
  30463. func (m *UsageDetailMutation) ClearedFields() []string {
  30464. var fields []string
  30465. if m.FieldCleared(usagedetail.FieldStatus) {
  30466. fields = append(fields, usagedetail.FieldStatus)
  30467. }
  30468. if m.FieldCleared(usagedetail.FieldType) {
  30469. fields = append(fields, usagedetail.FieldType)
  30470. }
  30471. if m.FieldCleared(usagedetail.FieldApp) {
  30472. fields = append(fields, usagedetail.FieldApp)
  30473. }
  30474. if m.FieldCleared(usagedetail.FieldSessionID) {
  30475. fields = append(fields, usagedetail.FieldSessionID)
  30476. }
  30477. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  30478. fields = append(fields, usagedetail.FieldTotalTokens)
  30479. }
  30480. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  30481. fields = append(fields, usagedetail.FieldPromptTokens)
  30482. }
  30483. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  30484. fields = append(fields, usagedetail.FieldCompletionTokens)
  30485. }
  30486. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  30487. fields = append(fields, usagedetail.FieldOrganizationID)
  30488. }
  30489. return fields
  30490. }
  30491. // FieldCleared returns a boolean indicating if a field with the given name was
  30492. // cleared in this mutation.
  30493. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  30494. _, ok := m.clearedFields[name]
  30495. return ok
  30496. }
  30497. // ClearField clears the value of the field with the given name. It returns an
  30498. // error if the field is not defined in the schema.
  30499. func (m *UsageDetailMutation) ClearField(name string) error {
  30500. switch name {
  30501. case usagedetail.FieldStatus:
  30502. m.ClearStatus()
  30503. return nil
  30504. case usagedetail.FieldType:
  30505. m.ClearType()
  30506. return nil
  30507. case usagedetail.FieldApp:
  30508. m.ClearApp()
  30509. return nil
  30510. case usagedetail.FieldSessionID:
  30511. m.ClearSessionID()
  30512. return nil
  30513. case usagedetail.FieldTotalTokens:
  30514. m.ClearTotalTokens()
  30515. return nil
  30516. case usagedetail.FieldPromptTokens:
  30517. m.ClearPromptTokens()
  30518. return nil
  30519. case usagedetail.FieldCompletionTokens:
  30520. m.ClearCompletionTokens()
  30521. return nil
  30522. case usagedetail.FieldOrganizationID:
  30523. m.ClearOrganizationID()
  30524. return nil
  30525. }
  30526. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  30527. }
  30528. // ResetField resets all changes in the mutation for the field with the given name.
  30529. // It returns an error if the field is not defined in the schema.
  30530. func (m *UsageDetailMutation) ResetField(name string) error {
  30531. switch name {
  30532. case usagedetail.FieldCreatedAt:
  30533. m.ResetCreatedAt()
  30534. return nil
  30535. case usagedetail.FieldUpdatedAt:
  30536. m.ResetUpdatedAt()
  30537. return nil
  30538. case usagedetail.FieldStatus:
  30539. m.ResetStatus()
  30540. return nil
  30541. case usagedetail.FieldType:
  30542. m.ResetType()
  30543. return nil
  30544. case usagedetail.FieldBotID:
  30545. m.ResetBotID()
  30546. return nil
  30547. case usagedetail.FieldReceiverID:
  30548. m.ResetReceiverID()
  30549. return nil
  30550. case usagedetail.FieldApp:
  30551. m.ResetApp()
  30552. return nil
  30553. case usagedetail.FieldSessionID:
  30554. m.ResetSessionID()
  30555. return nil
  30556. case usagedetail.FieldRequest:
  30557. m.ResetRequest()
  30558. return nil
  30559. case usagedetail.FieldResponse:
  30560. m.ResetResponse()
  30561. return nil
  30562. case usagedetail.FieldOriginalData:
  30563. m.ResetOriginalData()
  30564. return nil
  30565. case usagedetail.FieldTotalTokens:
  30566. m.ResetTotalTokens()
  30567. return nil
  30568. case usagedetail.FieldPromptTokens:
  30569. m.ResetPromptTokens()
  30570. return nil
  30571. case usagedetail.FieldCompletionTokens:
  30572. m.ResetCompletionTokens()
  30573. return nil
  30574. case usagedetail.FieldOrganizationID:
  30575. m.ResetOrganizationID()
  30576. return nil
  30577. }
  30578. return fmt.Errorf("unknown UsageDetail field %s", name)
  30579. }
  30580. // AddedEdges returns all edge names that were set/added in this mutation.
  30581. func (m *UsageDetailMutation) AddedEdges() []string {
  30582. edges := make([]string, 0, 0)
  30583. return edges
  30584. }
  30585. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30586. // name in this mutation.
  30587. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  30588. return nil
  30589. }
  30590. // RemovedEdges returns all edge names that were removed in this mutation.
  30591. func (m *UsageDetailMutation) RemovedEdges() []string {
  30592. edges := make([]string, 0, 0)
  30593. return edges
  30594. }
  30595. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30596. // the given name in this mutation.
  30597. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  30598. return nil
  30599. }
  30600. // ClearedEdges returns all edge names that were cleared in this mutation.
  30601. func (m *UsageDetailMutation) ClearedEdges() []string {
  30602. edges := make([]string, 0, 0)
  30603. return edges
  30604. }
  30605. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30606. // was cleared in this mutation.
  30607. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  30608. return false
  30609. }
  30610. // ClearEdge clears the value of the edge with the given name. It returns an error
  30611. // if that edge is not defined in the schema.
  30612. func (m *UsageDetailMutation) ClearEdge(name string) error {
  30613. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  30614. }
  30615. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30616. // It returns an error if the edge is not defined in the schema.
  30617. func (m *UsageDetailMutation) ResetEdge(name string) error {
  30618. return fmt.Errorf("unknown UsageDetail edge %s", name)
  30619. }
  30620. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  30621. type UsageStatisticDayMutation struct {
  30622. config
  30623. op Op
  30624. typ string
  30625. id *uint64
  30626. created_at *time.Time
  30627. updated_at *time.Time
  30628. status *uint8
  30629. addstatus *int8
  30630. deleted_at *time.Time
  30631. addtime *uint64
  30632. addaddtime *int64
  30633. _type *int
  30634. add_type *int
  30635. bot_id *string
  30636. organization_id *uint64
  30637. addorganization_id *int64
  30638. ai_response *uint64
  30639. addai_response *int64
  30640. sop_run *uint64
  30641. addsop_run *int64
  30642. total_friend *uint64
  30643. addtotal_friend *int64
  30644. total_group *uint64
  30645. addtotal_group *int64
  30646. account_balance *uint64
  30647. addaccount_balance *int64
  30648. consume_token *uint64
  30649. addconsume_token *int64
  30650. active_user *uint64
  30651. addactive_user *int64
  30652. new_user *int64
  30653. addnew_user *int64
  30654. label_dist *[]custom_types.LabelDist
  30655. appendlabel_dist []custom_types.LabelDist
  30656. clearedFields map[string]struct{}
  30657. done bool
  30658. oldValue func(context.Context) (*UsageStatisticDay, error)
  30659. predicates []predicate.UsageStatisticDay
  30660. }
  30661. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  30662. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  30663. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  30664. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  30665. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  30666. m := &UsageStatisticDayMutation{
  30667. config: c,
  30668. op: op,
  30669. typ: TypeUsageStatisticDay,
  30670. clearedFields: make(map[string]struct{}),
  30671. }
  30672. for _, opt := range opts {
  30673. opt(m)
  30674. }
  30675. return m
  30676. }
  30677. // withUsageStatisticDayID sets the ID field of the mutation.
  30678. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  30679. return func(m *UsageStatisticDayMutation) {
  30680. var (
  30681. err error
  30682. once sync.Once
  30683. value *UsageStatisticDay
  30684. )
  30685. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  30686. once.Do(func() {
  30687. if m.done {
  30688. err = errors.New("querying old values post mutation is not allowed")
  30689. } else {
  30690. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  30691. }
  30692. })
  30693. return value, err
  30694. }
  30695. m.id = &id
  30696. }
  30697. }
  30698. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  30699. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  30700. return func(m *UsageStatisticDayMutation) {
  30701. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  30702. return node, nil
  30703. }
  30704. m.id = &node.ID
  30705. }
  30706. }
  30707. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30708. // executed in a transaction (ent.Tx), a transactional client is returned.
  30709. func (m UsageStatisticDayMutation) Client() *Client {
  30710. client := &Client{config: m.config}
  30711. client.init()
  30712. return client
  30713. }
  30714. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30715. // it returns an error otherwise.
  30716. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  30717. if _, ok := m.driver.(*txDriver); !ok {
  30718. return nil, errors.New("ent: mutation is not running in a transaction")
  30719. }
  30720. tx := &Tx{config: m.config}
  30721. tx.init()
  30722. return tx, nil
  30723. }
  30724. // SetID sets the value of the id field. Note that this
  30725. // operation is only accepted on creation of UsageStatisticDay entities.
  30726. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  30727. m.id = &id
  30728. }
  30729. // ID returns the ID value in the mutation. Note that the ID is only available
  30730. // if it was provided to the builder or after it was returned from the database.
  30731. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  30732. if m.id == nil {
  30733. return
  30734. }
  30735. return *m.id, true
  30736. }
  30737. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30738. // That means, if the mutation is applied within a transaction with an isolation level such
  30739. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30740. // or updated by the mutation.
  30741. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  30742. switch {
  30743. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30744. id, exists := m.ID()
  30745. if exists {
  30746. return []uint64{id}, nil
  30747. }
  30748. fallthrough
  30749. case m.op.Is(OpUpdate | OpDelete):
  30750. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  30751. default:
  30752. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30753. }
  30754. }
  30755. // SetCreatedAt sets the "created_at" field.
  30756. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  30757. m.created_at = &t
  30758. }
  30759. // CreatedAt returns the value of the "created_at" field in the mutation.
  30760. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  30761. v := m.created_at
  30762. if v == nil {
  30763. return
  30764. }
  30765. return *v, true
  30766. }
  30767. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  30768. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30770. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30771. if !m.op.Is(OpUpdateOne) {
  30772. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30773. }
  30774. if m.id == nil || m.oldValue == nil {
  30775. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30776. }
  30777. oldValue, err := m.oldValue(ctx)
  30778. if err != nil {
  30779. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30780. }
  30781. return oldValue.CreatedAt, nil
  30782. }
  30783. // ResetCreatedAt resets all changes to the "created_at" field.
  30784. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  30785. m.created_at = nil
  30786. }
  30787. // SetUpdatedAt sets the "updated_at" field.
  30788. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  30789. m.updated_at = &t
  30790. }
  30791. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30792. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  30793. v := m.updated_at
  30794. if v == nil {
  30795. return
  30796. }
  30797. return *v, true
  30798. }
  30799. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  30800. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30802. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30803. if !m.op.Is(OpUpdateOne) {
  30804. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30805. }
  30806. if m.id == nil || m.oldValue == nil {
  30807. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30808. }
  30809. oldValue, err := m.oldValue(ctx)
  30810. if err != nil {
  30811. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30812. }
  30813. return oldValue.UpdatedAt, nil
  30814. }
  30815. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30816. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  30817. m.updated_at = nil
  30818. }
  30819. // SetStatus sets the "status" field.
  30820. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  30821. m.status = &u
  30822. m.addstatus = nil
  30823. }
  30824. // Status returns the value of the "status" field in the mutation.
  30825. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  30826. v := m.status
  30827. if v == nil {
  30828. return
  30829. }
  30830. return *v, true
  30831. }
  30832. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  30833. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30835. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30836. if !m.op.Is(OpUpdateOne) {
  30837. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30838. }
  30839. if m.id == nil || m.oldValue == nil {
  30840. return v, errors.New("OldStatus requires an ID field in the mutation")
  30841. }
  30842. oldValue, err := m.oldValue(ctx)
  30843. if err != nil {
  30844. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30845. }
  30846. return oldValue.Status, nil
  30847. }
  30848. // AddStatus adds u to the "status" field.
  30849. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  30850. if m.addstatus != nil {
  30851. *m.addstatus += u
  30852. } else {
  30853. m.addstatus = &u
  30854. }
  30855. }
  30856. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30857. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  30858. v := m.addstatus
  30859. if v == nil {
  30860. return
  30861. }
  30862. return *v, true
  30863. }
  30864. // ClearStatus clears the value of the "status" field.
  30865. func (m *UsageStatisticDayMutation) ClearStatus() {
  30866. m.status = nil
  30867. m.addstatus = nil
  30868. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  30869. }
  30870. // StatusCleared returns if the "status" field was cleared in this mutation.
  30871. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  30872. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  30873. return ok
  30874. }
  30875. // ResetStatus resets all changes to the "status" field.
  30876. func (m *UsageStatisticDayMutation) ResetStatus() {
  30877. m.status = nil
  30878. m.addstatus = nil
  30879. delete(m.clearedFields, usagestatisticday.FieldStatus)
  30880. }
  30881. // SetDeletedAt sets the "deleted_at" field.
  30882. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  30883. m.deleted_at = &t
  30884. }
  30885. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30886. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  30887. v := m.deleted_at
  30888. if v == nil {
  30889. return
  30890. }
  30891. return *v, true
  30892. }
  30893. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  30894. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30896. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30897. if !m.op.Is(OpUpdateOne) {
  30898. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30899. }
  30900. if m.id == nil || m.oldValue == nil {
  30901. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30902. }
  30903. oldValue, err := m.oldValue(ctx)
  30904. if err != nil {
  30905. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30906. }
  30907. return oldValue.DeletedAt, nil
  30908. }
  30909. // ClearDeletedAt clears the value of the "deleted_at" field.
  30910. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  30911. m.deleted_at = nil
  30912. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  30913. }
  30914. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30915. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  30916. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  30917. return ok
  30918. }
  30919. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30920. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  30921. m.deleted_at = nil
  30922. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  30923. }
  30924. // SetAddtime sets the "addtime" field.
  30925. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  30926. m.addtime = &u
  30927. m.addaddtime = nil
  30928. }
  30929. // Addtime returns the value of the "addtime" field in the mutation.
  30930. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  30931. v := m.addtime
  30932. if v == nil {
  30933. return
  30934. }
  30935. return *v, true
  30936. }
  30937. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  30938. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30940. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  30941. if !m.op.Is(OpUpdateOne) {
  30942. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  30943. }
  30944. if m.id == nil || m.oldValue == nil {
  30945. return v, errors.New("OldAddtime requires an ID field in the mutation")
  30946. }
  30947. oldValue, err := m.oldValue(ctx)
  30948. if err != nil {
  30949. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  30950. }
  30951. return oldValue.Addtime, nil
  30952. }
  30953. // AddAddtime adds u to the "addtime" field.
  30954. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  30955. if m.addaddtime != nil {
  30956. *m.addaddtime += u
  30957. } else {
  30958. m.addaddtime = &u
  30959. }
  30960. }
  30961. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  30962. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  30963. v := m.addaddtime
  30964. if v == nil {
  30965. return
  30966. }
  30967. return *v, true
  30968. }
  30969. // ResetAddtime resets all changes to the "addtime" field.
  30970. func (m *UsageStatisticDayMutation) ResetAddtime() {
  30971. m.addtime = nil
  30972. m.addaddtime = nil
  30973. }
  30974. // SetType sets the "type" field.
  30975. func (m *UsageStatisticDayMutation) SetType(i int) {
  30976. m._type = &i
  30977. m.add_type = nil
  30978. }
  30979. // GetType returns the value of the "type" field in the mutation.
  30980. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  30981. v := m._type
  30982. if v == nil {
  30983. return
  30984. }
  30985. return *v, true
  30986. }
  30987. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  30988. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30990. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  30991. if !m.op.Is(OpUpdateOne) {
  30992. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30993. }
  30994. if m.id == nil || m.oldValue == nil {
  30995. return v, errors.New("OldType requires an ID field in the mutation")
  30996. }
  30997. oldValue, err := m.oldValue(ctx)
  30998. if err != nil {
  30999. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31000. }
  31001. return oldValue.Type, nil
  31002. }
  31003. // AddType adds i to the "type" field.
  31004. func (m *UsageStatisticDayMutation) AddType(i int) {
  31005. if m.add_type != nil {
  31006. *m.add_type += i
  31007. } else {
  31008. m.add_type = &i
  31009. }
  31010. }
  31011. // AddedType returns the value that was added to the "type" field in this mutation.
  31012. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  31013. v := m.add_type
  31014. if v == nil {
  31015. return
  31016. }
  31017. return *v, true
  31018. }
  31019. // ResetType resets all changes to the "type" field.
  31020. func (m *UsageStatisticDayMutation) ResetType() {
  31021. m._type = nil
  31022. m.add_type = nil
  31023. }
  31024. // SetBotID sets the "bot_id" field.
  31025. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  31026. m.bot_id = &s
  31027. }
  31028. // BotID returns the value of the "bot_id" field in the mutation.
  31029. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  31030. v := m.bot_id
  31031. if v == nil {
  31032. return
  31033. }
  31034. return *v, true
  31035. }
  31036. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  31037. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31039. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  31040. if !m.op.Is(OpUpdateOne) {
  31041. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31042. }
  31043. if m.id == nil || m.oldValue == nil {
  31044. return v, errors.New("OldBotID requires an ID field in the mutation")
  31045. }
  31046. oldValue, err := m.oldValue(ctx)
  31047. if err != nil {
  31048. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31049. }
  31050. return oldValue.BotID, nil
  31051. }
  31052. // ClearBotID clears the value of the "bot_id" field.
  31053. func (m *UsageStatisticDayMutation) ClearBotID() {
  31054. m.bot_id = nil
  31055. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  31056. }
  31057. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31058. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  31059. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  31060. return ok
  31061. }
  31062. // ResetBotID resets all changes to the "bot_id" field.
  31063. func (m *UsageStatisticDayMutation) ResetBotID() {
  31064. m.bot_id = nil
  31065. delete(m.clearedFields, usagestatisticday.FieldBotID)
  31066. }
  31067. // SetOrganizationID sets the "organization_id" field.
  31068. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  31069. m.organization_id = &u
  31070. m.addorganization_id = nil
  31071. }
  31072. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31073. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  31074. v := m.organization_id
  31075. if v == nil {
  31076. return
  31077. }
  31078. return *v, true
  31079. }
  31080. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  31081. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31083. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31084. if !m.op.Is(OpUpdateOne) {
  31085. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31086. }
  31087. if m.id == nil || m.oldValue == nil {
  31088. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31089. }
  31090. oldValue, err := m.oldValue(ctx)
  31091. if err != nil {
  31092. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31093. }
  31094. return oldValue.OrganizationID, nil
  31095. }
  31096. // AddOrganizationID adds u to the "organization_id" field.
  31097. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  31098. if m.addorganization_id != nil {
  31099. *m.addorganization_id += u
  31100. } else {
  31101. m.addorganization_id = &u
  31102. }
  31103. }
  31104. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31105. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  31106. v := m.addorganization_id
  31107. if v == nil {
  31108. return
  31109. }
  31110. return *v, true
  31111. }
  31112. // ClearOrganizationID clears the value of the "organization_id" field.
  31113. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  31114. m.organization_id = nil
  31115. m.addorganization_id = nil
  31116. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  31117. }
  31118. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31119. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  31120. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  31121. return ok
  31122. }
  31123. // ResetOrganizationID resets all changes to the "organization_id" field.
  31124. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  31125. m.organization_id = nil
  31126. m.addorganization_id = nil
  31127. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  31128. }
  31129. // SetAiResponse sets the "ai_response" field.
  31130. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  31131. m.ai_response = &u
  31132. m.addai_response = nil
  31133. }
  31134. // AiResponse returns the value of the "ai_response" field in the mutation.
  31135. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  31136. v := m.ai_response
  31137. if v == nil {
  31138. return
  31139. }
  31140. return *v, true
  31141. }
  31142. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  31143. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31145. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31146. if !m.op.Is(OpUpdateOne) {
  31147. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31148. }
  31149. if m.id == nil || m.oldValue == nil {
  31150. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31151. }
  31152. oldValue, err := m.oldValue(ctx)
  31153. if err != nil {
  31154. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31155. }
  31156. return oldValue.AiResponse, nil
  31157. }
  31158. // AddAiResponse adds u to the "ai_response" field.
  31159. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  31160. if m.addai_response != nil {
  31161. *m.addai_response += u
  31162. } else {
  31163. m.addai_response = &u
  31164. }
  31165. }
  31166. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31167. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  31168. v := m.addai_response
  31169. if v == nil {
  31170. return
  31171. }
  31172. return *v, true
  31173. }
  31174. // ResetAiResponse resets all changes to the "ai_response" field.
  31175. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  31176. m.ai_response = nil
  31177. m.addai_response = nil
  31178. }
  31179. // SetSopRun sets the "sop_run" field.
  31180. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  31181. m.sop_run = &u
  31182. m.addsop_run = nil
  31183. }
  31184. // SopRun returns the value of the "sop_run" field in the mutation.
  31185. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  31186. v := m.sop_run
  31187. if v == nil {
  31188. return
  31189. }
  31190. return *v, true
  31191. }
  31192. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  31193. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31195. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31196. if !m.op.Is(OpUpdateOne) {
  31197. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31198. }
  31199. if m.id == nil || m.oldValue == nil {
  31200. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31201. }
  31202. oldValue, err := m.oldValue(ctx)
  31203. if err != nil {
  31204. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31205. }
  31206. return oldValue.SopRun, nil
  31207. }
  31208. // AddSopRun adds u to the "sop_run" field.
  31209. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  31210. if m.addsop_run != nil {
  31211. *m.addsop_run += u
  31212. } else {
  31213. m.addsop_run = &u
  31214. }
  31215. }
  31216. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31217. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  31218. v := m.addsop_run
  31219. if v == nil {
  31220. return
  31221. }
  31222. return *v, true
  31223. }
  31224. // ResetSopRun resets all changes to the "sop_run" field.
  31225. func (m *UsageStatisticDayMutation) ResetSopRun() {
  31226. m.sop_run = nil
  31227. m.addsop_run = nil
  31228. }
  31229. // SetTotalFriend sets the "total_friend" field.
  31230. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  31231. m.total_friend = &u
  31232. m.addtotal_friend = nil
  31233. }
  31234. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31235. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  31236. v := m.total_friend
  31237. if v == nil {
  31238. return
  31239. }
  31240. return *v, true
  31241. }
  31242. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  31243. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31245. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31246. if !m.op.Is(OpUpdateOne) {
  31247. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31248. }
  31249. if m.id == nil || m.oldValue == nil {
  31250. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31251. }
  31252. oldValue, err := m.oldValue(ctx)
  31253. if err != nil {
  31254. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31255. }
  31256. return oldValue.TotalFriend, nil
  31257. }
  31258. // AddTotalFriend adds u to the "total_friend" field.
  31259. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  31260. if m.addtotal_friend != nil {
  31261. *m.addtotal_friend += u
  31262. } else {
  31263. m.addtotal_friend = &u
  31264. }
  31265. }
  31266. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31267. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  31268. v := m.addtotal_friend
  31269. if v == nil {
  31270. return
  31271. }
  31272. return *v, true
  31273. }
  31274. // ResetTotalFriend resets all changes to the "total_friend" field.
  31275. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  31276. m.total_friend = nil
  31277. m.addtotal_friend = nil
  31278. }
  31279. // SetTotalGroup sets the "total_group" field.
  31280. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  31281. m.total_group = &u
  31282. m.addtotal_group = nil
  31283. }
  31284. // TotalGroup returns the value of the "total_group" field in the mutation.
  31285. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  31286. v := m.total_group
  31287. if v == nil {
  31288. return
  31289. }
  31290. return *v, true
  31291. }
  31292. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  31293. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31295. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31296. if !m.op.Is(OpUpdateOne) {
  31297. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31298. }
  31299. if m.id == nil || m.oldValue == nil {
  31300. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31301. }
  31302. oldValue, err := m.oldValue(ctx)
  31303. if err != nil {
  31304. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31305. }
  31306. return oldValue.TotalGroup, nil
  31307. }
  31308. // AddTotalGroup adds u to the "total_group" field.
  31309. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  31310. if m.addtotal_group != nil {
  31311. *m.addtotal_group += u
  31312. } else {
  31313. m.addtotal_group = &u
  31314. }
  31315. }
  31316. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31317. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  31318. v := m.addtotal_group
  31319. if v == nil {
  31320. return
  31321. }
  31322. return *v, true
  31323. }
  31324. // ResetTotalGroup resets all changes to the "total_group" field.
  31325. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  31326. m.total_group = nil
  31327. m.addtotal_group = nil
  31328. }
  31329. // SetAccountBalance sets the "account_balance" field.
  31330. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  31331. m.account_balance = &u
  31332. m.addaccount_balance = nil
  31333. }
  31334. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31335. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  31336. v := m.account_balance
  31337. if v == nil {
  31338. return
  31339. }
  31340. return *v, true
  31341. }
  31342. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  31343. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31345. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31346. if !m.op.Is(OpUpdateOne) {
  31347. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31348. }
  31349. if m.id == nil || m.oldValue == nil {
  31350. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31351. }
  31352. oldValue, err := m.oldValue(ctx)
  31353. if err != nil {
  31354. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31355. }
  31356. return oldValue.AccountBalance, nil
  31357. }
  31358. // AddAccountBalance adds u to the "account_balance" field.
  31359. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  31360. if m.addaccount_balance != nil {
  31361. *m.addaccount_balance += u
  31362. } else {
  31363. m.addaccount_balance = &u
  31364. }
  31365. }
  31366. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31367. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  31368. v := m.addaccount_balance
  31369. if v == nil {
  31370. return
  31371. }
  31372. return *v, true
  31373. }
  31374. // ResetAccountBalance resets all changes to the "account_balance" field.
  31375. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  31376. m.account_balance = nil
  31377. m.addaccount_balance = nil
  31378. }
  31379. // SetConsumeToken sets the "consume_token" field.
  31380. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  31381. m.consume_token = &u
  31382. m.addconsume_token = nil
  31383. }
  31384. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31385. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  31386. v := m.consume_token
  31387. if v == nil {
  31388. return
  31389. }
  31390. return *v, true
  31391. }
  31392. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  31393. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31395. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31396. if !m.op.Is(OpUpdateOne) {
  31397. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31398. }
  31399. if m.id == nil || m.oldValue == nil {
  31400. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31401. }
  31402. oldValue, err := m.oldValue(ctx)
  31403. if err != nil {
  31404. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31405. }
  31406. return oldValue.ConsumeToken, nil
  31407. }
  31408. // AddConsumeToken adds u to the "consume_token" field.
  31409. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  31410. if m.addconsume_token != nil {
  31411. *m.addconsume_token += u
  31412. } else {
  31413. m.addconsume_token = &u
  31414. }
  31415. }
  31416. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31417. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  31418. v := m.addconsume_token
  31419. if v == nil {
  31420. return
  31421. }
  31422. return *v, true
  31423. }
  31424. // ResetConsumeToken resets all changes to the "consume_token" field.
  31425. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  31426. m.consume_token = nil
  31427. m.addconsume_token = nil
  31428. }
  31429. // SetActiveUser sets the "active_user" field.
  31430. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  31431. m.active_user = &u
  31432. m.addactive_user = nil
  31433. }
  31434. // ActiveUser returns the value of the "active_user" field in the mutation.
  31435. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  31436. v := m.active_user
  31437. if v == nil {
  31438. return
  31439. }
  31440. return *v, true
  31441. }
  31442. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  31443. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31445. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31446. if !m.op.Is(OpUpdateOne) {
  31447. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31448. }
  31449. if m.id == nil || m.oldValue == nil {
  31450. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31451. }
  31452. oldValue, err := m.oldValue(ctx)
  31453. if err != nil {
  31454. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31455. }
  31456. return oldValue.ActiveUser, nil
  31457. }
  31458. // AddActiveUser adds u to the "active_user" field.
  31459. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  31460. if m.addactive_user != nil {
  31461. *m.addactive_user += u
  31462. } else {
  31463. m.addactive_user = &u
  31464. }
  31465. }
  31466. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31467. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  31468. v := m.addactive_user
  31469. if v == nil {
  31470. return
  31471. }
  31472. return *v, true
  31473. }
  31474. // ResetActiveUser resets all changes to the "active_user" field.
  31475. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  31476. m.active_user = nil
  31477. m.addactive_user = nil
  31478. }
  31479. // SetNewUser sets the "new_user" field.
  31480. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  31481. m.new_user = &i
  31482. m.addnew_user = nil
  31483. }
  31484. // NewUser returns the value of the "new_user" field in the mutation.
  31485. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  31486. v := m.new_user
  31487. if v == nil {
  31488. return
  31489. }
  31490. return *v, true
  31491. }
  31492. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  31493. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31495. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31496. if !m.op.Is(OpUpdateOne) {
  31497. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31498. }
  31499. if m.id == nil || m.oldValue == nil {
  31500. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31501. }
  31502. oldValue, err := m.oldValue(ctx)
  31503. if err != nil {
  31504. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31505. }
  31506. return oldValue.NewUser, nil
  31507. }
  31508. // AddNewUser adds i to the "new_user" field.
  31509. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  31510. if m.addnew_user != nil {
  31511. *m.addnew_user += i
  31512. } else {
  31513. m.addnew_user = &i
  31514. }
  31515. }
  31516. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31517. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  31518. v := m.addnew_user
  31519. if v == nil {
  31520. return
  31521. }
  31522. return *v, true
  31523. }
  31524. // ResetNewUser resets all changes to the "new_user" field.
  31525. func (m *UsageStatisticDayMutation) ResetNewUser() {
  31526. m.new_user = nil
  31527. m.addnew_user = nil
  31528. }
  31529. // SetLabelDist sets the "label_dist" field.
  31530. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31531. m.label_dist = &ctd
  31532. m.appendlabel_dist = nil
  31533. }
  31534. // LabelDist returns the value of the "label_dist" field in the mutation.
  31535. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31536. v := m.label_dist
  31537. if v == nil {
  31538. return
  31539. }
  31540. return *v, true
  31541. }
  31542. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  31543. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31545. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31546. if !m.op.Is(OpUpdateOne) {
  31547. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31548. }
  31549. if m.id == nil || m.oldValue == nil {
  31550. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31551. }
  31552. oldValue, err := m.oldValue(ctx)
  31553. if err != nil {
  31554. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31555. }
  31556. return oldValue.LabelDist, nil
  31557. }
  31558. // AppendLabelDist adds ctd to the "label_dist" field.
  31559. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31560. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31561. }
  31562. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31563. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31564. if len(m.appendlabel_dist) == 0 {
  31565. return nil, false
  31566. }
  31567. return m.appendlabel_dist, true
  31568. }
  31569. // ResetLabelDist resets all changes to the "label_dist" field.
  31570. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  31571. m.label_dist = nil
  31572. m.appendlabel_dist = nil
  31573. }
  31574. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  31575. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  31576. m.predicates = append(m.predicates, ps...)
  31577. }
  31578. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  31579. // users can use type-assertion to append predicates that do not depend on any generated package.
  31580. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  31581. p := make([]predicate.UsageStatisticDay, len(ps))
  31582. for i := range ps {
  31583. p[i] = ps[i]
  31584. }
  31585. m.Where(p...)
  31586. }
  31587. // Op returns the operation name.
  31588. func (m *UsageStatisticDayMutation) Op() Op {
  31589. return m.op
  31590. }
  31591. // SetOp allows setting the mutation operation.
  31592. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  31593. m.op = op
  31594. }
  31595. // Type returns the node type of this mutation (UsageStatisticDay).
  31596. func (m *UsageStatisticDayMutation) Type() string {
  31597. return m.typ
  31598. }
  31599. // Fields returns all fields that were changed during this mutation. Note that in
  31600. // order to get all numeric fields that were incremented/decremented, call
  31601. // AddedFields().
  31602. func (m *UsageStatisticDayMutation) Fields() []string {
  31603. fields := make([]string, 0, 17)
  31604. if m.created_at != nil {
  31605. fields = append(fields, usagestatisticday.FieldCreatedAt)
  31606. }
  31607. if m.updated_at != nil {
  31608. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  31609. }
  31610. if m.status != nil {
  31611. fields = append(fields, usagestatisticday.FieldStatus)
  31612. }
  31613. if m.deleted_at != nil {
  31614. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31615. }
  31616. if m.addtime != nil {
  31617. fields = append(fields, usagestatisticday.FieldAddtime)
  31618. }
  31619. if m._type != nil {
  31620. fields = append(fields, usagestatisticday.FieldType)
  31621. }
  31622. if m.bot_id != nil {
  31623. fields = append(fields, usagestatisticday.FieldBotID)
  31624. }
  31625. if m.organization_id != nil {
  31626. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31627. }
  31628. if m.ai_response != nil {
  31629. fields = append(fields, usagestatisticday.FieldAiResponse)
  31630. }
  31631. if m.sop_run != nil {
  31632. fields = append(fields, usagestatisticday.FieldSopRun)
  31633. }
  31634. if m.total_friend != nil {
  31635. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31636. }
  31637. if m.total_group != nil {
  31638. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31639. }
  31640. if m.account_balance != nil {
  31641. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31642. }
  31643. if m.consume_token != nil {
  31644. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31645. }
  31646. if m.active_user != nil {
  31647. fields = append(fields, usagestatisticday.FieldActiveUser)
  31648. }
  31649. if m.new_user != nil {
  31650. fields = append(fields, usagestatisticday.FieldNewUser)
  31651. }
  31652. if m.label_dist != nil {
  31653. fields = append(fields, usagestatisticday.FieldLabelDist)
  31654. }
  31655. return fields
  31656. }
  31657. // Field returns the value of a field with the given name. The second boolean
  31658. // return value indicates that this field was not set, or was not defined in the
  31659. // schema.
  31660. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  31661. switch name {
  31662. case usagestatisticday.FieldCreatedAt:
  31663. return m.CreatedAt()
  31664. case usagestatisticday.FieldUpdatedAt:
  31665. return m.UpdatedAt()
  31666. case usagestatisticday.FieldStatus:
  31667. return m.Status()
  31668. case usagestatisticday.FieldDeletedAt:
  31669. return m.DeletedAt()
  31670. case usagestatisticday.FieldAddtime:
  31671. return m.Addtime()
  31672. case usagestatisticday.FieldType:
  31673. return m.GetType()
  31674. case usagestatisticday.FieldBotID:
  31675. return m.BotID()
  31676. case usagestatisticday.FieldOrganizationID:
  31677. return m.OrganizationID()
  31678. case usagestatisticday.FieldAiResponse:
  31679. return m.AiResponse()
  31680. case usagestatisticday.FieldSopRun:
  31681. return m.SopRun()
  31682. case usagestatisticday.FieldTotalFriend:
  31683. return m.TotalFriend()
  31684. case usagestatisticday.FieldTotalGroup:
  31685. return m.TotalGroup()
  31686. case usagestatisticday.FieldAccountBalance:
  31687. return m.AccountBalance()
  31688. case usagestatisticday.FieldConsumeToken:
  31689. return m.ConsumeToken()
  31690. case usagestatisticday.FieldActiveUser:
  31691. return m.ActiveUser()
  31692. case usagestatisticday.FieldNewUser:
  31693. return m.NewUser()
  31694. case usagestatisticday.FieldLabelDist:
  31695. return m.LabelDist()
  31696. }
  31697. return nil, false
  31698. }
  31699. // OldField returns the old value of the field from the database. An error is
  31700. // returned if the mutation operation is not UpdateOne, or the query to the
  31701. // database failed.
  31702. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31703. switch name {
  31704. case usagestatisticday.FieldCreatedAt:
  31705. return m.OldCreatedAt(ctx)
  31706. case usagestatisticday.FieldUpdatedAt:
  31707. return m.OldUpdatedAt(ctx)
  31708. case usagestatisticday.FieldStatus:
  31709. return m.OldStatus(ctx)
  31710. case usagestatisticday.FieldDeletedAt:
  31711. return m.OldDeletedAt(ctx)
  31712. case usagestatisticday.FieldAddtime:
  31713. return m.OldAddtime(ctx)
  31714. case usagestatisticday.FieldType:
  31715. return m.OldType(ctx)
  31716. case usagestatisticday.FieldBotID:
  31717. return m.OldBotID(ctx)
  31718. case usagestatisticday.FieldOrganizationID:
  31719. return m.OldOrganizationID(ctx)
  31720. case usagestatisticday.FieldAiResponse:
  31721. return m.OldAiResponse(ctx)
  31722. case usagestatisticday.FieldSopRun:
  31723. return m.OldSopRun(ctx)
  31724. case usagestatisticday.FieldTotalFriend:
  31725. return m.OldTotalFriend(ctx)
  31726. case usagestatisticday.FieldTotalGroup:
  31727. return m.OldTotalGroup(ctx)
  31728. case usagestatisticday.FieldAccountBalance:
  31729. return m.OldAccountBalance(ctx)
  31730. case usagestatisticday.FieldConsumeToken:
  31731. return m.OldConsumeToken(ctx)
  31732. case usagestatisticday.FieldActiveUser:
  31733. return m.OldActiveUser(ctx)
  31734. case usagestatisticday.FieldNewUser:
  31735. return m.OldNewUser(ctx)
  31736. case usagestatisticday.FieldLabelDist:
  31737. return m.OldLabelDist(ctx)
  31738. }
  31739. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31740. }
  31741. // SetField sets the value of a field with the given name. It returns an error if
  31742. // the field is not defined in the schema, or if the type mismatched the field
  31743. // type.
  31744. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  31745. switch name {
  31746. case usagestatisticday.FieldCreatedAt:
  31747. v, ok := value.(time.Time)
  31748. if !ok {
  31749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31750. }
  31751. m.SetCreatedAt(v)
  31752. return nil
  31753. case usagestatisticday.FieldUpdatedAt:
  31754. v, ok := value.(time.Time)
  31755. if !ok {
  31756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31757. }
  31758. m.SetUpdatedAt(v)
  31759. return nil
  31760. case usagestatisticday.FieldStatus:
  31761. v, ok := value.(uint8)
  31762. if !ok {
  31763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31764. }
  31765. m.SetStatus(v)
  31766. return nil
  31767. case usagestatisticday.FieldDeletedAt:
  31768. v, ok := value.(time.Time)
  31769. if !ok {
  31770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31771. }
  31772. m.SetDeletedAt(v)
  31773. return nil
  31774. case usagestatisticday.FieldAddtime:
  31775. v, ok := value.(uint64)
  31776. if !ok {
  31777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31778. }
  31779. m.SetAddtime(v)
  31780. return nil
  31781. case usagestatisticday.FieldType:
  31782. v, ok := value.(int)
  31783. if !ok {
  31784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31785. }
  31786. m.SetType(v)
  31787. return nil
  31788. case usagestatisticday.FieldBotID:
  31789. v, ok := value.(string)
  31790. if !ok {
  31791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31792. }
  31793. m.SetBotID(v)
  31794. return nil
  31795. case usagestatisticday.FieldOrganizationID:
  31796. v, ok := value.(uint64)
  31797. if !ok {
  31798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31799. }
  31800. m.SetOrganizationID(v)
  31801. return nil
  31802. case usagestatisticday.FieldAiResponse:
  31803. v, ok := value.(uint64)
  31804. if !ok {
  31805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31806. }
  31807. m.SetAiResponse(v)
  31808. return nil
  31809. case usagestatisticday.FieldSopRun:
  31810. v, ok := value.(uint64)
  31811. if !ok {
  31812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31813. }
  31814. m.SetSopRun(v)
  31815. return nil
  31816. case usagestatisticday.FieldTotalFriend:
  31817. v, ok := value.(uint64)
  31818. if !ok {
  31819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31820. }
  31821. m.SetTotalFriend(v)
  31822. return nil
  31823. case usagestatisticday.FieldTotalGroup:
  31824. v, ok := value.(uint64)
  31825. if !ok {
  31826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31827. }
  31828. m.SetTotalGroup(v)
  31829. return nil
  31830. case usagestatisticday.FieldAccountBalance:
  31831. v, ok := value.(uint64)
  31832. if !ok {
  31833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31834. }
  31835. m.SetAccountBalance(v)
  31836. return nil
  31837. case usagestatisticday.FieldConsumeToken:
  31838. v, ok := value.(uint64)
  31839. if !ok {
  31840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31841. }
  31842. m.SetConsumeToken(v)
  31843. return nil
  31844. case usagestatisticday.FieldActiveUser:
  31845. v, ok := value.(uint64)
  31846. if !ok {
  31847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31848. }
  31849. m.SetActiveUser(v)
  31850. return nil
  31851. case usagestatisticday.FieldNewUser:
  31852. v, ok := value.(int64)
  31853. if !ok {
  31854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31855. }
  31856. m.SetNewUser(v)
  31857. return nil
  31858. case usagestatisticday.FieldLabelDist:
  31859. v, ok := value.([]custom_types.LabelDist)
  31860. if !ok {
  31861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31862. }
  31863. m.SetLabelDist(v)
  31864. return nil
  31865. }
  31866. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31867. }
  31868. // AddedFields returns all numeric fields that were incremented/decremented during
  31869. // this mutation.
  31870. func (m *UsageStatisticDayMutation) AddedFields() []string {
  31871. var fields []string
  31872. if m.addstatus != nil {
  31873. fields = append(fields, usagestatisticday.FieldStatus)
  31874. }
  31875. if m.addaddtime != nil {
  31876. fields = append(fields, usagestatisticday.FieldAddtime)
  31877. }
  31878. if m.add_type != nil {
  31879. fields = append(fields, usagestatisticday.FieldType)
  31880. }
  31881. if m.addorganization_id != nil {
  31882. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31883. }
  31884. if m.addai_response != nil {
  31885. fields = append(fields, usagestatisticday.FieldAiResponse)
  31886. }
  31887. if m.addsop_run != nil {
  31888. fields = append(fields, usagestatisticday.FieldSopRun)
  31889. }
  31890. if m.addtotal_friend != nil {
  31891. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31892. }
  31893. if m.addtotal_group != nil {
  31894. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31895. }
  31896. if m.addaccount_balance != nil {
  31897. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31898. }
  31899. if m.addconsume_token != nil {
  31900. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31901. }
  31902. if m.addactive_user != nil {
  31903. fields = append(fields, usagestatisticday.FieldActiveUser)
  31904. }
  31905. if m.addnew_user != nil {
  31906. fields = append(fields, usagestatisticday.FieldNewUser)
  31907. }
  31908. return fields
  31909. }
  31910. // AddedField returns the numeric value that was incremented/decremented on a field
  31911. // with the given name. The second boolean return value indicates that this field
  31912. // was not set, or was not defined in the schema.
  31913. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  31914. switch name {
  31915. case usagestatisticday.FieldStatus:
  31916. return m.AddedStatus()
  31917. case usagestatisticday.FieldAddtime:
  31918. return m.AddedAddtime()
  31919. case usagestatisticday.FieldType:
  31920. return m.AddedType()
  31921. case usagestatisticday.FieldOrganizationID:
  31922. return m.AddedOrganizationID()
  31923. case usagestatisticday.FieldAiResponse:
  31924. return m.AddedAiResponse()
  31925. case usagestatisticday.FieldSopRun:
  31926. return m.AddedSopRun()
  31927. case usagestatisticday.FieldTotalFriend:
  31928. return m.AddedTotalFriend()
  31929. case usagestatisticday.FieldTotalGroup:
  31930. return m.AddedTotalGroup()
  31931. case usagestatisticday.FieldAccountBalance:
  31932. return m.AddedAccountBalance()
  31933. case usagestatisticday.FieldConsumeToken:
  31934. return m.AddedConsumeToken()
  31935. case usagestatisticday.FieldActiveUser:
  31936. return m.AddedActiveUser()
  31937. case usagestatisticday.FieldNewUser:
  31938. return m.AddedNewUser()
  31939. }
  31940. return nil, false
  31941. }
  31942. // AddField adds the value to the field with the given name. It returns an error if
  31943. // the field is not defined in the schema, or if the type mismatched the field
  31944. // type.
  31945. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  31946. switch name {
  31947. case usagestatisticday.FieldStatus:
  31948. v, ok := value.(int8)
  31949. if !ok {
  31950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31951. }
  31952. m.AddStatus(v)
  31953. return nil
  31954. case usagestatisticday.FieldAddtime:
  31955. v, ok := value.(int64)
  31956. if !ok {
  31957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31958. }
  31959. m.AddAddtime(v)
  31960. return nil
  31961. case usagestatisticday.FieldType:
  31962. v, ok := value.(int)
  31963. if !ok {
  31964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31965. }
  31966. m.AddType(v)
  31967. return nil
  31968. case usagestatisticday.FieldOrganizationID:
  31969. v, ok := value.(int64)
  31970. if !ok {
  31971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31972. }
  31973. m.AddOrganizationID(v)
  31974. return nil
  31975. case usagestatisticday.FieldAiResponse:
  31976. v, ok := value.(int64)
  31977. if !ok {
  31978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31979. }
  31980. m.AddAiResponse(v)
  31981. return nil
  31982. case usagestatisticday.FieldSopRun:
  31983. v, ok := value.(int64)
  31984. if !ok {
  31985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31986. }
  31987. m.AddSopRun(v)
  31988. return nil
  31989. case usagestatisticday.FieldTotalFriend:
  31990. v, ok := value.(int64)
  31991. if !ok {
  31992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31993. }
  31994. m.AddTotalFriend(v)
  31995. return nil
  31996. case usagestatisticday.FieldTotalGroup:
  31997. v, ok := value.(int64)
  31998. if !ok {
  31999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32000. }
  32001. m.AddTotalGroup(v)
  32002. return nil
  32003. case usagestatisticday.FieldAccountBalance:
  32004. v, ok := value.(int64)
  32005. if !ok {
  32006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32007. }
  32008. m.AddAccountBalance(v)
  32009. return nil
  32010. case usagestatisticday.FieldConsumeToken:
  32011. v, ok := value.(int64)
  32012. if !ok {
  32013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32014. }
  32015. m.AddConsumeToken(v)
  32016. return nil
  32017. case usagestatisticday.FieldActiveUser:
  32018. v, ok := value.(int64)
  32019. if !ok {
  32020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32021. }
  32022. m.AddActiveUser(v)
  32023. return nil
  32024. case usagestatisticday.FieldNewUser:
  32025. v, ok := value.(int64)
  32026. if !ok {
  32027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32028. }
  32029. m.AddNewUser(v)
  32030. return nil
  32031. }
  32032. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  32033. }
  32034. // ClearedFields returns all nullable fields that were cleared during this
  32035. // mutation.
  32036. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  32037. var fields []string
  32038. if m.FieldCleared(usagestatisticday.FieldStatus) {
  32039. fields = append(fields, usagestatisticday.FieldStatus)
  32040. }
  32041. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  32042. fields = append(fields, usagestatisticday.FieldDeletedAt)
  32043. }
  32044. if m.FieldCleared(usagestatisticday.FieldBotID) {
  32045. fields = append(fields, usagestatisticday.FieldBotID)
  32046. }
  32047. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  32048. fields = append(fields, usagestatisticday.FieldOrganizationID)
  32049. }
  32050. return fields
  32051. }
  32052. // FieldCleared returns a boolean indicating if a field with the given name was
  32053. // cleared in this mutation.
  32054. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  32055. _, ok := m.clearedFields[name]
  32056. return ok
  32057. }
  32058. // ClearField clears the value of the field with the given name. It returns an
  32059. // error if the field is not defined in the schema.
  32060. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  32061. switch name {
  32062. case usagestatisticday.FieldStatus:
  32063. m.ClearStatus()
  32064. return nil
  32065. case usagestatisticday.FieldDeletedAt:
  32066. m.ClearDeletedAt()
  32067. return nil
  32068. case usagestatisticday.FieldBotID:
  32069. m.ClearBotID()
  32070. return nil
  32071. case usagestatisticday.FieldOrganizationID:
  32072. m.ClearOrganizationID()
  32073. return nil
  32074. }
  32075. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  32076. }
  32077. // ResetField resets all changes in the mutation for the field with the given name.
  32078. // It returns an error if the field is not defined in the schema.
  32079. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  32080. switch name {
  32081. case usagestatisticday.FieldCreatedAt:
  32082. m.ResetCreatedAt()
  32083. return nil
  32084. case usagestatisticday.FieldUpdatedAt:
  32085. m.ResetUpdatedAt()
  32086. return nil
  32087. case usagestatisticday.FieldStatus:
  32088. m.ResetStatus()
  32089. return nil
  32090. case usagestatisticday.FieldDeletedAt:
  32091. m.ResetDeletedAt()
  32092. return nil
  32093. case usagestatisticday.FieldAddtime:
  32094. m.ResetAddtime()
  32095. return nil
  32096. case usagestatisticday.FieldType:
  32097. m.ResetType()
  32098. return nil
  32099. case usagestatisticday.FieldBotID:
  32100. m.ResetBotID()
  32101. return nil
  32102. case usagestatisticday.FieldOrganizationID:
  32103. m.ResetOrganizationID()
  32104. return nil
  32105. case usagestatisticday.FieldAiResponse:
  32106. m.ResetAiResponse()
  32107. return nil
  32108. case usagestatisticday.FieldSopRun:
  32109. m.ResetSopRun()
  32110. return nil
  32111. case usagestatisticday.FieldTotalFriend:
  32112. m.ResetTotalFriend()
  32113. return nil
  32114. case usagestatisticday.FieldTotalGroup:
  32115. m.ResetTotalGroup()
  32116. return nil
  32117. case usagestatisticday.FieldAccountBalance:
  32118. m.ResetAccountBalance()
  32119. return nil
  32120. case usagestatisticday.FieldConsumeToken:
  32121. m.ResetConsumeToken()
  32122. return nil
  32123. case usagestatisticday.FieldActiveUser:
  32124. m.ResetActiveUser()
  32125. return nil
  32126. case usagestatisticday.FieldNewUser:
  32127. m.ResetNewUser()
  32128. return nil
  32129. case usagestatisticday.FieldLabelDist:
  32130. m.ResetLabelDist()
  32131. return nil
  32132. }
  32133. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  32134. }
  32135. // AddedEdges returns all edge names that were set/added in this mutation.
  32136. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  32137. edges := make([]string, 0, 0)
  32138. return edges
  32139. }
  32140. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32141. // name in this mutation.
  32142. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  32143. return nil
  32144. }
  32145. // RemovedEdges returns all edge names that were removed in this mutation.
  32146. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  32147. edges := make([]string, 0, 0)
  32148. return edges
  32149. }
  32150. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32151. // the given name in this mutation.
  32152. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  32153. return nil
  32154. }
  32155. // ClearedEdges returns all edge names that were cleared in this mutation.
  32156. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  32157. edges := make([]string, 0, 0)
  32158. return edges
  32159. }
  32160. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32161. // was cleared in this mutation.
  32162. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  32163. return false
  32164. }
  32165. // ClearEdge clears the value of the edge with the given name. It returns an error
  32166. // if that edge is not defined in the schema.
  32167. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  32168. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  32169. }
  32170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32171. // It returns an error if the edge is not defined in the schema.
  32172. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  32173. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  32174. }
  32175. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  32176. type UsageStatisticHourMutation struct {
  32177. config
  32178. op Op
  32179. typ string
  32180. id *uint64
  32181. created_at *time.Time
  32182. updated_at *time.Time
  32183. status *uint8
  32184. addstatus *int8
  32185. deleted_at *time.Time
  32186. addtime *uint64
  32187. addaddtime *int64
  32188. _type *int
  32189. add_type *int
  32190. bot_id *string
  32191. organization_id *uint64
  32192. addorganization_id *int64
  32193. ai_response *uint64
  32194. addai_response *int64
  32195. sop_run *uint64
  32196. addsop_run *int64
  32197. total_friend *uint64
  32198. addtotal_friend *int64
  32199. total_group *uint64
  32200. addtotal_group *int64
  32201. account_balance *uint64
  32202. addaccount_balance *int64
  32203. consume_token *uint64
  32204. addconsume_token *int64
  32205. active_user *uint64
  32206. addactive_user *int64
  32207. new_user *int64
  32208. addnew_user *int64
  32209. label_dist *[]custom_types.LabelDist
  32210. appendlabel_dist []custom_types.LabelDist
  32211. clearedFields map[string]struct{}
  32212. done bool
  32213. oldValue func(context.Context) (*UsageStatisticHour, error)
  32214. predicates []predicate.UsageStatisticHour
  32215. }
  32216. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  32217. // usagestatistichourOption allows management of the mutation configuration using functional options.
  32218. type usagestatistichourOption func(*UsageStatisticHourMutation)
  32219. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  32220. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  32221. m := &UsageStatisticHourMutation{
  32222. config: c,
  32223. op: op,
  32224. typ: TypeUsageStatisticHour,
  32225. clearedFields: make(map[string]struct{}),
  32226. }
  32227. for _, opt := range opts {
  32228. opt(m)
  32229. }
  32230. return m
  32231. }
  32232. // withUsageStatisticHourID sets the ID field of the mutation.
  32233. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  32234. return func(m *UsageStatisticHourMutation) {
  32235. var (
  32236. err error
  32237. once sync.Once
  32238. value *UsageStatisticHour
  32239. )
  32240. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  32241. once.Do(func() {
  32242. if m.done {
  32243. err = errors.New("querying old values post mutation is not allowed")
  32244. } else {
  32245. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  32246. }
  32247. })
  32248. return value, err
  32249. }
  32250. m.id = &id
  32251. }
  32252. }
  32253. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  32254. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  32255. return func(m *UsageStatisticHourMutation) {
  32256. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  32257. return node, nil
  32258. }
  32259. m.id = &node.ID
  32260. }
  32261. }
  32262. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32263. // executed in a transaction (ent.Tx), a transactional client is returned.
  32264. func (m UsageStatisticHourMutation) Client() *Client {
  32265. client := &Client{config: m.config}
  32266. client.init()
  32267. return client
  32268. }
  32269. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32270. // it returns an error otherwise.
  32271. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  32272. if _, ok := m.driver.(*txDriver); !ok {
  32273. return nil, errors.New("ent: mutation is not running in a transaction")
  32274. }
  32275. tx := &Tx{config: m.config}
  32276. tx.init()
  32277. return tx, nil
  32278. }
  32279. // SetID sets the value of the id field. Note that this
  32280. // operation is only accepted on creation of UsageStatisticHour entities.
  32281. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  32282. m.id = &id
  32283. }
  32284. // ID returns the ID value in the mutation. Note that the ID is only available
  32285. // if it was provided to the builder or after it was returned from the database.
  32286. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  32287. if m.id == nil {
  32288. return
  32289. }
  32290. return *m.id, true
  32291. }
  32292. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32293. // That means, if the mutation is applied within a transaction with an isolation level such
  32294. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32295. // or updated by the mutation.
  32296. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  32297. switch {
  32298. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32299. id, exists := m.ID()
  32300. if exists {
  32301. return []uint64{id}, nil
  32302. }
  32303. fallthrough
  32304. case m.op.Is(OpUpdate | OpDelete):
  32305. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  32306. default:
  32307. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32308. }
  32309. }
  32310. // SetCreatedAt sets the "created_at" field.
  32311. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  32312. m.created_at = &t
  32313. }
  32314. // CreatedAt returns the value of the "created_at" field in the mutation.
  32315. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  32316. v := m.created_at
  32317. if v == nil {
  32318. return
  32319. }
  32320. return *v, true
  32321. }
  32322. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  32323. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32325. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32326. if !m.op.Is(OpUpdateOne) {
  32327. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32328. }
  32329. if m.id == nil || m.oldValue == nil {
  32330. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32331. }
  32332. oldValue, err := m.oldValue(ctx)
  32333. if err != nil {
  32334. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32335. }
  32336. return oldValue.CreatedAt, nil
  32337. }
  32338. // ResetCreatedAt resets all changes to the "created_at" field.
  32339. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  32340. m.created_at = nil
  32341. }
  32342. // SetUpdatedAt sets the "updated_at" field.
  32343. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  32344. m.updated_at = &t
  32345. }
  32346. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32347. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  32348. v := m.updated_at
  32349. if v == nil {
  32350. return
  32351. }
  32352. return *v, true
  32353. }
  32354. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  32355. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32357. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32358. if !m.op.Is(OpUpdateOne) {
  32359. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32360. }
  32361. if m.id == nil || m.oldValue == nil {
  32362. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32363. }
  32364. oldValue, err := m.oldValue(ctx)
  32365. if err != nil {
  32366. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32367. }
  32368. return oldValue.UpdatedAt, nil
  32369. }
  32370. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32371. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  32372. m.updated_at = nil
  32373. }
  32374. // SetStatus sets the "status" field.
  32375. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  32376. m.status = &u
  32377. m.addstatus = nil
  32378. }
  32379. // Status returns the value of the "status" field in the mutation.
  32380. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  32381. v := m.status
  32382. if v == nil {
  32383. return
  32384. }
  32385. return *v, true
  32386. }
  32387. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  32388. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32390. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32391. if !m.op.Is(OpUpdateOne) {
  32392. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32393. }
  32394. if m.id == nil || m.oldValue == nil {
  32395. return v, errors.New("OldStatus requires an ID field in the mutation")
  32396. }
  32397. oldValue, err := m.oldValue(ctx)
  32398. if err != nil {
  32399. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32400. }
  32401. return oldValue.Status, nil
  32402. }
  32403. // AddStatus adds u to the "status" field.
  32404. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  32405. if m.addstatus != nil {
  32406. *m.addstatus += u
  32407. } else {
  32408. m.addstatus = &u
  32409. }
  32410. }
  32411. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32412. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  32413. v := m.addstatus
  32414. if v == nil {
  32415. return
  32416. }
  32417. return *v, true
  32418. }
  32419. // ClearStatus clears the value of the "status" field.
  32420. func (m *UsageStatisticHourMutation) ClearStatus() {
  32421. m.status = nil
  32422. m.addstatus = nil
  32423. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  32424. }
  32425. // StatusCleared returns if the "status" field was cleared in this mutation.
  32426. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  32427. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  32428. return ok
  32429. }
  32430. // ResetStatus resets all changes to the "status" field.
  32431. func (m *UsageStatisticHourMutation) ResetStatus() {
  32432. m.status = nil
  32433. m.addstatus = nil
  32434. delete(m.clearedFields, usagestatistichour.FieldStatus)
  32435. }
  32436. // SetDeletedAt sets the "deleted_at" field.
  32437. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  32438. m.deleted_at = &t
  32439. }
  32440. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32441. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  32442. v := m.deleted_at
  32443. if v == nil {
  32444. return
  32445. }
  32446. return *v, true
  32447. }
  32448. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  32449. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32451. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32452. if !m.op.Is(OpUpdateOne) {
  32453. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32454. }
  32455. if m.id == nil || m.oldValue == nil {
  32456. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32457. }
  32458. oldValue, err := m.oldValue(ctx)
  32459. if err != nil {
  32460. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32461. }
  32462. return oldValue.DeletedAt, nil
  32463. }
  32464. // ClearDeletedAt clears the value of the "deleted_at" field.
  32465. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  32466. m.deleted_at = nil
  32467. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  32468. }
  32469. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32470. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  32471. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  32472. return ok
  32473. }
  32474. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32475. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  32476. m.deleted_at = nil
  32477. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  32478. }
  32479. // SetAddtime sets the "addtime" field.
  32480. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  32481. m.addtime = &u
  32482. m.addaddtime = nil
  32483. }
  32484. // Addtime returns the value of the "addtime" field in the mutation.
  32485. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  32486. v := m.addtime
  32487. if v == nil {
  32488. return
  32489. }
  32490. return *v, true
  32491. }
  32492. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  32493. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32495. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32496. if !m.op.Is(OpUpdateOne) {
  32497. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32498. }
  32499. if m.id == nil || m.oldValue == nil {
  32500. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32501. }
  32502. oldValue, err := m.oldValue(ctx)
  32503. if err != nil {
  32504. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32505. }
  32506. return oldValue.Addtime, nil
  32507. }
  32508. // AddAddtime adds u to the "addtime" field.
  32509. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  32510. if m.addaddtime != nil {
  32511. *m.addaddtime += u
  32512. } else {
  32513. m.addaddtime = &u
  32514. }
  32515. }
  32516. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32517. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  32518. v := m.addaddtime
  32519. if v == nil {
  32520. return
  32521. }
  32522. return *v, true
  32523. }
  32524. // ResetAddtime resets all changes to the "addtime" field.
  32525. func (m *UsageStatisticHourMutation) ResetAddtime() {
  32526. m.addtime = nil
  32527. m.addaddtime = nil
  32528. }
  32529. // SetType sets the "type" field.
  32530. func (m *UsageStatisticHourMutation) SetType(i int) {
  32531. m._type = &i
  32532. m.add_type = nil
  32533. }
  32534. // GetType returns the value of the "type" field in the mutation.
  32535. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  32536. v := m._type
  32537. if v == nil {
  32538. return
  32539. }
  32540. return *v, true
  32541. }
  32542. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  32543. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32545. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  32546. if !m.op.Is(OpUpdateOne) {
  32547. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32548. }
  32549. if m.id == nil || m.oldValue == nil {
  32550. return v, errors.New("OldType requires an ID field in the mutation")
  32551. }
  32552. oldValue, err := m.oldValue(ctx)
  32553. if err != nil {
  32554. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32555. }
  32556. return oldValue.Type, nil
  32557. }
  32558. // AddType adds i to the "type" field.
  32559. func (m *UsageStatisticHourMutation) AddType(i int) {
  32560. if m.add_type != nil {
  32561. *m.add_type += i
  32562. } else {
  32563. m.add_type = &i
  32564. }
  32565. }
  32566. // AddedType returns the value that was added to the "type" field in this mutation.
  32567. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  32568. v := m.add_type
  32569. if v == nil {
  32570. return
  32571. }
  32572. return *v, true
  32573. }
  32574. // ResetType resets all changes to the "type" field.
  32575. func (m *UsageStatisticHourMutation) ResetType() {
  32576. m._type = nil
  32577. m.add_type = nil
  32578. }
  32579. // SetBotID sets the "bot_id" field.
  32580. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  32581. m.bot_id = &s
  32582. }
  32583. // BotID returns the value of the "bot_id" field in the mutation.
  32584. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  32585. v := m.bot_id
  32586. if v == nil {
  32587. return
  32588. }
  32589. return *v, true
  32590. }
  32591. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  32592. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32594. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  32595. if !m.op.Is(OpUpdateOne) {
  32596. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32597. }
  32598. if m.id == nil || m.oldValue == nil {
  32599. return v, errors.New("OldBotID requires an ID field in the mutation")
  32600. }
  32601. oldValue, err := m.oldValue(ctx)
  32602. if err != nil {
  32603. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32604. }
  32605. return oldValue.BotID, nil
  32606. }
  32607. // ClearBotID clears the value of the "bot_id" field.
  32608. func (m *UsageStatisticHourMutation) ClearBotID() {
  32609. m.bot_id = nil
  32610. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  32611. }
  32612. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32613. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  32614. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  32615. return ok
  32616. }
  32617. // ResetBotID resets all changes to the "bot_id" field.
  32618. func (m *UsageStatisticHourMutation) ResetBotID() {
  32619. m.bot_id = nil
  32620. delete(m.clearedFields, usagestatistichour.FieldBotID)
  32621. }
  32622. // SetOrganizationID sets the "organization_id" field.
  32623. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  32624. m.organization_id = &u
  32625. m.addorganization_id = nil
  32626. }
  32627. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32628. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  32629. v := m.organization_id
  32630. if v == nil {
  32631. return
  32632. }
  32633. return *v, true
  32634. }
  32635. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  32636. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32638. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32639. if !m.op.Is(OpUpdateOne) {
  32640. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32641. }
  32642. if m.id == nil || m.oldValue == nil {
  32643. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32644. }
  32645. oldValue, err := m.oldValue(ctx)
  32646. if err != nil {
  32647. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32648. }
  32649. return oldValue.OrganizationID, nil
  32650. }
  32651. // AddOrganizationID adds u to the "organization_id" field.
  32652. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  32653. if m.addorganization_id != nil {
  32654. *m.addorganization_id += u
  32655. } else {
  32656. m.addorganization_id = &u
  32657. }
  32658. }
  32659. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32660. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  32661. v := m.addorganization_id
  32662. if v == nil {
  32663. return
  32664. }
  32665. return *v, true
  32666. }
  32667. // ClearOrganizationID clears the value of the "organization_id" field.
  32668. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  32669. m.organization_id = nil
  32670. m.addorganization_id = nil
  32671. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  32672. }
  32673. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32674. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  32675. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  32676. return ok
  32677. }
  32678. // ResetOrganizationID resets all changes to the "organization_id" field.
  32679. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  32680. m.organization_id = nil
  32681. m.addorganization_id = nil
  32682. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  32683. }
  32684. // SetAiResponse sets the "ai_response" field.
  32685. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  32686. m.ai_response = &u
  32687. m.addai_response = nil
  32688. }
  32689. // AiResponse returns the value of the "ai_response" field in the mutation.
  32690. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  32691. v := m.ai_response
  32692. if v == nil {
  32693. return
  32694. }
  32695. return *v, true
  32696. }
  32697. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  32698. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32700. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32701. if !m.op.Is(OpUpdateOne) {
  32702. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32703. }
  32704. if m.id == nil || m.oldValue == nil {
  32705. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32706. }
  32707. oldValue, err := m.oldValue(ctx)
  32708. if err != nil {
  32709. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32710. }
  32711. return oldValue.AiResponse, nil
  32712. }
  32713. // AddAiResponse adds u to the "ai_response" field.
  32714. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  32715. if m.addai_response != nil {
  32716. *m.addai_response += u
  32717. } else {
  32718. m.addai_response = &u
  32719. }
  32720. }
  32721. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32722. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  32723. v := m.addai_response
  32724. if v == nil {
  32725. return
  32726. }
  32727. return *v, true
  32728. }
  32729. // ResetAiResponse resets all changes to the "ai_response" field.
  32730. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  32731. m.ai_response = nil
  32732. m.addai_response = nil
  32733. }
  32734. // SetSopRun sets the "sop_run" field.
  32735. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  32736. m.sop_run = &u
  32737. m.addsop_run = nil
  32738. }
  32739. // SopRun returns the value of the "sop_run" field in the mutation.
  32740. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  32741. v := m.sop_run
  32742. if v == nil {
  32743. return
  32744. }
  32745. return *v, true
  32746. }
  32747. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  32748. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32750. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32751. if !m.op.Is(OpUpdateOne) {
  32752. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32753. }
  32754. if m.id == nil || m.oldValue == nil {
  32755. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32756. }
  32757. oldValue, err := m.oldValue(ctx)
  32758. if err != nil {
  32759. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32760. }
  32761. return oldValue.SopRun, nil
  32762. }
  32763. // AddSopRun adds u to the "sop_run" field.
  32764. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  32765. if m.addsop_run != nil {
  32766. *m.addsop_run += u
  32767. } else {
  32768. m.addsop_run = &u
  32769. }
  32770. }
  32771. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32772. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  32773. v := m.addsop_run
  32774. if v == nil {
  32775. return
  32776. }
  32777. return *v, true
  32778. }
  32779. // ResetSopRun resets all changes to the "sop_run" field.
  32780. func (m *UsageStatisticHourMutation) ResetSopRun() {
  32781. m.sop_run = nil
  32782. m.addsop_run = nil
  32783. }
  32784. // SetTotalFriend sets the "total_friend" field.
  32785. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  32786. m.total_friend = &u
  32787. m.addtotal_friend = nil
  32788. }
  32789. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32790. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  32791. v := m.total_friend
  32792. if v == nil {
  32793. return
  32794. }
  32795. return *v, true
  32796. }
  32797. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  32798. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32800. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32801. if !m.op.Is(OpUpdateOne) {
  32802. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32803. }
  32804. if m.id == nil || m.oldValue == nil {
  32805. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32806. }
  32807. oldValue, err := m.oldValue(ctx)
  32808. if err != nil {
  32809. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32810. }
  32811. return oldValue.TotalFriend, nil
  32812. }
  32813. // AddTotalFriend adds u to the "total_friend" field.
  32814. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  32815. if m.addtotal_friend != nil {
  32816. *m.addtotal_friend += u
  32817. } else {
  32818. m.addtotal_friend = &u
  32819. }
  32820. }
  32821. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32822. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  32823. v := m.addtotal_friend
  32824. if v == nil {
  32825. return
  32826. }
  32827. return *v, true
  32828. }
  32829. // ResetTotalFriend resets all changes to the "total_friend" field.
  32830. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  32831. m.total_friend = nil
  32832. m.addtotal_friend = nil
  32833. }
  32834. // SetTotalGroup sets the "total_group" field.
  32835. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  32836. m.total_group = &u
  32837. m.addtotal_group = nil
  32838. }
  32839. // TotalGroup returns the value of the "total_group" field in the mutation.
  32840. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  32841. v := m.total_group
  32842. if v == nil {
  32843. return
  32844. }
  32845. return *v, true
  32846. }
  32847. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  32848. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32850. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32851. if !m.op.Is(OpUpdateOne) {
  32852. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32853. }
  32854. if m.id == nil || m.oldValue == nil {
  32855. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32856. }
  32857. oldValue, err := m.oldValue(ctx)
  32858. if err != nil {
  32859. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32860. }
  32861. return oldValue.TotalGroup, nil
  32862. }
  32863. // AddTotalGroup adds u to the "total_group" field.
  32864. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  32865. if m.addtotal_group != nil {
  32866. *m.addtotal_group += u
  32867. } else {
  32868. m.addtotal_group = &u
  32869. }
  32870. }
  32871. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32872. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  32873. v := m.addtotal_group
  32874. if v == nil {
  32875. return
  32876. }
  32877. return *v, true
  32878. }
  32879. // ResetTotalGroup resets all changes to the "total_group" field.
  32880. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  32881. m.total_group = nil
  32882. m.addtotal_group = nil
  32883. }
  32884. // SetAccountBalance sets the "account_balance" field.
  32885. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  32886. m.account_balance = &u
  32887. m.addaccount_balance = nil
  32888. }
  32889. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32890. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  32891. v := m.account_balance
  32892. if v == nil {
  32893. return
  32894. }
  32895. return *v, true
  32896. }
  32897. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  32898. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32900. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32901. if !m.op.Is(OpUpdateOne) {
  32902. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32903. }
  32904. if m.id == nil || m.oldValue == nil {
  32905. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32906. }
  32907. oldValue, err := m.oldValue(ctx)
  32908. if err != nil {
  32909. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32910. }
  32911. return oldValue.AccountBalance, nil
  32912. }
  32913. // AddAccountBalance adds u to the "account_balance" field.
  32914. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  32915. if m.addaccount_balance != nil {
  32916. *m.addaccount_balance += u
  32917. } else {
  32918. m.addaccount_balance = &u
  32919. }
  32920. }
  32921. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32922. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  32923. v := m.addaccount_balance
  32924. if v == nil {
  32925. return
  32926. }
  32927. return *v, true
  32928. }
  32929. // ResetAccountBalance resets all changes to the "account_balance" field.
  32930. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  32931. m.account_balance = nil
  32932. m.addaccount_balance = nil
  32933. }
  32934. // SetConsumeToken sets the "consume_token" field.
  32935. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  32936. m.consume_token = &u
  32937. m.addconsume_token = nil
  32938. }
  32939. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32940. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  32941. v := m.consume_token
  32942. if v == nil {
  32943. return
  32944. }
  32945. return *v, true
  32946. }
  32947. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  32948. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32950. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32951. if !m.op.Is(OpUpdateOne) {
  32952. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32953. }
  32954. if m.id == nil || m.oldValue == nil {
  32955. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32956. }
  32957. oldValue, err := m.oldValue(ctx)
  32958. if err != nil {
  32959. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32960. }
  32961. return oldValue.ConsumeToken, nil
  32962. }
  32963. // AddConsumeToken adds u to the "consume_token" field.
  32964. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  32965. if m.addconsume_token != nil {
  32966. *m.addconsume_token += u
  32967. } else {
  32968. m.addconsume_token = &u
  32969. }
  32970. }
  32971. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  32972. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  32973. v := m.addconsume_token
  32974. if v == nil {
  32975. return
  32976. }
  32977. return *v, true
  32978. }
  32979. // ResetConsumeToken resets all changes to the "consume_token" field.
  32980. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  32981. m.consume_token = nil
  32982. m.addconsume_token = nil
  32983. }
  32984. // SetActiveUser sets the "active_user" field.
  32985. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  32986. m.active_user = &u
  32987. m.addactive_user = nil
  32988. }
  32989. // ActiveUser returns the value of the "active_user" field in the mutation.
  32990. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  32991. v := m.active_user
  32992. if v == nil {
  32993. return
  32994. }
  32995. return *v, true
  32996. }
  32997. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  32998. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33000. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  33001. if !m.op.Is(OpUpdateOne) {
  33002. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  33003. }
  33004. if m.id == nil || m.oldValue == nil {
  33005. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  33006. }
  33007. oldValue, err := m.oldValue(ctx)
  33008. if err != nil {
  33009. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  33010. }
  33011. return oldValue.ActiveUser, nil
  33012. }
  33013. // AddActiveUser adds u to the "active_user" field.
  33014. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  33015. if m.addactive_user != nil {
  33016. *m.addactive_user += u
  33017. } else {
  33018. m.addactive_user = &u
  33019. }
  33020. }
  33021. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  33022. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  33023. v := m.addactive_user
  33024. if v == nil {
  33025. return
  33026. }
  33027. return *v, true
  33028. }
  33029. // ResetActiveUser resets all changes to the "active_user" field.
  33030. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  33031. m.active_user = nil
  33032. m.addactive_user = nil
  33033. }
  33034. // SetNewUser sets the "new_user" field.
  33035. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  33036. m.new_user = &i
  33037. m.addnew_user = nil
  33038. }
  33039. // NewUser returns the value of the "new_user" field in the mutation.
  33040. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  33041. v := m.new_user
  33042. if v == nil {
  33043. return
  33044. }
  33045. return *v, true
  33046. }
  33047. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  33048. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33050. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  33051. if !m.op.Is(OpUpdateOne) {
  33052. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  33053. }
  33054. if m.id == nil || m.oldValue == nil {
  33055. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33056. }
  33057. oldValue, err := m.oldValue(ctx)
  33058. if err != nil {
  33059. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33060. }
  33061. return oldValue.NewUser, nil
  33062. }
  33063. // AddNewUser adds i to the "new_user" field.
  33064. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  33065. if m.addnew_user != nil {
  33066. *m.addnew_user += i
  33067. } else {
  33068. m.addnew_user = &i
  33069. }
  33070. }
  33071. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33072. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  33073. v := m.addnew_user
  33074. if v == nil {
  33075. return
  33076. }
  33077. return *v, true
  33078. }
  33079. // ResetNewUser resets all changes to the "new_user" field.
  33080. func (m *UsageStatisticHourMutation) ResetNewUser() {
  33081. m.new_user = nil
  33082. m.addnew_user = nil
  33083. }
  33084. // SetLabelDist sets the "label_dist" field.
  33085. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33086. m.label_dist = &ctd
  33087. m.appendlabel_dist = nil
  33088. }
  33089. // LabelDist returns the value of the "label_dist" field in the mutation.
  33090. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33091. v := m.label_dist
  33092. if v == nil {
  33093. return
  33094. }
  33095. return *v, true
  33096. }
  33097. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  33098. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33100. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33101. if !m.op.Is(OpUpdateOne) {
  33102. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33103. }
  33104. if m.id == nil || m.oldValue == nil {
  33105. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33106. }
  33107. oldValue, err := m.oldValue(ctx)
  33108. if err != nil {
  33109. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33110. }
  33111. return oldValue.LabelDist, nil
  33112. }
  33113. // AppendLabelDist adds ctd to the "label_dist" field.
  33114. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33115. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33116. }
  33117. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33118. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33119. if len(m.appendlabel_dist) == 0 {
  33120. return nil, false
  33121. }
  33122. return m.appendlabel_dist, true
  33123. }
  33124. // ResetLabelDist resets all changes to the "label_dist" field.
  33125. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  33126. m.label_dist = nil
  33127. m.appendlabel_dist = nil
  33128. }
  33129. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  33130. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  33131. m.predicates = append(m.predicates, ps...)
  33132. }
  33133. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  33134. // users can use type-assertion to append predicates that do not depend on any generated package.
  33135. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  33136. p := make([]predicate.UsageStatisticHour, len(ps))
  33137. for i := range ps {
  33138. p[i] = ps[i]
  33139. }
  33140. m.Where(p...)
  33141. }
  33142. // Op returns the operation name.
  33143. func (m *UsageStatisticHourMutation) Op() Op {
  33144. return m.op
  33145. }
  33146. // SetOp allows setting the mutation operation.
  33147. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  33148. m.op = op
  33149. }
  33150. // Type returns the node type of this mutation (UsageStatisticHour).
  33151. func (m *UsageStatisticHourMutation) Type() string {
  33152. return m.typ
  33153. }
  33154. // Fields returns all fields that were changed during this mutation. Note that in
  33155. // order to get all numeric fields that were incremented/decremented, call
  33156. // AddedFields().
  33157. func (m *UsageStatisticHourMutation) Fields() []string {
  33158. fields := make([]string, 0, 17)
  33159. if m.created_at != nil {
  33160. fields = append(fields, usagestatistichour.FieldCreatedAt)
  33161. }
  33162. if m.updated_at != nil {
  33163. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  33164. }
  33165. if m.status != nil {
  33166. fields = append(fields, usagestatistichour.FieldStatus)
  33167. }
  33168. if m.deleted_at != nil {
  33169. fields = append(fields, usagestatistichour.FieldDeletedAt)
  33170. }
  33171. if m.addtime != nil {
  33172. fields = append(fields, usagestatistichour.FieldAddtime)
  33173. }
  33174. if m._type != nil {
  33175. fields = append(fields, usagestatistichour.FieldType)
  33176. }
  33177. if m.bot_id != nil {
  33178. fields = append(fields, usagestatistichour.FieldBotID)
  33179. }
  33180. if m.organization_id != nil {
  33181. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33182. }
  33183. if m.ai_response != nil {
  33184. fields = append(fields, usagestatistichour.FieldAiResponse)
  33185. }
  33186. if m.sop_run != nil {
  33187. fields = append(fields, usagestatistichour.FieldSopRun)
  33188. }
  33189. if m.total_friend != nil {
  33190. fields = append(fields, usagestatistichour.FieldTotalFriend)
  33191. }
  33192. if m.total_group != nil {
  33193. fields = append(fields, usagestatistichour.FieldTotalGroup)
  33194. }
  33195. if m.account_balance != nil {
  33196. fields = append(fields, usagestatistichour.FieldAccountBalance)
  33197. }
  33198. if m.consume_token != nil {
  33199. fields = append(fields, usagestatistichour.FieldConsumeToken)
  33200. }
  33201. if m.active_user != nil {
  33202. fields = append(fields, usagestatistichour.FieldActiveUser)
  33203. }
  33204. if m.new_user != nil {
  33205. fields = append(fields, usagestatistichour.FieldNewUser)
  33206. }
  33207. if m.label_dist != nil {
  33208. fields = append(fields, usagestatistichour.FieldLabelDist)
  33209. }
  33210. return fields
  33211. }
  33212. // Field returns the value of a field with the given name. The second boolean
  33213. // return value indicates that this field was not set, or was not defined in the
  33214. // schema.
  33215. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  33216. switch name {
  33217. case usagestatistichour.FieldCreatedAt:
  33218. return m.CreatedAt()
  33219. case usagestatistichour.FieldUpdatedAt:
  33220. return m.UpdatedAt()
  33221. case usagestatistichour.FieldStatus:
  33222. return m.Status()
  33223. case usagestatistichour.FieldDeletedAt:
  33224. return m.DeletedAt()
  33225. case usagestatistichour.FieldAddtime:
  33226. return m.Addtime()
  33227. case usagestatistichour.FieldType:
  33228. return m.GetType()
  33229. case usagestatistichour.FieldBotID:
  33230. return m.BotID()
  33231. case usagestatistichour.FieldOrganizationID:
  33232. return m.OrganizationID()
  33233. case usagestatistichour.FieldAiResponse:
  33234. return m.AiResponse()
  33235. case usagestatistichour.FieldSopRun:
  33236. return m.SopRun()
  33237. case usagestatistichour.FieldTotalFriend:
  33238. return m.TotalFriend()
  33239. case usagestatistichour.FieldTotalGroup:
  33240. return m.TotalGroup()
  33241. case usagestatistichour.FieldAccountBalance:
  33242. return m.AccountBalance()
  33243. case usagestatistichour.FieldConsumeToken:
  33244. return m.ConsumeToken()
  33245. case usagestatistichour.FieldActiveUser:
  33246. return m.ActiveUser()
  33247. case usagestatistichour.FieldNewUser:
  33248. return m.NewUser()
  33249. case usagestatistichour.FieldLabelDist:
  33250. return m.LabelDist()
  33251. }
  33252. return nil, false
  33253. }
  33254. // OldField returns the old value of the field from the database. An error is
  33255. // returned if the mutation operation is not UpdateOne, or the query to the
  33256. // database failed.
  33257. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33258. switch name {
  33259. case usagestatistichour.FieldCreatedAt:
  33260. return m.OldCreatedAt(ctx)
  33261. case usagestatistichour.FieldUpdatedAt:
  33262. return m.OldUpdatedAt(ctx)
  33263. case usagestatistichour.FieldStatus:
  33264. return m.OldStatus(ctx)
  33265. case usagestatistichour.FieldDeletedAt:
  33266. return m.OldDeletedAt(ctx)
  33267. case usagestatistichour.FieldAddtime:
  33268. return m.OldAddtime(ctx)
  33269. case usagestatistichour.FieldType:
  33270. return m.OldType(ctx)
  33271. case usagestatistichour.FieldBotID:
  33272. return m.OldBotID(ctx)
  33273. case usagestatistichour.FieldOrganizationID:
  33274. return m.OldOrganizationID(ctx)
  33275. case usagestatistichour.FieldAiResponse:
  33276. return m.OldAiResponse(ctx)
  33277. case usagestatistichour.FieldSopRun:
  33278. return m.OldSopRun(ctx)
  33279. case usagestatistichour.FieldTotalFriend:
  33280. return m.OldTotalFriend(ctx)
  33281. case usagestatistichour.FieldTotalGroup:
  33282. return m.OldTotalGroup(ctx)
  33283. case usagestatistichour.FieldAccountBalance:
  33284. return m.OldAccountBalance(ctx)
  33285. case usagestatistichour.FieldConsumeToken:
  33286. return m.OldConsumeToken(ctx)
  33287. case usagestatistichour.FieldActiveUser:
  33288. return m.OldActiveUser(ctx)
  33289. case usagestatistichour.FieldNewUser:
  33290. return m.OldNewUser(ctx)
  33291. case usagestatistichour.FieldLabelDist:
  33292. return m.OldLabelDist(ctx)
  33293. }
  33294. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33295. }
  33296. // SetField sets the value of a field with the given name. It returns an error if
  33297. // the field is not defined in the schema, or if the type mismatched the field
  33298. // type.
  33299. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  33300. switch name {
  33301. case usagestatistichour.FieldCreatedAt:
  33302. v, ok := value.(time.Time)
  33303. if !ok {
  33304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33305. }
  33306. m.SetCreatedAt(v)
  33307. return nil
  33308. case usagestatistichour.FieldUpdatedAt:
  33309. v, ok := value.(time.Time)
  33310. if !ok {
  33311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33312. }
  33313. m.SetUpdatedAt(v)
  33314. return nil
  33315. case usagestatistichour.FieldStatus:
  33316. v, ok := value.(uint8)
  33317. if !ok {
  33318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33319. }
  33320. m.SetStatus(v)
  33321. return nil
  33322. case usagestatistichour.FieldDeletedAt:
  33323. v, ok := value.(time.Time)
  33324. if !ok {
  33325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33326. }
  33327. m.SetDeletedAt(v)
  33328. return nil
  33329. case usagestatistichour.FieldAddtime:
  33330. v, ok := value.(uint64)
  33331. if !ok {
  33332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33333. }
  33334. m.SetAddtime(v)
  33335. return nil
  33336. case usagestatistichour.FieldType:
  33337. v, ok := value.(int)
  33338. if !ok {
  33339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33340. }
  33341. m.SetType(v)
  33342. return nil
  33343. case usagestatistichour.FieldBotID:
  33344. v, ok := value.(string)
  33345. if !ok {
  33346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33347. }
  33348. m.SetBotID(v)
  33349. return nil
  33350. case usagestatistichour.FieldOrganizationID:
  33351. v, ok := value.(uint64)
  33352. if !ok {
  33353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33354. }
  33355. m.SetOrganizationID(v)
  33356. return nil
  33357. case usagestatistichour.FieldAiResponse:
  33358. v, ok := value.(uint64)
  33359. if !ok {
  33360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33361. }
  33362. m.SetAiResponse(v)
  33363. return nil
  33364. case usagestatistichour.FieldSopRun:
  33365. v, ok := value.(uint64)
  33366. if !ok {
  33367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33368. }
  33369. m.SetSopRun(v)
  33370. return nil
  33371. case usagestatistichour.FieldTotalFriend:
  33372. v, ok := value.(uint64)
  33373. if !ok {
  33374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33375. }
  33376. m.SetTotalFriend(v)
  33377. return nil
  33378. case usagestatistichour.FieldTotalGroup:
  33379. v, ok := value.(uint64)
  33380. if !ok {
  33381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33382. }
  33383. m.SetTotalGroup(v)
  33384. return nil
  33385. case usagestatistichour.FieldAccountBalance:
  33386. v, ok := value.(uint64)
  33387. if !ok {
  33388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33389. }
  33390. m.SetAccountBalance(v)
  33391. return nil
  33392. case usagestatistichour.FieldConsumeToken:
  33393. v, ok := value.(uint64)
  33394. if !ok {
  33395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33396. }
  33397. m.SetConsumeToken(v)
  33398. return nil
  33399. case usagestatistichour.FieldActiveUser:
  33400. v, ok := value.(uint64)
  33401. if !ok {
  33402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33403. }
  33404. m.SetActiveUser(v)
  33405. return nil
  33406. case usagestatistichour.FieldNewUser:
  33407. v, ok := value.(int64)
  33408. if !ok {
  33409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33410. }
  33411. m.SetNewUser(v)
  33412. return nil
  33413. case usagestatistichour.FieldLabelDist:
  33414. v, ok := value.([]custom_types.LabelDist)
  33415. if !ok {
  33416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33417. }
  33418. m.SetLabelDist(v)
  33419. return nil
  33420. }
  33421. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33422. }
  33423. // AddedFields returns all numeric fields that were incremented/decremented during
  33424. // this mutation.
  33425. func (m *UsageStatisticHourMutation) AddedFields() []string {
  33426. var fields []string
  33427. if m.addstatus != nil {
  33428. fields = append(fields, usagestatistichour.FieldStatus)
  33429. }
  33430. if m.addaddtime != nil {
  33431. fields = append(fields, usagestatistichour.FieldAddtime)
  33432. }
  33433. if m.add_type != nil {
  33434. fields = append(fields, usagestatistichour.FieldType)
  33435. }
  33436. if m.addorganization_id != nil {
  33437. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33438. }
  33439. if m.addai_response != nil {
  33440. fields = append(fields, usagestatistichour.FieldAiResponse)
  33441. }
  33442. if m.addsop_run != nil {
  33443. fields = append(fields, usagestatistichour.FieldSopRun)
  33444. }
  33445. if m.addtotal_friend != nil {
  33446. fields = append(fields, usagestatistichour.FieldTotalFriend)
  33447. }
  33448. if m.addtotal_group != nil {
  33449. fields = append(fields, usagestatistichour.FieldTotalGroup)
  33450. }
  33451. if m.addaccount_balance != nil {
  33452. fields = append(fields, usagestatistichour.FieldAccountBalance)
  33453. }
  33454. if m.addconsume_token != nil {
  33455. fields = append(fields, usagestatistichour.FieldConsumeToken)
  33456. }
  33457. if m.addactive_user != nil {
  33458. fields = append(fields, usagestatistichour.FieldActiveUser)
  33459. }
  33460. if m.addnew_user != nil {
  33461. fields = append(fields, usagestatistichour.FieldNewUser)
  33462. }
  33463. return fields
  33464. }
  33465. // AddedField returns the numeric value that was incremented/decremented on a field
  33466. // with the given name. The second boolean return value indicates that this field
  33467. // was not set, or was not defined in the schema.
  33468. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  33469. switch name {
  33470. case usagestatistichour.FieldStatus:
  33471. return m.AddedStatus()
  33472. case usagestatistichour.FieldAddtime:
  33473. return m.AddedAddtime()
  33474. case usagestatistichour.FieldType:
  33475. return m.AddedType()
  33476. case usagestatistichour.FieldOrganizationID:
  33477. return m.AddedOrganizationID()
  33478. case usagestatistichour.FieldAiResponse:
  33479. return m.AddedAiResponse()
  33480. case usagestatistichour.FieldSopRun:
  33481. return m.AddedSopRun()
  33482. case usagestatistichour.FieldTotalFriend:
  33483. return m.AddedTotalFriend()
  33484. case usagestatistichour.FieldTotalGroup:
  33485. return m.AddedTotalGroup()
  33486. case usagestatistichour.FieldAccountBalance:
  33487. return m.AddedAccountBalance()
  33488. case usagestatistichour.FieldConsumeToken:
  33489. return m.AddedConsumeToken()
  33490. case usagestatistichour.FieldActiveUser:
  33491. return m.AddedActiveUser()
  33492. case usagestatistichour.FieldNewUser:
  33493. return m.AddedNewUser()
  33494. }
  33495. return nil, false
  33496. }
  33497. // AddField adds the value to the field with the given name. It returns an error if
  33498. // the field is not defined in the schema, or if the type mismatched the field
  33499. // type.
  33500. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  33501. switch name {
  33502. case usagestatistichour.FieldStatus:
  33503. v, ok := value.(int8)
  33504. if !ok {
  33505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33506. }
  33507. m.AddStatus(v)
  33508. return nil
  33509. case usagestatistichour.FieldAddtime:
  33510. v, ok := value.(int64)
  33511. if !ok {
  33512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33513. }
  33514. m.AddAddtime(v)
  33515. return nil
  33516. case usagestatistichour.FieldType:
  33517. v, ok := value.(int)
  33518. if !ok {
  33519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33520. }
  33521. m.AddType(v)
  33522. return nil
  33523. case usagestatistichour.FieldOrganizationID:
  33524. v, ok := value.(int64)
  33525. if !ok {
  33526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33527. }
  33528. m.AddOrganizationID(v)
  33529. return nil
  33530. case usagestatistichour.FieldAiResponse:
  33531. v, ok := value.(int64)
  33532. if !ok {
  33533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33534. }
  33535. m.AddAiResponse(v)
  33536. return nil
  33537. case usagestatistichour.FieldSopRun:
  33538. v, ok := value.(int64)
  33539. if !ok {
  33540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33541. }
  33542. m.AddSopRun(v)
  33543. return nil
  33544. case usagestatistichour.FieldTotalFriend:
  33545. v, ok := value.(int64)
  33546. if !ok {
  33547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33548. }
  33549. m.AddTotalFriend(v)
  33550. return nil
  33551. case usagestatistichour.FieldTotalGroup:
  33552. v, ok := value.(int64)
  33553. if !ok {
  33554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33555. }
  33556. m.AddTotalGroup(v)
  33557. return nil
  33558. case usagestatistichour.FieldAccountBalance:
  33559. v, ok := value.(int64)
  33560. if !ok {
  33561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33562. }
  33563. m.AddAccountBalance(v)
  33564. return nil
  33565. case usagestatistichour.FieldConsumeToken:
  33566. v, ok := value.(int64)
  33567. if !ok {
  33568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33569. }
  33570. m.AddConsumeToken(v)
  33571. return nil
  33572. case usagestatistichour.FieldActiveUser:
  33573. v, ok := value.(int64)
  33574. if !ok {
  33575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33576. }
  33577. m.AddActiveUser(v)
  33578. return nil
  33579. case usagestatistichour.FieldNewUser:
  33580. v, ok := value.(int64)
  33581. if !ok {
  33582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33583. }
  33584. m.AddNewUser(v)
  33585. return nil
  33586. }
  33587. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  33588. }
  33589. // ClearedFields returns all nullable fields that were cleared during this
  33590. // mutation.
  33591. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  33592. var fields []string
  33593. if m.FieldCleared(usagestatistichour.FieldStatus) {
  33594. fields = append(fields, usagestatistichour.FieldStatus)
  33595. }
  33596. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  33597. fields = append(fields, usagestatistichour.FieldDeletedAt)
  33598. }
  33599. if m.FieldCleared(usagestatistichour.FieldBotID) {
  33600. fields = append(fields, usagestatistichour.FieldBotID)
  33601. }
  33602. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  33603. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33604. }
  33605. return fields
  33606. }
  33607. // FieldCleared returns a boolean indicating if a field with the given name was
  33608. // cleared in this mutation.
  33609. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  33610. _, ok := m.clearedFields[name]
  33611. return ok
  33612. }
  33613. // ClearField clears the value of the field with the given name. It returns an
  33614. // error if the field is not defined in the schema.
  33615. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  33616. switch name {
  33617. case usagestatistichour.FieldStatus:
  33618. m.ClearStatus()
  33619. return nil
  33620. case usagestatistichour.FieldDeletedAt:
  33621. m.ClearDeletedAt()
  33622. return nil
  33623. case usagestatistichour.FieldBotID:
  33624. m.ClearBotID()
  33625. return nil
  33626. case usagestatistichour.FieldOrganizationID:
  33627. m.ClearOrganizationID()
  33628. return nil
  33629. }
  33630. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  33631. }
  33632. // ResetField resets all changes in the mutation for the field with the given name.
  33633. // It returns an error if the field is not defined in the schema.
  33634. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  33635. switch name {
  33636. case usagestatistichour.FieldCreatedAt:
  33637. m.ResetCreatedAt()
  33638. return nil
  33639. case usagestatistichour.FieldUpdatedAt:
  33640. m.ResetUpdatedAt()
  33641. return nil
  33642. case usagestatistichour.FieldStatus:
  33643. m.ResetStatus()
  33644. return nil
  33645. case usagestatistichour.FieldDeletedAt:
  33646. m.ResetDeletedAt()
  33647. return nil
  33648. case usagestatistichour.FieldAddtime:
  33649. m.ResetAddtime()
  33650. return nil
  33651. case usagestatistichour.FieldType:
  33652. m.ResetType()
  33653. return nil
  33654. case usagestatistichour.FieldBotID:
  33655. m.ResetBotID()
  33656. return nil
  33657. case usagestatistichour.FieldOrganizationID:
  33658. m.ResetOrganizationID()
  33659. return nil
  33660. case usagestatistichour.FieldAiResponse:
  33661. m.ResetAiResponse()
  33662. return nil
  33663. case usagestatistichour.FieldSopRun:
  33664. m.ResetSopRun()
  33665. return nil
  33666. case usagestatistichour.FieldTotalFriend:
  33667. m.ResetTotalFriend()
  33668. return nil
  33669. case usagestatistichour.FieldTotalGroup:
  33670. m.ResetTotalGroup()
  33671. return nil
  33672. case usagestatistichour.FieldAccountBalance:
  33673. m.ResetAccountBalance()
  33674. return nil
  33675. case usagestatistichour.FieldConsumeToken:
  33676. m.ResetConsumeToken()
  33677. return nil
  33678. case usagestatistichour.FieldActiveUser:
  33679. m.ResetActiveUser()
  33680. return nil
  33681. case usagestatistichour.FieldNewUser:
  33682. m.ResetNewUser()
  33683. return nil
  33684. case usagestatistichour.FieldLabelDist:
  33685. m.ResetLabelDist()
  33686. return nil
  33687. }
  33688. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33689. }
  33690. // AddedEdges returns all edge names that were set/added in this mutation.
  33691. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  33692. edges := make([]string, 0, 0)
  33693. return edges
  33694. }
  33695. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33696. // name in this mutation.
  33697. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  33698. return nil
  33699. }
  33700. // RemovedEdges returns all edge names that were removed in this mutation.
  33701. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  33702. edges := make([]string, 0, 0)
  33703. return edges
  33704. }
  33705. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33706. // the given name in this mutation.
  33707. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  33708. return nil
  33709. }
  33710. // ClearedEdges returns all edge names that were cleared in this mutation.
  33711. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  33712. edges := make([]string, 0, 0)
  33713. return edges
  33714. }
  33715. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33716. // was cleared in this mutation.
  33717. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  33718. return false
  33719. }
  33720. // ClearEdge clears the value of the edge with the given name. It returns an error
  33721. // if that edge is not defined in the schema.
  33722. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  33723. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  33724. }
  33725. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33726. // It returns an error if the edge is not defined in the schema.
  33727. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  33728. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  33729. }
  33730. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  33731. type UsageStatisticMonthMutation struct {
  33732. config
  33733. op Op
  33734. typ string
  33735. id *uint64
  33736. created_at *time.Time
  33737. updated_at *time.Time
  33738. status *uint8
  33739. addstatus *int8
  33740. deleted_at *time.Time
  33741. addtime *uint64
  33742. addaddtime *int64
  33743. _type *int
  33744. add_type *int
  33745. bot_id *string
  33746. organization_id *uint64
  33747. addorganization_id *int64
  33748. ai_response *uint64
  33749. addai_response *int64
  33750. sop_run *uint64
  33751. addsop_run *int64
  33752. total_friend *uint64
  33753. addtotal_friend *int64
  33754. total_group *uint64
  33755. addtotal_group *int64
  33756. account_balance *uint64
  33757. addaccount_balance *int64
  33758. consume_token *uint64
  33759. addconsume_token *int64
  33760. active_user *uint64
  33761. addactive_user *int64
  33762. new_user *int64
  33763. addnew_user *int64
  33764. label_dist *[]custom_types.LabelDist
  33765. appendlabel_dist []custom_types.LabelDist
  33766. clearedFields map[string]struct{}
  33767. done bool
  33768. oldValue func(context.Context) (*UsageStatisticMonth, error)
  33769. predicates []predicate.UsageStatisticMonth
  33770. }
  33771. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  33772. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  33773. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  33774. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  33775. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  33776. m := &UsageStatisticMonthMutation{
  33777. config: c,
  33778. op: op,
  33779. typ: TypeUsageStatisticMonth,
  33780. clearedFields: make(map[string]struct{}),
  33781. }
  33782. for _, opt := range opts {
  33783. opt(m)
  33784. }
  33785. return m
  33786. }
  33787. // withUsageStatisticMonthID sets the ID field of the mutation.
  33788. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  33789. return func(m *UsageStatisticMonthMutation) {
  33790. var (
  33791. err error
  33792. once sync.Once
  33793. value *UsageStatisticMonth
  33794. )
  33795. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  33796. once.Do(func() {
  33797. if m.done {
  33798. err = errors.New("querying old values post mutation is not allowed")
  33799. } else {
  33800. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  33801. }
  33802. })
  33803. return value, err
  33804. }
  33805. m.id = &id
  33806. }
  33807. }
  33808. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  33809. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  33810. return func(m *UsageStatisticMonthMutation) {
  33811. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  33812. return node, nil
  33813. }
  33814. m.id = &node.ID
  33815. }
  33816. }
  33817. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33818. // executed in a transaction (ent.Tx), a transactional client is returned.
  33819. func (m UsageStatisticMonthMutation) Client() *Client {
  33820. client := &Client{config: m.config}
  33821. client.init()
  33822. return client
  33823. }
  33824. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33825. // it returns an error otherwise.
  33826. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  33827. if _, ok := m.driver.(*txDriver); !ok {
  33828. return nil, errors.New("ent: mutation is not running in a transaction")
  33829. }
  33830. tx := &Tx{config: m.config}
  33831. tx.init()
  33832. return tx, nil
  33833. }
  33834. // SetID sets the value of the id field. Note that this
  33835. // operation is only accepted on creation of UsageStatisticMonth entities.
  33836. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  33837. m.id = &id
  33838. }
  33839. // ID returns the ID value in the mutation. Note that the ID is only available
  33840. // if it was provided to the builder or after it was returned from the database.
  33841. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  33842. if m.id == nil {
  33843. return
  33844. }
  33845. return *m.id, true
  33846. }
  33847. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33848. // That means, if the mutation is applied within a transaction with an isolation level such
  33849. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33850. // or updated by the mutation.
  33851. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  33852. switch {
  33853. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33854. id, exists := m.ID()
  33855. if exists {
  33856. return []uint64{id}, nil
  33857. }
  33858. fallthrough
  33859. case m.op.Is(OpUpdate | OpDelete):
  33860. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  33861. default:
  33862. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33863. }
  33864. }
  33865. // SetCreatedAt sets the "created_at" field.
  33866. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  33867. m.created_at = &t
  33868. }
  33869. // CreatedAt returns the value of the "created_at" field in the mutation.
  33870. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  33871. v := m.created_at
  33872. if v == nil {
  33873. return
  33874. }
  33875. return *v, true
  33876. }
  33877. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  33878. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33880. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33881. if !m.op.Is(OpUpdateOne) {
  33882. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33883. }
  33884. if m.id == nil || m.oldValue == nil {
  33885. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33886. }
  33887. oldValue, err := m.oldValue(ctx)
  33888. if err != nil {
  33889. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33890. }
  33891. return oldValue.CreatedAt, nil
  33892. }
  33893. // ResetCreatedAt resets all changes to the "created_at" field.
  33894. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  33895. m.created_at = nil
  33896. }
  33897. // SetUpdatedAt sets the "updated_at" field.
  33898. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  33899. m.updated_at = &t
  33900. }
  33901. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33902. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  33903. v := m.updated_at
  33904. if v == nil {
  33905. return
  33906. }
  33907. return *v, true
  33908. }
  33909. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  33910. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33912. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33913. if !m.op.Is(OpUpdateOne) {
  33914. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33915. }
  33916. if m.id == nil || m.oldValue == nil {
  33917. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33918. }
  33919. oldValue, err := m.oldValue(ctx)
  33920. if err != nil {
  33921. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33922. }
  33923. return oldValue.UpdatedAt, nil
  33924. }
  33925. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33926. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  33927. m.updated_at = nil
  33928. }
  33929. // SetStatus sets the "status" field.
  33930. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  33931. m.status = &u
  33932. m.addstatus = nil
  33933. }
  33934. // Status returns the value of the "status" field in the mutation.
  33935. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  33936. v := m.status
  33937. if v == nil {
  33938. return
  33939. }
  33940. return *v, true
  33941. }
  33942. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  33943. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33945. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33946. if !m.op.Is(OpUpdateOne) {
  33947. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33948. }
  33949. if m.id == nil || m.oldValue == nil {
  33950. return v, errors.New("OldStatus requires an ID field in the mutation")
  33951. }
  33952. oldValue, err := m.oldValue(ctx)
  33953. if err != nil {
  33954. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33955. }
  33956. return oldValue.Status, nil
  33957. }
  33958. // AddStatus adds u to the "status" field.
  33959. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  33960. if m.addstatus != nil {
  33961. *m.addstatus += u
  33962. } else {
  33963. m.addstatus = &u
  33964. }
  33965. }
  33966. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33967. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  33968. v := m.addstatus
  33969. if v == nil {
  33970. return
  33971. }
  33972. return *v, true
  33973. }
  33974. // ClearStatus clears the value of the "status" field.
  33975. func (m *UsageStatisticMonthMutation) ClearStatus() {
  33976. m.status = nil
  33977. m.addstatus = nil
  33978. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  33979. }
  33980. // StatusCleared returns if the "status" field was cleared in this mutation.
  33981. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  33982. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  33983. return ok
  33984. }
  33985. // ResetStatus resets all changes to the "status" field.
  33986. func (m *UsageStatisticMonthMutation) ResetStatus() {
  33987. m.status = nil
  33988. m.addstatus = nil
  33989. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  33990. }
  33991. // SetDeletedAt sets the "deleted_at" field.
  33992. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  33993. m.deleted_at = &t
  33994. }
  33995. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33996. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  33997. v := m.deleted_at
  33998. if v == nil {
  33999. return
  34000. }
  34001. return *v, true
  34002. }
  34003. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  34004. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34006. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34007. if !m.op.Is(OpUpdateOne) {
  34008. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34009. }
  34010. if m.id == nil || m.oldValue == nil {
  34011. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34012. }
  34013. oldValue, err := m.oldValue(ctx)
  34014. if err != nil {
  34015. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34016. }
  34017. return oldValue.DeletedAt, nil
  34018. }
  34019. // ClearDeletedAt clears the value of the "deleted_at" field.
  34020. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  34021. m.deleted_at = nil
  34022. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  34023. }
  34024. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34025. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  34026. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  34027. return ok
  34028. }
  34029. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34030. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  34031. m.deleted_at = nil
  34032. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  34033. }
  34034. // SetAddtime sets the "addtime" field.
  34035. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  34036. m.addtime = &u
  34037. m.addaddtime = nil
  34038. }
  34039. // Addtime returns the value of the "addtime" field in the mutation.
  34040. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  34041. v := m.addtime
  34042. if v == nil {
  34043. return
  34044. }
  34045. return *v, true
  34046. }
  34047. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  34048. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34050. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  34051. if !m.op.Is(OpUpdateOne) {
  34052. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  34053. }
  34054. if m.id == nil || m.oldValue == nil {
  34055. return v, errors.New("OldAddtime requires an ID field in the mutation")
  34056. }
  34057. oldValue, err := m.oldValue(ctx)
  34058. if err != nil {
  34059. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  34060. }
  34061. return oldValue.Addtime, nil
  34062. }
  34063. // AddAddtime adds u to the "addtime" field.
  34064. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  34065. if m.addaddtime != nil {
  34066. *m.addaddtime += u
  34067. } else {
  34068. m.addaddtime = &u
  34069. }
  34070. }
  34071. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  34072. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  34073. v := m.addaddtime
  34074. if v == nil {
  34075. return
  34076. }
  34077. return *v, true
  34078. }
  34079. // ResetAddtime resets all changes to the "addtime" field.
  34080. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  34081. m.addtime = nil
  34082. m.addaddtime = nil
  34083. }
  34084. // SetType sets the "type" field.
  34085. func (m *UsageStatisticMonthMutation) SetType(i int) {
  34086. m._type = &i
  34087. m.add_type = nil
  34088. }
  34089. // GetType returns the value of the "type" field in the mutation.
  34090. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  34091. v := m._type
  34092. if v == nil {
  34093. return
  34094. }
  34095. return *v, true
  34096. }
  34097. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  34098. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34100. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  34101. if !m.op.Is(OpUpdateOne) {
  34102. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34103. }
  34104. if m.id == nil || m.oldValue == nil {
  34105. return v, errors.New("OldType requires an ID field in the mutation")
  34106. }
  34107. oldValue, err := m.oldValue(ctx)
  34108. if err != nil {
  34109. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34110. }
  34111. return oldValue.Type, nil
  34112. }
  34113. // AddType adds i to the "type" field.
  34114. func (m *UsageStatisticMonthMutation) AddType(i int) {
  34115. if m.add_type != nil {
  34116. *m.add_type += i
  34117. } else {
  34118. m.add_type = &i
  34119. }
  34120. }
  34121. // AddedType returns the value that was added to the "type" field in this mutation.
  34122. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  34123. v := m.add_type
  34124. if v == nil {
  34125. return
  34126. }
  34127. return *v, true
  34128. }
  34129. // ResetType resets all changes to the "type" field.
  34130. func (m *UsageStatisticMonthMutation) ResetType() {
  34131. m._type = nil
  34132. m.add_type = nil
  34133. }
  34134. // SetBotID sets the "bot_id" field.
  34135. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  34136. m.bot_id = &s
  34137. }
  34138. // BotID returns the value of the "bot_id" field in the mutation.
  34139. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  34140. v := m.bot_id
  34141. if v == nil {
  34142. return
  34143. }
  34144. return *v, true
  34145. }
  34146. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  34147. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34149. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  34150. if !m.op.Is(OpUpdateOne) {
  34151. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34152. }
  34153. if m.id == nil || m.oldValue == nil {
  34154. return v, errors.New("OldBotID requires an ID field in the mutation")
  34155. }
  34156. oldValue, err := m.oldValue(ctx)
  34157. if err != nil {
  34158. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34159. }
  34160. return oldValue.BotID, nil
  34161. }
  34162. // ClearBotID clears the value of the "bot_id" field.
  34163. func (m *UsageStatisticMonthMutation) ClearBotID() {
  34164. m.bot_id = nil
  34165. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  34166. }
  34167. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  34168. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  34169. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  34170. return ok
  34171. }
  34172. // ResetBotID resets all changes to the "bot_id" field.
  34173. func (m *UsageStatisticMonthMutation) ResetBotID() {
  34174. m.bot_id = nil
  34175. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  34176. }
  34177. // SetOrganizationID sets the "organization_id" field.
  34178. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  34179. m.organization_id = &u
  34180. m.addorganization_id = nil
  34181. }
  34182. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34183. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  34184. v := m.organization_id
  34185. if v == nil {
  34186. return
  34187. }
  34188. return *v, true
  34189. }
  34190. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  34191. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34193. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34194. if !m.op.Is(OpUpdateOne) {
  34195. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34196. }
  34197. if m.id == nil || m.oldValue == nil {
  34198. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34199. }
  34200. oldValue, err := m.oldValue(ctx)
  34201. if err != nil {
  34202. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34203. }
  34204. return oldValue.OrganizationID, nil
  34205. }
  34206. // AddOrganizationID adds u to the "organization_id" field.
  34207. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  34208. if m.addorganization_id != nil {
  34209. *m.addorganization_id += u
  34210. } else {
  34211. m.addorganization_id = &u
  34212. }
  34213. }
  34214. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34215. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  34216. v := m.addorganization_id
  34217. if v == nil {
  34218. return
  34219. }
  34220. return *v, true
  34221. }
  34222. // ClearOrganizationID clears the value of the "organization_id" field.
  34223. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  34224. m.organization_id = nil
  34225. m.addorganization_id = nil
  34226. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  34227. }
  34228. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34229. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  34230. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  34231. return ok
  34232. }
  34233. // ResetOrganizationID resets all changes to the "organization_id" field.
  34234. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  34235. m.organization_id = nil
  34236. m.addorganization_id = nil
  34237. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  34238. }
  34239. // SetAiResponse sets the "ai_response" field.
  34240. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  34241. m.ai_response = &u
  34242. m.addai_response = nil
  34243. }
  34244. // AiResponse returns the value of the "ai_response" field in the mutation.
  34245. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  34246. v := m.ai_response
  34247. if v == nil {
  34248. return
  34249. }
  34250. return *v, true
  34251. }
  34252. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  34253. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34255. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  34256. if !m.op.Is(OpUpdateOne) {
  34257. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  34258. }
  34259. if m.id == nil || m.oldValue == nil {
  34260. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  34261. }
  34262. oldValue, err := m.oldValue(ctx)
  34263. if err != nil {
  34264. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  34265. }
  34266. return oldValue.AiResponse, nil
  34267. }
  34268. // AddAiResponse adds u to the "ai_response" field.
  34269. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  34270. if m.addai_response != nil {
  34271. *m.addai_response += u
  34272. } else {
  34273. m.addai_response = &u
  34274. }
  34275. }
  34276. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  34277. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  34278. v := m.addai_response
  34279. if v == nil {
  34280. return
  34281. }
  34282. return *v, true
  34283. }
  34284. // ResetAiResponse resets all changes to the "ai_response" field.
  34285. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  34286. m.ai_response = nil
  34287. m.addai_response = nil
  34288. }
  34289. // SetSopRun sets the "sop_run" field.
  34290. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  34291. m.sop_run = &u
  34292. m.addsop_run = nil
  34293. }
  34294. // SopRun returns the value of the "sop_run" field in the mutation.
  34295. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  34296. v := m.sop_run
  34297. if v == nil {
  34298. return
  34299. }
  34300. return *v, true
  34301. }
  34302. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  34303. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34305. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34306. if !m.op.Is(OpUpdateOne) {
  34307. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34308. }
  34309. if m.id == nil || m.oldValue == nil {
  34310. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34311. }
  34312. oldValue, err := m.oldValue(ctx)
  34313. if err != nil {
  34314. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34315. }
  34316. return oldValue.SopRun, nil
  34317. }
  34318. // AddSopRun adds u to the "sop_run" field.
  34319. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  34320. if m.addsop_run != nil {
  34321. *m.addsop_run += u
  34322. } else {
  34323. m.addsop_run = &u
  34324. }
  34325. }
  34326. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34327. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  34328. v := m.addsop_run
  34329. if v == nil {
  34330. return
  34331. }
  34332. return *v, true
  34333. }
  34334. // ResetSopRun resets all changes to the "sop_run" field.
  34335. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  34336. m.sop_run = nil
  34337. m.addsop_run = nil
  34338. }
  34339. // SetTotalFriend sets the "total_friend" field.
  34340. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  34341. m.total_friend = &u
  34342. m.addtotal_friend = nil
  34343. }
  34344. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34345. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  34346. v := m.total_friend
  34347. if v == nil {
  34348. return
  34349. }
  34350. return *v, true
  34351. }
  34352. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  34353. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34355. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34356. if !m.op.Is(OpUpdateOne) {
  34357. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34358. }
  34359. if m.id == nil || m.oldValue == nil {
  34360. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34361. }
  34362. oldValue, err := m.oldValue(ctx)
  34363. if err != nil {
  34364. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34365. }
  34366. return oldValue.TotalFriend, nil
  34367. }
  34368. // AddTotalFriend adds u to the "total_friend" field.
  34369. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  34370. if m.addtotal_friend != nil {
  34371. *m.addtotal_friend += u
  34372. } else {
  34373. m.addtotal_friend = &u
  34374. }
  34375. }
  34376. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34377. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  34378. v := m.addtotal_friend
  34379. if v == nil {
  34380. return
  34381. }
  34382. return *v, true
  34383. }
  34384. // ResetTotalFriend resets all changes to the "total_friend" field.
  34385. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  34386. m.total_friend = nil
  34387. m.addtotal_friend = nil
  34388. }
  34389. // SetTotalGroup sets the "total_group" field.
  34390. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  34391. m.total_group = &u
  34392. m.addtotal_group = nil
  34393. }
  34394. // TotalGroup returns the value of the "total_group" field in the mutation.
  34395. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  34396. v := m.total_group
  34397. if v == nil {
  34398. return
  34399. }
  34400. return *v, true
  34401. }
  34402. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  34403. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34405. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34406. if !m.op.Is(OpUpdateOne) {
  34407. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34408. }
  34409. if m.id == nil || m.oldValue == nil {
  34410. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34411. }
  34412. oldValue, err := m.oldValue(ctx)
  34413. if err != nil {
  34414. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34415. }
  34416. return oldValue.TotalGroup, nil
  34417. }
  34418. // AddTotalGroup adds u to the "total_group" field.
  34419. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  34420. if m.addtotal_group != nil {
  34421. *m.addtotal_group += u
  34422. } else {
  34423. m.addtotal_group = &u
  34424. }
  34425. }
  34426. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34427. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  34428. v := m.addtotal_group
  34429. if v == nil {
  34430. return
  34431. }
  34432. return *v, true
  34433. }
  34434. // ResetTotalGroup resets all changes to the "total_group" field.
  34435. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  34436. m.total_group = nil
  34437. m.addtotal_group = nil
  34438. }
  34439. // SetAccountBalance sets the "account_balance" field.
  34440. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  34441. m.account_balance = &u
  34442. m.addaccount_balance = nil
  34443. }
  34444. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34445. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  34446. v := m.account_balance
  34447. if v == nil {
  34448. return
  34449. }
  34450. return *v, true
  34451. }
  34452. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  34453. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34455. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34456. if !m.op.Is(OpUpdateOne) {
  34457. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34458. }
  34459. if m.id == nil || m.oldValue == nil {
  34460. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34461. }
  34462. oldValue, err := m.oldValue(ctx)
  34463. if err != nil {
  34464. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34465. }
  34466. return oldValue.AccountBalance, nil
  34467. }
  34468. // AddAccountBalance adds u to the "account_balance" field.
  34469. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  34470. if m.addaccount_balance != nil {
  34471. *m.addaccount_balance += u
  34472. } else {
  34473. m.addaccount_balance = &u
  34474. }
  34475. }
  34476. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34477. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  34478. v := m.addaccount_balance
  34479. if v == nil {
  34480. return
  34481. }
  34482. return *v, true
  34483. }
  34484. // ResetAccountBalance resets all changes to the "account_balance" field.
  34485. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  34486. m.account_balance = nil
  34487. m.addaccount_balance = nil
  34488. }
  34489. // SetConsumeToken sets the "consume_token" field.
  34490. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  34491. m.consume_token = &u
  34492. m.addconsume_token = nil
  34493. }
  34494. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34495. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  34496. v := m.consume_token
  34497. if v == nil {
  34498. return
  34499. }
  34500. return *v, true
  34501. }
  34502. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  34503. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34505. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34506. if !m.op.Is(OpUpdateOne) {
  34507. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34508. }
  34509. if m.id == nil || m.oldValue == nil {
  34510. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34511. }
  34512. oldValue, err := m.oldValue(ctx)
  34513. if err != nil {
  34514. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34515. }
  34516. return oldValue.ConsumeToken, nil
  34517. }
  34518. // AddConsumeToken adds u to the "consume_token" field.
  34519. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  34520. if m.addconsume_token != nil {
  34521. *m.addconsume_token += u
  34522. } else {
  34523. m.addconsume_token = &u
  34524. }
  34525. }
  34526. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34527. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  34528. v := m.addconsume_token
  34529. if v == nil {
  34530. return
  34531. }
  34532. return *v, true
  34533. }
  34534. // ResetConsumeToken resets all changes to the "consume_token" field.
  34535. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  34536. m.consume_token = nil
  34537. m.addconsume_token = nil
  34538. }
  34539. // SetActiveUser sets the "active_user" field.
  34540. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  34541. m.active_user = &u
  34542. m.addactive_user = nil
  34543. }
  34544. // ActiveUser returns the value of the "active_user" field in the mutation.
  34545. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  34546. v := m.active_user
  34547. if v == nil {
  34548. return
  34549. }
  34550. return *v, true
  34551. }
  34552. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  34553. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34555. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34556. if !m.op.Is(OpUpdateOne) {
  34557. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34558. }
  34559. if m.id == nil || m.oldValue == nil {
  34560. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34561. }
  34562. oldValue, err := m.oldValue(ctx)
  34563. if err != nil {
  34564. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34565. }
  34566. return oldValue.ActiveUser, nil
  34567. }
  34568. // AddActiveUser adds u to the "active_user" field.
  34569. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  34570. if m.addactive_user != nil {
  34571. *m.addactive_user += u
  34572. } else {
  34573. m.addactive_user = &u
  34574. }
  34575. }
  34576. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34577. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  34578. v := m.addactive_user
  34579. if v == nil {
  34580. return
  34581. }
  34582. return *v, true
  34583. }
  34584. // ResetActiveUser resets all changes to the "active_user" field.
  34585. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  34586. m.active_user = nil
  34587. m.addactive_user = nil
  34588. }
  34589. // SetNewUser sets the "new_user" field.
  34590. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  34591. m.new_user = &i
  34592. m.addnew_user = nil
  34593. }
  34594. // NewUser returns the value of the "new_user" field in the mutation.
  34595. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  34596. v := m.new_user
  34597. if v == nil {
  34598. return
  34599. }
  34600. return *v, true
  34601. }
  34602. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  34603. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34605. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34606. if !m.op.Is(OpUpdateOne) {
  34607. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34608. }
  34609. if m.id == nil || m.oldValue == nil {
  34610. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34611. }
  34612. oldValue, err := m.oldValue(ctx)
  34613. if err != nil {
  34614. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34615. }
  34616. return oldValue.NewUser, nil
  34617. }
  34618. // AddNewUser adds i to the "new_user" field.
  34619. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  34620. if m.addnew_user != nil {
  34621. *m.addnew_user += i
  34622. } else {
  34623. m.addnew_user = &i
  34624. }
  34625. }
  34626. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34627. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  34628. v := m.addnew_user
  34629. if v == nil {
  34630. return
  34631. }
  34632. return *v, true
  34633. }
  34634. // ResetNewUser resets all changes to the "new_user" field.
  34635. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  34636. m.new_user = nil
  34637. m.addnew_user = nil
  34638. }
  34639. // SetLabelDist sets the "label_dist" field.
  34640. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34641. m.label_dist = &ctd
  34642. m.appendlabel_dist = nil
  34643. }
  34644. // LabelDist returns the value of the "label_dist" field in the mutation.
  34645. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34646. v := m.label_dist
  34647. if v == nil {
  34648. return
  34649. }
  34650. return *v, true
  34651. }
  34652. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  34653. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34655. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34656. if !m.op.Is(OpUpdateOne) {
  34657. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34658. }
  34659. if m.id == nil || m.oldValue == nil {
  34660. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34661. }
  34662. oldValue, err := m.oldValue(ctx)
  34663. if err != nil {
  34664. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34665. }
  34666. return oldValue.LabelDist, nil
  34667. }
  34668. // AppendLabelDist adds ctd to the "label_dist" field.
  34669. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34670. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34671. }
  34672. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34673. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34674. if len(m.appendlabel_dist) == 0 {
  34675. return nil, false
  34676. }
  34677. return m.appendlabel_dist, true
  34678. }
  34679. // ResetLabelDist resets all changes to the "label_dist" field.
  34680. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  34681. m.label_dist = nil
  34682. m.appendlabel_dist = nil
  34683. }
  34684. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  34685. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  34686. m.predicates = append(m.predicates, ps...)
  34687. }
  34688. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  34689. // users can use type-assertion to append predicates that do not depend on any generated package.
  34690. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  34691. p := make([]predicate.UsageStatisticMonth, len(ps))
  34692. for i := range ps {
  34693. p[i] = ps[i]
  34694. }
  34695. m.Where(p...)
  34696. }
  34697. // Op returns the operation name.
  34698. func (m *UsageStatisticMonthMutation) Op() Op {
  34699. return m.op
  34700. }
  34701. // SetOp allows setting the mutation operation.
  34702. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  34703. m.op = op
  34704. }
  34705. // Type returns the node type of this mutation (UsageStatisticMonth).
  34706. func (m *UsageStatisticMonthMutation) Type() string {
  34707. return m.typ
  34708. }
  34709. // Fields returns all fields that were changed during this mutation. Note that in
  34710. // order to get all numeric fields that were incremented/decremented, call
  34711. // AddedFields().
  34712. func (m *UsageStatisticMonthMutation) Fields() []string {
  34713. fields := make([]string, 0, 17)
  34714. if m.created_at != nil {
  34715. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  34716. }
  34717. if m.updated_at != nil {
  34718. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  34719. }
  34720. if m.status != nil {
  34721. fields = append(fields, usagestatisticmonth.FieldStatus)
  34722. }
  34723. if m.deleted_at != nil {
  34724. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34725. }
  34726. if m.addtime != nil {
  34727. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34728. }
  34729. if m._type != nil {
  34730. fields = append(fields, usagestatisticmonth.FieldType)
  34731. }
  34732. if m.bot_id != nil {
  34733. fields = append(fields, usagestatisticmonth.FieldBotID)
  34734. }
  34735. if m.organization_id != nil {
  34736. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34737. }
  34738. if m.ai_response != nil {
  34739. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34740. }
  34741. if m.sop_run != nil {
  34742. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34743. }
  34744. if m.total_friend != nil {
  34745. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34746. }
  34747. if m.total_group != nil {
  34748. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34749. }
  34750. if m.account_balance != nil {
  34751. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34752. }
  34753. if m.consume_token != nil {
  34754. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34755. }
  34756. if m.active_user != nil {
  34757. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34758. }
  34759. if m.new_user != nil {
  34760. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34761. }
  34762. if m.label_dist != nil {
  34763. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  34764. }
  34765. return fields
  34766. }
  34767. // Field returns the value of a field with the given name. The second boolean
  34768. // return value indicates that this field was not set, or was not defined in the
  34769. // schema.
  34770. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  34771. switch name {
  34772. case usagestatisticmonth.FieldCreatedAt:
  34773. return m.CreatedAt()
  34774. case usagestatisticmonth.FieldUpdatedAt:
  34775. return m.UpdatedAt()
  34776. case usagestatisticmonth.FieldStatus:
  34777. return m.Status()
  34778. case usagestatisticmonth.FieldDeletedAt:
  34779. return m.DeletedAt()
  34780. case usagestatisticmonth.FieldAddtime:
  34781. return m.Addtime()
  34782. case usagestatisticmonth.FieldType:
  34783. return m.GetType()
  34784. case usagestatisticmonth.FieldBotID:
  34785. return m.BotID()
  34786. case usagestatisticmonth.FieldOrganizationID:
  34787. return m.OrganizationID()
  34788. case usagestatisticmonth.FieldAiResponse:
  34789. return m.AiResponse()
  34790. case usagestatisticmonth.FieldSopRun:
  34791. return m.SopRun()
  34792. case usagestatisticmonth.FieldTotalFriend:
  34793. return m.TotalFriend()
  34794. case usagestatisticmonth.FieldTotalGroup:
  34795. return m.TotalGroup()
  34796. case usagestatisticmonth.FieldAccountBalance:
  34797. return m.AccountBalance()
  34798. case usagestatisticmonth.FieldConsumeToken:
  34799. return m.ConsumeToken()
  34800. case usagestatisticmonth.FieldActiveUser:
  34801. return m.ActiveUser()
  34802. case usagestatisticmonth.FieldNewUser:
  34803. return m.NewUser()
  34804. case usagestatisticmonth.FieldLabelDist:
  34805. return m.LabelDist()
  34806. }
  34807. return nil, false
  34808. }
  34809. // OldField returns the old value of the field from the database. An error is
  34810. // returned if the mutation operation is not UpdateOne, or the query to the
  34811. // database failed.
  34812. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34813. switch name {
  34814. case usagestatisticmonth.FieldCreatedAt:
  34815. return m.OldCreatedAt(ctx)
  34816. case usagestatisticmonth.FieldUpdatedAt:
  34817. return m.OldUpdatedAt(ctx)
  34818. case usagestatisticmonth.FieldStatus:
  34819. return m.OldStatus(ctx)
  34820. case usagestatisticmonth.FieldDeletedAt:
  34821. return m.OldDeletedAt(ctx)
  34822. case usagestatisticmonth.FieldAddtime:
  34823. return m.OldAddtime(ctx)
  34824. case usagestatisticmonth.FieldType:
  34825. return m.OldType(ctx)
  34826. case usagestatisticmonth.FieldBotID:
  34827. return m.OldBotID(ctx)
  34828. case usagestatisticmonth.FieldOrganizationID:
  34829. return m.OldOrganizationID(ctx)
  34830. case usagestatisticmonth.FieldAiResponse:
  34831. return m.OldAiResponse(ctx)
  34832. case usagestatisticmonth.FieldSopRun:
  34833. return m.OldSopRun(ctx)
  34834. case usagestatisticmonth.FieldTotalFriend:
  34835. return m.OldTotalFriend(ctx)
  34836. case usagestatisticmonth.FieldTotalGroup:
  34837. return m.OldTotalGroup(ctx)
  34838. case usagestatisticmonth.FieldAccountBalance:
  34839. return m.OldAccountBalance(ctx)
  34840. case usagestatisticmonth.FieldConsumeToken:
  34841. return m.OldConsumeToken(ctx)
  34842. case usagestatisticmonth.FieldActiveUser:
  34843. return m.OldActiveUser(ctx)
  34844. case usagestatisticmonth.FieldNewUser:
  34845. return m.OldNewUser(ctx)
  34846. case usagestatisticmonth.FieldLabelDist:
  34847. return m.OldLabelDist(ctx)
  34848. }
  34849. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34850. }
  34851. // SetField sets the value of a field with the given name. It returns an error if
  34852. // the field is not defined in the schema, or if the type mismatched the field
  34853. // type.
  34854. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  34855. switch name {
  34856. case usagestatisticmonth.FieldCreatedAt:
  34857. v, ok := value.(time.Time)
  34858. if !ok {
  34859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34860. }
  34861. m.SetCreatedAt(v)
  34862. return nil
  34863. case usagestatisticmonth.FieldUpdatedAt:
  34864. v, ok := value.(time.Time)
  34865. if !ok {
  34866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34867. }
  34868. m.SetUpdatedAt(v)
  34869. return nil
  34870. case usagestatisticmonth.FieldStatus:
  34871. v, ok := value.(uint8)
  34872. if !ok {
  34873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34874. }
  34875. m.SetStatus(v)
  34876. return nil
  34877. case usagestatisticmonth.FieldDeletedAt:
  34878. v, ok := value.(time.Time)
  34879. if !ok {
  34880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34881. }
  34882. m.SetDeletedAt(v)
  34883. return nil
  34884. case usagestatisticmonth.FieldAddtime:
  34885. v, ok := value.(uint64)
  34886. if !ok {
  34887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34888. }
  34889. m.SetAddtime(v)
  34890. return nil
  34891. case usagestatisticmonth.FieldType:
  34892. v, ok := value.(int)
  34893. if !ok {
  34894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34895. }
  34896. m.SetType(v)
  34897. return nil
  34898. case usagestatisticmonth.FieldBotID:
  34899. v, ok := value.(string)
  34900. if !ok {
  34901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34902. }
  34903. m.SetBotID(v)
  34904. return nil
  34905. case usagestatisticmonth.FieldOrganizationID:
  34906. v, ok := value.(uint64)
  34907. if !ok {
  34908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34909. }
  34910. m.SetOrganizationID(v)
  34911. return nil
  34912. case usagestatisticmonth.FieldAiResponse:
  34913. v, ok := value.(uint64)
  34914. if !ok {
  34915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34916. }
  34917. m.SetAiResponse(v)
  34918. return nil
  34919. case usagestatisticmonth.FieldSopRun:
  34920. v, ok := value.(uint64)
  34921. if !ok {
  34922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34923. }
  34924. m.SetSopRun(v)
  34925. return nil
  34926. case usagestatisticmonth.FieldTotalFriend:
  34927. v, ok := value.(uint64)
  34928. if !ok {
  34929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34930. }
  34931. m.SetTotalFriend(v)
  34932. return nil
  34933. case usagestatisticmonth.FieldTotalGroup:
  34934. v, ok := value.(uint64)
  34935. if !ok {
  34936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34937. }
  34938. m.SetTotalGroup(v)
  34939. return nil
  34940. case usagestatisticmonth.FieldAccountBalance:
  34941. v, ok := value.(uint64)
  34942. if !ok {
  34943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34944. }
  34945. m.SetAccountBalance(v)
  34946. return nil
  34947. case usagestatisticmonth.FieldConsumeToken:
  34948. v, ok := value.(uint64)
  34949. if !ok {
  34950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34951. }
  34952. m.SetConsumeToken(v)
  34953. return nil
  34954. case usagestatisticmonth.FieldActiveUser:
  34955. v, ok := value.(uint64)
  34956. if !ok {
  34957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34958. }
  34959. m.SetActiveUser(v)
  34960. return nil
  34961. case usagestatisticmonth.FieldNewUser:
  34962. v, ok := value.(int64)
  34963. if !ok {
  34964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34965. }
  34966. m.SetNewUser(v)
  34967. return nil
  34968. case usagestatisticmonth.FieldLabelDist:
  34969. v, ok := value.([]custom_types.LabelDist)
  34970. if !ok {
  34971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34972. }
  34973. m.SetLabelDist(v)
  34974. return nil
  34975. }
  34976. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34977. }
  34978. // AddedFields returns all numeric fields that were incremented/decremented during
  34979. // this mutation.
  34980. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  34981. var fields []string
  34982. if m.addstatus != nil {
  34983. fields = append(fields, usagestatisticmonth.FieldStatus)
  34984. }
  34985. if m.addaddtime != nil {
  34986. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34987. }
  34988. if m.add_type != nil {
  34989. fields = append(fields, usagestatisticmonth.FieldType)
  34990. }
  34991. if m.addorganization_id != nil {
  34992. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34993. }
  34994. if m.addai_response != nil {
  34995. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34996. }
  34997. if m.addsop_run != nil {
  34998. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34999. }
  35000. if m.addtotal_friend != nil {
  35001. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  35002. }
  35003. if m.addtotal_group != nil {
  35004. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  35005. }
  35006. if m.addaccount_balance != nil {
  35007. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  35008. }
  35009. if m.addconsume_token != nil {
  35010. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  35011. }
  35012. if m.addactive_user != nil {
  35013. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  35014. }
  35015. if m.addnew_user != nil {
  35016. fields = append(fields, usagestatisticmonth.FieldNewUser)
  35017. }
  35018. return fields
  35019. }
  35020. // AddedField returns the numeric value that was incremented/decremented on a field
  35021. // with the given name. The second boolean return value indicates that this field
  35022. // was not set, or was not defined in the schema.
  35023. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  35024. switch name {
  35025. case usagestatisticmonth.FieldStatus:
  35026. return m.AddedStatus()
  35027. case usagestatisticmonth.FieldAddtime:
  35028. return m.AddedAddtime()
  35029. case usagestatisticmonth.FieldType:
  35030. return m.AddedType()
  35031. case usagestatisticmonth.FieldOrganizationID:
  35032. return m.AddedOrganizationID()
  35033. case usagestatisticmonth.FieldAiResponse:
  35034. return m.AddedAiResponse()
  35035. case usagestatisticmonth.FieldSopRun:
  35036. return m.AddedSopRun()
  35037. case usagestatisticmonth.FieldTotalFriend:
  35038. return m.AddedTotalFriend()
  35039. case usagestatisticmonth.FieldTotalGroup:
  35040. return m.AddedTotalGroup()
  35041. case usagestatisticmonth.FieldAccountBalance:
  35042. return m.AddedAccountBalance()
  35043. case usagestatisticmonth.FieldConsumeToken:
  35044. return m.AddedConsumeToken()
  35045. case usagestatisticmonth.FieldActiveUser:
  35046. return m.AddedActiveUser()
  35047. case usagestatisticmonth.FieldNewUser:
  35048. return m.AddedNewUser()
  35049. }
  35050. return nil, false
  35051. }
  35052. // AddField adds the value to the field with the given name. It returns an error if
  35053. // the field is not defined in the schema, or if the type mismatched the field
  35054. // type.
  35055. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  35056. switch name {
  35057. case usagestatisticmonth.FieldStatus:
  35058. v, ok := value.(int8)
  35059. if !ok {
  35060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35061. }
  35062. m.AddStatus(v)
  35063. return nil
  35064. case usagestatisticmonth.FieldAddtime:
  35065. v, ok := value.(int64)
  35066. if !ok {
  35067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35068. }
  35069. m.AddAddtime(v)
  35070. return nil
  35071. case usagestatisticmonth.FieldType:
  35072. v, ok := value.(int)
  35073. if !ok {
  35074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35075. }
  35076. m.AddType(v)
  35077. return nil
  35078. case usagestatisticmonth.FieldOrganizationID:
  35079. v, ok := value.(int64)
  35080. if !ok {
  35081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35082. }
  35083. m.AddOrganizationID(v)
  35084. return nil
  35085. case usagestatisticmonth.FieldAiResponse:
  35086. v, ok := value.(int64)
  35087. if !ok {
  35088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35089. }
  35090. m.AddAiResponse(v)
  35091. return nil
  35092. case usagestatisticmonth.FieldSopRun:
  35093. v, ok := value.(int64)
  35094. if !ok {
  35095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35096. }
  35097. m.AddSopRun(v)
  35098. return nil
  35099. case usagestatisticmonth.FieldTotalFriend:
  35100. v, ok := value.(int64)
  35101. if !ok {
  35102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35103. }
  35104. m.AddTotalFriend(v)
  35105. return nil
  35106. case usagestatisticmonth.FieldTotalGroup:
  35107. v, ok := value.(int64)
  35108. if !ok {
  35109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35110. }
  35111. m.AddTotalGroup(v)
  35112. return nil
  35113. case usagestatisticmonth.FieldAccountBalance:
  35114. v, ok := value.(int64)
  35115. if !ok {
  35116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35117. }
  35118. m.AddAccountBalance(v)
  35119. return nil
  35120. case usagestatisticmonth.FieldConsumeToken:
  35121. v, ok := value.(int64)
  35122. if !ok {
  35123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35124. }
  35125. m.AddConsumeToken(v)
  35126. return nil
  35127. case usagestatisticmonth.FieldActiveUser:
  35128. v, ok := value.(int64)
  35129. if !ok {
  35130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35131. }
  35132. m.AddActiveUser(v)
  35133. return nil
  35134. case usagestatisticmonth.FieldNewUser:
  35135. v, ok := value.(int64)
  35136. if !ok {
  35137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35138. }
  35139. m.AddNewUser(v)
  35140. return nil
  35141. }
  35142. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  35143. }
  35144. // ClearedFields returns all nullable fields that were cleared during this
  35145. // mutation.
  35146. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  35147. var fields []string
  35148. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  35149. fields = append(fields, usagestatisticmonth.FieldStatus)
  35150. }
  35151. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  35152. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  35153. }
  35154. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  35155. fields = append(fields, usagestatisticmonth.FieldBotID)
  35156. }
  35157. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  35158. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  35159. }
  35160. return fields
  35161. }
  35162. // FieldCleared returns a boolean indicating if a field with the given name was
  35163. // cleared in this mutation.
  35164. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  35165. _, ok := m.clearedFields[name]
  35166. return ok
  35167. }
  35168. // ClearField clears the value of the field with the given name. It returns an
  35169. // error if the field is not defined in the schema.
  35170. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  35171. switch name {
  35172. case usagestatisticmonth.FieldStatus:
  35173. m.ClearStatus()
  35174. return nil
  35175. case usagestatisticmonth.FieldDeletedAt:
  35176. m.ClearDeletedAt()
  35177. return nil
  35178. case usagestatisticmonth.FieldBotID:
  35179. m.ClearBotID()
  35180. return nil
  35181. case usagestatisticmonth.FieldOrganizationID:
  35182. m.ClearOrganizationID()
  35183. return nil
  35184. }
  35185. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  35186. }
  35187. // ResetField resets all changes in the mutation for the field with the given name.
  35188. // It returns an error if the field is not defined in the schema.
  35189. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  35190. switch name {
  35191. case usagestatisticmonth.FieldCreatedAt:
  35192. m.ResetCreatedAt()
  35193. return nil
  35194. case usagestatisticmonth.FieldUpdatedAt:
  35195. m.ResetUpdatedAt()
  35196. return nil
  35197. case usagestatisticmonth.FieldStatus:
  35198. m.ResetStatus()
  35199. return nil
  35200. case usagestatisticmonth.FieldDeletedAt:
  35201. m.ResetDeletedAt()
  35202. return nil
  35203. case usagestatisticmonth.FieldAddtime:
  35204. m.ResetAddtime()
  35205. return nil
  35206. case usagestatisticmonth.FieldType:
  35207. m.ResetType()
  35208. return nil
  35209. case usagestatisticmonth.FieldBotID:
  35210. m.ResetBotID()
  35211. return nil
  35212. case usagestatisticmonth.FieldOrganizationID:
  35213. m.ResetOrganizationID()
  35214. return nil
  35215. case usagestatisticmonth.FieldAiResponse:
  35216. m.ResetAiResponse()
  35217. return nil
  35218. case usagestatisticmonth.FieldSopRun:
  35219. m.ResetSopRun()
  35220. return nil
  35221. case usagestatisticmonth.FieldTotalFriend:
  35222. m.ResetTotalFriend()
  35223. return nil
  35224. case usagestatisticmonth.FieldTotalGroup:
  35225. m.ResetTotalGroup()
  35226. return nil
  35227. case usagestatisticmonth.FieldAccountBalance:
  35228. m.ResetAccountBalance()
  35229. return nil
  35230. case usagestatisticmonth.FieldConsumeToken:
  35231. m.ResetConsumeToken()
  35232. return nil
  35233. case usagestatisticmonth.FieldActiveUser:
  35234. m.ResetActiveUser()
  35235. return nil
  35236. case usagestatisticmonth.FieldNewUser:
  35237. m.ResetNewUser()
  35238. return nil
  35239. case usagestatisticmonth.FieldLabelDist:
  35240. m.ResetLabelDist()
  35241. return nil
  35242. }
  35243. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  35244. }
  35245. // AddedEdges returns all edge names that were set/added in this mutation.
  35246. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  35247. edges := make([]string, 0, 0)
  35248. return edges
  35249. }
  35250. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35251. // name in this mutation.
  35252. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  35253. return nil
  35254. }
  35255. // RemovedEdges returns all edge names that were removed in this mutation.
  35256. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  35257. edges := make([]string, 0, 0)
  35258. return edges
  35259. }
  35260. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35261. // the given name in this mutation.
  35262. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  35263. return nil
  35264. }
  35265. // ClearedEdges returns all edge names that were cleared in this mutation.
  35266. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  35267. edges := make([]string, 0, 0)
  35268. return edges
  35269. }
  35270. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35271. // was cleared in this mutation.
  35272. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  35273. return false
  35274. }
  35275. // ClearEdge clears the value of the edge with the given name. It returns an error
  35276. // if that edge is not defined in the schema.
  35277. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  35278. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  35279. }
  35280. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35281. // It returns an error if the edge is not defined in the schema.
  35282. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  35283. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  35284. }
  35285. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  35286. type UsageTotalMutation struct {
  35287. config
  35288. op Op
  35289. typ string
  35290. id *uint64
  35291. created_at *time.Time
  35292. updated_at *time.Time
  35293. status *uint8
  35294. addstatus *int8
  35295. _type *int
  35296. add_type *int
  35297. bot_id *string
  35298. total_tokens *uint64
  35299. addtotal_tokens *int64
  35300. start_index *uint64
  35301. addstart_index *int64
  35302. end_index *uint64
  35303. addend_index *int64
  35304. organization_id *uint64
  35305. addorganization_id *int64
  35306. clearedFields map[string]struct{}
  35307. done bool
  35308. oldValue func(context.Context) (*UsageTotal, error)
  35309. predicates []predicate.UsageTotal
  35310. }
  35311. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  35312. // usagetotalOption allows management of the mutation configuration using functional options.
  35313. type usagetotalOption func(*UsageTotalMutation)
  35314. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  35315. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  35316. m := &UsageTotalMutation{
  35317. config: c,
  35318. op: op,
  35319. typ: TypeUsageTotal,
  35320. clearedFields: make(map[string]struct{}),
  35321. }
  35322. for _, opt := range opts {
  35323. opt(m)
  35324. }
  35325. return m
  35326. }
  35327. // withUsageTotalID sets the ID field of the mutation.
  35328. func withUsageTotalID(id uint64) usagetotalOption {
  35329. return func(m *UsageTotalMutation) {
  35330. var (
  35331. err error
  35332. once sync.Once
  35333. value *UsageTotal
  35334. )
  35335. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  35336. once.Do(func() {
  35337. if m.done {
  35338. err = errors.New("querying old values post mutation is not allowed")
  35339. } else {
  35340. value, err = m.Client().UsageTotal.Get(ctx, id)
  35341. }
  35342. })
  35343. return value, err
  35344. }
  35345. m.id = &id
  35346. }
  35347. }
  35348. // withUsageTotal sets the old UsageTotal of the mutation.
  35349. func withUsageTotal(node *UsageTotal) usagetotalOption {
  35350. return func(m *UsageTotalMutation) {
  35351. m.oldValue = func(context.Context) (*UsageTotal, error) {
  35352. return node, nil
  35353. }
  35354. m.id = &node.ID
  35355. }
  35356. }
  35357. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35358. // executed in a transaction (ent.Tx), a transactional client is returned.
  35359. func (m UsageTotalMutation) Client() *Client {
  35360. client := &Client{config: m.config}
  35361. client.init()
  35362. return client
  35363. }
  35364. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35365. // it returns an error otherwise.
  35366. func (m UsageTotalMutation) Tx() (*Tx, error) {
  35367. if _, ok := m.driver.(*txDriver); !ok {
  35368. return nil, errors.New("ent: mutation is not running in a transaction")
  35369. }
  35370. tx := &Tx{config: m.config}
  35371. tx.init()
  35372. return tx, nil
  35373. }
  35374. // SetID sets the value of the id field. Note that this
  35375. // operation is only accepted on creation of UsageTotal entities.
  35376. func (m *UsageTotalMutation) SetID(id uint64) {
  35377. m.id = &id
  35378. }
  35379. // ID returns the ID value in the mutation. Note that the ID is only available
  35380. // if it was provided to the builder or after it was returned from the database.
  35381. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  35382. if m.id == nil {
  35383. return
  35384. }
  35385. return *m.id, true
  35386. }
  35387. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35388. // That means, if the mutation is applied within a transaction with an isolation level such
  35389. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35390. // or updated by the mutation.
  35391. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  35392. switch {
  35393. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35394. id, exists := m.ID()
  35395. if exists {
  35396. return []uint64{id}, nil
  35397. }
  35398. fallthrough
  35399. case m.op.Is(OpUpdate | OpDelete):
  35400. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  35401. default:
  35402. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35403. }
  35404. }
  35405. // SetCreatedAt sets the "created_at" field.
  35406. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  35407. m.created_at = &t
  35408. }
  35409. // CreatedAt returns the value of the "created_at" field in the mutation.
  35410. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  35411. v := m.created_at
  35412. if v == nil {
  35413. return
  35414. }
  35415. return *v, true
  35416. }
  35417. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  35418. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35420. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35421. if !m.op.Is(OpUpdateOne) {
  35422. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35423. }
  35424. if m.id == nil || m.oldValue == nil {
  35425. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35426. }
  35427. oldValue, err := m.oldValue(ctx)
  35428. if err != nil {
  35429. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35430. }
  35431. return oldValue.CreatedAt, nil
  35432. }
  35433. // ResetCreatedAt resets all changes to the "created_at" field.
  35434. func (m *UsageTotalMutation) ResetCreatedAt() {
  35435. m.created_at = nil
  35436. }
  35437. // SetUpdatedAt sets the "updated_at" field.
  35438. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  35439. m.updated_at = &t
  35440. }
  35441. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35442. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  35443. v := m.updated_at
  35444. if v == nil {
  35445. return
  35446. }
  35447. return *v, true
  35448. }
  35449. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  35450. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35452. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35453. if !m.op.Is(OpUpdateOne) {
  35454. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35455. }
  35456. if m.id == nil || m.oldValue == nil {
  35457. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35458. }
  35459. oldValue, err := m.oldValue(ctx)
  35460. if err != nil {
  35461. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35462. }
  35463. return oldValue.UpdatedAt, nil
  35464. }
  35465. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35466. func (m *UsageTotalMutation) ResetUpdatedAt() {
  35467. m.updated_at = nil
  35468. }
  35469. // SetStatus sets the "status" field.
  35470. func (m *UsageTotalMutation) SetStatus(u uint8) {
  35471. m.status = &u
  35472. m.addstatus = nil
  35473. }
  35474. // Status returns the value of the "status" field in the mutation.
  35475. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  35476. v := m.status
  35477. if v == nil {
  35478. return
  35479. }
  35480. return *v, true
  35481. }
  35482. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  35483. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35485. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35486. if !m.op.Is(OpUpdateOne) {
  35487. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35488. }
  35489. if m.id == nil || m.oldValue == nil {
  35490. return v, errors.New("OldStatus requires an ID field in the mutation")
  35491. }
  35492. oldValue, err := m.oldValue(ctx)
  35493. if err != nil {
  35494. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35495. }
  35496. return oldValue.Status, nil
  35497. }
  35498. // AddStatus adds u to the "status" field.
  35499. func (m *UsageTotalMutation) AddStatus(u int8) {
  35500. if m.addstatus != nil {
  35501. *m.addstatus += u
  35502. } else {
  35503. m.addstatus = &u
  35504. }
  35505. }
  35506. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35507. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  35508. v := m.addstatus
  35509. if v == nil {
  35510. return
  35511. }
  35512. return *v, true
  35513. }
  35514. // ClearStatus clears the value of the "status" field.
  35515. func (m *UsageTotalMutation) ClearStatus() {
  35516. m.status = nil
  35517. m.addstatus = nil
  35518. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  35519. }
  35520. // StatusCleared returns if the "status" field was cleared in this mutation.
  35521. func (m *UsageTotalMutation) StatusCleared() bool {
  35522. _, ok := m.clearedFields[usagetotal.FieldStatus]
  35523. return ok
  35524. }
  35525. // ResetStatus resets all changes to the "status" field.
  35526. func (m *UsageTotalMutation) ResetStatus() {
  35527. m.status = nil
  35528. m.addstatus = nil
  35529. delete(m.clearedFields, usagetotal.FieldStatus)
  35530. }
  35531. // SetType sets the "type" field.
  35532. func (m *UsageTotalMutation) SetType(i int) {
  35533. m._type = &i
  35534. m.add_type = nil
  35535. }
  35536. // GetType returns the value of the "type" field in the mutation.
  35537. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  35538. v := m._type
  35539. if v == nil {
  35540. return
  35541. }
  35542. return *v, true
  35543. }
  35544. // OldType returns the old "type" field's value of the UsageTotal entity.
  35545. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35547. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  35548. if !m.op.Is(OpUpdateOne) {
  35549. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35550. }
  35551. if m.id == nil || m.oldValue == nil {
  35552. return v, errors.New("OldType requires an ID field in the mutation")
  35553. }
  35554. oldValue, err := m.oldValue(ctx)
  35555. if err != nil {
  35556. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35557. }
  35558. return oldValue.Type, nil
  35559. }
  35560. // AddType adds i to the "type" field.
  35561. func (m *UsageTotalMutation) AddType(i int) {
  35562. if m.add_type != nil {
  35563. *m.add_type += i
  35564. } else {
  35565. m.add_type = &i
  35566. }
  35567. }
  35568. // AddedType returns the value that was added to the "type" field in this mutation.
  35569. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  35570. v := m.add_type
  35571. if v == nil {
  35572. return
  35573. }
  35574. return *v, true
  35575. }
  35576. // ClearType clears the value of the "type" field.
  35577. func (m *UsageTotalMutation) ClearType() {
  35578. m._type = nil
  35579. m.add_type = nil
  35580. m.clearedFields[usagetotal.FieldType] = struct{}{}
  35581. }
  35582. // TypeCleared returns if the "type" field was cleared in this mutation.
  35583. func (m *UsageTotalMutation) TypeCleared() bool {
  35584. _, ok := m.clearedFields[usagetotal.FieldType]
  35585. return ok
  35586. }
  35587. // ResetType resets all changes to the "type" field.
  35588. func (m *UsageTotalMutation) ResetType() {
  35589. m._type = nil
  35590. m.add_type = nil
  35591. delete(m.clearedFields, usagetotal.FieldType)
  35592. }
  35593. // SetBotID sets the "bot_id" field.
  35594. func (m *UsageTotalMutation) SetBotID(s string) {
  35595. m.bot_id = &s
  35596. }
  35597. // BotID returns the value of the "bot_id" field in the mutation.
  35598. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  35599. v := m.bot_id
  35600. if v == nil {
  35601. return
  35602. }
  35603. return *v, true
  35604. }
  35605. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  35606. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35608. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  35609. if !m.op.Is(OpUpdateOne) {
  35610. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35611. }
  35612. if m.id == nil || m.oldValue == nil {
  35613. return v, errors.New("OldBotID requires an ID field in the mutation")
  35614. }
  35615. oldValue, err := m.oldValue(ctx)
  35616. if err != nil {
  35617. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35618. }
  35619. return oldValue.BotID, nil
  35620. }
  35621. // ResetBotID resets all changes to the "bot_id" field.
  35622. func (m *UsageTotalMutation) ResetBotID() {
  35623. m.bot_id = nil
  35624. }
  35625. // SetTotalTokens sets the "total_tokens" field.
  35626. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  35627. m.total_tokens = &u
  35628. m.addtotal_tokens = nil
  35629. }
  35630. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  35631. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  35632. v := m.total_tokens
  35633. if v == nil {
  35634. return
  35635. }
  35636. return *v, true
  35637. }
  35638. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  35639. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35641. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  35642. if !m.op.Is(OpUpdateOne) {
  35643. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  35644. }
  35645. if m.id == nil || m.oldValue == nil {
  35646. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  35647. }
  35648. oldValue, err := m.oldValue(ctx)
  35649. if err != nil {
  35650. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  35651. }
  35652. return oldValue.TotalTokens, nil
  35653. }
  35654. // AddTotalTokens adds u to the "total_tokens" field.
  35655. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  35656. if m.addtotal_tokens != nil {
  35657. *m.addtotal_tokens += u
  35658. } else {
  35659. m.addtotal_tokens = &u
  35660. }
  35661. }
  35662. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  35663. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  35664. v := m.addtotal_tokens
  35665. if v == nil {
  35666. return
  35667. }
  35668. return *v, true
  35669. }
  35670. // ClearTotalTokens clears the value of the "total_tokens" field.
  35671. func (m *UsageTotalMutation) ClearTotalTokens() {
  35672. m.total_tokens = nil
  35673. m.addtotal_tokens = nil
  35674. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  35675. }
  35676. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  35677. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  35678. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  35679. return ok
  35680. }
  35681. // ResetTotalTokens resets all changes to the "total_tokens" field.
  35682. func (m *UsageTotalMutation) ResetTotalTokens() {
  35683. m.total_tokens = nil
  35684. m.addtotal_tokens = nil
  35685. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  35686. }
  35687. // SetStartIndex sets the "start_index" field.
  35688. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  35689. m.start_index = &u
  35690. m.addstart_index = nil
  35691. }
  35692. // StartIndex returns the value of the "start_index" field in the mutation.
  35693. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  35694. v := m.start_index
  35695. if v == nil {
  35696. return
  35697. }
  35698. return *v, true
  35699. }
  35700. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  35701. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35703. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  35704. if !m.op.Is(OpUpdateOne) {
  35705. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  35706. }
  35707. if m.id == nil || m.oldValue == nil {
  35708. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  35709. }
  35710. oldValue, err := m.oldValue(ctx)
  35711. if err != nil {
  35712. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  35713. }
  35714. return oldValue.StartIndex, nil
  35715. }
  35716. // AddStartIndex adds u to the "start_index" field.
  35717. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  35718. if m.addstart_index != nil {
  35719. *m.addstart_index += u
  35720. } else {
  35721. m.addstart_index = &u
  35722. }
  35723. }
  35724. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  35725. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  35726. v := m.addstart_index
  35727. if v == nil {
  35728. return
  35729. }
  35730. return *v, true
  35731. }
  35732. // ClearStartIndex clears the value of the "start_index" field.
  35733. func (m *UsageTotalMutation) ClearStartIndex() {
  35734. m.start_index = nil
  35735. m.addstart_index = nil
  35736. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  35737. }
  35738. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  35739. func (m *UsageTotalMutation) StartIndexCleared() bool {
  35740. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  35741. return ok
  35742. }
  35743. // ResetStartIndex resets all changes to the "start_index" field.
  35744. func (m *UsageTotalMutation) ResetStartIndex() {
  35745. m.start_index = nil
  35746. m.addstart_index = nil
  35747. delete(m.clearedFields, usagetotal.FieldStartIndex)
  35748. }
  35749. // SetEndIndex sets the "end_index" field.
  35750. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  35751. m.end_index = &u
  35752. m.addend_index = nil
  35753. }
  35754. // EndIndex returns the value of the "end_index" field in the mutation.
  35755. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  35756. v := m.end_index
  35757. if v == nil {
  35758. return
  35759. }
  35760. return *v, true
  35761. }
  35762. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  35763. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35765. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  35766. if !m.op.Is(OpUpdateOne) {
  35767. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  35768. }
  35769. if m.id == nil || m.oldValue == nil {
  35770. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  35771. }
  35772. oldValue, err := m.oldValue(ctx)
  35773. if err != nil {
  35774. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  35775. }
  35776. return oldValue.EndIndex, nil
  35777. }
  35778. // AddEndIndex adds u to the "end_index" field.
  35779. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  35780. if m.addend_index != nil {
  35781. *m.addend_index += u
  35782. } else {
  35783. m.addend_index = &u
  35784. }
  35785. }
  35786. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  35787. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  35788. v := m.addend_index
  35789. if v == nil {
  35790. return
  35791. }
  35792. return *v, true
  35793. }
  35794. // ClearEndIndex clears the value of the "end_index" field.
  35795. func (m *UsageTotalMutation) ClearEndIndex() {
  35796. m.end_index = nil
  35797. m.addend_index = nil
  35798. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  35799. }
  35800. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  35801. func (m *UsageTotalMutation) EndIndexCleared() bool {
  35802. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  35803. return ok
  35804. }
  35805. // ResetEndIndex resets all changes to the "end_index" field.
  35806. func (m *UsageTotalMutation) ResetEndIndex() {
  35807. m.end_index = nil
  35808. m.addend_index = nil
  35809. delete(m.clearedFields, usagetotal.FieldEndIndex)
  35810. }
  35811. // SetOrganizationID sets the "organization_id" field.
  35812. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  35813. m.organization_id = &u
  35814. m.addorganization_id = nil
  35815. }
  35816. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35817. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  35818. v := m.organization_id
  35819. if v == nil {
  35820. return
  35821. }
  35822. return *v, true
  35823. }
  35824. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  35825. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35827. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35828. if !m.op.Is(OpUpdateOne) {
  35829. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35830. }
  35831. if m.id == nil || m.oldValue == nil {
  35832. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35833. }
  35834. oldValue, err := m.oldValue(ctx)
  35835. if err != nil {
  35836. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35837. }
  35838. return oldValue.OrganizationID, nil
  35839. }
  35840. // AddOrganizationID adds u to the "organization_id" field.
  35841. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  35842. if m.addorganization_id != nil {
  35843. *m.addorganization_id += u
  35844. } else {
  35845. m.addorganization_id = &u
  35846. }
  35847. }
  35848. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35849. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  35850. v := m.addorganization_id
  35851. if v == nil {
  35852. return
  35853. }
  35854. return *v, true
  35855. }
  35856. // ClearOrganizationID clears the value of the "organization_id" field.
  35857. func (m *UsageTotalMutation) ClearOrganizationID() {
  35858. m.organization_id = nil
  35859. m.addorganization_id = nil
  35860. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  35861. }
  35862. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35863. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  35864. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  35865. return ok
  35866. }
  35867. // ResetOrganizationID resets all changes to the "organization_id" field.
  35868. func (m *UsageTotalMutation) ResetOrganizationID() {
  35869. m.organization_id = nil
  35870. m.addorganization_id = nil
  35871. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  35872. }
  35873. // Where appends a list predicates to the UsageTotalMutation builder.
  35874. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  35875. m.predicates = append(m.predicates, ps...)
  35876. }
  35877. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  35878. // users can use type-assertion to append predicates that do not depend on any generated package.
  35879. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  35880. p := make([]predicate.UsageTotal, len(ps))
  35881. for i := range ps {
  35882. p[i] = ps[i]
  35883. }
  35884. m.Where(p...)
  35885. }
  35886. // Op returns the operation name.
  35887. func (m *UsageTotalMutation) Op() Op {
  35888. return m.op
  35889. }
  35890. // SetOp allows setting the mutation operation.
  35891. func (m *UsageTotalMutation) SetOp(op Op) {
  35892. m.op = op
  35893. }
  35894. // Type returns the node type of this mutation (UsageTotal).
  35895. func (m *UsageTotalMutation) Type() string {
  35896. return m.typ
  35897. }
  35898. // Fields returns all fields that were changed during this mutation. Note that in
  35899. // order to get all numeric fields that were incremented/decremented, call
  35900. // AddedFields().
  35901. func (m *UsageTotalMutation) Fields() []string {
  35902. fields := make([]string, 0, 9)
  35903. if m.created_at != nil {
  35904. fields = append(fields, usagetotal.FieldCreatedAt)
  35905. }
  35906. if m.updated_at != nil {
  35907. fields = append(fields, usagetotal.FieldUpdatedAt)
  35908. }
  35909. if m.status != nil {
  35910. fields = append(fields, usagetotal.FieldStatus)
  35911. }
  35912. if m._type != nil {
  35913. fields = append(fields, usagetotal.FieldType)
  35914. }
  35915. if m.bot_id != nil {
  35916. fields = append(fields, usagetotal.FieldBotID)
  35917. }
  35918. if m.total_tokens != nil {
  35919. fields = append(fields, usagetotal.FieldTotalTokens)
  35920. }
  35921. if m.start_index != nil {
  35922. fields = append(fields, usagetotal.FieldStartIndex)
  35923. }
  35924. if m.end_index != nil {
  35925. fields = append(fields, usagetotal.FieldEndIndex)
  35926. }
  35927. if m.organization_id != nil {
  35928. fields = append(fields, usagetotal.FieldOrganizationID)
  35929. }
  35930. return fields
  35931. }
  35932. // Field returns the value of a field with the given name. The second boolean
  35933. // return value indicates that this field was not set, or was not defined in the
  35934. // schema.
  35935. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  35936. switch name {
  35937. case usagetotal.FieldCreatedAt:
  35938. return m.CreatedAt()
  35939. case usagetotal.FieldUpdatedAt:
  35940. return m.UpdatedAt()
  35941. case usagetotal.FieldStatus:
  35942. return m.Status()
  35943. case usagetotal.FieldType:
  35944. return m.GetType()
  35945. case usagetotal.FieldBotID:
  35946. return m.BotID()
  35947. case usagetotal.FieldTotalTokens:
  35948. return m.TotalTokens()
  35949. case usagetotal.FieldStartIndex:
  35950. return m.StartIndex()
  35951. case usagetotal.FieldEndIndex:
  35952. return m.EndIndex()
  35953. case usagetotal.FieldOrganizationID:
  35954. return m.OrganizationID()
  35955. }
  35956. return nil, false
  35957. }
  35958. // OldField returns the old value of the field from the database. An error is
  35959. // returned if the mutation operation is not UpdateOne, or the query to the
  35960. // database failed.
  35961. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35962. switch name {
  35963. case usagetotal.FieldCreatedAt:
  35964. return m.OldCreatedAt(ctx)
  35965. case usagetotal.FieldUpdatedAt:
  35966. return m.OldUpdatedAt(ctx)
  35967. case usagetotal.FieldStatus:
  35968. return m.OldStatus(ctx)
  35969. case usagetotal.FieldType:
  35970. return m.OldType(ctx)
  35971. case usagetotal.FieldBotID:
  35972. return m.OldBotID(ctx)
  35973. case usagetotal.FieldTotalTokens:
  35974. return m.OldTotalTokens(ctx)
  35975. case usagetotal.FieldStartIndex:
  35976. return m.OldStartIndex(ctx)
  35977. case usagetotal.FieldEndIndex:
  35978. return m.OldEndIndex(ctx)
  35979. case usagetotal.FieldOrganizationID:
  35980. return m.OldOrganizationID(ctx)
  35981. }
  35982. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  35983. }
  35984. // SetField sets the value of a field with the given name. It returns an error if
  35985. // the field is not defined in the schema, or if the type mismatched the field
  35986. // type.
  35987. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  35988. switch name {
  35989. case usagetotal.FieldCreatedAt:
  35990. v, ok := value.(time.Time)
  35991. if !ok {
  35992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35993. }
  35994. m.SetCreatedAt(v)
  35995. return nil
  35996. case usagetotal.FieldUpdatedAt:
  35997. v, ok := value.(time.Time)
  35998. if !ok {
  35999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36000. }
  36001. m.SetUpdatedAt(v)
  36002. return nil
  36003. case usagetotal.FieldStatus:
  36004. v, ok := value.(uint8)
  36005. if !ok {
  36006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36007. }
  36008. m.SetStatus(v)
  36009. return nil
  36010. case usagetotal.FieldType:
  36011. v, ok := value.(int)
  36012. if !ok {
  36013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36014. }
  36015. m.SetType(v)
  36016. return nil
  36017. case usagetotal.FieldBotID:
  36018. v, ok := value.(string)
  36019. if !ok {
  36020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36021. }
  36022. m.SetBotID(v)
  36023. return nil
  36024. case usagetotal.FieldTotalTokens:
  36025. v, ok := value.(uint64)
  36026. if !ok {
  36027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36028. }
  36029. m.SetTotalTokens(v)
  36030. return nil
  36031. case usagetotal.FieldStartIndex:
  36032. v, ok := value.(uint64)
  36033. if !ok {
  36034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36035. }
  36036. m.SetStartIndex(v)
  36037. return nil
  36038. case usagetotal.FieldEndIndex:
  36039. v, ok := value.(uint64)
  36040. if !ok {
  36041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36042. }
  36043. m.SetEndIndex(v)
  36044. return nil
  36045. case usagetotal.FieldOrganizationID:
  36046. v, ok := value.(uint64)
  36047. if !ok {
  36048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36049. }
  36050. m.SetOrganizationID(v)
  36051. return nil
  36052. }
  36053. return fmt.Errorf("unknown UsageTotal field %s", name)
  36054. }
  36055. // AddedFields returns all numeric fields that were incremented/decremented during
  36056. // this mutation.
  36057. func (m *UsageTotalMutation) AddedFields() []string {
  36058. var fields []string
  36059. if m.addstatus != nil {
  36060. fields = append(fields, usagetotal.FieldStatus)
  36061. }
  36062. if m.add_type != nil {
  36063. fields = append(fields, usagetotal.FieldType)
  36064. }
  36065. if m.addtotal_tokens != nil {
  36066. fields = append(fields, usagetotal.FieldTotalTokens)
  36067. }
  36068. if m.addstart_index != nil {
  36069. fields = append(fields, usagetotal.FieldStartIndex)
  36070. }
  36071. if m.addend_index != nil {
  36072. fields = append(fields, usagetotal.FieldEndIndex)
  36073. }
  36074. if m.addorganization_id != nil {
  36075. fields = append(fields, usagetotal.FieldOrganizationID)
  36076. }
  36077. return fields
  36078. }
  36079. // AddedField returns the numeric value that was incremented/decremented on a field
  36080. // with the given name. The second boolean return value indicates that this field
  36081. // was not set, or was not defined in the schema.
  36082. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  36083. switch name {
  36084. case usagetotal.FieldStatus:
  36085. return m.AddedStatus()
  36086. case usagetotal.FieldType:
  36087. return m.AddedType()
  36088. case usagetotal.FieldTotalTokens:
  36089. return m.AddedTotalTokens()
  36090. case usagetotal.FieldStartIndex:
  36091. return m.AddedStartIndex()
  36092. case usagetotal.FieldEndIndex:
  36093. return m.AddedEndIndex()
  36094. case usagetotal.FieldOrganizationID:
  36095. return m.AddedOrganizationID()
  36096. }
  36097. return nil, false
  36098. }
  36099. // AddField adds the value to the field with the given name. It returns an error if
  36100. // the field is not defined in the schema, or if the type mismatched the field
  36101. // type.
  36102. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  36103. switch name {
  36104. case usagetotal.FieldStatus:
  36105. v, ok := value.(int8)
  36106. if !ok {
  36107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36108. }
  36109. m.AddStatus(v)
  36110. return nil
  36111. case usagetotal.FieldType:
  36112. v, ok := value.(int)
  36113. if !ok {
  36114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36115. }
  36116. m.AddType(v)
  36117. return nil
  36118. case usagetotal.FieldTotalTokens:
  36119. v, ok := value.(int64)
  36120. if !ok {
  36121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36122. }
  36123. m.AddTotalTokens(v)
  36124. return nil
  36125. case usagetotal.FieldStartIndex:
  36126. v, ok := value.(int64)
  36127. if !ok {
  36128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36129. }
  36130. m.AddStartIndex(v)
  36131. return nil
  36132. case usagetotal.FieldEndIndex:
  36133. v, ok := value.(int64)
  36134. if !ok {
  36135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36136. }
  36137. m.AddEndIndex(v)
  36138. return nil
  36139. case usagetotal.FieldOrganizationID:
  36140. v, ok := value.(int64)
  36141. if !ok {
  36142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36143. }
  36144. m.AddOrganizationID(v)
  36145. return nil
  36146. }
  36147. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  36148. }
  36149. // ClearedFields returns all nullable fields that were cleared during this
  36150. // mutation.
  36151. func (m *UsageTotalMutation) ClearedFields() []string {
  36152. var fields []string
  36153. if m.FieldCleared(usagetotal.FieldStatus) {
  36154. fields = append(fields, usagetotal.FieldStatus)
  36155. }
  36156. if m.FieldCleared(usagetotal.FieldType) {
  36157. fields = append(fields, usagetotal.FieldType)
  36158. }
  36159. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  36160. fields = append(fields, usagetotal.FieldTotalTokens)
  36161. }
  36162. if m.FieldCleared(usagetotal.FieldStartIndex) {
  36163. fields = append(fields, usagetotal.FieldStartIndex)
  36164. }
  36165. if m.FieldCleared(usagetotal.FieldEndIndex) {
  36166. fields = append(fields, usagetotal.FieldEndIndex)
  36167. }
  36168. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  36169. fields = append(fields, usagetotal.FieldOrganizationID)
  36170. }
  36171. return fields
  36172. }
  36173. // FieldCleared returns a boolean indicating if a field with the given name was
  36174. // cleared in this mutation.
  36175. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  36176. _, ok := m.clearedFields[name]
  36177. return ok
  36178. }
  36179. // ClearField clears the value of the field with the given name. It returns an
  36180. // error if the field is not defined in the schema.
  36181. func (m *UsageTotalMutation) ClearField(name string) error {
  36182. switch name {
  36183. case usagetotal.FieldStatus:
  36184. m.ClearStatus()
  36185. return nil
  36186. case usagetotal.FieldType:
  36187. m.ClearType()
  36188. return nil
  36189. case usagetotal.FieldTotalTokens:
  36190. m.ClearTotalTokens()
  36191. return nil
  36192. case usagetotal.FieldStartIndex:
  36193. m.ClearStartIndex()
  36194. return nil
  36195. case usagetotal.FieldEndIndex:
  36196. m.ClearEndIndex()
  36197. return nil
  36198. case usagetotal.FieldOrganizationID:
  36199. m.ClearOrganizationID()
  36200. return nil
  36201. }
  36202. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  36203. }
  36204. // ResetField resets all changes in the mutation for the field with the given name.
  36205. // It returns an error if the field is not defined in the schema.
  36206. func (m *UsageTotalMutation) ResetField(name string) error {
  36207. switch name {
  36208. case usagetotal.FieldCreatedAt:
  36209. m.ResetCreatedAt()
  36210. return nil
  36211. case usagetotal.FieldUpdatedAt:
  36212. m.ResetUpdatedAt()
  36213. return nil
  36214. case usagetotal.FieldStatus:
  36215. m.ResetStatus()
  36216. return nil
  36217. case usagetotal.FieldType:
  36218. m.ResetType()
  36219. return nil
  36220. case usagetotal.FieldBotID:
  36221. m.ResetBotID()
  36222. return nil
  36223. case usagetotal.FieldTotalTokens:
  36224. m.ResetTotalTokens()
  36225. return nil
  36226. case usagetotal.FieldStartIndex:
  36227. m.ResetStartIndex()
  36228. return nil
  36229. case usagetotal.FieldEndIndex:
  36230. m.ResetEndIndex()
  36231. return nil
  36232. case usagetotal.FieldOrganizationID:
  36233. m.ResetOrganizationID()
  36234. return nil
  36235. }
  36236. return fmt.Errorf("unknown UsageTotal field %s", name)
  36237. }
  36238. // AddedEdges returns all edge names that were set/added in this mutation.
  36239. func (m *UsageTotalMutation) AddedEdges() []string {
  36240. edges := make([]string, 0, 0)
  36241. return edges
  36242. }
  36243. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36244. // name in this mutation.
  36245. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  36246. return nil
  36247. }
  36248. // RemovedEdges returns all edge names that were removed in this mutation.
  36249. func (m *UsageTotalMutation) RemovedEdges() []string {
  36250. edges := make([]string, 0, 0)
  36251. return edges
  36252. }
  36253. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36254. // the given name in this mutation.
  36255. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  36256. return nil
  36257. }
  36258. // ClearedEdges returns all edge names that were cleared in this mutation.
  36259. func (m *UsageTotalMutation) ClearedEdges() []string {
  36260. edges := make([]string, 0, 0)
  36261. return edges
  36262. }
  36263. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36264. // was cleared in this mutation.
  36265. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  36266. return false
  36267. }
  36268. // ClearEdge clears the value of the edge with the given name. It returns an error
  36269. // if that edge is not defined in the schema.
  36270. func (m *UsageTotalMutation) ClearEdge(name string) error {
  36271. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  36272. }
  36273. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36274. // It returns an error if the edge is not defined in the schema.
  36275. func (m *UsageTotalMutation) ResetEdge(name string) error {
  36276. return fmt.Errorf("unknown UsageTotal edge %s", name)
  36277. }
  36278. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  36279. type WhatsappMutation struct {
  36280. config
  36281. op Op
  36282. typ string
  36283. id *uint64
  36284. created_at *time.Time
  36285. updated_at *time.Time
  36286. status *uint8
  36287. addstatus *int8
  36288. deleted_at *time.Time
  36289. wa_id *string
  36290. wa_name *string
  36291. callback *string
  36292. account *string
  36293. cc *string
  36294. phone *string
  36295. cc_phone *string
  36296. phone_name *string
  36297. phone_status *int8
  36298. addphone_status *int8
  36299. organization_id *uint64
  36300. addorganization_id *int64
  36301. api_base *string
  36302. api_key *string
  36303. allow_list *[]string
  36304. appendallow_list []string
  36305. group_allow_list *[]string
  36306. appendgroup_allow_list []string
  36307. block_list *[]string
  36308. appendblock_list []string
  36309. group_block_list *[]string
  36310. appendgroup_block_list []string
  36311. clearedFields map[string]struct{}
  36312. agent *uint64
  36313. clearedagent bool
  36314. done bool
  36315. oldValue func(context.Context) (*Whatsapp, error)
  36316. predicates []predicate.Whatsapp
  36317. }
  36318. var _ ent.Mutation = (*WhatsappMutation)(nil)
  36319. // whatsappOption allows management of the mutation configuration using functional options.
  36320. type whatsappOption func(*WhatsappMutation)
  36321. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  36322. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  36323. m := &WhatsappMutation{
  36324. config: c,
  36325. op: op,
  36326. typ: TypeWhatsapp,
  36327. clearedFields: make(map[string]struct{}),
  36328. }
  36329. for _, opt := range opts {
  36330. opt(m)
  36331. }
  36332. return m
  36333. }
  36334. // withWhatsappID sets the ID field of the mutation.
  36335. func withWhatsappID(id uint64) whatsappOption {
  36336. return func(m *WhatsappMutation) {
  36337. var (
  36338. err error
  36339. once sync.Once
  36340. value *Whatsapp
  36341. )
  36342. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  36343. once.Do(func() {
  36344. if m.done {
  36345. err = errors.New("querying old values post mutation is not allowed")
  36346. } else {
  36347. value, err = m.Client().Whatsapp.Get(ctx, id)
  36348. }
  36349. })
  36350. return value, err
  36351. }
  36352. m.id = &id
  36353. }
  36354. }
  36355. // withWhatsapp sets the old Whatsapp of the mutation.
  36356. func withWhatsapp(node *Whatsapp) whatsappOption {
  36357. return func(m *WhatsappMutation) {
  36358. m.oldValue = func(context.Context) (*Whatsapp, error) {
  36359. return node, nil
  36360. }
  36361. m.id = &node.ID
  36362. }
  36363. }
  36364. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36365. // executed in a transaction (ent.Tx), a transactional client is returned.
  36366. func (m WhatsappMutation) Client() *Client {
  36367. client := &Client{config: m.config}
  36368. client.init()
  36369. return client
  36370. }
  36371. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36372. // it returns an error otherwise.
  36373. func (m WhatsappMutation) Tx() (*Tx, error) {
  36374. if _, ok := m.driver.(*txDriver); !ok {
  36375. return nil, errors.New("ent: mutation is not running in a transaction")
  36376. }
  36377. tx := &Tx{config: m.config}
  36378. tx.init()
  36379. return tx, nil
  36380. }
  36381. // SetID sets the value of the id field. Note that this
  36382. // operation is only accepted on creation of Whatsapp entities.
  36383. func (m *WhatsappMutation) SetID(id uint64) {
  36384. m.id = &id
  36385. }
  36386. // ID returns the ID value in the mutation. Note that the ID is only available
  36387. // if it was provided to the builder or after it was returned from the database.
  36388. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  36389. if m.id == nil {
  36390. return
  36391. }
  36392. return *m.id, true
  36393. }
  36394. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36395. // That means, if the mutation is applied within a transaction with an isolation level such
  36396. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36397. // or updated by the mutation.
  36398. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  36399. switch {
  36400. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36401. id, exists := m.ID()
  36402. if exists {
  36403. return []uint64{id}, nil
  36404. }
  36405. fallthrough
  36406. case m.op.Is(OpUpdate | OpDelete):
  36407. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  36408. default:
  36409. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36410. }
  36411. }
  36412. // SetCreatedAt sets the "created_at" field.
  36413. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  36414. m.created_at = &t
  36415. }
  36416. // CreatedAt returns the value of the "created_at" field in the mutation.
  36417. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  36418. v := m.created_at
  36419. if v == nil {
  36420. return
  36421. }
  36422. return *v, true
  36423. }
  36424. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  36425. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36427. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36428. if !m.op.Is(OpUpdateOne) {
  36429. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36430. }
  36431. if m.id == nil || m.oldValue == nil {
  36432. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36433. }
  36434. oldValue, err := m.oldValue(ctx)
  36435. if err != nil {
  36436. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36437. }
  36438. return oldValue.CreatedAt, nil
  36439. }
  36440. // ResetCreatedAt resets all changes to the "created_at" field.
  36441. func (m *WhatsappMutation) ResetCreatedAt() {
  36442. m.created_at = nil
  36443. }
  36444. // SetUpdatedAt sets the "updated_at" field.
  36445. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  36446. m.updated_at = &t
  36447. }
  36448. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36449. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  36450. v := m.updated_at
  36451. if v == nil {
  36452. return
  36453. }
  36454. return *v, true
  36455. }
  36456. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  36457. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36459. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36460. if !m.op.Is(OpUpdateOne) {
  36461. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36462. }
  36463. if m.id == nil || m.oldValue == nil {
  36464. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36465. }
  36466. oldValue, err := m.oldValue(ctx)
  36467. if err != nil {
  36468. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36469. }
  36470. return oldValue.UpdatedAt, nil
  36471. }
  36472. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36473. func (m *WhatsappMutation) ResetUpdatedAt() {
  36474. m.updated_at = nil
  36475. }
  36476. // SetStatus sets the "status" field.
  36477. func (m *WhatsappMutation) SetStatus(u uint8) {
  36478. m.status = &u
  36479. m.addstatus = nil
  36480. }
  36481. // Status returns the value of the "status" field in the mutation.
  36482. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  36483. v := m.status
  36484. if v == nil {
  36485. return
  36486. }
  36487. return *v, true
  36488. }
  36489. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  36490. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36492. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36493. if !m.op.Is(OpUpdateOne) {
  36494. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36495. }
  36496. if m.id == nil || m.oldValue == nil {
  36497. return v, errors.New("OldStatus requires an ID field in the mutation")
  36498. }
  36499. oldValue, err := m.oldValue(ctx)
  36500. if err != nil {
  36501. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36502. }
  36503. return oldValue.Status, nil
  36504. }
  36505. // AddStatus adds u to the "status" field.
  36506. func (m *WhatsappMutation) AddStatus(u int8) {
  36507. if m.addstatus != nil {
  36508. *m.addstatus += u
  36509. } else {
  36510. m.addstatus = &u
  36511. }
  36512. }
  36513. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36514. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  36515. v := m.addstatus
  36516. if v == nil {
  36517. return
  36518. }
  36519. return *v, true
  36520. }
  36521. // ClearStatus clears the value of the "status" field.
  36522. func (m *WhatsappMutation) ClearStatus() {
  36523. m.status = nil
  36524. m.addstatus = nil
  36525. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  36526. }
  36527. // StatusCleared returns if the "status" field was cleared in this mutation.
  36528. func (m *WhatsappMutation) StatusCleared() bool {
  36529. _, ok := m.clearedFields[whatsapp.FieldStatus]
  36530. return ok
  36531. }
  36532. // ResetStatus resets all changes to the "status" field.
  36533. func (m *WhatsappMutation) ResetStatus() {
  36534. m.status = nil
  36535. m.addstatus = nil
  36536. delete(m.clearedFields, whatsapp.FieldStatus)
  36537. }
  36538. // SetDeletedAt sets the "deleted_at" field.
  36539. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  36540. m.deleted_at = &t
  36541. }
  36542. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36543. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  36544. v := m.deleted_at
  36545. if v == nil {
  36546. return
  36547. }
  36548. return *v, true
  36549. }
  36550. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  36551. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36553. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36554. if !m.op.Is(OpUpdateOne) {
  36555. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36556. }
  36557. if m.id == nil || m.oldValue == nil {
  36558. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36559. }
  36560. oldValue, err := m.oldValue(ctx)
  36561. if err != nil {
  36562. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36563. }
  36564. return oldValue.DeletedAt, nil
  36565. }
  36566. // ClearDeletedAt clears the value of the "deleted_at" field.
  36567. func (m *WhatsappMutation) ClearDeletedAt() {
  36568. m.deleted_at = nil
  36569. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  36570. }
  36571. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36572. func (m *WhatsappMutation) DeletedAtCleared() bool {
  36573. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  36574. return ok
  36575. }
  36576. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36577. func (m *WhatsappMutation) ResetDeletedAt() {
  36578. m.deleted_at = nil
  36579. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  36580. }
  36581. // SetWaID sets the "wa_id" field.
  36582. func (m *WhatsappMutation) SetWaID(s string) {
  36583. m.wa_id = &s
  36584. }
  36585. // WaID returns the value of the "wa_id" field in the mutation.
  36586. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  36587. v := m.wa_id
  36588. if v == nil {
  36589. return
  36590. }
  36591. return *v, true
  36592. }
  36593. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  36594. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36596. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  36597. if !m.op.Is(OpUpdateOne) {
  36598. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  36599. }
  36600. if m.id == nil || m.oldValue == nil {
  36601. return v, errors.New("OldWaID requires an ID field in the mutation")
  36602. }
  36603. oldValue, err := m.oldValue(ctx)
  36604. if err != nil {
  36605. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  36606. }
  36607. return oldValue.WaID, nil
  36608. }
  36609. // ClearWaID clears the value of the "wa_id" field.
  36610. func (m *WhatsappMutation) ClearWaID() {
  36611. m.wa_id = nil
  36612. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  36613. }
  36614. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  36615. func (m *WhatsappMutation) WaIDCleared() bool {
  36616. _, ok := m.clearedFields[whatsapp.FieldWaID]
  36617. return ok
  36618. }
  36619. // ResetWaID resets all changes to the "wa_id" field.
  36620. func (m *WhatsappMutation) ResetWaID() {
  36621. m.wa_id = nil
  36622. delete(m.clearedFields, whatsapp.FieldWaID)
  36623. }
  36624. // SetWaName sets the "wa_name" field.
  36625. func (m *WhatsappMutation) SetWaName(s string) {
  36626. m.wa_name = &s
  36627. }
  36628. // WaName returns the value of the "wa_name" field in the mutation.
  36629. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  36630. v := m.wa_name
  36631. if v == nil {
  36632. return
  36633. }
  36634. return *v, true
  36635. }
  36636. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  36637. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36639. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  36640. if !m.op.Is(OpUpdateOne) {
  36641. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  36642. }
  36643. if m.id == nil || m.oldValue == nil {
  36644. return v, errors.New("OldWaName requires an ID field in the mutation")
  36645. }
  36646. oldValue, err := m.oldValue(ctx)
  36647. if err != nil {
  36648. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  36649. }
  36650. return oldValue.WaName, nil
  36651. }
  36652. // ClearWaName clears the value of the "wa_name" field.
  36653. func (m *WhatsappMutation) ClearWaName() {
  36654. m.wa_name = nil
  36655. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  36656. }
  36657. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  36658. func (m *WhatsappMutation) WaNameCleared() bool {
  36659. _, ok := m.clearedFields[whatsapp.FieldWaName]
  36660. return ok
  36661. }
  36662. // ResetWaName resets all changes to the "wa_name" field.
  36663. func (m *WhatsappMutation) ResetWaName() {
  36664. m.wa_name = nil
  36665. delete(m.clearedFields, whatsapp.FieldWaName)
  36666. }
  36667. // SetCallback sets the "callback" field.
  36668. func (m *WhatsappMutation) SetCallback(s string) {
  36669. m.callback = &s
  36670. }
  36671. // Callback returns the value of the "callback" field in the mutation.
  36672. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  36673. v := m.callback
  36674. if v == nil {
  36675. return
  36676. }
  36677. return *v, true
  36678. }
  36679. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  36680. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36682. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  36683. if !m.op.Is(OpUpdateOne) {
  36684. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  36685. }
  36686. if m.id == nil || m.oldValue == nil {
  36687. return v, errors.New("OldCallback requires an ID field in the mutation")
  36688. }
  36689. oldValue, err := m.oldValue(ctx)
  36690. if err != nil {
  36691. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  36692. }
  36693. return oldValue.Callback, nil
  36694. }
  36695. // ClearCallback clears the value of the "callback" field.
  36696. func (m *WhatsappMutation) ClearCallback() {
  36697. m.callback = nil
  36698. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  36699. }
  36700. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  36701. func (m *WhatsappMutation) CallbackCleared() bool {
  36702. _, ok := m.clearedFields[whatsapp.FieldCallback]
  36703. return ok
  36704. }
  36705. // ResetCallback resets all changes to the "callback" field.
  36706. func (m *WhatsappMutation) ResetCallback() {
  36707. m.callback = nil
  36708. delete(m.clearedFields, whatsapp.FieldCallback)
  36709. }
  36710. // SetAgentID sets the "agent_id" field.
  36711. func (m *WhatsappMutation) SetAgentID(u uint64) {
  36712. m.agent = &u
  36713. }
  36714. // AgentID returns the value of the "agent_id" field in the mutation.
  36715. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  36716. v := m.agent
  36717. if v == nil {
  36718. return
  36719. }
  36720. return *v, true
  36721. }
  36722. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  36723. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36725. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  36726. if !m.op.Is(OpUpdateOne) {
  36727. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  36728. }
  36729. if m.id == nil || m.oldValue == nil {
  36730. return v, errors.New("OldAgentID requires an ID field in the mutation")
  36731. }
  36732. oldValue, err := m.oldValue(ctx)
  36733. if err != nil {
  36734. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  36735. }
  36736. return oldValue.AgentID, nil
  36737. }
  36738. // ResetAgentID resets all changes to the "agent_id" field.
  36739. func (m *WhatsappMutation) ResetAgentID() {
  36740. m.agent = nil
  36741. }
  36742. // SetAccount sets the "account" field.
  36743. func (m *WhatsappMutation) SetAccount(s string) {
  36744. m.account = &s
  36745. }
  36746. // Account returns the value of the "account" field in the mutation.
  36747. func (m *WhatsappMutation) Account() (r string, exists bool) {
  36748. v := m.account
  36749. if v == nil {
  36750. return
  36751. }
  36752. return *v, true
  36753. }
  36754. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  36755. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36757. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  36758. if !m.op.Is(OpUpdateOne) {
  36759. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  36760. }
  36761. if m.id == nil || m.oldValue == nil {
  36762. return v, errors.New("OldAccount requires an ID field in the mutation")
  36763. }
  36764. oldValue, err := m.oldValue(ctx)
  36765. if err != nil {
  36766. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  36767. }
  36768. return oldValue.Account, nil
  36769. }
  36770. // ClearAccount clears the value of the "account" field.
  36771. func (m *WhatsappMutation) ClearAccount() {
  36772. m.account = nil
  36773. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  36774. }
  36775. // AccountCleared returns if the "account" field was cleared in this mutation.
  36776. func (m *WhatsappMutation) AccountCleared() bool {
  36777. _, ok := m.clearedFields[whatsapp.FieldAccount]
  36778. return ok
  36779. }
  36780. // ResetAccount resets all changes to the "account" field.
  36781. func (m *WhatsappMutation) ResetAccount() {
  36782. m.account = nil
  36783. delete(m.clearedFields, whatsapp.FieldAccount)
  36784. }
  36785. // SetCc sets the "cc" field.
  36786. func (m *WhatsappMutation) SetCc(s string) {
  36787. m.cc = &s
  36788. }
  36789. // Cc returns the value of the "cc" field in the mutation.
  36790. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  36791. v := m.cc
  36792. if v == nil {
  36793. return
  36794. }
  36795. return *v, true
  36796. }
  36797. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  36798. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36800. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  36801. if !m.op.Is(OpUpdateOne) {
  36802. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  36803. }
  36804. if m.id == nil || m.oldValue == nil {
  36805. return v, errors.New("OldCc requires an ID field in the mutation")
  36806. }
  36807. oldValue, err := m.oldValue(ctx)
  36808. if err != nil {
  36809. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  36810. }
  36811. return oldValue.Cc, nil
  36812. }
  36813. // ResetCc resets all changes to the "cc" field.
  36814. func (m *WhatsappMutation) ResetCc() {
  36815. m.cc = nil
  36816. }
  36817. // SetPhone sets the "phone" field.
  36818. func (m *WhatsappMutation) SetPhone(s string) {
  36819. m.phone = &s
  36820. }
  36821. // Phone returns the value of the "phone" field in the mutation.
  36822. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  36823. v := m.phone
  36824. if v == nil {
  36825. return
  36826. }
  36827. return *v, true
  36828. }
  36829. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  36830. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36832. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  36833. if !m.op.Is(OpUpdateOne) {
  36834. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  36835. }
  36836. if m.id == nil || m.oldValue == nil {
  36837. return v, errors.New("OldPhone requires an ID field in the mutation")
  36838. }
  36839. oldValue, err := m.oldValue(ctx)
  36840. if err != nil {
  36841. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  36842. }
  36843. return oldValue.Phone, nil
  36844. }
  36845. // ResetPhone resets all changes to the "phone" field.
  36846. func (m *WhatsappMutation) ResetPhone() {
  36847. m.phone = nil
  36848. }
  36849. // SetCcPhone sets the "cc_phone" field.
  36850. func (m *WhatsappMutation) SetCcPhone(s string) {
  36851. m.cc_phone = &s
  36852. }
  36853. // CcPhone returns the value of the "cc_phone" field in the mutation.
  36854. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  36855. v := m.cc_phone
  36856. if v == nil {
  36857. return
  36858. }
  36859. return *v, true
  36860. }
  36861. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  36862. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36864. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  36865. if !m.op.Is(OpUpdateOne) {
  36866. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  36867. }
  36868. if m.id == nil || m.oldValue == nil {
  36869. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  36870. }
  36871. oldValue, err := m.oldValue(ctx)
  36872. if err != nil {
  36873. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  36874. }
  36875. return oldValue.CcPhone, nil
  36876. }
  36877. // ResetCcPhone resets all changes to the "cc_phone" field.
  36878. func (m *WhatsappMutation) ResetCcPhone() {
  36879. m.cc_phone = nil
  36880. }
  36881. // SetPhoneName sets the "phone_name" field.
  36882. func (m *WhatsappMutation) SetPhoneName(s string) {
  36883. m.phone_name = &s
  36884. }
  36885. // PhoneName returns the value of the "phone_name" field in the mutation.
  36886. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  36887. v := m.phone_name
  36888. if v == nil {
  36889. return
  36890. }
  36891. return *v, true
  36892. }
  36893. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  36894. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36896. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  36897. if !m.op.Is(OpUpdateOne) {
  36898. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  36899. }
  36900. if m.id == nil || m.oldValue == nil {
  36901. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  36902. }
  36903. oldValue, err := m.oldValue(ctx)
  36904. if err != nil {
  36905. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  36906. }
  36907. return oldValue.PhoneName, nil
  36908. }
  36909. // ResetPhoneName resets all changes to the "phone_name" field.
  36910. func (m *WhatsappMutation) ResetPhoneName() {
  36911. m.phone_name = nil
  36912. }
  36913. // SetPhoneStatus sets the "phone_status" field.
  36914. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  36915. m.phone_status = &i
  36916. m.addphone_status = nil
  36917. }
  36918. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  36919. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  36920. v := m.phone_status
  36921. if v == nil {
  36922. return
  36923. }
  36924. return *v, true
  36925. }
  36926. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  36927. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36929. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  36930. if !m.op.Is(OpUpdateOne) {
  36931. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  36932. }
  36933. if m.id == nil || m.oldValue == nil {
  36934. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  36935. }
  36936. oldValue, err := m.oldValue(ctx)
  36937. if err != nil {
  36938. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  36939. }
  36940. return oldValue.PhoneStatus, nil
  36941. }
  36942. // AddPhoneStatus adds i to the "phone_status" field.
  36943. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  36944. if m.addphone_status != nil {
  36945. *m.addphone_status += i
  36946. } else {
  36947. m.addphone_status = &i
  36948. }
  36949. }
  36950. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  36951. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  36952. v := m.addphone_status
  36953. if v == nil {
  36954. return
  36955. }
  36956. return *v, true
  36957. }
  36958. // ResetPhoneStatus resets all changes to the "phone_status" field.
  36959. func (m *WhatsappMutation) ResetPhoneStatus() {
  36960. m.phone_status = nil
  36961. m.addphone_status = nil
  36962. }
  36963. // SetOrganizationID sets the "organization_id" field.
  36964. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  36965. m.organization_id = &u
  36966. m.addorganization_id = nil
  36967. }
  36968. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36969. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  36970. v := m.organization_id
  36971. if v == nil {
  36972. return
  36973. }
  36974. return *v, true
  36975. }
  36976. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  36977. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36979. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36980. if !m.op.Is(OpUpdateOne) {
  36981. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36982. }
  36983. if m.id == nil || m.oldValue == nil {
  36984. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36985. }
  36986. oldValue, err := m.oldValue(ctx)
  36987. if err != nil {
  36988. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36989. }
  36990. return oldValue.OrganizationID, nil
  36991. }
  36992. // AddOrganizationID adds u to the "organization_id" field.
  36993. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  36994. if m.addorganization_id != nil {
  36995. *m.addorganization_id += u
  36996. } else {
  36997. m.addorganization_id = &u
  36998. }
  36999. }
  37000. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37001. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  37002. v := m.addorganization_id
  37003. if v == nil {
  37004. return
  37005. }
  37006. return *v, true
  37007. }
  37008. // ClearOrganizationID clears the value of the "organization_id" field.
  37009. func (m *WhatsappMutation) ClearOrganizationID() {
  37010. m.organization_id = nil
  37011. m.addorganization_id = nil
  37012. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  37013. }
  37014. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37015. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  37016. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  37017. return ok
  37018. }
  37019. // ResetOrganizationID resets all changes to the "organization_id" field.
  37020. func (m *WhatsappMutation) ResetOrganizationID() {
  37021. m.organization_id = nil
  37022. m.addorganization_id = nil
  37023. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  37024. }
  37025. // SetAPIBase sets the "api_base" field.
  37026. func (m *WhatsappMutation) SetAPIBase(s string) {
  37027. m.api_base = &s
  37028. }
  37029. // APIBase returns the value of the "api_base" field in the mutation.
  37030. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  37031. v := m.api_base
  37032. if v == nil {
  37033. return
  37034. }
  37035. return *v, true
  37036. }
  37037. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  37038. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37040. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  37041. if !m.op.Is(OpUpdateOne) {
  37042. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  37043. }
  37044. if m.id == nil || m.oldValue == nil {
  37045. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  37046. }
  37047. oldValue, err := m.oldValue(ctx)
  37048. if err != nil {
  37049. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  37050. }
  37051. return oldValue.APIBase, nil
  37052. }
  37053. // ClearAPIBase clears the value of the "api_base" field.
  37054. func (m *WhatsappMutation) ClearAPIBase() {
  37055. m.api_base = nil
  37056. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  37057. }
  37058. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  37059. func (m *WhatsappMutation) APIBaseCleared() bool {
  37060. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  37061. return ok
  37062. }
  37063. // ResetAPIBase resets all changes to the "api_base" field.
  37064. func (m *WhatsappMutation) ResetAPIBase() {
  37065. m.api_base = nil
  37066. delete(m.clearedFields, whatsapp.FieldAPIBase)
  37067. }
  37068. // SetAPIKey sets the "api_key" field.
  37069. func (m *WhatsappMutation) SetAPIKey(s string) {
  37070. m.api_key = &s
  37071. }
  37072. // APIKey returns the value of the "api_key" field in the mutation.
  37073. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  37074. v := m.api_key
  37075. if v == nil {
  37076. return
  37077. }
  37078. return *v, true
  37079. }
  37080. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  37081. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37083. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  37084. if !m.op.Is(OpUpdateOne) {
  37085. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  37086. }
  37087. if m.id == nil || m.oldValue == nil {
  37088. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  37089. }
  37090. oldValue, err := m.oldValue(ctx)
  37091. if err != nil {
  37092. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  37093. }
  37094. return oldValue.APIKey, nil
  37095. }
  37096. // ClearAPIKey clears the value of the "api_key" field.
  37097. func (m *WhatsappMutation) ClearAPIKey() {
  37098. m.api_key = nil
  37099. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  37100. }
  37101. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  37102. func (m *WhatsappMutation) APIKeyCleared() bool {
  37103. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  37104. return ok
  37105. }
  37106. // ResetAPIKey resets all changes to the "api_key" field.
  37107. func (m *WhatsappMutation) ResetAPIKey() {
  37108. m.api_key = nil
  37109. delete(m.clearedFields, whatsapp.FieldAPIKey)
  37110. }
  37111. // SetAllowList sets the "allow_list" field.
  37112. func (m *WhatsappMutation) SetAllowList(s []string) {
  37113. m.allow_list = &s
  37114. m.appendallow_list = nil
  37115. }
  37116. // AllowList returns the value of the "allow_list" field in the mutation.
  37117. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  37118. v := m.allow_list
  37119. if v == nil {
  37120. return
  37121. }
  37122. return *v, true
  37123. }
  37124. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  37125. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37127. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  37128. if !m.op.Is(OpUpdateOne) {
  37129. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  37130. }
  37131. if m.id == nil || m.oldValue == nil {
  37132. return v, errors.New("OldAllowList requires an ID field in the mutation")
  37133. }
  37134. oldValue, err := m.oldValue(ctx)
  37135. if err != nil {
  37136. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  37137. }
  37138. return oldValue.AllowList, nil
  37139. }
  37140. // AppendAllowList adds s to the "allow_list" field.
  37141. func (m *WhatsappMutation) AppendAllowList(s []string) {
  37142. m.appendallow_list = append(m.appendallow_list, s...)
  37143. }
  37144. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  37145. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  37146. if len(m.appendallow_list) == 0 {
  37147. return nil, false
  37148. }
  37149. return m.appendallow_list, true
  37150. }
  37151. // ClearAllowList clears the value of the "allow_list" field.
  37152. func (m *WhatsappMutation) ClearAllowList() {
  37153. m.allow_list = nil
  37154. m.appendallow_list = nil
  37155. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  37156. }
  37157. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  37158. func (m *WhatsappMutation) AllowListCleared() bool {
  37159. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  37160. return ok
  37161. }
  37162. // ResetAllowList resets all changes to the "allow_list" field.
  37163. func (m *WhatsappMutation) ResetAllowList() {
  37164. m.allow_list = nil
  37165. m.appendallow_list = nil
  37166. delete(m.clearedFields, whatsapp.FieldAllowList)
  37167. }
  37168. // SetGroupAllowList sets the "group_allow_list" field.
  37169. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  37170. m.group_allow_list = &s
  37171. m.appendgroup_allow_list = nil
  37172. }
  37173. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  37174. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  37175. v := m.group_allow_list
  37176. if v == nil {
  37177. return
  37178. }
  37179. return *v, true
  37180. }
  37181. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  37182. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37184. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  37185. if !m.op.Is(OpUpdateOne) {
  37186. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  37187. }
  37188. if m.id == nil || m.oldValue == nil {
  37189. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  37190. }
  37191. oldValue, err := m.oldValue(ctx)
  37192. if err != nil {
  37193. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  37194. }
  37195. return oldValue.GroupAllowList, nil
  37196. }
  37197. // AppendGroupAllowList adds s to the "group_allow_list" field.
  37198. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  37199. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  37200. }
  37201. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  37202. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  37203. if len(m.appendgroup_allow_list) == 0 {
  37204. return nil, false
  37205. }
  37206. return m.appendgroup_allow_list, true
  37207. }
  37208. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  37209. func (m *WhatsappMutation) ClearGroupAllowList() {
  37210. m.group_allow_list = nil
  37211. m.appendgroup_allow_list = nil
  37212. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  37213. }
  37214. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  37215. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  37216. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  37217. return ok
  37218. }
  37219. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  37220. func (m *WhatsappMutation) ResetGroupAllowList() {
  37221. m.group_allow_list = nil
  37222. m.appendgroup_allow_list = nil
  37223. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  37224. }
  37225. // SetBlockList sets the "block_list" field.
  37226. func (m *WhatsappMutation) SetBlockList(s []string) {
  37227. m.block_list = &s
  37228. m.appendblock_list = nil
  37229. }
  37230. // BlockList returns the value of the "block_list" field in the mutation.
  37231. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  37232. v := m.block_list
  37233. if v == nil {
  37234. return
  37235. }
  37236. return *v, true
  37237. }
  37238. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  37239. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37241. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  37242. if !m.op.Is(OpUpdateOne) {
  37243. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  37244. }
  37245. if m.id == nil || m.oldValue == nil {
  37246. return v, errors.New("OldBlockList requires an ID field in the mutation")
  37247. }
  37248. oldValue, err := m.oldValue(ctx)
  37249. if err != nil {
  37250. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  37251. }
  37252. return oldValue.BlockList, nil
  37253. }
  37254. // AppendBlockList adds s to the "block_list" field.
  37255. func (m *WhatsappMutation) AppendBlockList(s []string) {
  37256. m.appendblock_list = append(m.appendblock_list, s...)
  37257. }
  37258. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  37259. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  37260. if len(m.appendblock_list) == 0 {
  37261. return nil, false
  37262. }
  37263. return m.appendblock_list, true
  37264. }
  37265. // ClearBlockList clears the value of the "block_list" field.
  37266. func (m *WhatsappMutation) ClearBlockList() {
  37267. m.block_list = nil
  37268. m.appendblock_list = nil
  37269. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  37270. }
  37271. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  37272. func (m *WhatsappMutation) BlockListCleared() bool {
  37273. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  37274. return ok
  37275. }
  37276. // ResetBlockList resets all changes to the "block_list" field.
  37277. func (m *WhatsappMutation) ResetBlockList() {
  37278. m.block_list = nil
  37279. m.appendblock_list = nil
  37280. delete(m.clearedFields, whatsapp.FieldBlockList)
  37281. }
  37282. // SetGroupBlockList sets the "group_block_list" field.
  37283. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  37284. m.group_block_list = &s
  37285. m.appendgroup_block_list = nil
  37286. }
  37287. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  37288. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  37289. v := m.group_block_list
  37290. if v == nil {
  37291. return
  37292. }
  37293. return *v, true
  37294. }
  37295. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  37296. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37298. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  37299. if !m.op.Is(OpUpdateOne) {
  37300. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  37301. }
  37302. if m.id == nil || m.oldValue == nil {
  37303. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  37304. }
  37305. oldValue, err := m.oldValue(ctx)
  37306. if err != nil {
  37307. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  37308. }
  37309. return oldValue.GroupBlockList, nil
  37310. }
  37311. // AppendGroupBlockList adds s to the "group_block_list" field.
  37312. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  37313. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  37314. }
  37315. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  37316. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  37317. if len(m.appendgroup_block_list) == 0 {
  37318. return nil, false
  37319. }
  37320. return m.appendgroup_block_list, true
  37321. }
  37322. // ClearGroupBlockList clears the value of the "group_block_list" field.
  37323. func (m *WhatsappMutation) ClearGroupBlockList() {
  37324. m.group_block_list = nil
  37325. m.appendgroup_block_list = nil
  37326. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  37327. }
  37328. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  37329. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  37330. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  37331. return ok
  37332. }
  37333. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  37334. func (m *WhatsappMutation) ResetGroupBlockList() {
  37335. m.group_block_list = nil
  37336. m.appendgroup_block_list = nil
  37337. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  37338. }
  37339. // ClearAgent clears the "agent" edge to the Agent entity.
  37340. func (m *WhatsappMutation) ClearAgent() {
  37341. m.clearedagent = true
  37342. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  37343. }
  37344. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  37345. func (m *WhatsappMutation) AgentCleared() bool {
  37346. return m.clearedagent
  37347. }
  37348. // AgentIDs returns the "agent" edge IDs in the mutation.
  37349. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  37350. // AgentID instead. It exists only for internal usage by the builders.
  37351. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  37352. if id := m.agent; id != nil {
  37353. ids = append(ids, *id)
  37354. }
  37355. return
  37356. }
  37357. // ResetAgent resets all changes to the "agent" edge.
  37358. func (m *WhatsappMutation) ResetAgent() {
  37359. m.agent = nil
  37360. m.clearedagent = false
  37361. }
  37362. // Where appends a list predicates to the WhatsappMutation builder.
  37363. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  37364. m.predicates = append(m.predicates, ps...)
  37365. }
  37366. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  37367. // users can use type-assertion to append predicates that do not depend on any generated package.
  37368. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  37369. p := make([]predicate.Whatsapp, len(ps))
  37370. for i := range ps {
  37371. p[i] = ps[i]
  37372. }
  37373. m.Where(p...)
  37374. }
  37375. // Op returns the operation name.
  37376. func (m *WhatsappMutation) Op() Op {
  37377. return m.op
  37378. }
  37379. // SetOp allows setting the mutation operation.
  37380. func (m *WhatsappMutation) SetOp(op Op) {
  37381. m.op = op
  37382. }
  37383. // Type returns the node type of this mutation (Whatsapp).
  37384. func (m *WhatsappMutation) Type() string {
  37385. return m.typ
  37386. }
  37387. // Fields returns all fields that were changed during this mutation. Note that in
  37388. // order to get all numeric fields that were incremented/decremented, call
  37389. // AddedFields().
  37390. func (m *WhatsappMutation) Fields() []string {
  37391. fields := make([]string, 0, 21)
  37392. if m.created_at != nil {
  37393. fields = append(fields, whatsapp.FieldCreatedAt)
  37394. }
  37395. if m.updated_at != nil {
  37396. fields = append(fields, whatsapp.FieldUpdatedAt)
  37397. }
  37398. if m.status != nil {
  37399. fields = append(fields, whatsapp.FieldStatus)
  37400. }
  37401. if m.deleted_at != nil {
  37402. fields = append(fields, whatsapp.FieldDeletedAt)
  37403. }
  37404. if m.wa_id != nil {
  37405. fields = append(fields, whatsapp.FieldWaID)
  37406. }
  37407. if m.wa_name != nil {
  37408. fields = append(fields, whatsapp.FieldWaName)
  37409. }
  37410. if m.callback != nil {
  37411. fields = append(fields, whatsapp.FieldCallback)
  37412. }
  37413. if m.agent != nil {
  37414. fields = append(fields, whatsapp.FieldAgentID)
  37415. }
  37416. if m.account != nil {
  37417. fields = append(fields, whatsapp.FieldAccount)
  37418. }
  37419. if m.cc != nil {
  37420. fields = append(fields, whatsapp.FieldCc)
  37421. }
  37422. if m.phone != nil {
  37423. fields = append(fields, whatsapp.FieldPhone)
  37424. }
  37425. if m.cc_phone != nil {
  37426. fields = append(fields, whatsapp.FieldCcPhone)
  37427. }
  37428. if m.phone_name != nil {
  37429. fields = append(fields, whatsapp.FieldPhoneName)
  37430. }
  37431. if m.phone_status != nil {
  37432. fields = append(fields, whatsapp.FieldPhoneStatus)
  37433. }
  37434. if m.organization_id != nil {
  37435. fields = append(fields, whatsapp.FieldOrganizationID)
  37436. }
  37437. if m.api_base != nil {
  37438. fields = append(fields, whatsapp.FieldAPIBase)
  37439. }
  37440. if m.api_key != nil {
  37441. fields = append(fields, whatsapp.FieldAPIKey)
  37442. }
  37443. if m.allow_list != nil {
  37444. fields = append(fields, whatsapp.FieldAllowList)
  37445. }
  37446. if m.group_allow_list != nil {
  37447. fields = append(fields, whatsapp.FieldGroupAllowList)
  37448. }
  37449. if m.block_list != nil {
  37450. fields = append(fields, whatsapp.FieldBlockList)
  37451. }
  37452. if m.group_block_list != nil {
  37453. fields = append(fields, whatsapp.FieldGroupBlockList)
  37454. }
  37455. return fields
  37456. }
  37457. // Field returns the value of a field with the given name. The second boolean
  37458. // return value indicates that this field was not set, or was not defined in the
  37459. // schema.
  37460. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  37461. switch name {
  37462. case whatsapp.FieldCreatedAt:
  37463. return m.CreatedAt()
  37464. case whatsapp.FieldUpdatedAt:
  37465. return m.UpdatedAt()
  37466. case whatsapp.FieldStatus:
  37467. return m.Status()
  37468. case whatsapp.FieldDeletedAt:
  37469. return m.DeletedAt()
  37470. case whatsapp.FieldWaID:
  37471. return m.WaID()
  37472. case whatsapp.FieldWaName:
  37473. return m.WaName()
  37474. case whatsapp.FieldCallback:
  37475. return m.Callback()
  37476. case whatsapp.FieldAgentID:
  37477. return m.AgentID()
  37478. case whatsapp.FieldAccount:
  37479. return m.Account()
  37480. case whatsapp.FieldCc:
  37481. return m.Cc()
  37482. case whatsapp.FieldPhone:
  37483. return m.Phone()
  37484. case whatsapp.FieldCcPhone:
  37485. return m.CcPhone()
  37486. case whatsapp.FieldPhoneName:
  37487. return m.PhoneName()
  37488. case whatsapp.FieldPhoneStatus:
  37489. return m.PhoneStatus()
  37490. case whatsapp.FieldOrganizationID:
  37491. return m.OrganizationID()
  37492. case whatsapp.FieldAPIBase:
  37493. return m.APIBase()
  37494. case whatsapp.FieldAPIKey:
  37495. return m.APIKey()
  37496. case whatsapp.FieldAllowList:
  37497. return m.AllowList()
  37498. case whatsapp.FieldGroupAllowList:
  37499. return m.GroupAllowList()
  37500. case whatsapp.FieldBlockList:
  37501. return m.BlockList()
  37502. case whatsapp.FieldGroupBlockList:
  37503. return m.GroupBlockList()
  37504. }
  37505. return nil, false
  37506. }
  37507. // OldField returns the old value of the field from the database. An error is
  37508. // returned if the mutation operation is not UpdateOne, or the query to the
  37509. // database failed.
  37510. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37511. switch name {
  37512. case whatsapp.FieldCreatedAt:
  37513. return m.OldCreatedAt(ctx)
  37514. case whatsapp.FieldUpdatedAt:
  37515. return m.OldUpdatedAt(ctx)
  37516. case whatsapp.FieldStatus:
  37517. return m.OldStatus(ctx)
  37518. case whatsapp.FieldDeletedAt:
  37519. return m.OldDeletedAt(ctx)
  37520. case whatsapp.FieldWaID:
  37521. return m.OldWaID(ctx)
  37522. case whatsapp.FieldWaName:
  37523. return m.OldWaName(ctx)
  37524. case whatsapp.FieldCallback:
  37525. return m.OldCallback(ctx)
  37526. case whatsapp.FieldAgentID:
  37527. return m.OldAgentID(ctx)
  37528. case whatsapp.FieldAccount:
  37529. return m.OldAccount(ctx)
  37530. case whatsapp.FieldCc:
  37531. return m.OldCc(ctx)
  37532. case whatsapp.FieldPhone:
  37533. return m.OldPhone(ctx)
  37534. case whatsapp.FieldCcPhone:
  37535. return m.OldCcPhone(ctx)
  37536. case whatsapp.FieldPhoneName:
  37537. return m.OldPhoneName(ctx)
  37538. case whatsapp.FieldPhoneStatus:
  37539. return m.OldPhoneStatus(ctx)
  37540. case whatsapp.FieldOrganizationID:
  37541. return m.OldOrganizationID(ctx)
  37542. case whatsapp.FieldAPIBase:
  37543. return m.OldAPIBase(ctx)
  37544. case whatsapp.FieldAPIKey:
  37545. return m.OldAPIKey(ctx)
  37546. case whatsapp.FieldAllowList:
  37547. return m.OldAllowList(ctx)
  37548. case whatsapp.FieldGroupAllowList:
  37549. return m.OldGroupAllowList(ctx)
  37550. case whatsapp.FieldBlockList:
  37551. return m.OldBlockList(ctx)
  37552. case whatsapp.FieldGroupBlockList:
  37553. return m.OldGroupBlockList(ctx)
  37554. }
  37555. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  37556. }
  37557. // SetField sets the value of a field with the given name. It returns an error if
  37558. // the field is not defined in the schema, or if the type mismatched the field
  37559. // type.
  37560. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  37561. switch name {
  37562. case whatsapp.FieldCreatedAt:
  37563. v, ok := value.(time.Time)
  37564. if !ok {
  37565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37566. }
  37567. m.SetCreatedAt(v)
  37568. return nil
  37569. case whatsapp.FieldUpdatedAt:
  37570. v, ok := value.(time.Time)
  37571. if !ok {
  37572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37573. }
  37574. m.SetUpdatedAt(v)
  37575. return nil
  37576. case whatsapp.FieldStatus:
  37577. v, ok := value.(uint8)
  37578. if !ok {
  37579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37580. }
  37581. m.SetStatus(v)
  37582. return nil
  37583. case whatsapp.FieldDeletedAt:
  37584. v, ok := value.(time.Time)
  37585. if !ok {
  37586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37587. }
  37588. m.SetDeletedAt(v)
  37589. return nil
  37590. case whatsapp.FieldWaID:
  37591. v, ok := value.(string)
  37592. if !ok {
  37593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37594. }
  37595. m.SetWaID(v)
  37596. return nil
  37597. case whatsapp.FieldWaName:
  37598. v, ok := value.(string)
  37599. if !ok {
  37600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37601. }
  37602. m.SetWaName(v)
  37603. return nil
  37604. case whatsapp.FieldCallback:
  37605. v, ok := value.(string)
  37606. if !ok {
  37607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37608. }
  37609. m.SetCallback(v)
  37610. return nil
  37611. case whatsapp.FieldAgentID:
  37612. v, ok := value.(uint64)
  37613. if !ok {
  37614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37615. }
  37616. m.SetAgentID(v)
  37617. return nil
  37618. case whatsapp.FieldAccount:
  37619. v, ok := value.(string)
  37620. if !ok {
  37621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37622. }
  37623. m.SetAccount(v)
  37624. return nil
  37625. case whatsapp.FieldCc:
  37626. v, ok := value.(string)
  37627. if !ok {
  37628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37629. }
  37630. m.SetCc(v)
  37631. return nil
  37632. case whatsapp.FieldPhone:
  37633. v, ok := value.(string)
  37634. if !ok {
  37635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37636. }
  37637. m.SetPhone(v)
  37638. return nil
  37639. case whatsapp.FieldCcPhone:
  37640. v, ok := value.(string)
  37641. if !ok {
  37642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37643. }
  37644. m.SetCcPhone(v)
  37645. return nil
  37646. case whatsapp.FieldPhoneName:
  37647. v, ok := value.(string)
  37648. if !ok {
  37649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37650. }
  37651. m.SetPhoneName(v)
  37652. return nil
  37653. case whatsapp.FieldPhoneStatus:
  37654. v, ok := value.(int8)
  37655. if !ok {
  37656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37657. }
  37658. m.SetPhoneStatus(v)
  37659. return nil
  37660. case whatsapp.FieldOrganizationID:
  37661. v, ok := value.(uint64)
  37662. if !ok {
  37663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37664. }
  37665. m.SetOrganizationID(v)
  37666. return nil
  37667. case whatsapp.FieldAPIBase:
  37668. v, ok := value.(string)
  37669. if !ok {
  37670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37671. }
  37672. m.SetAPIBase(v)
  37673. return nil
  37674. case whatsapp.FieldAPIKey:
  37675. v, ok := value.(string)
  37676. if !ok {
  37677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37678. }
  37679. m.SetAPIKey(v)
  37680. return nil
  37681. case whatsapp.FieldAllowList:
  37682. v, ok := value.([]string)
  37683. if !ok {
  37684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37685. }
  37686. m.SetAllowList(v)
  37687. return nil
  37688. case whatsapp.FieldGroupAllowList:
  37689. v, ok := value.([]string)
  37690. if !ok {
  37691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37692. }
  37693. m.SetGroupAllowList(v)
  37694. return nil
  37695. case whatsapp.FieldBlockList:
  37696. v, ok := value.([]string)
  37697. if !ok {
  37698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37699. }
  37700. m.SetBlockList(v)
  37701. return nil
  37702. case whatsapp.FieldGroupBlockList:
  37703. v, ok := value.([]string)
  37704. if !ok {
  37705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37706. }
  37707. m.SetGroupBlockList(v)
  37708. return nil
  37709. }
  37710. return fmt.Errorf("unknown Whatsapp field %s", name)
  37711. }
  37712. // AddedFields returns all numeric fields that were incremented/decremented during
  37713. // this mutation.
  37714. func (m *WhatsappMutation) AddedFields() []string {
  37715. var fields []string
  37716. if m.addstatus != nil {
  37717. fields = append(fields, whatsapp.FieldStatus)
  37718. }
  37719. if m.addphone_status != nil {
  37720. fields = append(fields, whatsapp.FieldPhoneStatus)
  37721. }
  37722. if m.addorganization_id != nil {
  37723. fields = append(fields, whatsapp.FieldOrganizationID)
  37724. }
  37725. return fields
  37726. }
  37727. // AddedField returns the numeric value that was incremented/decremented on a field
  37728. // with the given name. The second boolean return value indicates that this field
  37729. // was not set, or was not defined in the schema.
  37730. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  37731. switch name {
  37732. case whatsapp.FieldStatus:
  37733. return m.AddedStatus()
  37734. case whatsapp.FieldPhoneStatus:
  37735. return m.AddedPhoneStatus()
  37736. case whatsapp.FieldOrganizationID:
  37737. return m.AddedOrganizationID()
  37738. }
  37739. return nil, false
  37740. }
  37741. // AddField adds the value to the field with the given name. It returns an error if
  37742. // the field is not defined in the schema, or if the type mismatched the field
  37743. // type.
  37744. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  37745. switch name {
  37746. case whatsapp.FieldStatus:
  37747. v, ok := value.(int8)
  37748. if !ok {
  37749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37750. }
  37751. m.AddStatus(v)
  37752. return nil
  37753. case whatsapp.FieldPhoneStatus:
  37754. v, ok := value.(int8)
  37755. if !ok {
  37756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37757. }
  37758. m.AddPhoneStatus(v)
  37759. return nil
  37760. case whatsapp.FieldOrganizationID:
  37761. v, ok := value.(int64)
  37762. if !ok {
  37763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37764. }
  37765. m.AddOrganizationID(v)
  37766. return nil
  37767. }
  37768. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  37769. }
  37770. // ClearedFields returns all nullable fields that were cleared during this
  37771. // mutation.
  37772. func (m *WhatsappMutation) ClearedFields() []string {
  37773. var fields []string
  37774. if m.FieldCleared(whatsapp.FieldStatus) {
  37775. fields = append(fields, whatsapp.FieldStatus)
  37776. }
  37777. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  37778. fields = append(fields, whatsapp.FieldDeletedAt)
  37779. }
  37780. if m.FieldCleared(whatsapp.FieldWaID) {
  37781. fields = append(fields, whatsapp.FieldWaID)
  37782. }
  37783. if m.FieldCleared(whatsapp.FieldWaName) {
  37784. fields = append(fields, whatsapp.FieldWaName)
  37785. }
  37786. if m.FieldCleared(whatsapp.FieldCallback) {
  37787. fields = append(fields, whatsapp.FieldCallback)
  37788. }
  37789. if m.FieldCleared(whatsapp.FieldAccount) {
  37790. fields = append(fields, whatsapp.FieldAccount)
  37791. }
  37792. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  37793. fields = append(fields, whatsapp.FieldOrganizationID)
  37794. }
  37795. if m.FieldCleared(whatsapp.FieldAPIBase) {
  37796. fields = append(fields, whatsapp.FieldAPIBase)
  37797. }
  37798. if m.FieldCleared(whatsapp.FieldAPIKey) {
  37799. fields = append(fields, whatsapp.FieldAPIKey)
  37800. }
  37801. if m.FieldCleared(whatsapp.FieldAllowList) {
  37802. fields = append(fields, whatsapp.FieldAllowList)
  37803. }
  37804. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  37805. fields = append(fields, whatsapp.FieldGroupAllowList)
  37806. }
  37807. if m.FieldCleared(whatsapp.FieldBlockList) {
  37808. fields = append(fields, whatsapp.FieldBlockList)
  37809. }
  37810. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  37811. fields = append(fields, whatsapp.FieldGroupBlockList)
  37812. }
  37813. return fields
  37814. }
  37815. // FieldCleared returns a boolean indicating if a field with the given name was
  37816. // cleared in this mutation.
  37817. func (m *WhatsappMutation) FieldCleared(name string) bool {
  37818. _, ok := m.clearedFields[name]
  37819. return ok
  37820. }
  37821. // ClearField clears the value of the field with the given name. It returns an
  37822. // error if the field is not defined in the schema.
  37823. func (m *WhatsappMutation) ClearField(name string) error {
  37824. switch name {
  37825. case whatsapp.FieldStatus:
  37826. m.ClearStatus()
  37827. return nil
  37828. case whatsapp.FieldDeletedAt:
  37829. m.ClearDeletedAt()
  37830. return nil
  37831. case whatsapp.FieldWaID:
  37832. m.ClearWaID()
  37833. return nil
  37834. case whatsapp.FieldWaName:
  37835. m.ClearWaName()
  37836. return nil
  37837. case whatsapp.FieldCallback:
  37838. m.ClearCallback()
  37839. return nil
  37840. case whatsapp.FieldAccount:
  37841. m.ClearAccount()
  37842. return nil
  37843. case whatsapp.FieldOrganizationID:
  37844. m.ClearOrganizationID()
  37845. return nil
  37846. case whatsapp.FieldAPIBase:
  37847. m.ClearAPIBase()
  37848. return nil
  37849. case whatsapp.FieldAPIKey:
  37850. m.ClearAPIKey()
  37851. return nil
  37852. case whatsapp.FieldAllowList:
  37853. m.ClearAllowList()
  37854. return nil
  37855. case whatsapp.FieldGroupAllowList:
  37856. m.ClearGroupAllowList()
  37857. return nil
  37858. case whatsapp.FieldBlockList:
  37859. m.ClearBlockList()
  37860. return nil
  37861. case whatsapp.FieldGroupBlockList:
  37862. m.ClearGroupBlockList()
  37863. return nil
  37864. }
  37865. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  37866. }
  37867. // ResetField resets all changes in the mutation for the field with the given name.
  37868. // It returns an error if the field is not defined in the schema.
  37869. func (m *WhatsappMutation) ResetField(name string) error {
  37870. switch name {
  37871. case whatsapp.FieldCreatedAt:
  37872. m.ResetCreatedAt()
  37873. return nil
  37874. case whatsapp.FieldUpdatedAt:
  37875. m.ResetUpdatedAt()
  37876. return nil
  37877. case whatsapp.FieldStatus:
  37878. m.ResetStatus()
  37879. return nil
  37880. case whatsapp.FieldDeletedAt:
  37881. m.ResetDeletedAt()
  37882. return nil
  37883. case whatsapp.FieldWaID:
  37884. m.ResetWaID()
  37885. return nil
  37886. case whatsapp.FieldWaName:
  37887. m.ResetWaName()
  37888. return nil
  37889. case whatsapp.FieldCallback:
  37890. m.ResetCallback()
  37891. return nil
  37892. case whatsapp.FieldAgentID:
  37893. m.ResetAgentID()
  37894. return nil
  37895. case whatsapp.FieldAccount:
  37896. m.ResetAccount()
  37897. return nil
  37898. case whatsapp.FieldCc:
  37899. m.ResetCc()
  37900. return nil
  37901. case whatsapp.FieldPhone:
  37902. m.ResetPhone()
  37903. return nil
  37904. case whatsapp.FieldCcPhone:
  37905. m.ResetCcPhone()
  37906. return nil
  37907. case whatsapp.FieldPhoneName:
  37908. m.ResetPhoneName()
  37909. return nil
  37910. case whatsapp.FieldPhoneStatus:
  37911. m.ResetPhoneStatus()
  37912. return nil
  37913. case whatsapp.FieldOrganizationID:
  37914. m.ResetOrganizationID()
  37915. return nil
  37916. case whatsapp.FieldAPIBase:
  37917. m.ResetAPIBase()
  37918. return nil
  37919. case whatsapp.FieldAPIKey:
  37920. m.ResetAPIKey()
  37921. return nil
  37922. case whatsapp.FieldAllowList:
  37923. m.ResetAllowList()
  37924. return nil
  37925. case whatsapp.FieldGroupAllowList:
  37926. m.ResetGroupAllowList()
  37927. return nil
  37928. case whatsapp.FieldBlockList:
  37929. m.ResetBlockList()
  37930. return nil
  37931. case whatsapp.FieldGroupBlockList:
  37932. m.ResetGroupBlockList()
  37933. return nil
  37934. }
  37935. return fmt.Errorf("unknown Whatsapp field %s", name)
  37936. }
  37937. // AddedEdges returns all edge names that were set/added in this mutation.
  37938. func (m *WhatsappMutation) AddedEdges() []string {
  37939. edges := make([]string, 0, 1)
  37940. if m.agent != nil {
  37941. edges = append(edges, whatsapp.EdgeAgent)
  37942. }
  37943. return edges
  37944. }
  37945. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37946. // name in this mutation.
  37947. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  37948. switch name {
  37949. case whatsapp.EdgeAgent:
  37950. if id := m.agent; id != nil {
  37951. return []ent.Value{*id}
  37952. }
  37953. }
  37954. return nil
  37955. }
  37956. // RemovedEdges returns all edge names that were removed in this mutation.
  37957. func (m *WhatsappMutation) RemovedEdges() []string {
  37958. edges := make([]string, 0, 1)
  37959. return edges
  37960. }
  37961. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37962. // the given name in this mutation.
  37963. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  37964. return nil
  37965. }
  37966. // ClearedEdges returns all edge names that were cleared in this mutation.
  37967. func (m *WhatsappMutation) ClearedEdges() []string {
  37968. edges := make([]string, 0, 1)
  37969. if m.clearedagent {
  37970. edges = append(edges, whatsapp.EdgeAgent)
  37971. }
  37972. return edges
  37973. }
  37974. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37975. // was cleared in this mutation.
  37976. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  37977. switch name {
  37978. case whatsapp.EdgeAgent:
  37979. return m.clearedagent
  37980. }
  37981. return false
  37982. }
  37983. // ClearEdge clears the value of the edge with the given name. It returns an error
  37984. // if that edge is not defined in the schema.
  37985. func (m *WhatsappMutation) ClearEdge(name string) error {
  37986. switch name {
  37987. case whatsapp.EdgeAgent:
  37988. m.ClearAgent()
  37989. return nil
  37990. }
  37991. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  37992. }
  37993. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37994. // It returns an error if the edge is not defined in the schema.
  37995. func (m *WhatsappMutation) ResetEdge(name string) error {
  37996. switch name {
  37997. case whatsapp.EdgeAgent:
  37998. m.ResetAgent()
  37999. return nil
  38000. }
  38001. return fmt.Errorf("unknown Whatsapp edge %s", name)
  38002. }
  38003. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  38004. type WhatsappChannelMutation struct {
  38005. config
  38006. op Op
  38007. typ string
  38008. id *uint64
  38009. created_at *time.Time
  38010. updated_at *time.Time
  38011. status *uint8
  38012. addstatus *int8
  38013. deleted_at *time.Time
  38014. ak *string
  38015. sk *string
  38016. wa_id *string
  38017. wa_name *string
  38018. waba_id *uint64
  38019. addwaba_id *int64
  38020. business_id *uint64
  38021. addbusiness_id *int64
  38022. organization_id *uint64
  38023. addorganization_id *int64
  38024. verify_account *string
  38025. clearedFields map[string]struct{}
  38026. done bool
  38027. oldValue func(context.Context) (*WhatsappChannel, error)
  38028. predicates []predicate.WhatsappChannel
  38029. }
  38030. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  38031. // whatsappchannelOption allows management of the mutation configuration using functional options.
  38032. type whatsappchannelOption func(*WhatsappChannelMutation)
  38033. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  38034. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  38035. m := &WhatsappChannelMutation{
  38036. config: c,
  38037. op: op,
  38038. typ: TypeWhatsappChannel,
  38039. clearedFields: make(map[string]struct{}),
  38040. }
  38041. for _, opt := range opts {
  38042. opt(m)
  38043. }
  38044. return m
  38045. }
  38046. // withWhatsappChannelID sets the ID field of the mutation.
  38047. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  38048. return func(m *WhatsappChannelMutation) {
  38049. var (
  38050. err error
  38051. once sync.Once
  38052. value *WhatsappChannel
  38053. )
  38054. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  38055. once.Do(func() {
  38056. if m.done {
  38057. err = errors.New("querying old values post mutation is not allowed")
  38058. } else {
  38059. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  38060. }
  38061. })
  38062. return value, err
  38063. }
  38064. m.id = &id
  38065. }
  38066. }
  38067. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  38068. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  38069. return func(m *WhatsappChannelMutation) {
  38070. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  38071. return node, nil
  38072. }
  38073. m.id = &node.ID
  38074. }
  38075. }
  38076. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38077. // executed in a transaction (ent.Tx), a transactional client is returned.
  38078. func (m WhatsappChannelMutation) Client() *Client {
  38079. client := &Client{config: m.config}
  38080. client.init()
  38081. return client
  38082. }
  38083. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38084. // it returns an error otherwise.
  38085. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  38086. if _, ok := m.driver.(*txDriver); !ok {
  38087. return nil, errors.New("ent: mutation is not running in a transaction")
  38088. }
  38089. tx := &Tx{config: m.config}
  38090. tx.init()
  38091. return tx, nil
  38092. }
  38093. // SetID sets the value of the id field. Note that this
  38094. // operation is only accepted on creation of WhatsappChannel entities.
  38095. func (m *WhatsappChannelMutation) SetID(id uint64) {
  38096. m.id = &id
  38097. }
  38098. // ID returns the ID value in the mutation. Note that the ID is only available
  38099. // if it was provided to the builder or after it was returned from the database.
  38100. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  38101. if m.id == nil {
  38102. return
  38103. }
  38104. return *m.id, true
  38105. }
  38106. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38107. // That means, if the mutation is applied within a transaction with an isolation level such
  38108. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38109. // or updated by the mutation.
  38110. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  38111. switch {
  38112. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38113. id, exists := m.ID()
  38114. if exists {
  38115. return []uint64{id}, nil
  38116. }
  38117. fallthrough
  38118. case m.op.Is(OpUpdate | OpDelete):
  38119. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  38120. default:
  38121. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38122. }
  38123. }
  38124. // SetCreatedAt sets the "created_at" field.
  38125. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  38126. m.created_at = &t
  38127. }
  38128. // CreatedAt returns the value of the "created_at" field in the mutation.
  38129. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  38130. v := m.created_at
  38131. if v == nil {
  38132. return
  38133. }
  38134. return *v, true
  38135. }
  38136. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  38137. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38139. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38140. if !m.op.Is(OpUpdateOne) {
  38141. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38142. }
  38143. if m.id == nil || m.oldValue == nil {
  38144. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38145. }
  38146. oldValue, err := m.oldValue(ctx)
  38147. if err != nil {
  38148. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38149. }
  38150. return oldValue.CreatedAt, nil
  38151. }
  38152. // ResetCreatedAt resets all changes to the "created_at" field.
  38153. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  38154. m.created_at = nil
  38155. }
  38156. // SetUpdatedAt sets the "updated_at" field.
  38157. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  38158. m.updated_at = &t
  38159. }
  38160. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38161. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  38162. v := m.updated_at
  38163. if v == nil {
  38164. return
  38165. }
  38166. return *v, true
  38167. }
  38168. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  38169. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38171. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38172. if !m.op.Is(OpUpdateOne) {
  38173. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38174. }
  38175. if m.id == nil || m.oldValue == nil {
  38176. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38177. }
  38178. oldValue, err := m.oldValue(ctx)
  38179. if err != nil {
  38180. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38181. }
  38182. return oldValue.UpdatedAt, nil
  38183. }
  38184. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38185. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  38186. m.updated_at = nil
  38187. }
  38188. // SetStatus sets the "status" field.
  38189. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  38190. m.status = &u
  38191. m.addstatus = nil
  38192. }
  38193. // Status returns the value of the "status" field in the mutation.
  38194. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  38195. v := m.status
  38196. if v == nil {
  38197. return
  38198. }
  38199. return *v, true
  38200. }
  38201. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  38202. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38204. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38205. if !m.op.Is(OpUpdateOne) {
  38206. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38207. }
  38208. if m.id == nil || m.oldValue == nil {
  38209. return v, errors.New("OldStatus requires an ID field in the mutation")
  38210. }
  38211. oldValue, err := m.oldValue(ctx)
  38212. if err != nil {
  38213. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38214. }
  38215. return oldValue.Status, nil
  38216. }
  38217. // AddStatus adds u to the "status" field.
  38218. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  38219. if m.addstatus != nil {
  38220. *m.addstatus += u
  38221. } else {
  38222. m.addstatus = &u
  38223. }
  38224. }
  38225. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38226. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  38227. v := m.addstatus
  38228. if v == nil {
  38229. return
  38230. }
  38231. return *v, true
  38232. }
  38233. // ClearStatus clears the value of the "status" field.
  38234. func (m *WhatsappChannelMutation) ClearStatus() {
  38235. m.status = nil
  38236. m.addstatus = nil
  38237. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  38238. }
  38239. // StatusCleared returns if the "status" field was cleared in this mutation.
  38240. func (m *WhatsappChannelMutation) StatusCleared() bool {
  38241. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  38242. return ok
  38243. }
  38244. // ResetStatus resets all changes to the "status" field.
  38245. func (m *WhatsappChannelMutation) ResetStatus() {
  38246. m.status = nil
  38247. m.addstatus = nil
  38248. delete(m.clearedFields, whatsappchannel.FieldStatus)
  38249. }
  38250. // SetDeletedAt sets the "deleted_at" field.
  38251. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  38252. m.deleted_at = &t
  38253. }
  38254. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38255. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  38256. v := m.deleted_at
  38257. if v == nil {
  38258. return
  38259. }
  38260. return *v, true
  38261. }
  38262. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  38263. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38265. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38266. if !m.op.Is(OpUpdateOne) {
  38267. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38268. }
  38269. if m.id == nil || m.oldValue == nil {
  38270. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38271. }
  38272. oldValue, err := m.oldValue(ctx)
  38273. if err != nil {
  38274. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38275. }
  38276. return oldValue.DeletedAt, nil
  38277. }
  38278. // ClearDeletedAt clears the value of the "deleted_at" field.
  38279. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  38280. m.deleted_at = nil
  38281. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  38282. }
  38283. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38284. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  38285. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  38286. return ok
  38287. }
  38288. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38289. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  38290. m.deleted_at = nil
  38291. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  38292. }
  38293. // SetAk sets the "ak" field.
  38294. func (m *WhatsappChannelMutation) SetAk(s string) {
  38295. m.ak = &s
  38296. }
  38297. // Ak returns the value of the "ak" field in the mutation.
  38298. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  38299. v := m.ak
  38300. if v == nil {
  38301. return
  38302. }
  38303. return *v, true
  38304. }
  38305. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  38306. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38308. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  38309. if !m.op.Is(OpUpdateOne) {
  38310. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  38311. }
  38312. if m.id == nil || m.oldValue == nil {
  38313. return v, errors.New("OldAk requires an ID field in the mutation")
  38314. }
  38315. oldValue, err := m.oldValue(ctx)
  38316. if err != nil {
  38317. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  38318. }
  38319. return oldValue.Ak, nil
  38320. }
  38321. // ClearAk clears the value of the "ak" field.
  38322. func (m *WhatsappChannelMutation) ClearAk() {
  38323. m.ak = nil
  38324. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  38325. }
  38326. // AkCleared returns if the "ak" field was cleared in this mutation.
  38327. func (m *WhatsappChannelMutation) AkCleared() bool {
  38328. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  38329. return ok
  38330. }
  38331. // ResetAk resets all changes to the "ak" field.
  38332. func (m *WhatsappChannelMutation) ResetAk() {
  38333. m.ak = nil
  38334. delete(m.clearedFields, whatsappchannel.FieldAk)
  38335. }
  38336. // SetSk sets the "sk" field.
  38337. func (m *WhatsappChannelMutation) SetSk(s string) {
  38338. m.sk = &s
  38339. }
  38340. // Sk returns the value of the "sk" field in the mutation.
  38341. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  38342. v := m.sk
  38343. if v == nil {
  38344. return
  38345. }
  38346. return *v, true
  38347. }
  38348. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  38349. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38351. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  38352. if !m.op.Is(OpUpdateOne) {
  38353. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  38354. }
  38355. if m.id == nil || m.oldValue == nil {
  38356. return v, errors.New("OldSk requires an ID field in the mutation")
  38357. }
  38358. oldValue, err := m.oldValue(ctx)
  38359. if err != nil {
  38360. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  38361. }
  38362. return oldValue.Sk, nil
  38363. }
  38364. // ResetSk resets all changes to the "sk" field.
  38365. func (m *WhatsappChannelMutation) ResetSk() {
  38366. m.sk = nil
  38367. }
  38368. // SetWaID sets the "wa_id" field.
  38369. func (m *WhatsappChannelMutation) SetWaID(s string) {
  38370. m.wa_id = &s
  38371. }
  38372. // WaID returns the value of the "wa_id" field in the mutation.
  38373. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  38374. v := m.wa_id
  38375. if v == nil {
  38376. return
  38377. }
  38378. return *v, true
  38379. }
  38380. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  38381. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38383. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  38384. if !m.op.Is(OpUpdateOne) {
  38385. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  38386. }
  38387. if m.id == nil || m.oldValue == nil {
  38388. return v, errors.New("OldWaID requires an ID field in the mutation")
  38389. }
  38390. oldValue, err := m.oldValue(ctx)
  38391. if err != nil {
  38392. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  38393. }
  38394. return oldValue.WaID, nil
  38395. }
  38396. // ClearWaID clears the value of the "wa_id" field.
  38397. func (m *WhatsappChannelMutation) ClearWaID() {
  38398. m.wa_id = nil
  38399. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  38400. }
  38401. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  38402. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  38403. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  38404. return ok
  38405. }
  38406. // ResetWaID resets all changes to the "wa_id" field.
  38407. func (m *WhatsappChannelMutation) ResetWaID() {
  38408. m.wa_id = nil
  38409. delete(m.clearedFields, whatsappchannel.FieldWaID)
  38410. }
  38411. // SetWaName sets the "wa_name" field.
  38412. func (m *WhatsappChannelMutation) SetWaName(s string) {
  38413. m.wa_name = &s
  38414. }
  38415. // WaName returns the value of the "wa_name" field in the mutation.
  38416. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  38417. v := m.wa_name
  38418. if v == nil {
  38419. return
  38420. }
  38421. return *v, true
  38422. }
  38423. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  38424. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38426. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  38427. if !m.op.Is(OpUpdateOne) {
  38428. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  38429. }
  38430. if m.id == nil || m.oldValue == nil {
  38431. return v, errors.New("OldWaName requires an ID field in the mutation")
  38432. }
  38433. oldValue, err := m.oldValue(ctx)
  38434. if err != nil {
  38435. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  38436. }
  38437. return oldValue.WaName, nil
  38438. }
  38439. // ClearWaName clears the value of the "wa_name" field.
  38440. func (m *WhatsappChannelMutation) ClearWaName() {
  38441. m.wa_name = nil
  38442. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  38443. }
  38444. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  38445. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  38446. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  38447. return ok
  38448. }
  38449. // ResetWaName resets all changes to the "wa_name" field.
  38450. func (m *WhatsappChannelMutation) ResetWaName() {
  38451. m.wa_name = nil
  38452. delete(m.clearedFields, whatsappchannel.FieldWaName)
  38453. }
  38454. // SetWabaID sets the "waba_id" field.
  38455. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  38456. m.waba_id = &u
  38457. m.addwaba_id = nil
  38458. }
  38459. // WabaID returns the value of the "waba_id" field in the mutation.
  38460. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  38461. v := m.waba_id
  38462. if v == nil {
  38463. return
  38464. }
  38465. return *v, true
  38466. }
  38467. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  38468. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38470. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  38471. if !m.op.Is(OpUpdateOne) {
  38472. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  38473. }
  38474. if m.id == nil || m.oldValue == nil {
  38475. return v, errors.New("OldWabaID requires an ID field in the mutation")
  38476. }
  38477. oldValue, err := m.oldValue(ctx)
  38478. if err != nil {
  38479. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  38480. }
  38481. return oldValue.WabaID, nil
  38482. }
  38483. // AddWabaID adds u to the "waba_id" field.
  38484. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  38485. if m.addwaba_id != nil {
  38486. *m.addwaba_id += u
  38487. } else {
  38488. m.addwaba_id = &u
  38489. }
  38490. }
  38491. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  38492. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  38493. v := m.addwaba_id
  38494. if v == nil {
  38495. return
  38496. }
  38497. return *v, true
  38498. }
  38499. // ResetWabaID resets all changes to the "waba_id" field.
  38500. func (m *WhatsappChannelMutation) ResetWabaID() {
  38501. m.waba_id = nil
  38502. m.addwaba_id = nil
  38503. }
  38504. // SetBusinessID sets the "business_id" field.
  38505. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  38506. m.business_id = &u
  38507. m.addbusiness_id = nil
  38508. }
  38509. // BusinessID returns the value of the "business_id" field in the mutation.
  38510. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  38511. v := m.business_id
  38512. if v == nil {
  38513. return
  38514. }
  38515. return *v, true
  38516. }
  38517. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  38518. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38520. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  38521. if !m.op.Is(OpUpdateOne) {
  38522. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  38523. }
  38524. if m.id == nil || m.oldValue == nil {
  38525. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  38526. }
  38527. oldValue, err := m.oldValue(ctx)
  38528. if err != nil {
  38529. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  38530. }
  38531. return oldValue.BusinessID, nil
  38532. }
  38533. // AddBusinessID adds u to the "business_id" field.
  38534. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  38535. if m.addbusiness_id != nil {
  38536. *m.addbusiness_id += u
  38537. } else {
  38538. m.addbusiness_id = &u
  38539. }
  38540. }
  38541. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  38542. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  38543. v := m.addbusiness_id
  38544. if v == nil {
  38545. return
  38546. }
  38547. return *v, true
  38548. }
  38549. // ResetBusinessID resets all changes to the "business_id" field.
  38550. func (m *WhatsappChannelMutation) ResetBusinessID() {
  38551. m.business_id = nil
  38552. m.addbusiness_id = nil
  38553. }
  38554. // SetOrganizationID sets the "organization_id" field.
  38555. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  38556. m.organization_id = &u
  38557. m.addorganization_id = nil
  38558. }
  38559. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38560. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  38561. v := m.organization_id
  38562. if v == nil {
  38563. return
  38564. }
  38565. return *v, true
  38566. }
  38567. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  38568. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38570. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38571. if !m.op.Is(OpUpdateOne) {
  38572. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38573. }
  38574. if m.id == nil || m.oldValue == nil {
  38575. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38576. }
  38577. oldValue, err := m.oldValue(ctx)
  38578. if err != nil {
  38579. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38580. }
  38581. return oldValue.OrganizationID, nil
  38582. }
  38583. // AddOrganizationID adds u to the "organization_id" field.
  38584. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  38585. if m.addorganization_id != nil {
  38586. *m.addorganization_id += u
  38587. } else {
  38588. m.addorganization_id = &u
  38589. }
  38590. }
  38591. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38592. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  38593. v := m.addorganization_id
  38594. if v == nil {
  38595. return
  38596. }
  38597. return *v, true
  38598. }
  38599. // ClearOrganizationID clears the value of the "organization_id" field.
  38600. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  38601. m.organization_id = nil
  38602. m.addorganization_id = nil
  38603. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  38604. }
  38605. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38606. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  38607. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  38608. return ok
  38609. }
  38610. // ResetOrganizationID resets all changes to the "organization_id" field.
  38611. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  38612. m.organization_id = nil
  38613. m.addorganization_id = nil
  38614. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  38615. }
  38616. // SetVerifyAccount sets the "verify_account" field.
  38617. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  38618. m.verify_account = &s
  38619. }
  38620. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  38621. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  38622. v := m.verify_account
  38623. if v == nil {
  38624. return
  38625. }
  38626. return *v, true
  38627. }
  38628. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  38629. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38631. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  38632. if !m.op.Is(OpUpdateOne) {
  38633. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  38634. }
  38635. if m.id == nil || m.oldValue == nil {
  38636. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  38637. }
  38638. oldValue, err := m.oldValue(ctx)
  38639. if err != nil {
  38640. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  38641. }
  38642. return oldValue.VerifyAccount, nil
  38643. }
  38644. // ResetVerifyAccount resets all changes to the "verify_account" field.
  38645. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  38646. m.verify_account = nil
  38647. }
  38648. // Where appends a list predicates to the WhatsappChannelMutation builder.
  38649. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  38650. m.predicates = append(m.predicates, ps...)
  38651. }
  38652. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  38653. // users can use type-assertion to append predicates that do not depend on any generated package.
  38654. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  38655. p := make([]predicate.WhatsappChannel, len(ps))
  38656. for i := range ps {
  38657. p[i] = ps[i]
  38658. }
  38659. m.Where(p...)
  38660. }
  38661. // Op returns the operation name.
  38662. func (m *WhatsappChannelMutation) Op() Op {
  38663. return m.op
  38664. }
  38665. // SetOp allows setting the mutation operation.
  38666. func (m *WhatsappChannelMutation) SetOp(op Op) {
  38667. m.op = op
  38668. }
  38669. // Type returns the node type of this mutation (WhatsappChannel).
  38670. func (m *WhatsappChannelMutation) Type() string {
  38671. return m.typ
  38672. }
  38673. // Fields returns all fields that were changed during this mutation. Note that in
  38674. // order to get all numeric fields that were incremented/decremented, call
  38675. // AddedFields().
  38676. func (m *WhatsappChannelMutation) Fields() []string {
  38677. fields := make([]string, 0, 12)
  38678. if m.created_at != nil {
  38679. fields = append(fields, whatsappchannel.FieldCreatedAt)
  38680. }
  38681. if m.updated_at != nil {
  38682. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  38683. }
  38684. if m.status != nil {
  38685. fields = append(fields, whatsappchannel.FieldStatus)
  38686. }
  38687. if m.deleted_at != nil {
  38688. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38689. }
  38690. if m.ak != nil {
  38691. fields = append(fields, whatsappchannel.FieldAk)
  38692. }
  38693. if m.sk != nil {
  38694. fields = append(fields, whatsappchannel.FieldSk)
  38695. }
  38696. if m.wa_id != nil {
  38697. fields = append(fields, whatsappchannel.FieldWaID)
  38698. }
  38699. if m.wa_name != nil {
  38700. fields = append(fields, whatsappchannel.FieldWaName)
  38701. }
  38702. if m.waba_id != nil {
  38703. fields = append(fields, whatsappchannel.FieldWabaID)
  38704. }
  38705. if m.business_id != nil {
  38706. fields = append(fields, whatsappchannel.FieldBusinessID)
  38707. }
  38708. if m.organization_id != nil {
  38709. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38710. }
  38711. if m.verify_account != nil {
  38712. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  38713. }
  38714. return fields
  38715. }
  38716. // Field returns the value of a field with the given name. The second boolean
  38717. // return value indicates that this field was not set, or was not defined in the
  38718. // schema.
  38719. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  38720. switch name {
  38721. case whatsappchannel.FieldCreatedAt:
  38722. return m.CreatedAt()
  38723. case whatsappchannel.FieldUpdatedAt:
  38724. return m.UpdatedAt()
  38725. case whatsappchannel.FieldStatus:
  38726. return m.Status()
  38727. case whatsappchannel.FieldDeletedAt:
  38728. return m.DeletedAt()
  38729. case whatsappchannel.FieldAk:
  38730. return m.Ak()
  38731. case whatsappchannel.FieldSk:
  38732. return m.Sk()
  38733. case whatsappchannel.FieldWaID:
  38734. return m.WaID()
  38735. case whatsappchannel.FieldWaName:
  38736. return m.WaName()
  38737. case whatsappchannel.FieldWabaID:
  38738. return m.WabaID()
  38739. case whatsappchannel.FieldBusinessID:
  38740. return m.BusinessID()
  38741. case whatsappchannel.FieldOrganizationID:
  38742. return m.OrganizationID()
  38743. case whatsappchannel.FieldVerifyAccount:
  38744. return m.VerifyAccount()
  38745. }
  38746. return nil, false
  38747. }
  38748. // OldField returns the old value of the field from the database. An error is
  38749. // returned if the mutation operation is not UpdateOne, or the query to the
  38750. // database failed.
  38751. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38752. switch name {
  38753. case whatsappchannel.FieldCreatedAt:
  38754. return m.OldCreatedAt(ctx)
  38755. case whatsappchannel.FieldUpdatedAt:
  38756. return m.OldUpdatedAt(ctx)
  38757. case whatsappchannel.FieldStatus:
  38758. return m.OldStatus(ctx)
  38759. case whatsappchannel.FieldDeletedAt:
  38760. return m.OldDeletedAt(ctx)
  38761. case whatsappchannel.FieldAk:
  38762. return m.OldAk(ctx)
  38763. case whatsappchannel.FieldSk:
  38764. return m.OldSk(ctx)
  38765. case whatsappchannel.FieldWaID:
  38766. return m.OldWaID(ctx)
  38767. case whatsappchannel.FieldWaName:
  38768. return m.OldWaName(ctx)
  38769. case whatsappchannel.FieldWabaID:
  38770. return m.OldWabaID(ctx)
  38771. case whatsappchannel.FieldBusinessID:
  38772. return m.OldBusinessID(ctx)
  38773. case whatsappchannel.FieldOrganizationID:
  38774. return m.OldOrganizationID(ctx)
  38775. case whatsappchannel.FieldVerifyAccount:
  38776. return m.OldVerifyAccount(ctx)
  38777. }
  38778. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  38779. }
  38780. // SetField sets the value of a field with the given name. It returns an error if
  38781. // the field is not defined in the schema, or if the type mismatched the field
  38782. // type.
  38783. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  38784. switch name {
  38785. case whatsappchannel.FieldCreatedAt:
  38786. v, ok := value.(time.Time)
  38787. if !ok {
  38788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38789. }
  38790. m.SetCreatedAt(v)
  38791. return nil
  38792. case whatsappchannel.FieldUpdatedAt:
  38793. v, ok := value.(time.Time)
  38794. if !ok {
  38795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38796. }
  38797. m.SetUpdatedAt(v)
  38798. return nil
  38799. case whatsappchannel.FieldStatus:
  38800. v, ok := value.(uint8)
  38801. if !ok {
  38802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38803. }
  38804. m.SetStatus(v)
  38805. return nil
  38806. case whatsappchannel.FieldDeletedAt:
  38807. v, ok := value.(time.Time)
  38808. if !ok {
  38809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38810. }
  38811. m.SetDeletedAt(v)
  38812. return nil
  38813. case whatsappchannel.FieldAk:
  38814. v, ok := value.(string)
  38815. if !ok {
  38816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38817. }
  38818. m.SetAk(v)
  38819. return nil
  38820. case whatsappchannel.FieldSk:
  38821. v, ok := value.(string)
  38822. if !ok {
  38823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38824. }
  38825. m.SetSk(v)
  38826. return nil
  38827. case whatsappchannel.FieldWaID:
  38828. v, ok := value.(string)
  38829. if !ok {
  38830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38831. }
  38832. m.SetWaID(v)
  38833. return nil
  38834. case whatsappchannel.FieldWaName:
  38835. v, ok := value.(string)
  38836. if !ok {
  38837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38838. }
  38839. m.SetWaName(v)
  38840. return nil
  38841. case whatsappchannel.FieldWabaID:
  38842. v, ok := value.(uint64)
  38843. if !ok {
  38844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38845. }
  38846. m.SetWabaID(v)
  38847. return nil
  38848. case whatsappchannel.FieldBusinessID:
  38849. v, ok := value.(uint64)
  38850. if !ok {
  38851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38852. }
  38853. m.SetBusinessID(v)
  38854. return nil
  38855. case whatsappchannel.FieldOrganizationID:
  38856. v, ok := value.(uint64)
  38857. if !ok {
  38858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38859. }
  38860. m.SetOrganizationID(v)
  38861. return nil
  38862. case whatsappchannel.FieldVerifyAccount:
  38863. v, ok := value.(string)
  38864. if !ok {
  38865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38866. }
  38867. m.SetVerifyAccount(v)
  38868. return nil
  38869. }
  38870. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38871. }
  38872. // AddedFields returns all numeric fields that were incremented/decremented during
  38873. // this mutation.
  38874. func (m *WhatsappChannelMutation) AddedFields() []string {
  38875. var fields []string
  38876. if m.addstatus != nil {
  38877. fields = append(fields, whatsappchannel.FieldStatus)
  38878. }
  38879. if m.addwaba_id != nil {
  38880. fields = append(fields, whatsappchannel.FieldWabaID)
  38881. }
  38882. if m.addbusiness_id != nil {
  38883. fields = append(fields, whatsappchannel.FieldBusinessID)
  38884. }
  38885. if m.addorganization_id != nil {
  38886. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38887. }
  38888. return fields
  38889. }
  38890. // AddedField returns the numeric value that was incremented/decremented on a field
  38891. // with the given name. The second boolean return value indicates that this field
  38892. // was not set, or was not defined in the schema.
  38893. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  38894. switch name {
  38895. case whatsappchannel.FieldStatus:
  38896. return m.AddedStatus()
  38897. case whatsappchannel.FieldWabaID:
  38898. return m.AddedWabaID()
  38899. case whatsappchannel.FieldBusinessID:
  38900. return m.AddedBusinessID()
  38901. case whatsappchannel.FieldOrganizationID:
  38902. return m.AddedOrganizationID()
  38903. }
  38904. return nil, false
  38905. }
  38906. // AddField adds the value to the field with the given name. It returns an error if
  38907. // the field is not defined in the schema, or if the type mismatched the field
  38908. // type.
  38909. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  38910. switch name {
  38911. case whatsappchannel.FieldStatus:
  38912. v, ok := value.(int8)
  38913. if !ok {
  38914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38915. }
  38916. m.AddStatus(v)
  38917. return nil
  38918. case whatsappchannel.FieldWabaID:
  38919. v, ok := value.(int64)
  38920. if !ok {
  38921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38922. }
  38923. m.AddWabaID(v)
  38924. return nil
  38925. case whatsappchannel.FieldBusinessID:
  38926. v, ok := value.(int64)
  38927. if !ok {
  38928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38929. }
  38930. m.AddBusinessID(v)
  38931. return nil
  38932. case whatsappchannel.FieldOrganizationID:
  38933. v, ok := value.(int64)
  38934. if !ok {
  38935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38936. }
  38937. m.AddOrganizationID(v)
  38938. return nil
  38939. }
  38940. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  38941. }
  38942. // ClearedFields returns all nullable fields that were cleared during this
  38943. // mutation.
  38944. func (m *WhatsappChannelMutation) ClearedFields() []string {
  38945. var fields []string
  38946. if m.FieldCleared(whatsappchannel.FieldStatus) {
  38947. fields = append(fields, whatsappchannel.FieldStatus)
  38948. }
  38949. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  38950. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38951. }
  38952. if m.FieldCleared(whatsappchannel.FieldAk) {
  38953. fields = append(fields, whatsappchannel.FieldAk)
  38954. }
  38955. if m.FieldCleared(whatsappchannel.FieldWaID) {
  38956. fields = append(fields, whatsappchannel.FieldWaID)
  38957. }
  38958. if m.FieldCleared(whatsappchannel.FieldWaName) {
  38959. fields = append(fields, whatsappchannel.FieldWaName)
  38960. }
  38961. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  38962. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38963. }
  38964. return fields
  38965. }
  38966. // FieldCleared returns a boolean indicating if a field with the given name was
  38967. // cleared in this mutation.
  38968. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  38969. _, ok := m.clearedFields[name]
  38970. return ok
  38971. }
  38972. // ClearField clears the value of the field with the given name. It returns an
  38973. // error if the field is not defined in the schema.
  38974. func (m *WhatsappChannelMutation) ClearField(name string) error {
  38975. switch name {
  38976. case whatsappchannel.FieldStatus:
  38977. m.ClearStatus()
  38978. return nil
  38979. case whatsappchannel.FieldDeletedAt:
  38980. m.ClearDeletedAt()
  38981. return nil
  38982. case whatsappchannel.FieldAk:
  38983. m.ClearAk()
  38984. return nil
  38985. case whatsappchannel.FieldWaID:
  38986. m.ClearWaID()
  38987. return nil
  38988. case whatsappchannel.FieldWaName:
  38989. m.ClearWaName()
  38990. return nil
  38991. case whatsappchannel.FieldOrganizationID:
  38992. m.ClearOrganizationID()
  38993. return nil
  38994. }
  38995. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  38996. }
  38997. // ResetField resets all changes in the mutation for the field with the given name.
  38998. // It returns an error if the field is not defined in the schema.
  38999. func (m *WhatsappChannelMutation) ResetField(name string) error {
  39000. switch name {
  39001. case whatsappchannel.FieldCreatedAt:
  39002. m.ResetCreatedAt()
  39003. return nil
  39004. case whatsappchannel.FieldUpdatedAt:
  39005. m.ResetUpdatedAt()
  39006. return nil
  39007. case whatsappchannel.FieldStatus:
  39008. m.ResetStatus()
  39009. return nil
  39010. case whatsappchannel.FieldDeletedAt:
  39011. m.ResetDeletedAt()
  39012. return nil
  39013. case whatsappchannel.FieldAk:
  39014. m.ResetAk()
  39015. return nil
  39016. case whatsappchannel.FieldSk:
  39017. m.ResetSk()
  39018. return nil
  39019. case whatsappchannel.FieldWaID:
  39020. m.ResetWaID()
  39021. return nil
  39022. case whatsappchannel.FieldWaName:
  39023. m.ResetWaName()
  39024. return nil
  39025. case whatsappchannel.FieldWabaID:
  39026. m.ResetWabaID()
  39027. return nil
  39028. case whatsappchannel.FieldBusinessID:
  39029. m.ResetBusinessID()
  39030. return nil
  39031. case whatsappchannel.FieldOrganizationID:
  39032. m.ResetOrganizationID()
  39033. return nil
  39034. case whatsappchannel.FieldVerifyAccount:
  39035. m.ResetVerifyAccount()
  39036. return nil
  39037. }
  39038. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  39039. }
  39040. // AddedEdges returns all edge names that were set/added in this mutation.
  39041. func (m *WhatsappChannelMutation) AddedEdges() []string {
  39042. edges := make([]string, 0, 0)
  39043. return edges
  39044. }
  39045. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39046. // name in this mutation.
  39047. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  39048. return nil
  39049. }
  39050. // RemovedEdges returns all edge names that were removed in this mutation.
  39051. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  39052. edges := make([]string, 0, 0)
  39053. return edges
  39054. }
  39055. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39056. // the given name in this mutation.
  39057. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  39058. return nil
  39059. }
  39060. // ClearedEdges returns all edge names that were cleared in this mutation.
  39061. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  39062. edges := make([]string, 0, 0)
  39063. return edges
  39064. }
  39065. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39066. // was cleared in this mutation.
  39067. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  39068. return false
  39069. }
  39070. // ClearEdge clears the value of the edge with the given name. It returns an error
  39071. // if that edge is not defined in the schema.
  39072. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  39073. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  39074. }
  39075. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39076. // It returns an error if the edge is not defined in the schema.
  39077. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  39078. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  39079. }
  39080. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  39081. type WorkExperienceMutation struct {
  39082. config
  39083. op Op
  39084. typ string
  39085. id *uint64
  39086. created_at *time.Time
  39087. updated_at *time.Time
  39088. deleted_at *time.Time
  39089. start_date *time.Time
  39090. end_date *time.Time
  39091. company *string
  39092. experience *string
  39093. organization_id *uint64
  39094. addorganization_id *int64
  39095. clearedFields map[string]struct{}
  39096. employee *uint64
  39097. clearedemployee bool
  39098. done bool
  39099. oldValue func(context.Context) (*WorkExperience, error)
  39100. predicates []predicate.WorkExperience
  39101. }
  39102. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  39103. // workexperienceOption allows management of the mutation configuration using functional options.
  39104. type workexperienceOption func(*WorkExperienceMutation)
  39105. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  39106. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  39107. m := &WorkExperienceMutation{
  39108. config: c,
  39109. op: op,
  39110. typ: TypeWorkExperience,
  39111. clearedFields: make(map[string]struct{}),
  39112. }
  39113. for _, opt := range opts {
  39114. opt(m)
  39115. }
  39116. return m
  39117. }
  39118. // withWorkExperienceID sets the ID field of the mutation.
  39119. func withWorkExperienceID(id uint64) workexperienceOption {
  39120. return func(m *WorkExperienceMutation) {
  39121. var (
  39122. err error
  39123. once sync.Once
  39124. value *WorkExperience
  39125. )
  39126. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  39127. once.Do(func() {
  39128. if m.done {
  39129. err = errors.New("querying old values post mutation is not allowed")
  39130. } else {
  39131. value, err = m.Client().WorkExperience.Get(ctx, id)
  39132. }
  39133. })
  39134. return value, err
  39135. }
  39136. m.id = &id
  39137. }
  39138. }
  39139. // withWorkExperience sets the old WorkExperience of the mutation.
  39140. func withWorkExperience(node *WorkExperience) workexperienceOption {
  39141. return func(m *WorkExperienceMutation) {
  39142. m.oldValue = func(context.Context) (*WorkExperience, error) {
  39143. return node, nil
  39144. }
  39145. m.id = &node.ID
  39146. }
  39147. }
  39148. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39149. // executed in a transaction (ent.Tx), a transactional client is returned.
  39150. func (m WorkExperienceMutation) Client() *Client {
  39151. client := &Client{config: m.config}
  39152. client.init()
  39153. return client
  39154. }
  39155. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39156. // it returns an error otherwise.
  39157. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  39158. if _, ok := m.driver.(*txDriver); !ok {
  39159. return nil, errors.New("ent: mutation is not running in a transaction")
  39160. }
  39161. tx := &Tx{config: m.config}
  39162. tx.init()
  39163. return tx, nil
  39164. }
  39165. // SetID sets the value of the id field. Note that this
  39166. // operation is only accepted on creation of WorkExperience entities.
  39167. func (m *WorkExperienceMutation) SetID(id uint64) {
  39168. m.id = &id
  39169. }
  39170. // ID returns the ID value in the mutation. Note that the ID is only available
  39171. // if it was provided to the builder or after it was returned from the database.
  39172. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  39173. if m.id == nil {
  39174. return
  39175. }
  39176. return *m.id, true
  39177. }
  39178. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39179. // That means, if the mutation is applied within a transaction with an isolation level such
  39180. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39181. // or updated by the mutation.
  39182. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  39183. switch {
  39184. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39185. id, exists := m.ID()
  39186. if exists {
  39187. return []uint64{id}, nil
  39188. }
  39189. fallthrough
  39190. case m.op.Is(OpUpdate | OpDelete):
  39191. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  39192. default:
  39193. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39194. }
  39195. }
  39196. // SetCreatedAt sets the "created_at" field.
  39197. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  39198. m.created_at = &t
  39199. }
  39200. // CreatedAt returns the value of the "created_at" field in the mutation.
  39201. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  39202. v := m.created_at
  39203. if v == nil {
  39204. return
  39205. }
  39206. return *v, true
  39207. }
  39208. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  39209. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39211. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39212. if !m.op.Is(OpUpdateOne) {
  39213. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39214. }
  39215. if m.id == nil || m.oldValue == nil {
  39216. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39217. }
  39218. oldValue, err := m.oldValue(ctx)
  39219. if err != nil {
  39220. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39221. }
  39222. return oldValue.CreatedAt, nil
  39223. }
  39224. // ResetCreatedAt resets all changes to the "created_at" field.
  39225. func (m *WorkExperienceMutation) ResetCreatedAt() {
  39226. m.created_at = nil
  39227. }
  39228. // SetUpdatedAt sets the "updated_at" field.
  39229. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  39230. m.updated_at = &t
  39231. }
  39232. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39233. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  39234. v := m.updated_at
  39235. if v == nil {
  39236. return
  39237. }
  39238. return *v, true
  39239. }
  39240. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  39241. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39243. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39244. if !m.op.Is(OpUpdateOne) {
  39245. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39246. }
  39247. if m.id == nil || m.oldValue == nil {
  39248. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39249. }
  39250. oldValue, err := m.oldValue(ctx)
  39251. if err != nil {
  39252. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39253. }
  39254. return oldValue.UpdatedAt, nil
  39255. }
  39256. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39257. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  39258. m.updated_at = nil
  39259. }
  39260. // SetDeletedAt sets the "deleted_at" field.
  39261. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  39262. m.deleted_at = &t
  39263. }
  39264. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39265. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  39266. v := m.deleted_at
  39267. if v == nil {
  39268. return
  39269. }
  39270. return *v, true
  39271. }
  39272. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  39273. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39275. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39276. if !m.op.Is(OpUpdateOne) {
  39277. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39278. }
  39279. if m.id == nil || m.oldValue == nil {
  39280. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39281. }
  39282. oldValue, err := m.oldValue(ctx)
  39283. if err != nil {
  39284. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39285. }
  39286. return oldValue.DeletedAt, nil
  39287. }
  39288. // ClearDeletedAt clears the value of the "deleted_at" field.
  39289. func (m *WorkExperienceMutation) ClearDeletedAt() {
  39290. m.deleted_at = nil
  39291. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  39292. }
  39293. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39294. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  39295. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  39296. return ok
  39297. }
  39298. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39299. func (m *WorkExperienceMutation) ResetDeletedAt() {
  39300. m.deleted_at = nil
  39301. delete(m.clearedFields, workexperience.FieldDeletedAt)
  39302. }
  39303. // SetEmployeeID sets the "employee_id" field.
  39304. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  39305. m.employee = &u
  39306. }
  39307. // EmployeeID returns the value of the "employee_id" field in the mutation.
  39308. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  39309. v := m.employee
  39310. if v == nil {
  39311. return
  39312. }
  39313. return *v, true
  39314. }
  39315. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  39316. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39318. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  39319. if !m.op.Is(OpUpdateOne) {
  39320. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  39321. }
  39322. if m.id == nil || m.oldValue == nil {
  39323. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  39324. }
  39325. oldValue, err := m.oldValue(ctx)
  39326. if err != nil {
  39327. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  39328. }
  39329. return oldValue.EmployeeID, nil
  39330. }
  39331. // ResetEmployeeID resets all changes to the "employee_id" field.
  39332. func (m *WorkExperienceMutation) ResetEmployeeID() {
  39333. m.employee = nil
  39334. }
  39335. // SetStartDate sets the "start_date" field.
  39336. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  39337. m.start_date = &t
  39338. }
  39339. // StartDate returns the value of the "start_date" field in the mutation.
  39340. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  39341. v := m.start_date
  39342. if v == nil {
  39343. return
  39344. }
  39345. return *v, true
  39346. }
  39347. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  39348. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39350. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  39351. if !m.op.Is(OpUpdateOne) {
  39352. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  39353. }
  39354. if m.id == nil || m.oldValue == nil {
  39355. return v, errors.New("OldStartDate requires an ID field in the mutation")
  39356. }
  39357. oldValue, err := m.oldValue(ctx)
  39358. if err != nil {
  39359. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  39360. }
  39361. return oldValue.StartDate, nil
  39362. }
  39363. // ResetStartDate resets all changes to the "start_date" field.
  39364. func (m *WorkExperienceMutation) ResetStartDate() {
  39365. m.start_date = nil
  39366. }
  39367. // SetEndDate sets the "end_date" field.
  39368. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  39369. m.end_date = &t
  39370. }
  39371. // EndDate returns the value of the "end_date" field in the mutation.
  39372. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  39373. v := m.end_date
  39374. if v == nil {
  39375. return
  39376. }
  39377. return *v, true
  39378. }
  39379. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  39380. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39382. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  39383. if !m.op.Is(OpUpdateOne) {
  39384. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  39385. }
  39386. if m.id == nil || m.oldValue == nil {
  39387. return v, errors.New("OldEndDate requires an ID field in the mutation")
  39388. }
  39389. oldValue, err := m.oldValue(ctx)
  39390. if err != nil {
  39391. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  39392. }
  39393. return oldValue.EndDate, nil
  39394. }
  39395. // ResetEndDate resets all changes to the "end_date" field.
  39396. func (m *WorkExperienceMutation) ResetEndDate() {
  39397. m.end_date = nil
  39398. }
  39399. // SetCompany sets the "company" field.
  39400. func (m *WorkExperienceMutation) SetCompany(s string) {
  39401. m.company = &s
  39402. }
  39403. // Company returns the value of the "company" field in the mutation.
  39404. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  39405. v := m.company
  39406. if v == nil {
  39407. return
  39408. }
  39409. return *v, true
  39410. }
  39411. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  39412. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39414. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  39415. if !m.op.Is(OpUpdateOne) {
  39416. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39417. }
  39418. if m.id == nil || m.oldValue == nil {
  39419. return v, errors.New("OldCompany requires an ID field in the mutation")
  39420. }
  39421. oldValue, err := m.oldValue(ctx)
  39422. if err != nil {
  39423. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39424. }
  39425. return oldValue.Company, nil
  39426. }
  39427. // ResetCompany resets all changes to the "company" field.
  39428. func (m *WorkExperienceMutation) ResetCompany() {
  39429. m.company = nil
  39430. }
  39431. // SetExperience sets the "experience" field.
  39432. func (m *WorkExperienceMutation) SetExperience(s string) {
  39433. m.experience = &s
  39434. }
  39435. // Experience returns the value of the "experience" field in the mutation.
  39436. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  39437. v := m.experience
  39438. if v == nil {
  39439. return
  39440. }
  39441. return *v, true
  39442. }
  39443. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  39444. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39446. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  39447. if !m.op.Is(OpUpdateOne) {
  39448. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  39449. }
  39450. if m.id == nil || m.oldValue == nil {
  39451. return v, errors.New("OldExperience requires an ID field in the mutation")
  39452. }
  39453. oldValue, err := m.oldValue(ctx)
  39454. if err != nil {
  39455. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  39456. }
  39457. return oldValue.Experience, nil
  39458. }
  39459. // ResetExperience resets all changes to the "experience" field.
  39460. func (m *WorkExperienceMutation) ResetExperience() {
  39461. m.experience = nil
  39462. }
  39463. // SetOrganizationID sets the "organization_id" field.
  39464. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  39465. m.organization_id = &u
  39466. m.addorganization_id = nil
  39467. }
  39468. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39469. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  39470. v := m.organization_id
  39471. if v == nil {
  39472. return
  39473. }
  39474. return *v, true
  39475. }
  39476. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  39477. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39479. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39480. if !m.op.Is(OpUpdateOne) {
  39481. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39482. }
  39483. if m.id == nil || m.oldValue == nil {
  39484. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39485. }
  39486. oldValue, err := m.oldValue(ctx)
  39487. if err != nil {
  39488. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39489. }
  39490. return oldValue.OrganizationID, nil
  39491. }
  39492. // AddOrganizationID adds u to the "organization_id" field.
  39493. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  39494. if m.addorganization_id != nil {
  39495. *m.addorganization_id += u
  39496. } else {
  39497. m.addorganization_id = &u
  39498. }
  39499. }
  39500. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39501. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  39502. v := m.addorganization_id
  39503. if v == nil {
  39504. return
  39505. }
  39506. return *v, true
  39507. }
  39508. // ResetOrganizationID resets all changes to the "organization_id" field.
  39509. func (m *WorkExperienceMutation) ResetOrganizationID() {
  39510. m.organization_id = nil
  39511. m.addorganization_id = nil
  39512. }
  39513. // ClearEmployee clears the "employee" edge to the Employee entity.
  39514. func (m *WorkExperienceMutation) ClearEmployee() {
  39515. m.clearedemployee = true
  39516. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  39517. }
  39518. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  39519. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  39520. return m.clearedemployee
  39521. }
  39522. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  39523. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39524. // EmployeeID instead. It exists only for internal usage by the builders.
  39525. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  39526. if id := m.employee; id != nil {
  39527. ids = append(ids, *id)
  39528. }
  39529. return
  39530. }
  39531. // ResetEmployee resets all changes to the "employee" edge.
  39532. func (m *WorkExperienceMutation) ResetEmployee() {
  39533. m.employee = nil
  39534. m.clearedemployee = false
  39535. }
  39536. // Where appends a list predicates to the WorkExperienceMutation builder.
  39537. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  39538. m.predicates = append(m.predicates, ps...)
  39539. }
  39540. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  39541. // users can use type-assertion to append predicates that do not depend on any generated package.
  39542. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  39543. p := make([]predicate.WorkExperience, len(ps))
  39544. for i := range ps {
  39545. p[i] = ps[i]
  39546. }
  39547. m.Where(p...)
  39548. }
  39549. // Op returns the operation name.
  39550. func (m *WorkExperienceMutation) Op() Op {
  39551. return m.op
  39552. }
  39553. // SetOp allows setting the mutation operation.
  39554. func (m *WorkExperienceMutation) SetOp(op Op) {
  39555. m.op = op
  39556. }
  39557. // Type returns the node type of this mutation (WorkExperience).
  39558. func (m *WorkExperienceMutation) Type() string {
  39559. return m.typ
  39560. }
  39561. // Fields returns all fields that were changed during this mutation. Note that in
  39562. // order to get all numeric fields that were incremented/decremented, call
  39563. // AddedFields().
  39564. func (m *WorkExperienceMutation) Fields() []string {
  39565. fields := make([]string, 0, 9)
  39566. if m.created_at != nil {
  39567. fields = append(fields, workexperience.FieldCreatedAt)
  39568. }
  39569. if m.updated_at != nil {
  39570. fields = append(fields, workexperience.FieldUpdatedAt)
  39571. }
  39572. if m.deleted_at != nil {
  39573. fields = append(fields, workexperience.FieldDeletedAt)
  39574. }
  39575. if m.employee != nil {
  39576. fields = append(fields, workexperience.FieldEmployeeID)
  39577. }
  39578. if m.start_date != nil {
  39579. fields = append(fields, workexperience.FieldStartDate)
  39580. }
  39581. if m.end_date != nil {
  39582. fields = append(fields, workexperience.FieldEndDate)
  39583. }
  39584. if m.company != nil {
  39585. fields = append(fields, workexperience.FieldCompany)
  39586. }
  39587. if m.experience != nil {
  39588. fields = append(fields, workexperience.FieldExperience)
  39589. }
  39590. if m.organization_id != nil {
  39591. fields = append(fields, workexperience.FieldOrganizationID)
  39592. }
  39593. return fields
  39594. }
  39595. // Field returns the value of a field with the given name. The second boolean
  39596. // return value indicates that this field was not set, or was not defined in the
  39597. // schema.
  39598. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  39599. switch name {
  39600. case workexperience.FieldCreatedAt:
  39601. return m.CreatedAt()
  39602. case workexperience.FieldUpdatedAt:
  39603. return m.UpdatedAt()
  39604. case workexperience.FieldDeletedAt:
  39605. return m.DeletedAt()
  39606. case workexperience.FieldEmployeeID:
  39607. return m.EmployeeID()
  39608. case workexperience.FieldStartDate:
  39609. return m.StartDate()
  39610. case workexperience.FieldEndDate:
  39611. return m.EndDate()
  39612. case workexperience.FieldCompany:
  39613. return m.Company()
  39614. case workexperience.FieldExperience:
  39615. return m.Experience()
  39616. case workexperience.FieldOrganizationID:
  39617. return m.OrganizationID()
  39618. }
  39619. return nil, false
  39620. }
  39621. // OldField returns the old value of the field from the database. An error is
  39622. // returned if the mutation operation is not UpdateOne, or the query to the
  39623. // database failed.
  39624. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39625. switch name {
  39626. case workexperience.FieldCreatedAt:
  39627. return m.OldCreatedAt(ctx)
  39628. case workexperience.FieldUpdatedAt:
  39629. return m.OldUpdatedAt(ctx)
  39630. case workexperience.FieldDeletedAt:
  39631. return m.OldDeletedAt(ctx)
  39632. case workexperience.FieldEmployeeID:
  39633. return m.OldEmployeeID(ctx)
  39634. case workexperience.FieldStartDate:
  39635. return m.OldStartDate(ctx)
  39636. case workexperience.FieldEndDate:
  39637. return m.OldEndDate(ctx)
  39638. case workexperience.FieldCompany:
  39639. return m.OldCompany(ctx)
  39640. case workexperience.FieldExperience:
  39641. return m.OldExperience(ctx)
  39642. case workexperience.FieldOrganizationID:
  39643. return m.OldOrganizationID(ctx)
  39644. }
  39645. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  39646. }
  39647. // SetField sets the value of a field with the given name. It returns an error if
  39648. // the field is not defined in the schema, or if the type mismatched the field
  39649. // type.
  39650. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  39651. switch name {
  39652. case workexperience.FieldCreatedAt:
  39653. v, ok := value.(time.Time)
  39654. if !ok {
  39655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39656. }
  39657. m.SetCreatedAt(v)
  39658. return nil
  39659. case workexperience.FieldUpdatedAt:
  39660. v, ok := value.(time.Time)
  39661. if !ok {
  39662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39663. }
  39664. m.SetUpdatedAt(v)
  39665. return nil
  39666. case workexperience.FieldDeletedAt:
  39667. v, ok := value.(time.Time)
  39668. if !ok {
  39669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39670. }
  39671. m.SetDeletedAt(v)
  39672. return nil
  39673. case workexperience.FieldEmployeeID:
  39674. v, ok := value.(uint64)
  39675. if !ok {
  39676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39677. }
  39678. m.SetEmployeeID(v)
  39679. return nil
  39680. case workexperience.FieldStartDate:
  39681. v, ok := value.(time.Time)
  39682. if !ok {
  39683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39684. }
  39685. m.SetStartDate(v)
  39686. return nil
  39687. case workexperience.FieldEndDate:
  39688. v, ok := value.(time.Time)
  39689. if !ok {
  39690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39691. }
  39692. m.SetEndDate(v)
  39693. return nil
  39694. case workexperience.FieldCompany:
  39695. v, ok := value.(string)
  39696. if !ok {
  39697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39698. }
  39699. m.SetCompany(v)
  39700. return nil
  39701. case workexperience.FieldExperience:
  39702. v, ok := value.(string)
  39703. if !ok {
  39704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39705. }
  39706. m.SetExperience(v)
  39707. return nil
  39708. case workexperience.FieldOrganizationID:
  39709. v, ok := value.(uint64)
  39710. if !ok {
  39711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39712. }
  39713. m.SetOrganizationID(v)
  39714. return nil
  39715. }
  39716. return fmt.Errorf("unknown WorkExperience field %s", name)
  39717. }
  39718. // AddedFields returns all numeric fields that were incremented/decremented during
  39719. // this mutation.
  39720. func (m *WorkExperienceMutation) AddedFields() []string {
  39721. var fields []string
  39722. if m.addorganization_id != nil {
  39723. fields = append(fields, workexperience.FieldOrganizationID)
  39724. }
  39725. return fields
  39726. }
  39727. // AddedField returns the numeric value that was incremented/decremented on a field
  39728. // with the given name. The second boolean return value indicates that this field
  39729. // was not set, or was not defined in the schema.
  39730. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  39731. switch name {
  39732. case workexperience.FieldOrganizationID:
  39733. return m.AddedOrganizationID()
  39734. }
  39735. return nil, false
  39736. }
  39737. // AddField adds the value to the field with the given name. It returns an error if
  39738. // the field is not defined in the schema, or if the type mismatched the field
  39739. // type.
  39740. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  39741. switch name {
  39742. case workexperience.FieldOrganizationID:
  39743. v, ok := value.(int64)
  39744. if !ok {
  39745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39746. }
  39747. m.AddOrganizationID(v)
  39748. return nil
  39749. }
  39750. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  39751. }
  39752. // ClearedFields returns all nullable fields that were cleared during this
  39753. // mutation.
  39754. func (m *WorkExperienceMutation) ClearedFields() []string {
  39755. var fields []string
  39756. if m.FieldCleared(workexperience.FieldDeletedAt) {
  39757. fields = append(fields, workexperience.FieldDeletedAt)
  39758. }
  39759. return fields
  39760. }
  39761. // FieldCleared returns a boolean indicating if a field with the given name was
  39762. // cleared in this mutation.
  39763. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  39764. _, ok := m.clearedFields[name]
  39765. return ok
  39766. }
  39767. // ClearField clears the value of the field with the given name. It returns an
  39768. // error if the field is not defined in the schema.
  39769. func (m *WorkExperienceMutation) ClearField(name string) error {
  39770. switch name {
  39771. case workexperience.FieldDeletedAt:
  39772. m.ClearDeletedAt()
  39773. return nil
  39774. }
  39775. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  39776. }
  39777. // ResetField resets all changes in the mutation for the field with the given name.
  39778. // It returns an error if the field is not defined in the schema.
  39779. func (m *WorkExperienceMutation) ResetField(name string) error {
  39780. switch name {
  39781. case workexperience.FieldCreatedAt:
  39782. m.ResetCreatedAt()
  39783. return nil
  39784. case workexperience.FieldUpdatedAt:
  39785. m.ResetUpdatedAt()
  39786. return nil
  39787. case workexperience.FieldDeletedAt:
  39788. m.ResetDeletedAt()
  39789. return nil
  39790. case workexperience.FieldEmployeeID:
  39791. m.ResetEmployeeID()
  39792. return nil
  39793. case workexperience.FieldStartDate:
  39794. m.ResetStartDate()
  39795. return nil
  39796. case workexperience.FieldEndDate:
  39797. m.ResetEndDate()
  39798. return nil
  39799. case workexperience.FieldCompany:
  39800. m.ResetCompany()
  39801. return nil
  39802. case workexperience.FieldExperience:
  39803. m.ResetExperience()
  39804. return nil
  39805. case workexperience.FieldOrganizationID:
  39806. m.ResetOrganizationID()
  39807. return nil
  39808. }
  39809. return fmt.Errorf("unknown WorkExperience field %s", name)
  39810. }
  39811. // AddedEdges returns all edge names that were set/added in this mutation.
  39812. func (m *WorkExperienceMutation) AddedEdges() []string {
  39813. edges := make([]string, 0, 1)
  39814. if m.employee != nil {
  39815. edges = append(edges, workexperience.EdgeEmployee)
  39816. }
  39817. return edges
  39818. }
  39819. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39820. // name in this mutation.
  39821. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  39822. switch name {
  39823. case workexperience.EdgeEmployee:
  39824. if id := m.employee; id != nil {
  39825. return []ent.Value{*id}
  39826. }
  39827. }
  39828. return nil
  39829. }
  39830. // RemovedEdges returns all edge names that were removed in this mutation.
  39831. func (m *WorkExperienceMutation) RemovedEdges() []string {
  39832. edges := make([]string, 0, 1)
  39833. return edges
  39834. }
  39835. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39836. // the given name in this mutation.
  39837. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  39838. return nil
  39839. }
  39840. // ClearedEdges returns all edge names that were cleared in this mutation.
  39841. func (m *WorkExperienceMutation) ClearedEdges() []string {
  39842. edges := make([]string, 0, 1)
  39843. if m.clearedemployee {
  39844. edges = append(edges, workexperience.EdgeEmployee)
  39845. }
  39846. return edges
  39847. }
  39848. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39849. // was cleared in this mutation.
  39850. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  39851. switch name {
  39852. case workexperience.EdgeEmployee:
  39853. return m.clearedemployee
  39854. }
  39855. return false
  39856. }
  39857. // ClearEdge clears the value of the edge with the given name. It returns an error
  39858. // if that edge is not defined in the schema.
  39859. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  39860. switch name {
  39861. case workexperience.EdgeEmployee:
  39862. m.ClearEmployee()
  39863. return nil
  39864. }
  39865. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  39866. }
  39867. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39868. // It returns an error if the edge is not defined in the schema.
  39869. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  39870. switch name {
  39871. case workexperience.EdgeEmployee:
  39872. m.ResetEmployee()
  39873. return nil
  39874. }
  39875. return fmt.Errorf("unknown WorkExperience edge %s", name)
  39876. }
  39877. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  39878. type WpChatroomMutation struct {
  39879. config
  39880. op Op
  39881. typ string
  39882. id *uint64
  39883. created_at *time.Time
  39884. updated_at *time.Time
  39885. status *uint8
  39886. addstatus *int8
  39887. wx_wxid *string
  39888. chatroom_id *string
  39889. nickname *string
  39890. owner *string
  39891. avatar *string
  39892. member_list *[]string
  39893. appendmember_list []string
  39894. clearedFields map[string]struct{}
  39895. done bool
  39896. oldValue func(context.Context) (*WpChatroom, error)
  39897. predicates []predicate.WpChatroom
  39898. }
  39899. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  39900. // wpchatroomOption allows management of the mutation configuration using functional options.
  39901. type wpchatroomOption func(*WpChatroomMutation)
  39902. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  39903. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  39904. m := &WpChatroomMutation{
  39905. config: c,
  39906. op: op,
  39907. typ: TypeWpChatroom,
  39908. clearedFields: make(map[string]struct{}),
  39909. }
  39910. for _, opt := range opts {
  39911. opt(m)
  39912. }
  39913. return m
  39914. }
  39915. // withWpChatroomID sets the ID field of the mutation.
  39916. func withWpChatroomID(id uint64) wpchatroomOption {
  39917. return func(m *WpChatroomMutation) {
  39918. var (
  39919. err error
  39920. once sync.Once
  39921. value *WpChatroom
  39922. )
  39923. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  39924. once.Do(func() {
  39925. if m.done {
  39926. err = errors.New("querying old values post mutation is not allowed")
  39927. } else {
  39928. value, err = m.Client().WpChatroom.Get(ctx, id)
  39929. }
  39930. })
  39931. return value, err
  39932. }
  39933. m.id = &id
  39934. }
  39935. }
  39936. // withWpChatroom sets the old WpChatroom of the mutation.
  39937. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  39938. return func(m *WpChatroomMutation) {
  39939. m.oldValue = func(context.Context) (*WpChatroom, error) {
  39940. return node, nil
  39941. }
  39942. m.id = &node.ID
  39943. }
  39944. }
  39945. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39946. // executed in a transaction (ent.Tx), a transactional client is returned.
  39947. func (m WpChatroomMutation) Client() *Client {
  39948. client := &Client{config: m.config}
  39949. client.init()
  39950. return client
  39951. }
  39952. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39953. // it returns an error otherwise.
  39954. func (m WpChatroomMutation) Tx() (*Tx, error) {
  39955. if _, ok := m.driver.(*txDriver); !ok {
  39956. return nil, errors.New("ent: mutation is not running in a transaction")
  39957. }
  39958. tx := &Tx{config: m.config}
  39959. tx.init()
  39960. return tx, nil
  39961. }
  39962. // SetID sets the value of the id field. Note that this
  39963. // operation is only accepted on creation of WpChatroom entities.
  39964. func (m *WpChatroomMutation) SetID(id uint64) {
  39965. m.id = &id
  39966. }
  39967. // ID returns the ID value in the mutation. Note that the ID is only available
  39968. // if it was provided to the builder or after it was returned from the database.
  39969. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  39970. if m.id == nil {
  39971. return
  39972. }
  39973. return *m.id, true
  39974. }
  39975. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39976. // That means, if the mutation is applied within a transaction with an isolation level such
  39977. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39978. // or updated by the mutation.
  39979. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  39980. switch {
  39981. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39982. id, exists := m.ID()
  39983. if exists {
  39984. return []uint64{id}, nil
  39985. }
  39986. fallthrough
  39987. case m.op.Is(OpUpdate | OpDelete):
  39988. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  39989. default:
  39990. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39991. }
  39992. }
  39993. // SetCreatedAt sets the "created_at" field.
  39994. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  39995. m.created_at = &t
  39996. }
  39997. // CreatedAt returns the value of the "created_at" field in the mutation.
  39998. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  39999. v := m.created_at
  40000. if v == nil {
  40001. return
  40002. }
  40003. return *v, true
  40004. }
  40005. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  40006. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40008. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40009. if !m.op.Is(OpUpdateOne) {
  40010. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40011. }
  40012. if m.id == nil || m.oldValue == nil {
  40013. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40014. }
  40015. oldValue, err := m.oldValue(ctx)
  40016. if err != nil {
  40017. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40018. }
  40019. return oldValue.CreatedAt, nil
  40020. }
  40021. // ResetCreatedAt resets all changes to the "created_at" field.
  40022. func (m *WpChatroomMutation) ResetCreatedAt() {
  40023. m.created_at = nil
  40024. }
  40025. // SetUpdatedAt sets the "updated_at" field.
  40026. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  40027. m.updated_at = &t
  40028. }
  40029. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40030. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  40031. v := m.updated_at
  40032. if v == nil {
  40033. return
  40034. }
  40035. return *v, true
  40036. }
  40037. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  40038. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40040. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40041. if !m.op.Is(OpUpdateOne) {
  40042. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40043. }
  40044. if m.id == nil || m.oldValue == nil {
  40045. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40046. }
  40047. oldValue, err := m.oldValue(ctx)
  40048. if err != nil {
  40049. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40050. }
  40051. return oldValue.UpdatedAt, nil
  40052. }
  40053. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40054. func (m *WpChatroomMutation) ResetUpdatedAt() {
  40055. m.updated_at = nil
  40056. }
  40057. // SetStatus sets the "status" field.
  40058. func (m *WpChatroomMutation) SetStatus(u uint8) {
  40059. m.status = &u
  40060. m.addstatus = nil
  40061. }
  40062. // Status returns the value of the "status" field in the mutation.
  40063. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  40064. v := m.status
  40065. if v == nil {
  40066. return
  40067. }
  40068. return *v, true
  40069. }
  40070. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  40071. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40073. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40074. if !m.op.Is(OpUpdateOne) {
  40075. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40076. }
  40077. if m.id == nil || m.oldValue == nil {
  40078. return v, errors.New("OldStatus requires an ID field in the mutation")
  40079. }
  40080. oldValue, err := m.oldValue(ctx)
  40081. if err != nil {
  40082. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40083. }
  40084. return oldValue.Status, nil
  40085. }
  40086. // AddStatus adds u to the "status" field.
  40087. func (m *WpChatroomMutation) AddStatus(u int8) {
  40088. if m.addstatus != nil {
  40089. *m.addstatus += u
  40090. } else {
  40091. m.addstatus = &u
  40092. }
  40093. }
  40094. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40095. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  40096. v := m.addstatus
  40097. if v == nil {
  40098. return
  40099. }
  40100. return *v, true
  40101. }
  40102. // ClearStatus clears the value of the "status" field.
  40103. func (m *WpChatroomMutation) ClearStatus() {
  40104. m.status = nil
  40105. m.addstatus = nil
  40106. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  40107. }
  40108. // StatusCleared returns if the "status" field was cleared in this mutation.
  40109. func (m *WpChatroomMutation) StatusCleared() bool {
  40110. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  40111. return ok
  40112. }
  40113. // ResetStatus resets all changes to the "status" field.
  40114. func (m *WpChatroomMutation) ResetStatus() {
  40115. m.status = nil
  40116. m.addstatus = nil
  40117. delete(m.clearedFields, wpchatroom.FieldStatus)
  40118. }
  40119. // SetWxWxid sets the "wx_wxid" field.
  40120. func (m *WpChatroomMutation) SetWxWxid(s string) {
  40121. m.wx_wxid = &s
  40122. }
  40123. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  40124. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  40125. v := m.wx_wxid
  40126. if v == nil {
  40127. return
  40128. }
  40129. return *v, true
  40130. }
  40131. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  40132. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40134. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  40135. if !m.op.Is(OpUpdateOne) {
  40136. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  40137. }
  40138. if m.id == nil || m.oldValue == nil {
  40139. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  40140. }
  40141. oldValue, err := m.oldValue(ctx)
  40142. if err != nil {
  40143. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  40144. }
  40145. return oldValue.WxWxid, nil
  40146. }
  40147. // ResetWxWxid resets all changes to the "wx_wxid" field.
  40148. func (m *WpChatroomMutation) ResetWxWxid() {
  40149. m.wx_wxid = nil
  40150. }
  40151. // SetChatroomID sets the "chatroom_id" field.
  40152. func (m *WpChatroomMutation) SetChatroomID(s string) {
  40153. m.chatroom_id = &s
  40154. }
  40155. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  40156. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  40157. v := m.chatroom_id
  40158. if v == nil {
  40159. return
  40160. }
  40161. return *v, true
  40162. }
  40163. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  40164. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40166. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  40167. if !m.op.Is(OpUpdateOne) {
  40168. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  40169. }
  40170. if m.id == nil || m.oldValue == nil {
  40171. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  40172. }
  40173. oldValue, err := m.oldValue(ctx)
  40174. if err != nil {
  40175. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  40176. }
  40177. return oldValue.ChatroomID, nil
  40178. }
  40179. // ResetChatroomID resets all changes to the "chatroom_id" field.
  40180. func (m *WpChatroomMutation) ResetChatroomID() {
  40181. m.chatroom_id = nil
  40182. }
  40183. // SetNickname sets the "nickname" field.
  40184. func (m *WpChatroomMutation) SetNickname(s string) {
  40185. m.nickname = &s
  40186. }
  40187. // Nickname returns the value of the "nickname" field in the mutation.
  40188. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  40189. v := m.nickname
  40190. if v == nil {
  40191. return
  40192. }
  40193. return *v, true
  40194. }
  40195. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  40196. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40198. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  40199. if !m.op.Is(OpUpdateOne) {
  40200. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40201. }
  40202. if m.id == nil || m.oldValue == nil {
  40203. return v, errors.New("OldNickname requires an ID field in the mutation")
  40204. }
  40205. oldValue, err := m.oldValue(ctx)
  40206. if err != nil {
  40207. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40208. }
  40209. return oldValue.Nickname, nil
  40210. }
  40211. // ResetNickname resets all changes to the "nickname" field.
  40212. func (m *WpChatroomMutation) ResetNickname() {
  40213. m.nickname = nil
  40214. }
  40215. // SetOwner sets the "owner" field.
  40216. func (m *WpChatroomMutation) SetOwner(s string) {
  40217. m.owner = &s
  40218. }
  40219. // Owner returns the value of the "owner" field in the mutation.
  40220. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  40221. v := m.owner
  40222. if v == nil {
  40223. return
  40224. }
  40225. return *v, true
  40226. }
  40227. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  40228. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40230. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  40231. if !m.op.Is(OpUpdateOne) {
  40232. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  40233. }
  40234. if m.id == nil || m.oldValue == nil {
  40235. return v, errors.New("OldOwner requires an ID field in the mutation")
  40236. }
  40237. oldValue, err := m.oldValue(ctx)
  40238. if err != nil {
  40239. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  40240. }
  40241. return oldValue.Owner, nil
  40242. }
  40243. // ResetOwner resets all changes to the "owner" field.
  40244. func (m *WpChatroomMutation) ResetOwner() {
  40245. m.owner = nil
  40246. }
  40247. // SetAvatar sets the "avatar" field.
  40248. func (m *WpChatroomMutation) SetAvatar(s string) {
  40249. m.avatar = &s
  40250. }
  40251. // Avatar returns the value of the "avatar" field in the mutation.
  40252. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  40253. v := m.avatar
  40254. if v == nil {
  40255. return
  40256. }
  40257. return *v, true
  40258. }
  40259. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  40260. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40262. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40263. if !m.op.Is(OpUpdateOne) {
  40264. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40265. }
  40266. if m.id == nil || m.oldValue == nil {
  40267. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40268. }
  40269. oldValue, err := m.oldValue(ctx)
  40270. if err != nil {
  40271. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40272. }
  40273. return oldValue.Avatar, nil
  40274. }
  40275. // ResetAvatar resets all changes to the "avatar" field.
  40276. func (m *WpChatroomMutation) ResetAvatar() {
  40277. m.avatar = nil
  40278. }
  40279. // SetMemberList sets the "member_list" field.
  40280. func (m *WpChatroomMutation) SetMemberList(s []string) {
  40281. m.member_list = &s
  40282. m.appendmember_list = nil
  40283. }
  40284. // MemberList returns the value of the "member_list" field in the mutation.
  40285. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  40286. v := m.member_list
  40287. if v == nil {
  40288. return
  40289. }
  40290. return *v, true
  40291. }
  40292. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  40293. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40295. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  40296. if !m.op.Is(OpUpdateOne) {
  40297. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  40298. }
  40299. if m.id == nil || m.oldValue == nil {
  40300. return v, errors.New("OldMemberList requires an ID field in the mutation")
  40301. }
  40302. oldValue, err := m.oldValue(ctx)
  40303. if err != nil {
  40304. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  40305. }
  40306. return oldValue.MemberList, nil
  40307. }
  40308. // AppendMemberList adds s to the "member_list" field.
  40309. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  40310. m.appendmember_list = append(m.appendmember_list, s...)
  40311. }
  40312. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  40313. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  40314. if len(m.appendmember_list) == 0 {
  40315. return nil, false
  40316. }
  40317. return m.appendmember_list, true
  40318. }
  40319. // ResetMemberList resets all changes to the "member_list" field.
  40320. func (m *WpChatroomMutation) ResetMemberList() {
  40321. m.member_list = nil
  40322. m.appendmember_list = nil
  40323. }
  40324. // Where appends a list predicates to the WpChatroomMutation builder.
  40325. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  40326. m.predicates = append(m.predicates, ps...)
  40327. }
  40328. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  40329. // users can use type-assertion to append predicates that do not depend on any generated package.
  40330. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  40331. p := make([]predicate.WpChatroom, len(ps))
  40332. for i := range ps {
  40333. p[i] = ps[i]
  40334. }
  40335. m.Where(p...)
  40336. }
  40337. // Op returns the operation name.
  40338. func (m *WpChatroomMutation) Op() Op {
  40339. return m.op
  40340. }
  40341. // SetOp allows setting the mutation operation.
  40342. func (m *WpChatroomMutation) SetOp(op Op) {
  40343. m.op = op
  40344. }
  40345. // Type returns the node type of this mutation (WpChatroom).
  40346. func (m *WpChatroomMutation) Type() string {
  40347. return m.typ
  40348. }
  40349. // Fields returns all fields that were changed during this mutation. Note that in
  40350. // order to get all numeric fields that were incremented/decremented, call
  40351. // AddedFields().
  40352. func (m *WpChatroomMutation) Fields() []string {
  40353. fields := make([]string, 0, 9)
  40354. if m.created_at != nil {
  40355. fields = append(fields, wpchatroom.FieldCreatedAt)
  40356. }
  40357. if m.updated_at != nil {
  40358. fields = append(fields, wpchatroom.FieldUpdatedAt)
  40359. }
  40360. if m.status != nil {
  40361. fields = append(fields, wpchatroom.FieldStatus)
  40362. }
  40363. if m.wx_wxid != nil {
  40364. fields = append(fields, wpchatroom.FieldWxWxid)
  40365. }
  40366. if m.chatroom_id != nil {
  40367. fields = append(fields, wpchatroom.FieldChatroomID)
  40368. }
  40369. if m.nickname != nil {
  40370. fields = append(fields, wpchatroom.FieldNickname)
  40371. }
  40372. if m.owner != nil {
  40373. fields = append(fields, wpchatroom.FieldOwner)
  40374. }
  40375. if m.avatar != nil {
  40376. fields = append(fields, wpchatroom.FieldAvatar)
  40377. }
  40378. if m.member_list != nil {
  40379. fields = append(fields, wpchatroom.FieldMemberList)
  40380. }
  40381. return fields
  40382. }
  40383. // Field returns the value of a field with the given name. The second boolean
  40384. // return value indicates that this field was not set, or was not defined in the
  40385. // schema.
  40386. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  40387. switch name {
  40388. case wpchatroom.FieldCreatedAt:
  40389. return m.CreatedAt()
  40390. case wpchatroom.FieldUpdatedAt:
  40391. return m.UpdatedAt()
  40392. case wpchatroom.FieldStatus:
  40393. return m.Status()
  40394. case wpchatroom.FieldWxWxid:
  40395. return m.WxWxid()
  40396. case wpchatroom.FieldChatroomID:
  40397. return m.ChatroomID()
  40398. case wpchatroom.FieldNickname:
  40399. return m.Nickname()
  40400. case wpchatroom.FieldOwner:
  40401. return m.Owner()
  40402. case wpchatroom.FieldAvatar:
  40403. return m.Avatar()
  40404. case wpchatroom.FieldMemberList:
  40405. return m.MemberList()
  40406. }
  40407. return nil, false
  40408. }
  40409. // OldField returns the old value of the field from the database. An error is
  40410. // returned if the mutation operation is not UpdateOne, or the query to the
  40411. // database failed.
  40412. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40413. switch name {
  40414. case wpchatroom.FieldCreatedAt:
  40415. return m.OldCreatedAt(ctx)
  40416. case wpchatroom.FieldUpdatedAt:
  40417. return m.OldUpdatedAt(ctx)
  40418. case wpchatroom.FieldStatus:
  40419. return m.OldStatus(ctx)
  40420. case wpchatroom.FieldWxWxid:
  40421. return m.OldWxWxid(ctx)
  40422. case wpchatroom.FieldChatroomID:
  40423. return m.OldChatroomID(ctx)
  40424. case wpchatroom.FieldNickname:
  40425. return m.OldNickname(ctx)
  40426. case wpchatroom.FieldOwner:
  40427. return m.OldOwner(ctx)
  40428. case wpchatroom.FieldAvatar:
  40429. return m.OldAvatar(ctx)
  40430. case wpchatroom.FieldMemberList:
  40431. return m.OldMemberList(ctx)
  40432. }
  40433. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  40434. }
  40435. // SetField sets the value of a field with the given name. It returns an error if
  40436. // the field is not defined in the schema, or if the type mismatched the field
  40437. // type.
  40438. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  40439. switch name {
  40440. case wpchatroom.FieldCreatedAt:
  40441. v, ok := value.(time.Time)
  40442. if !ok {
  40443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40444. }
  40445. m.SetCreatedAt(v)
  40446. return nil
  40447. case wpchatroom.FieldUpdatedAt:
  40448. v, ok := value.(time.Time)
  40449. if !ok {
  40450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40451. }
  40452. m.SetUpdatedAt(v)
  40453. return nil
  40454. case wpchatroom.FieldStatus:
  40455. v, ok := value.(uint8)
  40456. if !ok {
  40457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40458. }
  40459. m.SetStatus(v)
  40460. return nil
  40461. case wpchatroom.FieldWxWxid:
  40462. v, ok := value.(string)
  40463. if !ok {
  40464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40465. }
  40466. m.SetWxWxid(v)
  40467. return nil
  40468. case wpchatroom.FieldChatroomID:
  40469. v, ok := value.(string)
  40470. if !ok {
  40471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40472. }
  40473. m.SetChatroomID(v)
  40474. return nil
  40475. case wpchatroom.FieldNickname:
  40476. v, ok := value.(string)
  40477. if !ok {
  40478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40479. }
  40480. m.SetNickname(v)
  40481. return nil
  40482. case wpchatroom.FieldOwner:
  40483. v, ok := value.(string)
  40484. if !ok {
  40485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40486. }
  40487. m.SetOwner(v)
  40488. return nil
  40489. case wpchatroom.FieldAvatar:
  40490. v, ok := value.(string)
  40491. if !ok {
  40492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40493. }
  40494. m.SetAvatar(v)
  40495. return nil
  40496. case wpchatroom.FieldMemberList:
  40497. v, ok := value.([]string)
  40498. if !ok {
  40499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40500. }
  40501. m.SetMemberList(v)
  40502. return nil
  40503. }
  40504. return fmt.Errorf("unknown WpChatroom field %s", name)
  40505. }
  40506. // AddedFields returns all numeric fields that were incremented/decremented during
  40507. // this mutation.
  40508. func (m *WpChatroomMutation) AddedFields() []string {
  40509. var fields []string
  40510. if m.addstatus != nil {
  40511. fields = append(fields, wpchatroom.FieldStatus)
  40512. }
  40513. return fields
  40514. }
  40515. // AddedField returns the numeric value that was incremented/decremented on a field
  40516. // with the given name. The second boolean return value indicates that this field
  40517. // was not set, or was not defined in the schema.
  40518. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  40519. switch name {
  40520. case wpchatroom.FieldStatus:
  40521. return m.AddedStatus()
  40522. }
  40523. return nil, false
  40524. }
  40525. // AddField adds the value to the field with the given name. It returns an error if
  40526. // the field is not defined in the schema, or if the type mismatched the field
  40527. // type.
  40528. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  40529. switch name {
  40530. case wpchatroom.FieldStatus:
  40531. v, ok := value.(int8)
  40532. if !ok {
  40533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40534. }
  40535. m.AddStatus(v)
  40536. return nil
  40537. }
  40538. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  40539. }
  40540. // ClearedFields returns all nullable fields that were cleared during this
  40541. // mutation.
  40542. func (m *WpChatroomMutation) ClearedFields() []string {
  40543. var fields []string
  40544. if m.FieldCleared(wpchatroom.FieldStatus) {
  40545. fields = append(fields, wpchatroom.FieldStatus)
  40546. }
  40547. return fields
  40548. }
  40549. // FieldCleared returns a boolean indicating if a field with the given name was
  40550. // cleared in this mutation.
  40551. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  40552. _, ok := m.clearedFields[name]
  40553. return ok
  40554. }
  40555. // ClearField clears the value of the field with the given name. It returns an
  40556. // error if the field is not defined in the schema.
  40557. func (m *WpChatroomMutation) ClearField(name string) error {
  40558. switch name {
  40559. case wpchatroom.FieldStatus:
  40560. m.ClearStatus()
  40561. return nil
  40562. }
  40563. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  40564. }
  40565. // ResetField resets all changes in the mutation for the field with the given name.
  40566. // It returns an error if the field is not defined in the schema.
  40567. func (m *WpChatroomMutation) ResetField(name string) error {
  40568. switch name {
  40569. case wpchatroom.FieldCreatedAt:
  40570. m.ResetCreatedAt()
  40571. return nil
  40572. case wpchatroom.FieldUpdatedAt:
  40573. m.ResetUpdatedAt()
  40574. return nil
  40575. case wpchatroom.FieldStatus:
  40576. m.ResetStatus()
  40577. return nil
  40578. case wpchatroom.FieldWxWxid:
  40579. m.ResetWxWxid()
  40580. return nil
  40581. case wpchatroom.FieldChatroomID:
  40582. m.ResetChatroomID()
  40583. return nil
  40584. case wpchatroom.FieldNickname:
  40585. m.ResetNickname()
  40586. return nil
  40587. case wpchatroom.FieldOwner:
  40588. m.ResetOwner()
  40589. return nil
  40590. case wpchatroom.FieldAvatar:
  40591. m.ResetAvatar()
  40592. return nil
  40593. case wpchatroom.FieldMemberList:
  40594. m.ResetMemberList()
  40595. return nil
  40596. }
  40597. return fmt.Errorf("unknown WpChatroom field %s", name)
  40598. }
  40599. // AddedEdges returns all edge names that were set/added in this mutation.
  40600. func (m *WpChatroomMutation) AddedEdges() []string {
  40601. edges := make([]string, 0, 0)
  40602. return edges
  40603. }
  40604. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40605. // name in this mutation.
  40606. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  40607. return nil
  40608. }
  40609. // RemovedEdges returns all edge names that were removed in this mutation.
  40610. func (m *WpChatroomMutation) RemovedEdges() []string {
  40611. edges := make([]string, 0, 0)
  40612. return edges
  40613. }
  40614. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40615. // the given name in this mutation.
  40616. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  40617. return nil
  40618. }
  40619. // ClearedEdges returns all edge names that were cleared in this mutation.
  40620. func (m *WpChatroomMutation) ClearedEdges() []string {
  40621. edges := make([]string, 0, 0)
  40622. return edges
  40623. }
  40624. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40625. // was cleared in this mutation.
  40626. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  40627. return false
  40628. }
  40629. // ClearEdge clears the value of the edge with the given name. It returns an error
  40630. // if that edge is not defined in the schema.
  40631. func (m *WpChatroomMutation) ClearEdge(name string) error {
  40632. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  40633. }
  40634. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40635. // It returns an error if the edge is not defined in the schema.
  40636. func (m *WpChatroomMutation) ResetEdge(name string) error {
  40637. return fmt.Errorf("unknown WpChatroom edge %s", name)
  40638. }
  40639. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  40640. type WpChatroomMemberMutation struct {
  40641. config
  40642. op Op
  40643. typ string
  40644. id *uint64
  40645. created_at *time.Time
  40646. updated_at *time.Time
  40647. status *uint8
  40648. addstatus *int8
  40649. wx_wxid *string
  40650. wxid *string
  40651. nickname *string
  40652. avatar *string
  40653. clearedFields map[string]struct{}
  40654. done bool
  40655. oldValue func(context.Context) (*WpChatroomMember, error)
  40656. predicates []predicate.WpChatroomMember
  40657. }
  40658. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  40659. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  40660. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  40661. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  40662. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  40663. m := &WpChatroomMemberMutation{
  40664. config: c,
  40665. op: op,
  40666. typ: TypeWpChatroomMember,
  40667. clearedFields: make(map[string]struct{}),
  40668. }
  40669. for _, opt := range opts {
  40670. opt(m)
  40671. }
  40672. return m
  40673. }
  40674. // withWpChatroomMemberID sets the ID field of the mutation.
  40675. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  40676. return func(m *WpChatroomMemberMutation) {
  40677. var (
  40678. err error
  40679. once sync.Once
  40680. value *WpChatroomMember
  40681. )
  40682. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  40683. once.Do(func() {
  40684. if m.done {
  40685. err = errors.New("querying old values post mutation is not allowed")
  40686. } else {
  40687. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  40688. }
  40689. })
  40690. return value, err
  40691. }
  40692. m.id = &id
  40693. }
  40694. }
  40695. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  40696. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  40697. return func(m *WpChatroomMemberMutation) {
  40698. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  40699. return node, nil
  40700. }
  40701. m.id = &node.ID
  40702. }
  40703. }
  40704. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40705. // executed in a transaction (ent.Tx), a transactional client is returned.
  40706. func (m WpChatroomMemberMutation) Client() *Client {
  40707. client := &Client{config: m.config}
  40708. client.init()
  40709. return client
  40710. }
  40711. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40712. // it returns an error otherwise.
  40713. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  40714. if _, ok := m.driver.(*txDriver); !ok {
  40715. return nil, errors.New("ent: mutation is not running in a transaction")
  40716. }
  40717. tx := &Tx{config: m.config}
  40718. tx.init()
  40719. return tx, nil
  40720. }
  40721. // SetID sets the value of the id field. Note that this
  40722. // operation is only accepted on creation of WpChatroomMember entities.
  40723. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  40724. m.id = &id
  40725. }
  40726. // ID returns the ID value in the mutation. Note that the ID is only available
  40727. // if it was provided to the builder or after it was returned from the database.
  40728. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  40729. if m.id == nil {
  40730. return
  40731. }
  40732. return *m.id, true
  40733. }
  40734. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40735. // That means, if the mutation is applied within a transaction with an isolation level such
  40736. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40737. // or updated by the mutation.
  40738. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  40739. switch {
  40740. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40741. id, exists := m.ID()
  40742. if exists {
  40743. return []uint64{id}, nil
  40744. }
  40745. fallthrough
  40746. case m.op.Is(OpUpdate | OpDelete):
  40747. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  40748. default:
  40749. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40750. }
  40751. }
  40752. // SetCreatedAt sets the "created_at" field.
  40753. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  40754. m.created_at = &t
  40755. }
  40756. // CreatedAt returns the value of the "created_at" field in the mutation.
  40757. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  40758. v := m.created_at
  40759. if v == nil {
  40760. return
  40761. }
  40762. return *v, true
  40763. }
  40764. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  40765. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40767. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40768. if !m.op.Is(OpUpdateOne) {
  40769. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40770. }
  40771. if m.id == nil || m.oldValue == nil {
  40772. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40773. }
  40774. oldValue, err := m.oldValue(ctx)
  40775. if err != nil {
  40776. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40777. }
  40778. return oldValue.CreatedAt, nil
  40779. }
  40780. // ResetCreatedAt resets all changes to the "created_at" field.
  40781. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  40782. m.created_at = nil
  40783. }
  40784. // SetUpdatedAt sets the "updated_at" field.
  40785. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  40786. m.updated_at = &t
  40787. }
  40788. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40789. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  40790. v := m.updated_at
  40791. if v == nil {
  40792. return
  40793. }
  40794. return *v, true
  40795. }
  40796. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  40797. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40799. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40800. if !m.op.Is(OpUpdateOne) {
  40801. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40802. }
  40803. if m.id == nil || m.oldValue == nil {
  40804. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40805. }
  40806. oldValue, err := m.oldValue(ctx)
  40807. if err != nil {
  40808. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40809. }
  40810. return oldValue.UpdatedAt, nil
  40811. }
  40812. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40813. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  40814. m.updated_at = nil
  40815. }
  40816. // SetStatus sets the "status" field.
  40817. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  40818. m.status = &u
  40819. m.addstatus = nil
  40820. }
  40821. // Status returns the value of the "status" field in the mutation.
  40822. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  40823. v := m.status
  40824. if v == nil {
  40825. return
  40826. }
  40827. return *v, true
  40828. }
  40829. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  40830. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40832. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40833. if !m.op.Is(OpUpdateOne) {
  40834. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40835. }
  40836. if m.id == nil || m.oldValue == nil {
  40837. return v, errors.New("OldStatus requires an ID field in the mutation")
  40838. }
  40839. oldValue, err := m.oldValue(ctx)
  40840. if err != nil {
  40841. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40842. }
  40843. return oldValue.Status, nil
  40844. }
  40845. // AddStatus adds u to the "status" field.
  40846. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  40847. if m.addstatus != nil {
  40848. *m.addstatus += u
  40849. } else {
  40850. m.addstatus = &u
  40851. }
  40852. }
  40853. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40854. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  40855. v := m.addstatus
  40856. if v == nil {
  40857. return
  40858. }
  40859. return *v, true
  40860. }
  40861. // ClearStatus clears the value of the "status" field.
  40862. func (m *WpChatroomMemberMutation) ClearStatus() {
  40863. m.status = nil
  40864. m.addstatus = nil
  40865. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  40866. }
  40867. // StatusCleared returns if the "status" field was cleared in this mutation.
  40868. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  40869. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  40870. return ok
  40871. }
  40872. // ResetStatus resets all changes to the "status" field.
  40873. func (m *WpChatroomMemberMutation) ResetStatus() {
  40874. m.status = nil
  40875. m.addstatus = nil
  40876. delete(m.clearedFields, wpchatroommember.FieldStatus)
  40877. }
  40878. // SetWxWxid sets the "wx_wxid" field.
  40879. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  40880. m.wx_wxid = &s
  40881. }
  40882. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  40883. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  40884. v := m.wx_wxid
  40885. if v == nil {
  40886. return
  40887. }
  40888. return *v, true
  40889. }
  40890. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  40891. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40893. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  40894. if !m.op.Is(OpUpdateOne) {
  40895. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  40896. }
  40897. if m.id == nil || m.oldValue == nil {
  40898. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  40899. }
  40900. oldValue, err := m.oldValue(ctx)
  40901. if err != nil {
  40902. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  40903. }
  40904. return oldValue.WxWxid, nil
  40905. }
  40906. // ResetWxWxid resets all changes to the "wx_wxid" field.
  40907. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  40908. m.wx_wxid = nil
  40909. }
  40910. // SetWxid sets the "wxid" field.
  40911. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  40912. m.wxid = &s
  40913. }
  40914. // Wxid returns the value of the "wxid" field in the mutation.
  40915. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  40916. v := m.wxid
  40917. if v == nil {
  40918. return
  40919. }
  40920. return *v, true
  40921. }
  40922. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  40923. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40925. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  40926. if !m.op.Is(OpUpdateOne) {
  40927. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40928. }
  40929. if m.id == nil || m.oldValue == nil {
  40930. return v, errors.New("OldWxid requires an ID field in the mutation")
  40931. }
  40932. oldValue, err := m.oldValue(ctx)
  40933. if err != nil {
  40934. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40935. }
  40936. return oldValue.Wxid, nil
  40937. }
  40938. // ResetWxid resets all changes to the "wxid" field.
  40939. func (m *WpChatroomMemberMutation) ResetWxid() {
  40940. m.wxid = nil
  40941. }
  40942. // SetNickname sets the "nickname" field.
  40943. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  40944. m.nickname = &s
  40945. }
  40946. // Nickname returns the value of the "nickname" field in the mutation.
  40947. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  40948. v := m.nickname
  40949. if v == nil {
  40950. return
  40951. }
  40952. return *v, true
  40953. }
  40954. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  40955. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40957. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  40958. if !m.op.Is(OpUpdateOne) {
  40959. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40960. }
  40961. if m.id == nil || m.oldValue == nil {
  40962. return v, errors.New("OldNickname requires an ID field in the mutation")
  40963. }
  40964. oldValue, err := m.oldValue(ctx)
  40965. if err != nil {
  40966. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40967. }
  40968. return oldValue.Nickname, nil
  40969. }
  40970. // ResetNickname resets all changes to the "nickname" field.
  40971. func (m *WpChatroomMemberMutation) ResetNickname() {
  40972. m.nickname = nil
  40973. }
  40974. // SetAvatar sets the "avatar" field.
  40975. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  40976. m.avatar = &s
  40977. }
  40978. // Avatar returns the value of the "avatar" field in the mutation.
  40979. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  40980. v := m.avatar
  40981. if v == nil {
  40982. return
  40983. }
  40984. return *v, true
  40985. }
  40986. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  40987. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40989. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40990. if !m.op.Is(OpUpdateOne) {
  40991. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40992. }
  40993. if m.id == nil || m.oldValue == nil {
  40994. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40995. }
  40996. oldValue, err := m.oldValue(ctx)
  40997. if err != nil {
  40998. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40999. }
  41000. return oldValue.Avatar, nil
  41001. }
  41002. // ResetAvatar resets all changes to the "avatar" field.
  41003. func (m *WpChatroomMemberMutation) ResetAvatar() {
  41004. m.avatar = nil
  41005. }
  41006. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  41007. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  41008. m.predicates = append(m.predicates, ps...)
  41009. }
  41010. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  41011. // users can use type-assertion to append predicates that do not depend on any generated package.
  41012. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  41013. p := make([]predicate.WpChatroomMember, len(ps))
  41014. for i := range ps {
  41015. p[i] = ps[i]
  41016. }
  41017. m.Where(p...)
  41018. }
  41019. // Op returns the operation name.
  41020. func (m *WpChatroomMemberMutation) Op() Op {
  41021. return m.op
  41022. }
  41023. // SetOp allows setting the mutation operation.
  41024. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  41025. m.op = op
  41026. }
  41027. // Type returns the node type of this mutation (WpChatroomMember).
  41028. func (m *WpChatroomMemberMutation) Type() string {
  41029. return m.typ
  41030. }
  41031. // Fields returns all fields that were changed during this mutation. Note that in
  41032. // order to get all numeric fields that were incremented/decremented, call
  41033. // AddedFields().
  41034. func (m *WpChatroomMemberMutation) Fields() []string {
  41035. fields := make([]string, 0, 7)
  41036. if m.created_at != nil {
  41037. fields = append(fields, wpchatroommember.FieldCreatedAt)
  41038. }
  41039. if m.updated_at != nil {
  41040. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  41041. }
  41042. if m.status != nil {
  41043. fields = append(fields, wpchatroommember.FieldStatus)
  41044. }
  41045. if m.wx_wxid != nil {
  41046. fields = append(fields, wpchatroommember.FieldWxWxid)
  41047. }
  41048. if m.wxid != nil {
  41049. fields = append(fields, wpchatroommember.FieldWxid)
  41050. }
  41051. if m.nickname != nil {
  41052. fields = append(fields, wpchatroommember.FieldNickname)
  41053. }
  41054. if m.avatar != nil {
  41055. fields = append(fields, wpchatroommember.FieldAvatar)
  41056. }
  41057. return fields
  41058. }
  41059. // Field returns the value of a field with the given name. The second boolean
  41060. // return value indicates that this field was not set, or was not defined in the
  41061. // schema.
  41062. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  41063. switch name {
  41064. case wpchatroommember.FieldCreatedAt:
  41065. return m.CreatedAt()
  41066. case wpchatroommember.FieldUpdatedAt:
  41067. return m.UpdatedAt()
  41068. case wpchatroommember.FieldStatus:
  41069. return m.Status()
  41070. case wpchatroommember.FieldWxWxid:
  41071. return m.WxWxid()
  41072. case wpchatroommember.FieldWxid:
  41073. return m.Wxid()
  41074. case wpchatroommember.FieldNickname:
  41075. return m.Nickname()
  41076. case wpchatroommember.FieldAvatar:
  41077. return m.Avatar()
  41078. }
  41079. return nil, false
  41080. }
  41081. // OldField returns the old value of the field from the database. An error is
  41082. // returned if the mutation operation is not UpdateOne, or the query to the
  41083. // database failed.
  41084. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41085. switch name {
  41086. case wpchatroommember.FieldCreatedAt:
  41087. return m.OldCreatedAt(ctx)
  41088. case wpchatroommember.FieldUpdatedAt:
  41089. return m.OldUpdatedAt(ctx)
  41090. case wpchatroommember.FieldStatus:
  41091. return m.OldStatus(ctx)
  41092. case wpchatroommember.FieldWxWxid:
  41093. return m.OldWxWxid(ctx)
  41094. case wpchatroommember.FieldWxid:
  41095. return m.OldWxid(ctx)
  41096. case wpchatroommember.FieldNickname:
  41097. return m.OldNickname(ctx)
  41098. case wpchatroommember.FieldAvatar:
  41099. return m.OldAvatar(ctx)
  41100. }
  41101. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  41102. }
  41103. // SetField sets the value of a field with the given name. It returns an error if
  41104. // the field is not defined in the schema, or if the type mismatched the field
  41105. // type.
  41106. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  41107. switch name {
  41108. case wpchatroommember.FieldCreatedAt:
  41109. v, ok := value.(time.Time)
  41110. if !ok {
  41111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41112. }
  41113. m.SetCreatedAt(v)
  41114. return nil
  41115. case wpchatroommember.FieldUpdatedAt:
  41116. v, ok := value.(time.Time)
  41117. if !ok {
  41118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41119. }
  41120. m.SetUpdatedAt(v)
  41121. return nil
  41122. case wpchatroommember.FieldStatus:
  41123. v, ok := value.(uint8)
  41124. if !ok {
  41125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41126. }
  41127. m.SetStatus(v)
  41128. return nil
  41129. case wpchatroommember.FieldWxWxid:
  41130. v, ok := value.(string)
  41131. if !ok {
  41132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41133. }
  41134. m.SetWxWxid(v)
  41135. return nil
  41136. case wpchatroommember.FieldWxid:
  41137. v, ok := value.(string)
  41138. if !ok {
  41139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41140. }
  41141. m.SetWxid(v)
  41142. return nil
  41143. case wpchatroommember.FieldNickname:
  41144. v, ok := value.(string)
  41145. if !ok {
  41146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41147. }
  41148. m.SetNickname(v)
  41149. return nil
  41150. case wpchatroommember.FieldAvatar:
  41151. v, ok := value.(string)
  41152. if !ok {
  41153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41154. }
  41155. m.SetAvatar(v)
  41156. return nil
  41157. }
  41158. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  41159. }
  41160. // AddedFields returns all numeric fields that were incremented/decremented during
  41161. // this mutation.
  41162. func (m *WpChatroomMemberMutation) AddedFields() []string {
  41163. var fields []string
  41164. if m.addstatus != nil {
  41165. fields = append(fields, wpchatroommember.FieldStatus)
  41166. }
  41167. return fields
  41168. }
  41169. // AddedField returns the numeric value that was incremented/decremented on a field
  41170. // with the given name. The second boolean return value indicates that this field
  41171. // was not set, or was not defined in the schema.
  41172. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  41173. switch name {
  41174. case wpchatroommember.FieldStatus:
  41175. return m.AddedStatus()
  41176. }
  41177. return nil, false
  41178. }
  41179. // AddField adds the value to the field with the given name. It returns an error if
  41180. // the field is not defined in the schema, or if the type mismatched the field
  41181. // type.
  41182. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  41183. switch name {
  41184. case wpchatroommember.FieldStatus:
  41185. v, ok := value.(int8)
  41186. if !ok {
  41187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41188. }
  41189. m.AddStatus(v)
  41190. return nil
  41191. }
  41192. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  41193. }
  41194. // ClearedFields returns all nullable fields that were cleared during this
  41195. // mutation.
  41196. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  41197. var fields []string
  41198. if m.FieldCleared(wpchatroommember.FieldStatus) {
  41199. fields = append(fields, wpchatroommember.FieldStatus)
  41200. }
  41201. return fields
  41202. }
  41203. // FieldCleared returns a boolean indicating if a field with the given name was
  41204. // cleared in this mutation.
  41205. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  41206. _, ok := m.clearedFields[name]
  41207. return ok
  41208. }
  41209. // ClearField clears the value of the field with the given name. It returns an
  41210. // error if the field is not defined in the schema.
  41211. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  41212. switch name {
  41213. case wpchatroommember.FieldStatus:
  41214. m.ClearStatus()
  41215. return nil
  41216. }
  41217. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  41218. }
  41219. // ResetField resets all changes in the mutation for the field with the given name.
  41220. // It returns an error if the field is not defined in the schema.
  41221. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  41222. switch name {
  41223. case wpchatroommember.FieldCreatedAt:
  41224. m.ResetCreatedAt()
  41225. return nil
  41226. case wpchatroommember.FieldUpdatedAt:
  41227. m.ResetUpdatedAt()
  41228. return nil
  41229. case wpchatroommember.FieldStatus:
  41230. m.ResetStatus()
  41231. return nil
  41232. case wpchatroommember.FieldWxWxid:
  41233. m.ResetWxWxid()
  41234. return nil
  41235. case wpchatroommember.FieldWxid:
  41236. m.ResetWxid()
  41237. return nil
  41238. case wpchatroommember.FieldNickname:
  41239. m.ResetNickname()
  41240. return nil
  41241. case wpchatroommember.FieldAvatar:
  41242. m.ResetAvatar()
  41243. return nil
  41244. }
  41245. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  41246. }
  41247. // AddedEdges returns all edge names that were set/added in this mutation.
  41248. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  41249. edges := make([]string, 0, 0)
  41250. return edges
  41251. }
  41252. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41253. // name in this mutation.
  41254. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  41255. return nil
  41256. }
  41257. // RemovedEdges returns all edge names that were removed in this mutation.
  41258. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  41259. edges := make([]string, 0, 0)
  41260. return edges
  41261. }
  41262. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41263. // the given name in this mutation.
  41264. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  41265. return nil
  41266. }
  41267. // ClearedEdges returns all edge names that were cleared in this mutation.
  41268. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  41269. edges := make([]string, 0, 0)
  41270. return edges
  41271. }
  41272. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41273. // was cleared in this mutation.
  41274. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  41275. return false
  41276. }
  41277. // ClearEdge clears the value of the edge with the given name. It returns an error
  41278. // if that edge is not defined in the schema.
  41279. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  41280. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  41281. }
  41282. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41283. // It returns an error if the edge is not defined in the schema.
  41284. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  41285. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  41286. }
  41287. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  41288. type WxMutation struct {
  41289. config
  41290. op Op
  41291. typ string
  41292. id *uint64
  41293. created_at *time.Time
  41294. updated_at *time.Time
  41295. status *uint8
  41296. addstatus *int8
  41297. deleted_at *time.Time
  41298. port *string
  41299. process_id *string
  41300. callback *string
  41301. wxid *string
  41302. account *string
  41303. nickname *string
  41304. tel *string
  41305. head_big *string
  41306. organization_id *uint64
  41307. addorganization_id *int64
  41308. api_base *string
  41309. api_key *string
  41310. allow_list *[]string
  41311. appendallow_list []string
  41312. group_allow_list *[]string
  41313. appendgroup_allow_list []string
  41314. block_list *[]string
  41315. appendblock_list []string
  41316. group_block_list *[]string
  41317. appendgroup_block_list []string
  41318. ctype *uint64
  41319. addctype *int64
  41320. clearedFields map[string]struct{}
  41321. server *uint64
  41322. clearedserver bool
  41323. agent *uint64
  41324. clearedagent bool
  41325. done bool
  41326. oldValue func(context.Context) (*Wx, error)
  41327. predicates []predicate.Wx
  41328. }
  41329. var _ ent.Mutation = (*WxMutation)(nil)
  41330. // wxOption allows management of the mutation configuration using functional options.
  41331. type wxOption func(*WxMutation)
  41332. // newWxMutation creates new mutation for the Wx entity.
  41333. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  41334. m := &WxMutation{
  41335. config: c,
  41336. op: op,
  41337. typ: TypeWx,
  41338. clearedFields: make(map[string]struct{}),
  41339. }
  41340. for _, opt := range opts {
  41341. opt(m)
  41342. }
  41343. return m
  41344. }
  41345. // withWxID sets the ID field of the mutation.
  41346. func withWxID(id uint64) wxOption {
  41347. return func(m *WxMutation) {
  41348. var (
  41349. err error
  41350. once sync.Once
  41351. value *Wx
  41352. )
  41353. m.oldValue = func(ctx context.Context) (*Wx, error) {
  41354. once.Do(func() {
  41355. if m.done {
  41356. err = errors.New("querying old values post mutation is not allowed")
  41357. } else {
  41358. value, err = m.Client().Wx.Get(ctx, id)
  41359. }
  41360. })
  41361. return value, err
  41362. }
  41363. m.id = &id
  41364. }
  41365. }
  41366. // withWx sets the old Wx of the mutation.
  41367. func withWx(node *Wx) wxOption {
  41368. return func(m *WxMutation) {
  41369. m.oldValue = func(context.Context) (*Wx, error) {
  41370. return node, nil
  41371. }
  41372. m.id = &node.ID
  41373. }
  41374. }
  41375. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41376. // executed in a transaction (ent.Tx), a transactional client is returned.
  41377. func (m WxMutation) Client() *Client {
  41378. client := &Client{config: m.config}
  41379. client.init()
  41380. return client
  41381. }
  41382. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41383. // it returns an error otherwise.
  41384. func (m WxMutation) Tx() (*Tx, error) {
  41385. if _, ok := m.driver.(*txDriver); !ok {
  41386. return nil, errors.New("ent: mutation is not running in a transaction")
  41387. }
  41388. tx := &Tx{config: m.config}
  41389. tx.init()
  41390. return tx, nil
  41391. }
  41392. // SetID sets the value of the id field. Note that this
  41393. // operation is only accepted on creation of Wx entities.
  41394. func (m *WxMutation) SetID(id uint64) {
  41395. m.id = &id
  41396. }
  41397. // ID returns the ID value in the mutation. Note that the ID is only available
  41398. // if it was provided to the builder or after it was returned from the database.
  41399. func (m *WxMutation) ID() (id uint64, exists bool) {
  41400. if m.id == nil {
  41401. return
  41402. }
  41403. return *m.id, true
  41404. }
  41405. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41406. // That means, if the mutation is applied within a transaction with an isolation level such
  41407. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41408. // or updated by the mutation.
  41409. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  41410. switch {
  41411. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41412. id, exists := m.ID()
  41413. if exists {
  41414. return []uint64{id}, nil
  41415. }
  41416. fallthrough
  41417. case m.op.Is(OpUpdate | OpDelete):
  41418. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  41419. default:
  41420. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41421. }
  41422. }
  41423. // SetCreatedAt sets the "created_at" field.
  41424. func (m *WxMutation) SetCreatedAt(t time.Time) {
  41425. m.created_at = &t
  41426. }
  41427. // CreatedAt returns the value of the "created_at" field in the mutation.
  41428. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  41429. v := m.created_at
  41430. if v == nil {
  41431. return
  41432. }
  41433. return *v, true
  41434. }
  41435. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  41436. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41438. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41439. if !m.op.Is(OpUpdateOne) {
  41440. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41441. }
  41442. if m.id == nil || m.oldValue == nil {
  41443. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41444. }
  41445. oldValue, err := m.oldValue(ctx)
  41446. if err != nil {
  41447. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41448. }
  41449. return oldValue.CreatedAt, nil
  41450. }
  41451. // ResetCreatedAt resets all changes to the "created_at" field.
  41452. func (m *WxMutation) ResetCreatedAt() {
  41453. m.created_at = nil
  41454. }
  41455. // SetUpdatedAt sets the "updated_at" field.
  41456. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  41457. m.updated_at = &t
  41458. }
  41459. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41460. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  41461. v := m.updated_at
  41462. if v == nil {
  41463. return
  41464. }
  41465. return *v, true
  41466. }
  41467. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  41468. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41470. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41471. if !m.op.Is(OpUpdateOne) {
  41472. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41473. }
  41474. if m.id == nil || m.oldValue == nil {
  41475. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41476. }
  41477. oldValue, err := m.oldValue(ctx)
  41478. if err != nil {
  41479. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41480. }
  41481. return oldValue.UpdatedAt, nil
  41482. }
  41483. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41484. func (m *WxMutation) ResetUpdatedAt() {
  41485. m.updated_at = nil
  41486. }
  41487. // SetStatus sets the "status" field.
  41488. func (m *WxMutation) SetStatus(u uint8) {
  41489. m.status = &u
  41490. m.addstatus = nil
  41491. }
  41492. // Status returns the value of the "status" field in the mutation.
  41493. func (m *WxMutation) Status() (r uint8, exists bool) {
  41494. v := m.status
  41495. if v == nil {
  41496. return
  41497. }
  41498. return *v, true
  41499. }
  41500. // OldStatus returns the old "status" field's value of the Wx entity.
  41501. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41503. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41504. if !m.op.Is(OpUpdateOne) {
  41505. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41506. }
  41507. if m.id == nil || m.oldValue == nil {
  41508. return v, errors.New("OldStatus requires an ID field in the mutation")
  41509. }
  41510. oldValue, err := m.oldValue(ctx)
  41511. if err != nil {
  41512. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41513. }
  41514. return oldValue.Status, nil
  41515. }
  41516. // AddStatus adds u to the "status" field.
  41517. func (m *WxMutation) AddStatus(u int8) {
  41518. if m.addstatus != nil {
  41519. *m.addstatus += u
  41520. } else {
  41521. m.addstatus = &u
  41522. }
  41523. }
  41524. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41525. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  41526. v := m.addstatus
  41527. if v == nil {
  41528. return
  41529. }
  41530. return *v, true
  41531. }
  41532. // ClearStatus clears the value of the "status" field.
  41533. func (m *WxMutation) ClearStatus() {
  41534. m.status = nil
  41535. m.addstatus = nil
  41536. m.clearedFields[wx.FieldStatus] = struct{}{}
  41537. }
  41538. // StatusCleared returns if the "status" field was cleared in this mutation.
  41539. func (m *WxMutation) StatusCleared() bool {
  41540. _, ok := m.clearedFields[wx.FieldStatus]
  41541. return ok
  41542. }
  41543. // ResetStatus resets all changes to the "status" field.
  41544. func (m *WxMutation) ResetStatus() {
  41545. m.status = nil
  41546. m.addstatus = nil
  41547. delete(m.clearedFields, wx.FieldStatus)
  41548. }
  41549. // SetDeletedAt sets the "deleted_at" field.
  41550. func (m *WxMutation) SetDeletedAt(t time.Time) {
  41551. m.deleted_at = &t
  41552. }
  41553. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41554. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  41555. v := m.deleted_at
  41556. if v == nil {
  41557. return
  41558. }
  41559. return *v, true
  41560. }
  41561. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  41562. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41564. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41565. if !m.op.Is(OpUpdateOne) {
  41566. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41567. }
  41568. if m.id == nil || m.oldValue == nil {
  41569. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41570. }
  41571. oldValue, err := m.oldValue(ctx)
  41572. if err != nil {
  41573. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41574. }
  41575. return oldValue.DeletedAt, nil
  41576. }
  41577. // ClearDeletedAt clears the value of the "deleted_at" field.
  41578. func (m *WxMutation) ClearDeletedAt() {
  41579. m.deleted_at = nil
  41580. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  41581. }
  41582. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41583. func (m *WxMutation) DeletedAtCleared() bool {
  41584. _, ok := m.clearedFields[wx.FieldDeletedAt]
  41585. return ok
  41586. }
  41587. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41588. func (m *WxMutation) ResetDeletedAt() {
  41589. m.deleted_at = nil
  41590. delete(m.clearedFields, wx.FieldDeletedAt)
  41591. }
  41592. // SetServerID sets the "server_id" field.
  41593. func (m *WxMutation) SetServerID(u uint64) {
  41594. m.server = &u
  41595. }
  41596. // ServerID returns the value of the "server_id" field in the mutation.
  41597. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  41598. v := m.server
  41599. if v == nil {
  41600. return
  41601. }
  41602. return *v, true
  41603. }
  41604. // OldServerID returns the old "server_id" field's value of the Wx entity.
  41605. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41607. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  41608. if !m.op.Is(OpUpdateOne) {
  41609. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  41610. }
  41611. if m.id == nil || m.oldValue == nil {
  41612. return v, errors.New("OldServerID requires an ID field in the mutation")
  41613. }
  41614. oldValue, err := m.oldValue(ctx)
  41615. if err != nil {
  41616. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  41617. }
  41618. return oldValue.ServerID, nil
  41619. }
  41620. // ClearServerID clears the value of the "server_id" field.
  41621. func (m *WxMutation) ClearServerID() {
  41622. m.server = nil
  41623. m.clearedFields[wx.FieldServerID] = struct{}{}
  41624. }
  41625. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  41626. func (m *WxMutation) ServerIDCleared() bool {
  41627. _, ok := m.clearedFields[wx.FieldServerID]
  41628. return ok
  41629. }
  41630. // ResetServerID resets all changes to the "server_id" field.
  41631. func (m *WxMutation) ResetServerID() {
  41632. m.server = nil
  41633. delete(m.clearedFields, wx.FieldServerID)
  41634. }
  41635. // SetPort sets the "port" field.
  41636. func (m *WxMutation) SetPort(s string) {
  41637. m.port = &s
  41638. }
  41639. // Port returns the value of the "port" field in the mutation.
  41640. func (m *WxMutation) Port() (r string, exists bool) {
  41641. v := m.port
  41642. if v == nil {
  41643. return
  41644. }
  41645. return *v, true
  41646. }
  41647. // OldPort returns the old "port" field's value of the Wx entity.
  41648. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41650. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  41651. if !m.op.Is(OpUpdateOne) {
  41652. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  41653. }
  41654. if m.id == nil || m.oldValue == nil {
  41655. return v, errors.New("OldPort requires an ID field in the mutation")
  41656. }
  41657. oldValue, err := m.oldValue(ctx)
  41658. if err != nil {
  41659. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  41660. }
  41661. return oldValue.Port, nil
  41662. }
  41663. // ResetPort resets all changes to the "port" field.
  41664. func (m *WxMutation) ResetPort() {
  41665. m.port = nil
  41666. }
  41667. // SetProcessID sets the "process_id" field.
  41668. func (m *WxMutation) SetProcessID(s string) {
  41669. m.process_id = &s
  41670. }
  41671. // ProcessID returns the value of the "process_id" field in the mutation.
  41672. func (m *WxMutation) ProcessID() (r string, exists bool) {
  41673. v := m.process_id
  41674. if v == nil {
  41675. return
  41676. }
  41677. return *v, true
  41678. }
  41679. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  41680. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41682. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  41683. if !m.op.Is(OpUpdateOne) {
  41684. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  41685. }
  41686. if m.id == nil || m.oldValue == nil {
  41687. return v, errors.New("OldProcessID requires an ID field in the mutation")
  41688. }
  41689. oldValue, err := m.oldValue(ctx)
  41690. if err != nil {
  41691. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  41692. }
  41693. return oldValue.ProcessID, nil
  41694. }
  41695. // ResetProcessID resets all changes to the "process_id" field.
  41696. func (m *WxMutation) ResetProcessID() {
  41697. m.process_id = nil
  41698. }
  41699. // SetCallback sets the "callback" field.
  41700. func (m *WxMutation) SetCallback(s string) {
  41701. m.callback = &s
  41702. }
  41703. // Callback returns the value of the "callback" field in the mutation.
  41704. func (m *WxMutation) Callback() (r string, exists bool) {
  41705. v := m.callback
  41706. if v == nil {
  41707. return
  41708. }
  41709. return *v, true
  41710. }
  41711. // OldCallback returns the old "callback" field's value of the Wx entity.
  41712. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41714. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  41715. if !m.op.Is(OpUpdateOne) {
  41716. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  41717. }
  41718. if m.id == nil || m.oldValue == nil {
  41719. return v, errors.New("OldCallback requires an ID field in the mutation")
  41720. }
  41721. oldValue, err := m.oldValue(ctx)
  41722. if err != nil {
  41723. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  41724. }
  41725. return oldValue.Callback, nil
  41726. }
  41727. // ResetCallback resets all changes to the "callback" field.
  41728. func (m *WxMutation) ResetCallback() {
  41729. m.callback = nil
  41730. }
  41731. // SetWxid sets the "wxid" field.
  41732. func (m *WxMutation) SetWxid(s string) {
  41733. m.wxid = &s
  41734. }
  41735. // Wxid returns the value of the "wxid" field in the mutation.
  41736. func (m *WxMutation) Wxid() (r string, exists bool) {
  41737. v := m.wxid
  41738. if v == nil {
  41739. return
  41740. }
  41741. return *v, true
  41742. }
  41743. // OldWxid returns the old "wxid" field's value of the Wx entity.
  41744. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41746. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  41747. if !m.op.Is(OpUpdateOne) {
  41748. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41749. }
  41750. if m.id == nil || m.oldValue == nil {
  41751. return v, errors.New("OldWxid requires an ID field in the mutation")
  41752. }
  41753. oldValue, err := m.oldValue(ctx)
  41754. if err != nil {
  41755. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41756. }
  41757. return oldValue.Wxid, nil
  41758. }
  41759. // ResetWxid resets all changes to the "wxid" field.
  41760. func (m *WxMutation) ResetWxid() {
  41761. m.wxid = nil
  41762. }
  41763. // SetAccount sets the "account" field.
  41764. func (m *WxMutation) SetAccount(s string) {
  41765. m.account = &s
  41766. }
  41767. // Account returns the value of the "account" field in the mutation.
  41768. func (m *WxMutation) Account() (r string, exists bool) {
  41769. v := m.account
  41770. if v == nil {
  41771. return
  41772. }
  41773. return *v, true
  41774. }
  41775. // OldAccount returns the old "account" field's value of the Wx entity.
  41776. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41778. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  41779. if !m.op.Is(OpUpdateOne) {
  41780. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41781. }
  41782. if m.id == nil || m.oldValue == nil {
  41783. return v, errors.New("OldAccount requires an ID field in the mutation")
  41784. }
  41785. oldValue, err := m.oldValue(ctx)
  41786. if err != nil {
  41787. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41788. }
  41789. return oldValue.Account, nil
  41790. }
  41791. // ResetAccount resets all changes to the "account" field.
  41792. func (m *WxMutation) ResetAccount() {
  41793. m.account = nil
  41794. }
  41795. // SetNickname sets the "nickname" field.
  41796. func (m *WxMutation) SetNickname(s string) {
  41797. m.nickname = &s
  41798. }
  41799. // Nickname returns the value of the "nickname" field in the mutation.
  41800. func (m *WxMutation) Nickname() (r string, exists bool) {
  41801. v := m.nickname
  41802. if v == nil {
  41803. return
  41804. }
  41805. return *v, true
  41806. }
  41807. // OldNickname returns the old "nickname" field's value of the Wx entity.
  41808. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41810. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  41811. if !m.op.Is(OpUpdateOne) {
  41812. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41813. }
  41814. if m.id == nil || m.oldValue == nil {
  41815. return v, errors.New("OldNickname requires an ID field in the mutation")
  41816. }
  41817. oldValue, err := m.oldValue(ctx)
  41818. if err != nil {
  41819. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41820. }
  41821. return oldValue.Nickname, nil
  41822. }
  41823. // ResetNickname resets all changes to the "nickname" field.
  41824. func (m *WxMutation) ResetNickname() {
  41825. m.nickname = nil
  41826. }
  41827. // SetTel sets the "tel" field.
  41828. func (m *WxMutation) SetTel(s string) {
  41829. m.tel = &s
  41830. }
  41831. // Tel returns the value of the "tel" field in the mutation.
  41832. func (m *WxMutation) Tel() (r string, exists bool) {
  41833. v := m.tel
  41834. if v == nil {
  41835. return
  41836. }
  41837. return *v, true
  41838. }
  41839. // OldTel returns the old "tel" field's value of the Wx entity.
  41840. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41842. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  41843. if !m.op.Is(OpUpdateOne) {
  41844. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  41845. }
  41846. if m.id == nil || m.oldValue == nil {
  41847. return v, errors.New("OldTel requires an ID field in the mutation")
  41848. }
  41849. oldValue, err := m.oldValue(ctx)
  41850. if err != nil {
  41851. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  41852. }
  41853. return oldValue.Tel, nil
  41854. }
  41855. // ResetTel resets all changes to the "tel" field.
  41856. func (m *WxMutation) ResetTel() {
  41857. m.tel = nil
  41858. }
  41859. // SetHeadBig sets the "head_big" field.
  41860. func (m *WxMutation) SetHeadBig(s string) {
  41861. m.head_big = &s
  41862. }
  41863. // HeadBig returns the value of the "head_big" field in the mutation.
  41864. func (m *WxMutation) HeadBig() (r string, exists bool) {
  41865. v := m.head_big
  41866. if v == nil {
  41867. return
  41868. }
  41869. return *v, true
  41870. }
  41871. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  41872. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41874. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  41875. if !m.op.Is(OpUpdateOne) {
  41876. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  41877. }
  41878. if m.id == nil || m.oldValue == nil {
  41879. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  41880. }
  41881. oldValue, err := m.oldValue(ctx)
  41882. if err != nil {
  41883. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  41884. }
  41885. return oldValue.HeadBig, nil
  41886. }
  41887. // ResetHeadBig resets all changes to the "head_big" field.
  41888. func (m *WxMutation) ResetHeadBig() {
  41889. m.head_big = nil
  41890. }
  41891. // SetOrganizationID sets the "organization_id" field.
  41892. func (m *WxMutation) SetOrganizationID(u uint64) {
  41893. m.organization_id = &u
  41894. m.addorganization_id = nil
  41895. }
  41896. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41897. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  41898. v := m.organization_id
  41899. if v == nil {
  41900. return
  41901. }
  41902. return *v, true
  41903. }
  41904. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  41905. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41907. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41908. if !m.op.Is(OpUpdateOne) {
  41909. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41910. }
  41911. if m.id == nil || m.oldValue == nil {
  41912. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41913. }
  41914. oldValue, err := m.oldValue(ctx)
  41915. if err != nil {
  41916. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41917. }
  41918. return oldValue.OrganizationID, nil
  41919. }
  41920. // AddOrganizationID adds u to the "organization_id" field.
  41921. func (m *WxMutation) AddOrganizationID(u int64) {
  41922. if m.addorganization_id != nil {
  41923. *m.addorganization_id += u
  41924. } else {
  41925. m.addorganization_id = &u
  41926. }
  41927. }
  41928. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41929. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  41930. v := m.addorganization_id
  41931. if v == nil {
  41932. return
  41933. }
  41934. return *v, true
  41935. }
  41936. // ClearOrganizationID clears the value of the "organization_id" field.
  41937. func (m *WxMutation) ClearOrganizationID() {
  41938. m.organization_id = nil
  41939. m.addorganization_id = nil
  41940. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  41941. }
  41942. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41943. func (m *WxMutation) OrganizationIDCleared() bool {
  41944. _, ok := m.clearedFields[wx.FieldOrganizationID]
  41945. return ok
  41946. }
  41947. // ResetOrganizationID resets all changes to the "organization_id" field.
  41948. func (m *WxMutation) ResetOrganizationID() {
  41949. m.organization_id = nil
  41950. m.addorganization_id = nil
  41951. delete(m.clearedFields, wx.FieldOrganizationID)
  41952. }
  41953. // SetAgentID sets the "agent_id" field.
  41954. func (m *WxMutation) SetAgentID(u uint64) {
  41955. m.agent = &u
  41956. }
  41957. // AgentID returns the value of the "agent_id" field in the mutation.
  41958. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  41959. v := m.agent
  41960. if v == nil {
  41961. return
  41962. }
  41963. return *v, true
  41964. }
  41965. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  41966. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41968. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  41969. if !m.op.Is(OpUpdateOne) {
  41970. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  41971. }
  41972. if m.id == nil || m.oldValue == nil {
  41973. return v, errors.New("OldAgentID requires an ID field in the mutation")
  41974. }
  41975. oldValue, err := m.oldValue(ctx)
  41976. if err != nil {
  41977. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  41978. }
  41979. return oldValue.AgentID, nil
  41980. }
  41981. // ResetAgentID resets all changes to the "agent_id" field.
  41982. func (m *WxMutation) ResetAgentID() {
  41983. m.agent = nil
  41984. }
  41985. // SetAPIBase sets the "api_base" field.
  41986. func (m *WxMutation) SetAPIBase(s string) {
  41987. m.api_base = &s
  41988. }
  41989. // APIBase returns the value of the "api_base" field in the mutation.
  41990. func (m *WxMutation) APIBase() (r string, exists bool) {
  41991. v := m.api_base
  41992. if v == nil {
  41993. return
  41994. }
  41995. return *v, true
  41996. }
  41997. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  41998. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42000. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42001. if !m.op.Is(OpUpdateOne) {
  42002. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42003. }
  42004. if m.id == nil || m.oldValue == nil {
  42005. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42006. }
  42007. oldValue, err := m.oldValue(ctx)
  42008. if err != nil {
  42009. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42010. }
  42011. return oldValue.APIBase, nil
  42012. }
  42013. // ClearAPIBase clears the value of the "api_base" field.
  42014. func (m *WxMutation) ClearAPIBase() {
  42015. m.api_base = nil
  42016. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  42017. }
  42018. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42019. func (m *WxMutation) APIBaseCleared() bool {
  42020. _, ok := m.clearedFields[wx.FieldAPIBase]
  42021. return ok
  42022. }
  42023. // ResetAPIBase resets all changes to the "api_base" field.
  42024. func (m *WxMutation) ResetAPIBase() {
  42025. m.api_base = nil
  42026. delete(m.clearedFields, wx.FieldAPIBase)
  42027. }
  42028. // SetAPIKey sets the "api_key" field.
  42029. func (m *WxMutation) SetAPIKey(s string) {
  42030. m.api_key = &s
  42031. }
  42032. // APIKey returns the value of the "api_key" field in the mutation.
  42033. func (m *WxMutation) APIKey() (r string, exists bool) {
  42034. v := m.api_key
  42035. if v == nil {
  42036. return
  42037. }
  42038. return *v, true
  42039. }
  42040. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  42041. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42043. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42044. if !m.op.Is(OpUpdateOne) {
  42045. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42046. }
  42047. if m.id == nil || m.oldValue == nil {
  42048. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42049. }
  42050. oldValue, err := m.oldValue(ctx)
  42051. if err != nil {
  42052. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42053. }
  42054. return oldValue.APIKey, nil
  42055. }
  42056. // ClearAPIKey clears the value of the "api_key" field.
  42057. func (m *WxMutation) ClearAPIKey() {
  42058. m.api_key = nil
  42059. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  42060. }
  42061. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42062. func (m *WxMutation) APIKeyCleared() bool {
  42063. _, ok := m.clearedFields[wx.FieldAPIKey]
  42064. return ok
  42065. }
  42066. // ResetAPIKey resets all changes to the "api_key" field.
  42067. func (m *WxMutation) ResetAPIKey() {
  42068. m.api_key = nil
  42069. delete(m.clearedFields, wx.FieldAPIKey)
  42070. }
  42071. // SetAllowList sets the "allow_list" field.
  42072. func (m *WxMutation) SetAllowList(s []string) {
  42073. m.allow_list = &s
  42074. m.appendallow_list = nil
  42075. }
  42076. // AllowList returns the value of the "allow_list" field in the mutation.
  42077. func (m *WxMutation) AllowList() (r []string, exists bool) {
  42078. v := m.allow_list
  42079. if v == nil {
  42080. return
  42081. }
  42082. return *v, true
  42083. }
  42084. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  42085. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42087. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  42088. if !m.op.Is(OpUpdateOne) {
  42089. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  42090. }
  42091. if m.id == nil || m.oldValue == nil {
  42092. return v, errors.New("OldAllowList requires an ID field in the mutation")
  42093. }
  42094. oldValue, err := m.oldValue(ctx)
  42095. if err != nil {
  42096. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  42097. }
  42098. return oldValue.AllowList, nil
  42099. }
  42100. // AppendAllowList adds s to the "allow_list" field.
  42101. func (m *WxMutation) AppendAllowList(s []string) {
  42102. m.appendallow_list = append(m.appendallow_list, s...)
  42103. }
  42104. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  42105. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  42106. if len(m.appendallow_list) == 0 {
  42107. return nil, false
  42108. }
  42109. return m.appendallow_list, true
  42110. }
  42111. // ResetAllowList resets all changes to the "allow_list" field.
  42112. func (m *WxMutation) ResetAllowList() {
  42113. m.allow_list = nil
  42114. m.appendallow_list = nil
  42115. }
  42116. // SetGroupAllowList sets the "group_allow_list" field.
  42117. func (m *WxMutation) SetGroupAllowList(s []string) {
  42118. m.group_allow_list = &s
  42119. m.appendgroup_allow_list = nil
  42120. }
  42121. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  42122. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  42123. v := m.group_allow_list
  42124. if v == nil {
  42125. return
  42126. }
  42127. return *v, true
  42128. }
  42129. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  42130. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42132. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  42133. if !m.op.Is(OpUpdateOne) {
  42134. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  42135. }
  42136. if m.id == nil || m.oldValue == nil {
  42137. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  42138. }
  42139. oldValue, err := m.oldValue(ctx)
  42140. if err != nil {
  42141. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  42142. }
  42143. return oldValue.GroupAllowList, nil
  42144. }
  42145. // AppendGroupAllowList adds s to the "group_allow_list" field.
  42146. func (m *WxMutation) AppendGroupAllowList(s []string) {
  42147. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  42148. }
  42149. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  42150. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  42151. if len(m.appendgroup_allow_list) == 0 {
  42152. return nil, false
  42153. }
  42154. return m.appendgroup_allow_list, true
  42155. }
  42156. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  42157. func (m *WxMutation) ResetGroupAllowList() {
  42158. m.group_allow_list = nil
  42159. m.appendgroup_allow_list = nil
  42160. }
  42161. // SetBlockList sets the "block_list" field.
  42162. func (m *WxMutation) SetBlockList(s []string) {
  42163. m.block_list = &s
  42164. m.appendblock_list = nil
  42165. }
  42166. // BlockList returns the value of the "block_list" field in the mutation.
  42167. func (m *WxMutation) BlockList() (r []string, exists bool) {
  42168. v := m.block_list
  42169. if v == nil {
  42170. return
  42171. }
  42172. return *v, true
  42173. }
  42174. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  42175. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42177. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  42178. if !m.op.Is(OpUpdateOne) {
  42179. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  42180. }
  42181. if m.id == nil || m.oldValue == nil {
  42182. return v, errors.New("OldBlockList requires an ID field in the mutation")
  42183. }
  42184. oldValue, err := m.oldValue(ctx)
  42185. if err != nil {
  42186. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  42187. }
  42188. return oldValue.BlockList, nil
  42189. }
  42190. // AppendBlockList adds s to the "block_list" field.
  42191. func (m *WxMutation) AppendBlockList(s []string) {
  42192. m.appendblock_list = append(m.appendblock_list, s...)
  42193. }
  42194. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  42195. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  42196. if len(m.appendblock_list) == 0 {
  42197. return nil, false
  42198. }
  42199. return m.appendblock_list, true
  42200. }
  42201. // ResetBlockList resets all changes to the "block_list" field.
  42202. func (m *WxMutation) ResetBlockList() {
  42203. m.block_list = nil
  42204. m.appendblock_list = nil
  42205. }
  42206. // SetGroupBlockList sets the "group_block_list" field.
  42207. func (m *WxMutation) SetGroupBlockList(s []string) {
  42208. m.group_block_list = &s
  42209. m.appendgroup_block_list = nil
  42210. }
  42211. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  42212. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  42213. v := m.group_block_list
  42214. if v == nil {
  42215. return
  42216. }
  42217. return *v, true
  42218. }
  42219. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  42220. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42222. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  42223. if !m.op.Is(OpUpdateOne) {
  42224. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  42225. }
  42226. if m.id == nil || m.oldValue == nil {
  42227. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  42228. }
  42229. oldValue, err := m.oldValue(ctx)
  42230. if err != nil {
  42231. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  42232. }
  42233. return oldValue.GroupBlockList, nil
  42234. }
  42235. // AppendGroupBlockList adds s to the "group_block_list" field.
  42236. func (m *WxMutation) AppendGroupBlockList(s []string) {
  42237. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  42238. }
  42239. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  42240. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  42241. if len(m.appendgroup_block_list) == 0 {
  42242. return nil, false
  42243. }
  42244. return m.appendgroup_block_list, true
  42245. }
  42246. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  42247. func (m *WxMutation) ResetGroupBlockList() {
  42248. m.group_block_list = nil
  42249. m.appendgroup_block_list = nil
  42250. }
  42251. // SetCtype sets the "ctype" field.
  42252. func (m *WxMutation) SetCtype(u uint64) {
  42253. m.ctype = &u
  42254. m.addctype = nil
  42255. }
  42256. // Ctype returns the value of the "ctype" field in the mutation.
  42257. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  42258. v := m.ctype
  42259. if v == nil {
  42260. return
  42261. }
  42262. return *v, true
  42263. }
  42264. // OldCtype returns the old "ctype" field's value of the Wx entity.
  42265. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42267. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  42268. if !m.op.Is(OpUpdateOne) {
  42269. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  42270. }
  42271. if m.id == nil || m.oldValue == nil {
  42272. return v, errors.New("OldCtype requires an ID field in the mutation")
  42273. }
  42274. oldValue, err := m.oldValue(ctx)
  42275. if err != nil {
  42276. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  42277. }
  42278. return oldValue.Ctype, nil
  42279. }
  42280. // AddCtype adds u to the "ctype" field.
  42281. func (m *WxMutation) AddCtype(u int64) {
  42282. if m.addctype != nil {
  42283. *m.addctype += u
  42284. } else {
  42285. m.addctype = &u
  42286. }
  42287. }
  42288. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  42289. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  42290. v := m.addctype
  42291. if v == nil {
  42292. return
  42293. }
  42294. return *v, true
  42295. }
  42296. // ClearCtype clears the value of the "ctype" field.
  42297. func (m *WxMutation) ClearCtype() {
  42298. m.ctype = nil
  42299. m.addctype = nil
  42300. m.clearedFields[wx.FieldCtype] = struct{}{}
  42301. }
  42302. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  42303. func (m *WxMutation) CtypeCleared() bool {
  42304. _, ok := m.clearedFields[wx.FieldCtype]
  42305. return ok
  42306. }
  42307. // ResetCtype resets all changes to the "ctype" field.
  42308. func (m *WxMutation) ResetCtype() {
  42309. m.ctype = nil
  42310. m.addctype = nil
  42311. delete(m.clearedFields, wx.FieldCtype)
  42312. }
  42313. // ClearServer clears the "server" edge to the Server entity.
  42314. func (m *WxMutation) ClearServer() {
  42315. m.clearedserver = true
  42316. m.clearedFields[wx.FieldServerID] = struct{}{}
  42317. }
  42318. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  42319. func (m *WxMutation) ServerCleared() bool {
  42320. return m.ServerIDCleared() || m.clearedserver
  42321. }
  42322. // ServerIDs returns the "server" edge IDs in the mutation.
  42323. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42324. // ServerID instead. It exists only for internal usage by the builders.
  42325. func (m *WxMutation) ServerIDs() (ids []uint64) {
  42326. if id := m.server; id != nil {
  42327. ids = append(ids, *id)
  42328. }
  42329. return
  42330. }
  42331. // ResetServer resets all changes to the "server" edge.
  42332. func (m *WxMutation) ResetServer() {
  42333. m.server = nil
  42334. m.clearedserver = false
  42335. }
  42336. // ClearAgent clears the "agent" edge to the Agent entity.
  42337. func (m *WxMutation) ClearAgent() {
  42338. m.clearedagent = true
  42339. m.clearedFields[wx.FieldAgentID] = struct{}{}
  42340. }
  42341. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  42342. func (m *WxMutation) AgentCleared() bool {
  42343. return m.clearedagent
  42344. }
  42345. // AgentIDs returns the "agent" edge IDs in the mutation.
  42346. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42347. // AgentID instead. It exists only for internal usage by the builders.
  42348. func (m *WxMutation) AgentIDs() (ids []uint64) {
  42349. if id := m.agent; id != nil {
  42350. ids = append(ids, *id)
  42351. }
  42352. return
  42353. }
  42354. // ResetAgent resets all changes to the "agent" edge.
  42355. func (m *WxMutation) ResetAgent() {
  42356. m.agent = nil
  42357. m.clearedagent = false
  42358. }
  42359. // Where appends a list predicates to the WxMutation builder.
  42360. func (m *WxMutation) Where(ps ...predicate.Wx) {
  42361. m.predicates = append(m.predicates, ps...)
  42362. }
  42363. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  42364. // users can use type-assertion to append predicates that do not depend on any generated package.
  42365. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  42366. p := make([]predicate.Wx, len(ps))
  42367. for i := range ps {
  42368. p[i] = ps[i]
  42369. }
  42370. m.Where(p...)
  42371. }
  42372. // Op returns the operation name.
  42373. func (m *WxMutation) Op() Op {
  42374. return m.op
  42375. }
  42376. // SetOp allows setting the mutation operation.
  42377. func (m *WxMutation) SetOp(op Op) {
  42378. m.op = op
  42379. }
  42380. // Type returns the node type of this mutation (Wx).
  42381. func (m *WxMutation) Type() string {
  42382. return m.typ
  42383. }
  42384. // Fields returns all fields that were changed during this mutation. Note that in
  42385. // order to get all numeric fields that were incremented/decremented, call
  42386. // AddedFields().
  42387. func (m *WxMutation) Fields() []string {
  42388. fields := make([]string, 0, 22)
  42389. if m.created_at != nil {
  42390. fields = append(fields, wx.FieldCreatedAt)
  42391. }
  42392. if m.updated_at != nil {
  42393. fields = append(fields, wx.FieldUpdatedAt)
  42394. }
  42395. if m.status != nil {
  42396. fields = append(fields, wx.FieldStatus)
  42397. }
  42398. if m.deleted_at != nil {
  42399. fields = append(fields, wx.FieldDeletedAt)
  42400. }
  42401. if m.server != nil {
  42402. fields = append(fields, wx.FieldServerID)
  42403. }
  42404. if m.port != nil {
  42405. fields = append(fields, wx.FieldPort)
  42406. }
  42407. if m.process_id != nil {
  42408. fields = append(fields, wx.FieldProcessID)
  42409. }
  42410. if m.callback != nil {
  42411. fields = append(fields, wx.FieldCallback)
  42412. }
  42413. if m.wxid != nil {
  42414. fields = append(fields, wx.FieldWxid)
  42415. }
  42416. if m.account != nil {
  42417. fields = append(fields, wx.FieldAccount)
  42418. }
  42419. if m.nickname != nil {
  42420. fields = append(fields, wx.FieldNickname)
  42421. }
  42422. if m.tel != nil {
  42423. fields = append(fields, wx.FieldTel)
  42424. }
  42425. if m.head_big != nil {
  42426. fields = append(fields, wx.FieldHeadBig)
  42427. }
  42428. if m.organization_id != nil {
  42429. fields = append(fields, wx.FieldOrganizationID)
  42430. }
  42431. if m.agent != nil {
  42432. fields = append(fields, wx.FieldAgentID)
  42433. }
  42434. if m.api_base != nil {
  42435. fields = append(fields, wx.FieldAPIBase)
  42436. }
  42437. if m.api_key != nil {
  42438. fields = append(fields, wx.FieldAPIKey)
  42439. }
  42440. if m.allow_list != nil {
  42441. fields = append(fields, wx.FieldAllowList)
  42442. }
  42443. if m.group_allow_list != nil {
  42444. fields = append(fields, wx.FieldGroupAllowList)
  42445. }
  42446. if m.block_list != nil {
  42447. fields = append(fields, wx.FieldBlockList)
  42448. }
  42449. if m.group_block_list != nil {
  42450. fields = append(fields, wx.FieldGroupBlockList)
  42451. }
  42452. if m.ctype != nil {
  42453. fields = append(fields, wx.FieldCtype)
  42454. }
  42455. return fields
  42456. }
  42457. // Field returns the value of a field with the given name. The second boolean
  42458. // return value indicates that this field was not set, or was not defined in the
  42459. // schema.
  42460. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  42461. switch name {
  42462. case wx.FieldCreatedAt:
  42463. return m.CreatedAt()
  42464. case wx.FieldUpdatedAt:
  42465. return m.UpdatedAt()
  42466. case wx.FieldStatus:
  42467. return m.Status()
  42468. case wx.FieldDeletedAt:
  42469. return m.DeletedAt()
  42470. case wx.FieldServerID:
  42471. return m.ServerID()
  42472. case wx.FieldPort:
  42473. return m.Port()
  42474. case wx.FieldProcessID:
  42475. return m.ProcessID()
  42476. case wx.FieldCallback:
  42477. return m.Callback()
  42478. case wx.FieldWxid:
  42479. return m.Wxid()
  42480. case wx.FieldAccount:
  42481. return m.Account()
  42482. case wx.FieldNickname:
  42483. return m.Nickname()
  42484. case wx.FieldTel:
  42485. return m.Tel()
  42486. case wx.FieldHeadBig:
  42487. return m.HeadBig()
  42488. case wx.FieldOrganizationID:
  42489. return m.OrganizationID()
  42490. case wx.FieldAgentID:
  42491. return m.AgentID()
  42492. case wx.FieldAPIBase:
  42493. return m.APIBase()
  42494. case wx.FieldAPIKey:
  42495. return m.APIKey()
  42496. case wx.FieldAllowList:
  42497. return m.AllowList()
  42498. case wx.FieldGroupAllowList:
  42499. return m.GroupAllowList()
  42500. case wx.FieldBlockList:
  42501. return m.BlockList()
  42502. case wx.FieldGroupBlockList:
  42503. return m.GroupBlockList()
  42504. case wx.FieldCtype:
  42505. return m.Ctype()
  42506. }
  42507. return nil, false
  42508. }
  42509. // OldField returns the old value of the field from the database. An error is
  42510. // returned if the mutation operation is not UpdateOne, or the query to the
  42511. // database failed.
  42512. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42513. switch name {
  42514. case wx.FieldCreatedAt:
  42515. return m.OldCreatedAt(ctx)
  42516. case wx.FieldUpdatedAt:
  42517. return m.OldUpdatedAt(ctx)
  42518. case wx.FieldStatus:
  42519. return m.OldStatus(ctx)
  42520. case wx.FieldDeletedAt:
  42521. return m.OldDeletedAt(ctx)
  42522. case wx.FieldServerID:
  42523. return m.OldServerID(ctx)
  42524. case wx.FieldPort:
  42525. return m.OldPort(ctx)
  42526. case wx.FieldProcessID:
  42527. return m.OldProcessID(ctx)
  42528. case wx.FieldCallback:
  42529. return m.OldCallback(ctx)
  42530. case wx.FieldWxid:
  42531. return m.OldWxid(ctx)
  42532. case wx.FieldAccount:
  42533. return m.OldAccount(ctx)
  42534. case wx.FieldNickname:
  42535. return m.OldNickname(ctx)
  42536. case wx.FieldTel:
  42537. return m.OldTel(ctx)
  42538. case wx.FieldHeadBig:
  42539. return m.OldHeadBig(ctx)
  42540. case wx.FieldOrganizationID:
  42541. return m.OldOrganizationID(ctx)
  42542. case wx.FieldAgentID:
  42543. return m.OldAgentID(ctx)
  42544. case wx.FieldAPIBase:
  42545. return m.OldAPIBase(ctx)
  42546. case wx.FieldAPIKey:
  42547. return m.OldAPIKey(ctx)
  42548. case wx.FieldAllowList:
  42549. return m.OldAllowList(ctx)
  42550. case wx.FieldGroupAllowList:
  42551. return m.OldGroupAllowList(ctx)
  42552. case wx.FieldBlockList:
  42553. return m.OldBlockList(ctx)
  42554. case wx.FieldGroupBlockList:
  42555. return m.OldGroupBlockList(ctx)
  42556. case wx.FieldCtype:
  42557. return m.OldCtype(ctx)
  42558. }
  42559. return nil, fmt.Errorf("unknown Wx field %s", name)
  42560. }
  42561. // SetField sets the value of a field with the given name. It returns an error if
  42562. // the field is not defined in the schema, or if the type mismatched the field
  42563. // type.
  42564. func (m *WxMutation) SetField(name string, value ent.Value) error {
  42565. switch name {
  42566. case wx.FieldCreatedAt:
  42567. v, ok := value.(time.Time)
  42568. if !ok {
  42569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42570. }
  42571. m.SetCreatedAt(v)
  42572. return nil
  42573. case wx.FieldUpdatedAt:
  42574. v, ok := value.(time.Time)
  42575. if !ok {
  42576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42577. }
  42578. m.SetUpdatedAt(v)
  42579. return nil
  42580. case wx.FieldStatus:
  42581. v, ok := value.(uint8)
  42582. if !ok {
  42583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42584. }
  42585. m.SetStatus(v)
  42586. return nil
  42587. case wx.FieldDeletedAt:
  42588. v, ok := value.(time.Time)
  42589. if !ok {
  42590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42591. }
  42592. m.SetDeletedAt(v)
  42593. return nil
  42594. case wx.FieldServerID:
  42595. v, ok := value.(uint64)
  42596. if !ok {
  42597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42598. }
  42599. m.SetServerID(v)
  42600. return nil
  42601. case wx.FieldPort:
  42602. v, ok := value.(string)
  42603. if !ok {
  42604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42605. }
  42606. m.SetPort(v)
  42607. return nil
  42608. case wx.FieldProcessID:
  42609. v, ok := value.(string)
  42610. if !ok {
  42611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42612. }
  42613. m.SetProcessID(v)
  42614. return nil
  42615. case wx.FieldCallback:
  42616. v, ok := value.(string)
  42617. if !ok {
  42618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42619. }
  42620. m.SetCallback(v)
  42621. return nil
  42622. case wx.FieldWxid:
  42623. v, ok := value.(string)
  42624. if !ok {
  42625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42626. }
  42627. m.SetWxid(v)
  42628. return nil
  42629. case wx.FieldAccount:
  42630. v, ok := value.(string)
  42631. if !ok {
  42632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42633. }
  42634. m.SetAccount(v)
  42635. return nil
  42636. case wx.FieldNickname:
  42637. v, ok := value.(string)
  42638. if !ok {
  42639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42640. }
  42641. m.SetNickname(v)
  42642. return nil
  42643. case wx.FieldTel:
  42644. v, ok := value.(string)
  42645. if !ok {
  42646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42647. }
  42648. m.SetTel(v)
  42649. return nil
  42650. case wx.FieldHeadBig:
  42651. v, ok := value.(string)
  42652. if !ok {
  42653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42654. }
  42655. m.SetHeadBig(v)
  42656. return nil
  42657. case wx.FieldOrganizationID:
  42658. v, ok := value.(uint64)
  42659. if !ok {
  42660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42661. }
  42662. m.SetOrganizationID(v)
  42663. return nil
  42664. case wx.FieldAgentID:
  42665. v, ok := value.(uint64)
  42666. if !ok {
  42667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42668. }
  42669. m.SetAgentID(v)
  42670. return nil
  42671. case wx.FieldAPIBase:
  42672. v, ok := value.(string)
  42673. if !ok {
  42674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42675. }
  42676. m.SetAPIBase(v)
  42677. return nil
  42678. case wx.FieldAPIKey:
  42679. v, ok := value.(string)
  42680. if !ok {
  42681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42682. }
  42683. m.SetAPIKey(v)
  42684. return nil
  42685. case wx.FieldAllowList:
  42686. v, ok := value.([]string)
  42687. if !ok {
  42688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42689. }
  42690. m.SetAllowList(v)
  42691. return nil
  42692. case wx.FieldGroupAllowList:
  42693. v, ok := value.([]string)
  42694. if !ok {
  42695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42696. }
  42697. m.SetGroupAllowList(v)
  42698. return nil
  42699. case wx.FieldBlockList:
  42700. v, ok := value.([]string)
  42701. if !ok {
  42702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42703. }
  42704. m.SetBlockList(v)
  42705. return nil
  42706. case wx.FieldGroupBlockList:
  42707. v, ok := value.([]string)
  42708. if !ok {
  42709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42710. }
  42711. m.SetGroupBlockList(v)
  42712. return nil
  42713. case wx.FieldCtype:
  42714. v, ok := value.(uint64)
  42715. if !ok {
  42716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42717. }
  42718. m.SetCtype(v)
  42719. return nil
  42720. }
  42721. return fmt.Errorf("unknown Wx field %s", name)
  42722. }
  42723. // AddedFields returns all numeric fields that were incremented/decremented during
  42724. // this mutation.
  42725. func (m *WxMutation) AddedFields() []string {
  42726. var fields []string
  42727. if m.addstatus != nil {
  42728. fields = append(fields, wx.FieldStatus)
  42729. }
  42730. if m.addorganization_id != nil {
  42731. fields = append(fields, wx.FieldOrganizationID)
  42732. }
  42733. if m.addctype != nil {
  42734. fields = append(fields, wx.FieldCtype)
  42735. }
  42736. return fields
  42737. }
  42738. // AddedField returns the numeric value that was incremented/decremented on a field
  42739. // with the given name. The second boolean return value indicates that this field
  42740. // was not set, or was not defined in the schema.
  42741. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  42742. switch name {
  42743. case wx.FieldStatus:
  42744. return m.AddedStatus()
  42745. case wx.FieldOrganizationID:
  42746. return m.AddedOrganizationID()
  42747. case wx.FieldCtype:
  42748. return m.AddedCtype()
  42749. }
  42750. return nil, false
  42751. }
  42752. // AddField adds the value to the field with the given name. It returns an error if
  42753. // the field is not defined in the schema, or if the type mismatched the field
  42754. // type.
  42755. func (m *WxMutation) AddField(name string, value ent.Value) error {
  42756. switch name {
  42757. case wx.FieldStatus:
  42758. v, ok := value.(int8)
  42759. if !ok {
  42760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42761. }
  42762. m.AddStatus(v)
  42763. return nil
  42764. case wx.FieldOrganizationID:
  42765. v, ok := value.(int64)
  42766. if !ok {
  42767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42768. }
  42769. m.AddOrganizationID(v)
  42770. return nil
  42771. case wx.FieldCtype:
  42772. v, ok := value.(int64)
  42773. if !ok {
  42774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42775. }
  42776. m.AddCtype(v)
  42777. return nil
  42778. }
  42779. return fmt.Errorf("unknown Wx numeric field %s", name)
  42780. }
  42781. // ClearedFields returns all nullable fields that were cleared during this
  42782. // mutation.
  42783. func (m *WxMutation) ClearedFields() []string {
  42784. var fields []string
  42785. if m.FieldCleared(wx.FieldStatus) {
  42786. fields = append(fields, wx.FieldStatus)
  42787. }
  42788. if m.FieldCleared(wx.FieldDeletedAt) {
  42789. fields = append(fields, wx.FieldDeletedAt)
  42790. }
  42791. if m.FieldCleared(wx.FieldServerID) {
  42792. fields = append(fields, wx.FieldServerID)
  42793. }
  42794. if m.FieldCleared(wx.FieldOrganizationID) {
  42795. fields = append(fields, wx.FieldOrganizationID)
  42796. }
  42797. if m.FieldCleared(wx.FieldAPIBase) {
  42798. fields = append(fields, wx.FieldAPIBase)
  42799. }
  42800. if m.FieldCleared(wx.FieldAPIKey) {
  42801. fields = append(fields, wx.FieldAPIKey)
  42802. }
  42803. if m.FieldCleared(wx.FieldCtype) {
  42804. fields = append(fields, wx.FieldCtype)
  42805. }
  42806. return fields
  42807. }
  42808. // FieldCleared returns a boolean indicating if a field with the given name was
  42809. // cleared in this mutation.
  42810. func (m *WxMutation) FieldCleared(name string) bool {
  42811. _, ok := m.clearedFields[name]
  42812. return ok
  42813. }
  42814. // ClearField clears the value of the field with the given name. It returns an
  42815. // error if the field is not defined in the schema.
  42816. func (m *WxMutation) ClearField(name string) error {
  42817. switch name {
  42818. case wx.FieldStatus:
  42819. m.ClearStatus()
  42820. return nil
  42821. case wx.FieldDeletedAt:
  42822. m.ClearDeletedAt()
  42823. return nil
  42824. case wx.FieldServerID:
  42825. m.ClearServerID()
  42826. return nil
  42827. case wx.FieldOrganizationID:
  42828. m.ClearOrganizationID()
  42829. return nil
  42830. case wx.FieldAPIBase:
  42831. m.ClearAPIBase()
  42832. return nil
  42833. case wx.FieldAPIKey:
  42834. m.ClearAPIKey()
  42835. return nil
  42836. case wx.FieldCtype:
  42837. m.ClearCtype()
  42838. return nil
  42839. }
  42840. return fmt.Errorf("unknown Wx nullable field %s", name)
  42841. }
  42842. // ResetField resets all changes in the mutation for the field with the given name.
  42843. // It returns an error if the field is not defined in the schema.
  42844. func (m *WxMutation) ResetField(name string) error {
  42845. switch name {
  42846. case wx.FieldCreatedAt:
  42847. m.ResetCreatedAt()
  42848. return nil
  42849. case wx.FieldUpdatedAt:
  42850. m.ResetUpdatedAt()
  42851. return nil
  42852. case wx.FieldStatus:
  42853. m.ResetStatus()
  42854. return nil
  42855. case wx.FieldDeletedAt:
  42856. m.ResetDeletedAt()
  42857. return nil
  42858. case wx.FieldServerID:
  42859. m.ResetServerID()
  42860. return nil
  42861. case wx.FieldPort:
  42862. m.ResetPort()
  42863. return nil
  42864. case wx.FieldProcessID:
  42865. m.ResetProcessID()
  42866. return nil
  42867. case wx.FieldCallback:
  42868. m.ResetCallback()
  42869. return nil
  42870. case wx.FieldWxid:
  42871. m.ResetWxid()
  42872. return nil
  42873. case wx.FieldAccount:
  42874. m.ResetAccount()
  42875. return nil
  42876. case wx.FieldNickname:
  42877. m.ResetNickname()
  42878. return nil
  42879. case wx.FieldTel:
  42880. m.ResetTel()
  42881. return nil
  42882. case wx.FieldHeadBig:
  42883. m.ResetHeadBig()
  42884. return nil
  42885. case wx.FieldOrganizationID:
  42886. m.ResetOrganizationID()
  42887. return nil
  42888. case wx.FieldAgentID:
  42889. m.ResetAgentID()
  42890. return nil
  42891. case wx.FieldAPIBase:
  42892. m.ResetAPIBase()
  42893. return nil
  42894. case wx.FieldAPIKey:
  42895. m.ResetAPIKey()
  42896. return nil
  42897. case wx.FieldAllowList:
  42898. m.ResetAllowList()
  42899. return nil
  42900. case wx.FieldGroupAllowList:
  42901. m.ResetGroupAllowList()
  42902. return nil
  42903. case wx.FieldBlockList:
  42904. m.ResetBlockList()
  42905. return nil
  42906. case wx.FieldGroupBlockList:
  42907. m.ResetGroupBlockList()
  42908. return nil
  42909. case wx.FieldCtype:
  42910. m.ResetCtype()
  42911. return nil
  42912. }
  42913. return fmt.Errorf("unknown Wx field %s", name)
  42914. }
  42915. // AddedEdges returns all edge names that were set/added in this mutation.
  42916. func (m *WxMutation) AddedEdges() []string {
  42917. edges := make([]string, 0, 2)
  42918. if m.server != nil {
  42919. edges = append(edges, wx.EdgeServer)
  42920. }
  42921. if m.agent != nil {
  42922. edges = append(edges, wx.EdgeAgent)
  42923. }
  42924. return edges
  42925. }
  42926. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42927. // name in this mutation.
  42928. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  42929. switch name {
  42930. case wx.EdgeServer:
  42931. if id := m.server; id != nil {
  42932. return []ent.Value{*id}
  42933. }
  42934. case wx.EdgeAgent:
  42935. if id := m.agent; id != nil {
  42936. return []ent.Value{*id}
  42937. }
  42938. }
  42939. return nil
  42940. }
  42941. // RemovedEdges returns all edge names that were removed in this mutation.
  42942. func (m *WxMutation) RemovedEdges() []string {
  42943. edges := make([]string, 0, 2)
  42944. return edges
  42945. }
  42946. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42947. // the given name in this mutation.
  42948. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  42949. return nil
  42950. }
  42951. // ClearedEdges returns all edge names that were cleared in this mutation.
  42952. func (m *WxMutation) ClearedEdges() []string {
  42953. edges := make([]string, 0, 2)
  42954. if m.clearedserver {
  42955. edges = append(edges, wx.EdgeServer)
  42956. }
  42957. if m.clearedagent {
  42958. edges = append(edges, wx.EdgeAgent)
  42959. }
  42960. return edges
  42961. }
  42962. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42963. // was cleared in this mutation.
  42964. func (m *WxMutation) EdgeCleared(name string) bool {
  42965. switch name {
  42966. case wx.EdgeServer:
  42967. return m.clearedserver
  42968. case wx.EdgeAgent:
  42969. return m.clearedagent
  42970. }
  42971. return false
  42972. }
  42973. // ClearEdge clears the value of the edge with the given name. It returns an error
  42974. // if that edge is not defined in the schema.
  42975. func (m *WxMutation) ClearEdge(name string) error {
  42976. switch name {
  42977. case wx.EdgeServer:
  42978. m.ClearServer()
  42979. return nil
  42980. case wx.EdgeAgent:
  42981. m.ClearAgent()
  42982. return nil
  42983. }
  42984. return fmt.Errorf("unknown Wx unique edge %s", name)
  42985. }
  42986. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42987. // It returns an error if the edge is not defined in the schema.
  42988. func (m *WxMutation) ResetEdge(name string) error {
  42989. switch name {
  42990. case wx.EdgeServer:
  42991. m.ResetServer()
  42992. return nil
  42993. case wx.EdgeAgent:
  42994. m.ResetAgent()
  42995. return nil
  42996. }
  42997. return fmt.Errorf("unknown Wx edge %s", name)
  42998. }
  42999. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  43000. type WxCardMutation struct {
  43001. config
  43002. op Op
  43003. typ string
  43004. id *uint64
  43005. created_at *time.Time
  43006. updated_at *time.Time
  43007. deleted_at *time.Time
  43008. user_id *uint64
  43009. adduser_id *int64
  43010. wx_user_id *uint64
  43011. addwx_user_id *int64
  43012. avatar *string
  43013. logo *string
  43014. name *string
  43015. company *string
  43016. address *string
  43017. phone *string
  43018. official_account *string
  43019. wechat_account *string
  43020. email *string
  43021. api_base *string
  43022. api_key *string
  43023. ai_info *string
  43024. intro *string
  43025. clearedFields map[string]struct{}
  43026. done bool
  43027. oldValue func(context.Context) (*WxCard, error)
  43028. predicates []predicate.WxCard
  43029. }
  43030. var _ ent.Mutation = (*WxCardMutation)(nil)
  43031. // wxcardOption allows management of the mutation configuration using functional options.
  43032. type wxcardOption func(*WxCardMutation)
  43033. // newWxCardMutation creates new mutation for the WxCard entity.
  43034. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  43035. m := &WxCardMutation{
  43036. config: c,
  43037. op: op,
  43038. typ: TypeWxCard,
  43039. clearedFields: make(map[string]struct{}),
  43040. }
  43041. for _, opt := range opts {
  43042. opt(m)
  43043. }
  43044. return m
  43045. }
  43046. // withWxCardID sets the ID field of the mutation.
  43047. func withWxCardID(id uint64) wxcardOption {
  43048. return func(m *WxCardMutation) {
  43049. var (
  43050. err error
  43051. once sync.Once
  43052. value *WxCard
  43053. )
  43054. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  43055. once.Do(func() {
  43056. if m.done {
  43057. err = errors.New("querying old values post mutation is not allowed")
  43058. } else {
  43059. value, err = m.Client().WxCard.Get(ctx, id)
  43060. }
  43061. })
  43062. return value, err
  43063. }
  43064. m.id = &id
  43065. }
  43066. }
  43067. // withWxCard sets the old WxCard of the mutation.
  43068. func withWxCard(node *WxCard) wxcardOption {
  43069. return func(m *WxCardMutation) {
  43070. m.oldValue = func(context.Context) (*WxCard, error) {
  43071. return node, nil
  43072. }
  43073. m.id = &node.ID
  43074. }
  43075. }
  43076. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43077. // executed in a transaction (ent.Tx), a transactional client is returned.
  43078. func (m WxCardMutation) Client() *Client {
  43079. client := &Client{config: m.config}
  43080. client.init()
  43081. return client
  43082. }
  43083. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43084. // it returns an error otherwise.
  43085. func (m WxCardMutation) Tx() (*Tx, error) {
  43086. if _, ok := m.driver.(*txDriver); !ok {
  43087. return nil, errors.New("ent: mutation is not running in a transaction")
  43088. }
  43089. tx := &Tx{config: m.config}
  43090. tx.init()
  43091. return tx, nil
  43092. }
  43093. // SetID sets the value of the id field. Note that this
  43094. // operation is only accepted on creation of WxCard entities.
  43095. func (m *WxCardMutation) SetID(id uint64) {
  43096. m.id = &id
  43097. }
  43098. // ID returns the ID value in the mutation. Note that the ID is only available
  43099. // if it was provided to the builder or after it was returned from the database.
  43100. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  43101. if m.id == nil {
  43102. return
  43103. }
  43104. return *m.id, true
  43105. }
  43106. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43107. // That means, if the mutation is applied within a transaction with an isolation level such
  43108. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43109. // or updated by the mutation.
  43110. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  43111. switch {
  43112. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43113. id, exists := m.ID()
  43114. if exists {
  43115. return []uint64{id}, nil
  43116. }
  43117. fallthrough
  43118. case m.op.Is(OpUpdate | OpDelete):
  43119. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  43120. default:
  43121. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43122. }
  43123. }
  43124. // SetCreatedAt sets the "created_at" field.
  43125. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  43126. m.created_at = &t
  43127. }
  43128. // CreatedAt returns the value of the "created_at" field in the mutation.
  43129. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  43130. v := m.created_at
  43131. if v == nil {
  43132. return
  43133. }
  43134. return *v, true
  43135. }
  43136. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  43137. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43139. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43140. if !m.op.Is(OpUpdateOne) {
  43141. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43142. }
  43143. if m.id == nil || m.oldValue == nil {
  43144. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43145. }
  43146. oldValue, err := m.oldValue(ctx)
  43147. if err != nil {
  43148. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43149. }
  43150. return oldValue.CreatedAt, nil
  43151. }
  43152. // ResetCreatedAt resets all changes to the "created_at" field.
  43153. func (m *WxCardMutation) ResetCreatedAt() {
  43154. m.created_at = nil
  43155. }
  43156. // SetUpdatedAt sets the "updated_at" field.
  43157. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  43158. m.updated_at = &t
  43159. }
  43160. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43161. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  43162. v := m.updated_at
  43163. if v == nil {
  43164. return
  43165. }
  43166. return *v, true
  43167. }
  43168. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  43169. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43171. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43172. if !m.op.Is(OpUpdateOne) {
  43173. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43174. }
  43175. if m.id == nil || m.oldValue == nil {
  43176. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43177. }
  43178. oldValue, err := m.oldValue(ctx)
  43179. if err != nil {
  43180. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43181. }
  43182. return oldValue.UpdatedAt, nil
  43183. }
  43184. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43185. func (m *WxCardMutation) ResetUpdatedAt() {
  43186. m.updated_at = nil
  43187. }
  43188. // SetDeletedAt sets the "deleted_at" field.
  43189. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  43190. m.deleted_at = &t
  43191. }
  43192. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43193. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  43194. v := m.deleted_at
  43195. if v == nil {
  43196. return
  43197. }
  43198. return *v, true
  43199. }
  43200. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  43201. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43203. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43204. if !m.op.Is(OpUpdateOne) {
  43205. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43206. }
  43207. if m.id == nil || m.oldValue == nil {
  43208. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43209. }
  43210. oldValue, err := m.oldValue(ctx)
  43211. if err != nil {
  43212. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43213. }
  43214. return oldValue.DeletedAt, nil
  43215. }
  43216. // ClearDeletedAt clears the value of the "deleted_at" field.
  43217. func (m *WxCardMutation) ClearDeletedAt() {
  43218. m.deleted_at = nil
  43219. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  43220. }
  43221. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43222. func (m *WxCardMutation) DeletedAtCleared() bool {
  43223. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  43224. return ok
  43225. }
  43226. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43227. func (m *WxCardMutation) ResetDeletedAt() {
  43228. m.deleted_at = nil
  43229. delete(m.clearedFields, wxcard.FieldDeletedAt)
  43230. }
  43231. // SetUserID sets the "user_id" field.
  43232. func (m *WxCardMutation) SetUserID(u uint64) {
  43233. m.user_id = &u
  43234. m.adduser_id = nil
  43235. }
  43236. // UserID returns the value of the "user_id" field in the mutation.
  43237. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  43238. v := m.user_id
  43239. if v == nil {
  43240. return
  43241. }
  43242. return *v, true
  43243. }
  43244. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  43245. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43247. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  43248. if !m.op.Is(OpUpdateOne) {
  43249. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  43250. }
  43251. if m.id == nil || m.oldValue == nil {
  43252. return v, errors.New("OldUserID requires an ID field in the mutation")
  43253. }
  43254. oldValue, err := m.oldValue(ctx)
  43255. if err != nil {
  43256. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  43257. }
  43258. return oldValue.UserID, nil
  43259. }
  43260. // AddUserID adds u to the "user_id" field.
  43261. func (m *WxCardMutation) AddUserID(u int64) {
  43262. if m.adduser_id != nil {
  43263. *m.adduser_id += u
  43264. } else {
  43265. m.adduser_id = &u
  43266. }
  43267. }
  43268. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  43269. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  43270. v := m.adduser_id
  43271. if v == nil {
  43272. return
  43273. }
  43274. return *v, true
  43275. }
  43276. // ClearUserID clears the value of the "user_id" field.
  43277. func (m *WxCardMutation) ClearUserID() {
  43278. m.user_id = nil
  43279. m.adduser_id = nil
  43280. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  43281. }
  43282. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  43283. func (m *WxCardMutation) UserIDCleared() bool {
  43284. _, ok := m.clearedFields[wxcard.FieldUserID]
  43285. return ok
  43286. }
  43287. // ResetUserID resets all changes to the "user_id" field.
  43288. func (m *WxCardMutation) ResetUserID() {
  43289. m.user_id = nil
  43290. m.adduser_id = nil
  43291. delete(m.clearedFields, wxcard.FieldUserID)
  43292. }
  43293. // SetWxUserID sets the "wx_user_id" field.
  43294. func (m *WxCardMutation) SetWxUserID(u uint64) {
  43295. m.wx_user_id = &u
  43296. m.addwx_user_id = nil
  43297. }
  43298. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  43299. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  43300. v := m.wx_user_id
  43301. if v == nil {
  43302. return
  43303. }
  43304. return *v, true
  43305. }
  43306. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  43307. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43309. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  43310. if !m.op.Is(OpUpdateOne) {
  43311. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  43312. }
  43313. if m.id == nil || m.oldValue == nil {
  43314. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  43315. }
  43316. oldValue, err := m.oldValue(ctx)
  43317. if err != nil {
  43318. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  43319. }
  43320. return oldValue.WxUserID, nil
  43321. }
  43322. // AddWxUserID adds u to the "wx_user_id" field.
  43323. func (m *WxCardMutation) AddWxUserID(u int64) {
  43324. if m.addwx_user_id != nil {
  43325. *m.addwx_user_id += u
  43326. } else {
  43327. m.addwx_user_id = &u
  43328. }
  43329. }
  43330. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  43331. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  43332. v := m.addwx_user_id
  43333. if v == nil {
  43334. return
  43335. }
  43336. return *v, true
  43337. }
  43338. // ClearWxUserID clears the value of the "wx_user_id" field.
  43339. func (m *WxCardMutation) ClearWxUserID() {
  43340. m.wx_user_id = nil
  43341. m.addwx_user_id = nil
  43342. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  43343. }
  43344. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  43345. func (m *WxCardMutation) WxUserIDCleared() bool {
  43346. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  43347. return ok
  43348. }
  43349. // ResetWxUserID resets all changes to the "wx_user_id" field.
  43350. func (m *WxCardMutation) ResetWxUserID() {
  43351. m.wx_user_id = nil
  43352. m.addwx_user_id = nil
  43353. delete(m.clearedFields, wxcard.FieldWxUserID)
  43354. }
  43355. // SetAvatar sets the "avatar" field.
  43356. func (m *WxCardMutation) SetAvatar(s string) {
  43357. m.avatar = &s
  43358. }
  43359. // Avatar returns the value of the "avatar" field in the mutation.
  43360. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  43361. v := m.avatar
  43362. if v == nil {
  43363. return
  43364. }
  43365. return *v, true
  43366. }
  43367. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  43368. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43370. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43371. if !m.op.Is(OpUpdateOne) {
  43372. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43373. }
  43374. if m.id == nil || m.oldValue == nil {
  43375. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43376. }
  43377. oldValue, err := m.oldValue(ctx)
  43378. if err != nil {
  43379. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43380. }
  43381. return oldValue.Avatar, nil
  43382. }
  43383. // ResetAvatar resets all changes to the "avatar" field.
  43384. func (m *WxCardMutation) ResetAvatar() {
  43385. m.avatar = nil
  43386. }
  43387. // SetLogo sets the "logo" field.
  43388. func (m *WxCardMutation) SetLogo(s string) {
  43389. m.logo = &s
  43390. }
  43391. // Logo returns the value of the "logo" field in the mutation.
  43392. func (m *WxCardMutation) Logo() (r string, exists bool) {
  43393. v := m.logo
  43394. if v == nil {
  43395. return
  43396. }
  43397. return *v, true
  43398. }
  43399. // OldLogo returns the old "logo" field's value of the WxCard entity.
  43400. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43402. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  43403. if !m.op.Is(OpUpdateOne) {
  43404. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  43405. }
  43406. if m.id == nil || m.oldValue == nil {
  43407. return v, errors.New("OldLogo requires an ID field in the mutation")
  43408. }
  43409. oldValue, err := m.oldValue(ctx)
  43410. if err != nil {
  43411. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  43412. }
  43413. return oldValue.Logo, nil
  43414. }
  43415. // ResetLogo resets all changes to the "logo" field.
  43416. func (m *WxCardMutation) ResetLogo() {
  43417. m.logo = nil
  43418. }
  43419. // SetName sets the "name" field.
  43420. func (m *WxCardMutation) SetName(s string) {
  43421. m.name = &s
  43422. }
  43423. // Name returns the value of the "name" field in the mutation.
  43424. func (m *WxCardMutation) Name() (r string, exists bool) {
  43425. v := m.name
  43426. if v == nil {
  43427. return
  43428. }
  43429. return *v, true
  43430. }
  43431. // OldName returns the old "name" field's value of the WxCard entity.
  43432. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43434. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  43435. if !m.op.Is(OpUpdateOne) {
  43436. return v, errors.New("OldName is only allowed on UpdateOne operations")
  43437. }
  43438. if m.id == nil || m.oldValue == nil {
  43439. return v, errors.New("OldName requires an ID field in the mutation")
  43440. }
  43441. oldValue, err := m.oldValue(ctx)
  43442. if err != nil {
  43443. return v, fmt.Errorf("querying old value for OldName: %w", err)
  43444. }
  43445. return oldValue.Name, nil
  43446. }
  43447. // ResetName resets all changes to the "name" field.
  43448. func (m *WxCardMutation) ResetName() {
  43449. m.name = nil
  43450. }
  43451. // SetCompany sets the "company" field.
  43452. func (m *WxCardMutation) SetCompany(s string) {
  43453. m.company = &s
  43454. }
  43455. // Company returns the value of the "company" field in the mutation.
  43456. func (m *WxCardMutation) Company() (r string, exists bool) {
  43457. v := m.company
  43458. if v == nil {
  43459. return
  43460. }
  43461. return *v, true
  43462. }
  43463. // OldCompany returns the old "company" field's value of the WxCard entity.
  43464. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43466. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  43467. if !m.op.Is(OpUpdateOne) {
  43468. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  43469. }
  43470. if m.id == nil || m.oldValue == nil {
  43471. return v, errors.New("OldCompany requires an ID field in the mutation")
  43472. }
  43473. oldValue, err := m.oldValue(ctx)
  43474. if err != nil {
  43475. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  43476. }
  43477. return oldValue.Company, nil
  43478. }
  43479. // ResetCompany resets all changes to the "company" field.
  43480. func (m *WxCardMutation) ResetCompany() {
  43481. m.company = nil
  43482. }
  43483. // SetAddress sets the "address" field.
  43484. func (m *WxCardMutation) SetAddress(s string) {
  43485. m.address = &s
  43486. }
  43487. // Address returns the value of the "address" field in the mutation.
  43488. func (m *WxCardMutation) Address() (r string, exists bool) {
  43489. v := m.address
  43490. if v == nil {
  43491. return
  43492. }
  43493. return *v, true
  43494. }
  43495. // OldAddress returns the old "address" field's value of the WxCard entity.
  43496. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43498. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  43499. if !m.op.Is(OpUpdateOne) {
  43500. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  43501. }
  43502. if m.id == nil || m.oldValue == nil {
  43503. return v, errors.New("OldAddress requires an ID field in the mutation")
  43504. }
  43505. oldValue, err := m.oldValue(ctx)
  43506. if err != nil {
  43507. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  43508. }
  43509. return oldValue.Address, nil
  43510. }
  43511. // ResetAddress resets all changes to the "address" field.
  43512. func (m *WxCardMutation) ResetAddress() {
  43513. m.address = nil
  43514. }
  43515. // SetPhone sets the "phone" field.
  43516. func (m *WxCardMutation) SetPhone(s string) {
  43517. m.phone = &s
  43518. }
  43519. // Phone returns the value of the "phone" field in the mutation.
  43520. func (m *WxCardMutation) Phone() (r string, exists bool) {
  43521. v := m.phone
  43522. if v == nil {
  43523. return
  43524. }
  43525. return *v, true
  43526. }
  43527. // OldPhone returns the old "phone" field's value of the WxCard entity.
  43528. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43530. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  43531. if !m.op.Is(OpUpdateOne) {
  43532. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43533. }
  43534. if m.id == nil || m.oldValue == nil {
  43535. return v, errors.New("OldPhone requires an ID field in the mutation")
  43536. }
  43537. oldValue, err := m.oldValue(ctx)
  43538. if err != nil {
  43539. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43540. }
  43541. return oldValue.Phone, nil
  43542. }
  43543. // ResetPhone resets all changes to the "phone" field.
  43544. func (m *WxCardMutation) ResetPhone() {
  43545. m.phone = nil
  43546. }
  43547. // SetOfficialAccount sets the "official_account" field.
  43548. func (m *WxCardMutation) SetOfficialAccount(s string) {
  43549. m.official_account = &s
  43550. }
  43551. // OfficialAccount returns the value of the "official_account" field in the mutation.
  43552. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  43553. v := m.official_account
  43554. if v == nil {
  43555. return
  43556. }
  43557. return *v, true
  43558. }
  43559. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  43560. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43562. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  43563. if !m.op.Is(OpUpdateOne) {
  43564. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  43565. }
  43566. if m.id == nil || m.oldValue == nil {
  43567. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  43568. }
  43569. oldValue, err := m.oldValue(ctx)
  43570. if err != nil {
  43571. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  43572. }
  43573. return oldValue.OfficialAccount, nil
  43574. }
  43575. // ResetOfficialAccount resets all changes to the "official_account" field.
  43576. func (m *WxCardMutation) ResetOfficialAccount() {
  43577. m.official_account = nil
  43578. }
  43579. // SetWechatAccount sets the "wechat_account" field.
  43580. func (m *WxCardMutation) SetWechatAccount(s string) {
  43581. m.wechat_account = &s
  43582. }
  43583. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  43584. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  43585. v := m.wechat_account
  43586. if v == nil {
  43587. return
  43588. }
  43589. return *v, true
  43590. }
  43591. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  43592. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43594. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  43595. if !m.op.Is(OpUpdateOne) {
  43596. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  43597. }
  43598. if m.id == nil || m.oldValue == nil {
  43599. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  43600. }
  43601. oldValue, err := m.oldValue(ctx)
  43602. if err != nil {
  43603. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  43604. }
  43605. return oldValue.WechatAccount, nil
  43606. }
  43607. // ResetWechatAccount resets all changes to the "wechat_account" field.
  43608. func (m *WxCardMutation) ResetWechatAccount() {
  43609. m.wechat_account = nil
  43610. }
  43611. // SetEmail sets the "email" field.
  43612. func (m *WxCardMutation) SetEmail(s string) {
  43613. m.email = &s
  43614. }
  43615. // Email returns the value of the "email" field in the mutation.
  43616. func (m *WxCardMutation) Email() (r string, exists bool) {
  43617. v := m.email
  43618. if v == nil {
  43619. return
  43620. }
  43621. return *v, true
  43622. }
  43623. // OldEmail returns the old "email" field's value of the WxCard entity.
  43624. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43626. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  43627. if !m.op.Is(OpUpdateOne) {
  43628. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  43629. }
  43630. if m.id == nil || m.oldValue == nil {
  43631. return v, errors.New("OldEmail requires an ID field in the mutation")
  43632. }
  43633. oldValue, err := m.oldValue(ctx)
  43634. if err != nil {
  43635. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  43636. }
  43637. return oldValue.Email, nil
  43638. }
  43639. // ClearEmail clears the value of the "email" field.
  43640. func (m *WxCardMutation) ClearEmail() {
  43641. m.email = nil
  43642. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  43643. }
  43644. // EmailCleared returns if the "email" field was cleared in this mutation.
  43645. func (m *WxCardMutation) EmailCleared() bool {
  43646. _, ok := m.clearedFields[wxcard.FieldEmail]
  43647. return ok
  43648. }
  43649. // ResetEmail resets all changes to the "email" field.
  43650. func (m *WxCardMutation) ResetEmail() {
  43651. m.email = nil
  43652. delete(m.clearedFields, wxcard.FieldEmail)
  43653. }
  43654. // SetAPIBase sets the "api_base" field.
  43655. func (m *WxCardMutation) SetAPIBase(s string) {
  43656. m.api_base = &s
  43657. }
  43658. // APIBase returns the value of the "api_base" field in the mutation.
  43659. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  43660. v := m.api_base
  43661. if v == nil {
  43662. return
  43663. }
  43664. return *v, true
  43665. }
  43666. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  43667. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43669. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  43670. if !m.op.Is(OpUpdateOne) {
  43671. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43672. }
  43673. if m.id == nil || m.oldValue == nil {
  43674. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  43675. }
  43676. oldValue, err := m.oldValue(ctx)
  43677. if err != nil {
  43678. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  43679. }
  43680. return oldValue.APIBase, nil
  43681. }
  43682. // ClearAPIBase clears the value of the "api_base" field.
  43683. func (m *WxCardMutation) ClearAPIBase() {
  43684. m.api_base = nil
  43685. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  43686. }
  43687. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43688. func (m *WxCardMutation) APIBaseCleared() bool {
  43689. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  43690. return ok
  43691. }
  43692. // ResetAPIBase resets all changes to the "api_base" field.
  43693. func (m *WxCardMutation) ResetAPIBase() {
  43694. m.api_base = nil
  43695. delete(m.clearedFields, wxcard.FieldAPIBase)
  43696. }
  43697. // SetAPIKey sets the "api_key" field.
  43698. func (m *WxCardMutation) SetAPIKey(s string) {
  43699. m.api_key = &s
  43700. }
  43701. // APIKey returns the value of the "api_key" field in the mutation.
  43702. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  43703. v := m.api_key
  43704. if v == nil {
  43705. return
  43706. }
  43707. return *v, true
  43708. }
  43709. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  43710. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43712. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43713. if !m.op.Is(OpUpdateOne) {
  43714. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43715. }
  43716. if m.id == nil || m.oldValue == nil {
  43717. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43718. }
  43719. oldValue, err := m.oldValue(ctx)
  43720. if err != nil {
  43721. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43722. }
  43723. return oldValue.APIKey, nil
  43724. }
  43725. // ClearAPIKey clears the value of the "api_key" field.
  43726. func (m *WxCardMutation) ClearAPIKey() {
  43727. m.api_key = nil
  43728. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  43729. }
  43730. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43731. func (m *WxCardMutation) APIKeyCleared() bool {
  43732. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  43733. return ok
  43734. }
  43735. // ResetAPIKey resets all changes to the "api_key" field.
  43736. func (m *WxCardMutation) ResetAPIKey() {
  43737. m.api_key = nil
  43738. delete(m.clearedFields, wxcard.FieldAPIKey)
  43739. }
  43740. // SetAiInfo sets the "ai_info" field.
  43741. func (m *WxCardMutation) SetAiInfo(s string) {
  43742. m.ai_info = &s
  43743. }
  43744. // AiInfo returns the value of the "ai_info" field in the mutation.
  43745. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  43746. v := m.ai_info
  43747. if v == nil {
  43748. return
  43749. }
  43750. return *v, true
  43751. }
  43752. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  43753. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43755. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  43756. if !m.op.Is(OpUpdateOne) {
  43757. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  43758. }
  43759. if m.id == nil || m.oldValue == nil {
  43760. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  43761. }
  43762. oldValue, err := m.oldValue(ctx)
  43763. if err != nil {
  43764. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  43765. }
  43766. return oldValue.AiInfo, nil
  43767. }
  43768. // ClearAiInfo clears the value of the "ai_info" field.
  43769. func (m *WxCardMutation) ClearAiInfo() {
  43770. m.ai_info = nil
  43771. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  43772. }
  43773. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  43774. func (m *WxCardMutation) AiInfoCleared() bool {
  43775. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  43776. return ok
  43777. }
  43778. // ResetAiInfo resets all changes to the "ai_info" field.
  43779. func (m *WxCardMutation) ResetAiInfo() {
  43780. m.ai_info = nil
  43781. delete(m.clearedFields, wxcard.FieldAiInfo)
  43782. }
  43783. // SetIntro sets the "intro" field.
  43784. func (m *WxCardMutation) SetIntro(s string) {
  43785. m.intro = &s
  43786. }
  43787. // Intro returns the value of the "intro" field in the mutation.
  43788. func (m *WxCardMutation) Intro() (r string, exists bool) {
  43789. v := m.intro
  43790. if v == nil {
  43791. return
  43792. }
  43793. return *v, true
  43794. }
  43795. // OldIntro returns the old "intro" field's value of the WxCard entity.
  43796. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43798. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  43799. if !m.op.Is(OpUpdateOne) {
  43800. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  43801. }
  43802. if m.id == nil || m.oldValue == nil {
  43803. return v, errors.New("OldIntro requires an ID field in the mutation")
  43804. }
  43805. oldValue, err := m.oldValue(ctx)
  43806. if err != nil {
  43807. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  43808. }
  43809. return oldValue.Intro, nil
  43810. }
  43811. // ClearIntro clears the value of the "intro" field.
  43812. func (m *WxCardMutation) ClearIntro() {
  43813. m.intro = nil
  43814. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  43815. }
  43816. // IntroCleared returns if the "intro" field was cleared in this mutation.
  43817. func (m *WxCardMutation) IntroCleared() bool {
  43818. _, ok := m.clearedFields[wxcard.FieldIntro]
  43819. return ok
  43820. }
  43821. // ResetIntro resets all changes to the "intro" field.
  43822. func (m *WxCardMutation) ResetIntro() {
  43823. m.intro = nil
  43824. delete(m.clearedFields, wxcard.FieldIntro)
  43825. }
  43826. // Where appends a list predicates to the WxCardMutation builder.
  43827. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  43828. m.predicates = append(m.predicates, ps...)
  43829. }
  43830. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  43831. // users can use type-assertion to append predicates that do not depend on any generated package.
  43832. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  43833. p := make([]predicate.WxCard, len(ps))
  43834. for i := range ps {
  43835. p[i] = ps[i]
  43836. }
  43837. m.Where(p...)
  43838. }
  43839. // Op returns the operation name.
  43840. func (m *WxCardMutation) Op() Op {
  43841. return m.op
  43842. }
  43843. // SetOp allows setting the mutation operation.
  43844. func (m *WxCardMutation) SetOp(op Op) {
  43845. m.op = op
  43846. }
  43847. // Type returns the node type of this mutation (WxCard).
  43848. func (m *WxCardMutation) Type() string {
  43849. return m.typ
  43850. }
  43851. // Fields returns all fields that were changed during this mutation. Note that in
  43852. // order to get all numeric fields that were incremented/decremented, call
  43853. // AddedFields().
  43854. func (m *WxCardMutation) Fields() []string {
  43855. fields := make([]string, 0, 18)
  43856. if m.created_at != nil {
  43857. fields = append(fields, wxcard.FieldCreatedAt)
  43858. }
  43859. if m.updated_at != nil {
  43860. fields = append(fields, wxcard.FieldUpdatedAt)
  43861. }
  43862. if m.deleted_at != nil {
  43863. fields = append(fields, wxcard.FieldDeletedAt)
  43864. }
  43865. if m.user_id != nil {
  43866. fields = append(fields, wxcard.FieldUserID)
  43867. }
  43868. if m.wx_user_id != nil {
  43869. fields = append(fields, wxcard.FieldWxUserID)
  43870. }
  43871. if m.avatar != nil {
  43872. fields = append(fields, wxcard.FieldAvatar)
  43873. }
  43874. if m.logo != nil {
  43875. fields = append(fields, wxcard.FieldLogo)
  43876. }
  43877. if m.name != nil {
  43878. fields = append(fields, wxcard.FieldName)
  43879. }
  43880. if m.company != nil {
  43881. fields = append(fields, wxcard.FieldCompany)
  43882. }
  43883. if m.address != nil {
  43884. fields = append(fields, wxcard.FieldAddress)
  43885. }
  43886. if m.phone != nil {
  43887. fields = append(fields, wxcard.FieldPhone)
  43888. }
  43889. if m.official_account != nil {
  43890. fields = append(fields, wxcard.FieldOfficialAccount)
  43891. }
  43892. if m.wechat_account != nil {
  43893. fields = append(fields, wxcard.FieldWechatAccount)
  43894. }
  43895. if m.email != nil {
  43896. fields = append(fields, wxcard.FieldEmail)
  43897. }
  43898. if m.api_base != nil {
  43899. fields = append(fields, wxcard.FieldAPIBase)
  43900. }
  43901. if m.api_key != nil {
  43902. fields = append(fields, wxcard.FieldAPIKey)
  43903. }
  43904. if m.ai_info != nil {
  43905. fields = append(fields, wxcard.FieldAiInfo)
  43906. }
  43907. if m.intro != nil {
  43908. fields = append(fields, wxcard.FieldIntro)
  43909. }
  43910. return fields
  43911. }
  43912. // Field returns the value of a field with the given name. The second boolean
  43913. // return value indicates that this field was not set, or was not defined in the
  43914. // schema.
  43915. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  43916. switch name {
  43917. case wxcard.FieldCreatedAt:
  43918. return m.CreatedAt()
  43919. case wxcard.FieldUpdatedAt:
  43920. return m.UpdatedAt()
  43921. case wxcard.FieldDeletedAt:
  43922. return m.DeletedAt()
  43923. case wxcard.FieldUserID:
  43924. return m.UserID()
  43925. case wxcard.FieldWxUserID:
  43926. return m.WxUserID()
  43927. case wxcard.FieldAvatar:
  43928. return m.Avatar()
  43929. case wxcard.FieldLogo:
  43930. return m.Logo()
  43931. case wxcard.FieldName:
  43932. return m.Name()
  43933. case wxcard.FieldCompany:
  43934. return m.Company()
  43935. case wxcard.FieldAddress:
  43936. return m.Address()
  43937. case wxcard.FieldPhone:
  43938. return m.Phone()
  43939. case wxcard.FieldOfficialAccount:
  43940. return m.OfficialAccount()
  43941. case wxcard.FieldWechatAccount:
  43942. return m.WechatAccount()
  43943. case wxcard.FieldEmail:
  43944. return m.Email()
  43945. case wxcard.FieldAPIBase:
  43946. return m.APIBase()
  43947. case wxcard.FieldAPIKey:
  43948. return m.APIKey()
  43949. case wxcard.FieldAiInfo:
  43950. return m.AiInfo()
  43951. case wxcard.FieldIntro:
  43952. return m.Intro()
  43953. }
  43954. return nil, false
  43955. }
  43956. // OldField returns the old value of the field from the database. An error is
  43957. // returned if the mutation operation is not UpdateOne, or the query to the
  43958. // database failed.
  43959. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43960. switch name {
  43961. case wxcard.FieldCreatedAt:
  43962. return m.OldCreatedAt(ctx)
  43963. case wxcard.FieldUpdatedAt:
  43964. return m.OldUpdatedAt(ctx)
  43965. case wxcard.FieldDeletedAt:
  43966. return m.OldDeletedAt(ctx)
  43967. case wxcard.FieldUserID:
  43968. return m.OldUserID(ctx)
  43969. case wxcard.FieldWxUserID:
  43970. return m.OldWxUserID(ctx)
  43971. case wxcard.FieldAvatar:
  43972. return m.OldAvatar(ctx)
  43973. case wxcard.FieldLogo:
  43974. return m.OldLogo(ctx)
  43975. case wxcard.FieldName:
  43976. return m.OldName(ctx)
  43977. case wxcard.FieldCompany:
  43978. return m.OldCompany(ctx)
  43979. case wxcard.FieldAddress:
  43980. return m.OldAddress(ctx)
  43981. case wxcard.FieldPhone:
  43982. return m.OldPhone(ctx)
  43983. case wxcard.FieldOfficialAccount:
  43984. return m.OldOfficialAccount(ctx)
  43985. case wxcard.FieldWechatAccount:
  43986. return m.OldWechatAccount(ctx)
  43987. case wxcard.FieldEmail:
  43988. return m.OldEmail(ctx)
  43989. case wxcard.FieldAPIBase:
  43990. return m.OldAPIBase(ctx)
  43991. case wxcard.FieldAPIKey:
  43992. return m.OldAPIKey(ctx)
  43993. case wxcard.FieldAiInfo:
  43994. return m.OldAiInfo(ctx)
  43995. case wxcard.FieldIntro:
  43996. return m.OldIntro(ctx)
  43997. }
  43998. return nil, fmt.Errorf("unknown WxCard field %s", name)
  43999. }
  44000. // SetField sets the value of a field with the given name. It returns an error if
  44001. // the field is not defined in the schema, or if the type mismatched the field
  44002. // type.
  44003. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  44004. switch name {
  44005. case wxcard.FieldCreatedAt:
  44006. v, ok := value.(time.Time)
  44007. if !ok {
  44008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44009. }
  44010. m.SetCreatedAt(v)
  44011. return nil
  44012. case wxcard.FieldUpdatedAt:
  44013. v, ok := value.(time.Time)
  44014. if !ok {
  44015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44016. }
  44017. m.SetUpdatedAt(v)
  44018. return nil
  44019. case wxcard.FieldDeletedAt:
  44020. v, ok := value.(time.Time)
  44021. if !ok {
  44022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44023. }
  44024. m.SetDeletedAt(v)
  44025. return nil
  44026. case wxcard.FieldUserID:
  44027. v, ok := value.(uint64)
  44028. if !ok {
  44029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44030. }
  44031. m.SetUserID(v)
  44032. return nil
  44033. case wxcard.FieldWxUserID:
  44034. v, ok := value.(uint64)
  44035. if !ok {
  44036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44037. }
  44038. m.SetWxUserID(v)
  44039. return nil
  44040. case wxcard.FieldAvatar:
  44041. v, ok := value.(string)
  44042. if !ok {
  44043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44044. }
  44045. m.SetAvatar(v)
  44046. return nil
  44047. case wxcard.FieldLogo:
  44048. v, ok := value.(string)
  44049. if !ok {
  44050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44051. }
  44052. m.SetLogo(v)
  44053. return nil
  44054. case wxcard.FieldName:
  44055. v, ok := value.(string)
  44056. if !ok {
  44057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44058. }
  44059. m.SetName(v)
  44060. return nil
  44061. case wxcard.FieldCompany:
  44062. v, ok := value.(string)
  44063. if !ok {
  44064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44065. }
  44066. m.SetCompany(v)
  44067. return nil
  44068. case wxcard.FieldAddress:
  44069. v, ok := value.(string)
  44070. if !ok {
  44071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44072. }
  44073. m.SetAddress(v)
  44074. return nil
  44075. case wxcard.FieldPhone:
  44076. v, ok := value.(string)
  44077. if !ok {
  44078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44079. }
  44080. m.SetPhone(v)
  44081. return nil
  44082. case wxcard.FieldOfficialAccount:
  44083. v, ok := value.(string)
  44084. if !ok {
  44085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44086. }
  44087. m.SetOfficialAccount(v)
  44088. return nil
  44089. case wxcard.FieldWechatAccount:
  44090. v, ok := value.(string)
  44091. if !ok {
  44092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44093. }
  44094. m.SetWechatAccount(v)
  44095. return nil
  44096. case wxcard.FieldEmail:
  44097. v, ok := value.(string)
  44098. if !ok {
  44099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44100. }
  44101. m.SetEmail(v)
  44102. return nil
  44103. case wxcard.FieldAPIBase:
  44104. v, ok := value.(string)
  44105. if !ok {
  44106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44107. }
  44108. m.SetAPIBase(v)
  44109. return nil
  44110. case wxcard.FieldAPIKey:
  44111. v, ok := value.(string)
  44112. if !ok {
  44113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44114. }
  44115. m.SetAPIKey(v)
  44116. return nil
  44117. case wxcard.FieldAiInfo:
  44118. v, ok := value.(string)
  44119. if !ok {
  44120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44121. }
  44122. m.SetAiInfo(v)
  44123. return nil
  44124. case wxcard.FieldIntro:
  44125. v, ok := value.(string)
  44126. if !ok {
  44127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44128. }
  44129. m.SetIntro(v)
  44130. return nil
  44131. }
  44132. return fmt.Errorf("unknown WxCard field %s", name)
  44133. }
  44134. // AddedFields returns all numeric fields that were incremented/decremented during
  44135. // this mutation.
  44136. func (m *WxCardMutation) AddedFields() []string {
  44137. var fields []string
  44138. if m.adduser_id != nil {
  44139. fields = append(fields, wxcard.FieldUserID)
  44140. }
  44141. if m.addwx_user_id != nil {
  44142. fields = append(fields, wxcard.FieldWxUserID)
  44143. }
  44144. return fields
  44145. }
  44146. // AddedField returns the numeric value that was incremented/decremented on a field
  44147. // with the given name. The second boolean return value indicates that this field
  44148. // was not set, or was not defined in the schema.
  44149. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  44150. switch name {
  44151. case wxcard.FieldUserID:
  44152. return m.AddedUserID()
  44153. case wxcard.FieldWxUserID:
  44154. return m.AddedWxUserID()
  44155. }
  44156. return nil, false
  44157. }
  44158. // AddField adds the value to the field with the given name. It returns an error if
  44159. // the field is not defined in the schema, or if the type mismatched the field
  44160. // type.
  44161. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  44162. switch name {
  44163. case wxcard.FieldUserID:
  44164. v, ok := value.(int64)
  44165. if !ok {
  44166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44167. }
  44168. m.AddUserID(v)
  44169. return nil
  44170. case wxcard.FieldWxUserID:
  44171. v, ok := value.(int64)
  44172. if !ok {
  44173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44174. }
  44175. m.AddWxUserID(v)
  44176. return nil
  44177. }
  44178. return fmt.Errorf("unknown WxCard numeric field %s", name)
  44179. }
  44180. // ClearedFields returns all nullable fields that were cleared during this
  44181. // mutation.
  44182. func (m *WxCardMutation) ClearedFields() []string {
  44183. var fields []string
  44184. if m.FieldCleared(wxcard.FieldDeletedAt) {
  44185. fields = append(fields, wxcard.FieldDeletedAt)
  44186. }
  44187. if m.FieldCleared(wxcard.FieldUserID) {
  44188. fields = append(fields, wxcard.FieldUserID)
  44189. }
  44190. if m.FieldCleared(wxcard.FieldWxUserID) {
  44191. fields = append(fields, wxcard.FieldWxUserID)
  44192. }
  44193. if m.FieldCleared(wxcard.FieldEmail) {
  44194. fields = append(fields, wxcard.FieldEmail)
  44195. }
  44196. if m.FieldCleared(wxcard.FieldAPIBase) {
  44197. fields = append(fields, wxcard.FieldAPIBase)
  44198. }
  44199. if m.FieldCleared(wxcard.FieldAPIKey) {
  44200. fields = append(fields, wxcard.FieldAPIKey)
  44201. }
  44202. if m.FieldCleared(wxcard.FieldAiInfo) {
  44203. fields = append(fields, wxcard.FieldAiInfo)
  44204. }
  44205. if m.FieldCleared(wxcard.FieldIntro) {
  44206. fields = append(fields, wxcard.FieldIntro)
  44207. }
  44208. return fields
  44209. }
  44210. // FieldCleared returns a boolean indicating if a field with the given name was
  44211. // cleared in this mutation.
  44212. func (m *WxCardMutation) FieldCleared(name string) bool {
  44213. _, ok := m.clearedFields[name]
  44214. return ok
  44215. }
  44216. // ClearField clears the value of the field with the given name. It returns an
  44217. // error if the field is not defined in the schema.
  44218. func (m *WxCardMutation) ClearField(name string) error {
  44219. switch name {
  44220. case wxcard.FieldDeletedAt:
  44221. m.ClearDeletedAt()
  44222. return nil
  44223. case wxcard.FieldUserID:
  44224. m.ClearUserID()
  44225. return nil
  44226. case wxcard.FieldWxUserID:
  44227. m.ClearWxUserID()
  44228. return nil
  44229. case wxcard.FieldEmail:
  44230. m.ClearEmail()
  44231. return nil
  44232. case wxcard.FieldAPIBase:
  44233. m.ClearAPIBase()
  44234. return nil
  44235. case wxcard.FieldAPIKey:
  44236. m.ClearAPIKey()
  44237. return nil
  44238. case wxcard.FieldAiInfo:
  44239. m.ClearAiInfo()
  44240. return nil
  44241. case wxcard.FieldIntro:
  44242. m.ClearIntro()
  44243. return nil
  44244. }
  44245. return fmt.Errorf("unknown WxCard nullable field %s", name)
  44246. }
  44247. // ResetField resets all changes in the mutation for the field with the given name.
  44248. // It returns an error if the field is not defined in the schema.
  44249. func (m *WxCardMutation) ResetField(name string) error {
  44250. switch name {
  44251. case wxcard.FieldCreatedAt:
  44252. m.ResetCreatedAt()
  44253. return nil
  44254. case wxcard.FieldUpdatedAt:
  44255. m.ResetUpdatedAt()
  44256. return nil
  44257. case wxcard.FieldDeletedAt:
  44258. m.ResetDeletedAt()
  44259. return nil
  44260. case wxcard.FieldUserID:
  44261. m.ResetUserID()
  44262. return nil
  44263. case wxcard.FieldWxUserID:
  44264. m.ResetWxUserID()
  44265. return nil
  44266. case wxcard.FieldAvatar:
  44267. m.ResetAvatar()
  44268. return nil
  44269. case wxcard.FieldLogo:
  44270. m.ResetLogo()
  44271. return nil
  44272. case wxcard.FieldName:
  44273. m.ResetName()
  44274. return nil
  44275. case wxcard.FieldCompany:
  44276. m.ResetCompany()
  44277. return nil
  44278. case wxcard.FieldAddress:
  44279. m.ResetAddress()
  44280. return nil
  44281. case wxcard.FieldPhone:
  44282. m.ResetPhone()
  44283. return nil
  44284. case wxcard.FieldOfficialAccount:
  44285. m.ResetOfficialAccount()
  44286. return nil
  44287. case wxcard.FieldWechatAccount:
  44288. m.ResetWechatAccount()
  44289. return nil
  44290. case wxcard.FieldEmail:
  44291. m.ResetEmail()
  44292. return nil
  44293. case wxcard.FieldAPIBase:
  44294. m.ResetAPIBase()
  44295. return nil
  44296. case wxcard.FieldAPIKey:
  44297. m.ResetAPIKey()
  44298. return nil
  44299. case wxcard.FieldAiInfo:
  44300. m.ResetAiInfo()
  44301. return nil
  44302. case wxcard.FieldIntro:
  44303. m.ResetIntro()
  44304. return nil
  44305. }
  44306. return fmt.Errorf("unknown WxCard field %s", name)
  44307. }
  44308. // AddedEdges returns all edge names that were set/added in this mutation.
  44309. func (m *WxCardMutation) AddedEdges() []string {
  44310. edges := make([]string, 0, 0)
  44311. return edges
  44312. }
  44313. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44314. // name in this mutation.
  44315. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  44316. return nil
  44317. }
  44318. // RemovedEdges returns all edge names that were removed in this mutation.
  44319. func (m *WxCardMutation) RemovedEdges() []string {
  44320. edges := make([]string, 0, 0)
  44321. return edges
  44322. }
  44323. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44324. // the given name in this mutation.
  44325. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  44326. return nil
  44327. }
  44328. // ClearedEdges returns all edge names that were cleared in this mutation.
  44329. func (m *WxCardMutation) ClearedEdges() []string {
  44330. edges := make([]string, 0, 0)
  44331. return edges
  44332. }
  44333. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44334. // was cleared in this mutation.
  44335. func (m *WxCardMutation) EdgeCleared(name string) bool {
  44336. return false
  44337. }
  44338. // ClearEdge clears the value of the edge with the given name. It returns an error
  44339. // if that edge is not defined in the schema.
  44340. func (m *WxCardMutation) ClearEdge(name string) error {
  44341. return fmt.Errorf("unknown WxCard unique edge %s", name)
  44342. }
  44343. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44344. // It returns an error if the edge is not defined in the schema.
  44345. func (m *WxCardMutation) ResetEdge(name string) error {
  44346. return fmt.Errorf("unknown WxCard edge %s", name)
  44347. }
  44348. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  44349. type WxCardUserMutation struct {
  44350. config
  44351. op Op
  44352. typ string
  44353. id *uint64
  44354. created_at *time.Time
  44355. updated_at *time.Time
  44356. deleted_at *time.Time
  44357. wxid *string
  44358. account *string
  44359. avatar *string
  44360. nickname *string
  44361. remark *string
  44362. phone *string
  44363. open_id *string
  44364. union_id *string
  44365. session_key *string
  44366. is_vip *int
  44367. addis_vip *int
  44368. clearedFields map[string]struct{}
  44369. done bool
  44370. oldValue func(context.Context) (*WxCardUser, error)
  44371. predicates []predicate.WxCardUser
  44372. }
  44373. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  44374. // wxcarduserOption allows management of the mutation configuration using functional options.
  44375. type wxcarduserOption func(*WxCardUserMutation)
  44376. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  44377. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  44378. m := &WxCardUserMutation{
  44379. config: c,
  44380. op: op,
  44381. typ: TypeWxCardUser,
  44382. clearedFields: make(map[string]struct{}),
  44383. }
  44384. for _, opt := range opts {
  44385. opt(m)
  44386. }
  44387. return m
  44388. }
  44389. // withWxCardUserID sets the ID field of the mutation.
  44390. func withWxCardUserID(id uint64) wxcarduserOption {
  44391. return func(m *WxCardUserMutation) {
  44392. var (
  44393. err error
  44394. once sync.Once
  44395. value *WxCardUser
  44396. )
  44397. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  44398. once.Do(func() {
  44399. if m.done {
  44400. err = errors.New("querying old values post mutation is not allowed")
  44401. } else {
  44402. value, err = m.Client().WxCardUser.Get(ctx, id)
  44403. }
  44404. })
  44405. return value, err
  44406. }
  44407. m.id = &id
  44408. }
  44409. }
  44410. // withWxCardUser sets the old WxCardUser of the mutation.
  44411. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  44412. return func(m *WxCardUserMutation) {
  44413. m.oldValue = func(context.Context) (*WxCardUser, error) {
  44414. return node, nil
  44415. }
  44416. m.id = &node.ID
  44417. }
  44418. }
  44419. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44420. // executed in a transaction (ent.Tx), a transactional client is returned.
  44421. func (m WxCardUserMutation) Client() *Client {
  44422. client := &Client{config: m.config}
  44423. client.init()
  44424. return client
  44425. }
  44426. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44427. // it returns an error otherwise.
  44428. func (m WxCardUserMutation) Tx() (*Tx, error) {
  44429. if _, ok := m.driver.(*txDriver); !ok {
  44430. return nil, errors.New("ent: mutation is not running in a transaction")
  44431. }
  44432. tx := &Tx{config: m.config}
  44433. tx.init()
  44434. return tx, nil
  44435. }
  44436. // SetID sets the value of the id field. Note that this
  44437. // operation is only accepted on creation of WxCardUser entities.
  44438. func (m *WxCardUserMutation) SetID(id uint64) {
  44439. m.id = &id
  44440. }
  44441. // ID returns the ID value in the mutation. Note that the ID is only available
  44442. // if it was provided to the builder or after it was returned from the database.
  44443. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  44444. if m.id == nil {
  44445. return
  44446. }
  44447. return *m.id, true
  44448. }
  44449. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44450. // That means, if the mutation is applied within a transaction with an isolation level such
  44451. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44452. // or updated by the mutation.
  44453. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  44454. switch {
  44455. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44456. id, exists := m.ID()
  44457. if exists {
  44458. return []uint64{id}, nil
  44459. }
  44460. fallthrough
  44461. case m.op.Is(OpUpdate | OpDelete):
  44462. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  44463. default:
  44464. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44465. }
  44466. }
  44467. // SetCreatedAt sets the "created_at" field.
  44468. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  44469. m.created_at = &t
  44470. }
  44471. // CreatedAt returns the value of the "created_at" field in the mutation.
  44472. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  44473. v := m.created_at
  44474. if v == nil {
  44475. return
  44476. }
  44477. return *v, true
  44478. }
  44479. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  44480. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44482. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44483. if !m.op.Is(OpUpdateOne) {
  44484. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44485. }
  44486. if m.id == nil || m.oldValue == nil {
  44487. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44488. }
  44489. oldValue, err := m.oldValue(ctx)
  44490. if err != nil {
  44491. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44492. }
  44493. return oldValue.CreatedAt, nil
  44494. }
  44495. // ResetCreatedAt resets all changes to the "created_at" field.
  44496. func (m *WxCardUserMutation) ResetCreatedAt() {
  44497. m.created_at = nil
  44498. }
  44499. // SetUpdatedAt sets the "updated_at" field.
  44500. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  44501. m.updated_at = &t
  44502. }
  44503. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44504. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  44505. v := m.updated_at
  44506. if v == nil {
  44507. return
  44508. }
  44509. return *v, true
  44510. }
  44511. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  44512. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44514. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44515. if !m.op.Is(OpUpdateOne) {
  44516. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44517. }
  44518. if m.id == nil || m.oldValue == nil {
  44519. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44520. }
  44521. oldValue, err := m.oldValue(ctx)
  44522. if err != nil {
  44523. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44524. }
  44525. return oldValue.UpdatedAt, nil
  44526. }
  44527. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44528. func (m *WxCardUserMutation) ResetUpdatedAt() {
  44529. m.updated_at = nil
  44530. }
  44531. // SetDeletedAt sets the "deleted_at" field.
  44532. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  44533. m.deleted_at = &t
  44534. }
  44535. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44536. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  44537. v := m.deleted_at
  44538. if v == nil {
  44539. return
  44540. }
  44541. return *v, true
  44542. }
  44543. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  44544. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44546. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44547. if !m.op.Is(OpUpdateOne) {
  44548. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44549. }
  44550. if m.id == nil || m.oldValue == nil {
  44551. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44552. }
  44553. oldValue, err := m.oldValue(ctx)
  44554. if err != nil {
  44555. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44556. }
  44557. return oldValue.DeletedAt, nil
  44558. }
  44559. // ClearDeletedAt clears the value of the "deleted_at" field.
  44560. func (m *WxCardUserMutation) ClearDeletedAt() {
  44561. m.deleted_at = nil
  44562. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  44563. }
  44564. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44565. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  44566. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  44567. return ok
  44568. }
  44569. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44570. func (m *WxCardUserMutation) ResetDeletedAt() {
  44571. m.deleted_at = nil
  44572. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  44573. }
  44574. // SetWxid sets the "wxid" field.
  44575. func (m *WxCardUserMutation) SetWxid(s string) {
  44576. m.wxid = &s
  44577. }
  44578. // Wxid returns the value of the "wxid" field in the mutation.
  44579. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  44580. v := m.wxid
  44581. if v == nil {
  44582. return
  44583. }
  44584. return *v, true
  44585. }
  44586. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  44587. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44589. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  44590. if !m.op.Is(OpUpdateOne) {
  44591. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  44592. }
  44593. if m.id == nil || m.oldValue == nil {
  44594. return v, errors.New("OldWxid requires an ID field in the mutation")
  44595. }
  44596. oldValue, err := m.oldValue(ctx)
  44597. if err != nil {
  44598. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  44599. }
  44600. return oldValue.Wxid, nil
  44601. }
  44602. // ResetWxid resets all changes to the "wxid" field.
  44603. func (m *WxCardUserMutation) ResetWxid() {
  44604. m.wxid = nil
  44605. }
  44606. // SetAccount sets the "account" field.
  44607. func (m *WxCardUserMutation) SetAccount(s string) {
  44608. m.account = &s
  44609. }
  44610. // Account returns the value of the "account" field in the mutation.
  44611. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  44612. v := m.account
  44613. if v == nil {
  44614. return
  44615. }
  44616. return *v, true
  44617. }
  44618. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  44619. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44621. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  44622. if !m.op.Is(OpUpdateOne) {
  44623. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  44624. }
  44625. if m.id == nil || m.oldValue == nil {
  44626. return v, errors.New("OldAccount requires an ID field in the mutation")
  44627. }
  44628. oldValue, err := m.oldValue(ctx)
  44629. if err != nil {
  44630. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  44631. }
  44632. return oldValue.Account, nil
  44633. }
  44634. // ResetAccount resets all changes to the "account" field.
  44635. func (m *WxCardUserMutation) ResetAccount() {
  44636. m.account = nil
  44637. }
  44638. // SetAvatar sets the "avatar" field.
  44639. func (m *WxCardUserMutation) SetAvatar(s string) {
  44640. m.avatar = &s
  44641. }
  44642. // Avatar returns the value of the "avatar" field in the mutation.
  44643. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  44644. v := m.avatar
  44645. if v == nil {
  44646. return
  44647. }
  44648. return *v, true
  44649. }
  44650. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  44651. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44653. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44654. if !m.op.Is(OpUpdateOne) {
  44655. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44656. }
  44657. if m.id == nil || m.oldValue == nil {
  44658. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44659. }
  44660. oldValue, err := m.oldValue(ctx)
  44661. if err != nil {
  44662. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44663. }
  44664. return oldValue.Avatar, nil
  44665. }
  44666. // ResetAvatar resets all changes to the "avatar" field.
  44667. func (m *WxCardUserMutation) ResetAvatar() {
  44668. m.avatar = nil
  44669. }
  44670. // SetNickname sets the "nickname" field.
  44671. func (m *WxCardUserMutation) SetNickname(s string) {
  44672. m.nickname = &s
  44673. }
  44674. // Nickname returns the value of the "nickname" field in the mutation.
  44675. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  44676. v := m.nickname
  44677. if v == nil {
  44678. return
  44679. }
  44680. return *v, true
  44681. }
  44682. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  44683. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44685. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  44686. if !m.op.Is(OpUpdateOne) {
  44687. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44688. }
  44689. if m.id == nil || m.oldValue == nil {
  44690. return v, errors.New("OldNickname requires an ID field in the mutation")
  44691. }
  44692. oldValue, err := m.oldValue(ctx)
  44693. if err != nil {
  44694. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44695. }
  44696. return oldValue.Nickname, nil
  44697. }
  44698. // ResetNickname resets all changes to the "nickname" field.
  44699. func (m *WxCardUserMutation) ResetNickname() {
  44700. m.nickname = nil
  44701. }
  44702. // SetRemark sets the "remark" field.
  44703. func (m *WxCardUserMutation) SetRemark(s string) {
  44704. m.remark = &s
  44705. }
  44706. // Remark returns the value of the "remark" field in the mutation.
  44707. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  44708. v := m.remark
  44709. if v == nil {
  44710. return
  44711. }
  44712. return *v, true
  44713. }
  44714. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  44715. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44717. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  44718. if !m.op.Is(OpUpdateOne) {
  44719. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  44720. }
  44721. if m.id == nil || m.oldValue == nil {
  44722. return v, errors.New("OldRemark requires an ID field in the mutation")
  44723. }
  44724. oldValue, err := m.oldValue(ctx)
  44725. if err != nil {
  44726. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  44727. }
  44728. return oldValue.Remark, nil
  44729. }
  44730. // ResetRemark resets all changes to the "remark" field.
  44731. func (m *WxCardUserMutation) ResetRemark() {
  44732. m.remark = nil
  44733. }
  44734. // SetPhone sets the "phone" field.
  44735. func (m *WxCardUserMutation) SetPhone(s string) {
  44736. m.phone = &s
  44737. }
  44738. // Phone returns the value of the "phone" field in the mutation.
  44739. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  44740. v := m.phone
  44741. if v == nil {
  44742. return
  44743. }
  44744. return *v, true
  44745. }
  44746. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  44747. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44749. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  44750. if !m.op.Is(OpUpdateOne) {
  44751. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  44752. }
  44753. if m.id == nil || m.oldValue == nil {
  44754. return v, errors.New("OldPhone requires an ID field in the mutation")
  44755. }
  44756. oldValue, err := m.oldValue(ctx)
  44757. if err != nil {
  44758. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  44759. }
  44760. return oldValue.Phone, nil
  44761. }
  44762. // ResetPhone resets all changes to the "phone" field.
  44763. func (m *WxCardUserMutation) ResetPhone() {
  44764. m.phone = nil
  44765. }
  44766. // SetOpenID sets the "open_id" field.
  44767. func (m *WxCardUserMutation) SetOpenID(s string) {
  44768. m.open_id = &s
  44769. }
  44770. // OpenID returns the value of the "open_id" field in the mutation.
  44771. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  44772. v := m.open_id
  44773. if v == nil {
  44774. return
  44775. }
  44776. return *v, true
  44777. }
  44778. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  44779. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44781. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  44782. if !m.op.Is(OpUpdateOne) {
  44783. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  44784. }
  44785. if m.id == nil || m.oldValue == nil {
  44786. return v, errors.New("OldOpenID requires an ID field in the mutation")
  44787. }
  44788. oldValue, err := m.oldValue(ctx)
  44789. if err != nil {
  44790. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  44791. }
  44792. return oldValue.OpenID, nil
  44793. }
  44794. // ResetOpenID resets all changes to the "open_id" field.
  44795. func (m *WxCardUserMutation) ResetOpenID() {
  44796. m.open_id = nil
  44797. }
  44798. // SetUnionID sets the "union_id" field.
  44799. func (m *WxCardUserMutation) SetUnionID(s string) {
  44800. m.union_id = &s
  44801. }
  44802. // UnionID returns the value of the "union_id" field in the mutation.
  44803. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  44804. v := m.union_id
  44805. if v == nil {
  44806. return
  44807. }
  44808. return *v, true
  44809. }
  44810. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  44811. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44813. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  44814. if !m.op.Is(OpUpdateOne) {
  44815. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  44816. }
  44817. if m.id == nil || m.oldValue == nil {
  44818. return v, errors.New("OldUnionID requires an ID field in the mutation")
  44819. }
  44820. oldValue, err := m.oldValue(ctx)
  44821. if err != nil {
  44822. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  44823. }
  44824. return oldValue.UnionID, nil
  44825. }
  44826. // ResetUnionID resets all changes to the "union_id" field.
  44827. func (m *WxCardUserMutation) ResetUnionID() {
  44828. m.union_id = nil
  44829. }
  44830. // SetSessionKey sets the "session_key" field.
  44831. func (m *WxCardUserMutation) SetSessionKey(s string) {
  44832. m.session_key = &s
  44833. }
  44834. // SessionKey returns the value of the "session_key" field in the mutation.
  44835. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  44836. v := m.session_key
  44837. if v == nil {
  44838. return
  44839. }
  44840. return *v, true
  44841. }
  44842. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  44843. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44845. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  44846. if !m.op.Is(OpUpdateOne) {
  44847. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  44848. }
  44849. if m.id == nil || m.oldValue == nil {
  44850. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  44851. }
  44852. oldValue, err := m.oldValue(ctx)
  44853. if err != nil {
  44854. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  44855. }
  44856. return oldValue.SessionKey, nil
  44857. }
  44858. // ResetSessionKey resets all changes to the "session_key" field.
  44859. func (m *WxCardUserMutation) ResetSessionKey() {
  44860. m.session_key = nil
  44861. }
  44862. // SetIsVip sets the "is_vip" field.
  44863. func (m *WxCardUserMutation) SetIsVip(i int) {
  44864. m.is_vip = &i
  44865. m.addis_vip = nil
  44866. }
  44867. // IsVip returns the value of the "is_vip" field in the mutation.
  44868. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  44869. v := m.is_vip
  44870. if v == nil {
  44871. return
  44872. }
  44873. return *v, true
  44874. }
  44875. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  44876. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44878. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  44879. if !m.op.Is(OpUpdateOne) {
  44880. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  44881. }
  44882. if m.id == nil || m.oldValue == nil {
  44883. return v, errors.New("OldIsVip requires an ID field in the mutation")
  44884. }
  44885. oldValue, err := m.oldValue(ctx)
  44886. if err != nil {
  44887. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  44888. }
  44889. return oldValue.IsVip, nil
  44890. }
  44891. // AddIsVip adds i to the "is_vip" field.
  44892. func (m *WxCardUserMutation) AddIsVip(i int) {
  44893. if m.addis_vip != nil {
  44894. *m.addis_vip += i
  44895. } else {
  44896. m.addis_vip = &i
  44897. }
  44898. }
  44899. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  44900. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  44901. v := m.addis_vip
  44902. if v == nil {
  44903. return
  44904. }
  44905. return *v, true
  44906. }
  44907. // ResetIsVip resets all changes to the "is_vip" field.
  44908. func (m *WxCardUserMutation) ResetIsVip() {
  44909. m.is_vip = nil
  44910. m.addis_vip = nil
  44911. }
  44912. // Where appends a list predicates to the WxCardUserMutation builder.
  44913. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  44914. m.predicates = append(m.predicates, ps...)
  44915. }
  44916. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  44917. // users can use type-assertion to append predicates that do not depend on any generated package.
  44918. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  44919. p := make([]predicate.WxCardUser, len(ps))
  44920. for i := range ps {
  44921. p[i] = ps[i]
  44922. }
  44923. m.Where(p...)
  44924. }
  44925. // Op returns the operation name.
  44926. func (m *WxCardUserMutation) Op() Op {
  44927. return m.op
  44928. }
  44929. // SetOp allows setting the mutation operation.
  44930. func (m *WxCardUserMutation) SetOp(op Op) {
  44931. m.op = op
  44932. }
  44933. // Type returns the node type of this mutation (WxCardUser).
  44934. func (m *WxCardUserMutation) Type() string {
  44935. return m.typ
  44936. }
  44937. // Fields returns all fields that were changed during this mutation. Note that in
  44938. // order to get all numeric fields that were incremented/decremented, call
  44939. // AddedFields().
  44940. func (m *WxCardUserMutation) Fields() []string {
  44941. fields := make([]string, 0, 13)
  44942. if m.created_at != nil {
  44943. fields = append(fields, wxcarduser.FieldCreatedAt)
  44944. }
  44945. if m.updated_at != nil {
  44946. fields = append(fields, wxcarduser.FieldUpdatedAt)
  44947. }
  44948. if m.deleted_at != nil {
  44949. fields = append(fields, wxcarduser.FieldDeletedAt)
  44950. }
  44951. if m.wxid != nil {
  44952. fields = append(fields, wxcarduser.FieldWxid)
  44953. }
  44954. if m.account != nil {
  44955. fields = append(fields, wxcarduser.FieldAccount)
  44956. }
  44957. if m.avatar != nil {
  44958. fields = append(fields, wxcarduser.FieldAvatar)
  44959. }
  44960. if m.nickname != nil {
  44961. fields = append(fields, wxcarduser.FieldNickname)
  44962. }
  44963. if m.remark != nil {
  44964. fields = append(fields, wxcarduser.FieldRemark)
  44965. }
  44966. if m.phone != nil {
  44967. fields = append(fields, wxcarduser.FieldPhone)
  44968. }
  44969. if m.open_id != nil {
  44970. fields = append(fields, wxcarduser.FieldOpenID)
  44971. }
  44972. if m.union_id != nil {
  44973. fields = append(fields, wxcarduser.FieldUnionID)
  44974. }
  44975. if m.session_key != nil {
  44976. fields = append(fields, wxcarduser.FieldSessionKey)
  44977. }
  44978. if m.is_vip != nil {
  44979. fields = append(fields, wxcarduser.FieldIsVip)
  44980. }
  44981. return fields
  44982. }
  44983. // Field returns the value of a field with the given name. The second boolean
  44984. // return value indicates that this field was not set, or was not defined in the
  44985. // schema.
  44986. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  44987. switch name {
  44988. case wxcarduser.FieldCreatedAt:
  44989. return m.CreatedAt()
  44990. case wxcarduser.FieldUpdatedAt:
  44991. return m.UpdatedAt()
  44992. case wxcarduser.FieldDeletedAt:
  44993. return m.DeletedAt()
  44994. case wxcarduser.FieldWxid:
  44995. return m.Wxid()
  44996. case wxcarduser.FieldAccount:
  44997. return m.Account()
  44998. case wxcarduser.FieldAvatar:
  44999. return m.Avatar()
  45000. case wxcarduser.FieldNickname:
  45001. return m.Nickname()
  45002. case wxcarduser.FieldRemark:
  45003. return m.Remark()
  45004. case wxcarduser.FieldPhone:
  45005. return m.Phone()
  45006. case wxcarduser.FieldOpenID:
  45007. return m.OpenID()
  45008. case wxcarduser.FieldUnionID:
  45009. return m.UnionID()
  45010. case wxcarduser.FieldSessionKey:
  45011. return m.SessionKey()
  45012. case wxcarduser.FieldIsVip:
  45013. return m.IsVip()
  45014. }
  45015. return nil, false
  45016. }
  45017. // OldField returns the old value of the field from the database. An error is
  45018. // returned if the mutation operation is not UpdateOne, or the query to the
  45019. // database failed.
  45020. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45021. switch name {
  45022. case wxcarduser.FieldCreatedAt:
  45023. return m.OldCreatedAt(ctx)
  45024. case wxcarduser.FieldUpdatedAt:
  45025. return m.OldUpdatedAt(ctx)
  45026. case wxcarduser.FieldDeletedAt:
  45027. return m.OldDeletedAt(ctx)
  45028. case wxcarduser.FieldWxid:
  45029. return m.OldWxid(ctx)
  45030. case wxcarduser.FieldAccount:
  45031. return m.OldAccount(ctx)
  45032. case wxcarduser.FieldAvatar:
  45033. return m.OldAvatar(ctx)
  45034. case wxcarduser.FieldNickname:
  45035. return m.OldNickname(ctx)
  45036. case wxcarduser.FieldRemark:
  45037. return m.OldRemark(ctx)
  45038. case wxcarduser.FieldPhone:
  45039. return m.OldPhone(ctx)
  45040. case wxcarduser.FieldOpenID:
  45041. return m.OldOpenID(ctx)
  45042. case wxcarduser.FieldUnionID:
  45043. return m.OldUnionID(ctx)
  45044. case wxcarduser.FieldSessionKey:
  45045. return m.OldSessionKey(ctx)
  45046. case wxcarduser.FieldIsVip:
  45047. return m.OldIsVip(ctx)
  45048. }
  45049. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  45050. }
  45051. // SetField sets the value of a field with the given name. It returns an error if
  45052. // the field is not defined in the schema, or if the type mismatched the field
  45053. // type.
  45054. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  45055. switch name {
  45056. case wxcarduser.FieldCreatedAt:
  45057. v, ok := value.(time.Time)
  45058. if !ok {
  45059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45060. }
  45061. m.SetCreatedAt(v)
  45062. return nil
  45063. case wxcarduser.FieldUpdatedAt:
  45064. v, ok := value.(time.Time)
  45065. if !ok {
  45066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45067. }
  45068. m.SetUpdatedAt(v)
  45069. return nil
  45070. case wxcarduser.FieldDeletedAt:
  45071. v, ok := value.(time.Time)
  45072. if !ok {
  45073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45074. }
  45075. m.SetDeletedAt(v)
  45076. return nil
  45077. case wxcarduser.FieldWxid:
  45078. v, ok := value.(string)
  45079. if !ok {
  45080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45081. }
  45082. m.SetWxid(v)
  45083. return nil
  45084. case wxcarduser.FieldAccount:
  45085. v, ok := value.(string)
  45086. if !ok {
  45087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45088. }
  45089. m.SetAccount(v)
  45090. return nil
  45091. case wxcarduser.FieldAvatar:
  45092. v, ok := value.(string)
  45093. if !ok {
  45094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45095. }
  45096. m.SetAvatar(v)
  45097. return nil
  45098. case wxcarduser.FieldNickname:
  45099. v, ok := value.(string)
  45100. if !ok {
  45101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45102. }
  45103. m.SetNickname(v)
  45104. return nil
  45105. case wxcarduser.FieldRemark:
  45106. v, ok := value.(string)
  45107. if !ok {
  45108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45109. }
  45110. m.SetRemark(v)
  45111. return nil
  45112. case wxcarduser.FieldPhone:
  45113. v, ok := value.(string)
  45114. if !ok {
  45115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45116. }
  45117. m.SetPhone(v)
  45118. return nil
  45119. case wxcarduser.FieldOpenID:
  45120. v, ok := value.(string)
  45121. if !ok {
  45122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45123. }
  45124. m.SetOpenID(v)
  45125. return nil
  45126. case wxcarduser.FieldUnionID:
  45127. v, ok := value.(string)
  45128. if !ok {
  45129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45130. }
  45131. m.SetUnionID(v)
  45132. return nil
  45133. case wxcarduser.FieldSessionKey:
  45134. v, ok := value.(string)
  45135. if !ok {
  45136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45137. }
  45138. m.SetSessionKey(v)
  45139. return nil
  45140. case wxcarduser.FieldIsVip:
  45141. v, ok := value.(int)
  45142. if !ok {
  45143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45144. }
  45145. m.SetIsVip(v)
  45146. return nil
  45147. }
  45148. return fmt.Errorf("unknown WxCardUser field %s", name)
  45149. }
  45150. // AddedFields returns all numeric fields that were incremented/decremented during
  45151. // this mutation.
  45152. func (m *WxCardUserMutation) AddedFields() []string {
  45153. var fields []string
  45154. if m.addis_vip != nil {
  45155. fields = append(fields, wxcarduser.FieldIsVip)
  45156. }
  45157. return fields
  45158. }
  45159. // AddedField returns the numeric value that was incremented/decremented on a field
  45160. // with the given name. The second boolean return value indicates that this field
  45161. // was not set, or was not defined in the schema.
  45162. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  45163. switch name {
  45164. case wxcarduser.FieldIsVip:
  45165. return m.AddedIsVip()
  45166. }
  45167. return nil, false
  45168. }
  45169. // AddField adds the value to the field with the given name. It returns an error if
  45170. // the field is not defined in the schema, or if the type mismatched the field
  45171. // type.
  45172. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  45173. switch name {
  45174. case wxcarduser.FieldIsVip:
  45175. v, ok := value.(int)
  45176. if !ok {
  45177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45178. }
  45179. m.AddIsVip(v)
  45180. return nil
  45181. }
  45182. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  45183. }
  45184. // ClearedFields returns all nullable fields that were cleared during this
  45185. // mutation.
  45186. func (m *WxCardUserMutation) ClearedFields() []string {
  45187. var fields []string
  45188. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  45189. fields = append(fields, wxcarduser.FieldDeletedAt)
  45190. }
  45191. return fields
  45192. }
  45193. // FieldCleared returns a boolean indicating if a field with the given name was
  45194. // cleared in this mutation.
  45195. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  45196. _, ok := m.clearedFields[name]
  45197. return ok
  45198. }
  45199. // ClearField clears the value of the field with the given name. It returns an
  45200. // error if the field is not defined in the schema.
  45201. func (m *WxCardUserMutation) ClearField(name string) error {
  45202. switch name {
  45203. case wxcarduser.FieldDeletedAt:
  45204. m.ClearDeletedAt()
  45205. return nil
  45206. }
  45207. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  45208. }
  45209. // ResetField resets all changes in the mutation for the field with the given name.
  45210. // It returns an error if the field is not defined in the schema.
  45211. func (m *WxCardUserMutation) ResetField(name string) error {
  45212. switch name {
  45213. case wxcarduser.FieldCreatedAt:
  45214. m.ResetCreatedAt()
  45215. return nil
  45216. case wxcarduser.FieldUpdatedAt:
  45217. m.ResetUpdatedAt()
  45218. return nil
  45219. case wxcarduser.FieldDeletedAt:
  45220. m.ResetDeletedAt()
  45221. return nil
  45222. case wxcarduser.FieldWxid:
  45223. m.ResetWxid()
  45224. return nil
  45225. case wxcarduser.FieldAccount:
  45226. m.ResetAccount()
  45227. return nil
  45228. case wxcarduser.FieldAvatar:
  45229. m.ResetAvatar()
  45230. return nil
  45231. case wxcarduser.FieldNickname:
  45232. m.ResetNickname()
  45233. return nil
  45234. case wxcarduser.FieldRemark:
  45235. m.ResetRemark()
  45236. return nil
  45237. case wxcarduser.FieldPhone:
  45238. m.ResetPhone()
  45239. return nil
  45240. case wxcarduser.FieldOpenID:
  45241. m.ResetOpenID()
  45242. return nil
  45243. case wxcarduser.FieldUnionID:
  45244. m.ResetUnionID()
  45245. return nil
  45246. case wxcarduser.FieldSessionKey:
  45247. m.ResetSessionKey()
  45248. return nil
  45249. case wxcarduser.FieldIsVip:
  45250. m.ResetIsVip()
  45251. return nil
  45252. }
  45253. return fmt.Errorf("unknown WxCardUser field %s", name)
  45254. }
  45255. // AddedEdges returns all edge names that were set/added in this mutation.
  45256. func (m *WxCardUserMutation) AddedEdges() []string {
  45257. edges := make([]string, 0, 0)
  45258. return edges
  45259. }
  45260. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45261. // name in this mutation.
  45262. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  45263. return nil
  45264. }
  45265. // RemovedEdges returns all edge names that were removed in this mutation.
  45266. func (m *WxCardUserMutation) RemovedEdges() []string {
  45267. edges := make([]string, 0, 0)
  45268. return edges
  45269. }
  45270. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45271. // the given name in this mutation.
  45272. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  45273. return nil
  45274. }
  45275. // ClearedEdges returns all edge names that were cleared in this mutation.
  45276. func (m *WxCardUserMutation) ClearedEdges() []string {
  45277. edges := make([]string, 0, 0)
  45278. return edges
  45279. }
  45280. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45281. // was cleared in this mutation.
  45282. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  45283. return false
  45284. }
  45285. // ClearEdge clears the value of the edge with the given name. It returns an error
  45286. // if that edge is not defined in the schema.
  45287. func (m *WxCardUserMutation) ClearEdge(name string) error {
  45288. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  45289. }
  45290. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45291. // It returns an error if the edge is not defined in the schema.
  45292. func (m *WxCardUserMutation) ResetEdge(name string) error {
  45293. return fmt.Errorf("unknown WxCardUser edge %s", name)
  45294. }
  45295. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  45296. type WxCardVisitMutation struct {
  45297. config
  45298. op Op
  45299. typ string
  45300. id *uint64
  45301. created_at *time.Time
  45302. updated_at *time.Time
  45303. deleted_at *time.Time
  45304. user_id *uint64
  45305. adduser_id *int64
  45306. bot_id *uint64
  45307. addbot_id *int64
  45308. bot_type *uint8
  45309. addbot_type *int8
  45310. clearedFields map[string]struct{}
  45311. done bool
  45312. oldValue func(context.Context) (*WxCardVisit, error)
  45313. predicates []predicate.WxCardVisit
  45314. }
  45315. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  45316. // wxcardvisitOption allows management of the mutation configuration using functional options.
  45317. type wxcardvisitOption func(*WxCardVisitMutation)
  45318. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  45319. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  45320. m := &WxCardVisitMutation{
  45321. config: c,
  45322. op: op,
  45323. typ: TypeWxCardVisit,
  45324. clearedFields: make(map[string]struct{}),
  45325. }
  45326. for _, opt := range opts {
  45327. opt(m)
  45328. }
  45329. return m
  45330. }
  45331. // withWxCardVisitID sets the ID field of the mutation.
  45332. func withWxCardVisitID(id uint64) wxcardvisitOption {
  45333. return func(m *WxCardVisitMutation) {
  45334. var (
  45335. err error
  45336. once sync.Once
  45337. value *WxCardVisit
  45338. )
  45339. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  45340. once.Do(func() {
  45341. if m.done {
  45342. err = errors.New("querying old values post mutation is not allowed")
  45343. } else {
  45344. value, err = m.Client().WxCardVisit.Get(ctx, id)
  45345. }
  45346. })
  45347. return value, err
  45348. }
  45349. m.id = &id
  45350. }
  45351. }
  45352. // withWxCardVisit sets the old WxCardVisit of the mutation.
  45353. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  45354. return func(m *WxCardVisitMutation) {
  45355. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  45356. return node, nil
  45357. }
  45358. m.id = &node.ID
  45359. }
  45360. }
  45361. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45362. // executed in a transaction (ent.Tx), a transactional client is returned.
  45363. func (m WxCardVisitMutation) Client() *Client {
  45364. client := &Client{config: m.config}
  45365. client.init()
  45366. return client
  45367. }
  45368. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45369. // it returns an error otherwise.
  45370. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  45371. if _, ok := m.driver.(*txDriver); !ok {
  45372. return nil, errors.New("ent: mutation is not running in a transaction")
  45373. }
  45374. tx := &Tx{config: m.config}
  45375. tx.init()
  45376. return tx, nil
  45377. }
  45378. // SetID sets the value of the id field. Note that this
  45379. // operation is only accepted on creation of WxCardVisit entities.
  45380. func (m *WxCardVisitMutation) SetID(id uint64) {
  45381. m.id = &id
  45382. }
  45383. // ID returns the ID value in the mutation. Note that the ID is only available
  45384. // if it was provided to the builder or after it was returned from the database.
  45385. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  45386. if m.id == nil {
  45387. return
  45388. }
  45389. return *m.id, true
  45390. }
  45391. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45392. // That means, if the mutation is applied within a transaction with an isolation level such
  45393. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45394. // or updated by the mutation.
  45395. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  45396. switch {
  45397. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45398. id, exists := m.ID()
  45399. if exists {
  45400. return []uint64{id}, nil
  45401. }
  45402. fallthrough
  45403. case m.op.Is(OpUpdate | OpDelete):
  45404. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  45405. default:
  45406. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45407. }
  45408. }
  45409. // SetCreatedAt sets the "created_at" field.
  45410. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  45411. m.created_at = &t
  45412. }
  45413. // CreatedAt returns the value of the "created_at" field in the mutation.
  45414. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  45415. v := m.created_at
  45416. if v == nil {
  45417. return
  45418. }
  45419. return *v, true
  45420. }
  45421. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  45422. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45424. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45425. if !m.op.Is(OpUpdateOne) {
  45426. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45427. }
  45428. if m.id == nil || m.oldValue == nil {
  45429. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45430. }
  45431. oldValue, err := m.oldValue(ctx)
  45432. if err != nil {
  45433. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45434. }
  45435. return oldValue.CreatedAt, nil
  45436. }
  45437. // ResetCreatedAt resets all changes to the "created_at" field.
  45438. func (m *WxCardVisitMutation) ResetCreatedAt() {
  45439. m.created_at = nil
  45440. }
  45441. // SetUpdatedAt sets the "updated_at" field.
  45442. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  45443. m.updated_at = &t
  45444. }
  45445. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45446. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  45447. v := m.updated_at
  45448. if v == nil {
  45449. return
  45450. }
  45451. return *v, true
  45452. }
  45453. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  45454. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45456. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45457. if !m.op.Is(OpUpdateOne) {
  45458. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45459. }
  45460. if m.id == nil || m.oldValue == nil {
  45461. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45462. }
  45463. oldValue, err := m.oldValue(ctx)
  45464. if err != nil {
  45465. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45466. }
  45467. return oldValue.UpdatedAt, nil
  45468. }
  45469. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45470. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  45471. m.updated_at = nil
  45472. }
  45473. // SetDeletedAt sets the "deleted_at" field.
  45474. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  45475. m.deleted_at = &t
  45476. }
  45477. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45478. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  45479. v := m.deleted_at
  45480. if v == nil {
  45481. return
  45482. }
  45483. return *v, true
  45484. }
  45485. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  45486. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45488. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45489. if !m.op.Is(OpUpdateOne) {
  45490. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45491. }
  45492. if m.id == nil || m.oldValue == nil {
  45493. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45494. }
  45495. oldValue, err := m.oldValue(ctx)
  45496. if err != nil {
  45497. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45498. }
  45499. return oldValue.DeletedAt, nil
  45500. }
  45501. // ClearDeletedAt clears the value of the "deleted_at" field.
  45502. func (m *WxCardVisitMutation) ClearDeletedAt() {
  45503. m.deleted_at = nil
  45504. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  45505. }
  45506. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45507. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  45508. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  45509. return ok
  45510. }
  45511. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45512. func (m *WxCardVisitMutation) ResetDeletedAt() {
  45513. m.deleted_at = nil
  45514. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  45515. }
  45516. // SetUserID sets the "user_id" field.
  45517. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  45518. m.user_id = &u
  45519. m.adduser_id = nil
  45520. }
  45521. // UserID returns the value of the "user_id" field in the mutation.
  45522. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  45523. v := m.user_id
  45524. if v == nil {
  45525. return
  45526. }
  45527. return *v, true
  45528. }
  45529. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  45530. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45532. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  45533. if !m.op.Is(OpUpdateOne) {
  45534. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  45535. }
  45536. if m.id == nil || m.oldValue == nil {
  45537. return v, errors.New("OldUserID requires an ID field in the mutation")
  45538. }
  45539. oldValue, err := m.oldValue(ctx)
  45540. if err != nil {
  45541. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  45542. }
  45543. return oldValue.UserID, nil
  45544. }
  45545. // AddUserID adds u to the "user_id" field.
  45546. func (m *WxCardVisitMutation) AddUserID(u int64) {
  45547. if m.adduser_id != nil {
  45548. *m.adduser_id += u
  45549. } else {
  45550. m.adduser_id = &u
  45551. }
  45552. }
  45553. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  45554. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  45555. v := m.adduser_id
  45556. if v == nil {
  45557. return
  45558. }
  45559. return *v, true
  45560. }
  45561. // ClearUserID clears the value of the "user_id" field.
  45562. func (m *WxCardVisitMutation) ClearUserID() {
  45563. m.user_id = nil
  45564. m.adduser_id = nil
  45565. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  45566. }
  45567. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  45568. func (m *WxCardVisitMutation) UserIDCleared() bool {
  45569. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  45570. return ok
  45571. }
  45572. // ResetUserID resets all changes to the "user_id" field.
  45573. func (m *WxCardVisitMutation) ResetUserID() {
  45574. m.user_id = nil
  45575. m.adduser_id = nil
  45576. delete(m.clearedFields, wxcardvisit.FieldUserID)
  45577. }
  45578. // SetBotID sets the "bot_id" field.
  45579. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  45580. m.bot_id = &u
  45581. m.addbot_id = nil
  45582. }
  45583. // BotID returns the value of the "bot_id" field in the mutation.
  45584. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  45585. v := m.bot_id
  45586. if v == nil {
  45587. return
  45588. }
  45589. return *v, true
  45590. }
  45591. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  45592. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45594. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  45595. if !m.op.Is(OpUpdateOne) {
  45596. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  45597. }
  45598. if m.id == nil || m.oldValue == nil {
  45599. return v, errors.New("OldBotID requires an ID field in the mutation")
  45600. }
  45601. oldValue, err := m.oldValue(ctx)
  45602. if err != nil {
  45603. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  45604. }
  45605. return oldValue.BotID, nil
  45606. }
  45607. // AddBotID adds u to the "bot_id" field.
  45608. func (m *WxCardVisitMutation) AddBotID(u int64) {
  45609. if m.addbot_id != nil {
  45610. *m.addbot_id += u
  45611. } else {
  45612. m.addbot_id = &u
  45613. }
  45614. }
  45615. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  45616. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  45617. v := m.addbot_id
  45618. if v == nil {
  45619. return
  45620. }
  45621. return *v, true
  45622. }
  45623. // ResetBotID resets all changes to the "bot_id" field.
  45624. func (m *WxCardVisitMutation) ResetBotID() {
  45625. m.bot_id = nil
  45626. m.addbot_id = nil
  45627. }
  45628. // SetBotType sets the "bot_type" field.
  45629. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  45630. m.bot_type = &u
  45631. m.addbot_type = nil
  45632. }
  45633. // BotType returns the value of the "bot_type" field in the mutation.
  45634. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  45635. v := m.bot_type
  45636. if v == nil {
  45637. return
  45638. }
  45639. return *v, true
  45640. }
  45641. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  45642. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45644. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  45645. if !m.op.Is(OpUpdateOne) {
  45646. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  45647. }
  45648. if m.id == nil || m.oldValue == nil {
  45649. return v, errors.New("OldBotType requires an ID field in the mutation")
  45650. }
  45651. oldValue, err := m.oldValue(ctx)
  45652. if err != nil {
  45653. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  45654. }
  45655. return oldValue.BotType, nil
  45656. }
  45657. // AddBotType adds u to the "bot_type" field.
  45658. func (m *WxCardVisitMutation) AddBotType(u int8) {
  45659. if m.addbot_type != nil {
  45660. *m.addbot_type += u
  45661. } else {
  45662. m.addbot_type = &u
  45663. }
  45664. }
  45665. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  45666. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  45667. v := m.addbot_type
  45668. if v == nil {
  45669. return
  45670. }
  45671. return *v, true
  45672. }
  45673. // ResetBotType resets all changes to the "bot_type" field.
  45674. func (m *WxCardVisitMutation) ResetBotType() {
  45675. m.bot_type = nil
  45676. m.addbot_type = nil
  45677. }
  45678. // Where appends a list predicates to the WxCardVisitMutation builder.
  45679. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  45680. m.predicates = append(m.predicates, ps...)
  45681. }
  45682. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  45683. // users can use type-assertion to append predicates that do not depend on any generated package.
  45684. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  45685. p := make([]predicate.WxCardVisit, len(ps))
  45686. for i := range ps {
  45687. p[i] = ps[i]
  45688. }
  45689. m.Where(p...)
  45690. }
  45691. // Op returns the operation name.
  45692. func (m *WxCardVisitMutation) Op() Op {
  45693. return m.op
  45694. }
  45695. // SetOp allows setting the mutation operation.
  45696. func (m *WxCardVisitMutation) SetOp(op Op) {
  45697. m.op = op
  45698. }
  45699. // Type returns the node type of this mutation (WxCardVisit).
  45700. func (m *WxCardVisitMutation) Type() string {
  45701. return m.typ
  45702. }
  45703. // Fields returns all fields that were changed during this mutation. Note that in
  45704. // order to get all numeric fields that were incremented/decremented, call
  45705. // AddedFields().
  45706. func (m *WxCardVisitMutation) Fields() []string {
  45707. fields := make([]string, 0, 6)
  45708. if m.created_at != nil {
  45709. fields = append(fields, wxcardvisit.FieldCreatedAt)
  45710. }
  45711. if m.updated_at != nil {
  45712. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  45713. }
  45714. if m.deleted_at != nil {
  45715. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45716. }
  45717. if m.user_id != nil {
  45718. fields = append(fields, wxcardvisit.FieldUserID)
  45719. }
  45720. if m.bot_id != nil {
  45721. fields = append(fields, wxcardvisit.FieldBotID)
  45722. }
  45723. if m.bot_type != nil {
  45724. fields = append(fields, wxcardvisit.FieldBotType)
  45725. }
  45726. return fields
  45727. }
  45728. // Field returns the value of a field with the given name. The second boolean
  45729. // return value indicates that this field was not set, or was not defined in the
  45730. // schema.
  45731. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  45732. switch name {
  45733. case wxcardvisit.FieldCreatedAt:
  45734. return m.CreatedAt()
  45735. case wxcardvisit.FieldUpdatedAt:
  45736. return m.UpdatedAt()
  45737. case wxcardvisit.FieldDeletedAt:
  45738. return m.DeletedAt()
  45739. case wxcardvisit.FieldUserID:
  45740. return m.UserID()
  45741. case wxcardvisit.FieldBotID:
  45742. return m.BotID()
  45743. case wxcardvisit.FieldBotType:
  45744. return m.BotType()
  45745. }
  45746. return nil, false
  45747. }
  45748. // OldField returns the old value of the field from the database. An error is
  45749. // returned if the mutation operation is not UpdateOne, or the query to the
  45750. // database failed.
  45751. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45752. switch name {
  45753. case wxcardvisit.FieldCreatedAt:
  45754. return m.OldCreatedAt(ctx)
  45755. case wxcardvisit.FieldUpdatedAt:
  45756. return m.OldUpdatedAt(ctx)
  45757. case wxcardvisit.FieldDeletedAt:
  45758. return m.OldDeletedAt(ctx)
  45759. case wxcardvisit.FieldUserID:
  45760. return m.OldUserID(ctx)
  45761. case wxcardvisit.FieldBotID:
  45762. return m.OldBotID(ctx)
  45763. case wxcardvisit.FieldBotType:
  45764. return m.OldBotType(ctx)
  45765. }
  45766. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  45767. }
  45768. // SetField sets the value of a field with the given name. It returns an error if
  45769. // the field is not defined in the schema, or if the type mismatched the field
  45770. // type.
  45771. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  45772. switch name {
  45773. case wxcardvisit.FieldCreatedAt:
  45774. v, ok := value.(time.Time)
  45775. if !ok {
  45776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45777. }
  45778. m.SetCreatedAt(v)
  45779. return nil
  45780. case wxcardvisit.FieldUpdatedAt:
  45781. v, ok := value.(time.Time)
  45782. if !ok {
  45783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45784. }
  45785. m.SetUpdatedAt(v)
  45786. return nil
  45787. case wxcardvisit.FieldDeletedAt:
  45788. v, ok := value.(time.Time)
  45789. if !ok {
  45790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45791. }
  45792. m.SetDeletedAt(v)
  45793. return nil
  45794. case wxcardvisit.FieldUserID:
  45795. v, ok := value.(uint64)
  45796. if !ok {
  45797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45798. }
  45799. m.SetUserID(v)
  45800. return nil
  45801. case wxcardvisit.FieldBotID:
  45802. v, ok := value.(uint64)
  45803. if !ok {
  45804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45805. }
  45806. m.SetBotID(v)
  45807. return nil
  45808. case wxcardvisit.FieldBotType:
  45809. v, ok := value.(uint8)
  45810. if !ok {
  45811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45812. }
  45813. m.SetBotType(v)
  45814. return nil
  45815. }
  45816. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45817. }
  45818. // AddedFields returns all numeric fields that were incremented/decremented during
  45819. // this mutation.
  45820. func (m *WxCardVisitMutation) AddedFields() []string {
  45821. var fields []string
  45822. if m.adduser_id != nil {
  45823. fields = append(fields, wxcardvisit.FieldUserID)
  45824. }
  45825. if m.addbot_id != nil {
  45826. fields = append(fields, wxcardvisit.FieldBotID)
  45827. }
  45828. if m.addbot_type != nil {
  45829. fields = append(fields, wxcardvisit.FieldBotType)
  45830. }
  45831. return fields
  45832. }
  45833. // AddedField returns the numeric value that was incremented/decremented on a field
  45834. // with the given name. The second boolean return value indicates that this field
  45835. // was not set, or was not defined in the schema.
  45836. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  45837. switch name {
  45838. case wxcardvisit.FieldUserID:
  45839. return m.AddedUserID()
  45840. case wxcardvisit.FieldBotID:
  45841. return m.AddedBotID()
  45842. case wxcardvisit.FieldBotType:
  45843. return m.AddedBotType()
  45844. }
  45845. return nil, false
  45846. }
  45847. // AddField adds the value to the field with the given name. It returns an error if
  45848. // the field is not defined in the schema, or if the type mismatched the field
  45849. // type.
  45850. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  45851. switch name {
  45852. case wxcardvisit.FieldUserID:
  45853. v, ok := value.(int64)
  45854. if !ok {
  45855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45856. }
  45857. m.AddUserID(v)
  45858. return nil
  45859. case wxcardvisit.FieldBotID:
  45860. v, ok := value.(int64)
  45861. if !ok {
  45862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45863. }
  45864. m.AddBotID(v)
  45865. return nil
  45866. case wxcardvisit.FieldBotType:
  45867. v, ok := value.(int8)
  45868. if !ok {
  45869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45870. }
  45871. m.AddBotType(v)
  45872. return nil
  45873. }
  45874. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  45875. }
  45876. // ClearedFields returns all nullable fields that were cleared during this
  45877. // mutation.
  45878. func (m *WxCardVisitMutation) ClearedFields() []string {
  45879. var fields []string
  45880. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  45881. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45882. }
  45883. if m.FieldCleared(wxcardvisit.FieldUserID) {
  45884. fields = append(fields, wxcardvisit.FieldUserID)
  45885. }
  45886. return fields
  45887. }
  45888. // FieldCleared returns a boolean indicating if a field with the given name was
  45889. // cleared in this mutation.
  45890. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  45891. _, ok := m.clearedFields[name]
  45892. return ok
  45893. }
  45894. // ClearField clears the value of the field with the given name. It returns an
  45895. // error if the field is not defined in the schema.
  45896. func (m *WxCardVisitMutation) ClearField(name string) error {
  45897. switch name {
  45898. case wxcardvisit.FieldDeletedAt:
  45899. m.ClearDeletedAt()
  45900. return nil
  45901. case wxcardvisit.FieldUserID:
  45902. m.ClearUserID()
  45903. return nil
  45904. }
  45905. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  45906. }
  45907. // ResetField resets all changes in the mutation for the field with the given name.
  45908. // It returns an error if the field is not defined in the schema.
  45909. func (m *WxCardVisitMutation) ResetField(name string) error {
  45910. switch name {
  45911. case wxcardvisit.FieldCreatedAt:
  45912. m.ResetCreatedAt()
  45913. return nil
  45914. case wxcardvisit.FieldUpdatedAt:
  45915. m.ResetUpdatedAt()
  45916. return nil
  45917. case wxcardvisit.FieldDeletedAt:
  45918. m.ResetDeletedAt()
  45919. return nil
  45920. case wxcardvisit.FieldUserID:
  45921. m.ResetUserID()
  45922. return nil
  45923. case wxcardvisit.FieldBotID:
  45924. m.ResetBotID()
  45925. return nil
  45926. case wxcardvisit.FieldBotType:
  45927. m.ResetBotType()
  45928. return nil
  45929. }
  45930. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45931. }
  45932. // AddedEdges returns all edge names that were set/added in this mutation.
  45933. func (m *WxCardVisitMutation) AddedEdges() []string {
  45934. edges := make([]string, 0, 0)
  45935. return edges
  45936. }
  45937. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45938. // name in this mutation.
  45939. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  45940. return nil
  45941. }
  45942. // RemovedEdges returns all edge names that were removed in this mutation.
  45943. func (m *WxCardVisitMutation) RemovedEdges() []string {
  45944. edges := make([]string, 0, 0)
  45945. return edges
  45946. }
  45947. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45948. // the given name in this mutation.
  45949. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  45950. return nil
  45951. }
  45952. // ClearedEdges returns all edge names that were cleared in this mutation.
  45953. func (m *WxCardVisitMutation) ClearedEdges() []string {
  45954. edges := make([]string, 0, 0)
  45955. return edges
  45956. }
  45957. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45958. // was cleared in this mutation.
  45959. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  45960. return false
  45961. }
  45962. // ClearEdge clears the value of the edge with the given name. It returns an error
  45963. // if that edge is not defined in the schema.
  45964. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  45965. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  45966. }
  45967. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45968. // It returns an error if the edge is not defined in the schema.
  45969. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  45970. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  45971. }
  45972. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  45973. type XunjiMutation struct {
  45974. config
  45975. op Op
  45976. typ string
  45977. id *uint64
  45978. created_at *time.Time
  45979. updated_at *time.Time
  45980. status *uint8
  45981. addstatus *int8
  45982. deleted_at *time.Time
  45983. app_key *string
  45984. app_secret *string
  45985. token *string
  45986. encoding_key *string
  45987. organization_id *uint64
  45988. addorganization_id *int64
  45989. clearedFields map[string]struct{}
  45990. done bool
  45991. oldValue func(context.Context) (*Xunji, error)
  45992. predicates []predicate.Xunji
  45993. }
  45994. var _ ent.Mutation = (*XunjiMutation)(nil)
  45995. // xunjiOption allows management of the mutation configuration using functional options.
  45996. type xunjiOption func(*XunjiMutation)
  45997. // newXunjiMutation creates new mutation for the Xunji entity.
  45998. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  45999. m := &XunjiMutation{
  46000. config: c,
  46001. op: op,
  46002. typ: TypeXunji,
  46003. clearedFields: make(map[string]struct{}),
  46004. }
  46005. for _, opt := range opts {
  46006. opt(m)
  46007. }
  46008. return m
  46009. }
  46010. // withXunjiID sets the ID field of the mutation.
  46011. func withXunjiID(id uint64) xunjiOption {
  46012. return func(m *XunjiMutation) {
  46013. var (
  46014. err error
  46015. once sync.Once
  46016. value *Xunji
  46017. )
  46018. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  46019. once.Do(func() {
  46020. if m.done {
  46021. err = errors.New("querying old values post mutation is not allowed")
  46022. } else {
  46023. value, err = m.Client().Xunji.Get(ctx, id)
  46024. }
  46025. })
  46026. return value, err
  46027. }
  46028. m.id = &id
  46029. }
  46030. }
  46031. // withXunji sets the old Xunji of the mutation.
  46032. func withXunji(node *Xunji) xunjiOption {
  46033. return func(m *XunjiMutation) {
  46034. m.oldValue = func(context.Context) (*Xunji, error) {
  46035. return node, nil
  46036. }
  46037. m.id = &node.ID
  46038. }
  46039. }
  46040. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46041. // executed in a transaction (ent.Tx), a transactional client is returned.
  46042. func (m XunjiMutation) Client() *Client {
  46043. client := &Client{config: m.config}
  46044. client.init()
  46045. return client
  46046. }
  46047. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46048. // it returns an error otherwise.
  46049. func (m XunjiMutation) Tx() (*Tx, error) {
  46050. if _, ok := m.driver.(*txDriver); !ok {
  46051. return nil, errors.New("ent: mutation is not running in a transaction")
  46052. }
  46053. tx := &Tx{config: m.config}
  46054. tx.init()
  46055. return tx, nil
  46056. }
  46057. // SetID sets the value of the id field. Note that this
  46058. // operation is only accepted on creation of Xunji entities.
  46059. func (m *XunjiMutation) SetID(id uint64) {
  46060. m.id = &id
  46061. }
  46062. // ID returns the ID value in the mutation. Note that the ID is only available
  46063. // if it was provided to the builder or after it was returned from the database.
  46064. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  46065. if m.id == nil {
  46066. return
  46067. }
  46068. return *m.id, true
  46069. }
  46070. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46071. // That means, if the mutation is applied within a transaction with an isolation level such
  46072. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46073. // or updated by the mutation.
  46074. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  46075. switch {
  46076. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46077. id, exists := m.ID()
  46078. if exists {
  46079. return []uint64{id}, nil
  46080. }
  46081. fallthrough
  46082. case m.op.Is(OpUpdate | OpDelete):
  46083. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  46084. default:
  46085. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46086. }
  46087. }
  46088. // SetCreatedAt sets the "created_at" field.
  46089. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  46090. m.created_at = &t
  46091. }
  46092. // CreatedAt returns the value of the "created_at" field in the mutation.
  46093. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  46094. v := m.created_at
  46095. if v == nil {
  46096. return
  46097. }
  46098. return *v, true
  46099. }
  46100. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  46101. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46103. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46104. if !m.op.Is(OpUpdateOne) {
  46105. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46106. }
  46107. if m.id == nil || m.oldValue == nil {
  46108. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46109. }
  46110. oldValue, err := m.oldValue(ctx)
  46111. if err != nil {
  46112. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46113. }
  46114. return oldValue.CreatedAt, nil
  46115. }
  46116. // ResetCreatedAt resets all changes to the "created_at" field.
  46117. func (m *XunjiMutation) ResetCreatedAt() {
  46118. m.created_at = nil
  46119. }
  46120. // SetUpdatedAt sets the "updated_at" field.
  46121. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  46122. m.updated_at = &t
  46123. }
  46124. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46125. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  46126. v := m.updated_at
  46127. if v == nil {
  46128. return
  46129. }
  46130. return *v, true
  46131. }
  46132. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  46133. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46135. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46136. if !m.op.Is(OpUpdateOne) {
  46137. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46138. }
  46139. if m.id == nil || m.oldValue == nil {
  46140. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46141. }
  46142. oldValue, err := m.oldValue(ctx)
  46143. if err != nil {
  46144. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46145. }
  46146. return oldValue.UpdatedAt, nil
  46147. }
  46148. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46149. func (m *XunjiMutation) ResetUpdatedAt() {
  46150. m.updated_at = nil
  46151. }
  46152. // SetStatus sets the "status" field.
  46153. func (m *XunjiMutation) SetStatus(u uint8) {
  46154. m.status = &u
  46155. m.addstatus = nil
  46156. }
  46157. // Status returns the value of the "status" field in the mutation.
  46158. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  46159. v := m.status
  46160. if v == nil {
  46161. return
  46162. }
  46163. return *v, true
  46164. }
  46165. // OldStatus returns the old "status" field's value of the Xunji entity.
  46166. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46168. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46169. if !m.op.Is(OpUpdateOne) {
  46170. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46171. }
  46172. if m.id == nil || m.oldValue == nil {
  46173. return v, errors.New("OldStatus requires an ID field in the mutation")
  46174. }
  46175. oldValue, err := m.oldValue(ctx)
  46176. if err != nil {
  46177. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46178. }
  46179. return oldValue.Status, nil
  46180. }
  46181. // AddStatus adds u to the "status" field.
  46182. func (m *XunjiMutation) AddStatus(u int8) {
  46183. if m.addstatus != nil {
  46184. *m.addstatus += u
  46185. } else {
  46186. m.addstatus = &u
  46187. }
  46188. }
  46189. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46190. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  46191. v := m.addstatus
  46192. if v == nil {
  46193. return
  46194. }
  46195. return *v, true
  46196. }
  46197. // ClearStatus clears the value of the "status" field.
  46198. func (m *XunjiMutation) ClearStatus() {
  46199. m.status = nil
  46200. m.addstatus = nil
  46201. m.clearedFields[xunji.FieldStatus] = struct{}{}
  46202. }
  46203. // StatusCleared returns if the "status" field was cleared in this mutation.
  46204. func (m *XunjiMutation) StatusCleared() bool {
  46205. _, ok := m.clearedFields[xunji.FieldStatus]
  46206. return ok
  46207. }
  46208. // ResetStatus resets all changes to the "status" field.
  46209. func (m *XunjiMutation) ResetStatus() {
  46210. m.status = nil
  46211. m.addstatus = nil
  46212. delete(m.clearedFields, xunji.FieldStatus)
  46213. }
  46214. // SetDeletedAt sets the "deleted_at" field.
  46215. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  46216. m.deleted_at = &t
  46217. }
  46218. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46219. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  46220. v := m.deleted_at
  46221. if v == nil {
  46222. return
  46223. }
  46224. return *v, true
  46225. }
  46226. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  46227. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46229. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46230. if !m.op.Is(OpUpdateOne) {
  46231. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46232. }
  46233. if m.id == nil || m.oldValue == nil {
  46234. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46235. }
  46236. oldValue, err := m.oldValue(ctx)
  46237. if err != nil {
  46238. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46239. }
  46240. return oldValue.DeletedAt, nil
  46241. }
  46242. // ClearDeletedAt clears the value of the "deleted_at" field.
  46243. func (m *XunjiMutation) ClearDeletedAt() {
  46244. m.deleted_at = nil
  46245. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  46246. }
  46247. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46248. func (m *XunjiMutation) DeletedAtCleared() bool {
  46249. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  46250. return ok
  46251. }
  46252. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46253. func (m *XunjiMutation) ResetDeletedAt() {
  46254. m.deleted_at = nil
  46255. delete(m.clearedFields, xunji.FieldDeletedAt)
  46256. }
  46257. // SetAppKey sets the "app_key" field.
  46258. func (m *XunjiMutation) SetAppKey(s string) {
  46259. m.app_key = &s
  46260. }
  46261. // AppKey returns the value of the "app_key" field in the mutation.
  46262. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  46263. v := m.app_key
  46264. if v == nil {
  46265. return
  46266. }
  46267. return *v, true
  46268. }
  46269. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  46270. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46272. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  46273. if !m.op.Is(OpUpdateOne) {
  46274. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  46275. }
  46276. if m.id == nil || m.oldValue == nil {
  46277. return v, errors.New("OldAppKey requires an ID field in the mutation")
  46278. }
  46279. oldValue, err := m.oldValue(ctx)
  46280. if err != nil {
  46281. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  46282. }
  46283. return oldValue.AppKey, nil
  46284. }
  46285. // ClearAppKey clears the value of the "app_key" field.
  46286. func (m *XunjiMutation) ClearAppKey() {
  46287. m.app_key = nil
  46288. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  46289. }
  46290. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  46291. func (m *XunjiMutation) AppKeyCleared() bool {
  46292. _, ok := m.clearedFields[xunji.FieldAppKey]
  46293. return ok
  46294. }
  46295. // ResetAppKey resets all changes to the "app_key" field.
  46296. func (m *XunjiMutation) ResetAppKey() {
  46297. m.app_key = nil
  46298. delete(m.clearedFields, xunji.FieldAppKey)
  46299. }
  46300. // SetAppSecret sets the "app_secret" field.
  46301. func (m *XunjiMutation) SetAppSecret(s string) {
  46302. m.app_secret = &s
  46303. }
  46304. // AppSecret returns the value of the "app_secret" field in the mutation.
  46305. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  46306. v := m.app_secret
  46307. if v == nil {
  46308. return
  46309. }
  46310. return *v, true
  46311. }
  46312. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  46313. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46315. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  46316. if !m.op.Is(OpUpdateOne) {
  46317. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  46318. }
  46319. if m.id == nil || m.oldValue == nil {
  46320. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  46321. }
  46322. oldValue, err := m.oldValue(ctx)
  46323. if err != nil {
  46324. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  46325. }
  46326. return oldValue.AppSecret, nil
  46327. }
  46328. // ClearAppSecret clears the value of the "app_secret" field.
  46329. func (m *XunjiMutation) ClearAppSecret() {
  46330. m.app_secret = nil
  46331. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  46332. }
  46333. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  46334. func (m *XunjiMutation) AppSecretCleared() bool {
  46335. _, ok := m.clearedFields[xunji.FieldAppSecret]
  46336. return ok
  46337. }
  46338. // ResetAppSecret resets all changes to the "app_secret" field.
  46339. func (m *XunjiMutation) ResetAppSecret() {
  46340. m.app_secret = nil
  46341. delete(m.clearedFields, xunji.FieldAppSecret)
  46342. }
  46343. // SetToken sets the "token" field.
  46344. func (m *XunjiMutation) SetToken(s string) {
  46345. m.token = &s
  46346. }
  46347. // Token returns the value of the "token" field in the mutation.
  46348. func (m *XunjiMutation) Token() (r string, exists bool) {
  46349. v := m.token
  46350. if v == nil {
  46351. return
  46352. }
  46353. return *v, true
  46354. }
  46355. // OldToken returns the old "token" field's value of the Xunji entity.
  46356. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46358. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  46359. if !m.op.Is(OpUpdateOne) {
  46360. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  46361. }
  46362. if m.id == nil || m.oldValue == nil {
  46363. return v, errors.New("OldToken requires an ID field in the mutation")
  46364. }
  46365. oldValue, err := m.oldValue(ctx)
  46366. if err != nil {
  46367. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  46368. }
  46369. return oldValue.Token, nil
  46370. }
  46371. // ClearToken clears the value of the "token" field.
  46372. func (m *XunjiMutation) ClearToken() {
  46373. m.token = nil
  46374. m.clearedFields[xunji.FieldToken] = struct{}{}
  46375. }
  46376. // TokenCleared returns if the "token" field was cleared in this mutation.
  46377. func (m *XunjiMutation) TokenCleared() bool {
  46378. _, ok := m.clearedFields[xunji.FieldToken]
  46379. return ok
  46380. }
  46381. // ResetToken resets all changes to the "token" field.
  46382. func (m *XunjiMutation) ResetToken() {
  46383. m.token = nil
  46384. delete(m.clearedFields, xunji.FieldToken)
  46385. }
  46386. // SetEncodingKey sets the "encoding_key" field.
  46387. func (m *XunjiMutation) SetEncodingKey(s string) {
  46388. m.encoding_key = &s
  46389. }
  46390. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  46391. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  46392. v := m.encoding_key
  46393. if v == nil {
  46394. return
  46395. }
  46396. return *v, true
  46397. }
  46398. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  46399. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46401. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  46402. if !m.op.Is(OpUpdateOne) {
  46403. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  46404. }
  46405. if m.id == nil || m.oldValue == nil {
  46406. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  46407. }
  46408. oldValue, err := m.oldValue(ctx)
  46409. if err != nil {
  46410. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  46411. }
  46412. return oldValue.EncodingKey, nil
  46413. }
  46414. // ClearEncodingKey clears the value of the "encoding_key" field.
  46415. func (m *XunjiMutation) ClearEncodingKey() {
  46416. m.encoding_key = nil
  46417. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  46418. }
  46419. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  46420. func (m *XunjiMutation) EncodingKeyCleared() bool {
  46421. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  46422. return ok
  46423. }
  46424. // ResetEncodingKey resets all changes to the "encoding_key" field.
  46425. func (m *XunjiMutation) ResetEncodingKey() {
  46426. m.encoding_key = nil
  46427. delete(m.clearedFields, xunji.FieldEncodingKey)
  46428. }
  46429. // SetOrganizationID sets the "organization_id" field.
  46430. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  46431. m.organization_id = &u
  46432. m.addorganization_id = nil
  46433. }
  46434. // OrganizationID returns the value of the "organization_id" field in the mutation.
  46435. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  46436. v := m.organization_id
  46437. if v == nil {
  46438. return
  46439. }
  46440. return *v, true
  46441. }
  46442. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  46443. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  46444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46445. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  46446. if !m.op.Is(OpUpdateOne) {
  46447. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  46448. }
  46449. if m.id == nil || m.oldValue == nil {
  46450. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  46451. }
  46452. oldValue, err := m.oldValue(ctx)
  46453. if err != nil {
  46454. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  46455. }
  46456. return oldValue.OrganizationID, nil
  46457. }
  46458. // AddOrganizationID adds u to the "organization_id" field.
  46459. func (m *XunjiMutation) AddOrganizationID(u int64) {
  46460. if m.addorganization_id != nil {
  46461. *m.addorganization_id += u
  46462. } else {
  46463. m.addorganization_id = &u
  46464. }
  46465. }
  46466. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  46467. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  46468. v := m.addorganization_id
  46469. if v == nil {
  46470. return
  46471. }
  46472. return *v, true
  46473. }
  46474. // ResetOrganizationID resets all changes to the "organization_id" field.
  46475. func (m *XunjiMutation) ResetOrganizationID() {
  46476. m.organization_id = nil
  46477. m.addorganization_id = nil
  46478. }
  46479. // Where appends a list predicates to the XunjiMutation builder.
  46480. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  46481. m.predicates = append(m.predicates, ps...)
  46482. }
  46483. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  46484. // users can use type-assertion to append predicates that do not depend on any generated package.
  46485. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  46486. p := make([]predicate.Xunji, len(ps))
  46487. for i := range ps {
  46488. p[i] = ps[i]
  46489. }
  46490. m.Where(p...)
  46491. }
  46492. // Op returns the operation name.
  46493. func (m *XunjiMutation) Op() Op {
  46494. return m.op
  46495. }
  46496. // SetOp allows setting the mutation operation.
  46497. func (m *XunjiMutation) SetOp(op Op) {
  46498. m.op = op
  46499. }
  46500. // Type returns the node type of this mutation (Xunji).
  46501. func (m *XunjiMutation) Type() string {
  46502. return m.typ
  46503. }
  46504. // Fields returns all fields that were changed during this mutation. Note that in
  46505. // order to get all numeric fields that were incremented/decremented, call
  46506. // AddedFields().
  46507. func (m *XunjiMutation) Fields() []string {
  46508. fields := make([]string, 0, 9)
  46509. if m.created_at != nil {
  46510. fields = append(fields, xunji.FieldCreatedAt)
  46511. }
  46512. if m.updated_at != nil {
  46513. fields = append(fields, xunji.FieldUpdatedAt)
  46514. }
  46515. if m.status != nil {
  46516. fields = append(fields, xunji.FieldStatus)
  46517. }
  46518. if m.deleted_at != nil {
  46519. fields = append(fields, xunji.FieldDeletedAt)
  46520. }
  46521. if m.app_key != nil {
  46522. fields = append(fields, xunji.FieldAppKey)
  46523. }
  46524. if m.app_secret != nil {
  46525. fields = append(fields, xunji.FieldAppSecret)
  46526. }
  46527. if m.token != nil {
  46528. fields = append(fields, xunji.FieldToken)
  46529. }
  46530. if m.encoding_key != nil {
  46531. fields = append(fields, xunji.FieldEncodingKey)
  46532. }
  46533. if m.organization_id != nil {
  46534. fields = append(fields, xunji.FieldOrganizationID)
  46535. }
  46536. return fields
  46537. }
  46538. // Field returns the value of a field with the given name. The second boolean
  46539. // return value indicates that this field was not set, or was not defined in the
  46540. // schema.
  46541. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  46542. switch name {
  46543. case xunji.FieldCreatedAt:
  46544. return m.CreatedAt()
  46545. case xunji.FieldUpdatedAt:
  46546. return m.UpdatedAt()
  46547. case xunji.FieldStatus:
  46548. return m.Status()
  46549. case xunji.FieldDeletedAt:
  46550. return m.DeletedAt()
  46551. case xunji.FieldAppKey:
  46552. return m.AppKey()
  46553. case xunji.FieldAppSecret:
  46554. return m.AppSecret()
  46555. case xunji.FieldToken:
  46556. return m.Token()
  46557. case xunji.FieldEncodingKey:
  46558. return m.EncodingKey()
  46559. case xunji.FieldOrganizationID:
  46560. return m.OrganizationID()
  46561. }
  46562. return nil, false
  46563. }
  46564. // OldField returns the old value of the field from the database. An error is
  46565. // returned if the mutation operation is not UpdateOne, or the query to the
  46566. // database failed.
  46567. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46568. switch name {
  46569. case xunji.FieldCreatedAt:
  46570. return m.OldCreatedAt(ctx)
  46571. case xunji.FieldUpdatedAt:
  46572. return m.OldUpdatedAt(ctx)
  46573. case xunji.FieldStatus:
  46574. return m.OldStatus(ctx)
  46575. case xunji.FieldDeletedAt:
  46576. return m.OldDeletedAt(ctx)
  46577. case xunji.FieldAppKey:
  46578. return m.OldAppKey(ctx)
  46579. case xunji.FieldAppSecret:
  46580. return m.OldAppSecret(ctx)
  46581. case xunji.FieldToken:
  46582. return m.OldToken(ctx)
  46583. case xunji.FieldEncodingKey:
  46584. return m.OldEncodingKey(ctx)
  46585. case xunji.FieldOrganizationID:
  46586. return m.OldOrganizationID(ctx)
  46587. }
  46588. return nil, fmt.Errorf("unknown Xunji field %s", name)
  46589. }
  46590. // SetField sets the value of a field with the given name. It returns an error if
  46591. // the field is not defined in the schema, or if the type mismatched the field
  46592. // type.
  46593. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  46594. switch name {
  46595. case xunji.FieldCreatedAt:
  46596. v, ok := value.(time.Time)
  46597. if !ok {
  46598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46599. }
  46600. m.SetCreatedAt(v)
  46601. return nil
  46602. case xunji.FieldUpdatedAt:
  46603. v, ok := value.(time.Time)
  46604. if !ok {
  46605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46606. }
  46607. m.SetUpdatedAt(v)
  46608. return nil
  46609. case xunji.FieldStatus:
  46610. v, ok := value.(uint8)
  46611. if !ok {
  46612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46613. }
  46614. m.SetStatus(v)
  46615. return nil
  46616. case xunji.FieldDeletedAt:
  46617. v, ok := value.(time.Time)
  46618. if !ok {
  46619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46620. }
  46621. m.SetDeletedAt(v)
  46622. return nil
  46623. case xunji.FieldAppKey:
  46624. v, ok := value.(string)
  46625. if !ok {
  46626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46627. }
  46628. m.SetAppKey(v)
  46629. return nil
  46630. case xunji.FieldAppSecret:
  46631. v, ok := value.(string)
  46632. if !ok {
  46633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46634. }
  46635. m.SetAppSecret(v)
  46636. return nil
  46637. case xunji.FieldToken:
  46638. v, ok := value.(string)
  46639. if !ok {
  46640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46641. }
  46642. m.SetToken(v)
  46643. return nil
  46644. case xunji.FieldEncodingKey:
  46645. v, ok := value.(string)
  46646. if !ok {
  46647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46648. }
  46649. m.SetEncodingKey(v)
  46650. return nil
  46651. case xunji.FieldOrganizationID:
  46652. v, ok := value.(uint64)
  46653. if !ok {
  46654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46655. }
  46656. m.SetOrganizationID(v)
  46657. return nil
  46658. }
  46659. return fmt.Errorf("unknown Xunji field %s", name)
  46660. }
  46661. // AddedFields returns all numeric fields that were incremented/decremented during
  46662. // this mutation.
  46663. func (m *XunjiMutation) AddedFields() []string {
  46664. var fields []string
  46665. if m.addstatus != nil {
  46666. fields = append(fields, xunji.FieldStatus)
  46667. }
  46668. if m.addorganization_id != nil {
  46669. fields = append(fields, xunji.FieldOrganizationID)
  46670. }
  46671. return fields
  46672. }
  46673. // AddedField returns the numeric value that was incremented/decremented on a field
  46674. // with the given name. The second boolean return value indicates that this field
  46675. // was not set, or was not defined in the schema.
  46676. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  46677. switch name {
  46678. case xunji.FieldStatus:
  46679. return m.AddedStatus()
  46680. case xunji.FieldOrganizationID:
  46681. return m.AddedOrganizationID()
  46682. }
  46683. return nil, false
  46684. }
  46685. // AddField adds the value to the field with the given name. It returns an error if
  46686. // the field is not defined in the schema, or if the type mismatched the field
  46687. // type.
  46688. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  46689. switch name {
  46690. case xunji.FieldStatus:
  46691. v, ok := value.(int8)
  46692. if !ok {
  46693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46694. }
  46695. m.AddStatus(v)
  46696. return nil
  46697. case xunji.FieldOrganizationID:
  46698. v, ok := value.(int64)
  46699. if !ok {
  46700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46701. }
  46702. m.AddOrganizationID(v)
  46703. return nil
  46704. }
  46705. return fmt.Errorf("unknown Xunji numeric field %s", name)
  46706. }
  46707. // ClearedFields returns all nullable fields that were cleared during this
  46708. // mutation.
  46709. func (m *XunjiMutation) ClearedFields() []string {
  46710. var fields []string
  46711. if m.FieldCleared(xunji.FieldStatus) {
  46712. fields = append(fields, xunji.FieldStatus)
  46713. }
  46714. if m.FieldCleared(xunji.FieldDeletedAt) {
  46715. fields = append(fields, xunji.FieldDeletedAt)
  46716. }
  46717. if m.FieldCleared(xunji.FieldAppKey) {
  46718. fields = append(fields, xunji.FieldAppKey)
  46719. }
  46720. if m.FieldCleared(xunji.FieldAppSecret) {
  46721. fields = append(fields, xunji.FieldAppSecret)
  46722. }
  46723. if m.FieldCleared(xunji.FieldToken) {
  46724. fields = append(fields, xunji.FieldToken)
  46725. }
  46726. if m.FieldCleared(xunji.FieldEncodingKey) {
  46727. fields = append(fields, xunji.FieldEncodingKey)
  46728. }
  46729. return fields
  46730. }
  46731. // FieldCleared returns a boolean indicating if a field with the given name was
  46732. // cleared in this mutation.
  46733. func (m *XunjiMutation) FieldCleared(name string) bool {
  46734. _, ok := m.clearedFields[name]
  46735. return ok
  46736. }
  46737. // ClearField clears the value of the field with the given name. It returns an
  46738. // error if the field is not defined in the schema.
  46739. func (m *XunjiMutation) ClearField(name string) error {
  46740. switch name {
  46741. case xunji.FieldStatus:
  46742. m.ClearStatus()
  46743. return nil
  46744. case xunji.FieldDeletedAt:
  46745. m.ClearDeletedAt()
  46746. return nil
  46747. case xunji.FieldAppKey:
  46748. m.ClearAppKey()
  46749. return nil
  46750. case xunji.FieldAppSecret:
  46751. m.ClearAppSecret()
  46752. return nil
  46753. case xunji.FieldToken:
  46754. m.ClearToken()
  46755. return nil
  46756. case xunji.FieldEncodingKey:
  46757. m.ClearEncodingKey()
  46758. return nil
  46759. }
  46760. return fmt.Errorf("unknown Xunji nullable field %s", name)
  46761. }
  46762. // ResetField resets all changes in the mutation for the field with the given name.
  46763. // It returns an error if the field is not defined in the schema.
  46764. func (m *XunjiMutation) ResetField(name string) error {
  46765. switch name {
  46766. case xunji.FieldCreatedAt:
  46767. m.ResetCreatedAt()
  46768. return nil
  46769. case xunji.FieldUpdatedAt:
  46770. m.ResetUpdatedAt()
  46771. return nil
  46772. case xunji.FieldStatus:
  46773. m.ResetStatus()
  46774. return nil
  46775. case xunji.FieldDeletedAt:
  46776. m.ResetDeletedAt()
  46777. return nil
  46778. case xunji.FieldAppKey:
  46779. m.ResetAppKey()
  46780. return nil
  46781. case xunji.FieldAppSecret:
  46782. m.ResetAppSecret()
  46783. return nil
  46784. case xunji.FieldToken:
  46785. m.ResetToken()
  46786. return nil
  46787. case xunji.FieldEncodingKey:
  46788. m.ResetEncodingKey()
  46789. return nil
  46790. case xunji.FieldOrganizationID:
  46791. m.ResetOrganizationID()
  46792. return nil
  46793. }
  46794. return fmt.Errorf("unknown Xunji field %s", name)
  46795. }
  46796. // AddedEdges returns all edge names that were set/added in this mutation.
  46797. func (m *XunjiMutation) AddedEdges() []string {
  46798. edges := make([]string, 0, 0)
  46799. return edges
  46800. }
  46801. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46802. // name in this mutation.
  46803. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  46804. return nil
  46805. }
  46806. // RemovedEdges returns all edge names that were removed in this mutation.
  46807. func (m *XunjiMutation) RemovedEdges() []string {
  46808. edges := make([]string, 0, 0)
  46809. return edges
  46810. }
  46811. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46812. // the given name in this mutation.
  46813. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  46814. return nil
  46815. }
  46816. // ClearedEdges returns all edge names that were cleared in this mutation.
  46817. func (m *XunjiMutation) ClearedEdges() []string {
  46818. edges := make([]string, 0, 0)
  46819. return edges
  46820. }
  46821. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46822. // was cleared in this mutation.
  46823. func (m *XunjiMutation) EdgeCleared(name string) bool {
  46824. return false
  46825. }
  46826. // ClearEdge clears the value of the edge with the given name. It returns an error
  46827. // if that edge is not defined in the schema.
  46828. func (m *XunjiMutation) ClearEdge(name string) error {
  46829. return fmt.Errorf("unknown Xunji unique edge %s", name)
  46830. }
  46831. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46832. // It returns an error if the edge is not defined in the schema.
  46833. func (m *XunjiMutation) ResetEdge(name string) error {
  46834. return fmt.Errorf("unknown Xunji edge %s", name)
  46835. }
  46836. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  46837. type XunjiServiceMutation struct {
  46838. config
  46839. op Op
  46840. typ string
  46841. id *uint64
  46842. created_at *time.Time
  46843. updated_at *time.Time
  46844. status *uint8
  46845. addstatus *int8
  46846. deleted_at *time.Time
  46847. xunji_id *uint64
  46848. addxunji_id *int64
  46849. organization_id *uint64
  46850. addorganization_id *int64
  46851. wxid *string
  46852. api_base *string
  46853. api_key *string
  46854. clearedFields map[string]struct{}
  46855. agent *uint64
  46856. clearedagent bool
  46857. done bool
  46858. oldValue func(context.Context) (*XunjiService, error)
  46859. predicates []predicate.XunjiService
  46860. }
  46861. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  46862. // xunjiserviceOption allows management of the mutation configuration using functional options.
  46863. type xunjiserviceOption func(*XunjiServiceMutation)
  46864. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  46865. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  46866. m := &XunjiServiceMutation{
  46867. config: c,
  46868. op: op,
  46869. typ: TypeXunjiService,
  46870. clearedFields: make(map[string]struct{}),
  46871. }
  46872. for _, opt := range opts {
  46873. opt(m)
  46874. }
  46875. return m
  46876. }
  46877. // withXunjiServiceID sets the ID field of the mutation.
  46878. func withXunjiServiceID(id uint64) xunjiserviceOption {
  46879. return func(m *XunjiServiceMutation) {
  46880. var (
  46881. err error
  46882. once sync.Once
  46883. value *XunjiService
  46884. )
  46885. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  46886. once.Do(func() {
  46887. if m.done {
  46888. err = errors.New("querying old values post mutation is not allowed")
  46889. } else {
  46890. value, err = m.Client().XunjiService.Get(ctx, id)
  46891. }
  46892. })
  46893. return value, err
  46894. }
  46895. m.id = &id
  46896. }
  46897. }
  46898. // withXunjiService sets the old XunjiService of the mutation.
  46899. func withXunjiService(node *XunjiService) xunjiserviceOption {
  46900. return func(m *XunjiServiceMutation) {
  46901. m.oldValue = func(context.Context) (*XunjiService, error) {
  46902. return node, nil
  46903. }
  46904. m.id = &node.ID
  46905. }
  46906. }
  46907. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46908. // executed in a transaction (ent.Tx), a transactional client is returned.
  46909. func (m XunjiServiceMutation) Client() *Client {
  46910. client := &Client{config: m.config}
  46911. client.init()
  46912. return client
  46913. }
  46914. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46915. // it returns an error otherwise.
  46916. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  46917. if _, ok := m.driver.(*txDriver); !ok {
  46918. return nil, errors.New("ent: mutation is not running in a transaction")
  46919. }
  46920. tx := &Tx{config: m.config}
  46921. tx.init()
  46922. return tx, nil
  46923. }
  46924. // SetID sets the value of the id field. Note that this
  46925. // operation is only accepted on creation of XunjiService entities.
  46926. func (m *XunjiServiceMutation) SetID(id uint64) {
  46927. m.id = &id
  46928. }
  46929. // ID returns the ID value in the mutation. Note that the ID is only available
  46930. // if it was provided to the builder or after it was returned from the database.
  46931. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  46932. if m.id == nil {
  46933. return
  46934. }
  46935. return *m.id, true
  46936. }
  46937. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46938. // That means, if the mutation is applied within a transaction with an isolation level such
  46939. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46940. // or updated by the mutation.
  46941. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  46942. switch {
  46943. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46944. id, exists := m.ID()
  46945. if exists {
  46946. return []uint64{id}, nil
  46947. }
  46948. fallthrough
  46949. case m.op.Is(OpUpdate | OpDelete):
  46950. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  46951. default:
  46952. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46953. }
  46954. }
  46955. // SetCreatedAt sets the "created_at" field.
  46956. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  46957. m.created_at = &t
  46958. }
  46959. // CreatedAt returns the value of the "created_at" field in the mutation.
  46960. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  46961. v := m.created_at
  46962. if v == nil {
  46963. return
  46964. }
  46965. return *v, true
  46966. }
  46967. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  46968. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  46969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46970. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46971. if !m.op.Is(OpUpdateOne) {
  46972. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46973. }
  46974. if m.id == nil || m.oldValue == nil {
  46975. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46976. }
  46977. oldValue, err := m.oldValue(ctx)
  46978. if err != nil {
  46979. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46980. }
  46981. return oldValue.CreatedAt, nil
  46982. }
  46983. // ResetCreatedAt resets all changes to the "created_at" field.
  46984. func (m *XunjiServiceMutation) ResetCreatedAt() {
  46985. m.created_at = nil
  46986. }
  46987. // SetUpdatedAt sets the "updated_at" field.
  46988. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  46989. m.updated_at = &t
  46990. }
  46991. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46992. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  46993. v := m.updated_at
  46994. if v == nil {
  46995. return
  46996. }
  46997. return *v, true
  46998. }
  46999. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  47000. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47002. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47003. if !m.op.Is(OpUpdateOne) {
  47004. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47005. }
  47006. if m.id == nil || m.oldValue == nil {
  47007. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47008. }
  47009. oldValue, err := m.oldValue(ctx)
  47010. if err != nil {
  47011. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47012. }
  47013. return oldValue.UpdatedAt, nil
  47014. }
  47015. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47016. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  47017. m.updated_at = nil
  47018. }
  47019. // SetStatus sets the "status" field.
  47020. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  47021. m.status = &u
  47022. m.addstatus = nil
  47023. }
  47024. // Status returns the value of the "status" field in the mutation.
  47025. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  47026. v := m.status
  47027. if v == nil {
  47028. return
  47029. }
  47030. return *v, true
  47031. }
  47032. // OldStatus returns the old "status" field's value of the XunjiService entity.
  47033. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47035. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  47036. if !m.op.Is(OpUpdateOne) {
  47037. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  47038. }
  47039. if m.id == nil || m.oldValue == nil {
  47040. return v, errors.New("OldStatus requires an ID field in the mutation")
  47041. }
  47042. oldValue, err := m.oldValue(ctx)
  47043. if err != nil {
  47044. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  47045. }
  47046. return oldValue.Status, nil
  47047. }
  47048. // AddStatus adds u to the "status" field.
  47049. func (m *XunjiServiceMutation) AddStatus(u int8) {
  47050. if m.addstatus != nil {
  47051. *m.addstatus += u
  47052. } else {
  47053. m.addstatus = &u
  47054. }
  47055. }
  47056. // AddedStatus returns the value that was added to the "status" field in this mutation.
  47057. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  47058. v := m.addstatus
  47059. if v == nil {
  47060. return
  47061. }
  47062. return *v, true
  47063. }
  47064. // ClearStatus clears the value of the "status" field.
  47065. func (m *XunjiServiceMutation) ClearStatus() {
  47066. m.status = nil
  47067. m.addstatus = nil
  47068. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  47069. }
  47070. // StatusCleared returns if the "status" field was cleared in this mutation.
  47071. func (m *XunjiServiceMutation) StatusCleared() bool {
  47072. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  47073. return ok
  47074. }
  47075. // ResetStatus resets all changes to the "status" field.
  47076. func (m *XunjiServiceMutation) ResetStatus() {
  47077. m.status = nil
  47078. m.addstatus = nil
  47079. delete(m.clearedFields, xunjiservice.FieldStatus)
  47080. }
  47081. // SetDeletedAt sets the "deleted_at" field.
  47082. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  47083. m.deleted_at = &t
  47084. }
  47085. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47086. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  47087. v := m.deleted_at
  47088. if v == nil {
  47089. return
  47090. }
  47091. return *v, true
  47092. }
  47093. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  47094. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47096. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47097. if !m.op.Is(OpUpdateOne) {
  47098. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47099. }
  47100. if m.id == nil || m.oldValue == nil {
  47101. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47102. }
  47103. oldValue, err := m.oldValue(ctx)
  47104. if err != nil {
  47105. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47106. }
  47107. return oldValue.DeletedAt, nil
  47108. }
  47109. // ClearDeletedAt clears the value of the "deleted_at" field.
  47110. func (m *XunjiServiceMutation) ClearDeletedAt() {
  47111. m.deleted_at = nil
  47112. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  47113. }
  47114. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47115. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  47116. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  47117. return ok
  47118. }
  47119. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47120. func (m *XunjiServiceMutation) ResetDeletedAt() {
  47121. m.deleted_at = nil
  47122. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  47123. }
  47124. // SetXunjiID sets the "xunji_id" field.
  47125. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  47126. m.xunji_id = &u
  47127. m.addxunji_id = nil
  47128. }
  47129. // XunjiID returns the value of the "xunji_id" field in the mutation.
  47130. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  47131. v := m.xunji_id
  47132. if v == nil {
  47133. return
  47134. }
  47135. return *v, true
  47136. }
  47137. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  47138. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47140. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  47141. if !m.op.Is(OpUpdateOne) {
  47142. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  47143. }
  47144. if m.id == nil || m.oldValue == nil {
  47145. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  47146. }
  47147. oldValue, err := m.oldValue(ctx)
  47148. if err != nil {
  47149. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  47150. }
  47151. return oldValue.XunjiID, nil
  47152. }
  47153. // AddXunjiID adds u to the "xunji_id" field.
  47154. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  47155. if m.addxunji_id != nil {
  47156. *m.addxunji_id += u
  47157. } else {
  47158. m.addxunji_id = &u
  47159. }
  47160. }
  47161. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  47162. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  47163. v := m.addxunji_id
  47164. if v == nil {
  47165. return
  47166. }
  47167. return *v, true
  47168. }
  47169. // ResetXunjiID resets all changes to the "xunji_id" field.
  47170. func (m *XunjiServiceMutation) ResetXunjiID() {
  47171. m.xunji_id = nil
  47172. m.addxunji_id = nil
  47173. }
  47174. // SetAgentID sets the "agent_id" field.
  47175. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  47176. m.agent = &u
  47177. }
  47178. // AgentID returns the value of the "agent_id" field in the mutation.
  47179. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  47180. v := m.agent
  47181. if v == nil {
  47182. return
  47183. }
  47184. return *v, true
  47185. }
  47186. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  47187. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47189. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  47190. if !m.op.Is(OpUpdateOne) {
  47191. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  47192. }
  47193. if m.id == nil || m.oldValue == nil {
  47194. return v, errors.New("OldAgentID requires an ID field in the mutation")
  47195. }
  47196. oldValue, err := m.oldValue(ctx)
  47197. if err != nil {
  47198. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  47199. }
  47200. return oldValue.AgentID, nil
  47201. }
  47202. // ResetAgentID resets all changes to the "agent_id" field.
  47203. func (m *XunjiServiceMutation) ResetAgentID() {
  47204. m.agent = nil
  47205. }
  47206. // SetOrganizationID sets the "organization_id" field.
  47207. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  47208. m.organization_id = &u
  47209. m.addorganization_id = nil
  47210. }
  47211. // OrganizationID returns the value of the "organization_id" field in the mutation.
  47212. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  47213. v := m.organization_id
  47214. if v == nil {
  47215. return
  47216. }
  47217. return *v, true
  47218. }
  47219. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  47220. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47222. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  47223. if !m.op.Is(OpUpdateOne) {
  47224. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  47225. }
  47226. if m.id == nil || m.oldValue == nil {
  47227. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  47228. }
  47229. oldValue, err := m.oldValue(ctx)
  47230. if err != nil {
  47231. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  47232. }
  47233. return oldValue.OrganizationID, nil
  47234. }
  47235. // AddOrganizationID adds u to the "organization_id" field.
  47236. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  47237. if m.addorganization_id != nil {
  47238. *m.addorganization_id += u
  47239. } else {
  47240. m.addorganization_id = &u
  47241. }
  47242. }
  47243. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  47244. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  47245. v := m.addorganization_id
  47246. if v == nil {
  47247. return
  47248. }
  47249. return *v, true
  47250. }
  47251. // ResetOrganizationID resets all changes to the "organization_id" field.
  47252. func (m *XunjiServiceMutation) ResetOrganizationID() {
  47253. m.organization_id = nil
  47254. m.addorganization_id = nil
  47255. }
  47256. // SetWxid sets the "wxid" field.
  47257. func (m *XunjiServiceMutation) SetWxid(s string) {
  47258. m.wxid = &s
  47259. }
  47260. // Wxid returns the value of the "wxid" field in the mutation.
  47261. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  47262. v := m.wxid
  47263. if v == nil {
  47264. return
  47265. }
  47266. return *v, true
  47267. }
  47268. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  47269. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47271. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  47272. if !m.op.Is(OpUpdateOne) {
  47273. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  47274. }
  47275. if m.id == nil || m.oldValue == nil {
  47276. return v, errors.New("OldWxid requires an ID field in the mutation")
  47277. }
  47278. oldValue, err := m.oldValue(ctx)
  47279. if err != nil {
  47280. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  47281. }
  47282. return oldValue.Wxid, nil
  47283. }
  47284. // ResetWxid resets all changes to the "wxid" field.
  47285. func (m *XunjiServiceMutation) ResetWxid() {
  47286. m.wxid = nil
  47287. }
  47288. // SetAPIBase sets the "api_base" field.
  47289. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  47290. m.api_base = &s
  47291. }
  47292. // APIBase returns the value of the "api_base" field in the mutation.
  47293. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  47294. v := m.api_base
  47295. if v == nil {
  47296. return
  47297. }
  47298. return *v, true
  47299. }
  47300. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  47301. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47303. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47304. if !m.op.Is(OpUpdateOne) {
  47305. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47306. }
  47307. if m.id == nil || m.oldValue == nil {
  47308. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  47309. }
  47310. oldValue, err := m.oldValue(ctx)
  47311. if err != nil {
  47312. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  47313. }
  47314. return oldValue.APIBase, nil
  47315. }
  47316. // ClearAPIBase clears the value of the "api_base" field.
  47317. func (m *XunjiServiceMutation) ClearAPIBase() {
  47318. m.api_base = nil
  47319. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  47320. }
  47321. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  47322. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  47323. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  47324. return ok
  47325. }
  47326. // ResetAPIBase resets all changes to the "api_base" field.
  47327. func (m *XunjiServiceMutation) ResetAPIBase() {
  47328. m.api_base = nil
  47329. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  47330. }
  47331. // SetAPIKey sets the "api_key" field.
  47332. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  47333. m.api_key = &s
  47334. }
  47335. // APIKey returns the value of the "api_key" field in the mutation.
  47336. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  47337. v := m.api_key
  47338. if v == nil {
  47339. return
  47340. }
  47341. return *v, true
  47342. }
  47343. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  47344. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  47345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47346. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  47347. if !m.op.Is(OpUpdateOne) {
  47348. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  47349. }
  47350. if m.id == nil || m.oldValue == nil {
  47351. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  47352. }
  47353. oldValue, err := m.oldValue(ctx)
  47354. if err != nil {
  47355. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  47356. }
  47357. return oldValue.APIKey, nil
  47358. }
  47359. // ClearAPIKey clears the value of the "api_key" field.
  47360. func (m *XunjiServiceMutation) ClearAPIKey() {
  47361. m.api_key = nil
  47362. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  47363. }
  47364. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  47365. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  47366. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  47367. return ok
  47368. }
  47369. // ResetAPIKey resets all changes to the "api_key" field.
  47370. func (m *XunjiServiceMutation) ResetAPIKey() {
  47371. m.api_key = nil
  47372. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  47373. }
  47374. // ClearAgent clears the "agent" edge to the Agent entity.
  47375. func (m *XunjiServiceMutation) ClearAgent() {
  47376. m.clearedagent = true
  47377. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  47378. }
  47379. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  47380. func (m *XunjiServiceMutation) AgentCleared() bool {
  47381. return m.clearedagent
  47382. }
  47383. // AgentIDs returns the "agent" edge IDs in the mutation.
  47384. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47385. // AgentID instead. It exists only for internal usage by the builders.
  47386. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  47387. if id := m.agent; id != nil {
  47388. ids = append(ids, *id)
  47389. }
  47390. return
  47391. }
  47392. // ResetAgent resets all changes to the "agent" edge.
  47393. func (m *XunjiServiceMutation) ResetAgent() {
  47394. m.agent = nil
  47395. m.clearedagent = false
  47396. }
  47397. // Where appends a list predicates to the XunjiServiceMutation builder.
  47398. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  47399. m.predicates = append(m.predicates, ps...)
  47400. }
  47401. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  47402. // users can use type-assertion to append predicates that do not depend on any generated package.
  47403. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  47404. p := make([]predicate.XunjiService, len(ps))
  47405. for i := range ps {
  47406. p[i] = ps[i]
  47407. }
  47408. m.Where(p...)
  47409. }
  47410. // Op returns the operation name.
  47411. func (m *XunjiServiceMutation) Op() Op {
  47412. return m.op
  47413. }
  47414. // SetOp allows setting the mutation operation.
  47415. func (m *XunjiServiceMutation) SetOp(op Op) {
  47416. m.op = op
  47417. }
  47418. // Type returns the node type of this mutation (XunjiService).
  47419. func (m *XunjiServiceMutation) Type() string {
  47420. return m.typ
  47421. }
  47422. // Fields returns all fields that were changed during this mutation. Note that in
  47423. // order to get all numeric fields that were incremented/decremented, call
  47424. // AddedFields().
  47425. func (m *XunjiServiceMutation) Fields() []string {
  47426. fields := make([]string, 0, 10)
  47427. if m.created_at != nil {
  47428. fields = append(fields, xunjiservice.FieldCreatedAt)
  47429. }
  47430. if m.updated_at != nil {
  47431. fields = append(fields, xunjiservice.FieldUpdatedAt)
  47432. }
  47433. if m.status != nil {
  47434. fields = append(fields, xunjiservice.FieldStatus)
  47435. }
  47436. if m.deleted_at != nil {
  47437. fields = append(fields, xunjiservice.FieldDeletedAt)
  47438. }
  47439. if m.xunji_id != nil {
  47440. fields = append(fields, xunjiservice.FieldXunjiID)
  47441. }
  47442. if m.agent != nil {
  47443. fields = append(fields, xunjiservice.FieldAgentID)
  47444. }
  47445. if m.organization_id != nil {
  47446. fields = append(fields, xunjiservice.FieldOrganizationID)
  47447. }
  47448. if m.wxid != nil {
  47449. fields = append(fields, xunjiservice.FieldWxid)
  47450. }
  47451. if m.api_base != nil {
  47452. fields = append(fields, xunjiservice.FieldAPIBase)
  47453. }
  47454. if m.api_key != nil {
  47455. fields = append(fields, xunjiservice.FieldAPIKey)
  47456. }
  47457. return fields
  47458. }
  47459. // Field returns the value of a field with the given name. The second boolean
  47460. // return value indicates that this field was not set, or was not defined in the
  47461. // schema.
  47462. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  47463. switch name {
  47464. case xunjiservice.FieldCreatedAt:
  47465. return m.CreatedAt()
  47466. case xunjiservice.FieldUpdatedAt:
  47467. return m.UpdatedAt()
  47468. case xunjiservice.FieldStatus:
  47469. return m.Status()
  47470. case xunjiservice.FieldDeletedAt:
  47471. return m.DeletedAt()
  47472. case xunjiservice.FieldXunjiID:
  47473. return m.XunjiID()
  47474. case xunjiservice.FieldAgentID:
  47475. return m.AgentID()
  47476. case xunjiservice.FieldOrganizationID:
  47477. return m.OrganizationID()
  47478. case xunjiservice.FieldWxid:
  47479. return m.Wxid()
  47480. case xunjiservice.FieldAPIBase:
  47481. return m.APIBase()
  47482. case xunjiservice.FieldAPIKey:
  47483. return m.APIKey()
  47484. }
  47485. return nil, false
  47486. }
  47487. // OldField returns the old value of the field from the database. An error is
  47488. // returned if the mutation operation is not UpdateOne, or the query to the
  47489. // database failed.
  47490. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47491. switch name {
  47492. case xunjiservice.FieldCreatedAt:
  47493. return m.OldCreatedAt(ctx)
  47494. case xunjiservice.FieldUpdatedAt:
  47495. return m.OldUpdatedAt(ctx)
  47496. case xunjiservice.FieldStatus:
  47497. return m.OldStatus(ctx)
  47498. case xunjiservice.FieldDeletedAt:
  47499. return m.OldDeletedAt(ctx)
  47500. case xunjiservice.FieldXunjiID:
  47501. return m.OldXunjiID(ctx)
  47502. case xunjiservice.FieldAgentID:
  47503. return m.OldAgentID(ctx)
  47504. case xunjiservice.FieldOrganizationID:
  47505. return m.OldOrganizationID(ctx)
  47506. case xunjiservice.FieldWxid:
  47507. return m.OldWxid(ctx)
  47508. case xunjiservice.FieldAPIBase:
  47509. return m.OldAPIBase(ctx)
  47510. case xunjiservice.FieldAPIKey:
  47511. return m.OldAPIKey(ctx)
  47512. }
  47513. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  47514. }
  47515. // SetField sets the value of a field with the given name. It returns an error if
  47516. // the field is not defined in the schema, or if the type mismatched the field
  47517. // type.
  47518. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  47519. switch name {
  47520. case xunjiservice.FieldCreatedAt:
  47521. v, ok := value.(time.Time)
  47522. if !ok {
  47523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47524. }
  47525. m.SetCreatedAt(v)
  47526. return nil
  47527. case xunjiservice.FieldUpdatedAt:
  47528. v, ok := value.(time.Time)
  47529. if !ok {
  47530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47531. }
  47532. m.SetUpdatedAt(v)
  47533. return nil
  47534. case xunjiservice.FieldStatus:
  47535. v, ok := value.(uint8)
  47536. if !ok {
  47537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47538. }
  47539. m.SetStatus(v)
  47540. return nil
  47541. case xunjiservice.FieldDeletedAt:
  47542. v, ok := value.(time.Time)
  47543. if !ok {
  47544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47545. }
  47546. m.SetDeletedAt(v)
  47547. return nil
  47548. case xunjiservice.FieldXunjiID:
  47549. v, ok := value.(uint64)
  47550. if !ok {
  47551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47552. }
  47553. m.SetXunjiID(v)
  47554. return nil
  47555. case xunjiservice.FieldAgentID:
  47556. v, ok := value.(uint64)
  47557. if !ok {
  47558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47559. }
  47560. m.SetAgentID(v)
  47561. return nil
  47562. case xunjiservice.FieldOrganizationID:
  47563. v, ok := value.(uint64)
  47564. if !ok {
  47565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47566. }
  47567. m.SetOrganizationID(v)
  47568. return nil
  47569. case xunjiservice.FieldWxid:
  47570. v, ok := value.(string)
  47571. if !ok {
  47572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47573. }
  47574. m.SetWxid(v)
  47575. return nil
  47576. case xunjiservice.FieldAPIBase:
  47577. v, ok := value.(string)
  47578. if !ok {
  47579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47580. }
  47581. m.SetAPIBase(v)
  47582. return nil
  47583. case xunjiservice.FieldAPIKey:
  47584. v, ok := value.(string)
  47585. if !ok {
  47586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47587. }
  47588. m.SetAPIKey(v)
  47589. return nil
  47590. }
  47591. return fmt.Errorf("unknown XunjiService field %s", name)
  47592. }
  47593. // AddedFields returns all numeric fields that were incremented/decremented during
  47594. // this mutation.
  47595. func (m *XunjiServiceMutation) AddedFields() []string {
  47596. var fields []string
  47597. if m.addstatus != nil {
  47598. fields = append(fields, xunjiservice.FieldStatus)
  47599. }
  47600. if m.addxunji_id != nil {
  47601. fields = append(fields, xunjiservice.FieldXunjiID)
  47602. }
  47603. if m.addorganization_id != nil {
  47604. fields = append(fields, xunjiservice.FieldOrganizationID)
  47605. }
  47606. return fields
  47607. }
  47608. // AddedField returns the numeric value that was incremented/decremented on a field
  47609. // with the given name. The second boolean return value indicates that this field
  47610. // was not set, or was not defined in the schema.
  47611. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  47612. switch name {
  47613. case xunjiservice.FieldStatus:
  47614. return m.AddedStatus()
  47615. case xunjiservice.FieldXunjiID:
  47616. return m.AddedXunjiID()
  47617. case xunjiservice.FieldOrganizationID:
  47618. return m.AddedOrganizationID()
  47619. }
  47620. return nil, false
  47621. }
  47622. // AddField adds the value to the field with the given name. It returns an error if
  47623. // the field is not defined in the schema, or if the type mismatched the field
  47624. // type.
  47625. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  47626. switch name {
  47627. case xunjiservice.FieldStatus:
  47628. v, ok := value.(int8)
  47629. if !ok {
  47630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47631. }
  47632. m.AddStatus(v)
  47633. return nil
  47634. case xunjiservice.FieldXunjiID:
  47635. v, ok := value.(int64)
  47636. if !ok {
  47637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47638. }
  47639. m.AddXunjiID(v)
  47640. return nil
  47641. case xunjiservice.FieldOrganizationID:
  47642. v, ok := value.(int64)
  47643. if !ok {
  47644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47645. }
  47646. m.AddOrganizationID(v)
  47647. return nil
  47648. }
  47649. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  47650. }
  47651. // ClearedFields returns all nullable fields that were cleared during this
  47652. // mutation.
  47653. func (m *XunjiServiceMutation) ClearedFields() []string {
  47654. var fields []string
  47655. if m.FieldCleared(xunjiservice.FieldStatus) {
  47656. fields = append(fields, xunjiservice.FieldStatus)
  47657. }
  47658. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  47659. fields = append(fields, xunjiservice.FieldDeletedAt)
  47660. }
  47661. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  47662. fields = append(fields, xunjiservice.FieldAPIBase)
  47663. }
  47664. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  47665. fields = append(fields, xunjiservice.FieldAPIKey)
  47666. }
  47667. return fields
  47668. }
  47669. // FieldCleared returns a boolean indicating if a field with the given name was
  47670. // cleared in this mutation.
  47671. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  47672. _, ok := m.clearedFields[name]
  47673. return ok
  47674. }
  47675. // ClearField clears the value of the field with the given name. It returns an
  47676. // error if the field is not defined in the schema.
  47677. func (m *XunjiServiceMutation) ClearField(name string) error {
  47678. switch name {
  47679. case xunjiservice.FieldStatus:
  47680. m.ClearStatus()
  47681. return nil
  47682. case xunjiservice.FieldDeletedAt:
  47683. m.ClearDeletedAt()
  47684. return nil
  47685. case xunjiservice.FieldAPIBase:
  47686. m.ClearAPIBase()
  47687. return nil
  47688. case xunjiservice.FieldAPIKey:
  47689. m.ClearAPIKey()
  47690. return nil
  47691. }
  47692. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  47693. }
  47694. // ResetField resets all changes in the mutation for the field with the given name.
  47695. // It returns an error if the field is not defined in the schema.
  47696. func (m *XunjiServiceMutation) ResetField(name string) error {
  47697. switch name {
  47698. case xunjiservice.FieldCreatedAt:
  47699. m.ResetCreatedAt()
  47700. return nil
  47701. case xunjiservice.FieldUpdatedAt:
  47702. m.ResetUpdatedAt()
  47703. return nil
  47704. case xunjiservice.FieldStatus:
  47705. m.ResetStatus()
  47706. return nil
  47707. case xunjiservice.FieldDeletedAt:
  47708. m.ResetDeletedAt()
  47709. return nil
  47710. case xunjiservice.FieldXunjiID:
  47711. m.ResetXunjiID()
  47712. return nil
  47713. case xunjiservice.FieldAgentID:
  47714. m.ResetAgentID()
  47715. return nil
  47716. case xunjiservice.FieldOrganizationID:
  47717. m.ResetOrganizationID()
  47718. return nil
  47719. case xunjiservice.FieldWxid:
  47720. m.ResetWxid()
  47721. return nil
  47722. case xunjiservice.FieldAPIBase:
  47723. m.ResetAPIBase()
  47724. return nil
  47725. case xunjiservice.FieldAPIKey:
  47726. m.ResetAPIKey()
  47727. return nil
  47728. }
  47729. return fmt.Errorf("unknown XunjiService field %s", name)
  47730. }
  47731. // AddedEdges returns all edge names that were set/added in this mutation.
  47732. func (m *XunjiServiceMutation) AddedEdges() []string {
  47733. edges := make([]string, 0, 1)
  47734. if m.agent != nil {
  47735. edges = append(edges, xunjiservice.EdgeAgent)
  47736. }
  47737. return edges
  47738. }
  47739. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47740. // name in this mutation.
  47741. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  47742. switch name {
  47743. case xunjiservice.EdgeAgent:
  47744. if id := m.agent; id != nil {
  47745. return []ent.Value{*id}
  47746. }
  47747. }
  47748. return nil
  47749. }
  47750. // RemovedEdges returns all edge names that were removed in this mutation.
  47751. func (m *XunjiServiceMutation) RemovedEdges() []string {
  47752. edges := make([]string, 0, 1)
  47753. return edges
  47754. }
  47755. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47756. // the given name in this mutation.
  47757. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  47758. return nil
  47759. }
  47760. // ClearedEdges returns all edge names that were cleared in this mutation.
  47761. func (m *XunjiServiceMutation) ClearedEdges() []string {
  47762. edges := make([]string, 0, 1)
  47763. if m.clearedagent {
  47764. edges = append(edges, xunjiservice.EdgeAgent)
  47765. }
  47766. return edges
  47767. }
  47768. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47769. // was cleared in this mutation.
  47770. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  47771. switch name {
  47772. case xunjiservice.EdgeAgent:
  47773. return m.clearedagent
  47774. }
  47775. return false
  47776. }
  47777. // ClearEdge clears the value of the edge with the given name. It returns an error
  47778. // if that edge is not defined in the schema.
  47779. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  47780. switch name {
  47781. case xunjiservice.EdgeAgent:
  47782. m.ClearAgent()
  47783. return nil
  47784. }
  47785. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  47786. }
  47787. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47788. // It returns an error if the edge is not defined in the schema.
  47789. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  47790. switch name {
  47791. case xunjiservice.EdgeAgent:
  47792. m.ResetAgent()
  47793. return nil
  47794. }
  47795. return fmt.Errorf("unknown XunjiService edge %s", name)
  47796. }